aboutsummaryrefslogtreecommitdiff
path: root/drivers/hwmon/tmp464.c
diff options
context:
space:
mode:
authorJohannes Berg <[email protected]>2024-10-09 08:59:14 +0200
committerJohannes Berg <[email protected]>2024-10-09 08:59:22 +0200
commita0efa2f362a69e47b9d8b48f770ef3a0249a7911 (patch)
tree384d2c79a9b613213ef7591583d820d18c7be9c3 /drivers/hwmon/tmp464.c
parentdb03488897a70367aeafe82d07a78943d2a6068e (diff)
parent36efaca9cb28a893cad98f0448c39a8b698859e2 (diff)
Merge net-next/main to resolve conflicts
The wireless-next tree was based on something older, and there are now conflicts between -rc2 and work here. Merge net-next, which has enough of -rc2 for the conflicts to happen, resolving them in the process. Signed-off-by: Johannes Berg <[email protected]>
Diffstat (limited to 'drivers/hwmon/tmp464.c')
-rw-r--r--drivers/hwmon/tmp464.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/drivers/hwmon/tmp464.c b/drivers/hwmon/tmp464.c
index 3ee1137533d6..0f629c6d7695 100644
--- a/drivers/hwmon/tmp464.c
+++ b/drivers/hwmon/tmp464.c
@@ -147,11 +147,11 @@ static int tmp464_temp_read(struct device *dev, u32 attr, int channel, long *val
{
struct tmp464_data *data = dev_get_drvdata(dev);
struct regmap *regmap = data->regmap;
- unsigned int regval, regval2;
+ unsigned int regs[2];
+ unsigned int regval;
+ u16 regvals[2];
int err = 0;
- mutex_lock(&data->update_lock);
-
switch (attr) {
case hwmon_temp_max_alarm:
err = regmap_read(regmap, TMP464_THERM_STATUS_REG, &regval);
@@ -172,26 +172,27 @@ static int tmp464_temp_read(struct device *dev, u32 attr, int channel, long *val
* complete. That means we have to cache the value internally
* for one measurement cycle and report the cached value.
*/
+ mutex_lock(&data->update_lock);
if (!data->valid || time_after(jiffies, data->last_updated +
msecs_to_jiffies(data->update_interval))) {
err = regmap_read(regmap, TMP464_REMOTE_OPEN_REG, &regval);
if (err < 0)
- break;
+ goto unlock;
data->open_reg = regval;
data->last_updated = jiffies;
data->valid = true;
}
*val = !!(data->open_reg & BIT(channel + 7));
+unlock:
+ mutex_unlock(&data->update_lock);
break;
case hwmon_temp_max_hyst:
- err = regmap_read(regmap, TMP464_THERM_LIMIT[channel], &regval);
+ regs[0] = TMP464_THERM_LIMIT[channel];
+ regs[1] = TMP464_TEMP_HYST_REG;
+ err = regmap_multi_reg_read(regmap, regs, regvals, 2);
if (err < 0)
break;
- err = regmap_read(regmap, TMP464_TEMP_HYST_REG, &regval2);
- if (err < 0)
- break;
- regval -= regval2;
- *val = temp_from_reg(regval);
+ *val = temp_from_reg(regvals[0] - regvals[1]);
break;
case hwmon_temp_max:
err = regmap_read(regmap, TMP464_THERM_LIMIT[channel], &regval);
@@ -200,14 +201,12 @@ static int tmp464_temp_read(struct device *dev, u32 attr, int channel, long *val
*val = temp_from_reg(regval);
break;
case hwmon_temp_crit_hyst:
- err = regmap_read(regmap, TMP464_THERM2_LIMIT[channel], &regval);
+ regs[0] = TMP464_THERM2_LIMIT[channel];
+ regs[1] = TMP464_TEMP_HYST_REG;
+ err = regmap_multi_reg_read(regmap, regs, regvals, 2);
if (err < 0)
break;
- err = regmap_read(regmap, TMP464_TEMP_HYST_REG, &regval2);
- if (err < 0)
- break;
- regval -= regval2;
- *val = temp_from_reg(regval);
+ *val = temp_from_reg(regvals[0] - regvals[1]);
break;
case hwmon_temp_crit:
err = regmap_read(regmap, TMP464_THERM2_LIMIT[channel], &regval);
@@ -239,8 +238,6 @@ static int tmp464_temp_read(struct device *dev, u32 attr, int channel, long *val
break;
}
- mutex_unlock(&data->update_lock);
-
return err;
}
@@ -565,18 +562,15 @@ static int tmp464_probe_child_from_dt(struct device *dev,
static int tmp464_probe_from_dt(struct device *dev, struct tmp464_data *data)
{
const struct device_node *np = dev->of_node;
- struct device_node *child;
int err;
- for_each_child_of_node(np, child) {
+ for_each_child_of_node_scoped(np, child) {
if (strcmp(child->name, "channel"))
continue;
err = tmp464_probe_child_from_dt(dev, child, data);
- if (err) {
- of_node_put(child);
+ if (err)
return err;
- }
}
return 0;