summaryrefslogtreecommitdiff
path: root/drivers/rtc
diff options
context:
space:
mode:
authorQianyu Gong <qianyu.gong@nxp.com>2016-04-21 14:55:40 +0800
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>2016-05-20 12:33:51 +0200
commitb4b77f3c280e38cec178f81d7a4d7e65f4045913 (patch)
treead6ae0b1dbb8cf4096a1ad03080c18ab7a34c70e /drivers/rtc
parenta350259da4b0556fcf276c506a14f406d608c2b3 (diff)
rtc: ds3232: fix call trace when rtc->ops_lock is used as NULL
The rtc->ops_lock would be accessed in ds3232_irq() without being initialized as rtc_device_register() is called too late. So move devm_rtc_device_register() just before registering irq handler to initialize rtc->ops_lock earlier. Signed-off-by: Gong Qianyu <Qianyu.Gong@nxp.com> Reviewed-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-ds3232.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/rtc/rtc-ds3232.c b/drivers/rtc/rtc-ds3232.c
index 7edc889729c5..04fbd7fffd0d 100644
--- a/drivers/rtc/rtc-ds3232.c
+++ b/drivers/rtc/rtc-ds3232.c
@@ -369,6 +369,11 @@ static int ds3232_probe(struct device *dev, struct regmap *regmap, int irq,
if (ret)
return ret;
+ ds3232->rtc = devm_rtc_device_register(dev, name, &ds3232_rtc_ops,
+ THIS_MODULE);
+ if (IS_ERR(ds3232->rtc))
+ return PTR_ERR(ds3232->rtc);
+
if (ds3232->irq > 0) {
ret = devm_request_threaded_irq(dev, ds3232->irq, NULL,
ds3232_irq,
@@ -380,10 +385,8 @@ static int ds3232_probe(struct device *dev, struct regmap *regmap, int irq,
} else
device_init_wakeup(dev, 1);
}
- ds3232->rtc = devm_rtc_device_register(dev, name, &ds3232_rtc_ops,
- THIS_MODULE);
- return PTR_ERR_OR_ZERO(ds3232->rtc);
+ return 0;
}
#ifdef CONFIG_PM_SLEEP