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 <johan@kernel.org>
---
drivers/usb/musb/omap2430.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c
index 36f756f9b7f6..c35c07b7488c 100644
--- a/drivers/usb/musb/omap2430.c
+++ b/drivers/usb/musb/omap2430.c
@@ -318,13 +318,11 @@ static int omap2430_probe(struct platform_device *pdev)
glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
if (!glue)
- goto err0;
+ return -ENOMEM;
musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO);
- if (!musb) {
- dev_err(&pdev->dev, "failed to allocate musb device\n");
- goto err0;
- }
+ if (!musb)
+ return -ENOMEM;
musb->dev.parent = &pdev->dev;
musb->dev.dma_mask = &omap2430_dmamask;
@@ -349,15 +347,15 @@ static int omap2430_probe(struct platform_device *pdev)
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
- goto err2;
+ goto err_put_musb;
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data)
- goto err2;
+ goto err_put_musb;
config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL);
if (!config)
- goto err2;
+ goto err_put_musb;
of_property_read_u32(np, "mode", (u32 *)&pdata->mode);
of_property_read_u32(np, "interface-type",
@@ -380,7 +378,7 @@ static int omap2430_probe(struct platform_device *pdev)
if (!control_pdev) {
dev_err(&pdev->dev, "Failed to get control device\n");
ret = -EINVAL;
- goto err2;
+ goto err_put_musb;
}
glue->control_otghs = &control_pdev->dev;
}
@@ -456,20 +454,19 @@ static int omap2430_probe(struct platform_device *pdev)
ret = platform_device_add(musb);
if (ret) {
dev_err(&pdev->dev, "failed to register musb device\n");
- goto err3;
+ goto err_disable_rpm;
}
return 0;
-err3:
+err_disable_rpm:
pm_runtime_disable(glue->dev);
err_put_control_otghs:
if (!IS_ERR(glue->control_otghs))
put_device(glue->control_otghs);
-err2:
+err_put_musb:
platform_device_put(musb);
-err0:
return ret;
}
--
2.49.1
Johan Hovold <johan@kernel.org> writes: > 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 <johan@kernel.org> Reviewed-by: Kevin Hilman <khilman@baylibre.com> > --- > drivers/usb/musb/omap2430.c | 23 ++++++++++------------- > 1 file changed, 10 insertions(+), 13 deletions(-) > > diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c > index 36f756f9b7f6..c35c07b7488c 100644 > --- a/drivers/usb/musb/omap2430.c > +++ b/drivers/usb/musb/omap2430.c > @@ -318,13 +318,11 @@ static int omap2430_probe(struct platform_device *pdev) > > glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); > if (!glue) > - goto err0; > + return -ENOMEM; > > musb = platform_device_alloc("musb-hdrc", PLATFORM_DEVID_AUTO); > - if (!musb) { > - dev_err(&pdev->dev, "failed to allocate musb device\n"); > - goto err0; > - } > + if (!musb) > + return -ENOMEM; > > musb->dev.parent = &pdev->dev; > musb->dev.dma_mask = &omap2430_dmamask; > @@ -349,15 +347,15 @@ static int omap2430_probe(struct platform_device *pdev) > > pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); > if (!pdata) > - goto err2; > + goto err_put_musb; > > data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); > if (!data) > - goto err2; > + goto err_put_musb; > > config = devm_kzalloc(&pdev->dev, sizeof(*config), GFP_KERNEL); > if (!config) > - goto err2; > + goto err_put_musb; > > of_property_read_u32(np, "mode", (u32 *)&pdata->mode); > of_property_read_u32(np, "interface-type", > @@ -380,7 +378,7 @@ static int omap2430_probe(struct platform_device *pdev) > if (!control_pdev) { > dev_err(&pdev->dev, "Failed to get control device\n"); > ret = -EINVAL; > - goto err2; > + goto err_put_musb; > } > glue->control_otghs = &control_pdev->dev; > } > @@ -456,20 +454,19 @@ static int omap2430_probe(struct platform_device *pdev) > ret = platform_device_add(musb); > if (ret) { > dev_err(&pdev->dev, "failed to register musb device\n"); > - goto err3; > + goto err_disable_rpm; > } > > return 0; > > -err3: > +err_disable_rpm: > pm_runtime_disable(glue->dev); > err_put_control_otghs: > if (!IS_ERR(glue->control_otghs)) > put_device(glue->control_otghs); > -err2: > +err_put_musb: > platform_device_put(musb); > > -err0: > return ret; > } > > -- > 2.49.1
© 2016 - 2025 Red Hat, Inc.