aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lm75.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 12:58:08 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-07-22 00:48:40 -0400
commit13ac7a017678d9d7ee4dcc93a10947df0d3b5b12 (patch)
tree67f65e1da9e67d19e0601db601b39039683cfedb /drivers/hwmon/lm75.c
parentc5a4a91d24e0d4af8630932081a4c9a15e7fb1f7 (diff)
hwmon: (lm75) 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>
Diffstat (limited to 'drivers/hwmon/lm75.c')
-rw-r--r--drivers/hwmon/lm75.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index a83f206af244..291edfff55bf 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -156,7 +156,7 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
156 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA)) 156 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA))
157 return -EIO; 157 return -EIO;
158 158
159 data = kzalloc(sizeof(struct lm75_data), GFP_KERNEL); 159 data = devm_kzalloc(&client->dev, sizeof(struct lm75_data), GFP_KERNEL);
160 if (!data) 160 if (!data)
161 return -ENOMEM; 161 return -ENOMEM;
162 162
@@ -174,7 +174,7 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
174 status = lm75_read_value(client, LM75_REG_CONF); 174 status = lm75_read_value(client, LM75_REG_CONF);
175 if (status < 0) { 175 if (status < 0) {
176 dev_dbg(&client->dev, "Can't read config? %d\n", status); 176 dev_dbg(&client->dev, "Can't read config? %d\n", status);
177 goto exit_free; 177 return status;
178 } 178 }
179 data->orig_conf = status; 179 data->orig_conf = status;
180 new = status & ~clr_mask; 180 new = status & ~clr_mask;
@@ -186,7 +186,7 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
186 /* Register sysfs hooks */ 186 /* Register sysfs hooks */
187 status = sysfs_create_group(&client->dev.kobj, &lm75_group); 187 status = sysfs_create_group(&client->dev.kobj, &lm75_group);
188 if (status) 188 if (status)
189 goto exit_free; 189 return status;
190 190
191 data->hwmon_dev = hwmon_device_register(&client->dev); 191 data->hwmon_dev = hwmon_device_register(&client->dev);
192 if (IS_ERR(data->hwmon_dev)) { 192 if (IS_ERR(data->hwmon_dev)) {
@@ -201,8 +201,6 @@ lm75_probe(struct i2c_client *client, const struct i2c_device_id *id)
201 201
202exit_remove: 202exit_remove:
203 sysfs_remove_group(&client->dev.kobj, &lm75_group); 203 sysfs_remove_group(&client->dev.kobj, &lm75_group);
204exit_free:
205 kfree(data);
206 return status; 204 return status;
207} 205}
208 206
@@ -213,7 +211,6 @@ static int lm75_remove(struct i2c_client *client)
213 hwmon_device_unregister(data->hwmon_dev); 211 hwmon_device_unregister(data->hwmon_dev);
214 sysfs_remove_group(&client->dev.kobj, &lm75_group); 212 sysfs_remove_group(&client->dev.kobj, &lm75_group);
215 lm75_write_value(client, LM75_REG_CONF, data->orig_conf); 213 lm75_write_value(client, LM75_REG_CONF, data->orig_conf);
216 kfree(data);
217 return 0; 214 return 0;
218} 215}
219 216