Merge tag 'hwmon-for-v6.19-take-2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon fixes Guenter Roeck: - Documentation: Fix link to g762 devicetree binding - emc2305: Fix devicetree refcount leak and double put - dell-smm: Fix channel-index off-by-one error - w83791d: Convert macros to functions to avoid TOCTOU * tag 'hwmon-for-v6.19-take-2' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: docs: hwmon: fix link to g762 devicetree binding hwmon: (emc2305) fix device node refcount leak in error path hwmon: (emc2305) fix double put in emc2305_probe_childs_from_dt hwmon: (dell-smm) Fix off-by-one error in dell_smm_is_visible() hwmon: (w83791d) Convert macros to functions to avoid TOCTOU
This commit is contained in:
commit
b88b2f82fa
4 files changed
+19
-14
No files matched your search
@@ -17,7 +17,7 @@ done via a userland daemon like fancontrol.
|
||||
Note that those entries do not provide ways to setup the specific
|
||||
hardware characteristics of the system (reference clock, pulses per
|
||||
fan revolution, ...); Those can be modified via devicetree bindings
|
||||
documented in Documentation/devicetree/bindings/hwmon/g762.txt or
|
||||
documented in Documentation/devicetree/bindings/hwmon/gmt,g762.yaml or
|
||||
using a specific platform_data structure in board initialization
|
||||
file (see include/linux/platform_data/g762.h).
|
||||
|
||||
|
||||
@@ -861,9 +861,9 @@ static umode_t dell_smm_is_visible(const void *drvdata, enum hwmon_sensor_types
|
||||
if (auto_fan) {
|
||||
/*
|
||||
* The setting affects all fans, so only create a
|
||||
* single attribute.
|
||||
* single attribute for the first fan channel.
|
||||
*/
|
||||
if (channel != 1)
|
||||
if (channel != 0)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
|
||||
@@ -593,10 +593,8 @@ static int emc2305_probe_childs_from_dt(struct device *dev)
|
||||
for_each_child_of_node(dev->of_node, child) {
|
||||
if (of_property_present(child, "reg")) {
|
||||
ret = emc2305_of_parse_pwm_child(dev, child, data);
|
||||
if (ret) {
|
||||
of_node_put(child);
|
||||
if (ret)
|
||||
continue;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -685,8 +683,10 @@ static int emc2305_probe(struct i2c_client *client)
|
||||
i = 0;
|
||||
for_each_child_of_node(dev->of_node, child) {
|
||||
ret = emc2305_set_single_tz(dev, child, i);
|
||||
if (ret != 0)
|
||||
if (ret != 0) {
|
||||
of_node_put(child);
|
||||
return ret;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
|
||||
+12
-7
@@ -218,9 +218,14 @@ static u8 fan_to_reg(long rpm, int div)
|
||||
return clamp_val((1350000 + rpm * div / 2) / (rpm * div), 1, 254);
|
||||
}
|
||||
|
||||
#define FAN_FROM_REG(val, div) ((val) == 0 ? -1 : \
|
||||
((val) == 255 ? 0 : \
|
||||
1350000 / ((val) * (div))))
|
||||
static int fan_from_reg(int val, int div)
|
||||
{
|
||||
if (val == 0)
|
||||
return -1;
|
||||
if (val == 255)
|
||||
return 0;
|
||||
return 1350000 / (val * div);
|
||||
}
|
||||
|
||||
/* for temp1 which is 8-bit resolution, LSB = 1 degree Celsius */
|
||||
#define TEMP1_FROM_REG(val) ((val) * 1000)
|
||||
@@ -521,7 +526,7 @@ static ssize_t show_##reg(struct device *dev, struct device_attribute *attr, \
|
||||
struct w83791d_data *data = w83791d_update_device(dev); \
|
||||
int nr = sensor_attr->index; \
|
||||
return sprintf(buf, "%d\n", \
|
||||
FAN_FROM_REG(data->reg[nr], DIV_FROM_REG(data->fan_div[nr]))); \
|
||||
fan_from_reg(data->reg[nr], DIV_FROM_REG(data->fan_div[nr]))); \
|
||||
}
|
||||
|
||||
show_fan_reg(fan);
|
||||
@@ -585,10 +590,10 @@ static ssize_t store_fan_div(struct device *dev, struct device_attribute *attr,
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* Save fan_min */
|
||||
min = FAN_FROM_REG(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr]));
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
/* Save fan_min */
|
||||
min = fan_from_reg(data->fan_min[nr], DIV_FROM_REG(data->fan_div[nr]));
|
||||
|
||||
data->fan_div[nr] = div_to_reg(nr, val);
|
||||
|
||||
switch (nr) {
|
||||
|
||||
Reference in new issue
Block a user