Linux RTC
 help / color / mirror / Atom feed
From: Cosmo Chou <chou.cosmo@gmail.com>
To: alexandre.belloni@bootlin.com
Cc: linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org,
	cosmo.chou@quantatw.com, Cosmo Chou <chou.cosmo@gmail.com>
Subject: [PATCH] rtc: pcf85363: Fix phantom device registration on missing hardware
Date: Thu, 16 Jul 2026 20:51:42 +0800	[thread overview]
Message-ID: <20260716125142.1801599-1-chou.cosmo@gmail.com> (raw)

During probe, pcf85363_load_capacitance() writes the oscillator load
capacitance configuration to the device. However, if the device is
not physically present on the bus (returning -ENXIO), the driver
only emits a warning and continues to execute the probe.

This results in the successful registration of a phantom RTC device
via devm_rtc_register_device() and its associated nvmem regions.
Consequently, userspace may attempt to bind to a non-functional
/dev/rtc node.

Propagate the I2C error back to the driver core using dev_err_probe()
to properly abort the probe and prevent phantom device registration.

Fixes: fd9a6a13949a ("rtc: pcf85363: add support for the quartz-load-femtofarads property")
Signed-off-by: Cosmo Chou <chou.cosmo@gmail.com>
---
 drivers/rtc/rtc-pcf85363.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-pcf85363.c b/drivers/rtc/rtc-pcf85363.c
index 540042b9eec8..5612330aff40 100644
--- a/drivers/rtc/rtc-pcf85363.c
+++ b/drivers/rtc/rtc-pcf85363.c
@@ -426,8 +426,8 @@ static int pcf85363_probe(struct i2c_client *client)
 
 	err = pcf85363_load_capacitance(pcf85363, client->dev.of_node);
 	if (err < 0)
-		dev_warn(&client->dev, "failed to set xtal load capacitance: %d",
-			 err);
+		return dev_err_probe(&client->dev, err,
+				     "failed to set xtal load capacitance\n");
 
 	pcf85363->rtc->ops = &rtc_ops;
 	pcf85363->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
-- 
2.43.0


             reply	other threads:[~2026-07-16 12:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16 12:51 Cosmo Chou [this message]
2026-07-16 12:56 ` [PATCH] rtc: pcf85363: Fix phantom device registration on missing hardware Alexandre Belloni
2026-07-16 14:56   ` Cosmo Chou
2026-07-16 15:22     ` Alexandre Belloni
2026-07-16 13:00 ` sashiko-bot

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=20260716125142.1801599-1-chou.cosmo@gmail.com \
    --to=chou.cosmo@gmail.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=cosmo.chou@quantatw.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