From: Joe Perches <joe@perches.com>
To: Daniel Baluta <daniel.baluta@intel.com>
Cc: Kevin Tsai <ktsai@capellamicro.com>,
Wolfram Sang <wsa@the-dreams.de>,
Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Kumar Gala <galak@codeaurora.org>,
Jonathan Cameron <jic23@kernel.org>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald <pmeerw@pmeerw.net>,
Grant Likely <grant.likely@linaro.org>,
Andrew Morton <akpm@linux-foundation.org>,
"David S. Miller" <davem@davemloft.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
Antti Palosaari <crope@iki.fi>,
Archana Patni <archana.patni@linux.intel.com>,
linux-i2c@vger.kernel.org, devicetree@vger.kernel.org,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V1 1/1] iio: Added Capella cm3232 ambient light sensor driver.
Date: Mon, 05 Jan 2015 09:56:51 -0800 [thread overview]
Message-ID: <1420480611.2652.19.camel@perches.com> (raw)
In-Reply-To: <CAEnQRZA6=FK8CaJvh7kxOEAyDLQQE77xZ02UofLUUT67yZG8bg@mail.gmail.com>
On Mon, 2015-01-05 at 19:50 +0200, Daniel Baluta wrote:
> On Mon, Jan 5, 2015 at 6:42 PM, Joe Perches <joe@perches.com> 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@perches.com> 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@capellamicro.com> 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.
cheers, Joe
next prev parent reply other threads:[~2015-01-05 17:56 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 [this message]
[not found] ` <1420480611.2652.19.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
2015-01-10 14:06 ` Jonathan Cameron
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=1420480611.2652.19.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=archana.patni@linux.intel.com \
--cc=crope@iki.fi \
--cc=daniel.baluta@intel.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=galak@codeaurora.org \
--cc=grant.likely@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=ktsai@capellamicro.com \
--cc=lars@metafoo.de \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mchehab@osg.samsung.com \
--cc=pawel.moll@arm.com \
--cc=pmeerw@pmeerw.net \
--cc=robh+dt@kernel.org \
--cc=wsa@the-dreams.de \
/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).