Skip to content

Commit e4818d3

Browse files
elfringabelvesa
authored andcommitted
clk: imx: scu: Use common error handling code in imx_clk_scu_alloc_dev()
Add a jump target so that a bit of exception handling can be better reused at the end of this function. Signed-off-by: Markus Elfring <[email protected]> Reviewed-by: Peng Fan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Abel Vesa <[email protected]>
1 parent e1ed0b0 commit e4818d3

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

drivers/clk/imx/clk-scu.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -712,31 +712,29 @@ struct clk_hw *imx_clk_scu_alloc_dev(const char *name,
712712
}
713713

714714
ret = platform_device_add_data(pdev, &clk, sizeof(clk));
715-
if (ret) {
716-
platform_device_put(pdev);
717-
return ERR_PTR(ret);
718-
}
715+
if (ret)
716+
goto put_device;
719717

720718
ret = driver_set_override(&pdev->dev, &pdev->driver_override,
721719
"imx-scu-clk", strlen("imx-scu-clk"));
722-
if (ret) {
723-
platform_device_put(pdev);
724-
return ERR_PTR(ret);
725-
}
720+
if (ret)
721+
goto put_device;
726722

727723
ret = imx_clk_scu_attach_pd(&pdev->dev, rsrc_id);
728724
if (ret)
729725
pr_warn("%s: failed to attached the power domain %d\n",
730726
name, ret);
731727

732728
ret = platform_device_add(pdev);
733-
if (ret) {
734-
platform_device_put(pdev);
735-
return ERR_PTR(ret);
736-
}
729+
if (ret)
730+
goto put_device;
737731

738732
/* For API backwards compatiblilty, simply return NULL for success */
739733
return NULL;
734+
735+
put_device:
736+
platform_device_put(pdev);
737+
return ERR_PTR(ret);
740738
}
741739

742740
void imx_clk_scu_unregister(void)

0 commit comments

Comments
 (0)