linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Jean Delvare <khali@linux-fr.org>
Cc: Daniel Kurtz <djkurtz@chromium.org>,
	Henrik Rydberg <rydberg@euromail.se>,
	Joonyoung Shim <jy0922.shim@samsung.com>,
	Nick Dyer <nick.dyer@itdev.co.uk>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Benson Leung <bleung@chromium.org>,
	Yufeng Shen <miletus@chromium.org>
Subject: Re: [PATCH 03/14 v3] Input: atmel_mxt_ts - refactor mxt_read/write_reg to take a length
Date: Wed, 9 May 2012 00:25:18 -0700	[thread overview]
Message-ID: <20120509072517.GH10514@core.coreip.homeip.net> (raw)
In-Reply-To: <20120509090500.1dc9143e@endymion.delvare>

On Wed, May 09, 2012 at 09:05:00AM +0200, Jean Delvare wrote:
> Hi Dmirty,
> 
> On Tue, 8 May 2012 22:54:11 -0700, Dmitry Torokhov wrote:
> > Hi Daniel,
> > 
> > On Wed, Apr 18, 2012 at 09:21:48PM +0800, Daniel Kurtz wrote:
> > > +	ret = i2c_transfer(client->adapter, xfer, 2);
> > > +	if (ret != 2) {
> > > +		dev_err(&client->dev, "i2c read reg failed (%d)\n", ret);
> > > +		if (ret >= 0)
> > > +			ret = -EIO;
> > >  	}
> > >  
> > > -	return 0;
> > > +	return (ret == 2) ? 0 : ret;
> > >  }
> > 
> > Would prefer:
> > 
> > 	ret = i2c_transfer(client->adapter, xfer, ARRAY_SIZE(xfer));
> > 	if (ret != ARRAY_SIZE(xfer)) {
> > 		if (ret >= 0)
> > 			ret = -EIO;
> > 		dev_err(&client->dev, "i2c read reg failed (%d)\n", ret);
> > 		return ret;
> > 	}
> > 
> > 	return 0;
> > 
> > 
> > Or maybe we need i2c_transfer_exact() wrapper? Jean?
> 
> What would this function do? Return 0 on success instead of the number
> of transferred messages? And -EIO on partial transfers?

Yes, exactly.

> 
> That would make sense. Partial success is a rare case anyway, and
> recovery possibilities are even rarer. I think most drivers don't
> bother and either retry the whole transaction or fail right away. In
> fact the number of messages successfully transferred is more useful to
> diagnose problems during driver development or debugging.
> 
> Feel free to write and send a patch introducing i2c_transfer_exact().
> It would make sense to have it log a debug message on partial success,
> as it is a rare case. Bonus points if you also sent one or more patches
> converting (some of) the existing callers to make use of the new
> function.

OK, thanks.

-- 
Dmitry

  reply	other threads:[~2012-05-09  7:25 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-18 13:21 [PATCH 00/14 v3] cleanup atmel_mxt_ts Daniel Kurtz
2012-04-18 13:21 ` [PATCH 01/14 v3] Input: atmel_mxt_ts - use CONFIG_PM_SLEEP Daniel Kurtz
2012-04-18 13:21 ` [PATCH 02/14 v3] Input: atmel_mxt_ts - only allow root to update firmware Daniel Kurtz
2012-04-18 13:21 ` [PATCH 03/14 v3] Input: atmel_mxt_ts - refactor mxt_read/write_reg to take a length Daniel Kurtz
2012-04-24 11:23   ` Henrik Rydberg
2012-05-09  5:50     ` Dmitry Torokhov
2012-05-09  5:54   ` Dmitry Torokhov
2012-05-09  7:05     ` Jean Delvare
2012-05-09  7:25       ` Dmitry Torokhov [this message]
2012-04-18 13:21 ` [PATCH 04/14 v3] Input: atmel_mxt_ts - verify object size in mxt_write_object Daniel Kurtz
2012-04-18 13:21 ` [PATCH 05/14 v3] Input: atmel_mxt_ts - do not read extra (checksum) byte Daniel Kurtz
2012-04-18 13:21 ` [PATCH 06/14 v3] Input: atmel_mxt_ts - dump each message on just 1 line Daniel Kurtz
2012-04-18 13:21 ` [PATCH 07/14 v3] Input: atmel_mxt_ts - refactor mxt_object_show Daniel Kurtz
2012-04-18 13:21 ` [PATCH 08/14 v3] Input: atmel_mxt_ts - optimize writing of object table entries Daniel Kurtz
2012-04-18 13:21 ` [PATCH 09/14 v3] Input: atmel_mxt_ts - refactor get info Daniel Kurtz
2012-05-05 17:41   ` Nick Dyer
2012-05-06  2:43     ` Daniel Kurtz
2012-04-18 13:21 ` [PATCH 10/14 v3] Input: atmel_mxt_ts - simplify event reporting Daniel Kurtz
2012-04-18 13:21 ` [PATCH 11/14 v3] Input: atmel_mxt_ts - cache T9 reportid range when reading object table Daniel Kurtz
2012-04-18 13:21 ` [PATCH 12/14 v3] Input: atmel_mxt_ts - parse vector field of data packets Daniel Kurtz
2012-04-18 13:21 ` [PATCH 13/14 v3] Input: atmel_mxt_ts - send all MT-B slots in one input report Daniel Kurtz
2012-04-18 13:21 ` [PATCH 14/14 v3] Input: atmel_mxt_ts - parse T6 reports Daniel Kurtz
2012-05-04 17:39 ` [PATCH 00/14 v3] cleanup atmel_mxt_ts Daniel Kurtz
2012-05-05 12:16   ` Henrik Rydberg
2012-05-05 13:01     ` Daniel Kurtz
2012-05-09  5:48     ` Dmitry Torokhov

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=20120509072517.GH10514@core.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=bleung@chromium.org \
    --cc=djkurtz@chromium.org \
    --cc=jy0922.shim@samsung.com \
    --cc=khali@linux-fr.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miletus@chromium.org \
    --cc=nick.dyer@itdev.co.uk \
    --cc=rydberg@euromail.se \
    /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).