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

pinctrl: spear: Use scope based of_node_put() cleanups

Use scope based of_node_put() cleanup to simplify code.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/20240504-pinctrl-cleanup-v2-6-26c5f2dc1181@nxp.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Peng Fan and committed by
Linus Walleij
8c5dc2a5 794e5dc5

+4 -9
+4 -9
drivers/pinctrl/spear/pinctrl-spear.c
··· 151 151 unsigned *num_maps) 152 152 { 153 153 struct spear_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); 154 - struct device_node *np; 155 154 struct property *prop; 156 155 const char *function, *group; 157 156 int ret, index = 0, count = 0; 158 157 159 158 /* calculate number of maps required */ 160 - for_each_child_of_node(np_config, np) { 159 + for_each_child_of_node_scoped(np_config, np) { 161 160 ret = of_property_read_string(np, "st,function", &function); 162 - if (ret < 0) { 163 - of_node_put(np); 161 + if (ret < 0) 164 162 return ret; 165 - } 166 163 167 164 ret = of_property_count_strings(np, "st,pins"); 168 - if (ret < 0) { 169 - of_node_put(np); 165 + if (ret < 0) 170 166 return ret; 171 - } 172 167 173 168 count += ret; 174 169 } ··· 177 182 if (!*map) 178 183 return -ENOMEM; 179 184 180 - for_each_child_of_node(np_config, np) { 185 + for_each_child_of_node_scoped(np_config, np) { 181 186 of_property_read_string(np, "st,function", &function); 182 187 of_property_for_each_string(np, "st,pins", prop, group) { 183 188 (*map)[index].type = PIN_MAP_TYPE_MUX_GROUP;