* [lm-sensors] Use of swab16() in drivers/hwmon/*.c @ 2011-01-07 10:37 Roland Stigge 2011-01-07 10:59 ` Jean Delvare 2011-01-07 12:56 ` Roland Stigge 0 siblings, 2 replies; 3+ messages in thread From: Roland Stigge @ 2011-01-07 10:37 UTC (permalink / raw) To: lm-sensors Hi, I wonder about a specific use of swab16() in several files in drivers/hwmon/. Consider ds1621.c: We get big endian words from i2c_smbus_read_word_data(). To use it on a little endian arch, the driver uses swab16() for conversion by swapping bytes unconditionally. IMHO this is not suitable on a big endian architecture. Shouldn't it be sth. like be16_to_cpu()? Thanks in advance. bye, Roland _______________________________________________ lm-sensors mailing list lm-sensors@lm-sensors.org http://lists.lm-sensors.org/mailman/listinfo/lm-sensors ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [lm-sensors] Use of swab16() in drivers/hwmon/*.c 2011-01-07 10:37 [lm-sensors] Use of swab16() in drivers/hwmon/*.c Roland Stigge @ 2011-01-07 10:59 ` Jean Delvare 2011-01-07 12:56 ` Roland Stigge 1 sibling, 0 replies; 3+ messages in thread From: Jean Delvare @ 2011-01-07 10:59 UTC (permalink / raw) To: lm-sensors Hallo Roland, On Fri, 07 Jan 2011 11:37:15 +0100, Roland Stigge wrote: > I wonder about a specific use of swab16() in several files > in drivers/hwmon/. > > Consider ds1621.c: We get big endian words from > i2c_smbus_read_word_data(). To use it on a little endian arch, the > driver uses swab16() for conversion by swapping bytes unconditionally. > > IMHO this is not suitable on a big endian architecture. Shouldn't it be > sth. like be16_to_cpu()? This has nothing to do with the host's endianess. This has to do with the fact that the SMBus specification says that words are sent low byte first but almost all hardware monitoring devices send the high byte first (because it makes a lot more sense.) -- Jean Delvare _______________________________________________ lm-sensors mailing list lm-sensors@lm-sensors.org http://lists.lm-sensors.org/mailman/listinfo/lm-sensors ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [lm-sensors] Use of swab16() in drivers/hwmon/*.c 2011-01-07 10:37 [lm-sensors] Use of swab16() in drivers/hwmon/*.c Roland Stigge 2011-01-07 10:59 ` Jean Delvare @ 2011-01-07 12:56 ` Roland Stigge 1 sibling, 0 replies; 3+ messages in thread From: Roland Stigge @ 2011-01-07 12:56 UTC (permalink / raw) To: lm-sensors Hi, On 01/07/2011 11:59 AM, Jean Delvare wrote: > This has nothing to do with the host's endianess. This has to do with > the fact that the SMBus specification says that words are sent low byte > first but almost all hardware monitoring devices send the high byte > first (because it makes a lot more sense.) Thanks! I just ignored that the word implementation of Linux' SMBus (I2C_SMBUS_WORD_DATA etc.) already takes care of that. bye, Roland _______________________________________________ lm-sensors mailing list lm-sensors@lm-sensors.org http://lists.lm-sensors.org/mailman/listinfo/lm-sensors ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-07 12:56 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-01-07 10:37 [lm-sensors] Use of swab16() in drivers/hwmon/*.c Roland Stigge 2011-01-07 10:59 ` Jean Delvare 2011-01-07 12:56 ` Roland Stigge
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.