From: Jean Delvare <khali@linux-fr.org>
To: Jonathan Cameron <jic23@cam.ac.uk>
Cc: Bryan Freed <bfreed@chromium.org>,
linux-kernel@vger.kernel.org, jbrenner@taosinc.com,
gregkh@suse.de, arnd@arndb.de,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
Amit Kucheria <amit.kucheria@verdurent.com>
Subject: Re: [PATCH 1/3] light sensor: Add SMBUS support to the tsl2563 driver.
Date: Wed, 22 Jun 2011 18:16:49 +0200 [thread overview]
Message-ID: <20110622181649.2881f439@endymion.delvare> (raw)
In-Reply-To: <4E02100C.2000408@cam.ac.uk>
On Wed, 22 Jun 2011 16:53:48 +0100, Jonathan Cameron wrote:
> On 06/22/11 15:10, Jean Delvare wrote:
> > On Wed, 22 Jun 2011 10:05:44 +0100, Jonathan Cameron wrote:
> >> On 06/21/11 23:54, Bryan Freed wrote:
> >>> + if (use_smbus) {
> >>> + if (len == 1) {
> >>> + ret = i2c_smbus_read_byte_data(client, cmd);
> >>> + buf[0] = ret & 0xff;
> >>> + } else if (len == 2) {
> >>> + ret = i2c_smbus_read_word_data(client, cmd);
> >>> + buf[0] = ret & 0xff;
> >>> + buf[1] = (ret >> 8) & 0xff;
> >
> > swab16 is your friend (and the bogus SMBus byte order convention be
> > damned.)
>
> I would imagine the be16_to_cpu etc is even better as we don't know the
> cpu endianess.
No, it has to do with SMBus endianess vs. I2C chip endianess, not host
endianess. SMBus specifies that the low byte of a word goes on the wire
first, but almost all I2C and SMBus devices I've see implement it the
other way around, high byte first. i2c-core's
i2c_smbus_read_word_data() stick to the specs, so for almost all I2C
devices, the driver has to swab16 the result.
(I didn't check the TSL2563 datasheet though... maybe this is one of
the rare chips that don't need it.)
--
Jean Delvare
prev parent reply other threads:[~2011-06-22 16:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-21 22:54 [PATCH 1/3] light sensor: Add SMBUS support to the tsl2563 driver Bryan Freed
2011-06-21 22:54 ` [PATCH 2/3] light sensor: Fix a panic in " Bryan Freed
2011-06-22 9:07 ` Jonathan Cameron
2011-06-21 22:54 ` [PATCH 3/3] " Bryan Freed
2011-06-22 9:09 ` Jonathan Cameron
2011-06-22 9:05 ` [PATCH 1/3] light sensor: Add SMBUS support to " Jonathan Cameron
2011-06-22 14:10 ` Jean Delvare
2011-06-22 15:53 ` Jonathan Cameron
2011-06-22 16:16 ` Jean Delvare [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=20110622181649.2881f439@endymion.delvare \
--to=khali@linux-fr.org \
--cc=amit.kucheria@verdurent.com \
--cc=arnd@arndb.de \
--cc=bfreed@chromium.org \
--cc=gregkh@suse.de \
--cc=jbrenner@taosinc.com \
--cc=jic23@cam.ac.uk \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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