From: Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>,
Daniel Baluta
<daniel.baluta-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Kevin Tsai <ktsai-GubuWUlQtMwciDkP5Hr2oA@public.gmane.org>,
Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
Ian Campbell
<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
Kumar Gala <galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org>,
Hartmut Knaack <knaack.h-Mmb7MZpHnFY@public.gmane.org>,
Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>,
Peter Meerwald <pmeerw-jW+XmwGofnusTnJN9+BGXg@public.gmane.org>,
Grant Likely
<grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Andrew Morton
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
Greg Kroah-Hartman
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
Mauro Carvalho Chehab
<mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org>,
Antti Palosaari <crope-X3B1VOXEql0@public.gmane.org>,
Archana Patni
<archana.patni-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
"linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Linux Kernel Mailing List
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH V1 1/1] iio: Added Capella cm3232 ambient light sensor driver.
Date: Sat, 10 Jan 2015 14:06:15 +0000 [thread overview]
Message-ID: <54B131D7.4040705@kernel.org> (raw)
In-Reply-To: <1420480611.2652.19.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
On 05/01/15 17:56, Joe Perches wrote:
> On Mon, 2015-01-05 at 19:50 +0200, Daniel Baluta wrote:
>> On Mon, Jan 5, 2015 at 6:42 PM, Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org> wrote:
>>> On Mon, 2015-01-05 at 16:20 +0200, Daniel Baluta wrote:
>>>> On Mon, Jan 5, 2015 at 3:09 PM, Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org> wrote:
>>>>> On Mon, 2015-01-05 at 12:51 +0200, Daniel Baluta wrote:
>>>>>> On Thu, Jan 1, 2015 at 2:10 AM, Kevin Tsai <ktsai-GubuWUlQtMwciDkP5Hr2oA@public.gmane.org> wrote:
>>>>>>> CM3232 is an advanced ambient light sensor with I2C protocol interface.
>>>>>>> The I2C slave address is internally hardwired as 0x10 (7-bit). Writing
>>>>>>> to configure register is byte mode, but reading ALS register requests to
>>>>>>> use word mode for 16-bit resolution.
>>> []
>>>>>> You could directly return i2c_smbus_write_byte_data(..).
>>>>>
>>>>> Sometimes it's better to return a specific value
>>>>> for the error instead of depending on correctness
>>>>> of all the indirect functions in the call chain.
>>>>>
>>>>> In this case, all the smbus_xfer functions must
>>>>> return 0 on success. Do they?
>>>>
>>>> Yes.
>>>>
>>>> http://lxr.free-electrons.com/source/drivers/i2c/i2c-core.c#L2845
>>>
>>> This doesn't show that adapter->algo->smbus_xfer()
>>> returns 0, you have to look at the code for that
>>> indirectly called function.
>>
>> I based my answer on the comment at the top of the function:
>>
>> 2845 * This executes an SMBus protocol operation, and returns a negative
>> 2846 * errno code else zero on success.
>
> Sure, but comments and code often differ and the
> implementation of any of those smbus_xfer functions
> could return a positive value like the byte value or
> the number of bytes written instead of 0.
>
> For correctness, you'd have to inspect them all.
>
> If some new future smbus_xfer function was written
> incorrectly, the return value from this function could
> now be positive.
>
That would however, clearly be a bug and likely to cause all
sorts of issues elsewhere given the documentation requires that
it does return 0 on success and people will have been
relying on it.
Jonathan
> cheers, Joe
>
prev parent reply other threads:[~2015-01-10 14:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-01 0:10 [PATCH V1 1/1] iio: Added Capella cm3232 ambient light sensor driver Kevin Tsai
2015-01-01 3:38 ` Jeremiah Mahler
2015-01-05 10:51 ` Daniel Baluta
[not found] ` <CAEnQRZBD2NMYRp1cW0J2ssT4CT=0jSM=X6ByHQiUrA0ueV8fRA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-05 13:09 ` Joe Perches
[not found] ` <1420463396.2652.8.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
2015-01-05 14:20 ` Daniel Baluta
2015-01-05 16:42 ` Joe Perches
[not found] ` <1420476166.2652.14.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
2015-01-05 17:50 ` Daniel Baluta
2015-01-05 17:56 ` Joe Perches
[not found] ` <1420480611.2652.19.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
2015-01-10 14:06 ` Jonathan Cameron [this message]
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=54B131D7.4040705@kernel.org \
--to=jic23-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=archana.patni-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=crope-X3B1VOXEql0@public.gmane.org \
--cc=daniel.baluta-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org \
--cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
--cc=joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org \
--cc=knaack.h-Mmb7MZpHnFY@public.gmane.org \
--cc=ktsai-GubuWUlQtMwciDkP5Hr2oA@public.gmane.org \
--cc=lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=mchehab-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org \
--cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
--cc=pmeerw-jW+XmwGofnusTnJN9+BGXg@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org \
/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).