summaryrefslogtreecommitdiff
path: root/drivers/hwmon/tmp421.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2025-12-04 12:19:49 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2025-12-04 12:19:49 -0800
commit02892f90a9851f508e557b3c75e93fc178310d5f (patch)
treedce4a63d452b76b565919aef70e8edb401bd8f43 /drivers/hwmon/tmp421.c
parentfca5327eaa8117b18c8faf79154d6eafecaf4892 (diff)
parent30ca0e049f507001c6377e28482a636689351f64 (diff)
Merge tag 'hwmon-for-v6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon updates from Guenter Roeck: "New drivers: - Apple Silicon SMC - TSC1641 I2C power monitor - MPS MP9945 - MAX17616 - MP2925 and MP2929 Added support for new devices to existing drivers: - dell-smm: Add Dell G5 5505 to fan control whitelist - aspeed-g6-pwm-tach: Support for AST2700 - asus-ec-sensors: Support for ROG STRIX X470-I GAMING, ROG STRIX X870-F GAMING WIFI, ROG STRIX X870E-H GAMING WIFI7, and Pro WS TRX50-SAGE WIFI - k10temp: Support for AMD Steam Deck APU ID - pmbus/isl68137: Support for raa229141 - aht10: Support for dht20 - adt7410: Support for ADT7422 - peci: Support for Intel Emerald Rapids - nct6775: Support for ASUS ROG STRIX X870E-H GAMING WIFI7 - pmbus/max34440: Support for ADPM12200 - ntc-thermistor: Support for Murata ncp18wm474 Infrastructure updates: - Utilize subsystem locking in various drivers - ltc4282, ltc2947: Use the new energy64 attribute Bug fixes: - Various drivers: Fixes to avoid TOCTOU, mostly in macro functions evaluating parameters multiple times, as well as missing locks - max6697: Fix regmap leak on probe failure - sy7636a: Fix regulator_enable resource leak on error path - asus-ec-sensors: Correct Pro WS TRX50-SAGE WIFI entry Other changes and improvements: - w83781d, lm78: Drop REALLY_SLOW_IO - Fix broken datasheet links in various drivers And various other minor fixes and improvements" * tag 'hwmon-for-v6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (110 commits) hwmon: (dell-smm) Add Dell G5 5505 to fan control whitelist hwmon: (max16065) Use local variable to avoid TOCTOU hwmon: (w83l786ng) Convert macros to functions to avoid TOCTOU hwmon: (max6697) fix regmap leak on probe failure hwmon/w83781d: Drop REALLY_SLOW_IO setting hwmon/lm78: Drop REALLY_SLOW_IO setting hwmon: sy7636a: Fix regulator_enable resource leak on error path hwmon: (adm1026) Convert macros to functions to avoid TOCTOU hwmon: (adm1029) Add locking to avoid TOCTOU hwmon: (lm87) Convert macros to functions to avoid TOCTOU hwmon: (asus-ec-sensors) correct Pro WS TRX50-SAGE WIFI entry hwmon: (vt8231) Convert macros to functions to avoid TOCTOU hwmon: (emc2103) Add locking to avoid TOCTOU hwmon: (aspeed-g6-pwm-tach): Add AST2700 compatible string dt-bindings: hwmon: Add AST2700 compatible hwmon: (asus-ec-sensors) add ROG STRIX X470-I GAMING hwmon: (vt1211) Convert macros to functions to avoid TOCTOU hwmon: (k10temp) Add AMD Steam Deck APU ID hwmon: Add Apple Silicon SMC hwmon driver Documentation/hwmon: Fix broken datasheet links for zl6100 ...
Diffstat (limited to 'drivers/hwmon/tmp421.c')
-rw-r--r--drivers/hwmon/tmp421.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/drivers/hwmon/tmp421.c b/drivers/hwmon/tmp421.c
index 9537727aad9a..2ea9d3e9553d 100644
--- a/drivers/hwmon/tmp421.c
+++ b/drivers/hwmon/tmp421.c
@@ -19,7 +19,6 @@
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
-#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/sysfs.h>
@@ -99,7 +98,6 @@ struct tmp421_channel {
struct tmp421_data {
struct i2c_client *client;
- struct mutex update_lock;
u32 temp_config[MAX_CHANNELS + 1];
struct hwmon_channel_info temp_info;
const struct hwmon_channel_info *info[2];
@@ -130,38 +128,28 @@ static int tmp421_update_device(struct tmp421_data *data)
int ret = 0;
int i;
- mutex_lock(&data->update_lock);
-
if (time_after(jiffies, data->last_updated + (HZ / 2)) ||
!data->valid) {
+ data->valid = false;
ret = i2c_smbus_read_byte_data(client, TMP421_CONFIG_REG_1);
if (ret < 0)
- goto exit;
+ return ret;
data->config = ret;
for (i = 0; i < data->channels; i++) {
ret = i2c_smbus_read_byte_data(client, TMP421_TEMP_MSB[i]);
if (ret < 0)
- goto exit;
+ return ret;
data->channel[i].temp = ret << 8;
ret = i2c_smbus_read_byte_data(client, TMP421_TEMP_LSB[i]);
if (ret < 0)
- goto exit;
+ return ret;
data->channel[i].temp |= ret;
}
data->last_updated = jiffies;
data->valid = true;
}
-
-exit:
- mutex_unlock(&data->update_lock);
-
- if (ret < 0) {
- data->valid = false;
- return ret;
- }
-
return 0;
}
@@ -262,7 +250,6 @@ static umode_t tmp421_is_visible(const void *data, enum hwmon_sensor_types type,
switch (attr) {
case hwmon_temp_fault:
case hwmon_temp_input:
- return 0444;
case hwmon_temp_label:
return 0444;
case hwmon_temp_enable:
@@ -381,7 +368,11 @@ static int tmp421_probe_child_from_dt(struct i2c_client *client,
return -EINVAL;
}
- of_property_read_string(child, "label", &data->channel[i].label);
+ err = of_property_read_string(child, "label", &data->channel[i].label);
+ if (err == -ENODATA || err == -EILSEQ) {
+ dev_err(dev, "invalid label property in %pOFn\n", child);
+ return err;
+ }
if (data->channel[i].label)
data->temp_config[i] |= HWMON_T_LABEL;
@@ -442,7 +433,6 @@ static int tmp421_probe(struct i2c_client *client)
if (!data)
return -ENOMEM;
- mutex_init(&data->update_lock);
data->channels = (unsigned long)i2c_get_match_data(client);
data->client = client;