* [PATCH] rtc: pcf85363: Fix phantom device registration on missing hardware
@ 2026-07-16 12:51 Cosmo Chou
2026-07-16 12:56 ` Alexandre Belloni
0 siblings, 1 reply; 4+ messages in thread
From: Cosmo Chou @ 2026-07-16 12:51 UTC (permalink / raw)
To: alexandre.belloni; +Cc: linux-rtc, linux-kernel, cosmo.chou, Cosmo Chou
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
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] rtc: pcf85363: Fix phantom device registration on missing hardware 2026-07-16 12:51 [PATCH] rtc: pcf85363: Fix phantom device registration on missing hardware Cosmo Chou @ 2026-07-16 12:56 ` Alexandre Belloni 2026-07-16 14:56 ` Cosmo Chou 0 siblings, 1 reply; 4+ messages in thread From: Alexandre Belloni @ 2026-07-16 12:56 UTC (permalink / raw) To: Cosmo Chou; +Cc: linux-rtc, linux-kernel, cosmo.chou On 16/07/2026 20:51:42+0800, Cosmo Chou wrote: > 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. > No, there is no point in this, simply remove the RTC node from you device tree. > 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 > -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rtc: pcf85363: Fix phantom device registration on missing hardware 2026-07-16 12:56 ` Alexandre Belloni @ 2026-07-16 14:56 ` Cosmo Chou 2026-07-16 15:22 ` Alexandre Belloni 0 siblings, 1 reply; 4+ messages in thread From: Cosmo Chou @ 2026-07-16 14:56 UTC (permalink / raw) To: Alexandre Belloni; +Cc: linux-rtc, linux-kernel, cosmo.chou On Thu, Jul 16, 2026 at 8:56 PM Alexandre Belloni <alexandre.belloni@bootlin.com> wrote: > > On 16/07/2026 20:51:42+0800, Cosmo Chou wrote: > > 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. > > > > No, there is no point in this, simply remove the RTC node from you > device tree. > Hi Alexandre, You are right, fixing the DT is the correct solution for missing hardware. My commit message was misleading. However, the current code ignores actual I2C transport errors (e.g., -ENXIO due to physical bus issues) from pcf85363_load_capacitance() and continues probing. Should I send a v2 with an updated commit message focusing solely on properly handling these transport errors? Thanks, Cosmo > > 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 > > > > -- > Alexandre Belloni, co-owner and COO, Bootlin > Embedded Linux and Kernel engineering > https://bootlin.com ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rtc: pcf85363: Fix phantom device registration on missing hardware 2026-07-16 14:56 ` Cosmo Chou @ 2026-07-16 15:22 ` Alexandre Belloni 0 siblings, 0 replies; 4+ messages in thread From: Alexandre Belloni @ 2026-07-16 15:22 UTC (permalink / raw) To: Cosmo Chou; +Cc: linux-rtc, linux-kernel, cosmo.chou On 16/07/2026 22:56:04+0800, Cosmo Chou wrote: > On Thu, Jul 16, 2026 at 8:56 PM Alexandre Belloni > <alexandre.belloni@bootlin.com> wrote: > > > > On 16/07/2026 20:51:42+0800, Cosmo Chou wrote: > > > 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. > > > > > > > No, there is no point in this, simply remove the RTC node from you > > device tree. > > > > Hi Alexandre, > > You are right, fixing the DT is the correct solution for missing > hardware. My commit message was misleading. > > However, the current code ignores actual I2C transport errors (e.g., > -ENXIO due to physical bus issues) from pcf85363_load_capacitance() > and continues probing. > > Should I send a v2 with an updated commit message focusing solely on > properly handling these transport errors? Then you should add error checking to all the regmap calls in probe() > > Thanks, > Cosmo > > > > 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 > > > > > > > -- > > Alexandre Belloni, co-owner and COO, Bootlin > > Embedded Linux and Kernel engineering > > https://bootlin.com -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-16 15:22 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-07-16 12:51 [PATCH] rtc: pcf85363: Fix phantom device registration on missing hardware Cosmo Chou 2026-07-16 12:56 ` Alexandre Belloni 2026-07-16 14:56 ` Cosmo Chou 2026-07-16 15:22 ` Alexandre Belloni
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox