Skip to content

Commit 4f210af

Browse files
javiercarrascocruzdtor
authored andcommitted
Input: qt1050 - use device_for_each_child_node_scoped()
Switch to the _scoped() version introduced in commit 365130f ("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> Link: https://lore.kernel.org/r/20240412-input_device_for_each_child_node_scoped-v1-2-dbad1bc7ea84@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 4256d47 commit 4f210af

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

drivers/input/keyboard/qt1050.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -346,35 +346,34 @@ static int qt1050_apply_fw_data(struct qt1050_priv *ts)
346346
static int qt1050_parse_fw(struct qt1050_priv *ts)
347347
{
348348
struct device *dev = &ts->client->dev;
349-
struct fwnode_handle *child;
350349
int nbuttons;
351350

352351
nbuttons = device_get_child_node_count(dev);
353352
if (nbuttons == 0 || nbuttons > QT1050_MAX_KEYS)
354353
return -ENODEV;
355354

356-
device_for_each_child_node(dev, child) {
355+
device_for_each_child_node_scoped(dev, child) {
357356
struct qt1050_key button;
358357

359358
/* Required properties */
360359
if (fwnode_property_read_u32(child, "linux,code",
361360
&button.keycode)) {
362361
dev_err(dev, "Button without keycode\n");
363-
goto err;
362+
return -EINVAL;
364363
}
365364
if (button.keycode >= KEY_MAX) {
366365
dev_err(dev, "Invalid keycode 0x%x\n",
367366
button.keycode);
368-
goto err;
367+
return -EINVAL;
369368
}
370369

371370
if (fwnode_property_read_u32(child, "reg",
372371
&button.num)) {
373372
dev_err(dev, "Button without pad number\n");
374-
goto err;
373+
return -EINVAL;
375374
}
376375
if (button.num < 0 || button.num > QT1050_MAX_KEYS - 1)
377-
goto err;
376+
return -EINVAL;
378377

379378
ts->reg_keys |= BIT(button.num);
380379

@@ -424,10 +423,6 @@ static int qt1050_parse_fw(struct qt1050_priv *ts)
424423
}
425424

426425
return 0;
427-
428-
err:
429-
fwnode_handle_put(child);
430-
return -EINVAL;
431426
}
432427

433428
static int qt1050_probe(struct i2c_client *client)

0 commit comments

Comments
 (0)