1

pinctrl: samsung: 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/r/20240504-pinctrl-cleanup-v2-20-26c5f2dc1181@nxp.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
This commit is contained in:
Peng Fan 2024-05-04 21:20:18 +08:00 committed by Krzysztof Kozlowski
parent aa85d45338
commit d59c2396e0
2 changed files with 9 additions and 26 deletions

View File

@ -662,7 +662,7 @@ static void exynos_irq_demux_eint16_31(struct irq_desc *desc)
__init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d) __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
{ {
struct device *dev = d->dev; struct device *dev = d->dev;
struct device_node *wkup_np = NULL; struct device_node *wkup_np __free(device_node) = NULL;
struct device_node *np; struct device_node *np;
struct samsung_pin_bank *bank; struct samsung_pin_bank *bank;
struct exynos_weint_data *weint_data; struct exynos_weint_data *weint_data;
@ -692,17 +692,14 @@ __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
bank->irq_chip = devm_kmemdup(dev, irq_chip, sizeof(*irq_chip), bank->irq_chip = devm_kmemdup(dev, irq_chip, sizeof(*irq_chip),
GFP_KERNEL); GFP_KERNEL);
if (!bank->irq_chip) { if (!bank->irq_chip)
of_node_put(wkup_np);
return -ENOMEM; return -ENOMEM;
}
bank->irq_chip->chip.name = bank->name; bank->irq_chip->chip.name = bank->name;
bank->irq_domain = irq_domain_create_linear(bank->fwnode, bank->irq_domain = irq_domain_create_linear(bank->fwnode,
bank->nr_pins, &exynos_eint_irqd_ops, bank); bank->nr_pins, &exynos_eint_irqd_ops, bank);
if (!bank->irq_domain) { if (!bank->irq_domain) {
dev_err(dev, "wkup irq domain add failed\n"); dev_err(dev, "wkup irq domain add failed\n");
of_node_put(wkup_np);
return -ENXIO; return -ENXIO;
} }
@ -715,10 +712,8 @@ __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
weint_data = devm_kcalloc(dev, weint_data = devm_kcalloc(dev,
bank->nr_pins, sizeof(*weint_data), bank->nr_pins, sizeof(*weint_data),
GFP_KERNEL); GFP_KERNEL);
if (!weint_data) { if (!weint_data)
of_node_put(wkup_np);
return -ENOMEM; return -ENOMEM;
}
for (idx = 0; idx < bank->nr_pins; ++idx) { for (idx = 0; idx < bank->nr_pins; ++idx) {
irq = irq_of_parse_and_map(to_of_node(bank->fwnode), idx); irq = irq_of_parse_and_map(to_of_node(bank->fwnode), idx);
@ -735,13 +730,10 @@ __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
} }
} }
if (!muxed_banks) { if (!muxed_banks)
of_node_put(wkup_np);
return 0; return 0;
}
irq = irq_of_parse_and_map(wkup_np, 0); irq = irq_of_parse_and_map(wkup_np, 0);
of_node_put(wkup_np);
if (!irq) { if (!irq) {
dev_err(dev, "irq number for muxed EINTs not found\n"); dev_err(dev, "irq number for muxed EINTs not found\n");
return 0; return 0;

View File

@ -251,7 +251,6 @@ static int samsung_dt_node_to_map(struct pinctrl_dev *pctldev,
{ {
struct samsung_pinctrl_drv_data *drvdata; struct samsung_pinctrl_drv_data *drvdata;
unsigned reserved_maps; unsigned reserved_maps;
struct device_node *np;
int ret; int ret;
drvdata = pinctrl_dev_get_drvdata(pctldev); drvdata = pinctrl_dev_get_drvdata(pctldev);
@ -266,12 +265,11 @@ static int samsung_dt_node_to_map(struct pinctrl_dev *pctldev,
&reserved_maps, &reserved_maps,
num_maps); num_maps);
for_each_child_of_node(np_config, np) { for_each_child_of_node_scoped(np_config, np) {
ret = samsung_dt_subnode_to_map(drvdata, pctldev->dev, np, map, ret = samsung_dt_subnode_to_map(drvdata, pctldev->dev, np, map,
&reserved_maps, num_maps); &reserved_maps, num_maps);
if (ret < 0) { if (ret < 0) {
samsung_dt_free_map(pctldev, *map, *num_maps); samsung_dt_free_map(pctldev, *map, *num_maps);
of_node_put(np);
return ret; return ret;
} }
} }
@ -849,16 +847,12 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
* and create pin groups and pin function lists. * and create pin groups and pin function lists.
*/ */
func_cnt = 0; func_cnt = 0;
for_each_child_of_node(dev_np, cfg_np) { for_each_child_of_node_scoped(dev_np, cfg_np) {
struct device_node *func_np;
if (!of_get_child_count(cfg_np)) { if (!of_get_child_count(cfg_np)) {
ret = samsung_pinctrl_create_function(dev, drvdata, ret = samsung_pinctrl_create_function(dev, drvdata,
cfg_np, func); cfg_np, func);
if (ret < 0) { if (ret < 0)
of_node_put(cfg_np);
return ERR_PTR(ret); return ERR_PTR(ret);
}
if (ret > 0) { if (ret > 0) {
++func; ++func;
++func_cnt; ++func_cnt;
@ -866,14 +860,11 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
continue; continue;
} }
for_each_child_of_node(cfg_np, func_np) { for_each_child_of_node_scoped(cfg_np, func_np) {
ret = samsung_pinctrl_create_function(dev, drvdata, ret = samsung_pinctrl_create_function(dev, drvdata,
func_np, func); func_np, func);
if (ret < 0) { if (ret < 0)
of_node_put(func_np);
of_node_put(cfg_np);
return ERR_PTR(ret); return ERR_PTR(ret);
}
if (ret > 0) { if (ret > 0) {
++func; ++func;
++func_cnt; ++func_cnt;