aboutsummaryrefslogtreecommitdiff
path: root/drivers/rtc/rtc-rp5c01.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-rp5c01.c')
-rw-r--r--drivers/rtc/rtc-rp5c01.c50
1 files changed, 12 insertions, 38 deletions
diff --git a/drivers/rtc/rtc-rp5c01.c b/drivers/rtc/rtc-rp5c01.c
index 36eb6618446..89d07367926 100644
--- a/drivers/rtc/rtc-rp5c01.c
+++ b/drivers/rtc/rtc-rp5c01.c
@@ -76,7 +76,7 @@ static inline unsigned int rp5c01_read(struct rp5c01_priv *priv,
static inline void rp5c01_write(struct rp5c01_priv *priv, unsigned int val,
unsigned int reg)
{
- return __raw_writel(val, &priv->regs[reg]);
+ __raw_writel(val, &priv->regs[reg]);
}
static void rp5c01_lock(struct rp5c01_priv *priv)
@@ -230,15 +230,13 @@ static int __init rp5c01_rtc_probe(struct platform_device *dev)
if (!res)
return -ENODEV;
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
- priv->regs = ioremap(res->start, resource_size(res));
- if (!priv->regs) {
- error = -ENOMEM;
- goto out_free_priv;
- }
+ priv->regs = devm_ioremap(&dev->dev, res->start, resource_size(res));
+ if (!priv->regs)
+ return -ENOMEM;
sysfs_bin_attr_init(&priv->nvram_attr);
priv->nvram_attr.attr.name = "nvram";
@@ -249,29 +247,19 @@ static int __init rp5c01_rtc_probe(struct platform_device *dev)
spin_lock_init(&priv->lock);
- rtc = rtc_device_register("rtc-rp5c01", &dev->dev, &rp5c01_rtc_ops,
- THIS_MODULE);
- if (IS_ERR(rtc)) {
- error = PTR_ERR(rtc);
- goto out_unmap;
- }
+ platform_set_drvdata(dev, priv);
+ rtc = devm_rtc_device_register(&dev->dev, "rtc-rp5c01", &rp5c01_rtc_ops,
+ THIS_MODULE);
+ if (IS_ERR(rtc))
+ return PTR_ERR(rtc);
priv->rtc = rtc;
- platform_set_drvdata(dev, priv);
error = sysfs_create_bin_file(&dev->dev.kobj, &priv->nvram_attr);
if (error)
- goto out_unregister;
+ return error;
return 0;
-
-out_unregister:
- rtc_device_unregister(rtc);
-out_unmap:
- iounmap(priv->regs);
-out_free_priv:
- kfree(priv);
- return error;
}
static int __exit rp5c01_rtc_remove(struct platform_device *dev)
@@ -279,9 +267,6 @@ static int __exit rp5c01_rtc_remove(struct platform_device *dev)
struct rp5c01_priv *priv = platform_get_drvdata(dev);
sysfs_remove_bin_file(&dev->dev.kobj, &priv->nvram_attr);
- rtc_device_unregister(priv->rtc);
- iounmap(priv->regs);
- kfree(priv);
return 0;
}
@@ -293,18 +278,7 @@ static struct platform_driver rp5c01_rtc_driver = {
.remove = __exit_p(rp5c01_rtc_remove),
};
-static int __init rp5c01_rtc_init(void)
-{
- return platform_driver_probe(&rp5c01_rtc_driver, rp5c01_rtc_probe);
-}
-
-static void __exit rp5c01_rtc_fini(void)
-{
- platform_driver_unregister(&rp5c01_rtc_driver);
-}
-
-module_init(rp5c01_rtc_init);
-module_exit(rp5c01_rtc_fini);
+module_platform_driver_probe(rp5c01_rtc_driver, rp5c01_rtc_probe);
MODULE_AUTHOR("Geert Uytterhoeven <geert@linux-m68k.org>");
MODULE_LICENSE("GPL");