public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: adc: adi-axi-adc: improve probe() error messaging
@ 2024-06-13 16:34 Trevor Gamblin
  2024-06-14  9:11 ` Nuno Sá
  0 siblings, 1 reply; 4+ messages in thread
From: Trevor Gamblin @ 2024-06-13 16:34 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron
  Cc: linux-iio, linux-kernel

The current error handling for calls such as devm_clk_get_enabled() in
the adi-axi-adc probe() function means that, if a property such as
'clocks' (for example) is not present in the devicetree when booting a
kernel with the driver enabled, the resulting error message will be
vague, e.g.:

|adi_axi_adc 44a00000.backend: probe with driver adi_axi_adc failed with error -2

Change the devm_clk_get_enabled(), devm_regmap_init_mmio(), and
devm_iio_backend_register() checks to use dev_err_probe() with some
context for easier debugging.

After the fix:

|adi_axi_adc 44a00000.backend: error -ENOENT: failed to get clock
|adi_axi_adc 44a00000.backend: probe with driver adi_axi_adc failed with error -2

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
---
 drivers/iio/adc/adi-axi-adc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c
index 0cf0d81358fd..99998c2769d5 100644
--- a/drivers/iio/adc/adi-axi-adc.c
+++ b/drivers/iio/adc/adi-axi-adc.c
@@ -292,7 +292,8 @@ static int adi_axi_adc_probe(struct platform_device *pdev)
 	st->regmap = devm_regmap_init_mmio(&pdev->dev, base,
 					   &axi_adc_regmap_config);
 	if (IS_ERR(st->regmap))
-		return PTR_ERR(st->regmap);
+		return dev_err_probe(&pdev->dev, PTR_ERR(st->regmap),
+				     "failed to init register map\n");
 
 	expected_ver = device_get_match_data(&pdev->dev);
 	if (!expected_ver)
@@ -300,7 +301,8 @@ static int adi_axi_adc_probe(struct platform_device *pdev)
 
 	clk = devm_clk_get_enabled(&pdev->dev, NULL);
 	if (IS_ERR(clk))
-		return PTR_ERR(clk);
+		return dev_err_probe(&pdev->dev, PTR_ERR(clk),
+				     "failed to get clock\n");
 
 	/*
 	 * Force disable the core. Up to the frontend to enable us. And we can
@@ -328,7 +330,8 @@ static int adi_axi_adc_probe(struct platform_device *pdev)
 
 	ret = devm_iio_backend_register(&pdev->dev, &adi_axi_adc_generic, st);
 	if (ret)
-		return ret;
+		return dev_err_probe(&pdev->dev, ret,
+				     "failed to register iio backend\n");
 
 	dev_info(&pdev->dev, "AXI ADC IP core (%d.%.2d.%c) probed\n",
 		 ADI_AXI_PCORE_VER_MAJOR(ver),
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] iio: adc: adi-axi-adc: improve probe() error messaging
  2024-06-13 16:34 [PATCH] iio: adc: adi-axi-adc: improve probe() error messaging Trevor Gamblin
@ 2024-06-14  9:11 ` Nuno Sá
  2024-06-14 19:18   ` Trevor Gamblin
  0 siblings, 1 reply; 4+ messages in thread
From: Nuno Sá @ 2024-06-14  9:11 UTC (permalink / raw)
  To: Trevor Gamblin, Lars-Peter Clausen, Michael Hennerich,
	Jonathan Cameron
  Cc: linux-iio, linux-kernel

On Thu, 2024-06-13 at 12:34 -0400, Trevor Gamblin wrote:
> The current error handling for calls such as devm_clk_get_enabled() in
> the adi-axi-adc probe() function means that, if a property such as
> 'clocks' (for example) is not present in the devicetree when booting a
> kernel with the driver enabled, the resulting error message will be
> vague, e.g.:
> 
> > adi_axi_adc 44a00000.backend: probe with driver adi_axi_adc failed with error -2
> 
> Change the devm_clk_get_enabled(), devm_regmap_init_mmio(), and
> devm_iio_backend_register() checks to use dev_err_probe() with some
> context for easier debugging.
> 
> After the fix:
> 
> > adi_axi_adc 44a00000.backend: error -ENOENT: failed to get clock
> > adi_axi_adc 44a00000.backend: probe with driver adi_axi_adc failed with error -2
> 
> Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
> ---

Somehow feel that in these cases the error log should come from the functions we're
calling but bah... likely not going happen/change:

Reviewed-by: Nuno Sa <nuno.sa@analog.com>

(As a suggestion, you may do similar work in the axi-dac driver)

- Nuno Sá



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iio: adc: adi-axi-adc: improve probe() error messaging
  2024-06-14  9:11 ` Nuno Sá
@ 2024-06-14 19:18   ` Trevor Gamblin
  2024-06-15 10:40     ` Jonathan Cameron
  0 siblings, 1 reply; 4+ messages in thread
From: Trevor Gamblin @ 2024-06-14 19:18 UTC (permalink / raw)
  To: Nuno Sá, Lars-Peter Clausen, Michael Hennerich,
	Jonathan Cameron
  Cc: linux-iio, linux-kernel


On 2024-06-14 5:11 a.m., Nuno Sá wrote:
> On Thu, 2024-06-13 at 12:34 -0400, Trevor Gamblin wrote:
>> The current error handling for calls such as devm_clk_get_enabled() in
>> the adi-axi-adc probe() function means that, if a property such as
>> 'clocks' (for example) is not present in the devicetree when booting a
>> kernel with the driver enabled, the resulting error message will be
>> vague, e.g.:
>>
>>> adi_axi_adc 44a00000.backend: probe with driver adi_axi_adc failed with error -2
>> Change the devm_clk_get_enabled(), devm_regmap_init_mmio(), and
>> devm_iio_backend_register() checks to use dev_err_probe() with some
>> context for easier debugging.
>>
>> After the fix:
>>
>>> adi_axi_adc 44a00000.backend: error -ENOENT: failed to get clock
>>> adi_axi_adc 44a00000.backend: probe with driver adi_axi_adc failed with error -2
>> Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
>> ---
> Somehow feel that in these cases the error log should come from the functions we're
> calling but bah... likely not going happen/change:
>
> Reviewed-by: Nuno Sa <nuno.sa@analog.com>
>
> (As a suggestion, you may do similar work in the axi-dac driver)

Thanks. I'll send that early next week after a quick test on a board.

Trevor

>
> - Nuno Sá
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iio: adc: adi-axi-adc: improve probe() error messaging
  2024-06-14 19:18   ` Trevor Gamblin
@ 2024-06-15 10:40     ` Jonathan Cameron
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2024-06-15 10:40 UTC (permalink / raw)
  To: Trevor Gamblin
  Cc: Nuno Sá, Lars-Peter Clausen, Michael Hennerich, linux-iio,
	linux-kernel

On Fri, 14 Jun 2024 15:18:12 -0400
Trevor Gamblin <tgamblin@baylibre.com> wrote:

> On 2024-06-14 5:11 a.m., Nuno Sá wrote:
> > On Thu, 2024-06-13 at 12:34 -0400, Trevor Gamblin wrote:  
> >> The current error handling for calls such as devm_clk_get_enabled() in
> >> the adi-axi-adc probe() function means that, if a property such as
> >> 'clocks' (for example) is not present in the devicetree when booting a
> >> kernel with the driver enabled, the resulting error message will be
> >> vague, e.g.:
> >>  
> >>> adi_axi_adc 44a00000.backend: probe with driver adi_axi_adc failed with error -2  
> >> Change the devm_clk_get_enabled(), devm_regmap_init_mmio(), and
> >> devm_iio_backend_register() checks to use dev_err_probe() with some
> >> context for easier debugging.
> >>
> >> After the fix:
> >>  
> >>> adi_axi_adc 44a00000.backend: error -ENOENT: failed to get clock
> >>> adi_axi_adc 44a00000.backend: probe with driver adi_axi_adc failed with error -2  
> >> Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
> >> ---  
> > Somehow feel that in these cases the error log should come from the functions we're
> > calling but bah... likely not going happen/change:
> >
> > Reviewed-by: Nuno Sa <nuno.sa@analog.com>
> >
> > (As a suggestion, you may do similar work in the axi-dac driver)  
> 
> Thanks. I'll send that early next week after a quick test on a board.
I tweaked the commit text to say
After the change:
as I don't want to see this picked up by a bot for stable.

As a side note, you could have taken the opportunity to add
struct device *dev = pdev->dev;
which I think would have reduced a few line lengths without loosing
readability.  Not important though and perhaps not even a good idea :)

Applied to the togreg branch of iio.git and pushed out as testing.
Note I plan to rebase my tree shortly to avoid some merge conflicts
that otherwise occur.  I'll probably do that before I push out
other than as testing.

Thanks,

Jonathan

> 
> Trevor
> 
> >
> > - Nuno Sá
> >
> >  
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-06-15 10:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-13 16:34 [PATCH] iio: adc: adi-axi-adc: improve probe() error messaging Trevor Gamblin
2024-06-14  9:11 ` Nuno Sá
2024-06-14 19:18   ` Trevor Gamblin
2024-06-15 10:40     ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox