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

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Krzysztof Kozlowski and committed by
Greg Kroah-Hartman
819c0c31 f93e96c5

+8 -25
+8 -25
drivers/usb/dwc3/dwc3-rtk.c
··· 358 358 struct device *dev = &pdev->dev; 359 359 struct resource *res; 360 360 void __iomem *regs; 361 - int ret = 0; 362 361 363 362 rtk = devm_kzalloc(dev, sizeof(*rtk), GFP_KERNEL); 364 - if (!rtk) { 365 - ret = -ENOMEM; 366 - goto out; 367 - } 363 + if (!rtk) 364 + return -ENOMEM; 368 365 369 366 platform_set_drvdata(pdev, rtk); 370 367 371 368 rtk->dev = dev; 372 369 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); 385 373 386 374 rtk->regs = regs; 387 375 rtk->regs_size = resource_size(res); ··· 377 389 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 378 390 if (res) { 379 391 rtk->pm_base = devm_ioremap_resource(dev, res); 380 - if (IS_ERR(rtk->pm_base)) { 381 - ret = PTR_ERR(rtk->pm_base); 382 - goto out; 383 - } 392 + if (IS_ERR(rtk->pm_base)) 393 + return PTR_ERR(rtk->pm_base); 384 394 } 385 395 386 - ret = dwc3_rtk_probe_dwc3_core(rtk); 387 - 388 - out: 389 - return ret; 396 + return dwc3_rtk_probe_dwc3_core(rtk); 390 397 } 391 398 392 399 static void dwc3_rtk_remove(struct platform_device *pdev)