hwmon fixes for v5.2-rc4
Fix a couple of inconsistencies and locking problems in pmbus driver. Register with thermal subsystem only on systems supporting devicetree. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJc+sT5AAoJEMsfJm/On5mBb/kQAJwSIL7c4cOEjWikRqdVncDd 3ABXeQRopGLv5LLtox7T8rFzF29MfeGbqMR1JUZGGZh6kbTFdhPGyVNZ/unkOXQD kIoiAfgixPNEzMC7r4vhCDPRyo+bKb4AavZbdnVvh/5G6wpBzsrJ80kQyNmlHyk4 djEdIbfyNQWOMo3cpJQYm8z8tKtbmsUTqMTCJe2OhjnOl9uO6eKt6cHqBp/O4OVw jMAEfXkFLktF8oS+DT3f5NuedKEubruJ+6iUJ7RIZPMpWUP6bjrE57FlM2NKakUc f/OjpL0LHiZJWFi/3+gSFPRkLIP3VSO9xmF2hefL90AHlAkuwJqL/bT+tZ5EyL+d QmYClANL4GUmQpcwFJTBHaeRustr13E1GNkPD9Yz22qsExOkYFgZ/zRBXNoVqqQH tKUdAeMIa3yQcCSek4lc4usXK0i14u/6H5l1mlhApGuc2DYGgiXNeLIKZyiINQJM URqnvnA6lvYjSUoutop2T5P9iI8tSejU3wQH0nN2bNM7h7km/uJ6Z1IUnRrO0U6p 0AZ5vO6ZTUT0E0i+32/0MiuFIksleR8lIiWvZErVKY1y0iKyZHh9IuHsXiUwoZBX Ial1gcD/d8lM4LsXEzaFIPCLHB72UVqK9YWX5KlS4BPAsFyT8RnTJPX/8C3N0ipO OaIJTU/7kEc14G+4b6GA =QTDh -----END PGP SIGNATURE----- Merge tag 'hwmon-for-v5.2-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging Pull hwmon fixes from Guenter Roeck: - Fix a couple of inconsistencies and locking problems in pmbus driver - Register with thermal subsystem only on systems supporting devicetree * tag 'hwmon-for-v5.2-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (pmbus/core) Treat parameters as paged if on multiple pages hwmon: (pmbus/core) mutex_lock write in pmbus_set_samples hwmon: (core) add thermal sensors only if dev->of_node is present
This commit is contained in:
commit
d4425649c6
|
@ -636,7 +636,7 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,
|
|||
if (err)
|
||||
goto free_hwmon;
|
||||
|
||||
if (dev && chip && chip->ops->read &&
|
||||
if (dev && dev->of_node && chip && chip->ops->read &&
|
||||
chip->info[0]->type == hwmon_chip &&
|
||||
(chip->info[0]->config[0] & HWMON_C_REGISTER_TZ)) {
|
||||
const struct hwmon_channel_info **info = chip->info;
|
||||
|
|
|
@ -1217,7 +1217,8 @@ static int pmbus_add_sensor_attrs_one(struct i2c_client *client,
|
|||
const struct pmbus_driver_info *info,
|
||||
const char *name,
|
||||
int index, int page,
|
||||
const struct pmbus_sensor_attr *attr)
|
||||
const struct pmbus_sensor_attr *attr,
|
||||
bool paged)
|
||||
{
|
||||
struct pmbus_sensor *base;
|
||||
bool upper = !!(attr->gbit & 0xff00); /* need to check STATUS_WORD */
|
||||
|
@ -1225,7 +1226,7 @@ static int pmbus_add_sensor_attrs_one(struct i2c_client *client,
|
|||
|
||||
if (attr->label) {
|
||||
ret = pmbus_add_label(data, name, index, attr->label,
|
||||
attr->paged ? page + 1 : 0);
|
||||
paged ? page + 1 : 0);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
@ -1258,6 +1259,30 @@ static int pmbus_add_sensor_attrs_one(struct i2c_client *client,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static bool pmbus_sensor_is_paged(const struct pmbus_driver_info *info,
|
||||
const struct pmbus_sensor_attr *attr)
|
||||
{
|
||||
int p;
|
||||
|
||||
if (attr->paged)
|
||||
return true;
|
||||
|
||||
/*
|
||||
* Some attributes may be present on more than one page despite
|
||||
* not being marked with the paged attribute. If that is the case,
|
||||
* then treat the sensor as being paged and add the page suffix to the
|
||||
* attribute name.
|
||||
* We don't just add the paged attribute to all such attributes, in
|
||||
* order to maintain the un-suffixed labels in the case where the
|
||||
* attribute is only on page 0.
|
||||
*/
|
||||
for (p = 1; p < info->pages; p++) {
|
||||
if (info->func[p] & attr->func)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int pmbus_add_sensor_attrs(struct i2c_client *client,
|
||||
struct pmbus_data *data,
|
||||
const char *name,
|
||||
|
@ -1271,14 +1296,15 @@ static int pmbus_add_sensor_attrs(struct i2c_client *client,
|
|||
index = 1;
|
||||
for (i = 0; i < nattrs; i++) {
|
||||
int page, pages;
|
||||
bool paged = pmbus_sensor_is_paged(info, attrs);
|
||||
|
||||
pages = attrs->paged ? info->pages : 1;
|
||||
pages = paged ? info->pages : 1;
|
||||
for (page = 0; page < pages; page++) {
|
||||
if (!(info->func[page] & attrs->func))
|
||||
continue;
|
||||
ret = pmbus_add_sensor_attrs_one(client, data, info,
|
||||
name, index, page,
|
||||
attrs);
|
||||
attrs, paged);
|
||||
if (ret)
|
||||
return ret;
|
||||
index++;
|
||||
|
@ -1942,11 +1968,14 @@ static ssize_t pmbus_set_samples(struct device *dev,
|
|||
long val;
|
||||
struct i2c_client *client = to_i2c_client(dev->parent);
|
||||
struct pmbus_samples_reg *reg = to_samples_reg(devattr);
|
||||
struct pmbus_data *data = i2c_get_clientdata(client);
|
||||
|
||||
if (kstrtol(buf, 0, &val) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
ret = _pmbus_write_word_data(client, reg->page, reg->attr->reg, val);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return ret ? : count;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue