Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1682276

[PATCH 06/11] rtc: rv8803: switch to rtc_register_device

From Alexandre Belloni <alexandre.belloni@free-electrons.com>
Newsgroups linux.kernel
Subject [PATCH 06/11] rtc: rv8803: switch to rtc_register_device
Date 2017-07-06 11:50 +0200
Message-ID <u0bA7-2xi-41@gated-at.bofh.it> (permalink)
References <u0bA5-2xi-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

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

diff --git a/drivers/rtc/rtc-rv8803.c b/drivers/rtc/rtc-rv8803.c
index 9ad97ab29866..209edbb03971 100644
--- a/drivers/rtc/rtc-rv8803.c
+++ b/drivers/rtc/rtc-rv8803.c
@@ -577,6 +577,11 @@ static int rv8803_probe(struct i2c_client *client,
 	if (flags & RV8803_FLAG_AF)
 		dev_warn(&client->dev, "An alarm maybe have been missed.\n");
 
+	rv8803->rtc = devm_rtc_allocate_device(&client->dev);
+	if (IS_ERR(rv8803->rtc)) {
+		return PTR_ERR(rv8803->rtc);
+	}
+
 	if (client->irq > 0) {
 		err = devm_request_threaded_irq(&client->dev, client->irq,
 						NULL, rv8803_handle_irq,
@@ -592,12 +597,10 @@ static int rv8803_probe(struct i2c_client *client,
 		}
 	}
 
-	rv8803->rtc = devm_rtc_device_register(&client->dev, client->name,
-					       &rv8803_rtc_ops, THIS_MODULE);
-	if (IS_ERR(rv8803->rtc)) {
-		dev_err(&client->dev, "unable to register the class device\n");
-		return PTR_ERR(rv8803->rtc);
-	}
+	rv8803->rtc->ops = &rv8803_rtc_ops;
+	err = rtc_register_device(rv8803->rtc);
+	if (err)
+		return err;
 
 	err = rv8803_write_reg(rv8803->client, RV8803_EXT, RV8803_EXT_WADA);
 	if (err)
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/11] RTC: rework registration Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-07-06 11:50 +0200
  [PATCH 07/11] rtc: rv8803: use generic nvmem support Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-07-06 11:50 +0200
  [PATCH 04/11] rtc: at91rm9200: remove race condition Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-07-06 11:50 +0200
  [PATCH 11/11] rtc: ds1307: remove ds1307_remove Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-07-06 11:50 +0200
  [PATCH 09/11] rtc: ds1307: switch to rtc_register_device Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-07-06 11:50 +0200
  [PATCH 03/11] rtc: introduce new registration method Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-07-06 11:50 +0200
  [PATCH 06/11] rtc: rv8803: switch to rtc_register_device Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-07-06 11:50 +0200
  [PATCH 02/11] rtc: class separate id allocation from registration Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-07-06 11:50 +0200
  [PATCH 01/11] rtc: class separate device allocation from registration Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-07-06 11:50 +0200
  [PATCH 05/11] rtc: add generic nvmem support Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-07-06 11:50 +0200
  [PATCH 08/11] rtc: rv8803: remove rv8803_remove Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2017-07-06 11:50 +0200

csiph-web