From: Guenter Roeck Date: Sat, 2 Jun 2012 16:58:04 +0000 (-0700) Subject: hwmon: (emc2103) Convert to use devm_ functions X-Git-Tag: next-20120914~85^2~36 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=24cb529a440e9c97e3e7873e515adc67be637670;p=karo-tx-linux.git hwmon: (emc2103) Convert to use devm_ functions Convert to use devm_ functions to reduce code size and simplify the code. Cc: Steve Glendinning Signed-off-by: Guenter Roeck --- diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c index 7bb8e888692c..77f434c58236 100644 --- a/drivers/hwmon/emc2103.c +++ b/drivers/hwmon/emc2103.c @@ -590,7 +590,8 @@ emc2103_probe(struct i2c_client *client, const struct i2c_device_id *id) if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -EIO; - data = kzalloc(sizeof(struct emc2103_data), GFP_KERNEL); + data = devm_kzalloc(&client->dev, sizeof(struct emc2103_data), + GFP_KERNEL); if (!data) return -ENOMEM; @@ -608,7 +609,7 @@ emc2103_probe(struct i2c_client *client, const struct i2c_device_id *id) if (status < 0) { dev_dbg(&client->dev, "reg 0x%02x, err %d\n", REG_CONF1, status); - goto exit_free; + return status; } /* detect current state of hardware */ @@ -631,7 +632,7 @@ emc2103_probe(struct i2c_client *client, const struct i2c_device_id *id) /* Register sysfs hooks */ status = sysfs_create_group(&client->dev.kobj, &emc2103_group); if (status) - goto exit_free; + return status; if (data->temp_count >= 3) { status = sysfs_create_group(&client->dev.kobj, @@ -666,8 +667,6 @@ exit_remove_temp3: sysfs_remove_group(&client->dev.kobj, &emc2103_temp3_group); exit_remove: sysfs_remove_group(&client->dev.kobj, &emc2103_group); -exit_free: - kfree(data); return status; } @@ -685,7 +684,6 @@ static int emc2103_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &emc2103_group); - kfree(data); return 0; }