diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-03-04 19:29:37 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-03-04 19:29:37 -0800 |
commit | 7629bac64204ff256d3b2415767a7acb1401047b (patch) | |
tree | 02c8efad4f0b334dd715868e8b09d204e9fe0e6a /drivers | |
parent | dcc75ddea1c3dde05db2f485d617dc8431177e33 (diff) | |
parent | 985e225142cf0cb826401f5448763f13ee712b3a (diff) |
Merge tag 'hwmon-for-v5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon updates from Guenter Roeck:
- Add support for LM96000, DPS-650AB to existing drivers
- Use permission specific SENSOR[_DEVICE]_ATTR variants in several
drivers
- Replace S_<PERMS> with octal values in several drivers
- Update some license headers
- Various minor fixes and improvements in several drivers
* tag 'hwmon-for-v5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (89 commits)
dt-bindings: hwmon: Add missing documentation for lm75
hwmon: (ad7418) Add device tree probing
hwmon: (ad741x) Add DT bindings for Analog Devices AD741x
hwmon: (ntc_thermistor) Convert to new hwmon API
hwmon: (pwm-fan) Add optional regulator support
dt-bindings: hwmon: Add optional regulator support to pwm-fan
hwmon: (f71882fg) Mark expected switch fall-through
hwmon: (ad7418) Catch I2C errors
hwmon: (lm85) add support for LM96000 high frequencies
hwmon: (lm85) support the LM96000
dt-bindings: Add LM96000 as a trivial device
hwmon: (lm85) remove freq_map size hardcodes
hwmon: (occ) Fix license headers
hwmon: (via-cputemp) Use permission specific SENSOR[_DEVICE]_ATTR variants
hwmon: (vexpress-hwmon) Use permission specific SENSOR[_DEVICE]_ATTR variants
hwmon: (tmp421) Replace S_<PERMS> with octal values
hwmon: (tmp103) Use permission specific SENSOR[_DEVICE]_ATTR variants
hwmon: (tmp102) Replace S_<PERMS> with octal values
hwmon: (tc74) Use permission specific SENSOR[_DEVICE]_ATTR variants
hwmon: (tc654) Use permission specific SENSOR[_DEVICE]_ATTR variants
...
Diffstat (limited to 'drivers')
74 files changed, 2088 insertions, 2270 deletions
diff --git a/drivers/hwmon/ad7418.c b/drivers/hwmon/ad7418.c index 76f0a5c01e8a..4aeba29b4629 100644 --- a/drivers/hwmon/ad7418.c +++ b/drivers/hwmon/ad7418.c @@ -19,6 +19,7 @@ #include <linux/hwmon-sysfs.h> #include <linux/err.h> #include <linux/mutex.h> +#include <linux/of_device.h> #include <linux/delay.h> #include <linux/slab.h> @@ -54,10 +55,11 @@ struct ad7418_data { u16 in[4]; }; -static struct ad7418_data *ad7418_update_device(struct device *dev) +static int ad7418_update_device(struct device *dev) { struct ad7418_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; + s32 val; mutex_lock(&data->lock); @@ -67,47 +69,74 @@ static struct ad7418_data *ad7418_update_device(struct device *dev) int i, ch; /* read config register and clear channel bits */ - cfg = i2c_smbus_read_byte_data(client, AD7418_REG_CONF); + val = i2c_smbus_read_byte_data(client, AD7418_REG_CONF); + if (val < 0) + goto abort; + + cfg = val; cfg &= 0x1F; - i2c_smbus_write_byte_data(client, AD7418_REG_CONF, + val = i2c_smbus_write_byte_data(client, AD7418_REG_CONF, cfg | AD7418_CH_TEMP); + if (val < 0) + goto abort; + udelay(30); for (i = 0; i < 3; i++) { - data->temp[i] = - i2c_smbus_read_word_swapped(client, - AD7418_REG_TEMP[i]); + val = i2c_smbus_read_word_swapped(client, + AD7418_REG_TEMP[i]); + if (val < 0) + goto abort; + + data->temp[i] = val; } for (i = 0, ch = 4; i < data->adc_max; i++, ch--) { - i2c_smbus_write_byte_data(client, - AD7418_REG_CONF, + val = i2c_smbus_write_byte_data(client, AD7418_REG_CONF, cfg | AD7418_REG_ADC_CH(ch)); + if (val < 0) + goto abort; udelay(15); - data->in[data->adc_max - 1 - i] = - i2c_smbus_read_word_swapped(client, - AD7418_REG_ADC); + val = i2c_smbus_read_word_swapped(client, + AD7418_REG_ADC); + if (val < 0) + goto abort; + + data->in[data->adc_max - 1 - i] = val; } /* restore old configuration value */ - i2c_smbus_write_word_swapped(client, AD7418_REG_CONF, cfg); + val = i2c_smbus_write_word_swapped(client, AD7418_REG_CONF, + cfg); + if (val < 0) + goto abort; data->last_updated = jiffies; data->valid = 1; } mutex_unlock(&data->lock); + return 0; - return data; +abort: + data->valid = 0; + mutex_unlock(&data->lock); + return val; } static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct ad7418_data *data = ad7418_update_device(dev); + struct ad7418_data *data = dev_get_drvdata(dev); + int ret; + + ret = ad7418_update_device(dev); + if (ret < 0) + return ret; + return sprintf(buf, "%d\n", LM75_TEMP_FROM_REG(data->temp[attr->index])); } @@ -116,7 +145,12 @@ static ssize_t adc_show(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); - struct ad7418_data *data = ad7418_update_device(dev); + struct ad7418_data *data = dev_get_drvdata(dev); + int ret; + + ret = ad7418_update_device(dev); + if (ret < 0) + return ret; return sprintf(buf, "%d\n", ((data->in[attr->index] >> 6) * 2500 + 512) / 1024); @@ -220,7 +254,10 @@ static int ad7418_probe(struct i2c_client *client, mutex_init(&data->lock); data->client = client; - data->type = id->driver_data; + if (dev->of_node) + data->type = (enum chips)of_device_get_match_data(dev); + else + data->type = id->driver_data; switch (data->type) { case ad7416: @@ -258,9 +295,18 @@ static const struct i2c_device_id ad7418_id[] = { }; MODULE_DEVICE_TABLE(i2c, ad7418_id); +static const struct of_device_id ad7418_dt_ids[] = { + { .compatible = "adi,ad7416", .data = (void *)ad7416, }, + { .compatible = "adi,ad7417", .data = (void *)ad7417, }, + { .compatible = "adi,ad7418", .data = (void *)ad7418, }, + { } +}; +MODULE_DEVICE_TABLE(of, ad7418_dt_ids); + static struct i2c_driver ad7418_driver = { .driver = { .name = "ad7418", + .of_match_table = ad7418_dt_ids, }, .probe = ad7418_probe, .id_table = ad7418_id, diff --git a/drivers/hwmon/adm1029.c b/drivers/hwmon/adm1029.c index 8c5cdb560258..e561279aea21 100644 --- a/drivers/hwmon/adm1029.c +++ b/drivers/hwmon/adm1029.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * adm1029.c - Part of lm_sensors, Linux kernel modules for hardware monitoring * @@ -19,10 +20,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <linux/module.h> @@ -111,7 +108,7 @@ static const u8 ADM1029_REG_FAN_DIV[] = { struct adm1029_data { struct i2c_client *client; - struct mutex update_lock; + struct mutex update_lock; /* protect register access */ char valid; /* zero until following fields are valid */ unsigned long last_updated; /* in jiffies */ @@ -134,8 +131,7 @@ static struct adm1029_data *adm1029_update_device(struct device *dev) * Use the "cache" Luke, don't recheck values * if there are already checked not a long time later */ - if (time_after(jiffies, data->last_updated + HZ * 2) - || !data->valid) { + if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) { int nr; dev_dbg(&client->dev, "Updating adm1029 data\n"); @@ -174,6 +170,7 @@ show_temp(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adm1029_data *data = adm1029_update_device(dev); + return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[attr->index])); } @@ -183,9 +180,10 @@ show_fan(struct device *dev, struct device_attribute *devattr, char *buf) struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adm1029_data *data = adm1029_update_device(dev); u16 val; - if (data->fan[attr->index] == 0 - || (data->fan_div[attr->index] & 0xC0) == 0 - || data->fan[attr->index] == 255) { + + if (data->fan[attr->index] == 0 || + (data->fan_div[attr->index] & 0xC0) == 0 || + data->fan[attr->index] == 255) { return sprintf(buf, "0\n"); } @@ -199,13 +197,14 @@ show_fan_div(struct device *dev, struct device_attribute *devattr, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adm1029_data *data = adm1029_update_device(dev); + if ((data->fan_div[attr->index] & 0xC0) == 0) return sprintf(buf, "0\n"); return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[attr->index])); } -static ssize_t set_fan_div(struct device *dev, - struct device_attribute *devattr, const char *buf, size_t count) +static ssize_t set_fan_div(struct device *dev, struct device_attribute *devattr, + const char *buf, size_t count) { struct adm1029_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; @@ -213,6 +212,7 @@ static ssize_t set_fan_div(struct device *dev, u8 reg; long val; int ret = kstrtol(buf, 10, &val); + if (ret < 0) return ret; @@ -253,32 +253,27 @@ static ssize_t set_fan_div(struct device *dev, return count; } -/* - * Access rights on sysfs. S_IRUGO: Is Readable by User, Group and Others - * S_IWUSR: Is Writable by User. - */ -static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); -static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); -static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2); +/* Access rights on sysfs. */ +static SENSOR_DEVICE_ATTR(temp1_input, 0444, show_temp, NULL, 0); +static SENSOR_DEVICE_ATTR(temp2_input, 0444, show_temp, NULL, 1); +static SENSOR_DEVICE_ATTR(temp3_input, 0444, show_temp, NULL, 2); -static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, show_temp, NULL, 3); -static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO, show_temp, NULL, 4); -static SENSOR_DEVICE_ATTR(temp3_max, S_IRUGO, show_temp, NULL, 5); +static SENSOR_DEVICE_ATTR(temp1_max, 0444, show_temp, NULL, 3); +static SENSOR_DEVICE_ATTR(temp2_max, 0444, show_temp, NULL, 4); +static SENSOR_DEVICE_ATTR(temp3_max, 0444, show_temp, NULL, 5); -static SENSOR_DEVICE_ATTR(temp1_min, S_IRUGO, show_temp, NULL, 6); -static SENSOR_DEVICE_ATTR(temp2_min, S_IRUGO, show_temp, NULL, 7); -static SENSOR_DEVICE_ATTR(temp3_min, S_IRUGO, show_temp, NULL, 8); +static SENSOR_DEVICE_ATTR(temp1_min, 0444, show_temp, NULL, 6); +static SENSOR_DEVICE_ATTR(temp2_min, 0444, show_temp, NULL, 7); +static SENSOR_DEVICE_ATTR(temp3_min, 0444, show_temp, NULL, 8); -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); +static SENSOR_DEVICE_ATTR(fan1_input, 0444, show_fan, NULL, 0); +static SENSOR_DEVICE_ATTR(fan2_input, 0444, show_fan, NULL, 1); -static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO, show_fan, NULL, 2); -static SENSOR_DEVICE_ATTR(fan2_min, S_IRUGO, show_fan, NULL, 3); +static SENSOR_DEVICE_ATTR(fan1_min, 0444, show_fan, NULL, 2); +static SENSOR_DEVICE_ATTR(fan2_min, 0444, show_fan, NULL, 3); -static SENSOR_DEVICE_ATTR(fan1_div, S_IRUGO | S_IWUSR, - show_fan_div, set_fan_div, 0); -static SENSOR_DEVICE_ATTR(fan2_div, S_IRUGO | S_IWUSR, - show_fan_div, set_fan_div, 1); +static SENSOR_DEVICE_ATTR(fan1_div, 0644, show_fan_div, set_fan_div, 0); +static SENSOR_DEVICE_ATTR(fan2_div, 0644, show_fan_div, set_fan_div, 1); static struct attribute *adm1029_attrs[] = { &sensor_dev_attr_temp1_input.dev_attr.attr, @@ -327,10 +322,10 @@ static int adm1029_detect(struct i2c_client *client, temp_devices_installed = i2c_smbus_read_byte_data(client, ADM1029_REG_TEMP_DEVICES_INSTALLED); nb_fan_support = i2c_smbus_read_byte_data(client, - ADM1029_REG_NB_FAN_SUPPORT); + ADM1029_REG_NB_FAN_SUPPORT); /* 0x41 is Analog Devices */ - if (man_id != 0x41 || (temp_devices_installed & 0xf9) != 0x01 - || nb_fan_support != 0x03) + if (man_id != 0x41 || (temp_devices_installed & 0xf9) != 0x01 || + nb_fan_support != 0x03) return -ENODEV; if ((chip_id & 0xF0) != 0x00) { diff --git a/drivers/hwmon/adt7462.c b/drivers/hwmon/adt7462.c index b0211f731251..030f5d49c061 100644 --- a/drivers/hwmon/adt7462.c +++ b/drivers/hwmon/adt7462.c @@ -448,6 +448,7 @@ static const char *voltage_label(struct adt7462_data *data, int which) case 3: return "+1.5V"; } + /* fall through */ case 2: if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT)) return "+12V3"; @@ -505,6 +506,7 @@ static const char *voltage_label(struct adt7462_data *data, int which) case 3: return "+1.5"; } + /* fall through */ case 11: if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == ADT7462_PIN28_VOLT && @@ -542,6 +544,7 @@ static int voltage_multiplier(struct adt7462_data *data, int which) case 3: return 7800; } + /* fall through */ case 2: if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT)) return 62500; @@ -599,6 +602,7 @@ static int voltage_multiplier(struct adt7462_data *data, int which) case 3: return 7800; } + /* fall through */ case 11: case 12: if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT == diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index 68c9a6664557..a6a38ceec174 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -82,9 +82,15 @@ static bool disallow_fan_support; #define I8K_HWMON_HAVE_TEMP2 (1 << 1) #define I8K_HWMON_HAVE_TEMP3 (1 << 2) #define I8K_HWMON_HAVE_TEMP4 (1 << 3) -#define I8K_HWMON_HAVE_FAN1 (1 << 4) -#define I8K_HWMON_HAVE_FAN2 (1 << 5) -#define I8K_HWMON_HAVE_FAN3 (1 << 6) +#define I8K_HWMON_HAVE_TEMP5 (1 << 4) +#define I8K_HWMON_HAVE_TEMP6 (1 << 5) +#define I8K_HWMON_HAVE_TEMP7 (1 << 6) +#define I8K_HWMON_HAVE_TEMP8 (1 << 7) +#define I8K_HWMON_HAVE_TEMP9 (1 << 8) +#define I8K_HWMON_HAVE_TEMP10 (1 << 9) +#define I8K_HWMON_HAVE_FAN1 (1 << 10) +#define I8K_HWMON_HAVE_FAN2 (1 << 11) +#define I8K_HWMON_HAVE_FAN3 (1 << 12) MODULE_AUTHOR("Massimo Dal Zotto (dz@debian.org)"); MODULE_AUTHOR("Pali Rohár <pali.rohar@gmail.com>"); @@ -737,6 +743,18 @@ static SENSOR_DEVICE_ATTR_RO(temp3_input, i8k_hwmon_temp, 2); static SENSOR_DEVICE_ATTR_RO(temp3_label, i8k_hwmon_temp_label, 2); static SENSOR_DEVICE_ATTR_RO(temp4_input, i8k_hwmon_temp, 3); static SENSOR_DEVICE_ATTR_RO(temp4_label, i8k_hwmon_temp_label, 3); +static SENSOR_DEVICE_ATTR_RO(temp5_input, i8k_hwmon_temp, 4); +static SENSOR_DEVICE_ATTR_RO(temp5_label, i8k_hwmon_temp_label, 4); +static SENSOR_DEVICE_ATTR_RO(temp6_input, i8k_hwmon_temp, 5); +static SENSOR_DEVICE_ATTR_RO(temp6_label, i8k_hwmon_temp_label, 5); +static SENSOR_DEVICE_ATTR_RO(temp7_input, i8k_hwmon_temp, 6); +static SENSOR_DEVICE_ATTR_RO(temp7_label, i8k_hwmon_temp_label, 6); +static SENSOR_DEVICE_ATTR_RO(temp8_input, i8k_hwmon_temp, 7); +static SENSOR_DEVICE_ATTR_RO(temp8_label, i8k_hwmon_temp_label, 7); +static SENSOR_DEVICE_ATTR_RO(temp9_input, i8k_hwmon_temp, 8); +static SENSOR_DEVICE_ATTR_RO(temp9_label, i8k_hwmon_temp_label, 8); +static SENSOR_DEVICE_ATTR_RO(temp10_input, i8k_hwmon_temp, 9); +static SENSOR_DEVICE_ATTR_RO(temp10_label, i8k_hwmon_temp_label, 9); static SENSOR_DEVICE_ATTR_RO(fan1_input, i8k_hwmon_fan, 0); static SENSOR_DEVICE_ATTR_RO(fan1_label, i8k_hwmon_fan_label, 0); static SENSOR_DEVICE_ATTR_RW(pwm1, i8k_hwmon_pwm, 0); @@ -756,15 +774,27 @@ static struct attribute *i8k_attrs[] = { &sensor_dev_attr_temp3_label.dev_attr.attr, /* 5 */ &sensor_dev_attr_temp4_input.dev_attr.attr, /* 6 */ &sensor_dev_attr_temp4_label.dev_attr.attr, /* 7 */ - &sensor_dev_attr_fan1_input.dev_attr.attr, /* 8 */ - &sensor_dev_attr_fan1_label.dev_attr.attr, /* 9 */ - &sensor_dev_attr_pwm1.dev_attr.attr, /* 10 */ - &sensor_dev_attr_fan2_input.dev_attr.attr, /* 11 */ - &sensor_dev_attr_fan2_label.dev_attr.attr, /* 12 */ - &sensor_dev_attr_pwm2.dev_attr.attr, /* 13 */ - &sensor_dev_attr_fan3_input.dev_attr.attr, /* 14 */ - &sensor_dev_attr_fan3_label.dev_attr.attr, /* 15 */ - &sensor_dev_attr_pwm3.dev_attr.attr, /* 16 */ + &sensor_dev_attr_temp5_input.dev_attr.attr, /* 8 */ + &sensor_dev_attr_temp5_label.dev_attr.attr, /* 9 */ + &sensor_dev_attr_temp6_input.dev_attr.attr, /* 10 */ + &sensor_dev_attr_temp6_label.dev_attr.attr, /* 11 */ + &sensor_dev_attr_temp7_input.dev_attr.attr, /* 12 */ + &sensor_dev_attr_temp7_label.dev_attr.attr, /* 13 */ + &sensor_dev_attr_temp8_input.dev_attr.attr, /* 14 */ + &sensor_dev_attr_temp8_label.dev_attr.attr, /* 15 */ + &sensor_dev_attr_temp9_input.dev_attr.attr, /* 16 */ + &sensor_dev_attr_temp9_label.dev_attr.attr, /* 17 */ + &sensor_dev_attr_temp10_input.dev_attr.attr, /* 18 */ + &sensor_dev_attr_temp10_label.dev_attr.attr, /* 19 */ + &sensor_dev_attr_fan1_input.dev_attr.attr, /* 20 */ + &sensor_dev_attr_fan1_label.dev_attr.attr, /* 21 */ + &sensor_dev_attr_pwm1.dev_attr.attr, /* 22 */ + &sensor_dev_attr_fan2_input.dev_attr.attr, /* 23 */ + &sensor_dev_attr_fan2_label.dev_attr.attr, /* 24 */ + &sensor_dev_attr_pwm2.dev_attr.attr, /* 25 */ + &sensor_dev_attr_fan3_input.dev_attr.attr, /* 26 */ + &sensor_dev_attr_fan3_label.dev_attr.attr, /* 27 */ + &sensor_dev_attr_pwm3.dev_attr.attr, /* 28 */ NULL }; @@ -788,13 +818,32 @@ static umode_t i8k_is_visible(struct kobject *kobj, struct attribute *attr, if (index >= 6 && index <= 7 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP4)) return 0; - if (index >= 8 && index <= 10 && + if (index >= 8 && index <= 9 && + !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP5)) + return 0; + if (index >= 10 && index <= 11 && + !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP6)) + return 0; + if (index >= 12 && index <= 13 && + !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP7)) + return 0; + if (index >= 14 && index <= 15 && + !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP8)) + return 0; + if (index >= 16 && index <= 17 && + !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP9)) + return 0; + if (index >= 18 && index <= 19 && + !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP10)) + return 0; + + if (index >= 20 && index <= 22 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_FAN1)) return 0; - if (index >= 11 && index <= 13 && + if (index >= 23 && index <= 25 && !( |