hwmon updates for v4.8 (take 2)

Improved error handling in  tmp102, lm75, and lm90 drivers
 Bug fixes in sht3x, ftsteutates, iio_hwmon, and adt7411 drivers
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJXnnZHAAoJEMsfJm/On5mBIgsQAK1o7j1ODYlvA4MONJ1MtBpq
 ojO7iELtpqeR2EIB1vHE3bNvIpwH7gdYcPAnXKeWj5OKCnliAYlYhC1RptZpyvaX
 6/GQrn93G2KHkkktbtlrs2pSzuzt8eFLrgzrvkPzNFjMEAa73hi7yO1Tt67urS0H
 t3crr0rbX4448l1taqjiB8vMKvBK6pL9Nq61oPks0FVaBewRQKnmHqyZsKd6CtcN
 Wlqy0D0ZASs0xWI1MlVVOqvBHXEAHb0UGpBlHtUeU+oTDpX7EMPbhev5vZYlBa95
 ot7PfGo+gh5f/oiFoIJ1m96+zdvujT+apAHZrquFzlBn0WhkQRMZlItoXqOkw/cn
 W+ybTgDbxvU/vmldPZk5eSej8RCK8omA0wx9d1zNWpRERUiUjwjetFZAnNltQarN
 twMor52GM1L7frLeno0gYyo3VqrCWQspmE4UDqhsLln0Z1k7aMKxW61Ev4xRKEMX
 MNaBAG83J7TPDpFKV3A/yT0nOgfmz915QQ9MFFa0RpY5ob439tC/wRsOib09AsNm
 hbCbyzNH3WnSxB7hZ1iaj9QpymmKt7G1BuKob2gA4S5VS1UtWXx9SHOYS3rmCgwV
 CGY3EpocTtjDkmx0v7aYoDmebLj117CXXFOK73tGmcK48CWjLt4RduR28Q5RyEgz
 1wSA31hiF++O+g+SvKlT
 =cv+q
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2016-08-01 16:49:13 -04:00
Родитель f38d2e5313 601807bbb7
Коммит 2790aed095
7 изменённых файлов: 73 добавлений и 27 удалений

Просмотреть файл

@ -30,6 +30,7 @@
#define ADT7411_REG_CFG1 0x18
#define ADT7411_CFG1_START_MONITOR (1 << 0)
#define ADT7411_CFG1_RESERVED_BIT1 (1 << 1)
#define ADT7411_CFG1_RESERVED_BIT3 (1 << 3)
#define ADT7411_REG_CFG2 0x19
@ -37,6 +38,9 @@
#define ADT7411_REG_CFG3 0x1a
#define ADT7411_CFG3_ADC_CLK_225 (1 << 0)
#define ADT7411_CFG3_RESERVED_BIT1 (1 << 1)
#define ADT7411_CFG3_RESERVED_BIT2 (1 << 2)
#define ADT7411_CFG3_RESERVED_BIT3 (1 << 3)
#define ADT7411_CFG3_REF_VDD (1 << 4)
#define ADT7411_REG_DEVICE_ID 0x4d
@ -280,6 +284,45 @@ static int adt7411_detect(struct i2c_client *client,
return 0;
}
static int adt7411_init_device(struct adt7411_data *data)
{
int ret;
u8 val;
ret = i2c_smbus_read_byte_data(data->client, ADT7411_REG_CFG3);
if (ret < 0)
return ret;
/*
* We must only write zero to bit 1 and bit 2 and only one to bit 3
* according to the datasheet.
*/
val = ret;
val &= ~(ADT7411_CFG3_RESERVED_BIT1 | ADT7411_CFG3_RESERVED_BIT2);
val |= ADT7411_CFG3_RESERVED_BIT3;
ret = i2c_smbus_write_byte_data(data->client, ADT7411_REG_CFG3, val);
if (ret < 0)
return ret;
ret = i2c_smbus_read_byte_data(data->client, ADT7411_REG_CFG1);
if (ret < 0)
return ret;
/*
* We must only write zero to bit 1 and only one to bit 3 according to
* the datasheet.
*/
val = ret;
val &= ~ADT7411_CFG1_RESERVED_BIT1;
val |= ADT7411_CFG1_RESERVED_BIT3;
/* enable monitoring */
val |= ADT7411_CFG1_START_MONITOR;
return i2c_smbus_write_byte_data(data->client, ADT7411_REG_CFG1, val);
}
static int adt7411_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@ -297,10 +340,7 @@ static int adt7411_probe(struct i2c_client *client,
mutex_init(&data->device_lock);
mutex_init(&data->update_lock);
/* According to the datasheet, we must only write 1 to bit 3 */
ret = adt7411_modify_bit(client, ADT7411_REG_CFG1,
ADT7411_CFG1_RESERVED_BIT3
| ADT7411_CFG1_START_MONITOR, 1);
ret = adt7411_init_device(data);
if (ret < 0)
return ret;

Просмотреть файл

@ -242,7 +242,7 @@ static int fts_wd_set_resolution(struct fts_data *data,
}
if (resolution == seconds)
set_bit(1, (unsigned long *)&ret);
ret |= BIT(1);
else
ret &= ~BIT(1);

Просмотреть файл

@ -110,24 +110,24 @@ static int iio_hwmon_probe(struct platform_device *pdev)
switch (type) {
case IIO_VOLTAGE:
a->dev_attr.attr.name = kasprintf(GFP_KERNEL,
"in%d_input",
in_i++);
a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
"in%d_input",
in_i++);
break;
case IIO_TEMP:
a->dev_attr.attr.name = kasprintf(GFP_KERNEL,
"temp%d_input",
temp_i++);
a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
"temp%d_input",
temp_i++);
break;
case IIO_CURRENT:
a->dev_attr.attr.name = kasprintf(GFP_KERNEL,
"curr%d_input",
curr_i++);
a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
"curr%d_input",
curr_i++);
break;
case IIO_HUMIDITYRELATIVE:
a->dev_attr.attr.name = kasprintf(GFP_KERNEL,
"humidity%d_input",
humidity_i++);
a->dev_attr.attr.name = devm_kasprintf(dev, GFP_KERNEL,
"humidity%d_input",
humidity_i++);
break;
default:
ret = -EINVAL;

Просмотреть файл

@ -220,7 +220,7 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
struct device *dev = &client->dev;
struct device *hwmon_dev;
struct lm75_data *data;
int status;
int status, err;
u8 set_mask, clr_mask;
int new;
enum lm75_type kind = id->driver_data;
@ -331,7 +331,9 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
if (status != new)
i2c_smbus_write_byte_data(client, LM75_REG_CONF, new);
devm_add_action(dev, lm75_remove, data);
err = devm_add_action_or_reset(dev, lm75_remove, data);
if (err)
return err;
dev_dbg(dev, "Config %02x\n", new);

Просмотреть файл

@ -529,7 +529,7 @@ static int lm90_update_limits(struct device *dev)
return val;
data->temp_hyst = val;
lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH);
val = lm90_read_reg(client, LM90_REG_R_REMOTE_LOWH);
if (val < 0)
return val;
data->temp11[REMOTE_LOW] = val << 8;
@ -1551,9 +1551,7 @@ static int lm90_init_client(struct i2c_client *client, struct lm90_data *data)
if (config != data->config_orig) /* Only write if changed */
i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1, config);
devm_add_action(&client->dev, lm90_restore_conf, data);
return 0;
return devm_add_action_or_reset(&client->dev, lm90_restore_conf, data);
}
static bool lm90_is_tripped(struct i2c_client *client, u16 *status)
@ -1640,7 +1638,9 @@ static int lm90_probe(struct i2c_client *client,
return err;
}
devm_add_action(dev, lm90_regulator_disable, regulator);
err = devm_add_action_or_reset(dev, lm90_regulator_disable, regulator);
if (err)
return err;
data = devm_kzalloc(dev, sizeof(struct lm90_data), GFP_KERNEL);
if (!data)
@ -1696,7 +1696,9 @@ static int lm90_probe(struct i2c_client *client,
err = device_create_file(dev, &dev_attr_pec);
if (err)
return err;
devm_add_action(dev, lm90_remove_pec, dev);
err = devm_add_action_or_reset(dev, lm90_remove_pec, dev);
if (err)
return err;
}
hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,

Просмотреть файл

@ -720,7 +720,7 @@ static int sht3x_probe(struct i2c_client *client,
data->setup.blocking_io = false;
data->setup.high_precision = true;
data->mode = 0;
data->last_update = 0;
data->last_update = jiffies - msecs_to_jiffies(3000);
data->client = client;
crc8_populate_msb(sht3x_crc8_table, SHT3X_CRC8_POLYNOMIAL);

Просмотреть файл

@ -227,7 +227,9 @@ static int tmp102_probe(struct i2c_client *client,
tmp102->config_orig = regval;
devm_add_action(dev, tmp102_restore_config, tmp102);
err = devm_add_action_or_reset(dev, tmp102_restore_config, tmp102);
if (err)
return err;
regval &= ~TMP102_CONFIG_CLEAR;
regval |= TMP102_CONFIG_SET;