diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-06-02 12:57:57 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2012-09-24 00:08:29 -0400 |
commit | be92304034220ee94a34df379101f14570db331b (patch) | |
tree | 0b19ff836268519970edc7d67ccc2d8f904fe24d /drivers/hwmon/ad7314.c | |
parent | a34c26d8e288d48e70c0e722da0c745e14d74e3a (diff) |
hwmon: (ad7314) 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>
Diffstat (limited to 'drivers/hwmon/ad7314.c')
-rw-r--r-- | drivers/hwmon/ad7314.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/hwmon/ad7314.c b/drivers/hwmon/ad7314.c index f915eb1c29f7..37c01e72d699 100644 --- a/drivers/hwmon/ad7314.c +++ b/drivers/hwmon/ad7314.c | |||
@@ -112,16 +112,16 @@ static int __devinit ad7314_probe(struct spi_device *spi_dev) | |||
112 | int ret; | 112 | int ret; |
113 | struct ad7314_data *chip; | 113 | struct ad7314_data *chip; |
114 | 114 | ||
115 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 115 | chip = devm_kzalloc(&spi_dev->dev, sizeof(*chip), GFP_KERNEL); |
116 | if (chip == NULL) { | 116 | if (chip == NULL) |
117 | ret = -ENOMEM; | 117 | return -ENOMEM; |
118 | goto error_ret; | 118 | |
119 | } | ||
120 | dev_set_drvdata(&spi_dev->dev, chip); | 119 | dev_set_drvdata(&spi_dev->dev, chip); |
121 | 120 | ||
122 | ret = sysfs_create_group(&spi_dev->dev.kobj, &ad7314_group); | 121 | ret = sysfs_create_group(&spi_dev->dev.kobj, &ad7314_group); |
123 | if (ret < 0) | 122 | if (ret < 0) |
124 | goto error_free_chip; | 123 | return ret; |
124 | |||
125 | chip->hwmon_dev = hwmon_device_register(&spi_dev->dev); | 125 | chip->hwmon_dev = hwmon_device_register(&spi_dev->dev); |
126 | if (IS_ERR(chip->hwmon_dev)) { | 126 | if (IS_ERR(chip->hwmon_dev)) { |
127 | ret = PTR_ERR(chip->hwmon_dev); | 127 | ret = PTR_ERR(chip->hwmon_dev); |
@@ -132,9 +132,6 @@ static int __devinit ad7314_probe(struct spi_device *spi_dev) | |||
132 | return 0; | 132 | return 0; |
133 | error_remove_group: | 133 | error_remove_group: |
134 | sysfs_remove_group(&spi_dev->dev.kobj, &ad7314_group); | 134 | sysfs_remove_group(&spi_dev->dev.kobj, &ad7314_group); |
135 | error_free_chip: | ||
136 | kfree(chip); | ||
137 | error_ret: | ||
138 | return ret; | 135 | return ret; |
139 | } | 136 | } |
140 | 137 | ||
@@ -144,7 +141,6 @@ static int __devexit ad7314_remove(struct spi_device *spi_dev) | |||
144 | 141 | ||
145 | hwmon_device_unregister(chip->hwmon_dev); | 142 | hwmon_device_unregister(chip->hwmon_dev); |
146 | sysfs_remove_group(&spi_dev->dev.kobj, &ad7314_group); | 143 | sysfs_remove_group(&spi_dev->dev.kobj, &ad7314_group); |
147 | kfree(chip); | ||
148 | 144 | ||
149 | return 0; | 145 | return 0; |
150 | } | 146 | } |