rtc: rtc-isl12022: use devm_*() functions
Use devm_*() functions to make cleanup paths simpler. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
c54a52e3a8
commit
dc831f9768
@@ -252,12 +252,11 @@ static int isl12022_probe(struct i2c_client *client,
|
|||||||
{
|
{
|
||||||
struct isl12022 *isl12022;
|
struct isl12022 *isl12022;
|
||||||
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
|
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
isl12022 = kzalloc(sizeof(struct isl12022), GFP_KERNEL);
|
isl12022 = devm_kzalloc(&client->dev, sizeof(struct isl12022),
|
||||||
|
GFP_KERNEL);
|
||||||
if (!isl12022)
|
if (!isl12022)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@@ -265,31 +264,17 @@ static int isl12022_probe(struct i2c_client *client,
|
|||||||
|
|
||||||
i2c_set_clientdata(client, isl12022);
|
i2c_set_clientdata(client, isl12022);
|
||||||
|
|
||||||
isl12022->rtc = rtc_device_register(isl12022_driver.driver.name,
|
isl12022->rtc = devm_rtc_device_register(&client->dev,
|
||||||
&client->dev,
|
isl12022_driver.driver.name,
|
||||||
&isl12022_rtc_ops,
|
&isl12022_rtc_ops, THIS_MODULE);
|
||||||
THIS_MODULE);
|
if (IS_ERR(isl12022->rtc))
|
||||||
|
return PTR_ERR(isl12022->rtc);
|
||||||
if (IS_ERR(isl12022->rtc)) {
|
|
||||||
ret = PTR_ERR(isl12022->rtc);
|
|
||||||
goto exit_kfree;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
exit_kfree:
|
|
||||||
kfree(isl12022);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int isl12022_remove(struct i2c_client *client)
|
static int isl12022_remove(struct i2c_client *client)
|
||||||
{
|
{
|
||||||
struct isl12022 *isl12022 = i2c_get_clientdata(client);
|
|
||||||
|
|
||||||
rtc_device_unregister(isl12022->rtc);
|
|
||||||
kfree(isl12022);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user