Commit 66714612 authored by Sachin Kamat's avatar Sachin Kamat Committed by Linus Torvalds

drivers/rtc/rtc-ds3232.c: use devm_* APIs

devm_* functions are device managed and make cleanup code simpler.
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Cc: Srikanth Srinivasan <srikanth.srinivasan@freescale.com>
Cc: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent d1a96639
...@@ -397,7 +397,7 @@ static int ds3232_probe(struct i2c_client *client, ...@@ -397,7 +397,7 @@ static int ds3232_probe(struct i2c_client *client,
struct ds3232 *ds3232; struct ds3232 *ds3232;
int ret; int ret;
ds3232 = kzalloc(sizeof(struct ds3232), GFP_KERNEL); ds3232 = devm_kzalloc(&client->dev, sizeof(struct ds3232), GFP_KERNEL);
if (!ds3232) if (!ds3232)
return -ENOMEM; return -ENOMEM;
...@@ -409,34 +409,25 @@ static int ds3232_probe(struct i2c_client *client, ...@@ -409,34 +409,25 @@ static int ds3232_probe(struct i2c_client *client,
ret = ds3232_check_rtc_status(client); ret = ds3232_check_rtc_status(client);
if (ret) if (ret)
goto out_free; return ret;
ds3232->rtc = rtc_device_register(client->name, &client->dev, ds3232->rtc = devm_rtc_device_register(&client->dev, client->name,
&ds3232_rtc_ops, THIS_MODULE); &ds3232_rtc_ops, THIS_MODULE);
if (IS_ERR(ds3232->rtc)) { if (IS_ERR(ds3232->rtc)) {
ret = PTR_ERR(ds3232->rtc);
dev_err(&client->dev, "unable to register the class device\n"); dev_err(&client->dev, "unable to register the class device\n");
goto out_irq; return PTR_ERR(ds3232->rtc);
} }
if (client->irq >= 0) { if (client->irq >= 0) {
ret = request_irq(client->irq, ds3232_irq, 0, ret = devm_request_irq(&client->dev, client->irq, ds3232_irq, 0,
"ds3232", client); "ds3232", client);
if (ret) { if (ret) {
dev_err(&client->dev, "unable to request IRQ\n"); dev_err(&client->dev, "unable to request IRQ\n");
goto out_free; return ret;
} }
} }
return 0; return 0;
out_irq:
if (client->irq >= 0)
free_irq(client->irq, client);
out_free:
kfree(ds3232);
return ret;
} }
static int ds3232_remove(struct i2c_client *client) static int ds3232_remove(struct i2c_client *client)
...@@ -448,12 +439,10 @@ static int ds3232_remove(struct i2c_client *client) ...@@ -448,12 +439,10 @@ static int ds3232_remove(struct i2c_client *client)
ds3232->exiting = 1; ds3232->exiting = 1;
mutex_unlock(&ds3232->mutex); mutex_unlock(&ds3232->mutex);
free_irq(client->irq, client); devm_free_irq(&client->dev, client->irq, client);
cancel_work_sync(&ds3232->work); cancel_work_sync(&ds3232->work);
} }
rtc_device_unregister(ds3232->rtc);
kfree(ds3232);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment