linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: linux-rtc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>
Subject: [PATCH 09/11] rtc: ds1307: switch to rtc_register_device
Date: Thu,  6 Jul 2017 11:42:06 +0200	[thread overview]
Message-ID: <20170706094208.16240-10-alexandre.belloni@free-electrons.com> (raw)
In-Reply-To: <20170706094208.16240-1-alexandre.belloni@free-electrons.com>

This removes a possible race condition and crash and allows for further
improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/rtc/rtc-ds1307.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 43e9dc6f2edc..bac920a50ece 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -1663,8 +1663,8 @@ static int ds1307_probe(struct i2c_client *client,
 		device_set_wakeup_capable(ds1307->dev, true);
 		set_bit(HAS_ALARM, &ds1307->flags);
 	}
-	ds1307->rtc = devm_rtc_device_register(ds1307->dev, ds1307->name,
-				rtc_ops, THIS_MODULE);
+
+	ds1307->rtc = devm_rtc_allocate_device(ds1307->dev);
 	if (IS_ERR(ds1307->rtc)) {
 		return PTR_ERR(ds1307->rtc);
 	}
@@ -1726,6 +1726,11 @@ static int ds1307_probe(struct i2c_client *client,
 		}
 	}
 
+	ds1307->rtc->ops = rtc_ops;
+	err = rtc_register_device(ds1307->rtc);
+	if (err)
+		return err;
+
 	ds1307_hwmon_register(ds1307);
 	ds1307_clks_register(ds1307);
 
-- 
2.11.0

  parent reply	other threads:[~2017-07-06  9:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-06  9:41 [PATCH 00/11] RTC: rework registration Alexandre Belloni
2017-07-06  9:41 ` [PATCH 01/11] rtc: class separate device allocation from registration Alexandre Belloni
2017-07-06  9:41 ` [PATCH 02/11] rtc: class separate id " Alexandre Belloni
2017-07-06  9:42 ` [PATCH 03/11] rtc: introduce new registration method Alexandre Belloni
2017-07-06  9:42 ` [PATCH 04/11] rtc: at91rm9200: remove race condition Alexandre Belloni
2017-07-06  9:42 ` [PATCH 05/11] rtc: add generic nvmem support Alexandre Belloni
2017-07-06  9:42 ` [PATCH 06/11] rtc: rv8803: switch to rtc_register_device Alexandre Belloni
2017-07-06  9:42 ` [PATCH 07/11] rtc: rv8803: use generic nvmem support Alexandre Belloni
2017-07-06  9:42 ` [PATCH 08/11] rtc: rv8803: remove rv8803_remove Alexandre Belloni
2017-07-06  9:42 ` Alexandre Belloni [this message]
2017-07-06  9:42 ` [PATCH 10/11] rtc: ds1307: use generic nvmem Alexandre Belloni
2017-07-06  9:42 ` [PATCH 11/11] rtc: ds1307: remove ds1307_remove Alexandre Belloni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170706094208.16240-10-alexandre.belloni@free-electrons.com \
    --to=alexandre.belloni@free-electrons.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).