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

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Javier Carrasco and committed by
Dmitry Torokhov
0ec6f58b 2e6980c1

+2 -5
+2 -5
drivers/input/keyboard/sun4i-lradc-keys.c
··· 202 202 static int sun4i_lradc_load_dt_keymap(struct device *dev, 203 203 struct sun4i_lradc_data *lradc) 204 204 { 205 - struct device_node *np, *pp; 205 + struct device_node *np; 206 206 int i; 207 207 int error; 208 208 ··· 223 223 return -ENOMEM; 224 224 225 225 i = 0; 226 - for_each_child_of_node(np, pp) { 226 + for_each_child_of_node_scoped(np, pp) { 227 227 struct sun4i_lradc_keymap *map = &lradc->chan0_map[i]; 228 228 u32 channel; 229 229 230 230 error = of_property_read_u32(pp, "channel", &channel); 231 231 if (error || channel != 0) { 232 232 dev_err(dev, "%pOFn: Inval channel prop\n", pp); 233 - of_node_put(pp); 234 233 return -EINVAL; 235 234 } 236 235 237 236 error = of_property_read_u32(pp, "voltage", &map->voltage); 238 237 if (error) { 239 238 dev_err(dev, "%pOFn: Inval voltage prop\n", pp); 240 - of_node_put(pp); 241 239 return -EINVAL; 242 240 } 243 241 244 242 error = of_property_read_u32(pp, "linux,code", &map->keycode); 245 243 if (error) { 246 244 dev_err(dev, "%pOFn: Inval linux,code prop\n", pp); 247 - of_node_put(pp); 248 245 return -EINVAL; 249 246 } 250 247