mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
Input: sun4i-lradc-keys - switch to for_each_child_of_node_scoped
Use the scoped variant of the macro to simplify the code and error handling. This makes the error handling more robust by ensuring that the child node is always freed. Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Reviewed-by: Andre Przywara <andre.przywara@arm.com> Link: https://lore.kernel.org/r/20241010-input_automate_of_node_put-v1-3-ebc62138fbf8@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
2e6980c169
commit
0ec6f58b63
|
|
@ -202,7 +202,7 @@ static void sun4i_lradc_close(struct input_dev *dev)
|
|||
static int sun4i_lradc_load_dt_keymap(struct device *dev,
|
||||
struct sun4i_lradc_data *lradc)
|
||||
{
|
||||
struct device_node *np, *pp;
|
||||
struct device_node *np;
|
||||
int i;
|
||||
int error;
|
||||
|
||||
|
|
@ -223,28 +223,25 @@ static int sun4i_lradc_load_dt_keymap(struct device *dev,
|
|||
return -ENOMEM;
|
||||
|
||||
i = 0;
|
||||
for_each_child_of_node(np, pp) {
|
||||
for_each_child_of_node_scoped(np, pp) {
|
||||
struct sun4i_lradc_keymap *map = &lradc->chan0_map[i];
|
||||
u32 channel;
|
||||
|
||||
error = of_property_read_u32(pp, "channel", &channel);
|
||||
if (error || channel != 0) {
|
||||
dev_err(dev, "%pOFn: Inval channel prop\n", pp);
|
||||
of_node_put(pp);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
error = of_property_read_u32(pp, "voltage", &map->voltage);
|
||||
if (error) {
|
||||
dev_err(dev, "%pOFn: Inval voltage prop\n", pp);
|
||||
of_node_put(pp);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
error = of_property_read_u32(pp, "linux,code", &map->keycode);
|
||||
if (error) {
|
||||
dev_err(dev, "%pOFn: Inval linux,code prop\n", pp);
|
||||
of_node_put(pp);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user