* [PATCH v3 0/3] iio: adc: bcm_iproc_adc: Simplify probe error handling
@ 2026-07-31 18:23 mdshahid03
2026-07-31 18:23 ` [PATCH v3 1/3] iio: adc: bcm_iproc_adc: Remove redundant error message after devm_request_threaded_irq() mdshahid03
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: mdshahid03 @ 2026-07-31 18:23 UTC (permalink / raw)
To: Jonathan Cameron, Andy Shevchenko
Cc: Joshua Crofts, Broadcom internal kernel list, David Lechner,
linux-arm-kernel, linux-iio, linux-kernel, Nuno Sá, Ray Jui,
Scott Branden, Mohammad Shahid
From: Mohammad Shahid <mdshahid03@gmail.com>
Hi,
This series simplifies the probe error handling in bcm_iproc_adc.
Changes in v3:
- Split the changes into three patches.
- Remove the redundant dev_err() after devm_request_threaded_irq().
- Introduce a local device pointer.
- Convert the remaining applicable probe error paths to dev_err_probe().
- Keep the original platform_get_irq() and devm_request_threaded_irq().
- Remove the redundant dev_err() after iproc_adc_enable().
- Convert the iio_device_register() error path to dev_err_probe().
Thanks,
Shahid
Mohammad Shahid (3):
iio: adc: bcm_iproc_adc: Remove redundant error message after
devm_request_threaded_irq()
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 | 54 +++++++++++++++------------------
1 file changed, 24 insertions(+), 30 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 1/3] iio: adc: bcm_iproc_adc: Remove redundant error message after devm_request_threaded_irq()
2026-07-31 18:23 [PATCH v3 0/3] iio: adc: bcm_iproc_adc: Simplify probe error handling mdshahid03
@ 2026-07-31 18:23 ` mdshahid03
2026-07-31 18:23 ` [PATCH v3 2/3] iio: adc: bcm_iproc_adc: Introduce local device pointer mdshahid03
2026-07-31 18:23 ` [PATCH v3 3/3] iio: adc: bcm_iproc_adc: Convert probe error handling to dev_err_probe() mdshahid03
2 siblings, 0 replies; 7+ messages in thread
From: mdshahid03 @ 2026-07-31 18:23 UTC (permalink / raw)
To: Jonathan Cameron, Andy Shevchenko
Cc: Joshua Crofts, Broadcom internal kernel list, David Lechner,
linux-arm-kernel, linux-iio, linux-kernel, Nuno Sá, Ray Jui,
Scott Branden, Mohammad Shahid
From: Mohammad Shahid <mdshahid03@gmail.com>
devm_request_threaded_irq() already logs an error when the request
fails, making the explicit dev_err() redundant.
Remove the duplicate message and simply return the error.
Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>
---
drivers/iio/adc/bcm_iproc_adc.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
index cf4738b16e62..1b0dd654402f 100644
--- a/drivers/iio/adc/bcm_iproc_adc.c
+++ b/drivers/iio/adc/bcm_iproc_adc.c
@@ -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) {
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 2/3] iio: adc: bcm_iproc_adc: Introduce local device pointer
2026-07-31 18:23 [PATCH v3 0/3] iio: adc: bcm_iproc_adc: Simplify probe error handling mdshahid03
2026-07-31 18:23 ` [PATCH v3 1/3] iio: adc: bcm_iproc_adc: Remove redundant error message after devm_request_threaded_irq() mdshahid03
@ 2026-07-31 18:23 ` mdshahid03
2026-08-02 1:58 ` Jonathan Cameron
2026-07-31 18:23 ` [PATCH v3 3/3] iio: adc: bcm_iproc_adc: Convert probe error handling to dev_err_probe() mdshahid03
2 siblings, 1 reply; 7+ messages in thread
From: mdshahid03 @ 2026-07-31 18:23 UTC (permalink / raw)
To: Jonathan Cameron, Andy Shevchenko
Cc: Joshua Crofts, Broadcom internal kernel list, David Lechner,
linux-arm-kernel, linux-iio, linux-kernel, Nuno Sá, Ray Jui,
Scott Branden, Mohammad Shahid
From: Mohammad Shahid <mdshahid03@gmail.com>
Introduce a local 'struct device *dev' variable in iproc_adc_probe()
and use it instead of repeatedly referencing '&pdev->dev'.
This simplifies the code and makes subsequent error handling changes
less verbose.
No functional change intended.
Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>
---
drivers/iio/adc/bcm_iproc_adc.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
index 1b0dd654402f..29ea35972a23 100644
--- a/drivers/iio/adc/bcm_iproc_adc.c
+++ b/drivers/iio/adc/bcm_iproc_adc.c
@@ -506,9 +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,
+ indio_dev = devm_iio_device_alloc(dev,
sizeof(*adc_priv));
if (!indio_dev)
return -ENOMEM;
@@ -523,14 +524,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");
+ dev_err(dev, "failed to get handle for tsc syscon\n");
ret = PTR_ERR(adc_priv->regmap);
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,
+ dev_err(dev,
"failed getting clock tsc_clk\n");
ret = PTR_ERR(adc_priv->adc_clk);
return ret;
@@ -543,11 +544,11 @@ 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);
+ dev_err(dev, "failed to write IPROC_REGCTL2 %d\n", ret);
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);
@@ -556,14 +557,14 @@ static int iproc_adc_probe(struct platform_device *pdev)
ret = clk_prepare_enable(adc_priv->adc_clk);
if (ret) {
- dev_err(&pdev->dev,
+ dev_err(dev,
"clk_prepare_enable failed %d\n", ret);
return ret;
}
ret = iproc_adc_enable(indio_dev);
if (ret) {
- dev_err(&pdev->dev, "failed to enable adc %d\n", ret);
+ dev_err(dev, "failed to enable adc %d\n", ret);
goto err_adc_enable;
}
@@ -575,7 +576,7 @@ static int iproc_adc_probe(struct platform_device *pdev)
ret = iio_device_register(indio_dev);
if (ret) {
- dev_err(&pdev->dev, "iio_device_register failed:err %d\n", ret);
+ dev_err(dev, "iio_device_register failed:err %d\n", ret);
goto err_clk;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 3/3] iio: adc: bcm_iproc_adc: Convert probe error handling to dev_err_probe()
2026-07-31 18:23 [PATCH v3 0/3] iio: adc: bcm_iproc_adc: Simplify probe error handling mdshahid03
2026-07-31 18:23 ` [PATCH v3 1/3] iio: adc: bcm_iproc_adc: Remove redundant error message after devm_request_threaded_irq() mdshahid03
2026-07-31 18:23 ` [PATCH v3 2/3] iio: adc: bcm_iproc_adc: Introduce local device pointer mdshahid03
@ 2026-07-31 18:23 ` mdshahid03
2026-08-01 6:45 ` Joshua Crofts
2026-08-02 2:04 ` Jonathan Cameron
2 siblings, 2 replies; 7+ messages in thread
From: mdshahid03 @ 2026-07-31 18:23 UTC (permalink / raw)
To: Jonathan Cameron, Andy Shevchenko
Cc: Joshua Crofts, Broadcom internal kernel list, David Lechner,
linux-arm-kernel, linux-iio, linux-kernel, Nuno Sá, Ray Jui,
Scott Branden, Mohammad Shahid
From: Mohammad Shahid <mdshahid03@gmail.com>
This simplifies the probe error handling by replacing open-coded
dev_err() and return sequences. Also remove the redundant
dev_err() after iproc_adc_enable(), as the helper already reports
the failure.
Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>
---
drivers/iio/adc/bcm_iproc_adc.c | 43 +++++++++++++++------------------
1 file changed, 19 insertions(+), 24 deletions(-)
diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
index 29ea35972a23..5fcd528eb88a 100644
--- a/drivers/iio/adc/bcm_iproc_adc.c
+++ b/drivers/iio/adc/bcm_iproc_adc.c
@@ -523,19 +523,16 @@ 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(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(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)
@@ -543,10 +540,10 @@ 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(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,
@@ -556,17 +553,14 @@ static int iproc_adc_probe(struct platform_device *pdev)
return ret;
ret = clk_prepare_enable(adc_priv->adc_clk);
- if (ret) {
- dev_err(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) {
- dev_err(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;
@@ -576,7 +570,8 @@ static int iproc_adc_probe(struct platform_device *pdev)
ret = iio_device_register(indio_dev);
if (ret) {
- dev_err(dev, "iio_device_register failed:err %d\n", ret);
+ dev_err_probe(dev, ret,
+ "failed to register IIO device\n");
goto err_clk;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v3 3/3] iio: adc: bcm_iproc_adc: Convert probe error handling to dev_err_probe()
2026-07-31 18:23 ` [PATCH v3 3/3] iio: adc: bcm_iproc_adc: Convert probe error handling to dev_err_probe() mdshahid03
@ 2026-08-01 6:45 ` Joshua Crofts
2026-08-02 2:04 ` Jonathan Cameron
1 sibling, 0 replies; 7+ messages in thread
From: Joshua Crofts @ 2026-08-01 6:45 UTC (permalink / raw)
To: mdshahid03
Cc: Jonathan Cameron, Andy Shevchenko, Joshua Crofts,
Broadcom internal kernel list, David Lechner, linux-arm-kernel,
linux-iio, linux-kernel, Nuno Sá, Ray Jui, Scott Branden
On Fri, 31 Jul 2026 23:53:47 +0530
mdshahid03@gmail.com wrote:
> From: Mohammad Shahid <mdshahid03@gmail.com>
>
> This simplifies the probe error handling by replacing open-coded
> dev_err() and return sequences. Also remove the redundant
> dev_err() after iproc_adc_enable(), as the helper already reports
> the failure.
>
> Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>
> ---
> drivers/iio/adc/bcm_iproc_adc.c | 43 +++++++++++++++------------------
> 1 file changed, 19 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
> index 29ea35972a23..5fcd528eb88a 100644
> --- a/drivers/iio/adc/bcm_iproc_adc.c
> +++ b/drivers/iio/adc/bcm_iproc_adc.c
> @@ -523,19 +523,16 @@ 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(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(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)
> @@ -543,10 +540,10 @@ 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(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,
> @@ -556,17 +553,14 @@ static int iproc_adc_probe(struct platform_device *pdev)
> return ret;
>
> ret = clk_prepare_enable(adc_priv->adc_clk);
> - if (ret) {
> - dev_err(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) {
> - dev_err(dev, "failed to enable adc %d\n", ret);
> + if (ret)
I'd say it would be better to move this change to the patch where
you remove the dev_err() at devm_request_threaded_irq().
--
Kind regards,
Joshua Crofts
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 2/3] iio: adc: bcm_iproc_adc: Introduce local device pointer
2026-07-31 18:23 ` [PATCH v3 2/3] iio: adc: bcm_iproc_adc: Introduce local device pointer mdshahid03
@ 2026-08-02 1:58 ` Jonathan Cameron
0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2026-08-02 1:58 UTC (permalink / raw)
To: mdshahid03
Cc: Andy Shevchenko, Joshua Crofts, Broadcom internal kernel list,
David Lechner, linux-arm-kernel, linux-iio, linux-kernel,
Nuno Sá, Ray Jui, Scott Branden
On Fri, 31 Jul 2026 23:53:46 +0530
mdshahid03@gmail.com wrote:
> From: Mohammad Shahid <mdshahid03@gmail.com>
>
> Introduce a local 'struct device *dev' variable in iproc_adc_probe()
> and use it instead of repeatedly referencing '&pdev->dev'.
>
> This simplifies the code and makes subsequent error handling changes
> less verbose.
>
> No functional change intended.
>
> Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>
> ---
> drivers/iio/adc/bcm_iproc_adc.c | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
> index 1b0dd654402f..29ea35972a23 100644
> --- a/drivers/iio/adc/bcm_iproc_adc.c
> +++ b/drivers/iio/adc/bcm_iproc_adc.c
> @@ -506,9 +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,
> + indio_dev = devm_iio_device_alloc(dev,
> sizeof(*adc_priv));
indio_dev = devm_iio_device_alloc(dev, sizeof(*adc_priv));
It fit on one line under 80 chars even before the change but it is even
shorter now so let us tidy this up whilst we are here.
> if (!indio_dev)
> return -ENOMEM;
> @@ -523,14 +524,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");
> + dev_err(dev, "failed to get handle for tsc syscon\n");
This is creating churn we don't need.
Generally I'd suggest only applying the newly available dev where you
aren't going to refactor the line later in the series. Then just
add a note there to say that alongside using dev_err_probe() you are taking
advantage of the now available dev local variable.
> ret = PTR_ERR(adc_priv->regmap);
> 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,
> + dev_err(dev,
> "failed getting clock tsc_clk\n");
Similar on this one.
> ret = PTR_ERR(adc_priv->adc_clk);
> return ret;
> @@ -543,11 +544,11 @@ 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);
> + dev_err(dev, "failed to write IPROC_REGCTL2 %d\n", ret);
and this one.
> 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);
> @@ -556,14 +557,14 @@ static int iproc_adc_probe(struct platform_device *pdev)
>
> ret = clk_prepare_enable(adc_priv->adc_clk);
> if (ret) {
> - dev_err(&pdev->dev,
> + dev_err(dev,
> "clk_prepare_enable failed %d\n", ret);
And here.
> return ret;
> }
>
> ret = iproc_adc_enable(indio_dev);
> if (ret) {
> - dev_err(&pdev->dev, "failed to enable adc %d\n", ret);
> + dev_err(dev, "failed to enable adc %d\n", ret);
you probably get the idea by this point!
> goto err_adc_enable;
> }
>
> @@ -575,7 +576,7 @@ static int iproc_adc_probe(struct platform_device *pdev)
>
> ret = iio_device_register(indio_dev);
> if (ret) {
> - dev_err(&pdev->dev, "iio_device_register failed:err %d\n", ret);
> + dev_err(dev, "iio_device_register failed:err %d\n", ret);
> goto err_clk;
> }
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v3 3/3] iio: adc: bcm_iproc_adc: Convert probe error handling to dev_err_probe()
2026-07-31 18:23 ` [PATCH v3 3/3] iio: adc: bcm_iproc_adc: Convert probe error handling to dev_err_probe() mdshahid03
2026-08-01 6:45 ` Joshua Crofts
@ 2026-08-02 2:04 ` Jonathan Cameron
1 sibling, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2026-08-02 2:04 UTC (permalink / raw)
To: mdshahid03
Cc: Andy Shevchenko, Joshua Crofts, Broadcom internal kernel list,
David Lechner, linux-arm-kernel, linux-iio, linux-kernel,
Nuno Sá, Ray Jui, Scott Branden
On Fri, 31 Jul 2026 23:53:47 +0530
mdshahid03@gmail.com wrote:
> From: Mohammad Shahid <mdshahid03@gmail.com>
>
> This simplifies the probe error handling by replacing open-coded
> dev_err() and return sequences. Also remove the redundant
> dev_err() after iproc_adc_enable(), as the helper already reports
> the failure.
>
> Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>
> ---
> drivers/iio/adc/bcm_iproc_adc.c | 43 +++++++++++++++------------------
> 1 file changed, 19 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
> index 29ea35972a23..5fcd528eb88a 100644
> --- a/drivers/iio/adc/bcm_iproc_adc.c
> +++ b/drivers/iio/adc/bcm_iproc_adc.c
> @@ -523,19 +523,16 @@ 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(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");
Look for places to wrap less as part of this change. E.g.
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(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),
Same here.
> + "failed getting clock tsc_clk\n");
>
> adc_priv->irqno = platform_get_irq(pdev, 0);
> if (adc_priv->irqno < 0)
> @@ -543,10 +540,10 @@ 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(dev, "failed to write IPROC_REGCTL2 %d\n", ret);
> - return ret;
> - }
> + if (ret)
> + return dev_err_probe(dev,
Definitely the same here!
> + ret,
> + "failed to write IPROC_REGCTL2\n");
>
> ret = devm_request_threaded_irq(dev, adc_priv->irqno,
> iproc_adc_interrupt_handler,
> @@ -556,17 +553,14 @@ static int iproc_adc_probe(struct platform_device *pdev)
> return ret;
>
> ret = clk_prepare_enable(adc_priv->adc_clk);
This should be combined with the get (be careful on ordering
> - if (ret) {
> - dev_err(dev,
> - "clk_prepare_enable failed %d\n", ret);
> - return ret;
> - }
> + if (ret)
> + return dev_err_probe(dev,
and here.
The local style before this patch was a bit odd. No need to keep it.
> + ret,
> + "failed to enable clock\n");
>
> ret = iproc_adc_enable(indio_dev);
> - if (ret) {
> - dev_err(dev, "failed to enable adc %d\n", ret);
> + if (ret)
> goto err_adc_enable;
Look at converting the whole thing to devm managed cleanup. You'll
need one custom cleanup function and devm_add_action_or_reset()
> - }
>
> indio_dev->name = "iproc-static-adc";
> indio_dev->info = &iproc_adc_iio_info;
> @@ -576,7 +570,8 @@ static int iproc_adc_probe(struct platform_device *pdev)
>
> ret = iio_device_register(indio_dev);
> if (ret) {
> - dev_err(dev, "iio_device_register failed:err %d\n", ret);
> + dev_err_probe(dev, ret,
> + "failed to register IIO device\n");
dev_err_probe() is as you see much less of an improvement when
we aren't returning. If we switch the whole thing to devm managed
cleanup then we will be returning here. If you make that change
I don't mind if you flip to return dev_err_probe() directly in that
patch to avoid unnecessary code churn.
thanks
Jonathan
> goto err_clk;
> }
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-08-02 2:04 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-31 18:23 [PATCH v3 0/3] iio: adc: bcm_iproc_adc: Simplify probe error handling mdshahid03
2026-07-31 18:23 ` [PATCH v3 1/3] iio: adc: bcm_iproc_adc: Remove redundant error message after devm_request_threaded_irq() mdshahid03
2026-07-31 18:23 ` [PATCH v3 2/3] iio: adc: bcm_iproc_adc: Introduce local device pointer mdshahid03
2026-08-02 1:58 ` Jonathan Cameron
2026-07-31 18:23 ` [PATCH v3 3/3] iio: adc: bcm_iproc_adc: Convert probe error handling to dev_err_probe() mdshahid03
2026-08-01 6:45 ` Joshua Crofts
2026-08-02 2:04 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox