public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: i2c: ds90ub960: Delete duplicate source code in ub960_parse_dt_rxports()
@ 2024-03-01  7:46 Markus Elfring
  2024-03-01  8:46 ` Sakari Ailus
  0 siblings, 1 reply; 7+ messages in thread
From: Markus Elfring @ 2024-03-01  7:46 UTC (permalink / raw)
  To: linux-media, kernel-janitors, Andy Shevchenko,
	Mauro Carvalho Chehab, Sakari Ailus, Tomi Valkeinen
  Cc: LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Mar 2024 08:23:24 +0100

Avoid the specification of a duplicate fwnode_handle_put() call
in this function implementation.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/i2c/ds90ub960.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c
index ffe5f25f8647..eb708ed7b56e 100644
--- a/drivers/media/i2c/ds90ub960.c
+++ b/drivers/media/i2c/ds90ub960.c
@@ -3486,10 +3486,7 @@ static int ub960_parse_dt_rxports(struct ub960_data *priv)
 		}
 	}

-	fwnode_handle_put(links_fwnode);
-
-	return 0;
-
+	ret = 0;
 err_put_links:
 	fwnode_handle_put(links_fwnode);

--
2.44.0


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

* Re: [PATCH] media: i2c: ds90ub960: Delete duplicate source code in ub960_parse_dt_rxports()
  2024-03-01  7:46 [PATCH] media: i2c: ds90ub960: Delete duplicate source code in ub960_parse_dt_rxports() Markus Elfring
@ 2024-03-01  8:46 ` Sakari Ailus
  2024-03-01  8:49   ` Tomi Valkeinen
  0 siblings, 1 reply; 7+ messages in thread
From: Sakari Ailus @ 2024-03-01  8:46 UTC (permalink / raw)
  To: Markus Elfring
  Cc: linux-media, kernel-janitors, Andy Shevchenko,
	Mauro Carvalho Chehab, Tomi Valkeinen, LKML

Hi Markus,

On Fri, Mar 01, 2024 at 08:46:25AM +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 1 Mar 2024 08:23:24 +0100
> 
> Avoid the specification of a duplicate fwnode_handle_put() call
> in this function implementation.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/media/i2c/ds90ub960.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c
> index ffe5f25f8647..eb708ed7b56e 100644
> --- a/drivers/media/i2c/ds90ub960.c
> +++ b/drivers/media/i2c/ds90ub960.c
> @@ -3486,10 +3486,7 @@ static int ub960_parse_dt_rxports(struct ub960_data *priv)
>  		}
>  	}
> 
> -	fwnode_handle_put(links_fwnode);
> -
> -	return 0;
> -
> +	ret = 0;

I think it'd be nicer to initialise ret as zero, then you can just drop the
assignment above.

>  err_put_links:
>  	fwnode_handle_put(links_fwnode);
> 

-- 
Regards,

Sakari Ailus

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

* Re: [PATCH] media: i2c: ds90ub960: Delete duplicate source code in ub960_parse_dt_rxports()
  2024-03-01  8:46 ` Sakari Ailus
@ 2024-03-01  8:49   ` Tomi Valkeinen
  2024-03-01  9:02     ` Sakari Ailus
  0 siblings, 1 reply; 7+ messages in thread
From: Tomi Valkeinen @ 2024-03-01  8:49 UTC (permalink / raw)
  To: Sakari Ailus, Markus Elfring
  Cc: linux-media, kernel-janitors, Andy Shevchenko,
	Mauro Carvalho Chehab, LKML

Hi,

On 01/03/2024 10:46, Sakari Ailus wrote:
> Hi Markus,
> 
> On Fri, Mar 01, 2024 at 08:46:25AM +0100, Markus Elfring wrote:
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> Date: Fri, 1 Mar 2024 08:23:24 +0100
>>
>> Avoid the specification of a duplicate fwnode_handle_put() call
>> in this function implementation.
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>> ---
>>   drivers/media/i2c/ds90ub960.c | 5 +----
>>   1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c
>> index ffe5f25f8647..eb708ed7b56e 100644
>> --- a/drivers/media/i2c/ds90ub960.c
>> +++ b/drivers/media/i2c/ds90ub960.c
>> @@ -3486,10 +3486,7 @@ static int ub960_parse_dt_rxports(struct ub960_data *priv)
>>   		}
>>   	}
>>
>> -	fwnode_handle_put(links_fwnode);
>> -
>> -	return 0;
>> -
>> +	ret = 0;
> 
> I think it'd be nicer to initialise ret as zero, then you can just drop the
> assignment above.

I don't like successful execution entering error paths. That's why 
there's the return 0.

  Tomi

>>   err_put_links:
>>   	fwnode_handle_put(links_fwnode);
>>
> 


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

* Re: [PATCH] media: i2c: ds90ub960: Delete duplicate source code in ub960_parse_dt_rxports()
  2024-03-01  8:49   ` Tomi Valkeinen
@ 2024-03-01  9:02     ` Sakari Ailus
  2024-03-01 17:36       ` Andy Shevchenko
  0 siblings, 1 reply; 7+ messages in thread
From: Sakari Ailus @ 2024-03-01  9:02 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: Markus Elfring, linux-media, kernel-janitors, Andy Shevchenko,
	Mauro Carvalho Chehab, LKML

Huomenta,

On Fri, Mar 01, 2024 at 10:49:19AM +0200, Tomi Valkeinen wrote:
> Hi,
> 
> On 01/03/2024 10:46, Sakari Ailus wrote:
> > Hi Markus,
> > 
> > On Fri, Mar 01, 2024 at 08:46:25AM +0100, Markus Elfring wrote:
> > > From: Markus Elfring <elfring@users.sourceforge.net>
> > > Date: Fri, 1 Mar 2024 08:23:24 +0100
> > > 
> > > Avoid the specification of a duplicate fwnode_handle_put() call
> > > in this function implementation.
> > > 
> > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > > ---
> > >   drivers/media/i2c/ds90ub960.c | 5 +----
> > >   1 file changed, 1 insertion(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c
> > > index ffe5f25f8647..eb708ed7b56e 100644
> > > --- a/drivers/media/i2c/ds90ub960.c
> > > +++ b/drivers/media/i2c/ds90ub960.c
> > > @@ -3486,10 +3486,7 @@ static int ub960_parse_dt_rxports(struct ub960_data *priv)
> > >   		}
> > >   	}
> > > 
> > > -	fwnode_handle_put(links_fwnode);
> > > -
> > > -	return 0;
> > > -
> > > +	ret = 0;
> > 
> > I think it'd be nicer to initialise ret as zero, then you can just drop the
> > assignment above.
> 
> I don't like successful execution entering error paths. That's why there's
> the return 0.

It could be called a common cleanup path as what you really want to do here
is to put the fwnode handle, independently of whether there was an error.
I think the current code is of course fine, too.

Soon you can do

	struct fwnode_handle *links_fwnode __free(fwnode_handle);

and forget about putting it (but you must need putting it).

-- 
Terveisin,

Sakari Ailus

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

* Re: [PATCH] media: i2c: ds90ub960: Delete duplicate source code in ub960_parse_dt_rxports()
  2024-03-01  9:02     ` Sakari Ailus
@ 2024-03-01 17:36       ` Andy Shevchenko
  2024-03-02  9:13         ` Dan Carpenter
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2024-03-01 17:36 UTC (permalink / raw)
  To: Sakari Ailus
  Cc: Tomi Valkeinen, Markus Elfring, linux-media, kernel-janitors,
	Mauro Carvalho Chehab, LKML

On Fri, Mar 01, 2024 at 09:02:41AM +0000, Sakari Ailus wrote:
> On Fri, Mar 01, 2024 at 10:49:19AM +0200, Tomi Valkeinen wrote:
> > On 01/03/2024 10:46, Sakari Ailus wrote:
> > > On Fri, Mar 01, 2024 at 08:46:25AM +0100, Markus Elfring wrote:
> > > > From: Markus Elfring <elfring@users.sourceforge.net>
> > > > Date: Fri, 1 Mar 2024 08:23:24 +0100
> > > > 
> > > > Avoid the specification of a duplicate fwnode_handle_put() call
> > > > in this function implementation.
> > > > 
> > > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > > > ---
> > > >   drivers/media/i2c/ds90ub960.c | 5 +----
> > > >   1 file changed, 1 insertion(+), 4 deletions(-)
> > > > 
> > > > diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c
> > > > index ffe5f25f8647..eb708ed7b56e 100644
> > > > --- a/drivers/media/i2c/ds90ub960.c
> > > > +++ b/drivers/media/i2c/ds90ub960.c
> > > > @@ -3486,10 +3486,7 @@ static int ub960_parse_dt_rxports(struct ub960_data *priv)
> > > >   		}
> > > >   	}
> > > > 
> > > > -	fwnode_handle_put(links_fwnode);
> > > > -
> > > > -	return 0;
> > > > -
> > > > +	ret = 0;
> > > 
> > > I think it'd be nicer to initialise ret as zero, then you can just drop the
> > > assignment above.

I think tearing apart the assignment and its actual user is not good.

> > I don't like successful execution entering error paths. That's why there's
> > the return 0.
> 
> It could be called a common cleanup path as what you really want to do here
> is to put the fwnode handle, independently of whether there was an error.
> I think the current code is of course fine, too.
> 
> Soon you can do
> 
> 	struct fwnode_handle *links_fwnode __free(fwnode_handle);
> 
> and forget about putting it (but you must need putting it).

Let's wait for the Jonathan's patches to land (v6.9-rc1 I hope) and then
we may modify drivers if needed.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] media: i2c: ds90ub960: Delete duplicate source code in ub960_parse_dt_rxports()
  2024-03-01 17:36       ` Andy Shevchenko
@ 2024-03-02  9:13         ` Dan Carpenter
  2024-03-02 11:25           ` Markus Elfring
  0 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2024-03-02  9:13 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Sakari Ailus, Tomi Valkeinen, Markus Elfring, linux-media,
	kernel-janitors, Mauro Carvalho Chehab, LKML

On Fri, Mar 01, 2024 at 07:36:17PM +0200, Andy Shevchenko wrote:
> On Fri, Mar 01, 2024 at 09:02:41AM +0000, Sakari Ailus wrote:
> > On Fri, Mar 01, 2024 at 10:49:19AM +0200, Tomi Valkeinen wrote:
> > > On 01/03/2024 10:46, Sakari Ailus wrote:
> > > > On Fri, Mar 01, 2024 at 08:46:25AM +0100, Markus Elfring wrote:
> > > > > From: Markus Elfring <elfring@users.sourceforge.net>
> > > > > Date: Fri, 1 Mar 2024 08:23:24 +0100
> > > > > 
> > > > > Avoid the specification of a duplicate fwnode_handle_put() call
> > > > > in this function implementation.
> > > > > 
> > > > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > > > > ---
> > > > >   drivers/media/i2c/ds90ub960.c | 5 +----
> > > > >   1 file changed, 1 insertion(+), 4 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c
> > > > > index ffe5f25f8647..eb708ed7b56e 100644
> > > > > --- a/drivers/media/i2c/ds90ub960.c
> > > > > +++ b/drivers/media/i2c/ds90ub960.c
> > > > > @@ -3486,10 +3486,7 @@ static int ub960_parse_dt_rxports(struct ub960_data *priv)
> > > > >   		}
> > > > >   	}
> > > > > 
> > > > > -	fwnode_handle_put(links_fwnode);
> > > > > -
> > > > > -	return 0;
> > > > > -
> > > > > +	ret = 0;
> > > > 
> > > > I think it'd be nicer to initialise ret as zero, then you can just drop the
> > > > assignment above.
> 
> I think tearing apart the assignment and its actual user is not good.
> 
> > > I don't like successful execution entering error paths. That's why there's
> > > the return 0.
> > 
> > It could be called a common cleanup path as what you really want to do here
> > is to put the fwnode handle, independently of whether there was an error.
> > I think the current code is of course fine, too.
> > 
> > Soon you can do
> > 
> > 	struct fwnode_handle *links_fwnode __free(fwnode_handle);
> > 
> > and forget about putting it (but you must need putting it).
> 
> Let's wait for the Jonathan's patches to land (v6.9-rc1 I hope) and then
> we may modify drivers if needed.

The __free(fwnode_handle) stuff has already been merged.

We could do some additional work to make a _scoped() macro for
fwnode_handles but here it's function wide so we already have what we
need.

regards,
dan carpenter



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

* Re: [PATCH] media: i2c: ds90ub960: Delete duplicate source code in ub960_parse_dt_rxports()
  2024-03-02  9:13         ` Dan Carpenter
@ 2024-03-02 11:25           ` Markus Elfring
  0 siblings, 0 replies; 7+ messages in thread
From: Markus Elfring @ 2024-03-02 11:25 UTC (permalink / raw)
  To: Dan Carpenter, Andy Shevchenko, linux-media, kernel-janitors
  Cc: Sakari Ailus, Tomi Valkeinen, Mauro Carvalho Chehab, LKML

> The __free(fwnode_handle) stuff has already been merged.

Would you like to point a corresponding commit out?

Regards,
Markus

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

end of thread, other threads:[~2024-03-02 11:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-01  7:46 [PATCH] media: i2c: ds90ub960: Delete duplicate source code in ub960_parse_dt_rxports() Markus Elfring
2024-03-01  8:46 ` Sakari Ailus
2024-03-01  8:49   ` Tomi Valkeinen
2024-03-01  9:02     ` Sakari Ailus
2024-03-01 17:36       ` Andy Shevchenko
2024-03-02  9:13         ` Dan Carpenter
2024-03-02 11:25           ` Markus Elfring

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