Use kernel's swab16 instead of our own function.

git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@2437 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare committed 2004-04-13 17:52:59 +00:00
1 parent 26aefc15ba
commit ff48783182
8 files changed
+26 -80

No files matched your search

+5 -10
View File
@@ -587,11 +587,6 @@ static int asb100_detach_client(struct i2c_client *client)
return 0;
}
static u16 swap_bytes(u16 val)
{
return (val >> 8) | (val << 8);
}
/* The SMBus locks itself, usually, but nothing may access the Winbond between
bank switches. ISA access must always be locked explicitly!
We ignore the W83781D BUSY flag at this moment - it could lead to deadlocks,
@@ -620,17 +615,17 @@ static int asb100_read_value(struct i2c_client *client, u16 reg)
/* convert from ISA to LM75 I2C addresses */
switch (reg & 0xff) {
case 0x50: /* TEMP */
res = swap_bytes(i2c_smbus_read_word_data (cl, 0));
res = swab16(i2c_smbus_read_word_data (cl, 0));
break;
case 0x52: /* CONFIG */
res = i2c_smbus_read_byte_data(cl, 1);
break;
case 0x53: /* HYST */
res = swap_bytes(i2c_smbus_read_word_data (cl, 2));
res = swab16(i2c_smbus_read_word_data (cl, 2));
break;
case 0x55: /* MAX */
default:
res = swap_bytes(i2c_smbus_read_word_data (cl, 3));
res = swab16(i2c_smbus_read_word_data (cl, 3));
break;
}
}
@@ -668,10 +663,10 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value)
i2c_smbus_write_byte_data(cl, 1, value & 0xff);
break;
case 0x53: /* HYST */
i2c_smbus_write_word_data(cl, 2, swap_bytes(value));
i2c_smbus_write_word_data(cl, 2, swab16(value));
break;
case 0x55: /* MAX */
i2c_smbus_write_word_data(cl, 3, swap_bytes(value));
i2c_smbus_write_word_data(cl, 3, swab16(value));
break;
}
}
+2 -9
View File
@@ -99,7 +99,6 @@ static int ds1621_detect(struct i2c_adapter *adapter, int address,
static void ds1621_init_client(struct i2c_client *client);
static int ds1621_detach_client(struct i2c_client *client);
static u16 swap_bytes(u16 val);
static int ds1621_read_value(struct i2c_client *client, u8 reg);
static int ds1621_write_value(struct i2c_client *client, u8 reg, u16 value);
static void ds1621_temp(struct i2c_client *client, int operation,
@@ -281,11 +280,6 @@ static int ds1621_detach_client(struct i2c_client *client)
}
static u16 swap_bytes(u16 val)
{
return (val >> 8) | (val << 8);
}
/* All registers are word-sized, except for the configuration register.
DS1621 uses a high-byte first convention, which is exactly opposite to
the usual practice. */
@@ -295,7 +289,7 @@ static int ds1621_read_value(struct i2c_client *client, u8 reg)
|| (reg == DS1621_REG_TEMP_SLOPE))
return i2c_smbus_read_byte_data(client, reg);
else
return swap_bytes(i2c_smbus_read_word_data(client, reg));
return swab16(i2c_smbus_read_word_data(client, reg));
}
/* All registers are word-sized, except for the configuration register.
@@ -310,8 +304,7 @@ static int ds1621_write_value(struct i2c_client *client, u8 reg, u16 value)
|| (reg == DS1621_REG_TEMP_SLOPE))
return i2c_smbus_write_byte_data(client, reg, value);
else
return i2c_smbus_write_word_data(client, reg,
swap_bytes(value));
return i2c_smbus_write_word_data(client, reg, swab16(value));
}
static void ds1621_init_client(struct i2c_client *client)
+2 -9
View File
@@ -147,7 +147,6 @@ static int gl518_detect(struct i2c_adapter *adapter, int address,
static void gl518_init_client(struct i2c_client *client);
static int gl518_detach_client(struct i2c_client *client);
static u16 swap_bytes(u16 val);
static int gl518_read_value(struct i2c_client *client, u8 reg);
static int gl518_write_value(struct i2c_client *client, u8 reg, u16 value);
static void gl518_update_client(struct i2c_client *client);
@@ -447,18 +446,13 @@ static int gl518_detach_client(struct i2c_client *client)
}
static u16 swap_bytes(u16 val)
{
return (val >> 8) | (val << 8);
}
/* Registers 0x07 to 0x0c are word-sized, others are byte-sized
GL518 uses a high-byte first convention, which is exactly opposite to
the usual practice. */
static int gl518_read_value(struct i2c_client *client, u8 reg)
{
if ((reg >= 0x07) && (reg <= 0x0c))
return swap_bytes(i2c_smbus_read_word_data(client, reg));
return swab16(i2c_smbus_read_word_data(client, reg));
else
return i2c_smbus_read_byte_data(client, reg);
}
@@ -469,8 +463,7 @@ static int gl518_read_value(struct i2c_client *client, u8 reg)
static int gl518_write_value(struct i2c_client *client, u8 reg, u16 value)
{
if ((reg >= 0x07) && (reg <= 0x0c))
return i2c_smbus_write_word_data(client, reg,
swap_bytes(value));
return i2c_smbus_write_word_data(client, reg, swab16(value));
else
return i2c_smbus_write_byte_data(client, reg, value);
}
+2 -9
View File
@@ -146,7 +146,6 @@ static int gl520_detect(struct i2c_adapter *adapter, int address,
static void gl520_init_client(struct i2c_client *client);
static int gl520_detach_client(struct i2c_client *client);
static u16 swap_bytes(u16 val);
static int gl520_read_value(struct i2c_client *client, u8 reg);
static int gl520_write_value(struct i2c_client *client, u8 reg, u16 value);
static void gl520_update_client(struct i2c_client *client);
@@ -398,18 +397,13 @@ static int gl520_detach_client(struct i2c_client *client)
}
static u16 swap_bytes(u16 val)
{
return (val >> 8) | (val << 8);
}
/* Registers 0x07 to 0x0c are word-sized, others are byte-sized
GL520 uses a high-byte first convention, which is exactly opposite to
the usual practice. */
static int gl520_read_value(struct i2c_client *client, u8 reg)
{
if ((reg >= 0x07) && (reg <= 0x0c))
return swap_bytes(i2c_smbus_read_word_data(client, reg));
return swab16(i2c_smbus_read_word_data(client, reg));
else
return i2c_smbus_read_byte_data(client, reg);
}
@@ -420,8 +414,7 @@ static int gl520_read_value(struct i2c_client *client, u8 reg)
static int gl520_write_value(struct i2c_client *client, u8 reg, u16 value)
{
if ((reg >= 0x07) && (reg <= 0x0c))
return i2c_smbus_write_word_data(client, reg,
swap_bytes(value));
return i2c_smbus_write_word_data(client, reg, swab16(value));
else
return i2c_smbus_write_byte_data(client, reg, value);
}
+2 -9
View File
@@ -60,7 +60,6 @@ static int lm75_detect(struct i2c_adapter *adapter, int address,
static void lm75_init_client(struct i2c_client *client);
static int lm75_detach_client(struct i2c_client *client);
static u16 swap_bytes(u16 val);
static int lm75_read_value(struct i2c_client *client, u8 reg);
static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value);
static void lm75_temp(struct i2c_client *client, int operation,
@@ -218,11 +217,6 @@ static int lm75_detach_client(struct i2c_client *client)
return 0;
}
static u16 swap_bytes(u16 val)
{
return (val >> 8) | (val << 8);
}
/* All registers are word-sized, except for the configuration register.
LM75 uses a high-byte first convention, which is exactly opposite to
the usual practice. */
@@ -231,7 +225,7 @@ static int lm75_read_value(struct i2c_client *client, u8 reg)
if (reg == LM75_REG_CONF)
return i2c_smbus_read_byte_data(client, reg);
else
return swap_bytes(i2c_smbus_read_word_data(client, reg));
return swab16(i2c_smbus_read_word_data(client, reg));
}
/* All registers are word-sized, except for the configuration register.
@@ -242,8 +236,7 @@ static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value)
if (reg == LM75_REG_CONF)
return i2c_smbus_write_byte_data(client, reg, value);
else
return i2c_smbus_write_word_data(client, reg,
swap_bytes(value));
return i2c_smbus_write_word_data(client, reg, swab16(value));
}
static void lm75_init_client(struct i2c_client *client)
+5 -3
View File
@@ -126,7 +126,7 @@ static inline int lm92_read16 (struct i2c_client *client,u8 reg,u16 *value)
if (tmp < 0) return (-EIO);
/* convert the data to little endian format */
*value = ((u16) tmp >> 8) | (u16) ((u16) tmp << 8);
*value = swab16((u16) tmp);
return (0);
}
@@ -134,8 +134,10 @@ static inline int lm92_read16 (struct i2c_client *client,u8 reg,u16 *value)
static inline int lm92_write16 (struct i2c_client *client,u8 reg,u16 value)
{
/* convert the data to big endian format */
u16 be = (value >> 8) | (u16) (value << 8);
return (i2c_smbus_write_word_data (client,reg,be) < 0 ? -EIO : 0);
if (i2c_smbus_write_word_data(client, reg, swab16(value)) < 0)
return -EIO;
return 0;
}
static int lm92_read (struct i2c_client *client)
+2 -10
View File
@@ -102,7 +102,6 @@ static int smartbatt_detach_client(struct i2c_client *client);
static int smartbatt_read(struct i2c_client *client, u8 reg);
#if 0
static u16 swap_bytes(u16 val);
static int smartbatt_write_value(struct i2c_client *client, u8 reg, u16 value);
#endif
static void smartbatt_temp(struct i2c_client *client, int operation,
@@ -321,14 +320,6 @@ static int smartbatt_detach_client(struct i2c_client *client)
return 0;
}
#if 0
/* Why swap bytes? */
static u16 swap_bytes(u16 val)
{
return (val >> 8) | (val << 8);
}
#endif
static int smartbatt_read(struct i2c_client *client, u8 reg)
{
int n = COMM_TIMEOUT;
@@ -342,7 +333,8 @@ static int smartbatt_read(struct i2c_client *client, u8 reg)
#if 0
static int smartbatt_write_value(struct i2c_client *client, u8 reg, u16 value)
{
return i2c_smbus_write_word_data(client, reg, swap_bytes(value));
/* Why swap bytes? */
return i2c_smbus_write_word_data(client, reg, swab16(value));
}
#endif
+6 -21
View File
@@ -327,7 +327,6 @@ static void w83781d_sens(struct i2c_client *client, int operation,
static void w83781d_rt(struct i2c_client *client, int operation,
int ctl_name, int *nrels_mag, long *results);
#endif
static u16 swap_bytes(u16 val);
static int w83781d_id = 0;
@@ -1127,11 +1126,6 @@ static int w83781d_detach_client(struct i2c_client *client)
return 0;
}
static inline u16 swap_bytes(u16 val)
{
return (val >> 8) | (val << 8);
}
/* The SMBus locks itself, usually, but nothing may access the Winbond between
bank switches. ISA access must always be locked explicitly!
We ignore the W83781D BUSY flag at this moment - it could lead to deadlocks,
@@ -1186,23 +1180,17 @@ static int w83781d_read_value(struct i2c_client *client, u16 reg)
/* convert from ISA to LM75 I2C addresses */
switch (reg & 0xff) {
case 0x50: /* TEMP */
res =
swap_bytes(i2c_smbus_read_word_data
(cl, 0));
res = swab16(i2c_smbus_read_word_data(cl, 0));
break;
case 0x52: /* CONFIG */
res = i2c_smbus_read_byte_data(cl, 1);
break;
case 0x53: /* HYST */
res =
swap_bytes(i2c_smbus_read_word_data
(cl, 2));
res = swab16(i2c_smbus_read_word_data(cl, 2));
break;
case 0x55: /* OVER */
default:
res =
swap_bytes(i2c_smbus_read_word_data
(cl, 3));
res = swab16(i2c_smbus_read_word_data(cl, 3));
break;
}
}
@@ -1261,16 +1249,13 @@ static int w83781d_write_value(struct i2c_client *client, u16 reg, u16 value)
/* convert from ISA to LM75 I2C addresses */
switch (reg & 0xff) {
case 0x52: /* CONFIG */
i2c_smbus_write_byte_data(cl, 1,
value & 0xff);
i2c_smbus_write_byte_data(cl, 1, value & 0xff);
break;
case 0x53: /* HYST */
i2c_smbus_write_word_data(cl, 2,
swap_bytes(value));
i2c_smbus_write_word_data(cl, 2, swab16(value));
break;
case 0x55: /* OVER */
i2c_smbus_write_word_data(cl, 3,
swap_bytes(value));
i2c_smbus_write_word_data(cl, 3, swab16(value));
break;
}
}