linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: [PATCH 6/8] rtc: nvmem: emit an error message when nvmem registration fails
Date: Mon,  9 Nov 2020 17:34:07 +0100	[thread overview]
Message-ID: <20201109163409.24301-7-brgl@bgdev.pl> (raw)
In-Reply-To: <20201109163409.24301-1-brgl@bgdev.pl>

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Some users check the return value of devm_rtc_nvmem_register() only in
order to emit an error message and then continue probing. This is fine
as an rtc can function without exposing nvmem but let's generalize it:
let's make the registration function emit the error message so that
users don't have to.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/rtc/nvmem.c      | 7 +++++--
 drivers/rtc/rtc-cmos.c   | 3 +--
 drivers/rtc/rtc-ds1553.c | 3 +--
 drivers/rtc/rtc-ds1742.c | 3 +--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/rtc/nvmem.c b/drivers/rtc/nvmem.c
index 7502deb6390e..07ede21cee34 100644
--- a/drivers/rtc/nvmem.c
+++ b/drivers/rtc/nvmem.c
@@ -13,14 +13,17 @@
 int devm_rtc_nvmem_register(struct rtc_device *rtc,
 		       struct nvmem_config *nvmem_config)
 {
+	struct device *dev = rtc->dev.parent;
 	struct nvmem_device *nvmem;
 
 	if (!nvmem_config)
 		return -ENODEV;
 
-	nvmem_config->dev = rtc->dev.parent;
+	nvmem_config->dev = dev;
 	nvmem_config->owner = rtc->owner;
-	nvmem = devm_nvmem_register(rtc->dev.parent, nvmem_config);
+	nvmem = devm_nvmem_register(dev, nvmem_config);
+	if (IS_ERR(nvmem))
+		dev_err(dev, "failed to register nvmem device for RTC\n");
 
 	return PTR_ERR_OR_ZERO(nvmem);
 }
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index eea91c1538aa..766074c04b53 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -869,8 +869,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
 
 	/* export at least the first block of NVRAM */
 	nvmem_cfg.size = address_space - NVRAM_OFFSET;
-	if (devm_rtc_nvmem_register(cmos_rtc.rtc, &nvmem_cfg))
-		dev_err(dev, "nvmem registration failed\n");
+	devm_rtc_nvmem_register(cmos_rtc.rtc, &nvmem_cfg);
 
 	dev_info(dev, "%s%s, %d bytes nvram%s\n",
 		 !is_valid_irq(rtc_irq) ? "no alarms" :
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c
index 2d2eb739d92b..bb40ea8b6373 100644
--- a/drivers/rtc/rtc-ds1553.c
+++ b/drivers/rtc/rtc-ds1553.c
@@ -309,8 +309,7 @@ static int ds1553_rtc_probe(struct platform_device *pdev)
 		}
 	}
 
-	if (devm_rtc_nvmem_register(pdata->rtc, &nvmem_cfg))
-		dev_err(&pdev->dev, "unable to register nvmem\n");
+	devm_rtc_nvmem_register(pdata->rtc, &nvmem_cfg);
 
 	return 0;
 }
diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c
index 29792a8cce97..39c6c3a85b34 100644
--- a/drivers/rtc/rtc-ds1742.c
+++ b/drivers/rtc/rtc-ds1742.c
@@ -195,8 +195,7 @@ static int ds1742_rtc_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	if (devm_rtc_nvmem_register(rtc, &nvmem_cfg))
-		dev_err(&pdev->dev, "Unable to register nvmem\n");
+	devm_rtc_nvmem_register(rtc, &nvmem_cfg);
 
 	return 0;
 }
-- 
2.29.1


  parent reply	other threads:[~2020-11-09 16:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-09 16:34 [PATCH 0/8] rtc: rework resource management Bartosz Golaszewski
2020-11-09 16:34 ` [PATCH 1/8] rtc: omap: use devm_pinctrl_register() Bartosz Golaszewski
2020-11-09 16:34 ` [PATCH 2/8] Revert "rtc: sc27xx: Always read normal alarm when registering RTC device" Bartosz Golaszewski
2020-11-17 21:23   ` Alexandre Belloni
2020-11-09 16:34 ` [PATCH 3/8] Documentation: list RTC devres helpers in devres.rst Bartosz Golaszewski
2020-11-09 16:34 ` [PATCH 4/8] rtc: nvmem: remove nvram ABI Bartosz Golaszewski
2020-11-09 16:34 ` [PATCH 5/8] rtc: add devm_ prefix to rtc_nvmem_register() Bartosz Golaszewski
2020-11-09 16:34 ` Bartosz Golaszewski [this message]
2020-11-09 16:34 ` [PATCH 7/8] rtc: rework rtc_register_device() resource management Bartosz Golaszewski
2020-11-17 21:35   ` Alexandre Belloni
2020-11-18  8:13     ` Bartosz Golaszewski
     [not found]   ` <CAF2Aj3inp8=dn9xuc8f3uJbL+m5LH7W3BDoOeZyiiOupmbfgOw@mail.gmail.com>
2020-11-27  9:23     ` Bartosz Golaszewski
2020-11-27 13:22       ` Lee Jones
2020-11-09 16:34 ` [PATCH 8/8] rtc: shrink devm_rtc_allocate_device() Bartosz Golaszewski
2020-11-17 22:57 ` [PATCH 0/8] rtc: rework resource management 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=20201109163409.24301-7-brgl@bgdev.pl \
    --to=brgl@bgdev.pl \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=bgolaszewski@baylibre.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).