Commit b4cd3d6a77b3f8acfd5b8ae9ea9dc43f831f0df9

Authored by Jingoo Han
Committed by Linus Torvalds
1 parent b8a4b4e2f7

rtc: rtc-s35390a: 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>

Showing 1 changed file with 6 additions and 8 deletions Side-by-side Diff

drivers/rtc/rtc-s35390a.c
... ... @@ -338,7 +338,8 @@
338 338 goto exit;
339 339 }
340 340  
341   - s35390a = kzalloc(sizeof(struct s35390a), GFP_KERNEL);
  341 + s35390a = devm_kzalloc(&client->dev, sizeof(struct s35390a),
  342 + GFP_KERNEL);
342 343 if (!s35390a) {
343 344 err = -ENOMEM;
344 345 goto exit;
... ... @@ -386,8 +387,9 @@
386 387  
387 388 device_set_wakeup_capable(&client->dev, 1);
388 389  
389   - s35390a->rtc = rtc_device_register(s35390a_driver.driver.name,
390   - &client->dev, &s35390a_rtc_ops, THIS_MODULE);
  390 + s35390a->rtc = devm_rtc_device_register(&client->dev,
  391 + s35390a_driver.driver.name,
  392 + &s35390a_rtc_ops, THIS_MODULE);
391 393  
392 394 if (IS_ERR(s35390a->rtc)) {
393 395 err = PTR_ERR(s35390a->rtc);
... ... @@ -399,7 +401,6 @@
399 401 for (i = 1; i < 8; ++i)
400 402 if (s35390a->client[i])
401 403 i2c_unregister_device(s35390a->client[i]);
402   - kfree(s35390a);
403 404  
404 405 exit:
405 406 return err;
406 407  
407 408  
... ... @@ -408,14 +409,11 @@
408 409 static int s35390a_remove(struct i2c_client *client)
409 410 {
410 411 unsigned int i;
411   -
412 412 struct s35390a *s35390a = i2c_get_clientdata(client);
  413 +
413 414 for (i = 1; i < 8; ++i)
414 415 if (s35390a->client[i])
415 416 i2c_unregister_device(s35390a->client[i]);
416   -
417   - rtc_device_unregister(s35390a->rtc);
418   - kfree(s35390a);
419 417  
420 418 return 0;
421 419 }