Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull hwmon fixes from Guenter Roeck:
"Fix word size register read and write operations in ina2xx driver, and
initialize uninitialized structure elements in twl4030-madc-hwmon
driver."

* tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
hwmon: (ina2xx) Fix word size register read and write operations
hwmon: (twl4030-madc-hwmon) Initialize uninitialized structure elements

+14 -25
+9 -21
drivers/hwmon/ina2xx.c
··· 69 69 u16 regs[INA2XX_MAX_REGISTERS]; 70 70 }; 71 71 72 - int ina2xx_read_word(struct i2c_client *client, int reg) 73 - { 74 - int val = i2c_smbus_read_word_data(client, reg); 75 - if (unlikely(val < 0)) { 76 - dev_dbg(&client->dev, 77 - "Failed to read register: %d\n", reg); 78 - return val; 79 - } 80 - return be16_to_cpu(val); 81 - } 82 - 83 - void ina2xx_write_word(struct i2c_client *client, int reg, int data) 84 - { 85 - i2c_smbus_write_word_data(client, reg, cpu_to_be16(data)); 86 - } 87 - 88 72 static struct ina2xx_data *ina2xx_update_device(struct device *dev) 89 73 { 90 74 struct i2c_client *client = to_i2c_client(dev); ··· 86 102 87 103 /* Read all registers */ 88 104 for (i = 0; i < data->registers; i++) { 89 - int rv = ina2xx_read_word(client, i); 105 + int rv = i2c_smbus_read_word_swapped(client, i); 90 106 if (rv < 0) { 91 107 ret = ERR_PTR(rv); 92 108 goto abort; ··· 263 279 switch (data->kind) { 264 280 case ina219: 265 281 /* device configuration */ 266 - ina2xx_write_word(client, INA2XX_CONFIG, INA219_CONFIG_DEFAULT); 282 + i2c_smbus_write_word_swapped(client, INA2XX_CONFIG, 283 + INA219_CONFIG_DEFAULT); 267 284 268 285 /* set current LSB to 1mA, shunt is in uOhms */ 269 286 /* (equation 13 in datasheet) */ 270 - ina2xx_write_word(client, INA2XX_CALIBRATION, 40960000 / shunt); 287 + i2c_smbus_write_word_swapped(client, INA2XX_CALIBRATION, 288 + 40960000 / shunt); 271 289 dev_info(&client->dev, 272 290 "power monitor INA219 (Rshunt = %li uOhm)\n", shunt); 273 291 data->registers = INA219_REGISTERS; 274 292 break; 275 293 case ina226: 276 294 /* device configuration */ 277 - ina2xx_write_word(client, INA2XX_CONFIG, INA226_CONFIG_DEFAULT); 295 + i2c_smbus_write_word_swapped(client, INA2XX_CONFIG, 296 + INA226_CONFIG_DEFAULT); 278 297 279 298 /* set current LSB to 1mA, shunt is in uOhms */ 280 299 /* (equation 1 in datasheet)*/ 281 - ina2xx_write_word(client, INA2XX_CALIBRATION, 5120000 / shunt); 300 + i2c_smbus_write_word_swapped(client, INA2XX_CALIBRATION, 301 + 5120000 / shunt); 282 302 dev_info(&client->dev, 283 303 "power monitor INA226 (Rshunt = %li uOhm)\n", shunt); 284 304 data->registers = INA226_REGISTERS;
+5 -4
drivers/hwmon/twl4030-madc-hwmon.c
··· 44 44 struct device_attribute *devattr, char *buf) 45 45 { 46 46 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); 47 - struct twl4030_madc_request req; 47 + struct twl4030_madc_request req = { 48 + .channels = 1 << attr->index, 49 + .method = TWL4030_MADC_SW2, 50 + .type = TWL4030_MADC_WAIT, 51 + }; 48 52 long val; 49 53 50 - req.channels = (1 << attr->index); 51 - req.method = TWL4030_MADC_SW2; 52 - req.func_cb = NULL; 53 54 val = twl4030_madc_conversion(&req); 54 55 if (val < 0) 55 56 return val;