* [PATCH 1/2] rtc: abx80x: switch to rtc_register_device
@ 2017-10-12 22:04 Alexandre Belloni
2017-10-12 22:04 ` [PATCH 2/2] rtc: abx80x: solve race condition Alexandre Belloni
0 siblings, 1 reply; 2+ messages in thread
From: Alexandre Belloni @ 2017-10-12 22:04 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
This allows for future improvement of the driver.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/rtc/rtc-abx80x.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
index fea9a60b06cf..442e62a3c9a9 100644
--- a/drivers/rtc/rtc-abx80x.c
+++ b/drivers/rtc/rtc-abx80x.c
@@ -614,12 +614,16 @@ static int abx80x_probe(struct i2c_client *client,
if (err)
return err;
- rtc = devm_rtc_device_register(&client->dev, "abx8xx",
- &abx80x_rtc_ops, THIS_MODULE);
-
+ rtc = devm_rtc_allocate_device(&client->dev);
if (IS_ERR(rtc))
return PTR_ERR(rtc);
+ rtc->ops = &abx80x_rtc_ops;
+
+ err = rtc_register_device(rtc);
+ if (err)
+ return err;
+
i2c_set_clientdata(client, rtc);
if (client->irq > 0) {
--
2.14.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/2] rtc: abx80x: solve race condition
2017-10-12 22:04 [PATCH 1/2] rtc: abx80x: switch to rtc_register_device Alexandre Belloni
@ 2017-10-12 22:04 ` Alexandre Belloni
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2017-10-12 22:04 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, Alexandre Belloni
There is a race condition that can happen if abx80x_probe() fails after the
rtc registration succeeded. Solve that by moving the registration at the
end of the probe function.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/rtc/rtc-abx80x.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c
index 442e62a3c9a9..b033bc556f5d 100644
--- a/drivers/rtc/rtc-abx80x.c
+++ b/drivers/rtc/rtc-abx80x.c
@@ -620,10 +620,6 @@ static int abx80x_probe(struct i2c_client *client,
rtc->ops = &abx80x_rtc_ops;
- err = rtc_register_device(rtc);
- if (err)
- return err;
-
i2c_set_clientdata(client, rtc);
if (client->irq > 0) {
@@ -650,10 +646,14 @@ static int abx80x_probe(struct i2c_client *client,
err = devm_add_action_or_reset(&client->dev,
rtc_calib_remove_sysfs_group,
&client->dev);
- if (err)
+ if (err) {
dev_err(&client->dev,
"Failed to add sysfs cleanup action: %d\n",
err);
+ return err;
+ }
+
+ err = rtc_register_device(rtc);
return err;
}
--
2.14.2
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-10-12 22:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-12 22:04 [PATCH 1/2] rtc: abx80x: switch to rtc_register_device Alexandre Belloni
2017-10-12 22:04 ` [PATCH 2/2] rtc: abx80x: solve race condition Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®