Yes, you are right. SMBUS always transfer low byte first. I need to use
swab16() instead.
 
 
Sonic


________________________________

        From: Hennerich, Michael [mailto:[email protected]] 
        Sent: Wednesday, May 12, 2010 5:00 PM
        To: [email protected];
[email protected]
        Subject: RE: [Linux-kernel-commits] [8586]
trunk/drivers/staging/iio/adc/ad7416.c: Task[#5912] Enabled convert pin
mode for ad7417/8 driver.
        
        

        Hi Sonic,

         

        In some of your iio drivers you use cpu_to_be16(data) together
with 

        i2c_smbus_write_word_data(). I think you should better use
swab16().

        Since cpu_to_be16(data) won't flip bytes on BigEndian machines,
however 

        Smbus spec by default transfers Low Byte first no matter which
endian machine is used.

         

         

              case I2C_SMBUS_WORD_DATA:

                    if (read_write == I2C_SMBUS_READ)

                          msg[1].len = 2;

                    else {

                          msg[0].len=3;

                          msgbuf0[1] = data->word & 0xff;

                          msgbuf0[2] = data->word >> 8;

                    }

         

         

        Correct me if I'm wrong - but I think bytes need to be always
swapped, since the AD parts expect high byte first.

         

         

         

        Greetings,

        Michael

         

        Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807
Muenchen

        Sitz der Gesellschaft Muenchen, Registergericht Muenchen HRB
4036

        Geschaeftsfuehrer Thomas Wessel, William A. Martin, Margaret
Seif

         

         

_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to