hwmon fixes for v6.19-rc1
* 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 -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiHPvMQj9QTOCiqgVyx8mb86fmYEFAmk25tQACgkQyx8mb86f mYEHzQ/+N07lGU1M1uv1Jr3FLGntiT7yIh04zgxwxqE9+R1bTWV/+x9K6s2kDNyG Q+UYjtV3mEf7EawvAeXgo8Zi+9V5lKdCvUonIJ20Gx88aOPjWdBesmztUNTg7pJi S9Au9R+w0oDZWWdtnwVEmLfMAL6huCusoj2pb4miaFcxzBa1ZlzH5whtwW1uRBQm NbRW+Wn6Yuf317rF2nGaGTKp9U7iGUid8ONl0wdCJGikamnf46g+m5r0QzpcinNS Km0wK+YatBVhWte6kQ1YE+3oI0uLXtA70J0SKUeyw0CnyuCX+Z/D5LMp7X5y2cDV /kxqV5WcU0H1VQOKeRga8vclBhqN32vad8nOJ/sKYUezoZpbkrIIu7I0u2ZKZbX1 LdVtq5i47Llt/zY/V1tBaXkn+bXbYeGZdbUvsyK0r93MLZOg98VZ5j1PkwresP5o QqlpYTUNw6vS/zkec248hR111wBGDXsMBkV1SbMDHlnVzcALUG5IQWdSUUHn6NYi yT/cJwCgv6h5wg0ZWhs3ogNGd9FAVJN/+xYMARfxEkVkvQCUJEa1HozuRTzaJFN3 3E7z63ouq9sKPEyc+3bIA3qJGwXpg8XhVFm098lgAeESOLwf9anc/tWU9BCQMOyD iTdQMeTWVI/XAldw1oqJKlrKjxyzw9y8tpn0htkmn5xdGbVqpGs= =M9bd -----END PGP SIGNATURE----- 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 TOCTOUpull/1354/merge
commit
b88b2f82fa
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue