clk: imx: imx8: Fix some error handling paths
v2 cover clk: imx: imx8: Fix some error handling paths
This serie fix some error handling paths. It is split in different patches to ease review because the issues are unrelated and the proposed fixes are maybe wrong (I don't have the hardware to test anything)
Some of v1 patches had been incorrectly hand modified. There was a extra ')' in patch 3 and 4 that prevented the merge.
This v2 is a cleanly regenarated serie, compile tested at each step. This time, git format-patch did all the work and the patches have NOT been hand modified afterwards.
Some log messages have also been slightly tweaked. R-b tags have been added.
v1: https://lore.kernel.org/all/[email protected]/
Christophe JAILLET (5):
clk: imx: imx8: Fix an error handling path in
clk_imx_acm_attach_pm_domains()
clk: imx: imx8: Fix an error handling path if
devm_clk_hw_register_mux_parent_data_table() fails
clk: imx: imx8: Fix an error handling path in imx8_acm_clk_probe()
clk: imx: imx8: Add a message in case of
devm_clk_hw_register_mux_parent_data_table() error
clk: imx: imx8: Simplify clk_imx_acm_detach_pm_domains()
drivers/clk/imx/clk-imx8-acm.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/5 clk: imx: imx8: Fix an error handling path in clk_imx_acm_attach_pm_domains()
If a dev_pm_domain_attach_by_id() call fails, previously allocated resources need to be released.
--- drivers/clk/imx/clk-imx8-acm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/clk/imx/clk-imx8-acm.c +4 -2
@@ -279,8 +279,10 @@ static int clk_imx_acm_attach_pm_domains(struct device *dev,for (i =0 ; i < dev_pm->num_domains; i++) { dev_pm->pd_dev[i] =dev_pm_domain_attach_by_id (dev, i); -if (IS_ERR (dev_pm->pd_dev[i])) -return PTR_ERR (dev_pm->pd_dev[i]); +if (IS_ERR (dev_pm->pd_dev[i])) { + ret =PTR_ERR (dev_pm->pd_dev[i]); + goto detach_pm; + } dev_pm->pd_dev_link[i] = device_link_add(dev, dev_pm->pd_dev[i],
Signature · 1 line
2.34.1
PATCH v2 2/5 clk: imx: imx8: Fix an error handling path if devm_clk_hw_register_mux_parent_data_table() fails
In reply to Christophe JAILLETIf a devm_clk_hw_register_mux_parent_data_table() call fails, it is likely that the probe should fail with an error code.
Set 'ret' before leaving the function.
--- drivers/clk/imx/clk-imx8-acm.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/imx/clk-imx8-acm.c +1 -0
@@ -373,6 +373,7 @@ static int imx8_acm_clk_probe(struct platform_device *pdev) sels[i].shift, sels[i].width, 0, NULL, NULL);if (IS_ERR (hws[sels[i].clkid])) { + ret =PTR_ERR (hws[sels[i].clkid]);pm_runtime_disable (&pdev->dev); goto err_clk_register; }
Signature · 1 line
2.34.1
PATCH v2 3/5 clk: imx: imx8: Fix an error handling path in imx8_acm_clk_probe()
In reply to Christophe JAILLETIf an error occurs after a successful clk_imx_acm_attach_pm_domains() call, it must be undone.
Add an explicit error handling path, re-order the code and add the missing clk_imx_acm_detach_pm_domains() call.
--- drivers/clk/imx/clk-imx8-acm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/clk/imx/clk-imx8-acm.c +6 -3
@@ -374,7 +374,6 @@ static int imx8_acm_clk_probe(struct platform_device *pdev) 0, NULL, NULL);if (IS_ERR (hws[sels[i].clkid])) { ret =PTR_ERR (hws[sels[i].clkid]); -pm_runtime_disable (&pdev->dev); goto err_clk_register; } }
@@ -384,12 +383,16 @@ static int imx8_acm_clk_probe(struct platform_device *pdev) ret =devm_of_clk_add_hw_provider (dev, of_clk_hw_onecell_get, clk_hw_data);if (ret <0 ) {dev_err (dev,"failed to register hws for ACM\n" ); -pm_runtime_disable (&pdev->dev); + goto err_clk_register; } -err_clk_register: +pm_runtime_put_sync (&pdev->dev); +return 0 ; +err_clk_register:pm_runtime_put_sync (&pdev->dev); +pm_runtime_disable (&pdev->dev); +clk_imx_acm_detach_pm_domains (&pdev->dev, &priv->dev_pm);return ret; }
Signature · 1 line
2.34.1
PATCH v2 4/5 clk: imx: imx8: Add a message in case of devm_clk_hw_register_mux_parent_data_table() error
In reply to Christophe JAILLETIf devm_clk_hw_register_mux_parent_data_table() fails, we branch to the error handling path and imx_check_clk_hws() is never called.
Actually, imx_check_clk_hws() is a no-op because values in 'hws' are either valid, either NULL.
Move the call to imx_check_clk_hws() in the error handling path, so that an error is logged.
--- drivers/clk/imx/clk-imx8-acm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/clk/imx/clk-imx8-acm.c +1 -2
@@ -374,12 +374,11 @@ static int imx8_acm_clk_probe(struct platform_device *pdev) 0, NULL, NULL);if (IS_ERR (hws[sels[i].clkid])) { ret =PTR_ERR (hws[sels[i].clkid]); +imx_check_clk_hws (hws,IMX_ADMA_ACM_CLK_END ); goto err_clk_register; } } -imx_check_clk_hws (hws,IMX_ADMA_ACM_CLK_END ); - ret =devm_of_clk_add_hw_provider (dev, of_clk_hw_onecell_get, clk_hw_data);if (ret <0 ) {dev_err (dev,"failed to register hws for ACM\n" );
Signature · 1 line
2.34.1
PATCH v2 5/5 clk: imx: imx8: Simplify clk_imx_acm_detach_pm_domains()
In reply to Christophe JAILLETThe return value of clk_imx_acm_detach_pm_domains() is never used. Simplify the code and turn it into a void function.
--- drivers/clk/imx/clk-imx8-acm.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/clk/imx/clk-imx8-acm.c +3 -5
@@ -310,20 +310,18 @@ static int clk_imx_acm_attach_pm_domains(struct device *dev,* @dev: deivice pointer * @dev_pm: multi power domain for device */ -static int clk_imx_acm_detach_pm_domains (struct device *dev, -struct clk_imx_acm_pm_domains *dev_pm) +static void clk_imx_acm_detach_pm_domains (struct device *dev, +struct clk_imx_acm_pm_domains *dev_pm) {int i;if (dev_pm->num_domains <=1 ) -return 0 ; +return ;for (i =0 ; i < dev_pm->num_domains; i++) {device_link_del (dev_pm->pd_dev_link[i]);dev_pm_domain_detach (dev_pm->pd_dev[i], false); } - -return 0 ; }static int imx8_acm_clk_probe (struct platform_device *pdev)
Signature · 1 line
2.34.1
Quoted 9 lines
This serie fix some error handling paths. It is split in different patches to ease review because the issues are unrelated and the proposed fixes are maybe wrong (I don't have the hardware to test anything)
Some of v1 patches had been incorrectly hand modified. There was a extra ')' in patch 3 and 4 that prevented the merge.
Quoted 7 lines
This v2 is a cleanly regenarated serie, compile tested at each step. This time, git format-patch did all the work and the patches have NOT been hand modified afterwards.
Some log messages have also been slightly tweaked. R-b tags have been added.
Best regards
Wang Shengjiu
Quoted 26 lines
v1:
https://lore.k/
ernel.org%2Fall%2Fcover.1693126687.git.christophe.jaillet%40wanadoo.fr%2 F&data=05%7C01%7Cshengjiu.wang%40nxp.com%7C5134bf2d7d924e4ca9ae 08dbb561881c%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6383 03202724496811%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiL CJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&s data=f0SvmM0H1Ki%2Bp3Qqsya8u87CbVowC4bXym2i%2FSBCgJc%3D&reser ved=0Christophe JAILLET (5):
clk: imx: imx8: Fix an error handling path in
clk_imx_acm_attach_pm_domains()
clk: imx: imx8: Fix an error handling path if
devm_clk_hw_register_mux_parent_data_table()fails
clk: imx: imx8: Fix an error handling path inimx8_acm_clk_probe()
clk: imx: imx8: Add a message in case of
devm_clk_hw_register_mux_parent_data_table()error
clk: imx: imx8: Simplifyclk_imx_acm_detach_pm_domains()drivers/clk/imx/clk-imx8-acm.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)--
2.34.1
Abel Vesa
AppliedQuoted 8 lines · Christophe JAILLET
This serie fix some error handling paths. It is split in different patches to ease review because the issues are unrelated and the proposed fixes are maybe wrong (I don't have the hardware to test anything)
Some of v1 patches had been incorrectly hand modified. There was a extra ')' in patch 3 and 4 that prevented the merge.
[...]
Applied, thanks!
[1/5] clk: imx: imx8: Fix an error handling path in clk_imx_acm_attach_pm_domains()
commit: 156624e2cf815ce98fad5a24f04370f4459ae6f4
[2/5] clk: imx: imx8: Fix an error handling path if devm_clk_hw_register_mux_parent_data_table() fails
commit: 9a0108acdb1b6189dcc8f9318edfc6b7e0281df4
[3/5] clk: imx: imx8: Fix an error handling path in imx8_acm_clk_probe()
commit: e9a164e367f039629fd5466a79b9f495646e1261
[4/5] clk: imx: imx8: Add a message in case of devm_clk_hw_register_mux_parent_data_table() error
commit: ef23d44b7fcbd19773dcedcb50ca2f625107604f
[5/5] clk: imx: imx8: Simplify clk_imx_acm_detach_pm_domains()
commit: 3af29a89de2c6e49737a1201b7d6fd5ad3f635a4Best regards,
Signature · 1 line
Abel Vesa <[email protected]>