diff mbox series

remoteproc: k3-r5: Fix an error message

Message ID d6e29d903b48957bf59c67229d54b0fc215e31ae.1620333870.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State Accepted
Commit 34c4da6d5dfba48f49f891ebd75bb55999f0c538
Headers show
Series remoteproc: k3-r5: Fix an error message | expand

Commit Message

Christophe JAILLET May 6, 2021, 8:46 p.m. UTC
'ret' is known to be 0 here.
Reorder the code so that the expected error code is printed.

Fixes: 6dedbd1d5443 ("remoteproc: k3-r5: Add a remoteproc driver for R5F subsystem")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/remoteproc/ti_k3_r5_remoteproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Suman Anna May 6, 2021, 11:51 p.m. UTC | #1
On 5/6/21 3:46 PM, Christophe JAILLET wrote:
> 'ret' is known to be 0 here.
> Reorder the code so that the expected error code is printed.
> 
> Fixes: 6dedbd1d5443 ("remoteproc: k3-r5: Add a remoteproc driver for R5F subsystem")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Thanks for catching the issue.

Acked-by: Suman Anna <s-anna@ti.com>

regards
Suman

> ---
>  drivers/remoteproc/ti_k3_r5_remoteproc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c
> index 5cf8d030a1f0..4104e4846dbf 100644
> --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c
> +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c
> @@ -1272,9 +1272,9 @@ static int k3_r5_core_of_init(struct platform_device *pdev)
>  
>  	core->tsp = k3_r5_core_of_get_tsp(dev, core->ti_sci);
>  	if (IS_ERR(core->tsp)) {
> +		ret = PTR_ERR(core->tsp);
>  		dev_err(dev, "failed to construct ti-sci proc control, ret = %d\n",
>  			ret);
> -		ret = PTR_ERR(core->tsp);
>  		goto err;
>  	}
>  
>
Dan Carpenter May 7, 2021, 5:26 a.m. UTC | #2
On Thu, May 06, 2021 at 10:46:01PM +0200, Christophe JAILLET wrote:
> 'ret' is known to be 0 here.
> Reorder the code so that the expected error code is printed.
> 
> Fixes: 6dedbd1d5443 ("remoteproc: k3-r5: Add a remoteproc driver for R5F subsystem")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/remoteproc/ti_k3_r5_remoteproc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c
> index 5cf8d030a1f0..4104e4846dbf 100644
> --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c
> +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c
> @@ -1272,9 +1272,9 @@ static int k3_r5_core_of_init(struct platform_device *pdev)
>  
>  	core->tsp = k3_r5_core_of_get_tsp(dev, core->ti_sci);
>  	if (IS_ERR(core->tsp)) {
> +		ret = PTR_ERR(core->tsp);
>  		dev_err(dev, "failed to construct ti-sci proc control, ret = %d\n",
>  			ret);

I recently learned about the %pe format specifier, which prints "-ENOMEM"
instead of -12.

		dev_err(dev, "failed to construct ti-sci proc control, ret = %pe\n",
			core->tsp);
regards,
dan carpenter
Christophe JAILLET May 7, 2021, 5:58 a.m. UTC | #3
Le 07/05/2021 à 07:26, Dan Carpenter a écrit :
> On Thu, May 06, 2021 at 10:46:01PM +0200, Christophe JAILLET wrote:
>> 'ret' is known to be 0 here.
>> Reorder the code so that the expected error code is printed.
>>
>> Fixes: 6dedbd1d5443 ("remoteproc: k3-r5: Add a remoteproc driver for R5F subsystem")
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>>   drivers/remoteproc/ti_k3_r5_remoteproc.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c
>> index 5cf8d030a1f0..4104e4846dbf 100644
>> --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c
>> +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c
>> @@ -1272,9 +1272,9 @@ static int k3_r5_core_of_init(struct platform_device *pdev)
>>   
>>   	core->tsp = k3_r5_core_of_get_tsp(dev, core->ti_sci);
>>   	if (IS_ERR(core->tsp)) {
>> +		ret = PTR_ERR(core->tsp);
>>   		dev_err(dev, "failed to construct ti-sci proc control, ret = %d\n",
>>   			ret);
> 
> I recently learned about the %pe format specifier, which prints "-ENOMEM"
> instead of -12.

Hi Dan,

I see that we are reading the same ML  :)


Well, I'm a bit puzzled by it.
On one hand, it is more user-friendly. On the other hand it is not 
widely used up to now.

So is it better to keep the legacy way of reporting error code?

Do you know if there is preferred way?

Using it after a IS_ERR is straightforward, but should we also do things 
like (kmalloc usually don't need error message, just given as an example):
     x = kmalloc(...);
     if (!x)
         dev_err(dev, "Memory allocation failure (%pe)\n",
                 ERR_PTR(-ENOMEM));

When changing a message and make use of %pe, should all the messages in 
the neighborhood be changed as well to keep some kind of consistancy?

CJ

> 
> 		dev_err(dev, "failed to construct ti-sci proc control, ret = %pe\n",
> 			core->tsp);
> regards,
> dan carpenter
> 
> 
>
Dan Carpenter May 7, 2021, 6:59 a.m. UTC | #4
On Fri, May 07, 2021 at 07:58:39AM +0200, Christophe JAILLET wrote:
> Le 07/05/2021 à 07:26, Dan Carpenter a écrit :
> > On Thu, May 06, 2021 at 10:46:01PM +0200, Christophe JAILLET wrote:
> > > 'ret' is known to be 0 here.
> > > Reorder the code so that the expected error code is printed.
> > > 
> > > Fixes: 6dedbd1d5443 ("remoteproc: k3-r5: Add a remoteproc driver for R5F subsystem")
> > > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> > > ---
> > >   drivers/remoteproc/ti_k3_r5_remoteproc.c | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c
> > > index 5cf8d030a1f0..4104e4846dbf 100644
> > > --- a/drivers/remoteproc/ti_k3_r5_remoteproc.c
> > > +++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c
> > > @@ -1272,9 +1272,9 @@ static int k3_r5_core_of_init(struct platform_device *pdev)
> > >   	core->tsp = k3_r5_core_of_get_tsp(dev, core->ti_sci);
> > >   	if (IS_ERR(core->tsp)) {
> > > +		ret = PTR_ERR(core->tsp);
> > >   		dev_err(dev, "failed to construct ti-sci proc control, ret = %d\n",
> > >   			ret);
> > 
> > I recently learned about the %pe format specifier, which prints "-ENOMEM"
> > instead of -12.
> 
> Hi Dan,
> 
> I see that we are reading the same ML  :)
> 
> 
> Well, I'm a bit puzzled by it.
> On one hand, it is more user-friendly. On the other hand it is not widely
> used up to now.
> 
> So is it better to keep the legacy way of reporting error code?

It might make back porting things more complicated?  I'm surprised this
hasn't been backported further back to 5.4.

> 
> Do you know if there is preferred way?

It's new.  Soon it will be the prefered way.  You're right, of course,
that needs to introduce a %e which takes an int.  I have left this as an
exercise for the reader.  ;)  Eventually someone will work up the energy
required and do this work.

regards,
dan carpenter
patchwork-bot+linux-remoteproc@kernel.org May 31, 2021, 2:50 p.m. UTC | #5
Hello:

This patch was applied to andersson/remoteproc.git (refs/heads/for-next):

On Thu,  6 May 2021 22:46:01 +0200 you wrote:
> 'ret' is known to be 0 here.
> Reorder the code so that the expected error code is printed.
> 
> Fixes: 6dedbd1d5443 ("remoteproc: k3-r5: Add a remoteproc driver for R5F subsystem")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/remoteproc/ti_k3_r5_remoteproc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
  - remoteproc: k3-r5: Fix an error message
    https://git.kernel.org/andersson/remoteproc/c/34c4da6d5dfb

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/drivers/remoteproc/ti_k3_r5_remoteproc.c b/drivers/remoteproc/ti_k3_r5_remoteproc.c
index 5cf8d030a1f0..4104e4846dbf 100644
--- a/drivers/remoteproc/ti_k3_r5_remoteproc.c
+++ b/drivers/remoteproc/ti_k3_r5_remoteproc.c
@@ -1272,9 +1272,9 @@  static int k3_r5_core_of_init(struct platform_device *pdev)
 
 	core->tsp = k3_r5_core_of_get_tsp(dev, core->ti_sci);
 	if (IS_ERR(core->tsp)) {
+		ret = PTR_ERR(core->tsp);
 		dev_err(dev, "failed to construct ti-sci proc control, ret = %d\n",
 			ret);
-		ret = PTR_ERR(core->tsp);
 		goto err;
 	}