diff mbox series

gpio: pca953x: Print the error code on read/write failures

Message ID 20240821114202.2072220-1-festevam@gmail.com
State New
Headers show
Series gpio: pca953x: Print the error code on read/write failures | expand

Commit Message

Fabio Estevam Aug. 21, 2024, 11:42 a.m. UTC
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(-)

Comments

Bartosz Golaszewski Aug. 21, 2024, 12:11 p.m. UTC | #1
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
Fabio Estevam Aug. 21, 2024, 12:16 p.m. UTC | #2
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().
Bartosz Golaszewski Aug. 21, 2024, 12:28 p.m. UTC | #3
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
Andy Shevchenko Aug. 23, 2024, 3:25 p.m. UTC | #4
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.
diff mbox series

Patch

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;
 	}