Skip to content

Commit 819c0c3

Browse files
krzkgregkh
authored andcommitted
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: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Acked-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com> Link: https://lore.kernel.org/r/20240814-b4-cleanup-h-of-node-put-usb-v1-10-95481b9682bc@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f93e96c commit 819c0c3

File tree

1 file changed

+8
-25
lines changed

1 file changed

+8
-25
lines changed

drivers/usb/dwc3/dwc3-rtk.c

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -358,47 +358,30 @@ static int dwc3_rtk_probe(struct platform_device *pdev)
358358
struct device *dev = &pdev->dev;
359359
struct resource *res;
360360
void __iomem *regs;
361-
int ret = 0;
362361

363362
rtk = devm_kzalloc(dev, sizeof(*rtk), GFP_KERNEL);
364-
if (!rtk) {
365-
ret = -ENOMEM;
366-
goto out;
367-
}
363+
if (!rtk)
364+
return -ENOMEM;
368365

369366
platform_set_drvdata(pdev, rtk);
370367

371368
rtk->dev = dev;
372369

373-
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
374-
if (!res) {
375-
dev_err(dev, "missing memory resource\n");
376-
ret = -ENODEV;
377-
goto out;
378-
}
379-
380-
regs = devm_ioremap_resource(dev, res);
381-
if (IS_ERR(regs)) {
382-
ret = PTR_ERR(regs);
383-
goto out;
384-
}
370+
regs = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
371+
if (IS_ERR(regs))
372+
return PTR_ERR(regs);
385373

386374
rtk->regs = regs;
387375
rtk->regs_size = resource_size(res);
388376

389377
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
390378
if (res) {
391379
rtk->pm_base = devm_ioremap_resource(dev, res);
392-
if (IS_ERR(rtk->pm_base)) {
393-
ret = PTR_ERR(rtk->pm_base);
394-
goto out;
395-
}
380+
if (IS_ERR(rtk->pm_base))
381+
return PTR_ERR(rtk->pm_base);
396382
}
397383

398-
ret = dwc3_rtk_probe_dwc3_core(rtk);
399-
400-
out:
401-
return ret;
384+
return dwc3_rtk_probe_dwc3_core(rtk);
402385
}
403386

404387
static void dwc3_rtk_remove(struct platform_device *pdev)

0 commit comments

Comments
 (0)