hwmon: (ltc4245) Use device managed function to register hwmon device
authorGuenter Roeck <linux@roeck-us.net>
Sun, 2 Feb 2014 22:12:40 +0000 (14:12 -0800)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 3 Mar 2014 16:01:04 +0000 (08:01 -0800)
This simplifies the code and reduces code size.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
drivers/hwmon/ltc4245.c

index d4172933ce4f2b67d8696b97527d25e7fd5fab48..2c6da5d955f5836537e9c133ce2cb5e484993bdf 100644 (file)
@@ -512,24 +512,10 @@ static int ltc4245_probe(struct i2c_client *client,
        /* Add sysfs hooks */
        ltc4245_sysfs_add_groups(data);
 
-       hwmon_dev = hwmon_device_register_with_groups(&client->dev,
-                                                     client->name, data,
-                                                     data->groups);
-       if (IS_ERR(hwmon_dev))
-               return PTR_ERR(hwmon_dev);
-
-       i2c_set_clientdata(client, hwmon_dev);
-
-       return 0;
-}
-
-static int ltc4245_remove(struct i2c_client *client)
-{
-       struct device *hwmon_dev = i2c_get_clientdata(client);
-
-       hwmon_device_unregister(hwmon_dev);
-
-       return 0;
+       hwmon_dev = devm_hwmon_device_register_with_groups(&client->dev,
+                                                          client->name, data,
+                                                          data->groups);
+       return PTR_ERR_OR_ZERO(hwmon_dev);
 }
 
 static const struct i2c_device_id ltc4245_id[] = {
@@ -544,7 +530,6 @@ static struct i2c_driver ltc4245_driver = {
                .name   = "ltc4245",
        },
        .probe          = ltc4245_probe,
-       .remove         = ltc4245_remove,
        .id_table       = ltc4245_id,
 };