lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20110622181649.2881f439@endymion.delvare>
Date:	Wed, 22 Jun 2011 18:16:49 +0200
From:	Jean Delvare <khali@...ux-fr.org>
To:	Jonathan Cameron <jic23@....ac.uk>
Cc:	Bryan Freed <bfreed@...omium.org>, linux-kernel@...r.kernel.org,
	jbrenner@...sinc.com, gregkh@...e.de, arnd@...db.de,
	"linux-iio@...r.kernel.org" <linux-iio@...r.kernel.org>,
	Amit Kucheria <amit.kucheria@...durent.com>
Subject: Re: [PATCH 1/3] light sensor: Add SMBUS support to the tsl2563
 driver.

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
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ