iio: adc: bcm_iproc_adc: Simplify probe error handling
Subsystems (2)
v6 cover iio: adc: bcm_iproc_adc: Simplify probe error handling
From: Mohammad Shahid <[email protected]>
This series simplifies probe error handling in bcm_iproc_adc.
Patch 1 removes redundant probe error messages where lower-level helpers already report failures.
Patch 2 introduces a local device pointer to reduce repetition and prepare for subsequent error handling cleanup.
Patch 3 converts immediate-return probe error paths to dev_err_probe() while leaving cleanup paths unchanged.
Changes in v6:
- Restore the original formatting in Patch 2 to avoid unnecessary code churn, as suggested by Jonathan.
- Reduce indentation in selected dev_err_probe() calls in Patch 3 following review comments from Markus.
---
Mohammad Shahid (3):
iio: adc: bcm_iproc_adc: Remove redundant probe error messages
iio: adc: bcm_iproc_adc: Introduce local device pointer
iio: adc: bcm_iproc_adc: Convert probe error handling to
dev_err_probe()
drivers/iio/adc/bcm_iproc_adc.c | 46 ++++++++++++--------------------- 1 file changed, 16 insertions(+), 30 deletions(-)
Signature · 1 line
2.43.0
PATCH v6 1/3 iio: adc: bcm_iproc_adc: Remove redundant probe error messages
From: Mohammad Shahid <[email protected]>
devm_request_threaded_irq() already logs an error when the request fails, making the explicit dev_err() redundant.
Similarly, iproc_adc_enable() already reports failures, making the additional dev_err() in the probe path redundant.
Remove both duplicate messages.
--- drivers/iio/adc/bcm_iproc_adc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/iio/adc/bcm_iproc_adc.c +2 -6
@@ -551,10 +551,8 @@ static int iproc_adc_probe(struct platform_device *pdev) iproc_adc_interrupt_handler, iproc_adc_interrupt_thread, IRQF_SHARED, "iproc-adc", indio_dev); -if (ret) { -dev_err (&pdev->dev,"request_irq error %d\n" , ret); +if (ret)return ret; - } ret =clk_prepare_enable (adc_priv->adc_clk);if (ret) {
@@ -564,10 +562,8 @@ static int iproc_adc_probe(struct platform_device *pdev) } ret =iproc_adc_enable (indio_dev); -if (ret) { -dev_err (&pdev->dev,"failed to enable adc %d\n" , ret); +if (ret) goto err_adc_enable; - } indio_dev->name ="iproc-static-adc" ; indio_dev->info = &iproc_adc_iio_info;
Signature · 1 line
2.43.0
Re: [PATCH v6 1/3] iio: adc: bcm_iproc_adc: Remove redundant probe error messages
Quoted 7 lines · On Thu, Aug 06, 2026 at 08:09:00AM +0530, [email protected] wrote:
devm_request_threaded_irq()already logs an error when the request fails, making the explicitdev_err()redundant.Similarly,
iproc_adc_enable()already reports failures, making the additionaldev_err()in the probe path redundant.Remove both duplicate messages.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v6 2/3 iio: adc: bcm_iproc_adc: Introduce local device pointer
In reply to [email protected]From: Mohammad Shahid <[email protected]>
Introduce a local 'struct device *dev' variable in iproc_adc_probe() and use it for device-managed helper calls instead of repeatedly referencing '&pdev->dev'.
No functional change intended.
--- drivers/iio/adc/bcm_iproc_adc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/iio/adc/bcm_iproc_adc.c +4 -4
@@ -506,10 +506,10 @@ static int iproc_adc_probe(struct platform_device *pdev) {struct iproc_adc_priv *adc_priv;struct iio_dev *indio_dev =NULL ; +struct device *dev = &pdev->dev;int ret; - indio_dev =devm_iio_device_alloc (&pdev->dev, -sizeof (*adc_priv)); + indio_dev =devm_iio_device_alloc (dev,sizeof (*adc_priv));if (!indio_dev)return -ENOMEM ;
@@ -528,7 +528,7 @@ static int iproc_adc_probe(struct platform_device *pdev)return ret; } - adc_priv->adc_clk =devm_clk_get (&pdev->dev,"tsc_clk" ); + adc_priv->adc_clk =devm_clk_get (dev,"tsc_clk" );if (IS_ERR (adc_priv->adc_clk)) {dev_err (&pdev->dev,"failed getting clock tsc_clk\n" );
@@ -547,7 +547,7 @@ static int iproc_adc_probe(struct platform_device *pdev)return ret; } - ret =devm_request_threaded_irq (&pdev->dev, adc_priv->irqno, + ret =devm_request_threaded_irq (dev, adc_priv->irqno, iproc_adc_interrupt_handler, iproc_adc_interrupt_thread,IRQF_SHARED ,"iproc-adc" , indio_dev);
Signature · 1 line
2.43.0
Re: [PATCH v6 2/3] iio: adc: bcm_iproc_adc: Introduce local device pointer
Quoted 5 lines · On Thu, Aug 06, 2026 at 08:09:01AM +0530, [email protected] wrote:
Introduce a local 'struct device *dev' variable in
iproc_adc_probe()and use it for device-managed helper calls instead of repeatedly referencing '&pdev->dev'.No functional change intended.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v6 3/3 iio: adc: bcm_iproc_adc: Convert probe error handling to dev_err_probe()
In reply to [email protected]From: Mohammad Shahid <[email protected]>
Replace open-coded dev_err() followed by return with dev_err_probe() for probe failures that immediately return.
Leave error paths that jump to cleanup labels unchanged to reduce code churn. These paths will be converted separately together with the planned devm-managed cleanup using devm_add_action_or_reset().
--- drivers/iio/adc/bcm_iproc_adc.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-)
drivers/iio/adc/bcm_iproc_adc.c +10 -20
@@ -522,19 +522,14 @@ static int iproc_adc_probe(struct platform_device *pdev) adc_priv->regmap =syscon_regmap_lookup_by_phandle (pdev->dev.of_node,"adc-syscon" ); -if (IS_ERR (adc_priv->regmap)) { -dev_err (&pdev->dev,"failed to get handle for tsc syscon\n" ); - ret =PTR_ERR (adc_priv->regmap); -return ret; - } +if (IS_ERR (adc_priv->regmap)) +return dev_err_probe (dev,PTR_ERR (adc_priv->regmap), +"failed to get handle for tsc syscon\n" ); adc_priv->adc_clk =devm_clk_get (dev,"tsc_clk" ); -if (IS_ERR (adc_priv->adc_clk)) { -dev_err (&pdev->dev, -"failed getting clock tsc_clk\n" ); - ret =PTR_ERR (adc_priv->adc_clk); -return ret; - } +if (IS_ERR (adc_priv->adc_clk)) +return dev_err_probe (dev,PTR_ERR (adc_priv->adc_clk), +"failed getting clock tsc_clk\n" ); adc_priv->irqno =platform_get_irq (pdev,0 );if (adc_priv->irqno <0 )
@@ -542,10 +537,8 @@ static int iproc_adc_probe(struct platform_device *pdev) ret =regmap_clear_bits (adc_priv->regmap,IPROC_REGCTL2 ,IPROC_ADC_AUXIN_SCAN_ENA ); -if (ret) { -dev_err (&pdev->dev,"failed to write IPROC_REGCTL2 %d\n" , ret); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"failed to write IPROC_REGCTL2\n" ); ret = devm_request_threaded_irq(dev, adc_priv->irqno, iproc_adc_interrupt_handler,
@@ -555,11 +548,8 @@ static int iproc_adc_probe(struct platform_device *pdev)return ret; ret =clk_prepare_enable (adc_priv->adc_clk); -if (ret) { -dev_err (&pdev->dev, -"clk_prepare_enable failed %d\n" , ret); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"failed to enable clock\n" ); ret =iproc_adc_enable (indio_dev);if (ret)
Signature · 1 line
2.43.0
Re: [PATCH v6 3/3] iio: adc: bcm_iproc_adc: Convert probe error handling to dev_err_probe()
Quoted 6 lines · On Thu, Aug 06, 2026 at 08:09:02AM +0530, [email protected] wrote:
Replace open-coded
dev_err()followed by return withdev_err_probe()for probe failures that immediately return.Leave error paths that jump to cleanup labels unchanged to reduce code churn. These paths will be converted separately together with the planned devm-managed cleanup using
devm_add_action_or_reset().
...
drivers/iio/adc/bcm_iproc_adc.c static int iproc_adc_probe(struct platform_device *pdev) · line 524
Quoted 2 lines
drivers/iio/adc/bcm_iproc_adc.c +0
-0adc_priv->regmap =syscon_regmap_lookup_by_phandle (pdev->dev.of_node,"adc-syscon" );
Size note: the above can be also amended (since you have a 'dev') to
adc_priv->regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "adc-syscon");
But we can go even further (in a separate patch) and move it to
adc_priv->regmap = syscon_regmap_lookup_by_phandle(dev_of_node(dev), "adc-syscon");
...
Quoted 9 lines
drivers/iio/adc/bcm_iproc_adc.c +2
-6adc_priv->adc_clk =devm_clk_get (dev,"tsc_clk" ); -if (IS_ERR (adc_priv->adc_clk)) { -dev_err (&pdev->dev, -"failed getting clock tsc_clk\n" ); - ret =PTR_ERR (adc_priv->adc_clk); -return ret; - } +if (IS_ERR (adc_priv->adc_clk)) + return dev_err_probe(dev, PTR_ERR(adc_priv->adc_clk),
drivers/iio/adc/bcm_iproc_adc.c static int iproc_adc_probe(struct platform_device *pdev)
Quoted 10 lines
drivers/iio/adc/bcm_iproc_adc.c +3
-5+ "failed getting clock tsc_clk\n"); ret =clk_prepare_enable (adc_priv->adc_clk); -if (ret) { -dev_err (&pdev->dev, -"clk_prepare_enable failed %d\n" , ret); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"failed to enable clock\n" );
This will be less churn if the previous (new) patch will convert this to use devn_clk_get_enabled(). But if Jonathan is okay with this patch as is, you can take my
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerRe: [PATCH v6 3/3] iio: adc: bcm_iproc_adc: Convert probe error handling to dev_err_probe()
Quoted 49 lines · On Mon, 10 Aug 2026 11:32:26 +0300 Andy Shevchenko…
Quoted 6 lines · On Thu, Aug 06, 2026 at 08:09:02AM +0530, [email protected] wrote:
Replace open-coded
dev_err()followed by return withdev_err_probe()for probe failures that immediately return.Leave error paths that jump to cleanup labels unchanged to reduce code churn. These paths will be converted separately together with the planned devm-managed cleanup using
devm_add_action_or_reset()....
drivers/iio/adc/bcm_iproc_adc.c static int iproc_adc_probe(struct platform_device *pdev) · line 524
Quoted 2 lines
drivers/iio/adc/bcm_iproc_adc.c +0
-0adc_priv->regmap =syscon_regmap_lookup_by_phandle (pdev->dev.of_node,"adc-syscon" );Size note: the above can be also amended (since you have a 'dev') to
adc_priv->regmap = syscon_regmap_lookup_by_phandle(dev->of_node, "adc-syscon");But we can go even further (in a separate patch) and move it to
adc_priv->regmap = syscon_regmap_lookup_by_phandle(dev_of_node(dev), "adc-syscon");...
Quoted 9 lines
drivers/iio/adc/bcm_iproc_adc.c +2
-6adc_priv->adc_clk =devm_clk_get (dev,"tsc_clk" ); -if (IS_ERR (adc_priv->adc_clk)) { -dev_err (&pdev->dev, -"failed getting clock tsc_clk\n" ); - ret =PTR_ERR (adc_priv->adc_clk); -return ret; - } +if (IS_ERR (adc_priv->adc_clk)) + return dev_err_probe(dev, PTR_ERR(adc_priv->adc_clk),drivers/iio/adc/bcm_iproc_adc.c static int iproc_adc_probe(struct platform_device *pdev)
Quoted 10 lines
drivers/iio/adc/bcm_iproc_adc.c +3
-5+ "failed getting clock tsc_clk\n"); ret =clk_prepare_enable (adc_priv->adc_clk); -if (ret) { -dev_err (&pdev->dev, -"clk_prepare_enable failed %d\n" , ret); -return ret; - } +if (ret) +return dev_err_probe (dev, ret,"failed to enable clock\n" );This will be less churn if the previous (new) patch will convert this to use
devn_clk_get_enabled(). But if Jonathan is okay with this patch as is, you can take my
Quoted 1 line
Reviewed-by Andy Shevchenko <[email protected]>
Too much in my backlog for me to keep track so I'll merge what we have here and a follow up bit of devm_ work can be a separate series (this time - look for similar opportunities if you do similar work in future!)
Series applied to the testing branch of iio.git.
Jonathan