aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-08-01 16:49:13 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-08-01 16:49:13 -0400
commit2790aed095fe50b21ab7ed94dc34a0f410a3872c (patch)
tree842f28c60c19d52029b71d9b623393b2057b7c34
parentf38d2e5313f0af9d9b66c02a5d49c71deb994b85 (diff)
parent601807bbb7b422012492611b283bdf3647d3742c (diff)
Merge tag 'hwmon-for-linus-v4.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull more hwmon updates from Guenter Roeck: - Improved error handling in tmp102, lm75, and lm90 drivers - Bug fixes in sht3x, ftsteutates, iio_hwmon, and adt7411 drivers * tag 'hwmon-for-linus-v4.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (adt7411) set sane values for CFG1 and CFG3 hwmon: (iio_hwmon) fix memory leak in name attribute hwmon: (ftsteutates) Fix potential memory access error hwmon: (tmp102) Improve error handling hwmon: (lm75) Improve error handling hwmon: (lm90) Improve error handling hwmon: (lm90) Add missing assignment hwmon: (sht3x) set initial jiffies to last_update
-rw-r--r--drivers/hwmon/adt7411.c48
-rw-r--r--drivers/hwmon/ftsteutates.c2
-rw-r--r--drivers/hwmon/iio_hwmon.c24
-rw-r--r--drivers/hwmon/lm75.c6
-rw-r--r--drivers/hwmon/lm90.c14
-rw-r--r--drivers/hwmon/sht3x.c2
-rw-r--r--drivers/hwmon/tmp102.c4
7 files changed, 73 insertions, 27 deletions
diff --git a/drivers/hwmon/adt7411.c b/drivers/hwmon/adt7411.c
index a7f886961830..fc1e65a263a4 100644
--- a/drivers/hwmon/adt7411.c
+++ b/drivers/hwmon/adt7411.c
@@ -30,6 +30,7 @@
30 30
31#define ADT7411_REG_CFG1 0x18 31#define ADT7411_REG_CFG1 0x18
32#define ADT7411_CFG1_START_MONITOR (1 << 0) 32#define ADT7411_CFG1_START_MONITOR (1 << 0)
33#define ADT7411_CFG1_RESERVED_BIT1 (1 << 1)
33#define ADT7411_CFG1_RESERVED_BIT3 (1 << 3) 34#define ADT7411_CFG1_RESERVED_BIT3 (1 << 3)
34 35
35#define ADT7411_REG_CFG2 0x19 36#define ADT7411_REG_CFG2 0x19
@@ -37,6 +38,9 @@
37 38
38#define ADT7411_REG_CFG3 0x1a 39#define ADT7411_REG_CFG3 0x1a
39#define ADT7411_CFG3_ADC_CLK_225 (1 << 0) 40#define ADT7411_CFG3_ADC_CLK_225 (1 << 0)
41#define ADT7411_CFG3_RESERVED_BIT1 (1 << 1)
42#define ADT7411_CFG3_RESERVED_BIT2 (1 << 2)
43#define ADT7411_CFG3_RESERVED_BIT3 (1 << 3)
40#define ADT7411_CFG3_REF_VDD (1 << 4) 44#define ADT7411_CFG3_REF_VDD (1 << 4)
41 45
42#define ADT7411_REG_DEVICE_ID 0x4d 46#define ADT7411_REG_DEVICE_ID 0x4d
@@ -280,6 +284,45 @@ static int adt7411_detect(struct i2c_client *client,
280 return 0; 284 return 0;
281} 285}
282 286
287static int adt7411_init_device(struct adt7411_data *data)
288{
289 int ret;
290 u8 val;
291
292 ret = i2c_smbus_read_byte_data(data->client, ADT7411_REG_CFG3);
293 if (ret < 0)
294 return ret;
295
296 /*
297 * We must only write zero to bit 1 and bit 2 and only one to bit 3
298 * according to the datasheet.
299 */
300 val = ret;
301 val &= ~(ADT7411_CFG3_RESERVED_BIT1 | ADT7411_CFG3_RESERVED_BIT2);
302 val |= ADT7411_CFG3_RESERVED_BIT3;
303
304 ret = i2c_smbus_write_byte_data(data->client, ADT7411_REG_CFG3, val);
305 if (ret < 0)
306 return ret;
307
308 ret = i2c_smbus_read_byte_data(data->client, ADT7411_REG_CFG1);
309 if (ret < 0)
310 return ret;
311
312 /*
313 * We must only write zero to bit 1 and only one to bit 3 according to
314 * the datasheet.
315 */
316 val = ret;
317 val &= ~ADT7411_CFG1_RESERVED_BIT1;
318 val |= ADT7411_CFG1_RESERVED_BIT3;
319
320 /* enable monitoring */
321 val |= ADT7411_CFG1_START_MONITOR;
322
323 return i2c_smbus_write_byte_data(data->client, ADT7411_REG_CFG1, val);
324}
325
283static int adt7411_probe(struct i2c_client *client, 326static int adt7411_probe(struct i2c_client *client,
284 const struct i2c_device_id *id) 327 const struct i2c_device_id *id)
285{ 328{
@@ -297,10 +340,7 @@ static int adt7411_probe(struct i2c_client *client,
297 mutex_init(&data->device_lock); 340 mutex_init(&data->device_lock);
298 mutex_init(&data->update_lock); 341 mutex_init(&data->update_lock);
299 342
300 /* According to the datasheet, we must only write 1 to bit 3 */ 343 ret = adt7411_init_device(data);
301 ret = adt7411_modify_bit(client, ADT7411_REG_CFG1,
302 ADT7411_CFG1_RESERVED_BIT3
303 | ADT7411_CFG1_START_MONITOR, 1);
304 if (ret < 0) 344 if (ret < 0)
305 return ret; 345 return ret;
306 346
diff --git a/drivers/hwmon/ftsteutates.c b/drivers/hwmon/ftsteutates.c
index 2b2ff67026be..48633e541dc3 100644
--- a/drivers/hwmon/ftsteutates.c
+++ b/drivers/hwmon/ftsteutates.c
@@ -242,7 +242,7 @@ static int fts_wd_set_resolution(struct fts_data *data,
242 } 242 }
243 243
244 if (resolution == seconds) 244 if (resolution == seconds)
245 set_bit(1, (unsigned long *)&ret); 245 ret |= BIT(1);
246 else 246 else
247 ret &= ~BIT(1); 247 ret &= ~BIT(1);
248 248
diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
index b550ba5fa58a..89449871bca7 100644
--- a/drivers/hwmon/iio_hwmon.c
+++ b/drivers/hwmon/iio_hwmon.c
@@ -110,24 +110,24 @@ static int iio_hwmon_probe(struct platform_device *pdev)
110 110
111 switch (type) { 111 switch (type) {
112 case IIO_VOLTAGE: 112 case IIO_VOLTAGE:
113 a->dev_attr.attr.name = kasprintf(GFP_KERNEL, 113 a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
114 "in%d_input", 114 "in%d_input",
115 in_i++); 115 in_i++);
116 break; 116 break;
117 case IIO_TEMP: 117 case IIO_TEMP:
118 a->dev_attr.attr.name = kasprintf(GFP_KERNEL, 118 a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
119 "temp%d_input", 119 "temp%d_input",
120 temp_i++); 120 temp_i++);
121 break; 121 break;
122 case IIO_CURRENT: 122 case IIO_CURRENT:
123 a->dev_attr.attr.name = kasprintf(GFP_KERNEL, 123 a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
124 "curr%d_input", 124 "curr%d_input",
125 curr_i++); 125 curr_i++);
126 break; 126 break;
127 case IIO_HUMIDITYRELATIVE: 127 case IIO_HUMIDITYRELATIVE:
128 a->dev_attr.attr.name = kasprintf(GFP_KERNEL, 128 a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
129 "humidity%d_input", 129 "humidity%d_input",
130 humidity_i++); 130 humidity_i++);
131 break; 131 break;
132 default: 132 default:
133 ret = -EINVAL; 133 ret = -EINVAL;
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 547a9c87c68c..92f9d4bbf597 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -220,7 +220,7 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
220 struct device *dev = &client->dev; 220 struct device *dev = &client->dev;
221 struct device *hwmon_dev; 221 struct device *hwmon_dev;
222 struct lm75_data *data; 222 struct lm75_data *data;
223 int status; 223 int status, err;
224 u8 set_mask, clr_mask; 224 u8 set_mask, clr_mask;
225 int new; 225 int new;
226 enum lm75_type kind = id->driver_data; 226 enum lm75_type kind = id->driver_data;
@@ -331,7 +331,9 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
331 if (status != new) 331 if (status != new)
332 i2c_smbus_write_byte_data(client, LM75_REG_CONF, new); 332 i2c_smbus_write_byte_data(client, LM75_REG_CONF, new);
333 333
334 devm_add_action(dev, lm75_remove, data); 334 err = devm_add_action_or_reset(dev, lm75_remove, data);
335 if (err)
336 return err;
335 337
336 dev_dbg(dev, "Config %02x\n", new); 338 dev_dbg(dev, "Config %02x\n", new);
337 339
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 1e8237478b2f..496e771b363f 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -529,7 +529,7 @@ static int lm90_update_limits(struct device *dev)
529 return val; 529 return val;
530 data->temp_hyst = val; 530 data->temp_hyst = val;
531 531
532 lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH); 532 val = lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH);
533 if (val < 0) 533 if (val < 0)
534 return val; 534 return val;
535 data->temp11[REMOTE_LOW] = val << 8; 535 data->temp11[REMOTE_LOW] = val << 8;
@@ -1551,9 +1551,7 @@ static int lm90_init_client(struct i2c_client *client, struct lm90_data *data)
1551 if (config != data->config_orig) /* Only write if changed */ 1551 if (config != data->config_orig) /* Only write if changed */
1552 i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config); 1552 i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config);
1553 1553
1554 devm_add_action(&client->dev, lm90_restore_conf, data); 1554 return devm_add_action_or_reset(&client->dev, lm90_restore_conf, data);
1555
1556 return 0;
1557} 1555}
1558 1556
1559static bool lm90_is_tripped(struct i2c_client *client, u16 *status) 1557static bool lm90_is_tripped(struct i2c_client *client, u16 *status)
@@ -1640,7 +1638,9 @@ static int lm90_probe(struct i2c_client *client,
1640 return err; 1638 return err;
1641 } 1639 }
1642 1640
1643 devm_add_action(dev, lm90_regulator_disable, regulator); 1641 err = devm_add_action_or_reset(dev, lm90_regulator_disable, regulator);
1642 if (err)
1643 return err;
1644 1644
1645 data = devm_kzalloc(dev, sizeof(struct lm90_data), GFP_KERNEL); 1645 data = devm_kzalloc(dev, sizeof(struct lm90_data), GFP_KERNEL);
1646 if (!data) 1646 if (!data)
@@ -1696,7 +1696,9 @@ static int lm90_probe(struct i2c_client *client,
1696 err = device_create_file(dev, &dev_attr_pec); 1696 err = device_create_file(dev, &dev_attr_pec);
1697 if (err) 1697 if (err)
1698 return err; 1698 return err;
1699 devm_add_action(dev, lm90_remove_pec, dev); 1699 err = devm_add_action_or_reset(dev, lm90_remove_pec, dev);
1700 if (err)
1701 return err;
1700 } 1702 }
1701 1703
1702 hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name, 1704 hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c
index b73a48832732..6ea99cd6ae79 100644
--- a/drivers/hwmon/sht3x.c
+++ b/drivers/hwmon/sht3x.c
@@ -720,7 +720,7 @@ static int sht3x_probe(struct i2c_client *client,
720 data->setup.blocking_io = false; 720 data->setup.blocking_io = false;
721 data->setup.high_precision = true; 721 data->setup.high_precision = true;
722 data->mode = 0; 722 data->mode = 0;
723 data->last_update = 0; 723 data->last_update = jiffies - msecs_to_jiffies(3000);
724 data->client = client; 724 data->client = client;
725 crc8_populate_msb(sht3x_crc8_table, SHT3X_CRC8_POLYNOMIAL); 725 crc8_populate_msb(sht3x_crc8_table, SHT3X_CRC8_POLYNOMIAL);
726 726
diff --git a/drivers/hwmon/tmp102.c b/drivers/hwmon/tmp102.c
index a942a2574a4d..8479ac5eb853 100644
--- a/drivers/hwmon/tmp102.c
+++ b/drivers/hwmon/tmp102.c
@@ -227,7 +227,9 @@ static int tmp102_probe(struct i2c_client *client,
227 227
228 tmp102->config_orig = regval; 228 tmp102->config_orig = regval;
229 229
230 devm_add_action(dev, tmp102_restore_config, tmp102); 230 err = devm_add_action_or_reset(dev, tmp102_restore_config, tmp102);
231 if (err)
232 return err;
231 233
232 regval &= ~TMP102_CONFIG_CLEAR; 234 regval &= ~TMP102_CONFIG_CLEAR;
233 regval |= TMP102_CONFIG_SET; 235 regval |= TMP102_CONFIG_SET;