i2c-tiny-usb: Fix on big-endian systems

The functionality bit vector is always returned as a little-endian
32-bit number by the device, so it must be byte-swapped to the host
endianness.

On the other hand, the delay value is handled by the USB stack, so no
byte swapping is needed on our side.

This fixes bug #15105:
http://bugzilla.kernel.org/show_bug.cgi?id=15105

Reported-by: Jens Richter <jens@richter-stutensee.de>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Tested-by: Jens Richter <jens@richter-stutensee.de>
Cc: Till Harbaum <till@harbaum.org>
Cc: stable@kernel.org

+6 -6
+6 -6
drivers/i2c/busses/i2c-tiny-usb.c
··· 13 13 #include <linux/kernel.h> 14 14 #include <linux/errno.h> 15 15 #include <linux/module.h> 16 + #include <linux/types.h> 16 17 17 18 /* include interfaces to usb layer */ 18 19 #include <linux/usb.h> ··· 32 31 #define CMD_I2C_IO_END (1<<1) 33 32 34 33 /* i2c bit delay, default is 10us -> 100kHz */ 35 - static int delay = 10; 36 - module_param(delay, int, 0); 34 + static unsigned short delay = 10; 35 + module_param(delay, ushort, 0); 37 36 MODULE_PARM_DESC(delay, "bit delay in microseconds, " 38 37 "e.g. 10 for 100kHz (default is 100kHz)"); 39 38 ··· 110 109 111 110 static u32 usb_func(struct i2c_adapter *adapter) 112 111 { 113 - u32 func; 112 + __le32 func; 114 113 115 114 /* get functionality from adapter */ 116 115 if (usb_read(adapter, CMD_GET_FUNC, 0, 0, &func, sizeof(func)) != ··· 119 118 return 0; 120 119 } 121 120 122 - return func; 121 + return le32_to_cpu(func); 123 122 } 124 123 125 124 /* This is the actual algorithm we define */ ··· 217 216 "i2c-tiny-usb at bus %03d device %03d", 218 217 dev->usb_dev->bus->busnum, dev->usb_dev->devnum); 219 218 220 - if (usb_write(&dev->adapter, CMD_SET_DELAY, 221 - cpu_to_le16(delay), 0, NULL, 0) != 0) { 219 + if (usb_write(&dev->adapter, CMD_SET_DELAY, delay, 0, NULL, 0) != 0) { 222 220 dev_err(&dev->adapter.dev, 223 221 "failure setting delay to %dus\n", delay); 224 222 retval = -EIO;