mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-30 07:34:12 +08:00
hwmon: (smm665) Convert to use devm_kzalloc
Marginally less code and eliminate the possibility of memory leaks. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
3683928720
commit
b8a5a7cebd
@ -584,10 +584,9 @@ static int smm665_probe(struct i2c_client *client,
|
|||||||
if (i2c_smbus_read_byte_data(client, SMM665_ADOC_ENABLE) < 0)
|
if (i2c_smbus_read_byte_data(client, SMM665_ADOC_ENABLE) < 0)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
ret = -ENOMEM;
|
data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
|
||||||
data = kzalloc(sizeof(*data), GFP_KERNEL);
|
|
||||||
if (!data)
|
if (!data)
|
||||||
goto out_return;
|
return -ENOMEM;
|
||||||
|
|
||||||
i2c_set_clientdata(client, data);
|
i2c_set_clientdata(client, data);
|
||||||
mutex_init(&data->update_lock);
|
mutex_init(&data->update_lock);
|
||||||
@ -596,7 +595,7 @@ static int smm665_probe(struct i2c_client *client,
|
|||||||
data->cmdreg = i2c_new_dummy(adapter, (client->addr & ~SMM665_REGMASK)
|
data->cmdreg = i2c_new_dummy(adapter, (client->addr & ~SMM665_REGMASK)
|
||||||
| SMM665_CMDREG_BASE);
|
| SMM665_CMDREG_BASE);
|
||||||
if (!data->cmdreg)
|
if (!data->cmdreg)
|
||||||
goto out_kfree;
|
return -ENOMEM;
|
||||||
|
|
||||||
switch (data->type) {
|
switch (data->type) {
|
||||||
case smm465:
|
case smm465:
|
||||||
@ -679,9 +678,6 @@ out_remove_group:
|
|||||||
sysfs_remove_group(&client->dev.kobj, &smm665_group);
|
sysfs_remove_group(&client->dev.kobj, &smm665_group);
|
||||||
out_unregister:
|
out_unregister:
|
||||||
i2c_unregister_device(data->cmdreg);
|
i2c_unregister_device(data->cmdreg);
|
||||||
out_kfree:
|
|
||||||
kfree(data);
|
|
||||||
out_return:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -693,8 +689,6 @@ static int smm665_remove(struct i2c_client *client)
|
|||||||
hwmon_device_unregister(data->hwmon_dev);
|
hwmon_device_unregister(data->hwmon_dev);
|
||||||
sysfs_remove_group(&client->dev.kobj, &smm665_group);
|
sysfs_remove_group(&client->dev.kobj, &smm665_group);
|
||||||
|
|
||||||
kfree(data);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user