aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-03-23 05:02:18 -0400
committerJean Delvare <khali@endymion.delvare>2012-03-23 05:02:18 -0400
commitf7001bb063ec06e7fff8782146a7bed49dfe6507 (patch)
tree43e81025282433a3496b56968e6e15fe54dee9c8
parentae544f64cc7b0850471f62e6808068ef77b90763 (diff)
hwmon: (lm90) Restore original configuration if probe function fails
The lm90 driver restores the original chip configuration in its exit function. However, the chip configuration is not restored if the probe function fails. Restore it there as well. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Jean Delvare <khali@linux-fr.org>
-rw-r--r--drivers/hwmon/lm90.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 3309a511e8e1..22b14a68e35e 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -1336,6 +1336,15 @@ static void lm90_remove_files(struct i2c_client *client, struct lm90_data *data)
1336 sysfs_remove_group(&dev->kobj, &lm90_group); 1336 sysfs_remove_group(&dev->kobj, &lm90_group);
1337} 1337}
1338 1338
1339static void lm90_restore_conf(struct i2c_client *client, struct lm90_data *data)
1340{
1341 /* Restore initial configuration */
1342 i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE,
1343 data->convrate_orig);
1344 i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
1345 data->config_orig);
1346}
1347
1339static void lm90_init_client(struct i2c_client *client) 1348static void lm90_init_client(struct i2c_client *client)
1340{ 1349{
1341 u8 config, convrate; 1350 u8 config, convrate;
@@ -1424,7 +1433,7 @@ static int lm90_probe(struct i2c_client *client,
1424 /* Register sysfs hooks */ 1433 /* Register sysfs hooks */
1425 err = sysfs_create_group(&dev->kobj, &lm90_group); 1434 err = sysfs_create_group(&dev->kobj, &lm90_group);
1426 if (err) 1435 if (err)
1427 goto exit_free; 1436 goto exit_restore;
1428 if (client->flags & I2C_CLIENT_PEC) { 1437 if (client->flags & I2C_CLIENT_PEC) {
1429 err = device_create_file(dev, &dev_attr_pec); 1438 err = device_create_file(dev, &dev_attr_pec);
1430 if (err) 1439 if (err)
@@ -1463,7 +1472,8 @@ static int lm90_probe(struct i2c_client *client,
1463 1472
1464exit_remove_files: 1473exit_remove_files:
1465 lm90_remove_files(client, data); 1474 lm90_remove_files(client, data);
1466exit_free: 1475exit_restore:
1476 lm90_restore_conf(client, data);
1467 kfree(data); 1477 kfree(data);
1468exit: 1478exit:
1469 return err; 1479 return err;
@@ -1475,12 +1485,7 @@ static int lm90_remove(struct i2c_client *client)
1475 1485
1476 hwmon_device_unregister(data->hwmon_dev); 1486 hwmon_device_unregister(data->hwmon_dev);
1477 lm90_remove_files(client, data); 1487 lm90_remove_files(client, data);
1478 1488 lm90_restore_conf(client, data);
1479 /* Restore initial configuration */
1480 i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE,
1481 data->convrate_orig);
1482 i2c_smbus_write_byte_data(client, LM90_REG_W_CONFIG1,
1483 data->config_orig);
1484 1489
1485 kfree(data); 1490 kfree(data);
1486 return 0; 1491 return 0;