Commit b56295dd authored by Alexandre Belloni's avatar Alexandre Belloni

rtc: ab8500: use rtc_add_group

Use rtc_add_group to add the sysfs group in a race free manner.
Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
parent 1654a2b0
...@@ -360,15 +360,14 @@ static DEVICE_ATTR(rtc_calibration, S_IRUGO | S_IWUSR, ...@@ -360,15 +360,14 @@ static DEVICE_ATTR(rtc_calibration, S_IRUGO | S_IWUSR,
ab8500_sysfs_show_rtc_calibration, ab8500_sysfs_show_rtc_calibration,
ab8500_sysfs_store_rtc_calibration); ab8500_sysfs_store_rtc_calibration);
static int ab8500_sysfs_rtc_register(struct device *dev) static struct attribute *ab8500_rtc_attrs[] = {
{ &dev_attr_rtc_calibration.attr,
return device_create_file(dev, &dev_attr_rtc_calibration); NULL
} };
static void ab8500_sysfs_rtc_unregister(struct device *dev) static const struct attribute_group ab8500_rtc_sysfs_files = {
{ .attrs = ab8500_rtc_attrs,
device_remove_file(dev, &dev_attr_rtc_calibration); };
}
static irqreturn_t rtc_alarm_handler(int irq, void *data) static irqreturn_t rtc_alarm_handler(int irq, void *data)
{ {
...@@ -429,14 +428,11 @@ static int ab8500_rtc_probe(struct platform_device *pdev) ...@@ -429,14 +428,11 @@ static int ab8500_rtc_probe(struct platform_device *pdev)
device_init_wakeup(&pdev->dev, true); device_init_wakeup(&pdev->dev, true);
rtc = devm_rtc_device_register(&pdev->dev, "ab8500-rtc", rtc = devm_rtc_allocate_device(&pdev->dev);
(struct rtc_class_ops *)platid->driver_data, if (IS_ERR(rtc))
THIS_MODULE); return PTR_ERR(rtc);
if (IS_ERR(rtc)) {
dev_err(&pdev->dev, "Registration failed\n"); rtc->ops = (struct rtc_class_ops *)platid->driver_data;
err = PTR_ERR(rtc);
return err;
}
err = devm_request_threaded_irq(&pdev->dev, irq, NULL, err = devm_request_threaded_irq(&pdev->dev, irq, NULL,
rtc_alarm_handler, IRQF_ONESHOT, rtc_alarm_handler, IRQF_ONESHOT,
...@@ -447,22 +443,19 @@ static int ab8500_rtc_probe(struct platform_device *pdev) ...@@ -447,22 +443,19 @@ static int ab8500_rtc_probe(struct platform_device *pdev)
dev_pm_set_wake_irq(&pdev->dev, irq); dev_pm_set_wake_irq(&pdev->dev, irq);
platform_set_drvdata(pdev, rtc); platform_set_drvdata(pdev, rtc);
err = ab8500_sysfs_rtc_register(&pdev->dev);
if (err) {
dev_err(&pdev->dev, "sysfs RTC failed to register\n");
return err;
}
rtc->uie_unsupported = 1; rtc->uie_unsupported = 1;
return 0; err = rtc_add_group(rtc, &ab8500_rtc_sysfs_files);
if (err)
return err;
return rtc_register_device(rtc);
} }
static int ab8500_rtc_remove(struct platform_device *pdev) static int ab8500_rtc_remove(struct platform_device *pdev)
{ {
dev_pm_clear_wake_irq(&pdev->dev); dev_pm_clear_wake_irq(&pdev->dev);
device_init_wakeup(&pdev->dev, false); device_init_wakeup(&pdev->dev, false);
ab8500_sysfs_rtc_unregister(&pdev->dev);
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