Skip to content

Commit 77d9278

Browse files
committed
Merge tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon fixes from Guenter Roeck: "Fix resource leak as well as broken store function in emc1403 driver, and add support for additional chip revisions" * tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (emc1403) Support full range of known chip revision numbers hwmon: (emc1403) Fix resource leak on module unload hwmon: (emc1403) fix inverted store_hyst()
2 parents 68cb363 + 3a18e13 commit 77d9278

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/hwmon/emc1403.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static ssize_t store_hyst(struct device *dev,
163163
if (retval < 0)
164164
goto fail;
165165

166-
hyst = val - retval * 1000;
166+
hyst = retval * 1000 - val;
167167
hyst = DIV_ROUND_CLOSEST(hyst, 1000);
168168
if (hyst < 0 || hyst > 255) {
169169
retval = -ERANGE;
@@ -330,7 +330,7 @@ static int emc1403_detect(struct i2c_client *client,
330330
}
331331

332332
id = i2c_smbus_read_byte_data(client, THERMAL_REVISION_REG);
333-
if (id != 0x01)
333+
if (id < 0x01 || id > 0x04)
334334
return -ENODEV;
335335

336336
return 0;
@@ -355,9 +355,9 @@ static int emc1403_probe(struct i2c_client *client,
355355
if (id->driver_data)
356356
data->groups[1] = &emc1404_group;
357357

358-
hwmon_dev = hwmon_device_register_with_groups(&client->dev,
359-
client->name, data,
360-
data->groups);
358+
hwmon_dev = devm_hwmon_device_register_with_groups(&client->dev,
359+
client->name, data,
360+
data->groups);
361361
if (IS_ERR(hwmon_dev))
362362
return PTR_ERR(hwmon_dev);
363363

0 commit comments

Comments
 (0)