Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: qt1050 - use device_for_each_child_node_scoped()

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>
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>

authored by

Javier Carrasco and committed by
Dmitry Torokhov
4f210af5 4256d472

+5 -10
+5 -10
drivers/input/keyboard/qt1050.c
··· 346 346 static int qt1050_parse_fw(struct qt1050_priv *ts) 347 347 { 348 348 struct device *dev = &ts->client->dev; 349 - struct fwnode_handle *child; 350 349 int nbuttons; 351 350 352 351 nbuttons = device_get_child_node_count(dev); 353 352 if (nbuttons == 0 || nbuttons > QT1050_MAX_KEYS) 354 353 return -ENODEV; 355 354 356 - device_for_each_child_node(dev, child) { 355 + device_for_each_child_node_scoped(dev, child) { 357 356 struct qt1050_key button; 358 357 359 358 /* Required properties */ 360 359 if (fwnode_property_read_u32(child, "linux,code", 361 360 &button.keycode)) { 362 361 dev_err(dev, "Button without keycode\n"); 363 - goto err; 362 + return -EINVAL; 364 363 } 365 364 if (button.keycode >= KEY_MAX) { 366 365 dev_err(dev, "Invalid keycode 0x%x\n", 367 366 button.keycode); 368 - goto err; 367 + return -EINVAL; 369 368 } 370 369 371 370 if (fwnode_property_read_u32(child, "reg", 372 371 &button.num)) { 373 372 dev_err(dev, "Button without pad number\n"); 374 - goto err; 373 + return -EINVAL; 375 374 } 376 375 if (button.num < 0 || button.num > QT1050_MAX_KEYS - 1) 377 - goto err; 376 + return -EINVAL; 378 377 379 378 ts->reg_keys |= BIT(button.num); 380 379 ··· 423 424 } 424 425 425 426 return 0; 426 - 427 - err: 428 - fwnode_handle_put(child); 429 - return -EINVAL; 430 427 } 431 428 432 429 static int qt1050_probe(struct i2c_client *client)