All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Shyti <andi.shyti@kernel.org>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Chen-Yu Tsai <wens@csie.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	Wolfram Sang <wsa@kernel.org>,
	linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] i2c: sun6i-p2wi: Fix an error message in probe()
Date: Tue, 27 Jun 2023 15:33:22 +0200	[thread overview]
Message-ID: <20230627133322.szotkthwsfwgkdby@intel.intel> (raw)
In-Reply-To: <7c6db53c-427d-4ba5-80b7-a069ab9322a0@kadam.mountain>

Hi Dan,

On Tue, Jun 27, 2023 at 03:08:53PM +0300, Dan Carpenter wrote:
> On Tue, Jun 27, 2023 at 01:59:20PM +0200, Andi Shyti wrote:
> > Hi Dan,
> > 
> > On Tue, Jun 27, 2023 at 10:12:36AM +0300, Dan Carpenter wrote:
> > > The "ret" variable is uninitialized.  It was the "p2wi->rstc" variable
> > > that was intended.  We can also use the %pe string format to print the
> > > error code name instead of just the number.
> > > 
> > > Fixes: 75ff8a340a81 ("i2c: sun6i-p2wi: Use devm_clk_get_enabled()")
> > > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > > ---
> > >  drivers/i2c/busses/i2c-sun6i-p2wi.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/i2c/busses/i2c-sun6i-p2wi.c b/drivers/i2c/busses/i2c-sun6i-p2wi.c
> > > index ad8270cdbd3e..fa6020dced59 100644
> > > --- a/drivers/i2c/busses/i2c-sun6i-p2wi.c
> > > +++ b/drivers/i2c/busses/i2c-sun6i-p2wi.c
> > > @@ -250,7 +250,8 @@ static int p2wi_probe(struct platform_device *pdev)
> > >  
> > >  	p2wi->rstc = devm_reset_control_get_exclusive(dev, NULL);
> > >  	if (IS_ERR(p2wi->rstc)) {
> > > -		dev_err(dev, "failed to retrieve reset controller: %d\n", ret);
> > > +		dev_err(dev, "failed to retrieve reset controller: %pe\n",
> > > +			p2wi->rstc);
> > 
> > Yes, good catch! Thanks! But I think we want to print the error
> > value here, so I think it should be:
> > 
> > -		dev_err(dev, "failed to retrieve reset controller: %d\n", ret);
> > +		dev_err(dev, "failed to retrieve reset controller: %d\n",
> > +			PTR_ERR(p2wi->rstc));
> > 
> 
> The %pe which I changed it to is a cool new thing that prints:
> 
> 	failed to retrieve reset controller: -EINVAL\n

oh... that's right! Sorry, I didn't know about it! Then,
definitely:

Reviewed-by: Andi Shyti <andi.shyti@kernel.org> 

> We should create a similar %e printk format that works for ints instead
> of error pointers.  But instead of that you have people who cast error
> codes to pointers just to get the %pe functionality.  And other people
> who make suggestions (this is the catagory that I'm in) but are too lazy
> to do the actual work.

Ahaha... that's right! It's indeed a nice feature to have. Let me
see if I manage to scratch a few hours out of my time.

Andi

WARNING: multiple messages have this Message-ID (diff)
From: Andi Shyti <andi.shyti@kernel.org>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Chen-Yu Tsai <wens@csie.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	Wolfram Sang <wsa@kernel.org>,
	linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] i2c: sun6i-p2wi: Fix an error message in probe()
Date: Tue, 27 Jun 2023 15:33:22 +0200	[thread overview]
Message-ID: <20230627133322.szotkthwsfwgkdby@intel.intel> (raw)
In-Reply-To: <7c6db53c-427d-4ba5-80b7-a069ab9322a0@kadam.mountain>

Hi Dan,

On Tue, Jun 27, 2023 at 03:08:53PM +0300, Dan Carpenter wrote:
> On Tue, Jun 27, 2023 at 01:59:20PM +0200, Andi Shyti wrote:
> > Hi Dan,
> > 
> > On Tue, Jun 27, 2023 at 10:12:36AM +0300, Dan Carpenter wrote:
> > > The "ret" variable is uninitialized.  It was the "p2wi->rstc" variable
> > > that was intended.  We can also use the %pe string format to print the
> > > error code name instead of just the number.
> > > 
> > > Fixes: 75ff8a340a81 ("i2c: sun6i-p2wi: Use devm_clk_get_enabled()")
> > > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > > ---
> > >  drivers/i2c/busses/i2c-sun6i-p2wi.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/i2c/busses/i2c-sun6i-p2wi.c b/drivers/i2c/busses/i2c-sun6i-p2wi.c
> > > index ad8270cdbd3e..fa6020dced59 100644
> > > --- a/drivers/i2c/busses/i2c-sun6i-p2wi.c
> > > +++ b/drivers/i2c/busses/i2c-sun6i-p2wi.c
> > > @@ -250,7 +250,8 @@ static int p2wi_probe(struct platform_device *pdev)
> > >  
> > >  	p2wi->rstc = devm_reset_control_get_exclusive(dev, NULL);
> > >  	if (IS_ERR(p2wi->rstc)) {
> > > -		dev_err(dev, "failed to retrieve reset controller: %d\n", ret);
> > > +		dev_err(dev, "failed to retrieve reset controller: %pe\n",
> > > +			p2wi->rstc);
> > 
> > Yes, good catch! Thanks! But I think we want to print the error
> > value here, so I think it should be:
> > 
> > -		dev_err(dev, "failed to retrieve reset controller: %d\n", ret);
> > +		dev_err(dev, "failed to retrieve reset controller: %d\n",
> > +			PTR_ERR(p2wi->rstc));
> > 
> 
> The %pe which I changed it to is a cool new thing that prints:
> 
> 	failed to retrieve reset controller: -EINVAL\n

oh... that's right! Sorry, I didn't know about it! Then,
definitely:

Reviewed-by: Andi Shyti <andi.shyti@kernel.org> 

> We should create a similar %e printk format that works for ints instead
> of error pointers.  But instead of that you have people who cast error
> codes to pointers just to get the %pe functionality.  And other people
> who make suggestions (this is the catagory that I'm in) but are too lazy
> to do the actual work.

Ahaha... that's right! It's indeed a nice feature to have. Let me
see if I manage to scratch a few hours out of my time.

Andi

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-06-27 13:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-27  7:12 [PATCH] i2c: sun6i-p2wi: Fix an error message in probe() Dan Carpenter
2023-06-27  7:12 ` Dan Carpenter
2023-06-27 11:59 ` Andi Shyti
2023-06-27 11:59   ` Andi Shyti
2023-06-27 12:08   ` Dan Carpenter
2023-06-27 12:08     ` Dan Carpenter
2023-06-27 13:33     ` Andi Shyti [this message]
2023-06-27 13:33       ` Andi Shyti
2023-06-30 19:58     ` Christophe JAILLET
2023-06-30 19:58       ` Christophe JAILLET
2023-07-01  9:42       ` Dan Carpenter
2023-07-01  9:42         ` Dan Carpenter
2023-08-14 15:53 ` Wolfram Sang
2023-08-14 15:53   ` Wolfram Sang

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=20230627133322.szotkthwsfwgkdby@intel.intel \
    --to=andi.shyti@kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=samuel@sholland.org \
    --cc=wens@csie.org \
    --cc=wsa@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.