aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2013-04-29 19:20:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 21:28:35 -0400
commitd1a9663964d3520435f887ba6a15b98d8a6ac312 (patch)
treecb401ab83b2882372982a7ad578abafe6a00e163
parent0529bf4673a05ca688fa42a14917069278d88103 (diff)
drivers/rtc/rtc-ds1374.c: use devm_* APIs
devm_* functions are device managed and make cleanup code simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Cc: Scott Wood <scottwood@freescale.com> Cc: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/rtc/rtc-ds1374.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c
index 67cd1e3e77a5..94366e12f40f 100644
--- a/drivers/rtc/rtc-ds1374.c
+++ b/drivers/rtc/rtc-ds1374.c
@@ -347,7 +347,7 @@ static int ds1374_probe(struct i2c_client *client,
347 struct ds1374 *ds1374; 347 struct ds1374 *ds1374;
348 int ret; 348 int ret;
349 349
350 ds1374 = kzalloc(sizeof(struct ds1374), GFP_KERNEL); 350 ds1374 = devm_kzalloc(&client->dev, sizeof(struct ds1374), GFP_KERNEL);
351 if (!ds1374) 351 if (!ds1374)
352 return -ENOMEM; 352 return -ENOMEM;
353 353
@@ -359,36 +359,27 @@ static int ds1374_probe(struct i2c_client *client,
359 359
360 ret = ds1374_check_rtc_status(client); 360 ret = ds1374_check_rtc_status(client);
361 if (ret) 361 if (ret)
362 goto out_free; 362 return ret;
363 363
364 if (client->irq > 0) { 364 if (client->irq > 0) {
365 ret = request_irq(client->irq, ds1374_irq, 0, 365 ret = devm_request_irq(&client->dev, client->irq, ds1374_irq, 0,
366 "ds1374", client); 366 "ds1374", client);
367 if (ret) { 367 if (ret) {
368 dev_err(&client->dev, "unable to request IRQ\n"); 368 dev_err(&client->dev, "unable to request IRQ\n");
369 goto out_free; 369 return ret;
370 } 370 }
371 371
372 device_set_wakeup_capable(&client->dev, 1); 372 device_set_wakeup_capable(&client->dev, 1);
373 } 373 }
374 374
375 ds1374->rtc = rtc_device_register(client->name, &client->dev, 375 ds1374->rtc = devm_rtc_device_register(&client->dev, client->name,
376 &ds1374_rtc_ops, THIS_MODULE); 376 &ds1374_rtc_ops, THIS_MODULE);
377 if (IS_ERR(ds1374->rtc)) { 377 if (IS_ERR(ds1374->rtc)) {
378 ret = PTR_ERR(ds1374->rtc);
379 dev_err(&client->dev, "unable to register the class device\n"); 378 dev_err(&client->dev, "unable to register the class device\n");
380 goto out_irq; 379 return PTR_ERR(ds1374->rtc);
381 } 380 }
382 381
383 return 0; 382 return 0;
384
385out_irq:
386 if (client->irq > 0)
387 free_irq(client->irq, client);
388
389out_free:
390 kfree(ds1374);
391 return ret;
392} 383}
393 384
394static int ds1374_remove(struct i2c_client *client) 385static int ds1374_remove(struct i2c_client *client)
@@ -400,12 +391,10 @@ static int ds1374_remove(struct i2c_client *client)
400 ds1374->exiting = 1; 391 ds1374->exiting = 1;
401 mutex_unlock(&ds1374->mutex); 392 mutex_unlock(&ds1374->mutex);
402 393
403 free_irq(client->irq, client); 394 devm_free_irq(&client->dev, client->irq, client);
404 cancel_work_sync(&ds1374->work); 395 cancel_work_sync(&ds1374->work);
405 } 396 }
406 397
407 rtc_device_unregister(ds1374->rtc);
408 kfree(ds1374);
409 return 0; 398 return 0;
410} 399}
411 400