Skip to content

Commit 791a8bb

Browse files
MrVanlinusw
authored andcommitted
pinctrl: ti: iodelay: 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> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Link: https://lore.kernel.org/20240627131721.678727-2-peng.fan@oss.nxp.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent d1cddd6 commit 791a8bb

File tree

1 file changed

+15
-28
lines changed

1 file changed

+15
-28
lines changed

drivers/pinctrl/ti/pinctrl-ti-iodelay.c

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -822,53 +822,48 @@ MODULE_DEVICE_TABLE(of, ti_iodelay_of_match);
822822
static int ti_iodelay_probe(struct platform_device *pdev)
823823
{
824824
struct device *dev = &pdev->dev;
825-
struct device_node *np = of_node_get(dev->of_node);
825+
struct device_node *np __free(device_node) = of_node_get(dev->of_node);
826826
struct resource *res;
827827
struct ti_iodelay_device *iod;
828-
int ret = 0;
828+
int ret;
829829

830830
if (!np) {
831-
ret = -EINVAL;
832831
dev_err(dev, "No OF node\n");
833-
goto exit_out;
832+
return -EINVAL;
834833
}
835834

836835
iod = devm_kzalloc(dev, sizeof(*iod), GFP_KERNEL);
837-
if (!iod) {
838-
ret = -ENOMEM;
839-
goto exit_out;
840-
}
836+
if (!iod)
837+
return -ENOMEM;
838+
841839
iod->dev = dev;
842840
iod->reg_data = device_get_match_data(dev);
843841
if (!iod->reg_data) {
844-
ret = -EINVAL;
845842
dev_err(dev, "No DATA match\n");
846-
goto exit_out;
843+
return -EINVAL;
847844
}
848845

849846
/* So far We can assume there is only 1 bank of registers */
850847
iod->reg_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
851-
if (IS_ERR(iod->reg_base)) {
852-
ret = PTR_ERR(iod->reg_base);
853-
goto exit_out;
854-
}
848+
if (IS_ERR(iod->reg_base))
849+
return PTR_ERR(iod->reg_base);
850+
855851
iod->phys_base = res->start;
856852

857853
iod->regmap = devm_regmap_init_mmio(dev, iod->reg_base,
858854
iod->reg_data->regmap_config);
859855
if (IS_ERR(iod->regmap)) {
860856
dev_err(dev, "Regmap MMIO init failed.\n");
861-
ret = PTR_ERR(iod->regmap);
862-
goto exit_out;
857+
return PTR_ERR(iod->regmap);
863858
}
864859

865860
ret = ti_iodelay_pinconf_init_dev(iod);
866861
if (ret)
867-
goto exit_out;
862+
return ret;
868863

869864
ret = ti_iodelay_alloc_pins(dev, iod, res->start);
870865
if (ret)
871-
goto exit_out;
866+
return ret;
872867

873868
iod->desc.pctlops = &ti_iodelay_pinctrl_ops;
874869
/* no pinmux ops - we are pinconf */
@@ -879,20 +874,12 @@ static int ti_iodelay_probe(struct platform_device *pdev)
879874
ret = devm_pinctrl_register_and_init(dev, &iod->desc, iod, &iod->pctl);
880875
if (ret) {
881876
dev_err(dev, "Failed to register pinctrl\n");
882-
goto exit_out;
877+
return ret;
883878
}
884879

885880
platform_set_drvdata(pdev, iod);
886881

887-
ret = pinctrl_enable(iod->pctl);
888-
if (ret)
889-
goto exit_out;
890-
891-
return 0;
892-
893-
exit_out:
894-
of_node_put(np);
895-
return ret;
882+
return pinctrl_enable(iod->pctl);
896883
}
897884

898885
/**

0 commit comments

Comments
 (0)