diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 12:58:12 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-07-22 00:48:41 -0400 |
commit | 661f020f56c698be9cf40f0b3c8963c2d15be0dd (patch) | |
tree | aaf2a8c665c45195bd9af13bc060e98edd63b671 | |
parent | 4a8ad25af56fa55746a97c4f48985154eb82a842 (diff) |
hwmon: (max1111) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>
-rw-r--r-- | drivers/hwmon/max1111.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/hwmon/max1111.c b/drivers/hwmon/max1111.c index 362a40eb6129..f3978a46e844 100644 --- a/drivers/hwmon/max1111.c +++ b/drivers/hwmon/max1111.c | |||
@@ -168,7 +168,7 @@ static int __devinit max1111_probe(struct spi_device *spi) | |||
168 | if (err < 0) | 168 | if (err < 0) |
169 | return err; | 169 | return err; |
170 | 170 | ||
171 | data = kzalloc(sizeof(struct max1111_data), GFP_KERNEL); | 171 | data = devm_kzalloc(&spi->dev, sizeof(struct max1111_data), GFP_KERNEL); |
172 | if (data == NULL) { | 172 | if (data == NULL) { |
173 | dev_err(&spi->dev, "failed to allocate memory\n"); | 173 | dev_err(&spi->dev, "failed to allocate memory\n"); |
174 | return -ENOMEM; | 174 | return -ENOMEM; |
@@ -176,7 +176,7 @@ static int __devinit max1111_probe(struct spi_device *spi) | |||
176 | 176 | ||
177 | err = setup_transfer(data); | 177 | err = setup_transfer(data); |
178 | if (err) | 178 | if (err) |
179 | goto err_free_data; | 179 | return err; |
180 | 180 | ||
181 | mutex_init(&data->drvdata_lock); | 181 | mutex_init(&data->drvdata_lock); |
182 | 182 | ||
@@ -186,7 +186,7 @@ static int __devinit max1111_probe(struct spi_device *spi) | |||
186 | err = sysfs_create_group(&spi->dev.kobj, &max1111_attr_group); | 186 | err = sysfs_create_group(&spi->dev.kobj, &max1111_attr_group); |
187 | if (err) { | 187 | if (err) { |
188 | dev_err(&spi->dev, "failed to create attribute group\n"); | 188 | dev_err(&spi->dev, "failed to create attribute group\n"); |
189 | goto err_free_data; | 189 | return err; |
190 | } | 190 | } |
191 | 191 | ||
192 | data->hwmon_dev = hwmon_device_register(&spi->dev); | 192 | data->hwmon_dev = hwmon_device_register(&spi->dev); |
@@ -203,8 +203,6 @@ static int __devinit max1111_probe(struct spi_device *spi) | |||
203 | 203 | ||
204 | err_remove: | 204 | err_remove: |
205 | sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group); | 205 | sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group); |
206 | err_free_data: | ||
207 | kfree(data); | ||
208 | return err; | 206 | return err; |
209 | } | 207 | } |
210 | 208 | ||
@@ -215,7 +213,6 @@ static int __devexit max1111_remove(struct spi_device *spi) | |||
215 | hwmon_device_unregister(data->hwmon_dev); | 213 | hwmon_device_unregister(data->hwmon_dev); |
216 | sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group); | 214 | sysfs_remove_group(&spi->dev.kobj, &max1111_attr_group); |
217 | mutex_destroy(&data->drvdata_lock); | 215 | mutex_destroy(&data->drvdata_lock); |
218 | kfree(data); | ||
219 | return 0; | 216 | return 0; |
220 | } | 217 | } |
221 | 218 | ||