mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-07 18:05:21 +02:00
pinctrl: ti: iodelay: Use scope based of_node_put() cleanups
[ Upstream commit791a8bb202
] 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> Stable-dep-of:a9f2b249ad
("pinctrl: ti: ti-iodelay: Fix some error handling paths") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
ccc7cdf496
commit
85427d5109
|
@ -822,53 +822,48 @@ MODULE_DEVICE_TABLE(of, ti_iodelay_of_match);
|
||||||
static int ti_iodelay_probe(struct platform_device *pdev)
|
static int ti_iodelay_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct device_node *np = of_node_get(dev->of_node);
|
struct device_node *np __free(device_node) = of_node_get(dev->of_node);
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
struct ti_iodelay_device *iod;
|
struct ti_iodelay_device *iod;
|
||||||
int ret = 0;
|
int ret;
|
||||||
|
|
||||||
if (!np) {
|
if (!np) {
|
||||||
ret = -EINVAL;
|
|
||||||
dev_err(dev, "No OF node\n");
|
dev_err(dev, "No OF node\n");
|
||||||
goto exit_out;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
iod = devm_kzalloc(dev, sizeof(*iod), GFP_KERNEL);
|
iod = devm_kzalloc(dev, sizeof(*iod), GFP_KERNEL);
|
||||||
if (!iod) {
|
if (!iod)
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto exit_out;
|
|
||||||
}
|
|
||||||
iod->dev = dev;
|
iod->dev = dev;
|
||||||
iod->reg_data = device_get_match_data(dev);
|
iod->reg_data = device_get_match_data(dev);
|
||||||
if (!iod->reg_data) {
|
if (!iod->reg_data) {
|
||||||
ret = -EINVAL;
|
|
||||||
dev_err(dev, "No DATA match\n");
|
dev_err(dev, "No DATA match\n");
|
||||||
goto exit_out;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* So far We can assume there is only 1 bank of registers */
|
/* So far We can assume there is only 1 bank of registers */
|
||||||
iod->reg_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
|
iod->reg_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
|
||||||
if (IS_ERR(iod->reg_base)) {
|
if (IS_ERR(iod->reg_base))
|
||||||
ret = PTR_ERR(iod->reg_base);
|
return PTR_ERR(iod->reg_base);
|
||||||
goto exit_out;
|
|
||||||
}
|
|
||||||
iod->phys_base = res->start;
|
iod->phys_base = res->start;
|
||||||
|
|
||||||
iod->regmap = devm_regmap_init_mmio(dev, iod->reg_base,
|
iod->regmap = devm_regmap_init_mmio(dev, iod->reg_base,
|
||||||
iod->reg_data->regmap_config);
|
iod->reg_data->regmap_config);
|
||||||
if (IS_ERR(iod->regmap)) {
|
if (IS_ERR(iod->regmap)) {
|
||||||
dev_err(dev, "Regmap MMIO init failed.\n");
|
dev_err(dev, "Regmap MMIO init failed.\n");
|
||||||
ret = PTR_ERR(iod->regmap);
|
return PTR_ERR(iod->regmap);
|
||||||
goto exit_out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ti_iodelay_pinconf_init_dev(iod);
|
ret = ti_iodelay_pinconf_init_dev(iod);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto exit_out;
|
return ret;
|
||||||
|
|
||||||
ret = ti_iodelay_alloc_pins(dev, iod, res->start);
|
ret = ti_iodelay_alloc_pins(dev, iod, res->start);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto exit_out;
|
return ret;
|
||||||
|
|
||||||
iod->desc.pctlops = &ti_iodelay_pinctrl_ops;
|
iod->desc.pctlops = &ti_iodelay_pinctrl_ops;
|
||||||
/* no pinmux ops - we are pinconf */
|
/* no pinmux ops - we are pinconf */
|
||||||
|
@ -879,20 +874,12 @@ static int ti_iodelay_probe(struct platform_device *pdev)
|
||||||
ret = devm_pinctrl_register_and_init(dev, &iod->desc, iod, &iod->pctl);
|
ret = devm_pinctrl_register_and_init(dev, &iod->desc, iod, &iod->pctl);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev, "Failed to register pinctrl\n");
|
dev_err(dev, "Failed to register pinctrl\n");
|
||||||
goto exit_out;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
platform_set_drvdata(pdev, iod);
|
platform_set_drvdata(pdev, iod);
|
||||||
|
|
||||||
ret = pinctrl_enable(iod->pctl);
|
return pinctrl_enable(iod->pctl);
|
||||||
if (ret)
|
|
||||||
goto exit_out;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
exit_out:
|
|
||||||
of_node_put(np);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user