Commit 819c0c31 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Greg Kroah-Hartman

usb: dwc3: rtk: return directly and simplify with devm_platform_ioremap_resource

Use devm_platform_ioremap_resource() wrapper instead of two calls, which
together with returning directly instead of useless goto, allows to
nicely simplify the probe() function.
Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Acked-by: default avatarThinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://lore.kernel.org/r/20240814-b4-cleanup-h-of-node-put-usb-v1-10-95481b9682bc@linaro.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f93e96c5
...@@ -358,30 +358,18 @@ static int dwc3_rtk_probe(struct platform_device *pdev) ...@@ -358,30 +358,18 @@ static int dwc3_rtk_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct resource *res; struct resource *res;
void __iomem *regs; void __iomem *regs;
int ret = 0;
rtk = devm_kzalloc(dev, sizeof(*rtk), GFP_KERNEL); rtk = devm_kzalloc(dev, sizeof(*rtk), GFP_KERNEL);
if (!rtk) { if (!rtk)
ret = -ENOMEM; return -ENOMEM;
goto out;
}
platform_set_drvdata(pdev, rtk); platform_set_drvdata(pdev, rtk);
rtk->dev = dev; rtk->dev = dev;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (!res) { if (IS_ERR(regs))
dev_err(dev, "missing memory resource\n"); return PTR_ERR(regs);
ret = -ENODEV;
goto out;
}
regs = devm_ioremap_resource(dev, res);
if (IS_ERR(regs)) {
ret = PTR_ERR(regs);
goto out;
}
rtk->regs = regs; rtk->regs = regs;
rtk->regs_size = resource_size(res); rtk->regs_size = resource_size(res);
...@@ -389,16 +377,11 @@ static int dwc3_rtk_probe(struct platform_device *pdev) ...@@ -389,16 +377,11 @@ static int dwc3_rtk_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 1); res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (res) { if (res) {
rtk->pm_base = devm_ioremap_resource(dev, res); rtk->pm_base = devm_ioremap_resource(dev, res);
if (IS_ERR(rtk->pm_base)) { if (IS_ERR(rtk->pm_base))
ret = PTR_ERR(rtk->pm_base); return PTR_ERR(rtk->pm_base);
goto out;
}
} }
ret = dwc3_rtk_probe_dwc3_core(rtk); return dwc3_rtk_probe_dwc3_core(rtk);
out:
return ret;
} }
static void dwc3_rtk_remove(struct platform_device *pdev) static void dwc3_rtk_remove(struct platform_device *pdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment