[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120509090500.1dc9143e@endymion.delvare>
Date: Wed, 9 May 2012 09:05:00 +0200
From: Jean Delvare <khali@...ux-fr.org>
To: Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc: Daniel Kurtz <djkurtz@...omium.org>,
Henrik Rydberg <rydberg@...omail.se>,
Joonyoung Shim <jy0922.shim@...sung.com>,
Nick Dyer <nick.dyer@...ev.co.uk>, linux-input@...r.kernel.org,
linux-kernel@...r.kernel.org, Benson Leung <bleung@...omium.org>,
Yufeng Shen <miletus@...omium.org>
Subject: Re: [PATCH 03/14 v3] Input: atmel_mxt_ts - refactor
mxt_read/write_reg to take a length
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?
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.
--
Jean Delvare
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists