diff mbox series

[2/6] input: qt1050: use device_for_each_child_node_scoped()

Message ID 20240412-input_device_for_each_child_node_scoped-v1-2-dbad1bc7ea84@gmail.com
State New
Headers show
Series input: use device_for_each_child_node_scoped() | expand

Commit Message

Javier Carrasco April 12, 2024, 8:57 p.m. UTC
Switch to the _scoped() version introduced in commit 365130fd47af
("device property: Introduce device_for_each_child_node_scoped()")
to remove the need for manual calling of fwnode_handle_put() in the
paths where the code exits the loop early.

In this case the err label was no longer necessary and EINVAL is
returned directly.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
 drivers/input/keyboard/qt1050.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Dmitry Torokhov July 16, 2024, 1:03 a.m. UTC | #1
Hi Javier,

On Fri, Apr 12, 2024 at 10:57:31PM +0200, Javier Carrasco wrote:
> Switch to the _scoped() version introduced in commit 365130fd47af
> ("device property: Introduce device_for_each_child_node_scoped()")
> to remove the need for manual calling of fwnode_handle_put() in the
> paths where the code exits the loop early.
> 
> In this case the err label was no longer necessary and EINVAL is
> returned directly.
> 
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> ---
>  drivers/input/keyboard/qt1050.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/input/keyboard/qt1050.c b/drivers/input/keyboard/qt1050.c
> index b51dfcd76038..6ac2b9dbdb85 100644
> --- a/drivers/input/keyboard/qt1050.c
> +++ b/drivers/input/keyboard/qt1050.c
> @@ -355,21 +355,21 @@ static int qt1050_parse_fw(struct qt1050_priv *ts)
>  		if (fwnode_property_read_u32(child, "linux,code",
>  					     &button.keycode)) {
>  			dev_err(dev, "Button without keycode\n");
> -			goto err;
> +			return -EINVAL;

It looks like the chunk actually switching to
device_for_each_child_node_scoped() is missing from the patch. I added
it and applied, thank you.

Thanks.
Javier Carrasco July 16, 2024, 4:17 a.m. UTC | #2
On 16/07/2024 03:03, Dmitry Torokhov wrote:
> Hi Javier,
> 
> On Fri, Apr 12, 2024 at 10:57:31PM +0200, Javier Carrasco wrote:
>> Switch to the _scoped() version introduced in commit 365130fd47af
>> ("device property: Introduce device_for_each_child_node_scoped()")
>> to remove the need for manual calling of fwnode_handle_put() in the
>> paths where the code exits the loop early.
>>
>> In this case the err label was no longer necessary and EINVAL is
>> returned directly.
>>
>> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
>> ---
>>  drivers/input/keyboard/qt1050.c | 12 ++++--------
>>  1 file changed, 4 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/input/keyboard/qt1050.c b/drivers/input/keyboard/qt1050.c
>> index b51dfcd76038..6ac2b9dbdb85 100644
>> --- a/drivers/input/keyboard/qt1050.c
>> +++ b/drivers/input/keyboard/qt1050.c
>> @@ -355,21 +355,21 @@ static int qt1050_parse_fw(struct qt1050_priv *ts)
>>  		if (fwnode_property_read_u32(child, "linux,code",
>>  					     &button.keycode)) {
>>  			dev_err(dev, "Button without keycode\n");
>> -			goto err;
>> +			return -EINVAL;
> 
> It looks like the chunk actually switching to
> device_for_each_child_node_scoped() is missing from the patch. I added
> it and applied, thank you.
> 
> Thanks.
> 


Thank your for adding the missing bit. Did you remove the child variable
at the beginning of the function as well? It will be unused otherwise
(child is defined in the macro itself).

Thanks again and best regards,
Javier Carrasco
Dmitry Torokhov July 16, 2024, 4:23 a.m. UTC | #3
On Tue, Jul 16, 2024 at 06:17:35AM +0200, Javier Carrasco wrote:
> On 16/07/2024 03:03, Dmitry Torokhov wrote:
> > Hi Javier,
> > 
> > On Fri, Apr 12, 2024 at 10:57:31PM +0200, Javier Carrasco wrote:
> >> Switch to the _scoped() version introduced in commit 365130fd47af
> >> ("device property: Introduce device_for_each_child_node_scoped()")
> >> to remove the need for manual calling of fwnode_handle_put() in the
> >> paths where the code exits the loop early.
> >>
> >> In this case the err label was no longer necessary and EINVAL is
> >> returned directly.
> >>
> >> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> >> ---
> >>  drivers/input/keyboard/qt1050.c | 12 ++++--------
> >>  1 file changed, 4 insertions(+), 8 deletions(-)
> >>
> >> diff --git a/drivers/input/keyboard/qt1050.c b/drivers/input/keyboard/qt1050.c
> >> index b51dfcd76038..6ac2b9dbdb85 100644
> >> --- a/drivers/input/keyboard/qt1050.c
> >> +++ b/drivers/input/keyboard/qt1050.c
> >> @@ -355,21 +355,21 @@ static int qt1050_parse_fw(struct qt1050_priv *ts)
> >>  		if (fwnode_property_read_u32(child, "linux,code",
> >>  					     &button.keycode)) {
> >>  			dev_err(dev, "Button without keycode\n");
> >> -			goto err;
> >> +			return -EINVAL;
> > 
> > It looks like the chunk actually switching to
> > device_for_each_child_node_scoped() is missing from the patch. I added
> > it and applied, thank you.
> > 
> > Thanks.
> > 
> 
> 
> Thank your for adding the missing bit. Did you remove the child variable
> at the beginning of the function as well? It will be unused otherwise
> (child is defined in the macro itself).

Yep, I did.

Thanks.
diff mbox series

Patch

diff --git a/drivers/input/keyboard/qt1050.c b/drivers/input/keyboard/qt1050.c
index b51dfcd76038..6ac2b9dbdb85 100644
--- a/drivers/input/keyboard/qt1050.c
+++ b/drivers/input/keyboard/qt1050.c
@@ -355,21 +355,21 @@  static int qt1050_parse_fw(struct qt1050_priv *ts)
 		if (fwnode_property_read_u32(child, "linux,code",
 					     &button.keycode)) {
 			dev_err(dev, "Button without keycode\n");
-			goto err;
+			return -EINVAL;
 		}
 		if (button.keycode >= KEY_MAX) {
 			dev_err(dev, "Invalid keycode 0x%x\n",
 				button.keycode);
-			goto err;
+			return -EINVAL;
 		}
 
 		if (fwnode_property_read_u32(child, "reg",
 					     &button.num)) {
 			dev_err(dev, "Button without pad number\n");
-			goto err;
+			return -EINVAL;
 		}
 		if (button.num < 0 || button.num > QT1050_MAX_KEYS - 1)
-			goto err;
+			return -EINVAL;
 
 		ts->reg_keys |= BIT(button.num);
 
@@ -419,10 +419,6 @@  static int qt1050_parse_fw(struct qt1050_priv *ts)
 	}
 
 	return 0;
-
-err:
-	fwnode_handle_put(child);
-	return -EINVAL;
 }
 
 static int qt1050_probe(struct i2c_client *client)