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

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>

authored by

Peng Fan and committed by
Linus Walleij
791a8bb2 d1cddd6e

+15 -28
+15 -28
drivers/pinctrl/ti/pinctrl-ti-iodelay.c
··· 822 822 static int ti_iodelay_probe(struct platform_device *pdev) 823 823 { 824 824 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); 826 826 struct resource *res; 827 827 struct ti_iodelay_device *iod; 828 - int ret = 0; 828 + int ret; 829 829 830 830 if (!np) { 831 - ret = -EINVAL; 832 831 dev_err(dev, "No OF node\n"); 833 - goto exit_out; 832 + return -EINVAL; 834 833 } 835 834 836 835 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 + 841 839 iod->dev = dev; 842 840 iod->reg_data = device_get_match_data(dev); 843 841 if (!iod->reg_data) { 844 - ret = -EINVAL; 845 842 dev_err(dev, "No DATA match\n"); 846 - goto exit_out; 843 + return -EINVAL; 847 844 } 848 845 849 846 /* So far We can assume there is only 1 bank of registers */ 850 847 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 + 855 851 iod->phys_base = res->start; 856 852 857 853 iod->regmap = devm_regmap_init_mmio(dev, iod->reg_base, 858 854 iod->reg_data->regmap_config); 859 855 if (IS_ERR(iod->regmap)) { 860 856 dev_err(dev, "Regmap MMIO init failed.\n"); 861 - ret = PTR_ERR(iod->regmap); 862 - goto exit_out; 857 + return PTR_ERR(iod->regmap); 863 858 } 864 859 865 860 ret = ti_iodelay_pinconf_init_dev(iod); 866 861 if (ret) 867 - goto exit_out; 862 + return ret; 868 863 869 864 ret = ti_iodelay_alloc_pins(dev, iod, res->start); 870 865 if (ret) 871 - goto exit_out; 866 + return ret; 872 867 873 868 iod->desc.pctlops = &ti_iodelay_pinctrl_ops; 874 869 /* no pinmux ops - we are pinconf */ ··· 874 879 ret = devm_pinctrl_register_and_init(dev, &iod->desc, iod, &iod->pctl); 875 880 if (ret) { 876 881 dev_err(dev, "Failed to register pinctrl\n"); 877 - goto exit_out; 882 + return ret; 878 883 } 879 884 880 885 platform_set_drvdata(pdev, iod); 881 886 882 - ret = pinctrl_enable(iod->pctl); 883 - if (ret) 884 - goto exit_out; 885 - 886 - return 0; 887 - 888 - exit_out: 889 - of_node_put(np); 890 - return ret; 887 + return pinctrl_enable(iod->pctl); 891 888 } 892 889 893 890 /**