linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Bryan Wu <bryan.wu@analog.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>,
	linux-input@vger.kernel.org
Subject: Re: [PATCH] Input/Touchscreen Driver: add support AD7877 touchscreen driver (resend to linux-input mailist)
Date: Mon, 4 Feb 2008 12:12:43 -0500	[thread overview]
Message-ID: <20080204115801.ZZRA012@mailhub.coreip.homeip.net> (raw)
In-Reply-To: <1202118758.6286.5.camel@roc-laptop>

Hi Bryan,

On Mon, Feb 04, 2008 at 05:52:38PM +0800, Bryan Wu wrote:
 +
> +	spi_message_add_tail(&req->xfer[0], &req->msg);
> +	spi_message_add_tail(&req->xfer[1], &req->msg);
> +
> +	status = spi_sync(spi, &req->msg);
> +
> +	if (req->msg.status)
> +		status = req->msg.status;
> +

I think the "new way" for spi is to just check return value of
spi_sync and not bother with req->msg.status, but even using
old style spi_sycn I'd expect something like:

	status = spi_sync(spi, &req->msg);
	if (status == 0)
		status = req->msg.status;

> +
> +static ssize_t ad7877_gpio3_store(struct device *dev,
> +				     struct device_attribute *attr,
> +				     const char *buf, size_t count)
> +{
> +	struct ad7877 *ts = dev_get_drvdata(dev);
> +	char *endp;
> +	int i;
> +
> +	i = simple_strtoul(buf, &endp, 10);
> +
> +	if (i)
> +		ts->gpio3=1;
> +	else
> +		ts->gpio3=0;
> +

I am tempted to change the above to ts->gpio3 = !!i;

> +
> +	if (likely(x && z1 && !device_suspended(&ts->spi->dev))) {
> +		/* compute touch pressure resistance using equation #2 */
> +		Rt = z2;
> +		Rt -= z1;
> +		Rt *= x;
> +		Rt *= ts->x_plate_ohms;
> +		Rt /= z1;
> +		Rt = (Rt + 2047) >> 12;
> +	} else
> +		Rt = 0;
> +
> +	if (Rt) {
> +		input_report_abs(input_dev, ABS_X, x);
> +		input_report_abs(input_dev, ABS_Y, y);
> +		input_report_abs(input_dev, ABS_PRESSURE, Rt);
> +		input_sync(input_dev);
> +	}
> +
> +#ifdef	VERBOSE
> +	if (Rt)
> +		pr_debug("%s: %d/%d/%d%s\n", ts->spi->dev.bus_id,
> +			x, y, Rt, Rt ? "" : " UP");

We check the same condition 3 times in a row. The compiler might
combine them but why not help it?

> +
> +static int ad7877_suspend(struct spi_device *spi, pm_message_t message)
> +{
> +	struct ad7877 *ts = dev_get_drvdata(&spi->dev);
> +
> +	spi->dev.power.power_state = message;

I think they are trying to get rid of power_state...

> +	ad7877_disable(ts);
> +
> +	return 0;
> +
> +}
> +
> +static int ad7877_resume(struct spi_device *spi)
> +{
> +	struct ad7877 *ts = dev_get_drvdata(&spi->dev);
> +
> +	spi->dev.power.power_state = PMSG_ON;

Same here.

> +
> +	err = input_register_device(input_dev);
> +	if (err)
> +		goto err_idev;
> +
> +	ts->intr_flag = 0;
> +
> +	return 0;
> +
> +err_idev:
> +	input_dev = NULL; /* so we don't try to free it later */

But we _do_ need to free it if input_register_device() fails.

Thanks.

-- 
Dmitry

  reply	other threads:[~2008-02-04 17:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-04  9:52 [PATCH] Input/Touchscreen Driver: add support AD7877 touchscreen driver (resend to linux-input mailist) Bryan Wu
2008-02-04 17:12 ` Dmitry Torokhov [this message]
2008-02-05 10:27   ` [PATCH] Input/Touchscreen Driver: add support AD7877touchscreen " Hennerich, Michael

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080204115801.ZZRA012@mailhub.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=bryan.wu@analog.com \
    --cc=linux-input@vger.kernel.org \
    --cc=michael.hennerich@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).