Skip to content

Commit 51d4b0a

Browse files
jhovoldgregkh
authored andcommitted
usb: musb: omap2430: clean up probe error handling
Using numbered error labels is discouraged (e.g. as it requires renumbering them when adding a new intermediate error path). Rename the error labels after what they do. While at it, drop the redundant platform allocation failure dev_err() as the error would already have been logged by the allocator. Signed-off-by: Johan Hovold <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1473e9e commit 51d4b0a

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

drivers/usb/musb/omap2430.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,11 @@ static int omap2430_probe(struct platform_device *pdev)
318318

319319
glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
320320
if (!glue)
321-
goto err0;
321+
return -ENOMEM;
322322

323323
musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
324-
if (!musb) {
325-
dev_err(&pdev->dev, "failed to allocate musb device\n");
326-
goto err0;
327-
}
324+
if (!musb)
325+
return -ENOMEM;
328326

329327
musb->dev.parent = &pdev->dev;
330328
musb->dev.dma_mask = &omap2430_dmamask;
@@ -349,15 +347,15 @@ static int omap2430_probe(struct platform_device *pdev)
349347

350348
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
351349
if (!pdata)
352-
goto err2;
350+
goto err_put_musb;
353351

354352
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
355353
if (!data)
356-
goto err2;
354+
goto err_put_musb;
357355

358356
config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL);
359357
if (!config)
360-
goto err2;
358+
goto err_put_musb;
361359

362360
of_property_read_u32(np, "mode", (u32 *)&pdata->mode);
363361
of_property_read_u32(np, "interface-type",
@@ -380,7 +378,7 @@ static int omap2430_probe(struct platform_device *pdev)
380378
if (!control_pdev) {
381379
dev_err(&pdev->dev, "Failed to get control device\n");
382380
ret = -EINVAL;
383-
goto err2;
381+
goto err_put_musb;
384382
}
385383
glue->control_otghs = &control_pdev->dev;
386384
}
@@ -456,20 +454,19 @@ static int omap2430_probe(struct platform_device *pdev)
456454
ret = platform_device_add(musb);
457455
if (ret) {
458456
dev_err(&pdev->dev, "failed to register musb device\n");
459-
goto err3;
457+
goto err_disable_rpm;
460458
}
461459

462460
return 0;
463461

464-
err3:
462+
err_disable_rpm:
465463
pm_runtime_disable(glue->dev);
466464
err_put_control_otghs:
467465
if (!IS_ERR(glue->control_otghs))
468466
put_device(glue->control_otghs);
469-
err2:
467+
err_put_musb:
470468
platform_device_put(musb);
471469

472-
err0:
473470
return ret;
474471
}
475472

0 commit comments

Comments
 (0)