summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Belloni <alexandre.belloni@bootlin.com>2018-09-24 10:49:00 -0400
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2018-09-28 08:36:44 -0400
commitb56295dd337a35402663b230ac62260cbe7ee5ac (patch)
treec83e6a6d15b3734e430f3d447874be3cc89e2a17
parent1654a2b06b936c5e123978e6d9523b022a2a5aa1 (diff)
rtc: ab8500: use rtc_add_group
Use rtc_add_group to add the sysfs group in a race free manner. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
-rw-r--r--drivers/rtc/rtc-ab8500.c41
1 files changed, 17 insertions, 24 deletions
diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c
index e28f4401fd35..e97015e5c63e 100644
--- a/drivers/rtc/rtc-ab8500.c
+++ b/drivers/rtc/rtc-ab8500.c
@@ -360,15 +360,14 @@ static DEVICE_ATTR(rtc_calibration, S_IRUGO | S_IWUSR,
360 ab8500_sysfs_show_rtc_calibration, 360 ab8500_sysfs_show_rtc_calibration,
361 ab8500_sysfs_store_rtc_calibration); 361 ab8500_sysfs_store_rtc_calibration);
362 362
363static int ab8500_sysfs_rtc_register(struct device *dev) 363static struct attribute *ab8500_rtc_attrs[] = {
364{ 364 &dev_attr_rtc_calibration.attr,
365 return device_create_file(dev, &dev_attr_rtc_calibration); 365 NULL
366} 366};
367 367
368static void ab8500_sysfs_rtc_unregister(struct device *dev) 368static const struct attribute_group ab8500_rtc_sysfs_files = {
369{ 369 .attrs = ab8500_rtc_attrs,
370 device_remove_file(dev, &dev_attr_rtc_calibration); 370};
371}
372 371
373static irqreturn_t rtc_alarm_handler(int irq, void *data) 372static irqreturn_t rtc_alarm_handler(int irq, void *data)
374{ 373{
@@ -429,14 +428,11 @@ static int ab8500_rtc_probe(struct platform_device *pdev)
429 428
430 device_init_wakeup(&pdev->dev, true); 429 device_init_wakeup(&pdev->dev, true);
431 430
432 rtc = devm_rtc_device_register(&pdev->dev, "ab8500-rtc", 431 rtc = devm_rtc_allocate_device(&pdev->dev);
433 (struct rtc_class_ops *)platid->driver_data, 432 if (IS_ERR(rtc))
434 THIS_MODULE); 433 return PTR_ERR(rtc);
435 if (IS_ERR(rtc)) { 434
436 dev_err(&pdev->dev, "Registration failed\n"); 435 rtc->ops = (struct rtc_class_ops *)platid->driver_data;
437 err = PTR_ERR(rtc);
438 return err;
439 }
440 436
441 err = devm_request_threaded_irq(&pdev->dev, irq, NULL, 437 err = devm_request_threaded_irq(&pdev->dev, irq, NULL,
442 rtc_alarm_handler, IRQF_ONESHOT, 438 rtc_alarm_handler, IRQF_ONESHOT,
@@ -447,22 +443,19 @@ static int ab8500_rtc_probe(struct platform_device *pdev)
447 dev_pm_set_wake_irq(&pdev->dev, irq); 443 dev_pm_set_wake_irq(&pdev->dev, irq);
448 platform_set_drvdata(pdev, rtc); 444 platform_set_drvdata(pdev, rtc);
449 445
450 err = ab8500_sysfs_rtc_register(&pdev->dev);
451 if (err) {
452 dev_err(&pdev->dev, "sysfs RTC failed to register\n");
453 return err;
454 }
455
456 rtc->uie_unsupported = 1; 446 rtc->uie_unsupported = 1;
457 447
458 return 0; 448 err = rtc_add_group(rtc, &ab8500_rtc_sysfs_files);
449 if (err)
450 return err;
451
452 return rtc_register_device(rtc);
459} 453}
460 454
461static int ab8500_rtc_remove(struct platform_device *pdev) 455static int ab8500_rtc_remove(struct platform_device *pdev)
462{ 456{
463 dev_pm_clear_wake_irq(&pdev->dev); 457 dev_pm_clear_wake_irq(&pdev->dev);
464 device_init_wakeup(&pdev->dev, false); 458 device_init_wakeup(&pdev->dev, false);
465 ab8500_sysfs_rtc_unregister(&pdev->dev);
466 459
467 return 0; 460 return 0;
468} 461}