summaryrefslogtreecommitdiff
path: root/drivers/hwmon/sht21.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 11:20:22 -0700
committerGuenter Roeck <linux@roeck-us.net>2012-09-23 21:08:32 -0700
commita844af19b9a8c3bcd1169f60916b0f7c40b6295f (patch)
tree380b8c64d12d949835b66862a0e4240c6a2f1f15 /drivers/hwmon/sht21.c
parent38fe7560a391cba81ec7fc5b169b764819632060 (diff)
downloadlinux-stable-a844af19b9a8c3bcd1169f60916b0f7c40b6295f.tar.gz
linux-stable-a844af19b9a8c3bcd1169f60916b0f7c40b6295f.tar.bz2
linux-stable-a844af19b9a8c3bcd1169f60916b0f7c40b6295f.zip
hwmon: (sht21) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code. Cc: Jonathan Cameron <jic23@cam.ac.uk> Cc: Urs Fleisch <urs.fleisch@sensirion.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/sht21.c')
-rw-r--r--drivers/hwmon/sht21.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/hwmon/sht21.c b/drivers/hwmon/sht21.c
index 6c2dede4b8e7..c2565d04cd4a 100644
--- a/drivers/hwmon/sht21.c
+++ b/drivers/hwmon/sht21.c
@@ -199,11 +199,10 @@ static int __devinit sht21_probe(struct i2c_client *client,
return -ENODEV;
}
- sht21 = kzalloc(sizeof(*sht21), GFP_KERNEL);
- if (!sht21) {
- dev_dbg(&client->dev, "kzalloc failed\n");
+ sht21 = devm_kzalloc(&client->dev, sizeof(*sht21), GFP_KERNEL);
+ if (!sht21)
return -ENOMEM;
- }
+
i2c_set_clientdata(client, sht21);
mutex_init(&sht21->lock);
@@ -211,7 +210,7 @@ static int __devinit sht21_probe(struct i2c_client *client,
err = sysfs_create_group(&client->dev.kobj, &sht21_attr_group);
if (err) {
dev_dbg(&client->dev, "could not create sysfs files\n");
- goto fail_free;
+ return err;
}
sht21->hwmon_dev = hwmon_device_register(&client->dev);
if (IS_ERR(sht21->hwmon_dev)) {
@@ -226,9 +225,6 @@ static int __devinit sht21_probe(struct i2c_client *client,
fail_remove_sysfs:
sysfs_remove_group(&client->dev.kobj, &sht21_attr_group);
-fail_free:
- kfree(sht21);
-
return err;
}
@@ -242,7 +238,6 @@ static int __devexit sht21_remove(struct i2c_client *client)
hwmon_device_unregister(sht21->hwmon_dev);
sysfs_remove_group(&client->dev.kobj, &sht21_attr_group);
- kfree(sht21);
return 0;
}