staging: most: dim2: clean up error handling in fsl_mx6_enable
Subsystems (2)
v3 cover staging: most: dim2: clean up error handling in fsl_mx6_enable
This series cleans up error handling in fsl_mx6_enable(), split into separate logical changes per Dan Carpenter's review of v1.
Patch 1 replaces IS_ERR_OR_NULL() with IS_ERR() since devm_clk_get() never returns NULL.
Patch 2 replaces dev_err() + hardcoded -EFAULT with dev_err_probe() and PTR_ERR() to propagate correct error codes and handle probe deferral properly.
Patch 3 removes unnecessary string indirection in dev_err() calls ("%s\n", "message" -> "message\n").
Changes since v2:
- No code changes, resending as new thread to resolve duplicate v2 submissions (sorry for the noise)
Changes since v1:
- Split combined patch into 3 separate patches (one change per patch)
- Extended string indirection fix to all three enable functions
Artem Lytkin (3):
staging: most: dim2: replace IS_ERR_OR_NULL with IS_ERR for
devm_clk_get
staging: most: dim2: use dev_err_probe and proper error codes for
clock
staging: most: dim2: remove unnecessary string indirection in dev_err
drivers/staging/most/dim2/dim2.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
Signature · 1 line
2.43.0
PATCH v3 1/3 staging: most: dim2: replace IS_ERR_OR_NULL with IS_ERR for devm_clk_get
devm_clk_get() never returns NULL, so IS_ERR_OR_NULL() checks are unnecessary. Replace them with IS_ERR() for both the "mlb" and "pll8_mlb" clock lookups in fsl_mx6_enable().
--- drivers/staging/most/dim2/dim2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/most/dim2/dim2.c +2 -2
@@ -921,7 +921,7 @@ static int fsl_mx6_enable(struct platform_device *pdev)int ret; dev->clk =devm_clk_get (&pdev->dev,"mlb" ); -if (IS_ERR_OR_NULL (dev->clk)) { +if (IS_ERR (dev->clk)) {dev_err (&pdev->dev,"unable to get mlb clock\n" );return -EFAULT ; }
@@ -935,7 +935,7 @@ static int fsl_mx6_enable(struct platform_device *pdev)if (dev->clk_speed >=CLK_2048FS ) {/* enable pll */ dev->clk_pll =devm_clk_get (&pdev->dev,"pll8_mlb" ); -if (IS_ERR_OR_NULL (dev->clk_pll)) { +if (IS_ERR (dev->clk_pll)) {dev_err (&pdev->dev,"unable to get mlb pll clock\n" );clk_disable_unprepare (dev->clk);return -EFAULT ;
Signature · 1 line
2.43.0
PATCH v3 2/3 staging: most: dim2: use dev_err_probe and proper error codes for clock
In reply to Artem LytkinReplace hardcoded -EFAULT returns with dev_err_probe() and PTR_ERR() when devm_clk_get() fails in fsl_mx6_enable(). This ensures the correct error code is propagated (e.g. -EPROBE_DEFER for deferred probing) and avoids log noise during probe deferral.
--- drivers/staging/most/dim2/dim2.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/staging/most/dim2/dim2.c +5 -6
@@ -921,10 +921,9 @@ static int fsl_mx6_enable(struct platform_device *pdev)int ret; dev->clk =devm_clk_get (&pdev->dev,"mlb" ); -if (IS_ERR (dev->clk)) { -dev_err (&pdev->dev,"unable to get mlb clock\n" ); -return -EFAULT ; - } +if (IS_ERR (dev->clk)) +return dev_err_probe (&pdev->dev,PTR_ERR (dev->clk), +"unable to get mlb clock\n" ); ret =clk_prepare_enable (dev->clk);if (ret) {
@@ -936,9 +935,9 @@ static int fsl_mx6_enable(struct platform_device *pdev)/* enable pll */ dev->clk_pll =devm_clk_get (&pdev->dev,"pll8_mlb" );if (IS_ERR (dev->clk_pll)) { -dev_err (&pdev->dev,"unable to get mlb pll clock\n" );clk_disable_unprepare (dev->clk); -return -EFAULT ; +return dev_err_probe (&pdev->dev,PTR_ERR (dev->clk_pll), +"unable to get mlb pll clock\n" ); }writel (0x888 , dev->io_base +0x38 );
Signature · 1 line
2.43.0
PATCH v3 3/3 staging: most: dim2: remove unnecessary string indirection in dev_err
In reply to Artem LytkinReplace dev_err(&pdev->dev, "%s\n", "clk_prepare_enable failed") with the direct format string dev_err(&pdev->dev, "clk_prepare_enable failed\n"). The extra level of indirection through %s is unnecessary.
--- drivers/staging/most/dim2/dim2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/most/dim2/dim2.c +3 -3
@@ -927,7 +927,7 @@ static int fsl_mx6_enable(struct platform_device *pdev) ret =clk_prepare_enable (dev->clk);if (ret) { -dev_err (&pdev->dev,"%s\n" ,"clk_prepare_enable failed" ); +dev_err (&pdev->dev,"clk_prepare_enable failed\n" );return ret; }
@@ -975,7 +975,7 @@ static int rcar_gen2_enable(struct platform_device *pdev) ret =clk_prepare_enable (dev->clk);if (ret) { -dev_err (&pdev->dev,"%s\n" ,"clk_prepare_enable failed" ); +dev_err (&pdev->dev,"clk_prepare_enable failed\n" );return ret; }
@@ -1020,7 +1020,7 @@ static int rcar_gen3_enable(struct platform_device *pdev) ret =clk_prepare_enable (dev->clk);if (ret) { -dev_err (&pdev->dev,"%s\n" ,"clk_prepare_enable failed" ); +dev_err (&pdev->dev,"clk_prepare_enable failed\n" );return ret; }
Signature · 1 line
2.43.0