Commit 4f210af5 authored by Javier Carrasco's avatar Javier Carrasco Committed by Dmitry Torokhov

Input: qt1050 - use device_for_each_child_node_scoped()

Switch to the _scoped() version introduced in commit 365130fd
("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: default avatarJavier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240412-input_device_for_each_child_node_scoped-v1-2-dbad1bc7ea84@gmail.comSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 4256d472
...@@ -346,35 +346,34 @@ static int qt1050_apply_fw_data(struct qt1050_priv *ts) ...@@ -346,35 +346,34 @@ static int qt1050_apply_fw_data(struct qt1050_priv *ts)
static int qt1050_parse_fw(struct qt1050_priv *ts) static int qt1050_parse_fw(struct qt1050_priv *ts)
{ {
struct device *dev = &ts->client->dev; struct device *dev = &ts->client->dev;
struct fwnode_handle *child;
int nbuttons; int nbuttons;
nbuttons = device_get_child_node_count(dev); nbuttons = device_get_child_node_count(dev);
if (nbuttons == 0 || nbuttons > QT1050_MAX_KEYS) if (nbuttons == 0 || nbuttons > QT1050_MAX_KEYS)
return -ENODEV; return -ENODEV;
device_for_each_child_node(dev, child) { device_for_each_child_node_scoped(dev, child) {
struct qt1050_key button; struct qt1050_key button;
/* Required properties */ /* Required properties */
if (fwnode_property_read_u32(child, "linux,code", if (fwnode_property_read_u32(child, "linux,code",
&button.keycode)) { &button.keycode)) {
dev_err(dev, "Button without keycode\n"); dev_err(dev, "Button without keycode\n");
goto err; return -EINVAL;
} }
if (button.keycode >= KEY_MAX) { if (button.keycode >= KEY_MAX) {
dev_err(dev, "Invalid keycode 0x%x\n", dev_err(dev, "Invalid keycode 0x%x\n",
button.keycode); button.keycode);
goto err; return -EINVAL;
} }
if (fwnode_property_read_u32(child, "reg", if (fwnode_property_read_u32(child, "reg",
&button.num)) { &button.num)) {
dev_err(dev, "Button without pad number\n"); dev_err(dev, "Button without pad number\n");
goto err; return -EINVAL;
} }
if (button.num < 0 || button.num > QT1050_MAX_KEYS - 1) if (button.num < 0 || button.num > QT1050_MAX_KEYS - 1)
goto err; return -EINVAL;
ts->reg_keys |= BIT(button.num); ts->reg_keys |= BIT(button.num);
...@@ -424,10 +423,6 @@ static int qt1050_parse_fw(struct qt1050_priv *ts) ...@@ -424,10 +423,6 @@ static int qt1050_parse_fw(struct qt1050_priv *ts)
} }
return 0; return 0;
err:
fwnode_handle_put(child);
return -EINVAL;
} }
static int qt1050_probe(struct i2c_client *client) static int qt1050_probe(struct i2c_client *client)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment