* [PATCH] rtc: pcf2127: add error message if writing to CLKOUT register fails
@ 2022-01-19 17:27 Hugo Villeneuve
2022-01-19 17:37 ` Alexandre Belloni
0 siblings, 1 reply; 6+ messages in thread
From: Hugo Villeneuve @ 2022-01-19 17:27 UTC (permalink / raw)
To: Alessandro Zummo, Alexandre Belloni
Cc: hugo, Hugo Villeneuve, linux-rtc, linux-kernel
From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
If writing to CLKOUT register fails, the probe operation will be aborted
without a meaningful error message.
Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
---
drivers/rtc/rtc-pcf2127.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
index 3d1f57e54372..823abe2a7147 100644
--- a/drivers/rtc/rtc-pcf2127.c
+++ b/drivers/rtc/rtc-pcf2127.c
@@ -717,8 +717,10 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
if (!(val & PCF2127_BIT_CLKOUT_OTPR)) {
ret = regmap_set_bits(pcf2127->regmap, PCF2127_REG_CLKOUT,
PCF2127_BIT_CLKOUT_OTPR);
- if (ret < 0)
+ if (ret < 0) {
+ dev_err(dev, "writing to CLKOUT register failed\n");
return ret;
+ }
msleep(100);
}
--
2.30.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] rtc: pcf2127: add error message if writing to CLKOUT register fails
2022-01-19 17:27 [PATCH] rtc: pcf2127: add error message if writing to CLKOUT register fails Hugo Villeneuve
@ 2022-01-19 17:37 ` Alexandre Belloni
2022-01-19 18:08 ` Hugo Villeneuve
0 siblings, 1 reply; 6+ messages in thread
From: Alexandre Belloni @ 2022-01-19 17:37 UTC (permalink / raw)
To: Hugo Villeneuve
Cc: Alessandro Zummo, Hugo Villeneuve, linux-rtc, linux-kernel
On 19/01/2022 12:27:39-0500, Hugo Villeneuve wrote:
> From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
>
> If writing to CLKOUT register fails, the probe operation will be aborted
> without a meaningful error message.
>
The current trend is to remove debug messages, please do not add more :)
> Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> ---
> drivers/rtc/rtc-pcf2127.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
> index 3d1f57e54372..823abe2a7147 100644
> --- a/drivers/rtc/rtc-pcf2127.c
> +++ b/drivers/rtc/rtc-pcf2127.c
> @@ -717,8 +717,10 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
> if (!(val & PCF2127_BIT_CLKOUT_OTPR)) {
> ret = regmap_set_bits(pcf2127->regmap, PCF2127_REG_CLKOUT,
> PCF2127_BIT_CLKOUT_OTPR);
> - if (ret < 0)
> + if (ret < 0) {
> + dev_err(dev, "writing to CLKOUT register failed\n");
> return ret;
> + }
>
> msleep(100);
> }
> --
> 2.30.2
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rtc: pcf2127: add error message if writing to CLKOUT register fails
2022-01-19 17:37 ` Alexandre Belloni
@ 2022-01-19 18:08 ` Hugo Villeneuve
2022-01-19 19:10 ` Alexandre Belloni
0 siblings, 1 reply; 6+ messages in thread
From: Hugo Villeneuve @ 2022-01-19 18:08 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Alessandro Zummo, Hugo Villeneuve, linux-rtc, linux-kernel
On Wed, 19 Jan 2022 18:37:40 +0100
Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:
> On 19/01/2022 12:27:39-0500, Hugo Villeneuve wrote:
> > From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> >
> > If writing to CLKOUT register fails, the probe operation will be aborted
> > without a meaningful error message.
> >
>
> The current trend is to remove debug messages, please do not add more :)
Hi,
If the read operation fails, the probe function will exit silently, and our RTC chip will not work. In that case, if we parse the dmesg logs, I think we should have an indication that something went wrong.
I had a case where my dev board was not properly plugged-in, and before this patch, I didn't notice it because of the silent abort of the probe function.
>
> > Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> > ---
> > drivers/rtc/rtc-pcf2127.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
> > index 3d1f57e54372..823abe2a7147 100644
> > --- a/drivers/rtc/rtc-pcf2127.c
> > +++ b/drivers/rtc/rtc-pcf2127.c
> > @@ -717,8 +717,10 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
> > if (!(val & PCF2127_BIT_CLKOUT_OTPR)) {
> > ret = regmap_set_bits(pcf2127->regmap, PCF2127_REG_CLKOUT,
> > PCF2127_BIT_CLKOUT_OTPR);
> > - if (ret < 0)
> > + if (ret < 0) {
> > + dev_err(dev, "writing to CLKOUT register failed\n");
> > return ret;
> > + }
> >
> > msleep(100);
> > }
> > --
> > 2.30.2
> >
>
> --
> Alexandre Belloni, co-owner and COO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
>
--
Hugo Villeneuve <hugo@hugovil.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rtc: pcf2127: add error message if writing to CLKOUT register fails
2022-01-19 18:08 ` Hugo Villeneuve
@ 2022-01-19 19:10 ` Alexandre Belloni
2022-01-20 23:35 ` Hugo Villeneuve
0 siblings, 1 reply; 6+ messages in thread
From: Alexandre Belloni @ 2022-01-19 19:10 UTC (permalink / raw)
To: Hugo Villeneuve
Cc: Alessandro Zummo, Hugo Villeneuve, linux-rtc, linux-kernel
On 19/01/2022 13:08:45-0500, Hugo Villeneuve wrote:
> On Wed, 19 Jan 2022 18:37:40 +0100
> Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:
>
> > On 19/01/2022 12:27:39-0500, Hugo Villeneuve wrote:
> > > From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> > >
> > > If writing to CLKOUT register fails, the probe operation will be aborted
> > > without a meaningful error message.
> > >
> >
> > The current trend is to remove debug messages, please do not add more :)
>
> Hi,
> If the read operation fails, the probe function will exit silently, and our RTC chip will not work. In that case, if we parse the dmesg logs, I think we should have an indication that something went wrong.
>
This is not true, it doesn't fail silently, you'd get:
rtc-pcf2127: probe of 1-0051 failed with error -121
> I had a case where my dev board was not properly plugged-in, and before this patch, I didn't notice it because of the silent abort of the probe function.
>
Again, not silent.
> >
> > > Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> > > ---
> > > drivers/rtc/rtc-pcf2127.c | 4 +++-
> > > 1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
> > > index 3d1f57e54372..823abe2a7147 100644
> > > --- a/drivers/rtc/rtc-pcf2127.c
> > > +++ b/drivers/rtc/rtc-pcf2127.c
> > > @@ -717,8 +717,10 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
> > > if (!(val & PCF2127_BIT_CLKOUT_OTPR)) {
> > > ret = regmap_set_bits(pcf2127->regmap, PCF2127_REG_CLKOUT,
> > > PCF2127_BIT_CLKOUT_OTPR);
> > > - if (ret < 0)
> > > + if (ret < 0) {
> > > + dev_err(dev, "writing to CLKOUT register failed\n");
> > > return ret;
> > > + }
> > >
> > > msleep(100);
> > > }
> > > --
> > > 2.30.2
> > >
> >
> > --
> > Alexandre Belloni, co-owner and COO, Bootlin
> > Embedded Linux and Kernel engineering
> > https://bootlin.com
> >
>
>
> --
> Hugo Villeneuve <hugo@hugovil.com>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rtc: pcf2127: add error message if writing to CLKOUT register fails
2022-01-19 19:10 ` Alexandre Belloni
@ 2022-01-20 23:35 ` Hugo Villeneuve
2022-01-21 17:06 ` Alexandre Belloni
0 siblings, 1 reply; 6+ messages in thread
From: Hugo Villeneuve @ 2022-01-20 23:35 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Alessandro Zummo, Hugo Villeneuve, linux-rtc, linux-kernel
On Wed, 19 Jan 2022 20:10:20 +0100
Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:
> On 19/01/2022 13:08:45-0500, Hugo Villeneuve wrote:
> > On Wed, 19 Jan 2022 18:37:40 +0100
> > Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:
> >
> > > On 19/01/2022 12:27:39-0500, Hugo Villeneuve wrote:
> > > > From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> > > >
> > > > If writing to CLKOUT register fails, the probe operation will be aborted
> > > > without a meaningful error message.
> > > >
> > >
> > > The current trend is to remove debug messages, please do not add more :)
> >
> > Hi,
> > If the read operation fails, the probe function will exit silently, and our RTC chip will not work. In that case, if we parse the dmesg logs, I think we should have an indication that something went wrong.
> >
>
> This is not true, it doesn't fail silently, you'd get:
> rtc-pcf2127: probe of 1-0051 failed with error -121
Well this is certainly true for me because I am not seing the same error message as you :)
Just for context, I have defined a dummy pcf2127 on I2C bus 0 in my device tree (no actual hardware is present). I also added some debug messages to investigate (rtc-pcf2127.c and dd.c files), and here is the dmesg log after issuing "modprobe rtc-pcf2127":
[Thu Jan 20 23:22:20 2022] rtc-pcf2127-i2c 0-0051: pcf2127_i2c_probe
[Thu Jan 20 23:22:20 2022] rtc-pcf2127-i2c 0-0051: pcf2127_probe
[Thu Jan 20 23:22:20 2022] rtc-pcf2127-i2c 0-0051: PORO disabling failed with error -6
[Thu Jan 20 23:22:20 2022] rtc-pcf2127-i2c 0-0051: call_driver_probe probe error: -6
Error code -6 is -ENXIO, and looking at the call_driver_probe() function in dd.c, I now understand why I didn't see the error message (line 531):
case -ENXIO:
pr_debug("%s: probe of %s rejects match %d\n",
drv->name, dev_name(dev), ret);
So it seems that the return code is different than what you got?
> > I had a case where my dev board was not properly plugged-in, and before this patch, I didn't notice it because of the silent abort of the probe function.
> >
>
> Again, not silent.
>
> > >
> > > > Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> > > > ---
> > > > drivers/rtc/rtc-pcf2127.c | 4 +++-
> > > > 1 file changed, 3 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c
> > > > index 3d1f57e54372..823abe2a7147 100644
> > > > --- a/drivers/rtc/rtc-pcf2127.c
> > > > +++ b/drivers/rtc/rtc-pcf2127.c
> > > > @@ -717,8 +717,10 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
> > > > if (!(val & PCF2127_BIT_CLKOUT_OTPR)) {
> > > > ret = regmap_set_bits(pcf2127->regmap, PCF2127_REG_CLKOUT,
> > > > PCF2127_BIT_CLKOUT_OTPR);
> > > > - if (ret < 0)
> > > > + if (ret < 0) {
> > > > + dev_err(dev, "writing to CLKOUT register failed\n");
> > > > return ret;
> > > > + }
> > > >
> > > > msleep(100);
> > > > }
> > > > --
> > > > 2.30.2
> > > >
> > >
> > > --
> > > Alexandre Belloni, co-owner and COO, Bootlin
> > > Embedded Linux and Kernel engineering
> > > https://bootlin.com
> > >
> >
> >
> > --
> > Hugo Villeneuve <hugo@hugovil.com>
>
> --
> Alexandre Belloni, co-owner and COO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
>
--
Hugo Villeneuve <hugo@hugovil.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rtc: pcf2127: add error message if writing to CLKOUT register fails
2022-01-20 23:35 ` Hugo Villeneuve
@ 2022-01-21 17:06 ` Alexandre Belloni
0 siblings, 0 replies; 6+ messages in thread
From: Alexandre Belloni @ 2022-01-21 17:06 UTC (permalink / raw)
To: Hugo Villeneuve
Cc: Alessandro Zummo, Hugo Villeneuve, linux-rtc, linux-kernel
On 20/01/2022 18:35:48-0500, Hugo Villeneuve wrote:
> On Wed, 19 Jan 2022 20:10:20 +0100
> Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:
>
> > On 19/01/2022 13:08:45-0500, Hugo Villeneuve wrote:
> > > On Wed, 19 Jan 2022 18:37:40 +0100
> > > Alexandre Belloni <alexandre.belloni@bootlin.com> wrote:
> > >
> > > > On 19/01/2022 12:27:39-0500, Hugo Villeneuve wrote:
> > > > > From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> > > > >
> > > > > If writing to CLKOUT register fails, the probe operation will be aborted
> > > > > without a meaningful error message.
> > > > >
> > > >
> > > > The current trend is to remove debug messages, please do not add more :)
> > >
> > > Hi,
> > > If the read operation fails, the probe function will exit silently, and our RTC chip will not work. In that case, if we parse the dmesg logs, I think we should have an indication that something went wrong.
> > >
> >
> > This is not true, it doesn't fail silently, you'd get:
> > rtc-pcf2127: probe of 1-0051 failed with error -121
>
> Well this is certainly true for me because I am not seing the same error message as you :)
>
> Just for context, I have defined a dummy pcf2127 on I2C bus 0 in my device tree (no actual hardware is present). I also added some debug messages to investigate (rtc-pcf2127.c and dd.c files), and here is the dmesg log after issuing "modprobe rtc-pcf2127":
>
> [Thu Jan 20 23:22:20 2022] rtc-pcf2127-i2c 0-0051: pcf2127_i2c_probe
> [Thu Jan 20 23:22:20 2022] rtc-pcf2127-i2c 0-0051: pcf2127_probe
> [Thu Jan 20 23:22:20 2022] rtc-pcf2127-i2c 0-0051: PORO disabling failed with error -6
> [Thu Jan 20 23:22:20 2022] rtc-pcf2127-i2c 0-0051: call_driver_probe probe error: -6
>
> Error code -6 is -ENXIO, and looking at the call_driver_probe() function in dd.c, I now understand why I didn't see the error message (line 531):
>
> case -ENXIO:
> pr_debug("%s: probe of %s rejects match %d\n",
> drv->name, dev_name(dev), ret);
>
> So it seems that the return code is different than what you got?
>
Probably because we don't have the same i2c controller and the driver
for mine is returning -EREMOTEIO when the device is not present.
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-01-21 17:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-19 17:27 [PATCH] rtc: pcf2127: add error message if writing to CLKOUT register fails Hugo Villeneuve
2022-01-19 17:37 ` Alexandre Belloni
2022-01-19 18:08 ` Hugo Villeneuve
2022-01-19 19:10 ` Alexandre Belloni
2022-01-20 23:35 ` Hugo Villeneuve
2022-01-21 17:06 ` Alexandre Belloni
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).