public inbox for linux-gpio@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: pca953x: Print the error code on read/write failures
@ 2024-08-21 11:42 Fabio Estevam
  2024-08-21 12:11 ` Bartosz Golaszewski
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Fabio Estevam @ 2024-08-21 11:42 UTC (permalink / raw)
  To: brgl; +Cc: linus.walleij, linux-gpio, linux, Fabio Estevam

From: Fabio Estevam <festevam@denx.de>

Print the error code in the pca953x_write_regs() and pca953x_read_regs()
functions to help debugging.

Suggested-by: Russell King (Oracle) <linux@armlinux.org.uk>
Signed-off-by: Fabio Estevam <festevam@denx.de>
---
 drivers/gpio/gpio-pca953x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 8baf3edd5274..3f2d33ee20cc 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -498,7 +498,7 @@ static int pca953x_write_regs(struct pca953x_chip *chip, int reg, unsigned long
 
 	ret = regmap_bulk_write(chip->regmap, regaddr, value, NBANK(chip));
 	if (ret < 0) {
-		dev_err(&chip->client->dev, "failed writing register\n");
+		dev_err(&chip->client->dev, "failed writing register: %d\n", ret);
 		return ret;
 	}
 
@@ -513,7 +513,7 @@ static int pca953x_read_regs(struct pca953x_chip *chip, int reg, unsigned long *
 
 	ret = regmap_bulk_read(chip->regmap, regaddr, value, NBANK(chip));
 	if (ret < 0) {
-		dev_err(&chip->client->dev, "failed reading register\n");
+		dev_err(&chip->client->dev, "failed reading register: %d\n", ret);
 		return ret;
 	}
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] gpio: pca953x: Print the error code on read/write failures
  2024-08-21 11:42 [PATCH] gpio: pca953x: Print the error code on read/write failures Fabio Estevam
@ 2024-08-21 12:11 ` Bartosz Golaszewski
  2024-08-21 12:16   ` Fabio Estevam
  2024-08-21 12:29 ` Bartosz Golaszewski
  2024-08-23 15:25 ` Andy Shevchenko
  2 siblings, 1 reply; 6+ messages in thread
From: Bartosz Golaszewski @ 2024-08-21 12:11 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: linus.walleij, linux-gpio, linux, Fabio Estevam

On Wed, Aug 21, 2024 at 1:42 PM Fabio Estevam <festevam@gmail.com> wrote:
>
> From: Fabio Estevam <festevam@denx.de>
>
> Print the error code in the pca953x_write_regs() and pca953x_read_regs()
> functions to help debugging.
>
> Suggested-by: Russell King (Oracle) <linux@armlinux.org.uk>
> Signed-off-by: Fabio Estevam <festevam@denx.de>
> ---
>  drivers/gpio/gpio-pca953x.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index 8baf3edd5274..3f2d33ee20cc 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -498,7 +498,7 @@ static int pca953x_write_regs(struct pca953x_chip *chip, int reg, unsigned long
>
>         ret = regmap_bulk_write(chip->regmap, regaddr, value, NBANK(chip));
>         if (ret < 0) {
> -               dev_err(&chip->client->dev, "failed writing register\n");
> +               dev_err(&chip->client->dev, "failed writing register: %d\n", ret);
>                 return ret;
>         }
>
> @@ -513,7 +513,7 @@ static int pca953x_read_regs(struct pca953x_chip *chip, int reg, unsigned long *
>
>         ret = regmap_bulk_read(chip->regmap, regaddr, value, NBANK(chip));
>         if (ret < 0) {
> -               dev_err(&chip->client->dev, "failed reading register\n");
> +               dev_err(&chip->client->dev, "failed reading register: %d\n", ret);
>                 return ret;
>         }
>
> --
> 2.34.1
>

How about using dev_err_probe() instead?

Bart

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gpio: pca953x: Print the error code on read/write failures
  2024-08-21 12:11 ` Bartosz Golaszewski
@ 2024-08-21 12:16   ` Fabio Estevam
  2024-08-21 12:28     ` Bartosz Golaszewski
  0 siblings, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2024-08-21 12:16 UTC (permalink / raw)
  To: Bartosz Golaszewski; +Cc: linus.walleij, linux-gpio, linux, Fabio Estevam

Hi Bartosz,

On Wed, Aug 21, 2024 at 9:11 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> How about using dev_err_probe() instead?

pca953x_write_regs() and pca953x_read_regs() are not called from
probe(), so we should use dev_err().

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gpio: pca953x: Print the error code on read/write failures
  2024-08-21 12:16   ` Fabio Estevam
@ 2024-08-21 12:28     ` Bartosz Golaszewski
  0 siblings, 0 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2024-08-21 12:28 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: linus.walleij, linux-gpio, linux, Fabio Estevam

On Wed, Aug 21, 2024 at 2:17 PM Fabio Estevam <festevam@gmail.com> wrote:
>
> Hi Bartosz,
>
> On Wed, Aug 21, 2024 at 9:11 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> > How about using dev_err_probe() instead?
>
> pca953x_write_regs() and pca953x_read_regs() are not called from
> probe(), so we should use dev_err().

Right, sorry for the noise.

Bart

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gpio: pca953x: Print the error code on read/write failures
  2024-08-21 11:42 [PATCH] gpio: pca953x: Print the error code on read/write failures Fabio Estevam
  2024-08-21 12:11 ` Bartosz Golaszewski
@ 2024-08-21 12:29 ` Bartosz Golaszewski
  2024-08-23 15:25 ` Andy Shevchenko
  2 siblings, 0 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2024-08-21 12:29 UTC (permalink / raw)
  To: brgl, Fabio Estevam
  Cc: Bartosz Golaszewski, linus.walleij, linux-gpio, linux,
	Fabio Estevam

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


On Wed, 21 Aug 2024 08:42:02 -0300, Fabio Estevam wrote:
> Print the error code in the pca953x_write_regs() and pca953x_read_regs()
> functions to help debugging.
> 
> 

Applied, thanks!

[1/1] gpio: pca953x: Print the error code on read/write failures
      commit: b41a9bf2c64eea119bb6cbef420345f547b9a677

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gpio: pca953x: Print the error code on read/write failures
  2024-08-21 11:42 [PATCH] gpio: pca953x: Print the error code on read/write failures Fabio Estevam
  2024-08-21 12:11 ` Bartosz Golaszewski
  2024-08-21 12:29 ` Bartosz Golaszewski
@ 2024-08-23 15:25 ` Andy Shevchenko
  2 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-08-23 15:25 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: brgl, linus.walleij, linux-gpio, linux, Fabio Estevam

On Wed, Aug 21, 2024 at 08:42:02AM -0300, Fabio Estevam wrote:

> Print the error code in the pca953x_write_regs() and pca953x_read_regs()
> functions to help debugging.

May be, or may be better to use (implement?) proper filters for regmap
tracepoints? In that case we may drop all these noisy messages and leave
only the fatal ones.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-08-23 15:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-21 11:42 [PATCH] gpio: pca953x: Print the error code on read/write failures Fabio Estevam
2024-08-21 12:11 ` Bartosz Golaszewski
2024-08-21 12:16   ` Fabio Estevam
2024-08-21 12:28     ` Bartosz Golaszewski
2024-08-21 12:29 ` Bartosz Golaszewski
2024-08-23 15:25 ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox