Commit 46e85f5f authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging

* 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging:
  hwmon: (w83627ehf) Add support for the W83627UHG
  hwmon: (w83627ehf) Clean up probe function
  hwmon: (w83627ehf) Properly report PECI and AMD-SI sensor types
  hwmon: Use i2c_smbus_{read,write}_word_swapped
  hwmon: (smsc47b397) Fix checkpatch errors
  hwmon: (lm90) Make code more readable
  hwmon: (lm90) Fix warnings
  hwmon: (ibmaem) Avoid repeated memory allocations
  hwmon: (ibmaem) Make instance initializations independent
  hwmon: (ibmaem) Fix error paths
  hwmon: (lm73) Make detection less problematic
  hwmon: Avoid building drivers for powerpc that read/write ISA addresses
parents b2409fb6 eff7687d
...@@ -14,6 +14,10 @@ Supported chips: ...@@ -14,6 +14,10 @@ Supported chips:
Prefix: 'w83627dhg' Prefix: 'w83627dhg'
Addresses scanned: ISA address retrieved from Super I/O registers Addresses scanned: ISA address retrieved from Super I/O registers
Datasheet: not available Datasheet: not available
* Winbond W83627UHG
Prefix: 'w83627uhg'
Addresses scanned: ISA address retrieved from Super I/O registers
Datasheet: available from www.nuvoton.com
* Winbond W83667HG * Winbond W83667HG
Prefix: 'w83667hg' Prefix: 'w83667hg'
Addresses scanned: ISA address retrieved from Super I/O registers Addresses scanned: ISA address retrieved from Super I/O registers
...@@ -42,14 +46,13 @@ Description ...@@ -42,14 +46,13 @@ Description
----------- -----------
This driver implements support for the Winbond W83627EHF, W83627EHG, This driver implements support for the Winbond W83627EHF, W83627EHG,
W83627DHG, W83627DHG-P, W83667HG, W83667HG-B, W83667HG-I (NCT6775F), W83627DHG, W83627DHG-P, W83627UHG, W83667HG, W83667HG-B, W83667HG-I
and NCT6776F super I/O chips. We will refer to them collectively as (NCT6775F), and NCT6776F super I/O chips. We will refer to them collectively
Winbond chips. as Winbond chips.
The chips implement three temperature sensors (up to four for 667HG-B, and nine The chips implement 2 to 4 temperature sensors (9 for NCT6775F and NCT6776F),
for NCT6775F and NCT6776F), five fan rotation speed sensors, ten analog voltage 2 to 5 fan rotation speed sensors, 8 to 10 analog voltage sensors, one VID
sensors (only nine for the 627DHG), one VID (6 pins for the 627EHF/EHG, 8 pins (except for 627UHG), alarms with beep warnings (control unimplemented),
for the 627DHG and 667HG), alarms with beep warnings (control unimplemented),
and some automatic fan regulation strategies (plus manual fan control mode). and some automatic fan regulation strategies (plus manual fan control mode).
The temperature sensor sources on W82677HG-B, NCT6775F, and NCT6776F are The temperature sensor sources on W82677HG-B, NCT6775F, and NCT6776F are
...@@ -86,17 +89,16 @@ follows: ...@@ -86,17 +89,16 @@ follows:
temp1 -> pwm1 temp1 -> pwm1
temp2 -> pwm2 temp2 -> pwm2
temp3 -> pwm3 temp3 -> pwm3 (not on 627UHG)
prog -> pwm4 (not on 667HG and 667HG-B; the programmable setting is not prog -> pwm4 (not on 667HG and 667HG-B; the programmable setting is not
supported by the driver) supported by the driver)
/sys files /sys files
---------- ----------
name - this is a standard hwmon device entry. For the W83627EHF and W83627EHG, name - this is a standard hwmon device entry, it contains the name of
it is set to "w83627ehf", for the W83627DHG it is set to "w83627dhg", the device (see the prefix in the list of supported devices at
for the W83667HG and W83667HG-B it is set to "w83667hg", for NCT6775F it the top of this file)
is set to "nct6775", and for NCT6776F it is set to "nct6776".
pwm[1-4] - this file stores PWM duty cycle or DC value (fan speed) in range: pwm[1-4] - this file stores PWM duty cycle or DC value (fan speed) in range:
0 (stop) to 255 (full) 0 (stop) to 255 (full)
......
...@@ -335,6 +335,7 @@ config SENSORS_I5K_AMB ...@@ -335,6 +335,7 @@ config SENSORS_I5K_AMB
config SENSORS_F71805F config SENSORS_F71805F
tristate "Fintek F71805F/FG, F71806F/FG and F71872F/FG" tristate "Fintek F71805F/FG, F71806F/FG and F71872F/FG"
depends on !PPC
help help
If you say yes here you get support for hardware monitoring If you say yes here you get support for hardware monitoring
features of the Fintek F71805F/FG, F71806F/FG and F71872F/FG features of the Fintek F71805F/FG, F71806F/FG and F71872F/FG
...@@ -345,6 +346,7 @@ config SENSORS_F71805F ...@@ -345,6 +346,7 @@ config SENSORS_F71805F
config SENSORS_F71882FG config SENSORS_F71882FG
tristate "Fintek F71882FG and compatibles" tristate "Fintek F71882FG and compatibles"
depends on !PPC
help help
If you say yes here you get support for hardware monitoring If you say yes here you get support for hardware monitoring
features of many Fintek Super-I/O (LPC) chips. The currently features of many Fintek Super-I/O (LPC) chips. The currently
...@@ -468,6 +470,7 @@ config SENSORS_IBMPEX ...@@ -468,6 +470,7 @@ config SENSORS_IBMPEX
config SENSORS_IT87 config SENSORS_IT87
tristate "ITE IT87xx and compatibles" tristate "ITE IT87xx and compatibles"
depends on !PPC
select HWMON_VID select HWMON_VID
help help
If you say yes here you get support for ITE IT8705F, IT8712F, If you say yes here you get support for ITE IT8705F, IT8712F,
...@@ -824,6 +827,7 @@ config SENSORS_NTC_THERMISTOR ...@@ -824,6 +827,7 @@ config SENSORS_NTC_THERMISTOR
config SENSORS_PC87360 config SENSORS_PC87360
tristate "National Semiconductor PC87360 family" tristate "National Semiconductor PC87360 family"
depends on !PPC
select HWMON_VID select HWMON_VID
help help
If you say yes here you get access to the hardware monitoring If you say yes here you get access to the hardware monitoring
...@@ -837,6 +841,7 @@ config SENSORS_PC87360 ...@@ -837,6 +841,7 @@ config SENSORS_PC87360
config SENSORS_PC87427 config SENSORS_PC87427
tristate "National Semiconductor PC87427" tristate "National Semiconductor PC87427"
depends on !PPC
help help
If you say yes here you get access to the hardware monitoring If you say yes here you get access to the hardware monitoring
functions of the National Semiconductor PC87427 Super-I/O chip. functions of the National Semiconductor PC87427 Super-I/O chip.
...@@ -928,7 +933,7 @@ config SENSORS_SMM665 ...@@ -928,7 +933,7 @@ config SENSORS_SMM665
config SENSORS_DME1737 config SENSORS_DME1737
tristate "SMSC DME1737, SCH311x and compatibles" tristate "SMSC DME1737, SCH311x and compatibles"
depends on I2C && EXPERIMENTAL depends on I2C && EXPERIMENTAL && !PPC
select HWMON_VID select HWMON_VID
help help
If you say yes here you get support for the hardware monitoring If you say yes here you get support for the hardware monitoring
...@@ -970,6 +975,7 @@ config SENSORS_EMC6W201 ...@@ -970,6 +975,7 @@ config SENSORS_EMC6W201
config SENSORS_SMSC47M1 config SENSORS_SMSC47M1
tristate "SMSC LPC47M10x and compatibles" tristate "SMSC LPC47M10x and compatibles"
depends on !PPC
help help
If you say yes here you get support for the integrated fan If you say yes here you get support for the integrated fan
monitoring and control capabilities of the SMSC LPC47B27x, monitoring and control capabilities of the SMSC LPC47B27x,
...@@ -1003,7 +1009,7 @@ config SENSORS_SMSC47M192 ...@@ -1003,7 +1009,7 @@ config SENSORS_SMSC47M192
config SENSORS_SMSC47B397 config SENSORS_SMSC47B397
tristate "SMSC LPC47B397-NC" tristate "SMSC LPC47B397-NC"
depends on EXPERIMENTAL depends on EXPERIMENTAL && !PPC
help help
If you say yes here you get support for the SMSC LPC47B397-NC If you say yes here you get support for the SMSC LPC47B397-NC
sensor chip. sensor chip.
...@@ -1017,6 +1023,7 @@ config SENSORS_SCH56XX_COMMON ...@@ -1017,6 +1023,7 @@ config SENSORS_SCH56XX_COMMON
config SENSORS_SCH5627 config SENSORS_SCH5627
tristate "SMSC SCH5627" tristate "SMSC SCH5627"
depends on !PPC
select SENSORS_SCH56XX_COMMON select SENSORS_SCH56XX_COMMON
help help
If you say yes here you get support for the hardware monitoring If you say yes here you get support for the hardware monitoring
...@@ -1027,6 +1034,7 @@ config SENSORS_SCH5627 ...@@ -1027,6 +1034,7 @@ config SENSORS_SCH5627
config SENSORS_SCH5636 config SENSORS_SCH5636
tristate "SMSC SCH5636" tristate "SMSC SCH5636"
depends on !PPC
select SENSORS_SCH56XX_COMMON select SENSORS_SCH56XX_COMMON
help help
SMSC SCH5636 Super I/O chips include an embedded microcontroller for SMSC SCH5636 Super I/O chips include an embedded microcontroller for
...@@ -1150,6 +1158,7 @@ config SENSORS_VIA686A ...@@ -1150,6 +1158,7 @@ config SENSORS_VIA686A
config SENSORS_VT1211 config SENSORS_VT1211
tristate "VIA VT1211" tristate "VIA VT1211"
depends on !PPC
select HWMON_VID select HWMON_VID
help help
If you say yes here then you get support for hardware monitoring If you say yes here then you get support for hardware monitoring
...@@ -1262,6 +1271,7 @@ config SENSORS_W83L786NG ...@@ -1262,6 +1271,7 @@ config SENSORS_W83L786NG
config SENSORS_W83627HF config SENSORS_W83627HF
tristate "Winbond W83627HF, W83627THF, W83637HF, W83687THF, W83697HF" tristate "Winbond W83627HF, W83627THF, W83637HF, W83687THF, W83697HF"
depends on !PPC
select HWMON_VID select HWMON_VID
help help
If you say yes here you get support for the Winbond W836X7 series If you say yes here you get support for the Winbond W836X7 series
...@@ -1272,7 +1282,8 @@ config SENSORS_W83627HF ...@@ -1272,7 +1282,8 @@ config SENSORS_W83627HF
will be called w83627hf. will be called w83627hf.
config SENSORS_W83627EHF config SENSORS_W83627EHF
tristate "Winbond W83627EHF/EHG/DHG, W83667HG, NCT6775F, NCT6776F" tristate "Winbond W83627EHF/EHG/DHG/UHG, W83667HG, NCT6775F, NCT6776F"
depends on !PPC
select HWMON_VID select HWMON_VID
help help
If you say yes here you get support for the hardware If you say yes here you get support for the hardware
...@@ -1281,7 +1292,8 @@ config SENSORS_W83627EHF ...@@ -1281,7 +1292,8 @@ config SENSORS_W83627EHF
This driver also supports the W83627EHG, which is the lead-free This driver also supports the W83627EHG, which is the lead-free
version of the W83627EHF, and the W83627DHG, which is a similar version of the W83627EHF, and the W83627DHG, which is a similar
chip suited for specific Intel processors that use PECI such as chip suited for specific Intel processors that use PECI such as
the Core 2 Duo. the Core 2 Duo. And also the W83627UHG, which is a stripped down
version of the W83627DHG (as far as hardware monitoring goes.)
This driver also supports Nuvoton W83667HG, W83667HG-B, NCT6775F This driver also supports Nuvoton W83667HG, W83667HG-B, NCT6775F
(also known as W83667HG-I), and NCT6776F. (also known as W83667HG-I), and NCT6776F.
......
...@@ -58,10 +58,9 @@ static inline int ad7414_temp_from_reg(s16 reg) ...@@ -58,10 +58,9 @@ static inline int ad7414_temp_from_reg(s16 reg)
static inline int ad7414_read(struct i2c_client *client, u8 reg) static inline int ad7414_read(struct i2c_client *client, u8 reg)
{ {
if (reg == AD7414_REG_TEMP) { if (reg == AD7414_REG_TEMP)
int value = i2c_smbus_read_word_data(client, reg); return i2c_smbus_read_word_swapped(client, reg);
return (value < 0) ? value : swab16(value); else
} else
return i2c_smbus_read_byte_data(client, reg); return i2c_smbus_read_byte_data(client, reg);
} }
......
...@@ -76,20 +76,6 @@ static struct i2c_driver ad7418_driver = { ...@@ -76,20 +76,6 @@ static struct i2c_driver ad7418_driver = {
.id_table = ad7418_id, .id_table = ad7418_id,
}; };
/* All registers are word-sized, except for the configuration registers.
* AD7418 uses a high-byte first convention. Do NOT use those functions to
* access the configuration registers CONF and CONF2, as they are byte-sized.
*/
static inline int ad7418_read(struct i2c_client *client, u8 reg)
{
return swab16(i2c_smbus_read_word_data(client, reg));
}
static inline int ad7418_write(struct i2c_client *client, u8 reg, u16 value)
{
return i2c_smbus_write_word_data(client, reg, swab16(value));
}
static void ad7418_init_client(struct i2c_client *client) static void ad7418_init_client(struct i2c_client *client)
{ {
struct ad7418_data *data = i2c_get_clientdata(client); struct ad7418_data *data = i2c_get_clientdata(client);
...@@ -128,7 +114,9 @@ static struct ad7418_data *ad7418_update_device(struct device *dev) ...@@ -128,7 +114,9 @@ static struct ad7418_data *ad7418_update_device(struct device *dev)
udelay(30); udelay(30);
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
data->temp[i] = ad7418_read(client, AD7418_REG_TEMP[i]); data->temp[i] =
i2c_smbus_read_word_swapped(client,
AD7418_REG_TEMP[i]);
} }
for (i = 0, ch = 4; i < data->adc_max; i++, ch--) { for (i = 0, ch = 4; i < data->adc_max; i++, ch--) {
...@@ -138,11 +126,12 @@ static struct ad7418_data *ad7418_update_device(struct device *dev) ...@@ -138,11 +126,12 @@ static struct ad7418_data *ad7418_update_device(struct device *dev)
udelay(15); udelay(15);
data->in[data->adc_max - 1 - i] = data->in[data->adc_max - 1 - i] =
ad7418_read(client, AD7418_REG_ADC); i2c_smbus_read_word_swapped(client,
AD7418_REG_ADC);
} }
/* restore old configuration value */ /* restore old configuration value */
ad7418_write(client, AD7418_REG_CONF, cfg); i2c_smbus_write_word_swapped(client, AD7418_REG_CONF, cfg);
data->last_updated = jiffies; data->last_updated = jiffies;
data->valid = 1; data->valid = 1;
...@@ -182,7 +171,9 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr, ...@@ -182,7 +171,9 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr,
mutex_lock(&data->lock); mutex_lock(&data->lock);
data->temp[attr->index] = LM75_TEMP_TO_REG(temp); data->temp[attr->index] = LM75_TEMP_TO_REG(temp);
ad7418_write(client, AD7418_REG_TEMP[attr->index], data->temp[attr->index]); i2c_smbus_write_word_swapped(client,
AD7418_REG_TEMP[attr->index],
data->temp[attr->index]);
mutex_unlock(&data->lock); mutex_unlock(&data->lock);
return count; return count;
} }
......
...@@ -59,19 +59,6 @@ struct ads1015_data { ...@@ -59,19 +59,6 @@ struct ads1015_data {
struct ads1015_channel_data channel_data[ADS1015_CHANNELS]; struct ads1015_channel_data channel_data[ADS1015_CHANNELS];
}; };
static s32 ads1015_read_reg(struct i2c_client *client, unsigned int reg)
{
s32 data = i2c_smbus_read_word_data(client, reg);
return (data < 0) ? data : swab16(data);
}
static s32 ads1015_write_reg(struct i2c_client *client, unsigned int reg,
u16 val)
{
return i2c_smbus_write_word_data(client, reg, swab16(val));
}
static int ads1015_read_value(struct i2c_client *client, unsigned int channel, static int ads1015_read_value(struct i2c_client *client, unsigned int channel,
int *value) int *value)
{ {
...@@ -87,7 +74,7 @@ static int ads1015_read_value(struct i2c_client *client, unsigned int channel, ...@@ -87,7 +74,7 @@ static int ads1015_read_value(struct i2c_client *client, unsigned int channel,
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
/* get channel parameters */ /* get channel parameters */
res = ads1015_read_reg(client, ADS1015_CONFIG); res = i2c_smbus_read_word_swapped(client, ADS1015_CONFIG);
if (res < 0) if (res < 0)
goto err_unlock; goto err_unlock;
config = res; config = res;
...@@ -101,13 +88,13 @@ static int ads1015_read_value(struct i2c_client *client, unsigned int channel, ...@@ -101,13 +88,13 @@ static int ads1015_read_value(struct i2c_client *client, unsigned int channel,
config |= (pga & 0x0007) << 9; config |= (pga & 0x0007) << 9;
config |= (data_rate & 0x0007) << 5; config |= (data_rate & 0x0007) << 5;
res = ads1015_write_reg(client, ADS1015_CONFIG, config); res = i2c_smbus_write_word_swapped(client, ADS1015_CONFIG, config);
if (res < 0) if (res < 0)
goto err_unlock; goto err_unlock;
/* wait until conversion finished */ /* wait until conversion finished */
msleep(conversion_time_ms); msleep(conversion_time_ms);
res = ads1015_read_reg(client, ADS1015_CONFIG); res = i2c_smbus_read_word_swapped(client, ADS1015_CONFIG);
if (res < 0) if (res < 0)
goto err_unlock; goto err_unlock;
config = res; config = res;
...@@ -117,7 +104,7 @@ static int ads1015_read_value(struct i2c_client *client, unsigned int channel, ...@@ -117,7 +104,7 @@ static int ads1015_read_value(struct i2c_client *client, unsigned int channel,
goto err_unlock; goto err_unlock;
} }
res = ads1015_read_reg(client, ADS1015_CONVERSION); res = i2c_smbus_read_word_swapped(client, ADS1015_CONVERSION);
if (res < 0) if (res < 0)
goto err_unlock; goto err_unlock;
conversion = res; conversion = res;
......
...@@ -74,13 +74,6 @@ static int ads7828_detect(struct i2c_client *client, ...@@ -74,13 +74,6 @@ static int ads7828_detect(struct i2c_client *client,
static int ads7828_probe(struct i2c_client *client, static int ads7828_probe(struct i2c_client *client,
const struct i2c_device_id *id); const struct i2c_device_id *id);
/* The ADS7828 returns the 12-bit sample in two bytes,
these are read as a word then byte-swapped */
static u16 ads7828_read_value(struct i2c_client *client, u8 reg)
{
return swab16(i2c_smbus_read_word_data(client, reg));
}
static inline u8 channel_cmd_byte(int ch) static inline u8 channel_cmd_byte(int ch)
{ {
/* cmd byte C2,C1,C0 - see datasheet */ /* cmd byte C2,C1,C0 - see datasheet */
...@@ -104,7 +97,8 @@ static struct ads7828_data *ads7828_update_device(struct device *dev) ...@@ -104,7 +97,8 @@ static struct ads7828_data *ads7828_update_device(struct device *dev)
for (ch = 0; ch < ADS7828_NCH; ch++) { for (ch = 0; ch < ADS7828_NCH; ch++) {
u8 cmd = channel_cmd_byte(ch); u8 cmd = channel_cmd_byte(ch);
data->adc_input[ch] = ads7828_read_value(client, cmd); data->adc_input[ch] =
i2c_smbus_read_word_swapped(client, cmd);
} }
data->last_updated = jiffies; data->last_updated = jiffies;
data->valid = 1; data->valid = 1;
...@@ -203,7 +197,7 @@ static int ads7828_detect(struct i2c_client *client, ...@@ -203,7 +197,7 @@ static int ads7828_detect(struct i2c_client *client,
for (ch = 0; ch < ADS7828_NCH; ch++) { for (ch = 0; ch < ADS7828_NCH; ch++) {
u16 in_data; u16 in_data;
u8 cmd = channel_cmd_byte(ch); u8 cmd = channel_cmd_byte(ch);
in_data = ads7828_read_value(client, cmd); in_data = i2c_smbus_read_word_swapped(client, cmd);
if (in_data & 0xF000) { if (in_data & 0xF000) {
pr_debug("%s : Doesn't look like an ads7828 device\n", pr_debug("%s : Doesn't look like an ads7828 device\n",
__func__); __func__);
......
...@@ -829,17 +829,17 @@ static int asb100_read_value(struct i2c_client *client, u16 reg) ...@@ -829,17 +829,17 @@ static int asb100_read_value(struct i2c_client *client, u16 reg)
/* convert from ISA to LM75 I2C addresses */ /* convert from ISA to LM75 I2C addresses */
switch (reg & 0xff) { switch (reg & 0xff) {
case 0x50: /* TEMP */ case 0x50: /* TEMP */
res = swab16(i2c_smbus_read_word_data(cl, 0)); res = i2c_smbus_read_word_swapped(cl, 0);
break; break;
case 0x52: /* CONFIG */ case 0x52: /* CONFIG */
res = i2c_smbus_read_byte_data(cl, 1); res = i2c_smbus_read_byte_data(cl, 1);
break; break;
case 0x53: /* HYST */ case 0x53: /* HYST */
res = swab16(i2c_smbus_read_word_data(cl, 2)); res = i2c_smbus_read_word_swapped(cl, 2);
break; break;
case 0x55: /* MAX */ case 0x55: /* MAX */
default: default:
res = swab16(i2c_smbus_read_word_data(cl, 3)); res = i2c_smbus_read_word_swapped(cl, 3);
break; break;
} }
} }
...@@ -877,10 +877,10 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value) ...@@ -877,10 +877,10 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value)
i2c_smbus_write_byte_data(cl, 1, value & 0xff); i2c_smbus_write_byte_data(cl, 1, value & 0xff);
break; break;
case 0x53: /* HYST */ case 0x53: /* HYST */
i2c_smbus_write_word_data(cl, 2, swab16(value)); i2c_smbus_write_word_swapped(cl, 2, value);
break; break;
case 0x55: /* MAX */ case 0x55: /* MAX */
i2c_smbus_write_word_data(cl, 3, swab16(value)); i2c_smbus_write_word_swapped(cl, 3, value);
break; break;
} }
} }
......
...@@ -80,24 +80,6 @@ struct ds1621_data { ...@@ -80,24 +80,6 @@ struct ds1621_data {
u8 conf; /* Register encoding, combined */ u8 conf; /* Register encoding, combined */
}; };
/* Temperature registers are word-sized.
DS1621 uses a high-byte first convention, which is exactly opposite to
the SMBus standard. */
static int ds1621_read_temp(struct i2c_client *client, u8 reg)
{
int ret;
ret = i2c_smbus_read_word_data(client, reg);
if (ret < 0)
return ret;
return swab16(ret);
}
static int ds1621_write_temp(struct i2c_client *client, u8 reg, u16 value)
{
return i2c_smbus_write_word_data(client, reg, swab16(value));
}
static void ds1621_init_client(struct i2c_client *client) static void ds1621_init_client(struct i2c_client *client)
{ {
u8 conf, new_conf; u8 conf, new_conf;
...@@ -136,7 +118,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev) ...@@ -136,7 +118,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev)
data->conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF); data->conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF);
for (i = 0; i < ARRAY_SIZE(data->temp); i++) for (i = 0; i < ARRAY_SIZE(data->temp); i++)
data->temp[i] = ds1621_read_temp(client, data->temp[i] = i2c_smbus_read_word_swapped(client,
DS1621_REG_TEMP[i]); DS1621_REG_TEMP[i]);
/* reset alarms if necessary */ /* reset alarms if necessary */
...@@ -177,8 +159,8 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da, ...@@ -177,8 +159,8 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->temp[attr->index] = val; data->temp[attr->index] = val;
ds1621_write_temp(client, DS1621_REG_TEMP[attr->index], i2c_smbus_write_word_swapped(client, DS1621_REG_TEMP[attr->index],
data->temp[attr->index]); data->temp[attr->index]);
mutex_unlock(&data->update_lock); mutex_unlock(&data->update_lock);
return count; return count;
} }
......
...@@ -75,33 +75,13 @@ struct ds620_data { ...@@ -75,33 +75,13 @@ struct ds620_data {
s16 temp[3]; /* Register values, word */ s16 temp[3]; /* Register values, word */
}; };
/*
* Temperature registers are word-sized.
* DS620 uses a high-byte first convention, which is exactly opposite to
* the SMBus standard.
*/
static int ds620_read_temp(struct i2c_client *client, u8 reg)
{
int ret;
ret = i2c_smbus_read_word_data(client, reg);
if (ret < 0)
return ret;
return swab16(ret);
}
static int ds620_write_temp(struct i2c_client *client, u8 reg, u16 value)
{
return i2c_smbus_write_word_data(client, reg, swab16(value));
}
static void ds620_init_client(struct i2c_client *client) static void ds620_init_client(struct i2c_client *client)
{ {
struct ds620_platform_data *ds620_info = client->dev.platform_data; struct ds620_platform_data *ds620_info = client->dev.platform_data;
u16 conf, new_conf; u16 conf, new_conf;
new_conf = conf = new_conf = conf =
swab16(i2c_smbus_read_word_data(client, DS620_REG_CONF)); i2c_smbus_read_word_swapped(client, DS620_REG_CONF);
/* switch to continuous conversion mode */ /* switch to continuous conversion mode */
new_conf &= ~DS620_REG_CONFIG_1SHOT; new_conf &= ~DS620_REG_CONFIG_1SHOT;
...@@ -118,8 +98,7 @@ static void ds620_init_client(struct i2c_client *client) ...@@ -118,8 +98,7 @@ static void ds620_init_client(struct i2c_client *client)
new_conf |= DS620_REG_CONFIG_R1 | DS620_REG_CONFIG_R0; new_conf |= DS620_REG_CONFIG_R1 | DS620_REG_CONFIG_R0;
if (conf != new_conf) if (conf != new_conf)
i2c_smbus_write_word_data(client, DS620_REG_CONF, i2c_smbus_write_word_swapped(client, DS620_REG_CONF, new_conf);
swab16(new_conf));
/* start conversion */ /* start conversion */
i2c_smbus_write_byte(client, DS620_COM_START); i2c_smbus_write_byte(client, DS620_COM_START);
...@@ -141,8 +120,8 @@ static struct ds620_data *ds620_update_client(struct device *dev) ...@@ -141,8 +120,8 @@ static struct ds620_data *ds620_update_client(struct device *dev)
dev_dbg(&client->dev, "Starting ds620 update\n"); dev_dbg(&client->dev, "Starting ds620 update\n");
for (i = 0; i < ARRAY_SIZE(data->temp); i++) { for (i = 0; i < ARRAY_SIZE(data->temp); i++) {
res = ds620_read_temp(client, res = i2c_smbus_read_word_swapped(client,
DS620_REG_TEMP[i]); DS620_REG_TEMP[i]);
if (res < 0) { if (res < 0) {
ret = ERR_PTR(res); ret = ERR_PTR(res);
goto abort; goto abort;
...@@ -191,8 +170,8 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da, ...@@ -191,8 +170,8 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->temp[attr->index] = val; data->temp[attr->index] = val;
ds620_write_temp(client, DS620_REG_TEMP[attr->index], i2c_smbus_write_word_swapped(client, DS620_REG_TEMP[attr->index],
data->temp[attr->index]); data->temp[attr->index]);
mutex_unlock(&data->update_lock); mutex_unlock(&data->update_lock);
return count; return count;
} }
...@@ -210,16 +189,15 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *da, ...@@ -210,16 +189,15 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *da,
return PTR_ERR(data); return PTR_ERR(data);
/* reset alarms if necessary */ /* reset alarms if necessary */
res = i2c_smbus_read_word_data(client, DS620_REG_CONF); res = i2c_smbus_read_word_swapped(client, DS620_REG_CONF);
if (res < 0) if (res < 0)
return res; return res;
conf = swab16(res); new_conf = conf = res;
new_conf = conf;
new_conf &= ~attr->index; new_conf &= ~attr->index;
if (conf != new_conf) { if (conf != new_conf) {
res = i2c_smbus_write_word_data(client, DS620_REG_CONF, res = i2c_smbus_write_word_swapped(client, DS620_REG_CONF,
swab16(new_conf)); new_conf);
if (res < 0) if (res < 0)
return res; return res;
} }
......
...@@ -591,7 +591,7 @@ static int gl518_remove(struct i2c_client *client) ...@@ -591,7 +591,7 @@ static int gl518_remove(struct i2c_client *client)
static int gl518_read_value(struct i2c_client *client, u8 reg) static int gl518_read_value(struct i2c_client *client, u8 reg)
{ {
if ((reg >= 0x07) && (reg <= 0x0c)) if ((reg >= 0x07) && (reg <= 0x0c))
return swab16(i2c_smbus_read_word_data(client, reg)); return i2c_smbus_read_word_swapped(client, reg);
else else
return i2c_smbus_read_byte_data(client, reg); return i2c_smbus_read_byte_data(client, reg);
} }
...@@ -599,7 +599,7 @@ static int gl518_read_value(struct i2c_client *client, u8 reg) ...@@ -599,7 +599,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) static int gl518_write_value(struct i2c_client *client, u8 reg, u16 value)
{ {
if ((reg >= 0x07) && (reg <= 0x0c)) if ((reg >= 0x07) && (reg <= 0x0c))
return i2c_smbus_write_word_data(client, reg, swab16(value)); return i2c_smbus_write_word_swapped(client, reg, value);
else else
return i2c_smbus_write_byte_data(client, reg, value); return i2c_smbus_write_byte_data(client, reg, value);
} }
......
...@@ -821,7 +821,7 @@ static int gl520_remove(struct i2c_client *client) ...@@ -821,7 +821,7 @@ static int gl520_remove(struct i2c_client *client)
static int gl520_read_value(struct i2c_client *client, u8 reg) static int gl520_read_value(struct i2c_client *client, u8 reg)
{ {
if ((reg >= 0x07) && (reg <= 0x0c)) if ((reg >= 0x07) && (reg <= 0x0c))
return swab16(i2c_smbus_read_word_data(client, reg)); return i2c_smbus_read_word_swapped(client, reg);
else else
return i2c_smbus_read_byte_data(client, reg); return i2c_smbus_read_byte_data(client, reg);
} }
...@@ -829,7 +829,7 @@ static int gl520_read_value(struct i2c_client *client, u8 reg) ...@@ -829,7 +829,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) static int gl520_write_value(struct i2c_client *client, u8 reg, u16 value)
{ {
if ((reg >= 0x07) && (reg <= 0x0c)) if ((reg >= 0x07) && (reg <= 0x0c))
return i2c_smbus_write_word_data(client, reg, swab16(value)); return i2c_smbus_write_word_swapped(client, reg, value);
else else
return i2c_smbus_write_byte_data(client, reg, value); return i2c_smbus_write_byte_data(client, reg, value);
} }
......
...@@ -147,8 +147,9 @@ struct aem_data { ...@@ -147,8 +147,9 @@ struct aem_data {
int id; int id;
struct aem_ipmi_data ipmi; struct aem_ipmi_data ipmi;
/* Function to update sensors */ /* Function and buffer to update sensors */
void (*update)(struct aem_data *data); void (*update)(struct aem_data *data);
struct aem_read_sensor_resp *rs_resp;
/* /*
* AEM 1.x sensors: * AEM 1.x sensors:
...@@ -245,8 +246,6 @@ static void aem_bmc_gone(int iface); ...@@ -245,8 +246,6 @@ static void aem_bmc_gone(int iface);
static void aem_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data); static void aem_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data);
static void aem_remove_sensors(struct aem_data *data); static void aem_remove_sensors(struct aem_data *data);
static int aem_init_aem1(struct aem_ipmi_data *probe);
static int aem_init_aem2(struct aem_ipmi_data *probe);
static int aem1_find_sensors(struct aem_data *data); static int aem1_find_sensors(struct aem_data *data);
static int aem2_find_sensors(struct aem_data *data); static int aem2_find_sensors(struct aem_data *data);
static void update_aem1_sensors(struct aem_data *data); static void update_aem1_sensors(struct aem_data *data);
...@@ -357,13 +356,14 @@ static void aem_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data) ...@@ -357,13 +356,14 @@ static void aem_msg_handler(struct ipmi_recv_msg *msg, void *user_msg_data)
/* Sensor support functions */ /* Sensor support functions */
/* Read a sensor value */ /* Read a sensor value; must be called with data->lock held */
static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg, static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg,
void *buf, size_t size) void *buf, size_t size)
{ {
int rs_size, res; int rs_size, res;
struct aem_read_sensor_req rs_req; struct aem_read_sensor_req rs_req;
struct aem_read_sensor_resp *rs_resp; /* Use preallocated rx buffer */
struct aem_read_sensor_resp *rs_resp = data->rs_resp;
struct aem_ipmi_data *ipmi = &data->ipmi; struct aem_ipmi_data *ipmi = &data->ipmi;
/* AEM registers are 1, 2, 4 or 8 bytes */ /* AEM registers are 1, 2, 4 or 8 bytes */
...@@ -389,10 +389,6 @@ static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg, ...@@ -389,10 +389,6 @@ static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg,
ipmi->tx_message.data_len = sizeof(rs_req); ipmi->tx_message.data_len = sizeof(rs_req);
rs_size = sizeof(*rs_resp) + size; rs_size = sizeof(*rs_resp) + size;
rs_resp = kzalloc(rs_size, GFP_KERNEL);
if (!rs_resp)
return -ENOMEM;
ipmi->rx_msg_data = rs_resp; ipmi->rx_msg_data = rs_resp;
ipmi->rx_msg_len = rs_size; ipmi->rx_msg_len = rs_size;
...@@ -435,7 +431,6 @@ static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg, ...@@ -435,7 +431,6 @@ static int aem_read_sensor(struct aem_data *data, u8 elt, u8 reg,
res = 0; res = 0;
out: out:
kfree(rs_resp);
return res; return res;
} }
...@@ -493,6 +488,7 @@ static void aem_delete(struct aem_data *data) ...@@ -493,6 +488,7 @@ static void aem_delete(struct aem_data *data)
{ {
list_del(&data->list); list_del(&data->list);
aem_remove_sensors(data); aem_remove_sensors(data);
kfree(data->rs_resp);
hwmon_device_unregister(data->hwmon_dev); hwmon_device_unregister(data->hwmon_dev);
ipmi_destroy_user(data->ipmi.user); ipmi_destroy_user(data->ipmi.user);
platform_set_drvdata(data->pdev, NULL); platform_set_drvdata(data->pdev, NULL);
...@@ -570,24 +566,31 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle) ...@@ -570,24 +566,31 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle)
platform_set_drvdata(data->pdev, data); platform_set_drvdata(data->pdev, data);
/* Set up IPMI interface */ /* Set up IPMI interface */
if (aem_init_ipmi_data(&data->ipmi, probe->interface, res = aem_init_ipmi_data(&data->ipmi, probe->interface,
probe->bmc_device)) probe->bmc_device);
if (res)
goto ipmi_err; goto ipmi_err;
/* Register with hwmon */ /* Register with hwmon */
data->hwmon_dev = hwmon_device_register(&data->pdev->dev); data->hwmon_dev = hwmon_device_register(&data->pdev->dev);
if (IS_ERR(data->hwmon_dev)) { if (IS_ERR(data->hwmon_dev)) {
dev_err(&data->pdev->dev, "Unable to register hwmon " dev_err(&data->pdev->dev, "Unable to register hwmon "
"device for IPMI interface %d\n", "device for IPMI interface %d\n",
probe->interface); probe->interface);
res = PTR_ERR(data->hwmon_dev);
goto hwmon_reg_err; goto hwmon_reg_err;
} }
data->update = update_aem1_sensors; data->update = update_aem1_sensors;
data->rs_resp = kzalloc(sizeof(*(data->rs_resp)) + 8, GFP_KERNEL);
if (!data->rs_resp) {
res = -ENOMEM;
goto alloc_resp_err;
}
/* Find sensors */ /* Find sensors */
if (aem1_find_sensors(data)) res = aem1_find_sensors(data);
if (res)
goto sensor_err; goto sensor_err;
/* Add to our list of AEM devices */ /* Add to our list of AEM devices */
...@@ -599,6 +602,8 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle) ...@@ -599,6 +602,8 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle)
return 0; return 0;
sensor_err: sensor_err:
kfree(data->rs_resp);
alloc_resp_err:
hwmon_device_unregister(data->hwmon_dev); hwmon_device_unregister(data->hwmon_dev);
hwmon_reg_err: hwmon_reg_err:
ipmi_destroy_user(data->ipmi.user); ipmi_destroy_user(data->ipmi.user);
...@@ -614,7 +619,7 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle) ...@@ -614,7 +619,7 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle)
} }
/* Find and initialize all AEM1 instances */ /* Find and initialize all AEM1 instances */
static int aem_init_aem1(struct aem_ipmi_data *probe) static void aem_init_aem1(struct aem_ipmi_data *probe)
{ {
int num, i, err; int num, i, err;
...@@ -625,11 +630,8 @@ static int aem_init_aem1(struct aem_ipmi_data *probe) ...@@ -625,11 +630,8 @@ static int aem_init_aem1(struct aem_ipmi_data *probe)
dev_err(probe->bmc_device, dev_err(probe->bmc_device,
"Error %d initializing AEM1 0x%X\n", "Error %d initializing AEM1 0x%X\n",
err, i); err, i);
return err;
} }
} }
return 0;
} }
/* Probe functions for AEM2 devices */ /* Probe functions for AEM2 devices */
...@@ -704,24 +706,31 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe, ...@@ -704,24 +706,31 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe,
platform_set_drvdata(data->pdev, data); platform_set_drvdata(data->pdev, data);
/* Set up IPMI interface */ /* Set up IPMI interface */
if (aem_init_ipmi_data(&data->ipmi, probe->interface, res = aem_init_ipmi_data(&data->ipmi, probe->interface,
probe->bmc_device)) probe->bmc_device);
if (res)
goto ipmi_err; goto ipmi_err;
/* Register with hwmon */ /* Register with hwmon */
data->hwmon_dev = hwmon_device_register(&data->pdev->dev); data->hwmon_dev = hwmon_device_register(&data->pdev->dev);
if (IS_ERR(data->hwmon_dev)) { if (IS_ERR(data->hwmon_dev)) {
dev_err(&data->pdev->dev, "Unable to register hwmon " dev_err(&data->pdev->dev, "Unable to register hwmon "
"device for IPMI interface %d\n", "device for IPMI interface %d\n",
probe->interface); probe->interface);
res = PTR_ERR(data->hwmon_dev);
goto hwmon_reg_err; goto hwmon_reg_err;
} }
data->update = update_aem2_sensors; data->update = update_aem2_sensors;
data->rs_resp = kzalloc(sizeof(*(data->rs_resp)) + 8, GFP_KERNEL);
if (!data->rs_resp) {
res = -ENOMEM;
goto alloc_resp_err;
}
/* Find sensors */ /* Find sensors */
if (aem2_find_sensors(data)) res = aem2_find_sensors(data);
if (res)
goto sensor_err; goto sensor_err;
/* Add to our list of AEM devices */ /* Add to our list of AEM devices */
...@@ -733,6 +742,8 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe, ...@@ -733,6 +742,8 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe,
return 0; return 0;
sensor_err: sensor_err:
kfree(data->rs_resp);
alloc_resp_err:
hwmon_device_unregister(data->hwmon_dev); hwmon_device_unregister(data->hwmon_dev);
hwmon_reg_err: hwmon_reg_err:
ipmi_destroy_user(data->ipmi.user); ipmi_destroy_user(data->ipmi.user);
...@@ -748,7 +759,7 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe, ...@@ -748,7 +759,7 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe,
} }
/* Find and initialize all AEM2 instances */ /* Find and initialize all AEM2 instances */
static int aem_init_aem2(struct aem_ipmi_data *probe) static void aem_init_aem2(struct aem_ipmi_data *probe)
{ {
struct aem_find_instance_resp fi_resp; struct aem_find_instance_resp fi_resp;
int err; int err;
...@@ -767,12 +778,9 @@ static int aem_init_aem2(struct aem_ipmi_data *probe) ...@@ -767,12 +778,9 @@ static int aem_init_aem2(struct aem_ipmi_data *probe)
dev_err(probe->bmc_device, dev_err(probe->bmc_device,
"Error %d initializing AEM2 0x%X\n", "Error %d initializing AEM2 0x%X\n",
err, fi_resp.module_handle); err, fi_resp.module_handle);
return err;
} }
i++; i++;
} }
return 0;
} }
/* Probe a BMC for AEM firmware instances */ /* Probe a BMC for AEM firmware instances */
......
...@@ -154,8 +154,6 @@ static int jc42_probe(struct i2c_client *client, ...@@ -154,8 +154,6 @@ static int jc42_probe(struct i2c_client *client,
const struct i2c_device_id *id); const struct i2c_device_id *id);
static int jc42_detect(struct i2c_client *client, struct i2c_board_info *info); static int jc42_detect(struct i2c_client *client, struct i2c_board_info *info);
static int jc42_remove(struct i2c_client *client); static int jc42_remove(struct i2c_client *client);
static int jc42_read_value(struct i2c_client *client, u8 reg);
static int jc42_write_value(struct i2c_client *client, u8 reg, u16 value);
static struct jc42_data *jc42_update_device(struct device *dev); static struct jc42_data *jc42_update_device(struct device *dev);
...@@ -187,7 +185,7 @@ static int jc42_suspend(struct device *dev) ...@@ -187,7 +185,7 @@ static int jc42_suspend(struct device *dev)
struct jc42_data *data = i2c_get_clientdata(client); struct jc42_data *data = i2c_get_clientdata(client);
data->config |= JC42_CFG_SHUTDOWN; data->config |= JC42_CFG_SHUTDOWN;
jc42_write_value(client, JC42_REG_CONFIG, data->config); i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG, data->config);
return 0; return 0;
} }
...@@ -197,7 +195,7 @@ static int jc42_resume(struct device *dev) ...@@ -197,7 +195,7 @@ static int jc42_resume(struct device *dev)
struct jc42_data *data = i2c_get_clientdata(client); struct jc42_data *data = i2c_get_clientdata(client);
data->config &= ~JC42_CFG_SHUTDOWN; data->config &= ~JC42_CFG_SHUTDOWN;
jc42_write_value(client, JC42_REG_CONFIG, data->config); i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG, data->config);
return 0; return 0;
} }
...@@ -315,7 +313,7 @@ static ssize_t set_##value(struct device *dev, \ ...@@ -315,7 +313,7 @@ static ssize_t set_##value(struct device *dev, \
return -EINVAL; \ return -EINVAL; \
mutex_lock(&data->update_lock); \ mutex_lock(&data->update_lock); \
data->value = jc42_temp_to_reg(val, data->extended); \ data->value = jc42_temp_to_reg(val, data->extended); \
err = jc42_write_value(client, reg, data->value); \ err = i2c_smbus_write_word_swapped(client, reg, data->value); \
if (err < 0) \ if (err < 0) \
ret = err; \ ret = err; \
mutex_unlock(&data->update_lock); \ mutex_unlock(&data->update_lock); \
...@@ -357,7 +355,8 @@ static ssize_t set_temp_crit_hyst(struct device *dev, ...@@ -357,7 +355,8 @@ static ssize_t set_temp_crit_hyst(struct device *dev,
data->config = (data->config data->config = (data->config
& ~(JC42_CFG_HYST_MASK << JC42_CFG_HYST_SHIFT)) & ~(JC42_CFG_HYST_MASK << JC42_CFG_HYST_SHIFT))
| (hyst << JC42_CFG_HYST_SHIFT); | (hyst << JC42_CFG_HYST_SHIFT);
err = jc42_write_value(client, JC42_REG_CONFIG, data->config); err = i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG,
data->config);
if (err < 0) if (err < 0)
ret = err; ret = err;
mutex_unlock(&data->update_lock); mutex_unlock(&data->update_lock);
...@@ -452,10 +451,10 @@ static int jc42_detect(struct i2c_client *new_client, ...@@ -452,10 +451,10 @@ static int jc42_detect(struct i2c_client *new_client,
I2C_FUNC_SMBUS_WORD_DATA)) I2C_FUNC_SMBUS_WORD_DATA))
return -ENODEV; return -ENODEV;
cap = jc42_read_value(new_client, JC42_REG_CAP); cap = i2c_smbus_read_word_swapped(new_client, JC42_REG_CAP);
config = jc42_read_value(new_client, JC42_REG_CONFIG); config = i2c_smbus_read_word_swapped(new_client, JC42_REG_CONFIG);
manid = jc42_read_value(new_client, JC42_REG_MANID); manid = i2c_smbus_read_word_swapped(new_client, JC42_REG_MANID);
devid = jc42_read_value(new_client, JC42_REG_DEVICEID); devid = i2c_smbus_read_word_swapped(new_client, JC42_REG_DEVICEID);
if (cap < 0 || config < 0 || manid < 0 || devid < 0) if (cap < 0 || config < 0 || manid < 0 || devid < 0)
return -ENODEV; return -ENODEV;
...@@ -489,14 +488,14 @@ static int jc42_probe(struct i2c_client *new_client, ...@@ -489,14 +488,14 @@ static int jc42_probe(struct i2c_client *new_client,
i2c_set_clientdata(new_client, data); i2c_set_clientdata(new_client, data);
mutex_init(&data->update_lock); mutex_init(&data->update_lock);
cap = jc42_read_value(new_client, JC42_REG_CAP); cap = i2c_smbus_read_word_swapped(new_client, JC42_REG_CAP);
if (cap < 0) { if (cap < 0) {
err = -EINVAL; err = -EINVAL;
goto exit_free; goto exit_free;
} }
data->extended = !!(cap & JC42_CAP_RANGE); data->extended = !!(cap & JC42_CAP_RANGE);
config = jc42_read_value(new_client, JC42_REG_CONFIG); config = i2c_smbus_read_word_swapped(new_client, JC42_REG_CONFIG);
if (config < 0) { if (config < 0) {
err = -EINVAL; err = -EINVAL;
goto exit_free; goto exit_free;
...@@ -504,7 +503,8 @@ static int jc42_probe(struct i2c_client *new_client, ...@@ -504,7 +503,8 @@ static int jc42_probe(struct i2c_client *new_client,
data->orig_config = config; data->orig_config = config;
if (config & JC42_CFG_SHUTDOWN) { if (config & JC42_CFG_SHUTDOWN) {
config &= ~JC42_CFG_SHUTDOWN; config &= ~JC42_CFG_SHUTDOWN;
jc42_write_value(new_client, JC42_REG_CONFIG, config); i2c_smbus_write_word_swapped(new_client, JC42_REG_CONFIG,
config);
} }
data->config = config; data->config = config;
...@@ -535,25 +535,12 @@ static int jc42_remove(struct i2c_client *client) ...@@ -535,25 +535,12 @@ static int jc42_remove(struct i2c_client *client)
hwmon_device_unregister(data->hwmon_dev); hwmon_device_unregister(data->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &jc42_group); sysfs_remove_group(&client->dev.kobj, &jc42_group);
if (data->config != data->orig_config) if (data->config != data->orig_config)
jc42_write_value(client, JC42_REG_CONFIG, data->orig_config); i2c_smbus_write_word_swapped(client, JC42_REG_CONFIG,
data->orig_config);
kfree(data); kfree(data);
return 0; return 0;
} }
/* All registers are word-sized. */
static int jc42_read_value(struct i2c_client *client, u8 reg)
{
int ret = i2c_smbus_read_word_data(client, reg);
if (ret < 0)
return ret;
return swab16(ret);
}
static int jc42_write_value(struct i2c_client *client, u8 reg, u16 value)
{
return i2c_smbus_write_word_data(client, reg, swab16(value));
}
static struct jc42_data *jc42_update_device(struct device *dev) static struct jc42_data *jc42_update_device(struct device *dev)
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
...@@ -564,28 +551,29 @@ static struct jc42_data *jc42_update_device(struct device *dev) ...@@ -564,28 +551,29 @@ static struct jc42_data *jc42_update_device(struct device *dev)
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ) || !data->valid) { if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
val = jc42_read_value(client, JC42_REG_TEMP); val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP);
if (val < 0) { if (val < 0) {
ret = ERR_PTR(val); ret = ERR_PTR(val);
goto abort; goto abort;
} }
data->temp_input = val; data->temp_input = val;
val = jc42_read_value(client, JC42_REG_TEMP_CRITICAL); val = i2c_smbus_read_word_swapped(client,
JC42_REG_TEMP_CRITICAL);
if (val < 0) { if (val < 0) {
ret = ERR_PTR(val); ret = ERR_PTR(val);
goto abort; goto abort;
} }
data->temp_crit = val; data->temp_crit = val;
val = jc42_read_value(client, JC42_REG_TEMP_LOWER); val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP_LOWER);
if (val < 0) { if (val < 0) {
ret = ERR_PTR(val); ret = ERR_PTR(val);
goto abort; goto abort;
} }
data->temp_min = val; data->temp_min = val;
val = jc42_read_value(client, JC42_REG_TEMP_UPPER); val = i2c_smbus_read_word_swapped(client, JC42_REG_TEMP_UPPER);
if (val < 0) { if (val < 0) {
ret = ERR_PTR(val); ret = ERR_PTR(val);
goto abort; goto abort;
......
...@@ -34,7 +34,7 @@ static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4c, ...@@ -34,7 +34,7 @@ static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4c,
#define LM73_REG_CTRL 0x04 #define LM73_REG_CTRL 0x04
#define LM73_REG_ID 0x07 #define LM73_REG_ID 0x07
#define LM73_ID 0x9001 /* or 0x190 after a swab16() */ #define LM73_ID 0x9001 /* 0x0190, byte-swapped */
#define DRVNAME "lm73" #define DRVNAME "lm73"
#define LM73_TEMP_MIN (-40) #define LM73_TEMP_MIN (-40)
#define LM73_TEMP_MAX 150 #define LM73_TEMP_MAX 150
...@@ -57,7 +57,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da, ...@@ -57,7 +57,7 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *da,
/* Write value */ /* Write value */
value = (short) SENSORS_LIMIT(temp/250, (LM73_TEMP_MIN*4), value = (short) SENSORS_LIMIT(temp/250, (LM73_TEMP_MIN*4),
(LM73_TEMP_MAX*4)) << 5; (LM73_TEMP_MAX*4)) << 5;
i2c_smbus_write_word_data(client, attr->index, swab16(value)); i2c_smbus_write_word_swapped(client, attr->index, value);
return count; return count;
} }
...@@ -68,8 +68,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *da, ...@@ -68,8 +68,8 @@ static ssize_t show_temp(struct device *dev, struct device_attribute *da,
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
/* use integer division instead of equivalent right shift to /* use integer division instead of equivalent right shift to
guarantee arithmetic shift and preserve the sign */ guarantee arithmetic shift and preserve the sign */
int temp = ((s16) (swab16(i2c_smbus_read_word_data(client, int temp = ((s16) (i2c_smbus_read_word_swapped(client,
attr->index)))*250) / 32; attr->index))*250) / 32;
return sprintf(buf, "%d\n", temp); return sprintf(buf, "%d\n", temp);
} }
...@@ -150,17 +150,31 @@ static int lm73_detect(struct i2c_client *new_client, ...@@ -150,17 +150,31 @@ static int lm73_detect(struct i2c_client *new_client,
struct i2c_board_info *info) struct i2c_board_info *info)
{ {
struct i2c_adapter *adapter = new_client->adapter; struct i2c_adapter *adapter = new_client->adapter;
u16 id; int id, ctrl, conf;
u8 ctrl;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
I2C_FUNC_SMBUS_WORD_DATA)) I2C_FUNC_SMBUS_WORD_DATA))
return -ENODEV; return -ENODEV;
/*
* Do as much detection as possible with byte reads first, as word
* reads can confuse other devices.
*/
ctrl = i2c_smbus_read_byte_data(new_client, LM73_REG_CTRL);
if (ctrl < 0 || (ctrl & 0x10))
return -ENODEV;
conf = i2c_smbus_read_byte_data(new_client, LM73_REG_CONF);
if (conf < 0 || (conf & 0x0c))
return -ENODEV;
id = i2c_smbus_read_byte_data(new_client, LM73_REG_ID);
if (id < 0 || id != (LM73_ID & 0xff))
return -ENODEV;
/* Check device ID */ /* Check device ID */
id = i2c_smbus_read_word_data(new_client, LM73_REG_ID); id = i2c_smbus_read_word_data(new_client, LM73_REG_ID);
ctrl = i2c_smbus_read_byte_data(new_client, LM73_REG_CTRL); if (id < 0 || id != LM73_ID)
if ((id != LM73_ID) || (ctrl & 0x10))
return -ENODEV; return -ENODEV;
strlcpy(info->type, "lm73", I2C_NAME_SIZE); strlcpy(info->type, "lm73", I2C_NAME_SIZE);
......
...@@ -384,13 +384,10 @@ static struct i2c_driver lm75_driver = { ...@@ -384,13 +384,10 @@ static struct i2c_driver lm75_driver = {
*/ */
static int lm75_read_value(struct i2c_client *client, u8 reg) static int lm75_read_value(struct i2c_client *client, u8 reg)
{ {
int value;
if (reg == LM75_REG_CONF) if (reg == LM75_REG_CONF)
return i2c_smbus_read_byte_data(client, reg); return i2c_smbus_read_byte_data(client, reg);
else
value = i2c_smbus_read_word_data(client, reg); return i2c_smbus_read_word_swapped(client, reg);
return (value < 0) ? value : swab16(value);
} }
static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value)
...@@ -398,7 +395,7 @@ static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value) ...@@ -398,7 +395,7 @@ static int lm75_write_value(struct i2c_client *client, u8 reg, u16 value)
if (reg == LM75_REG_CONF) if (reg == LM75_REG_CONF)
return i2c_smbus_write_byte_data(client, reg, value); return i2c_smbus_write_byte_data(client, reg, value);
else else
return i2c_smbus_write_word_data(client, reg, swab16(value)); return i2c_smbus_write_word_swapped(client, reg, value);
} }
static struct lm75_data *lm75_update_device(struct device *dev) static struct lm75_data *lm75_update_device(struct device *dev)
......
...@@ -365,7 +365,7 @@ static u16 lm77_read_value(struct i2c_client *client, u8 reg) ...@@ -365,7 +365,7 @@ static u16 lm77_read_value(struct i2c_client *client, u8 reg)
if (reg == LM77_REG_CONF) if (reg == LM77_REG_CONF)
return i2c_smbus_read_byte_data(client, reg); return i2c_smbus_read_byte_data(client, reg);
else else
return swab16(i2c_smbus_read_word_data(client, reg)); return i2c_smbus_read_word_swapped(client, reg);
} }
static int lm77_write_value(struct i2c_client *client, u8 reg, u16 value) static int lm77_write_value(struct i2c_client *client, u8 reg, u16 value)
...@@ -373,7 +373,7 @@ static int lm77_write_value(struct i2c_client *client, u8 reg, u16 value) ...@@ -373,7 +373,7 @@ static int lm77_write_value(struct i2c_client *client, u8 reg, u16 value)
if (reg == LM77_REG_CONF) if (reg == LM77_REG_CONF)
return i2c_smbus_write_byte_data(client, reg, value); return i2c_smbus_write_byte_data(client, reg, value);
else else
return i2c_smbus_write_word_data(client, reg, swab16(value)); return i2c_smbus_write_word_swapped(client, reg, value);
} }
static void lm77_init_client(struct i2c_client *client) static void lm77_init_client(struct i2c_client *client)
......
...@@ -1105,41 +1105,37 @@ static DEVICE_ATTR(pec, S_IWUSR | S_IRUGO, show_pec, set_pec); ...@@ -1105,41 +1105,37 @@ static DEVICE_ATTR(pec, S_IWUSR | S_IRUGO, show_pec, set_pec);
*/ */
/* Return 0 if detection is successful, -ENODEV otherwise */ /* Return 0 if detection is successful, -ENODEV otherwise */
static int lm90_detect(struct i2c_client *new_client, static int lm90_detect(struct i2c_client *client,
struct i2c_board_info *info) struct i2c_board_info *info)
{ {
struct i2c_adapter *adapter = new_client->adapter; struct i2c_adapter *adapter = client->adapter;
int address = new_client->addr; int address = client->addr;
const char *name = NULL; const char *name = NULL;
int man_id, chip_id, reg_config1, reg_config2, reg_convrate; int man_id, chip_id, config1, config2, convrate;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -ENODEV; return -ENODEV;
/* detection and identification */ /* detection and identification */
if ((man_id = i2c_smbus_read_byte_data(new_client, man_id = i2c_smbus_read_byte_data(client, LM90_REG_R_MAN_ID);
LM90_REG_R_MAN_ID)) < 0 chip_id = i2c_smbus_read_byte_data(client, LM90_REG_R_CHIP_ID);
|| (chip_id = i2c_smbus_read_byte_data(new_client, config1 = i2c_smbus_read_byte_data(client, LM90_REG_R_CONFIG1);
LM90_REG_R_CHIP_ID)) < 0 convrate = i2c_smbus_read_byte_data(client, LM90_REG_R_CONVRATE);
|| (reg_config1 = i2c_smbus_read_byte_data(new_client, if (man_id < 0 || chip_id < 0 || config1 < 0 || convrate < 0)
LM90_REG_R_CONFIG1)) < 0
|| (reg_convrate = i2c_smbus_read_byte_data(new_client,
LM90_REG_R_CONVRATE)) < 0)
return -ENODEV; return -ENODEV;
if (man_id == 0x01 || man_id == 0x5C || man_id == 0x41) { if (man_id == 0x01 || man_id == 0x5C || man_id == 0x41) {
reg_config2 = i2c_smbus_read_byte_data(new_client, config2 = i2c_smbus_read_byte_data(client, LM90_REG_R_CONFIG2);
LM90_REG_R_CONFIG2); if (config2 < 0)
if (reg_config2 < 0)
return -ENODEV; return -ENODEV;
} else } else
reg_config2 = 0; /* Make compiler happy */ config2 = 0; /* Make compiler happy */
if ((address == 0x4C || address == 0x4D) if ((address == 0x4C || address == 0x4D)
&& man_id == 0x01) { /* National Semiconductor */ && man_id == 0x01) { /* National Semiconductor */
if ((reg_config1 & 0x2A) == 0x00 if ((config1 & 0x2A) == 0x00
&& (reg_config2 & 0xF8) == 0x00 && (config2 & 0xF8) == 0x00
&& reg_convrate <= 0x09) { && convrate <= 0x09) {
if (address == 0x4C if (address == 0x4C
&& (chip_id & 0xF0) == 0x20) { /* LM90 */ && (chip_id & 0xF0) == 0x20) { /* LM90 */
name = "lm90"; name = "lm90";
...@@ -1163,8 +1159,8 @@ static int lm90_detect(struct i2c_client *new_client, ...@@ -1163,8 +1159,8 @@ static int lm90_detect(struct i2c_client *new_client,
if ((address == 0x4C || address == 0x4D) if ((address == 0x4C || address == 0x4D)
&& man_id == 0x41) { /* Analog Devices */ && man_id == 0x41) { /* Analog Devices */
if ((chip_id & 0xF0) == 0x40 /* ADM1032 */ if ((chip_id & 0xF0) == 0x40 /* ADM1032 */
&& (reg_config1 & 0x3F) == 0x00 && (config1 & 0x3F) == 0x00
&& reg_convrate <= 0x0A) { && convrate <= 0x0A) {
name = "adm1032"; name = "adm1032";
/* The ADM1032 supports PEC, but only if combined /* The ADM1032 supports PEC, but only if combined
transactions are not used. */ transactions are not used. */
...@@ -1173,18 +1169,18 @@ static int lm90_detect(struct i2c_client *new_client, ...@@ -1173,18 +1169,18 @@ static int lm90_detect(struct i2c_client *new_client,
info->flags |= I2C_CLIENT_PEC; info->flags |= I2C_CLIENT_PEC;
} else } else
if (chip_id == 0x51 /* ADT7461 */ if (chip_id == 0x51 /* ADT7461 */
&& (reg_config1 & 0x1B) == 0x00 && (config1 & 0x1B) == 0x00
&& reg_convrate <= 0x0A) { && convrate <= 0x0A) {
name = "adt7461"; name = "adt7461";
} else } else
if (chip_id == 0x57 /* ADT7461A, NCT1008 */ if (chip_id == 0x57 /* ADT7461A, NCT1008 */
&& (reg_config1 & 0x1B) == 0x00 && (config1 & 0x1B) == 0x00
&& reg_convrate <= 0x0A) { && convrate <= 0x0A) {
name = "adt7461a"; name = "adt7461a";
} }
} else } else
if (man_id == 0x4D) { /* Maxim */ if (man_id == 0x4D) { /* Maxim */
int reg_emerg, reg_emerg2, reg_status2; int emerg, emerg2, status2;
/* /*
* We read MAX6659_REG_R_REMOTE_EMERG twice, and re-read * We read MAX6659_REG_R_REMOTE_EMERG twice, and re-read
...@@ -1192,13 +1188,15 @@ static int lm90_detect(struct i2c_client *new_client, ...@@ -1192,13 +1188,15 @@ static int lm90_detect(struct i2c_client *new_client,
* exists, both readings will reflect the same value. Otherwise, * exists, both readings will reflect the same value. Otherwise,
* the readings will be different. * the readings will be different.
*/ */
if ((reg_emerg = i2c_smbus_read_byte_data(new_client, emerg = i2c_smbus_read_byte_data(client,
MAX6659_REG_R_REMOTE_EMERG)) < 0 MAX6659_REG_R_REMOTE_EMERG);
|| i2c_smbus_read_byte_data(new_client, LM90_REG_R_MAN_ID) < 0 man_id = i2c_smbus_read_byte_data(client,
|| (reg_emerg2 = i2c_smbus_read_byte_data(new_client, LM90_REG_R_MAN_ID);
MAX6659_REG_R_REMOTE_EMERG)) < 0 emerg2 = i2c_smbus_read_byte_data(client,
|| (reg_status2 = i2c_smbus_read_byte_data(new_client, MAX6659_REG_R_REMOTE_EMERG);
MAX6696_REG_R_STATUS2)) < 0) status2 = i2c_smbus_read_byte_data(client,
MAX6696_REG_R_STATUS2);
if (emerg < 0 || man_id < 0 || emerg2 < 0 || status2 < 0)
return -ENODEV; return -ENODEV;
/* /*
...@@ -1216,8 +1214,8 @@ static int lm90_detect(struct i2c_client *new_client, ...@@ -1216,8 +1214,8 @@ static int lm90_detect(struct i2c_client *new_client,
*/ */
if (chip_id == man_id if (chip_id == man_id
&& (address == 0x4C || address == 0x4D || address == 0x4E) && (address == 0x4C || address == 0x4D || address == 0x4E)
&& (reg_config1 & 0x1F) == (man_id & 0x0F) && (config1 & 0x1F) == (man_id & 0x0F)
&& reg_convrate <= 0x09) { && convrate <= 0x09) {
if (address == 0x4C) if (address == 0x4C)
name = "max6657"; name = "max6657";
else else
...@@ -1235,10 +1233,10 @@ static int lm90_detect(struct i2c_client *new_client, ...@@ -1235,10 +1233,10 @@ static int lm90_detect(struct i2c_client *new_client,
* one of those registers exists. * one of those registers exists.
*/ */
if (chip_id == 0x01 if (chip_id == 0x01
&& (reg_config1 & 0x10) == 0x00 && (config1 & 0x10) == 0x00
&& (reg_status2 & 0x01) == 0x00 && (status2 & 0x01) == 0x00
&& reg_emerg == reg_emerg2 && emerg == emerg2
&& reg_convrate <= 0x07) { && convrate <= 0x07) {
name = "max6696"; name = "max6696";
} else } else
/* /*
...@@ -1248,8 +1246,8 @@ static int lm90_detect(struct i2c_client *new_client, ...@@ -1248,8 +1246,8 @@ static int lm90_detect(struct i2c_client *new_client,
* second to last bit of config1 (software reset). * second to last bit of config1 (software reset).
*/ */
if (chip_id == 0x01 if (chip_id == 0x01
&& (reg_config1 & 0x03) == 0x00 && (config1 & 0x03) == 0x00
&& reg_convrate <= 0x07) { && convrate <= 0x07) {
name = "max6680"; name = "max6680";
} else } else
/* /*
...@@ -1258,21 +1256,21 @@ static int lm90_detect(struct i2c_client *new_client, ...@@ -1258,21 +1256,21 @@ static int lm90_detect(struct i2c_client *new_client,
* register are unused and should return zero when read. * register are unused and should return zero when read.
*/ */
if (chip_id == 0x59 if (chip_id == 0x59
&& (reg_config1 & 0x3f) == 0x00 && (config1 & 0x3f) == 0x00
&& reg_convrate <= 0x07) { && convrate <= 0x07) {
name = "max6646"; name = "max6646";
} }
} else } else
if (address == 0x4C if (address == 0x4C
&& man_id == 0x5C) { /* Winbond/Nuvoton */ && man_id == 0x5C) { /* Winbond/Nuvoton */
if ((reg_config1 & 0x2A) == 0x00 if ((config1 & 0x2A) == 0x00
&& (reg_config2 & 0xF8) == 0x00) { && (config2 & 0xF8) == 0x00) {
if (chip_id == 0x01 /* W83L771W/G */ if (chip_id == 0x01 /* W83L771W/G */
&& reg_convrate <= 0x09) { && convrate <= 0x09) {
name = "w83l771"; name = "w83l771";
} else } else
if ((chip_id & 0xFE) == 0x10 /* W83L771AWG/ASG */ if ((chip_id & 0xFE) == 0x10 /* W83L771AWG/ASG */
&& reg_convrate <= 0x08) { && convrate <= 0x08) {
name = "w83l771"; name = "w83l771";
} }
} }
...@@ -1280,9 +1278,9 @@ static int lm90_detect(struct i2c_client *new_client, ...@@ -1280,9 +1278,9 @@ static int lm90_detect(struct i2c_client *new_client,
if (address >= 0x48 && address <= 0x4F if (address >= 0x48 && address <= 0x4F
&& man_id == 0xA1) { /* NXP Semiconductor/Philips */ && man_id == 0xA1) { /* NXP Semiconductor/Philips */
if (chip_id == 0x00 if (chip_id == 0x00
&& (reg_config1 & 0x2A) == 0x00 && (config1 & 0x2A) == 0x00
&& (reg_config2 & 0xFE) == 0x00 && (config2 & 0xFE) == 0x00
&& reg_convrate <= 0x09) { && convrate <= 0x09) {
name = "sa56004"; name = "sa56004";
} }
} }
...@@ -1301,19 +1299,18 @@ static int lm90_detect(struct i2c_client *new_client, ...@@ -1301,19 +1299,18 @@ static int lm90_detect(struct i2c_client *new_client,
static void lm90_remove_files(struct i2c_client *client, struct lm90_data *data) static void lm90_remove_files(struct i2c_client *client, struct lm90_data *data)
{ {
struct device *dev = &client->dev;
if (data->flags & LM90_HAVE_TEMP3) if (data->flags & LM90_HAVE_TEMP3)
sysfs_remove_group(&client->dev.kobj, &lm90_temp3_group); sysfs_remove_group(&dev->kobj, &lm90_temp3_group);
if (data->flags & LM90_HAVE_EMERGENCY_ALARM) if (data->flags & LM90_HAVE_EMERGENCY_ALARM)
sysfs_remove_group(&client->dev.kobj, sysfs_remove_group(&dev->kobj, &lm90_emergency_alarm_group);
&lm90_emergency_alarm_group);
if (data->flags & LM90_HAVE_EMERGENCY) if (data->flags & LM90_HAVE_EMERGENCY)
sysfs_remove_group(&client->dev.kobj, sysfs_remove_group(&dev->kobj, &lm90_emergency_group);
&lm90_emergency_group);
if (data->flags & LM90_HAVE_OFFSET) if (data->flags & LM90_HAVE_OFFSET)
device_remove_file(&client->dev, device_remove_file(dev, &sensor_dev_attr_temp2_offset.dev_attr);
&sensor_dev_attr_temp2_offset.dev_attr); device_remove_file(dev, &dev_attr_pec);
device_remove_file(&client->dev, &dev_attr_pec); sysfs_remove_group(&dev->kobj, &lm90_group);
sysfs_remove_group(&client->dev.kobj, &lm90_group);
} }
static void lm90_init_client(struct i2c_client *client) static void lm90_init_client(struct i2c_client *client)
...@@ -1362,10 +1359,11 @@ static void lm90_init_client(struct i2c_client *client) ...@@ -1362,10 +1359,11 @@ static void lm90_init_client(struct i2c_client *client)
i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config); i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config);
} }
static int lm90_probe(struct i2c_client *new_client, static int lm90_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct i2c_adapter *adapter = to_i2c_adapter(new_client->dev.parent); struct device *dev = &client->dev;
struct i2c_adapter *adapter = to_i2c_adapter(dev->parent);
struct lm90_data *data; struct lm90_data *data;
int err; int err;
...@@ -1374,14 +1372,14 @@ static int lm90_probe(struct i2c_client *new_client, ...@@ -1374,14 +1372,14 @@ static int lm90_probe(struct i2c_client *new_client,
err = -ENOMEM; err = -ENOMEM;
goto exit; goto exit;
} }
i2c_set_clientdata(new_client, data); i2c_set_clientdata(client, data);
mutex_init(&data->update_lock); mutex_init(&data->update_lock);
/* Set the device type */ /* Set the device type */
data->kind = id->driver_data; data->kind = id->driver_data;
if (data->kind == adm1032) { if (data->kind == adm1032) {
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
new_client->flags &= ~I2C_CLIENT_PEC; client->flags &= ~I2C_CLIENT_PEC;
} }
/* Different devices have different alarm bits triggering the /* Different devices have different alarm bits triggering the
...@@ -1396,43 +1394,41 @@ static int lm90_probe(struct i2c_client *new_client, ...@@ -1396,43 +1394,41 @@ static int lm90_probe(struct i2c_client *new_client,
data->max_convrate = lm90_params[data->kind].max_convrate; data->max_convrate = lm90_params[data->kind].max_convrate;
/* Initialize the LM90 chip */ /* Initialize the LM90 chip */
lm90_init_client(new_client); lm90_init_client(client);
/* Register sysfs hooks */ /* Register sysfs hooks */
err = sysfs_create_group(&new_client->dev.kobj, &lm90_group); err = sysfs_create_group(&dev->kobj, &lm90_group);
if (err) if (err)
goto exit_free; goto exit_free;
if (new_client->flags & I2C_CLIENT_PEC) { if (client->flags & I2C_CLIENT_PEC) {
err = device_create_file(&new_client->dev, &dev_attr_pec); err = device_create_file(dev, &dev_attr_pec);
if (err) if (err)
goto exit_remove_files; goto exit_remove_files;
} }
if (data->flags & LM90_HAVE_OFFSET) { if (data->flags & LM90_HAVE_OFFSET) {
err = device_create_file(&new_client->dev, err = device_create_file(dev,
&sensor_dev_attr_temp2_offset.dev_attr); &sensor_dev_attr_temp2_offset.dev_attr);
if (err) if (err)
goto exit_remove_files; goto exit_remove_files;
} }
if (data->flags & LM90_HAVE_EMERGENCY) { if (data->flags & LM90_HAVE_EMERGENCY) {
err = sysfs_create_group(&new_client->dev.kobj, err = sysfs_create_group(&dev->kobj, &lm90_emergency_group);
&lm90_emergency_group);
if (err) if (err)
goto exit_remove_files; goto exit_remove_files;
} }
if (data->flags & LM90_HAVE_EMERGENCY_ALARM) { if (data->flags & LM90_HAVE_EMERGENCY_ALARM) {
err = sysfs_create_group(&new_client->dev.kobj, err = sysfs_create_group(&dev->kobj,
&lm90_emergency_alarm_group); &lm90_emergency_alarm_group);
if (err) if (err)
goto exit_remove_files; goto exit_remove_files;
} }
if (data->flags & LM90_HAVE_TEMP3) { if (data->flags & LM90_HAVE_TEMP3) {
err = sysfs_create_group(&new_client->dev.kobj, err = sysfs_create_group(&dev->kobj, &lm90_temp3_group);
&lm90_temp3_group);
if (err) if (err)
goto exit_remove_files; goto exit_remove_files;
} }
data->hwmon_dev = hwmon_device_register(&new_client->dev); data->hwmon_dev = hwmon_device_register(dev);
if (IS_ERR(data->hwmon_dev)) { if (IS_ERR(data->hwmon_dev)) {
err = PTR_ERR(data->hwmon_dev); err = PTR_ERR(data->hwmon_dev);
goto exit_remove_files; goto exit_remove_files;
...@@ -1441,7 +1437,7 @@ static int lm90_probe(struct i2c_client *new_client, ...@@ -1441,7 +1437,7 @@ static int lm90_probe(struct i2c_client *new_client,
return 0; return 0;
exit_remove_files: exit_remove_files:
lm90_remove_files(new_client, data); lm90_remove_files(client, data);
exit_free: exit_free:
kfree(data); kfree(data);
exit: exit:
......
...@@ -117,16 +117,16 @@ static struct lm92_data *lm92_update_device(struct device *dev) ...@@ -117,16 +117,16 @@ static struct lm92_data *lm92_update_device(struct device *dev)
if (time_after(jiffies, data->last_updated + HZ) if (time_after(jiffies, data->last_updated + HZ)
|| !data->valid) { || !data->valid) {
dev_dbg(&client->dev, "Updating lm92 data\n"); dev_dbg(&client->dev, "Updating lm92 data\n");
data->temp1_input = swab16(i2c_smbus_read_word_data(client, data->temp1_input = i2c_smbus_read_word_swapped(client,
LM92_REG_TEMP)); LM92_REG_TEMP);
data->temp1_hyst = swab16(i2c_smbus_read_word_data(client, data->temp1_hyst = i2c_smbus_read_word_swapped(client,
LM92_REG_TEMP_HYST)); LM92_REG_TEMP_HYST);
data->temp1_crit = swab16(i2c_smbus_read_word_data(client, data->temp1_crit = i2c_smbus_read_word_swapped(client,
LM92_REG_TEMP_CRIT)); LM92_REG_TEMP_CRIT);
data->temp1_min = swab16(i2c_smbus_read_word_data(client, data->temp1_min = i2c_smbus_read_word_swapped(client,
LM92_REG_TEMP_LOW)); LM92_REG_TEMP_LOW);
data->temp1_max = swab16(i2c_smbus_read_word_data(client, data->temp1_max = i2c_smbus_read_word_swapped(client,
LM92_REG_TEMP_HIGH)); LM92_REG_TEMP_HIGH);
data->last_updated = jiffies; data->last_updated = jiffies;
data->valid = 1; data->valid = 1;
...@@ -158,7 +158,7 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co ...@@ -158,7 +158,7 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
\ \
mutex_lock(&data->update_lock); \ mutex_lock(&data->update_lock); \
data->value = TEMP_TO_REG(val); \ data->value = TEMP_TO_REG(val); \
i2c_smbus_write_word_data(client, reg, swab16(data->value)); \ i2c_smbus_write_word_swapped(client, reg, data->value); \
mutex_unlock(&data->update_lock); \ mutex_unlock(&data->update_lock); \
return count; \ return count; \
} }
...@@ -194,8 +194,8 @@ static ssize_t set_temp1_crit_hyst(struct device *dev, struct device_attribute * ...@@ -194,8 +194,8 @@ static ssize_t set_temp1_crit_hyst(struct device *dev, struct device_attribute *
mutex_lock(&data->update_lock); mutex_lock(&data->update_lock);
data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val; data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val;
i2c_smbus_write_word_data(client, LM92_REG_TEMP_HYST, i2c_smbus_write_word_swapped(client, LM92_REG_TEMP_HYST,
swab16(TEMP_TO_REG(data->temp1_hyst))); TEMP_TO_REG(data->temp1_hyst));
mutex_unlock(&data->update_lock); mutex_unlock(&data->update_lock);
return count; return count;
} }
......
...@@ -137,10 +137,10 @@ static int max16065_read_adc(struct i2c_client *client, int reg) ...@@ -137,10 +137,10 @@ static int max16065_read_adc(struct i2c_client *client, int reg)
{ {
int rv; int rv;
rv = i2c_smbus_read_word_data(client, reg); rv = i2c_smbus_read_word_swapped(client, reg);
if (unlikely(rv < 0)) if (unlikely(rv < 0))
return rv; return rv;
return ((rv & 0xff) << 2) | ((rv >> 14) & 0x03); return rv >> 6;
} }
static struct max16065_data *max16065_update_device(struct device *dev) static struct max16065_data *max16065_update_device(struct device *dev)
......
...@@ -82,25 +82,6 @@ static inline int sht21_rh_ticks_to_per_cent_mille(int ticks) ...@@ -82,25 +82,6 @@ static inline int sht21_rh_ticks_to_per_cent_mille(int ticks)
return ((15625 * ticks) >> 13) - 6000; return ((15625 * ticks) >> 13) - 6000;
} }
/**
* sht21_read_word_data() - read word from register
* @client: I2C client device
* @reg: I2C command byte
*
* Returns value, negative errno on error.
*/
static inline int sht21_read_word_data(struct i2c_client *client, u8 reg)
{
int ret = i2c_smbus_read_word_data(client, reg);
if (ret < 0)
return ret;
/*
* SMBus specifies low byte first, but the SHT21 returns MSB
* first, so we have to swab16 the values
*/
return swab16(ret);
}
/** /**
* sht21_update_measurements() - get updated measurements from device * sht21_update_measurements() - get updated measurements from device
* @client: I2C client device * @client: I2C client device
...@@ -119,12 +100,13 @@ static int sht21_update_measurements(struct i2c_client *client) ...@@ -119,12 +100,13 @@ static int sht21_update_measurements(struct i2c_client *client)
* maximum two measurements per second at 12bit accuracy shall be made. * maximum two measurements per second at 12bit accuracy shall be made.
*/ */
if (time_after(jiffies, sht21->last_update + HZ / 2) || !sht21->valid) { if (time_after(jiffies, sht21->last_update + HZ / 2) || !sht21->valid) {
ret = sht21_read_word_data(client, SHT21_TRIG_T_MEASUREMENT_HM); ret = i2c_smbus_read_word_swapped(client,
SHT21_TRIG_T_MEASUREMENT_HM);
if (ret < 0) if (ret < 0)
goto out; goto out;
sht21->temperature = sht21_temp_ticks_to_millicelsius(ret); sht21->temperature = sht21_temp_ticks_to_millicelsius(ret);
ret = sht21_read_word_data(client, ret = i2c_smbus_read_word_swapped(client,
SHT21_TRIG_RH_MEASUREMENT_HM); SHT21_TRIG_RH_MEASUREMENT_HM);
if (ret < 0) if (ret < 0)
goto out; goto out;
sht21->humidity = sht21_rh_ticks_to_per_cent_mille(ret); sht21->humidity = sht21_rh_ticks_to_per_cent_mille(ret);
......
...@@ -214,33 +214,26 @@ static int smm665_read_adc(struct smm665_data *data, int adc) ...@@ -214,33 +214,26 @@ static int smm665_read_adc(struct smm665_data *data, int adc)
* *
* Neither i2c_smbus_read_byte() nor * Neither i2c_smbus_read_byte() nor
* i2c_smbus_read_block_data() worked here, * i2c_smbus_read_block_data() worked here,
* so use i2c_smbus_read_word_data() instead. * so use i2c_smbus_read_word_swapped() instead.
* We could also try to use i2c_master_recv(), * We could also try to use i2c_master_recv(),
* but that is not always supported. * but that is not always supported.
*/ */
rv = i2c_smbus_read_word_data(client, 0); rv = i2c_smbus_read_word_swapped(client, 0);
if (rv < 0) { if (rv < 0) {
dev_dbg(&client->dev, "Failed to read ADC value: error %d", rv); dev_dbg(&client->dev, "Failed to read ADC value: error %d", rv);
return -1; return -1;
} }
/* /*
* Validate/verify readback adc channel (in bit 11..14). * Validate/verify readback adc channel (in bit 11..14).
* High byte is in lower 8 bit of rv, so only shift by 3.
*/ */
radc = (rv >> 3) & 0x0f; radc = (rv >> 11) & 0x0f;
if (radc != adc) { if (radc != adc) {
dev_dbg(&client->dev, "Unexpected RADC: Expected %d got %d", dev_dbg(&client->dev, "Unexpected RADC: Expected %d got %d",
adc, radc); adc, radc);
return -EIO; return -EIO;
} }
/*
* Chip replies with H/L, while SMBus expects L/H.
* Thus, byte order is reversed, and we have to swap
* the result.
*/
rv = swab16(rv) & SMM665_ADC_MASK;
return rv; return rv & SMM665_ADC_MASK;
} }
static struct smm665_data *smm665_update_device(struct device *dev) static struct smm665_data *smm665_update_device(struct device *dev)
......
...@@ -113,7 +113,7 @@ struct smsc47b397_data { ...@@ -113,7 +113,7 @@ struct smsc47b397_data {
u8 temp[4]; u8 temp[4];
}; };
static int smsc47b397_read_value(struct smsc47b397_data* data, u8 reg) static int smsc47b397_read_value(struct smsc47b397_data *data, u8 reg)
{ {
int res; int res;
...@@ -265,7 +265,8 @@ static int __devinit smsc47b397_probe(struct platform_device *pdev) ...@@ -265,7 +265,8 @@ static int __devinit smsc47b397_probe(struct platform_device *pdev)
return -EBUSY; return -EBUSY;
} }
if (!(data = kzalloc(sizeof(struct smsc47b397_data), GFP_KERNEL))) { data = kzalloc(sizeof(struct smsc47b397_data), GFP_KERNEL);
if (!data) {
err = -ENOMEM; err = -ENOMEM;
goto error_release; goto error_release;
} }
...@@ -276,7 +277,8 @@ static int __devinit smsc47b397_probe(struct platform_device *pdev) ...@@ -276,7 +277,8 @@ static int __devinit smsc47b397_probe(struct platform_device *pdev)
mutex_init(&data->update_lock); mutex_init(&data->update_lock);
platform_set_drvdata(pdev, data); platform_set_drvdata(pdev, data);
if ((err = sysfs_create_group(&dev->kobj, &smsc47b397_group))) err = sysfs_create_group(&dev->kobj, &smsc47b397_group);
if (err)
goto error_free; goto error_free;
data->hwmon_dev = hwmon_device_register(dev); data->hwmon_dev = hwmon_device_register(dev);
...@@ -345,7 +347,7 @@ static int __init smsc47b397_find(unsigned short *addr) ...@@ -345,7 +347,7 @@ static int __init smsc47b397_find(unsigned short *addr)
superio_enter(); superio_enter();
id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID); id = force_id ? force_id : superio_inb(SUPERIO_REG_DEVID);
switch(id) { switch (id) {
case 0x81: case 0x81:
name = "SCH5307-NS"; name = "SCH5307-NS";
break; break;
...@@ -379,7 +381,8 @@ static int __init smsc47b397_init(void) ...@@ -379,7 +381,8 @@ static int __init smsc47b397_init(void)
unsigned short address; unsigned short address;
int ret; int ret;
if ((ret = smsc47b397_find(&address))) ret = smsc47b397_find(&address);
if (ret)
return ret; return ret;
ret = platform_driver_register(&smsc47b397_driver); ret = platform_driver_register(&smsc47b397_driver);
......
...@@ -55,19 +55,6 @@ struct tmp102 { ...@@ -55,19 +55,6 @@ struct tmp102 {
int temp[3]; int temp[3];
}; };
/* SMBus specifies low byte first, but the TMP102 returns high byte first,
* so we have to swab16 the values */
static inline int tmp102_read_reg(struct i2c_client *client, u8 reg)
{
int result = i2c_smbus_read_word_data(client, reg);
return result < 0 ? result : swab16(result);
}
static inline int tmp102_write_reg(struct i2c_client *client, u8 reg, u16 val)
{
return i2c_smbus_write_word_data(client, reg, swab16(val));
}
/* convert left adjusted 13-bit TMP102 register value to milliCelsius */ /* convert left adjusted 13-bit TMP102 register value to milliCelsius */
static inline int tmp102_reg_to_mC(s16 val) static inline int tmp102_reg_to_mC(s16 val)
{ {
...@@ -94,7 +81,8 @@ static struct tmp102 *tmp102_update_device(struct i2c_client *client) ...@@ -94,7 +81,8 @@ static struct tmp102 *tmp102_update_device(struct i2c_client *client)
if (time_after(jiffies, tmp102->last_update + HZ / 3)) { if (time_after(jiffies, tmp102->last_update + HZ / 3)) {
int i; int i;
for (i = 0; i < ARRAY_SIZE(tmp102->temp); ++i) { for (i = 0; i < ARRAY_SIZE(tmp102->temp); ++i) {
int status = tmp102_read_reg(client, tmp102_reg[i]); int status = i2c_smbus_read_word_swapped(client,
tmp102_reg[i]);
if (status > -1) if (status > -1)
tmp102->temp[i] = tmp102_reg_to_mC(status); tmp102->temp[i] = tmp102_reg_to_mC(status);
} }
...@@ -130,8 +118,8 @@ static ssize_t tmp102_set_temp(struct device *dev, ...@@ -130,8 +118,8 @@ static ssize_t tmp102_set_temp(struct device *dev,
mutex_lock(&tmp102->lock); mutex_lock(&tmp102->lock);
tmp102->temp[sda->index] = val; tmp102->temp[sda->index] = val;
status = tmp102_write_reg(client, tmp102_reg[sda->index], status = i2c_smbus_write_word_swapped(client, tmp102_reg[sda->index],
tmp102_mC_to_reg(val)); tmp102_mC_to_reg(val));
mutex_unlock(&tmp102->lock); mutex_unlock(&tmp102->lock);
return status ? : count; return status ? : count;
} }
...@@ -178,18 +166,19 @@ static int __devinit tmp102_probe(struct i2c_client *client, ...@@ -178,18 +166,19 @@ static int __devinit tmp102_probe(struct i2c_client *client,
} }
i2c_set_clientdata(client, tmp102); i2c_set_clientdata(client, tmp102);
status = tmp102_read_reg(client, TMP102_CONF_REG); status = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG);
if (status < 0) { if (status < 0) {
dev_err(&client->dev, "error reading config register\n"); dev_err(&client->dev, "error reading config register\n");
goto fail_free; goto fail_free;
} }
tmp102->config_orig = status; tmp102->config_orig = status;
status = tmp102_write_reg(client, TMP102_CONF_REG, TMP102_CONFIG); status = i2c_smbus_write_word_swapped(client, TMP102_CONF_REG,
TMP102_CONFIG);
if (status < 0) { if (status < 0) {
dev_err(&client->dev, "error writing config register\n"); dev_err(&client->dev, "error writing config register\n");
goto fail_restore_config; goto fail_restore_config;
} }
status = tmp102_read_reg(client, TMP102_CONF_REG); status = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG);
if (status < 0) { if (status < 0) {
dev_err(&client->dev, "error reading config register\n"); dev_err(&client->dev, "error reading config register\n");
goto fail_restore_config; goto fail_restore_config;
...@@ -222,7 +211,8 @@ static int __devinit tmp102_probe(struct i2c_client *client, ...@@ -222,7 +211,8 @@ static int __devinit tmp102_probe(struct i2c_client *client,
fail_remove_sysfs: fail_remove_sysfs:
sysfs_remove_group(&client->dev.kobj, &tmp102_attr_group); sysfs_remove_group(&client->dev.kobj, &tmp102_attr_group);
fail_restore_config: fail_restore_config:
tmp102_write_reg(client, TMP102_CONF_REG, tmp102->config_orig); i2c_smbus_write_word_swapped(client, TMP102_CONF_REG,
tmp102->config_orig);
fail_free: fail_free:
kfree(tmp102); kfree(tmp102);
...@@ -240,10 +230,10 @@ static int __devexit tmp102_remove(struct i2c_client *client) ...@@ -240,10 +230,10 @@ static int __devexit tmp102_remove(struct i2c_client *client)
if (tmp102->config_orig & TMP102_CONF_SD) { if (tmp102->config_orig & TMP102_CONF_SD) {
int config; int config;
config = tmp102_read_reg(client, TMP102_CONF_REG); config = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG);
if (config >= 0) if (config >= 0)
tmp102_write_reg(client, TMP102_CONF_REG, i2c_smbus_write_word_swapped(client, TMP102_CONF_REG,
config | TMP102_CONF_SD); config | TMP102_CONF_SD);
} }
kfree(tmp102); kfree(tmp102);
...@@ -257,12 +247,12 @@ static int tmp102_suspend(struct device *dev) ...@@ -257,12 +247,12 @@ static int tmp102_suspend(struct device *dev)
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
int config; int config;
config = tmp102_read_reg(client, TMP102_CONF_REG); config = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG);
if (config < 0) if (config < 0)
return config; return config;
config |= TMP102_CONF_SD; config |= TMP102_CONF_SD;
return tmp102_write_reg(client, TMP102_CONF_REG, config); return i2c_smbus_write_word_swapped(client, TMP102_CONF_REG, config);
} }
static int tmp102_resume(struct device *dev) static int tmp102_resume(struct device *dev)
...@@ -270,12 +260,12 @@ static int tmp102_resume(struct device *dev) ...@@ -270,12 +260,12 @@ static int tmp102_resume(struct device *dev)
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
int config; int config;
config = tmp102_read_reg(client, TMP102_CONF_REG); config = i2c_smbus_read_word_swapped(client, TMP102_CONF_REG);
if (config < 0) if (config < 0)
return config; return config;
config &= ~TMP102_CONF_SD; config &= ~TMP102_CONF_SD;
return tmp102_write_reg(client, TMP102_CONF_REG, config); return i2c_smbus_write_word_swapped(client, TMP102_CONF_REG, config);
} }
static const struct dev_pm_ops tmp102_dev_pm_ops = { static const struct dev_pm_ops tmp102_dev_pm_ops = {
......
/* /*
w83627ehf - Driver for the hardware monitoring functionality of w83627ehf - Driver for the hardware monitoring functionality of
the Winbond W83627EHF Super-I/O chip the Winbond W83627EHF Super-I/O chip
Copyright (C) 2005 Jean Delvare <khali@linux-fr.org> Copyright (C) 2005-2011 Jean Delvare <khali@linux-fr.org>
Copyright (C) 2006 Yuan Mu (Winbond), Copyright (C) 2006 Yuan Mu (Winbond),
Rudolf Marek <r.marek@assembler.cz> Rudolf Marek <r.marek@assembler.cz>
David Hubbard <david.c.hubbard@gmail.com> David Hubbard <david.c.hubbard@gmail.com>
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
0x8860 0xa1 0x8860 0xa1
w83627dhg 9 5 4 3 0xa020 0xc1 0x5ca3 w83627dhg 9 5 4 3 0xa020 0xc1 0x5ca3
w83627dhg-p 9 5 4 3 0xb070 0xc1 0x5ca3 w83627dhg-p 9 5 4 3 0xb070 0xc1 0x5ca3
w83627uhg 8 2 2 2 0xa230 0xc1 0x5ca3
w83667hg 9 5 3 3 0xa510 0xc1 0x5ca3 w83667hg 9 5 3 3 0xa510 0xc1 0x5ca3
w83667hg-b 9 5 3 4 0xb350 0xc1 0x5ca3 w83667hg-b 9 5 3 4 0xb350 0xc1 0x5ca3
nct6775f 9 4 3 9 0xb470 0xc1 0x5ca3 nct6775f 9 4 3 9 0xb470 0xc1 0x5ca3
...@@ -61,14 +62,17 @@ ...@@ -61,14 +62,17 @@
#include <linux/io.h> #include <linux/io.h>
#include "lm75.h" #include "lm75.h"
enum kinds { w83627ehf, w83627dhg, w83627dhg_p, w83667hg, w83667hg_b, nct6775, enum kinds {
nct6776 }; w83627ehf, w83627dhg, w83627dhg_p, w83627uhg,
w83667hg, w83667hg_b, nct6775, nct6776,
};
/* used to set data->name = w83627ehf_device_names[data->sio_kind] */ /* used to set data->name = w83627ehf_device_names[data->sio_kind] */
static const char * const w83627ehf_device_names[] = { static const char * const w83627ehf_device_names[] = {
"w83627ehf", "w83627ehf",
"w83627dhg", "w83627dhg",
"w83627dhg", "w83627dhg",
"w83627uhg",
"w83667hg", "w83667hg",
"w83667hg", "w83667hg",
"nct6775", "nct6775",
...@@ -104,6 +108,7 @@ MODULE_PARM_DESC(fan_debounce, "Enable debouncing for fan RPM signal"); ...@@ -104,6 +108,7 @@ MODULE_PARM_DESC(fan_debounce, "Enable debouncing for fan RPM signal");
#define SIO_W83627EHG_ID 0x8860 #define SIO_W83627EHG_ID 0x8860
#define SIO_W83627DHG_ID 0xa020 #define SIO_W83627DHG_ID 0xa020
#define SIO_W83627DHG_P_ID 0xb070 #define SIO_W83627DHG_P_ID 0xb070
#define SIO_W83627UHG_ID 0xa230
#define SIO_W83667HG_ID 0xa510 #define SIO_W83667HG_ID 0xa510
#define SIO_W83667HG_B_ID 0xb350 #define SIO_W83667HG_B_ID 0xb350
#define SIO_NCT6775_ID 0xb470 #define SIO_NCT6775_ID 0xb470
...@@ -388,18 +393,23 @@ div_from_reg(u8 reg) ...@@ -388,18 +393,23 @@ div_from_reg(u8 reg)
return 1 << reg; return 1 << reg;
} }
/* Some of analog inputs have internal scaling (2x), 8mV is ADC LSB */ /* Some of the voltage inputs have internal scaling, the tables below
* contain 8 (the ADC LSB in mV) * scaling factor * 100 */
static u8 scale_in[10] = { 8, 8, 16, 16, 8, 8, 8, 16, 16, 8 }; static const u16 scale_in_common[10] = {
800, 800, 1600, 1600, 800, 800, 800, 1600, 1600, 800
};
static const u16 scale_in_w83627uhg[9] = {
800, 800, 3328, 3424, 800, 800, 0, 3328, 3400
};
static inline long in_from_reg(u8 reg, u8 nr) static inline long in_from_reg(u8 reg, u8 nr, const u16 *scale_in)
{ {
return reg * scale_in[nr]; return DIV_ROUND_CLOSEST(reg * scale_in[nr], 100);
} }
static inline u8 in_to_reg(u32 val, u8 nr) static inline u8 in_to_reg(u32 val, u8 nr, const u16 *scale_in)
{ {
return SENSORS_LIMIT(((val + (scale_in[nr] / 2)) / scale_in[nr]), 0, return SENSORS_LIMIT(DIV_ROUND_CLOSEST(val * 100, scale_in[nr]), 0,
255); 255);
} }
...@@ -430,6 +440,7 @@ struct w83627ehf_data { ...@@ -430,6 +440,7 @@ struct w83627ehf_data {
const u16 *REG_FAN_STOP_TIME; const u16 *REG_FAN_STOP_TIME;
const u16 *REG_FAN_MAX_OUTPUT; const u16 *REG_FAN_MAX_OUTPUT;
const u16 *REG_FAN_STEP_OUTPUT; const u16 *REG_FAN_STEP_OUTPUT;
const u16 *scale_in;
unsigned int (*fan_from_reg)(u16 reg, unsigned int divreg); unsigned int (*fan_from_reg)(u16 reg, unsigned int divreg);
unsigned int (*fan_from_reg_min)(u16 reg, unsigned int divreg); unsigned int (*fan_from_reg_min)(u16 reg, unsigned int divreg);
...@@ -481,7 +492,8 @@ struct w83627ehf_data { ...@@ -481,7 +492,8 @@ struct w83627ehf_data {
u8 vrm; u8 vrm;
u16 have_temp; u16 have_temp;
u8 in6_skip; u8 in6_skip:1;
u8 temp3_val_only:1;
}; };
struct w83627ehf_sio_data { struct w83627ehf_sio_data {
...@@ -907,7 +919,8 @@ show_##reg(struct device *dev, struct device_attribute *attr, \ ...@@ -907,7 +919,8 @@ show_##reg(struct device *dev, struct device_attribute *attr, \
struct sensor_device_attribute *sensor_attr = \ struct sensor_device_attribute *sensor_attr = \
to_sensor_dev_attr(attr); \ to_sensor_dev_attr(attr); \
int nr = sensor_attr->index; \ int nr = sensor_attr->index; \
return sprintf(buf, "%ld\n", in_from_reg(data->reg[nr], nr)); \ return sprintf(buf, "%ld\n", in_from_reg(data->reg[nr], nr, \
data->scale_in)); \
} }
show_in_reg(in) show_in_reg(in)
show_in_reg(in_min) show_in_reg(in_min)
...@@ -928,7 +941,7 @@ store_in_##reg(struct device *dev, struct device_attribute *attr, \ ...@@ -928,7 +941,7 @@ store_in_##reg(struct device *dev, struct device_attribute *attr, \
if (err < 0) \ if (err < 0) \
return err; \ return err; \
mutex_lock(&data->update_lock); \ mutex_lock(&data->update_lock); \
data->in_##reg[nr] = in_to_reg(val, nr); \ data->in_##reg[nr] = in_to_reg(val, nr, data->scale_in); \
w83627ehf_write_value(data, W83627EHF_REG_IN_##REG(nr), \ w83627ehf_write_value(data, W83627EHF_REG_IN_##REG(nr), \
data->in_##reg[nr]); \ data->in_##reg[nr]); \
mutex_unlock(&data->update_lock); \ mutex_unlock(&data->update_lock); \
...@@ -1617,25 +1630,28 @@ static struct sensor_device_attribute sda_sf3_arrays_fan4[] = { ...@@ -1617,25 +1630,28 @@ static struct sensor_device_attribute sda_sf3_arrays_fan4[] = {
store_fan_step_output, 3), store_fan_step_output, 3),
}; };
static struct sensor_device_attribute sda_sf3_arrays_fan3[] = {
SENSOR_ATTR(pwm3_stop_time, S_IWUSR | S_IRUGO, show_fan_stop_time,
store_fan_stop_time, 2),
SENSOR_ATTR(pwm3_start_output, S_IWUSR | S_IRUGO, show_fan_start_output,
store_fan_start_output, 2),
SENSOR_ATTR(pwm3_stop_output, S_IWUSR | S_IRUGO, show_fan_stop_output,
store_fan_stop_output, 2),
};
static struct sensor_device_attribute sda_sf3_arrays[] = { static struct sensor_device_attribute sda_sf3_arrays[] = {
SENSOR_ATTR(pwm1_stop_time, S_IWUSR | S_IRUGO, show_fan_stop_time, SENSOR_ATTR(pwm1_stop_time, S_IWUSR | S_IRUGO, show_fan_stop_time,
store_fan_stop_time, 0), store_fan_stop_time, 0),
SENSOR_ATTR(pwm2_stop_time, S_IWUSR | S_IRUGO, show_fan_stop_time, SENSOR_ATTR(pwm2_stop_time, S_IWUSR | S_IRUGO, show_fan_stop_time,
store_fan_stop_time, 1), store_fan_stop_time, 1),
SENSOR_ATTR(pwm3_stop_time, S_IWUSR | S_IRUGO, show_fan_stop_time,
store_fan_stop_time, 2),
SENSOR_ATTR(pwm1_start_output, S_IWUSR | S_IRUGO, show_fan_start_output, SENSOR_ATTR(pwm1_start_output, S_IWUSR | S_IRUGO, show_fan_start_output,
store_fan_start_output, 0), store_fan_start_output, 0),
SENSOR_ATTR(pwm2_start_output, S_IWUSR | S_IRUGO, show_fan_start_output, SENSOR_ATTR(pwm2_start_output, S_IWUSR | S_IRUGO, show_fan_start_output,
store_fan_start_output, 1), store_fan_start_output, 1),
SENSOR_ATTR(pwm3_start_output, S_IWUSR | S_IRUGO, show_fan_start_output,
store_fan_start_output, 2),
SENSOR_ATTR(pwm1_stop_output, S_IWUSR | S_IRUGO, show_fan_stop_output, SENSOR_ATTR(pwm1_stop_output, S_IWUSR | S_IRUGO, show_fan_stop_output,
store_fan_stop_output, 0), store_fan_stop_output, 0),
SENSOR_ATTR(pwm2_stop_output, S_IWUSR | S_IRUGO, show_fan_stop_output, SENSOR_ATTR(pwm2_stop_output, S_IWUSR | S_IRUGO, show_fan_stop_output,
store_fan_stop_output, 1), store_fan_stop_output, 1),
SENSOR_ATTR(pwm3_stop_output, S_IWUSR | S_IRUGO, show_fan_stop_output,
store_fan_stop_output, 2),
}; };
...@@ -1728,6 +1744,8 @@ static void w83627ehf_device_remove_files(struct device *dev) ...@@ -1728,6 +1744,8 @@ static void w83627ehf_device_remove_files(struct device *dev)
data->REG_FAN_STEP_OUTPUT[attr->index] != 0xff) data->REG_FAN_STEP_OUTPUT[attr->index] != 0xff)
device_remove_file(dev, &attr->dev_attr); device_remove_file(dev, &attr->dev_attr);
} }
for (i = 0; i < ARRAY_SIZE(sda_sf3_arrays_fan3); i++)
device_remove_file(dev, &sda_sf3_arrays_fan3[i].dev_attr);
for (i = 0; i < ARRAY_SIZE(sda_sf3_arrays_fan4); i++) for (i = 0; i < ARRAY_SIZE(sda_sf3_arrays_fan4); i++)
device_remove_file(dev, &sda_sf3_arrays_fan4[i].dev_attr); device_remove_file(dev, &sda_sf3_arrays_fan4[i].dev_attr);
for (i = 0; i < data->in_num; i++) { for (i = 0; i < data->in_num; i++) {
...@@ -1756,6 +1774,8 @@ static void w83627ehf_device_remove_files(struct device *dev) ...@@ -1756,6 +1774,8 @@ static void w83627ehf_device_remove_files(struct device *dev)
continue; continue;
device_remove_file(dev, &sda_temp_input[i].dev_attr); device_remove_file(dev, &sda_temp_input[i].dev_attr);
device_remove_file(dev, &sda_temp_label[i].dev_attr); device_remove_file(dev, &sda_temp_label[i].dev_attr);
if (i == 2 && data->temp3_val_only)
continue;
device_remove_file(dev, &sda_temp_max[i].dev_attr); device_remove_file(dev, &sda_temp_max[i].dev_attr);
device_remove_file(dev, &sda_temp_max_hyst[i].dev_attr); device_remove_file(dev, &sda_temp_max_hyst[i].dev_attr);
if (i > 2) if (i > 2)
...@@ -1808,11 +1828,21 @@ static inline void __devinit w83627ehf_init_device(struct w83627ehf_data *data, ...@@ -1808,11 +1828,21 @@ static inline void __devinit w83627ehf_init_device(struct w83627ehf_data *data,
case w83627ehf: case w83627ehf:
diode = w83627ehf_read_value(data, W83627EHF_REG_DIODE); diode = w83627ehf_read_value(data, W83627EHF_REG_DIODE);
break; break;
case w83627uhg:
diode = 0x00;
break;
default: default:
diode = 0x70; diode = 0x70;
} }
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
if ((tmp & (0x02 << i))) const char *label = data->temp_label[data->temp_src[i]];
/* Digital source overrides analog type */
if (strncmp(label, "PECI", 4) == 0)
data->temp_type[i] = 6;
else if (strncmp(label, "AMD", 3) == 0)
data->temp_type[i] = 5;
else if ((tmp & (0x02 << i)))
data->temp_type[i] = (diode & (0x10 << i)) ? 1 : 3; data->temp_type[i] = (diode & (0x10 << i)) ? 1 : 3;
else else
data->temp_type[i] = 4; /* thermistor */ data->temp_type[i] = 4; /* thermistor */
...@@ -1845,12 +1875,32 @@ static void w82627ehf_swap_tempreg(struct w83627ehf_data *data, ...@@ -1845,12 +1875,32 @@ static void w82627ehf_swap_tempreg(struct w83627ehf_data *data,
data->reg_temp_config[r2] = tmp; data->reg_temp_config[r2] = tmp;
} }
static void __devinit
w83627ehf_set_temp_reg_ehf(struct w83627ehf_data *data, int n_temp)
{
int i;
for (i = 0; i < n_temp; i++) {
data->reg_temp[i] = W83627EHF_REG_TEMP[i];
data->reg_temp_over[i] = W83627EHF_REG_TEMP_OVER[i];
data->reg_temp_hyst[i] = W83627EHF_REG_TEMP_HYST[i];
data->reg_temp_config[i] = W83627EHF_REG_TEMP_CONFIG[i];
}
}
static void __devinit static void __devinit
w83627ehf_check_fan_inputs(const struct w83627ehf_sio_data *sio_data, w83627ehf_check_fan_inputs(const struct w83627ehf_sio_data *sio_data,
struct w83627ehf_data *data) struct w83627ehf_data *data)
{ {
int fan3pin, fan4pin, fan4min, fan5pin, regval; int fan3pin, fan4pin, fan4min, fan5pin, regval;
/* The W83627UHG is simple, only two fan inputs, no config */
if (sio_data->kind == w83627uhg) {
data->has_fan = 0x03; /* fan1 and fan2 */
data->has_fan_min = 0x03;
return;
}
superio_enter(sio_data->sioreg); superio_enter(sio_data->sioreg);
/* fan4 and fan5 share some pins with the GPIO and serial flash */ /* fan4 and fan5 share some pins with the GPIO and serial flash */
...@@ -1942,23 +1992,24 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev) ...@@ -1942,23 +1992,24 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
/* 627EHG and 627EHF have 10 voltage inputs; 627DHG and 667HG have 9 */ /* 627EHG and 627EHF have 10 voltage inputs; 627DHG and 667HG have 9 */
data->in_num = (sio_data->kind == w83627ehf) ? 10 : 9; data->in_num = (sio_data->kind == w83627ehf) ? 10 : 9;
/* 667HG, NCT6775F, and NCT6776F have 3 pwms */ /* 667HG, NCT6775F, and NCT6776F have 3 pwms, and 627UHG has only 2 */
data->pwm_num = (sio_data->kind == w83667hg switch (sio_data->kind) {
|| sio_data->kind == w83667hg_b default:
|| sio_data->kind == nct6775 data->pwm_num = 4;
|| sio_data->kind == nct6776) ? 3 : 4; break;
case w83667hg:
case w83667hg_b:
case nct6775:
case nct6776:
data->pwm_num = 3;
break;
case w83627uhg:
data->pwm_num = 2;
break;
}
/* Default to 3 temperature inputs, code below will adjust as needed */
data->have_temp = 0x07; data->have_temp = 0x07;
/* Check temp3 configuration bit for 667HG */
if (sio_data->kind == w83667hg) {
u8 reg;
reg = w83627ehf_read_value(data, W83627EHF_REG_TEMP_CONFIG[2]);
if (reg & 0x01)
data->have_temp &= ~(1 << 2);
else
data->in6_skip = 1; /* either temp3 or in6 */
}
/* Deal with temperature register setup first. */ /* Deal with temperature register setup first. */
if (sio_data->kind == nct6775 || sio_data->kind == nct6776) { if (sio_data->kind == nct6775 || sio_data->kind == nct6776) {
...@@ -2035,16 +2086,12 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev) ...@@ -2035,16 +2086,12 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
} else if (sio_data->kind == w83667hg_b) { } else if (sio_data->kind == w83667hg_b) {
u8 reg; u8 reg;
w83627ehf_set_temp_reg_ehf(data, 4);
/* /*
* Temperature sources are selected with bank 0, registers 0x49 * Temperature sources are selected with bank 0, registers 0x49
* and 0x4a. * and 0x4a.
*/ */
for (i = 0; i < ARRAY_SIZE(W83627EHF_REG_TEMP); i++) {
data->reg_temp[i] = W83627EHF_REG_TEMP[i];
data->reg_temp_over[i] = W83627EHF_REG_TEMP_OVER[i];
data->reg_temp_hyst[i] = W83627EHF_REG_TEMP_HYST[i];
data->reg_temp_config[i] = W83627EHF_REG_TEMP_CONFIG[i];
}
reg = w83627ehf_read_value(data, 0x4a); reg = w83627ehf_read_value(data, 0x4a);
data->temp_src[0] = reg >> 5; data->temp_src[0] = reg >> 5;
reg = w83627ehf_read_value(data, 0x49); reg = w83627ehf_read_value(data, 0x49);
...@@ -2077,14 +2124,61 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev) ...@@ -2077,14 +2124,61 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
|| (data->temp_src[3] == 2 && (data->have_temp & (1 << 3)))) || (data->temp_src[3] == 2 && (data->have_temp & (1 << 3))))
data->in6_skip = 1; data->in6_skip = 1;
data->temp_label = w83667hg_b_temp_label;
} else if (sio_data->kind == w83627uhg) {
u8 reg;
w83627ehf_set_temp_reg_ehf(data, 3);
/*
* Temperature sources for temp1 and temp2 are selected with
* bank 0, registers 0x49 and 0x4a.
*/
data->temp_src[0] = 0; /* SYSTIN */
reg = w83627ehf_read_value(data, 0x49) & 0x07;
/* Adjust to have the same mapping as other source registers */
if (reg == 0)
data->temp_src[1]++;
else if (reg >= 2 && reg <= 5)
data->temp_src[1] += 2;
else /* should never happen */
data->have_temp &= ~(1 << 1);
reg = w83627ehf_read_value(data, 0x4a);
data->temp_src[2] = reg >> 5;
/*
* Skip temp3 if source is invalid or the same as temp1
* or temp2.
*/
if (data->temp_src[2] == 2 || data->temp_src[2] == 3 ||
data->temp_src[2] == data->temp_src[0] ||
((data->have_temp & (1 << 1)) &&
data->temp_src[2] == data->temp_src[1]))
data->have_temp &= ~(1 << 2);
else
data->temp3_val_only = 1; /* No limit regs */
data->in6_skip = 1; /* No VIN3 */
data->temp_label = w83667hg_b_temp_label; data->temp_label = w83667hg_b_temp_label;
} else { } else {
w83627ehf_set_temp_reg_ehf(data, 3);
/* Temperature sources are fixed */ /* Temperature sources are fixed */
for (i = 0; i < 3; i++) {
data->reg_temp[i] = W83627EHF_REG_TEMP[i]; if (sio_data->kind == w83667hg) {
data->reg_temp_over[i] = W83627EHF_REG_TEMP_OVER[i]; u8 reg;
data->reg_temp_hyst[i] = W83627EHF_REG_TEMP_HYST[i];
data->reg_temp_config[i] = W83627EHF_REG_TEMP_CONFIG[i]; /*
* Chip supports either AUXTIN or VIN3. Try to find
* out which one.
*/
reg = w83627ehf_read_value(data,
W83627EHF_REG_TEMP_CONFIG[2]);
if (reg & 0x01)
data->have_temp &= ~(1 << 2);
else
data->in6_skip = 1;
} }
} }
...@@ -2144,6 +2238,12 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev) ...@@ -2144,6 +2238,12 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
W83627EHF_REG_FAN_STEP_OUTPUT_COMMON; W83627EHF_REG_FAN_STEP_OUTPUT_COMMON;
} }
/* Setup input voltage scaling factors */
if (sio_data->kind == w83627uhg)
data->scale_in = scale_in_w83627uhg;
else
data->scale_in = scale_in_common;
/* Initialize the chip */ /* Initialize the chip */
w83627ehf_init_device(data, sio_data->kind); w83627ehf_init_device(data, sio_data->kind);
...@@ -2160,7 +2260,7 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev) ...@@ -2160,7 +2260,7 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
err = device_create_file(dev, &dev_attr_cpu0_vid); err = device_create_file(dev, &dev_attr_cpu0_vid);
if (err) if (err)
goto exit_release; goto exit_release;
} else { } else if (sio_data->kind != w83627uhg) {
superio_select(sio_data->sioreg, W83627EHF_LD_HWM); superio_select(sio_data->sioreg, W83627EHF_LD_HWM);
if (superio_inb(sio_data->sioreg, SIO_REG_VID_CTRL) & 0x80) { if (superio_inb(sio_data->sioreg, SIO_REG_VID_CTRL) & 0x80) {
/* Set VID input sensibility if needed. In theory the /* Set VID input sensibility if needed. In theory the
...@@ -2250,7 +2350,14 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev) ...@@ -2250,7 +2350,14 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
goto exit_remove; goto exit_remove;
} }
} }
/* if fan4 is enabled create the sf3 files for it */ /* if fan3 and fan4 are enabled create the sf3 files for them */
if ((data->has_fan & (1 << 2)) && data->pwm_num >= 3)
for (i = 0; i < ARRAY_SIZE(sda_sf3_arrays_fan3); i++) {
err = device_create_file(dev,
&sda_sf3_arrays_fan3[i].dev_attr);
if (err)
goto exit_remove;
}
if ((data->has_fan & (1 << 3)) && data->pwm_num >= 4) if ((data->has_fan & (1 << 3)) && data->pwm_num >= 4)
for (i = 0; i < ARRAY_SIZE(sda_sf3_arrays_fan4); i++) { for (i = 0; i < ARRAY_SIZE(sda_sf3_arrays_fan4); i++) {
err = device_create_file(dev, err = device_create_file(dev,
...@@ -2318,6 +2425,8 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev) ...@@ -2318,6 +2425,8 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
if (err) if (err)
goto exit_remove; goto exit_remove;
} }
if (i == 2 && data->temp3_val_only)
continue;
if (data->reg_temp_over[i]) { if (data->reg_temp_over[i]) {
err = device_create_file(dev, err = device_create_file(dev,
&sda_temp_max[i].dev_attr); &sda_temp_max[i].dev_attr);
...@@ -2401,6 +2510,7 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr, ...@@ -2401,6 +2510,7 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr,
static const char __initdata sio_name_W83627EHG[] = "W83627EHG"; static const char __initdata sio_name_W83627EHG[] = "W83627EHG";
static const char __initdata sio_name_W83627DHG[] = "W83627DHG"; static const char __initdata sio_name_W83627DHG[] = "W83627DHG";
static const char __initdata sio_name_W83627DHG_P[] = "W83627DHG-P"; static const char __initdata sio_name_W83627DHG_P[] = "W83627DHG-P";
static const char __initdata sio_name_W83627UHG[] = "W83627UHG";
static const char __initdata sio_name_W83667HG[] = "W83667HG"; static const char __initdata sio_name_W83667HG[] = "W83667HG";
static const char __initdata sio_name_W83667HG_B[] = "W83667HG-B"; static const char __initdata sio_name_W83667HG_B[] = "W83667HG-B";
static const char __initdata sio_name_NCT6775[] = "NCT6775F"; static const char __initdata sio_name_NCT6775[] = "NCT6775F";
...@@ -2433,6 +2543,10 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr, ...@@ -2433,6 +2543,10 @@ static int __init w83627ehf_find(int sioaddr, unsigned short *addr,
sio_data->kind = w83627dhg_p; sio_data->kind = w83627dhg_p;
sio_name = sio_name_W83627DHG_P; sio_name = sio_name_W83627DHG_P;
break; break;
case SIO_W83627UHG_ID:
sio_data->kind = w83627uhg;
sio_name = sio_name_W83627UHG;
break;
case SIO_W83667HG_ID: case SIO_W83667HG_ID:
sio_data->kind = w83667hg; sio_data->kind = w83667hg;
sio_name = sio_name_W83667HG; sio_name = sio_name_W83667HG;
......
...@@ -1245,17 +1245,17 @@ w83781d_read_value_i2c(struct w83781d_data *data, u16 reg) ...@@ -1245,17 +1245,17 @@ w83781d_read_value_i2c(struct w83781d_data *data, u16 reg)
/* convert from ISA to LM75 I2C addresses */ /* convert from ISA to LM75 I2C addresses */
switch (reg & 0xff) { switch (reg & 0xff) {
case 0x50: /* TEMP */ case 0x50: /* TEMP */
res = swab16(i2c_smbus_read_word_data(cl, 0)); res = i2c_smbus_read_word_swapped(cl, 0);
break; break;
case 0x52: /* CONFIG */ case 0x52: /* CONFIG */
res = i2c_smbus_read_byte_data(cl, 1); res = i2c_smbus_read_byte_data(cl, 1);
break; break;
case 0x53: /* HYST */ case 0x53: /* HYST */
res = swab16(i2c_smbus_read_word_data(cl, 2)); res = i2c_smbus_read_word_swapped(cl, 2);
break; break;
case 0x55: /* OVER */ case 0x55: /* OVER */
default: default:
res = swab16(i2c_smbus_read_word_data(cl, 3)); res = i2c_smbus_read_word_swapped(cl, 3);
break; break;
} }
} }
...@@ -1289,10 +1289,10 @@ w83781d_write_value_i2c(struct w83781d_data *data, u16 reg, u16 value) ...@@ -1289,10 +1289,10 @@ w83781d_write_value_i2c(struct w83781d_data *data, u16 reg, u16 value)
i2c_smbus_write_byte_data(cl, 1, value & 0xff); i2c_smbus_write_byte_data(cl, 1, value & 0xff);
break; break;
case 0x53: /* HYST */ case 0x53: /* HYST */
i2c_smbus_write_word_data(cl, 2, swab16(value)); i2c_smbus_write_word_swapped(cl, 2, value);
break; break;
case 0x55: /* OVER */ case 0x55: /* OVER */
i2c_smbus_write_word_data(cl, 3, swab16(value)); i2c_smbus_write_word_swapped(cl, 3, value);
break; break;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment