* [PATCH] iio: dac: adi-axi-dac: improve probe() error messaging
@ 2024-06-17 15:18 Trevor Gamblin
2024-06-18 8:34 ` Nuno Sá
0 siblings, 1 reply; 3+ messages in thread
From: Trevor Gamblin @ 2024-06-17 15:18 UTC (permalink / raw)
To: Nuno Sa, Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron
Cc: Trevor Gamblin, Angelo Dureghello, linux-iio, linux-kernel
The current error handling for calls such as devm_clk_get_enabled() in
the adi-axi-dac 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_dac 44a00000.dac: probe with driver adi_axi_dac 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 change:
|adi_axi_dac 44a00000.dac: error -ENOENT: failed to get clock
|adi_axi_dac 44a00000.dac: probe with driver adi_axi_dac failed with error -2
Suggested-by: Nuno Sa <nuno.sa@analog.com>
Tested-by: Angelo Dureghello <adureghello@baylibre.com>
Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
---
Added Angelo as Tested-by since he tested the patch on an internal
setup.
---
drivers/iio/dac/adi-axi-dac.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/dac/adi-axi-dac.c b/drivers/iio/dac/adi-axi-dac.c
index 880d83a014a1..6d56428e623d 100644
--- a/drivers/iio/dac/adi-axi-dac.c
+++ b/drivers/iio/dac/adi-axi-dac.c
@@ -545,7 +545,8 @@ static int axi_dac_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");
base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(base))
@@ -555,7 +556,8 @@ static int axi_dac_probe(struct platform_device *pdev)
st->regmap = devm_regmap_init_mmio(&pdev->dev, base,
&axi_dac_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");
/*
* Force disable the core. Up to the frontend to enable us. And we can
@@ -601,7 +603,8 @@ static int axi_dac_probe(struct platform_device *pdev)
mutex_init(&st->lock);
ret = devm_iio_backend_register(&pdev->dev, &axi_dac_generic, st);
if (ret)
- return ret;
+ return dev_err_probe(&pdev->dev, ret,
+ "failed to register iio backend\n");
dev_info(&pdev->dev, "AXI DAC IP core (%d.%.2d.%c) probed\n",
ADI_AXI_PCORE_VER_MAJOR(ver),
--
2.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: dac: adi-axi-dac: improve probe() error messaging
2024-06-17 15:18 [PATCH] iio: dac: adi-axi-dac: improve probe() error messaging Trevor Gamblin
@ 2024-06-18 8:34 ` Nuno Sá
2024-06-22 18:09 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Nuno Sá @ 2024-06-18 8:34 UTC (permalink / raw)
To: Trevor Gamblin, Nuno Sa, Lars-Peter Clausen, Michael Hennerich,
Jonathan Cameron
Cc: Angelo Dureghello, linux-iio, linux-kernel
On Mon, 2024-06-17 at 11:18 -0400, Trevor Gamblin wrote:
> The current error handling for calls such as devm_clk_get_enabled() in
> the adi-axi-dac 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_dac 44a00000.dac: probe with driver adi_axi_dac 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 change:
>
> > adi_axi_dac 44a00000.dac: error -ENOENT: failed to get clock
> > adi_axi_dac 44a00000.dac: probe with driver adi_axi_dac failed with error -2
>
> Suggested-by: Nuno Sa <nuno.sa@analog.com>
> Tested-by: Angelo Dureghello <adureghello@baylibre.com>
> Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
> ---
> Added Angelo as Tested-by since he tested the patch on an internal
> setup.
> ---
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: dac: adi-axi-dac: improve probe() error messaging
2024-06-18 8:34 ` Nuno Sá
@ 2024-06-22 18:09 ` Jonathan Cameron
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2024-06-22 18:09 UTC (permalink / raw)
To: Nuno Sá
Cc: Trevor Gamblin, Nuno Sa, Lars-Peter Clausen, Michael Hennerich,
Angelo Dureghello, linux-iio, linux-kernel
On Tue, 18 Jun 2024 10:34:34 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:
> On Mon, 2024-06-17 at 11:18 -0400, Trevor Gamblin wrote:
> > The current error handling for calls such as devm_clk_get_enabled() in
> > the adi-axi-dac 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_dac 44a00000.dac: probe with driver adi_axi_dac 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 change:
> >
> > > adi_axi_dac 44a00000.dac: error -ENOENT: failed to get clock
> > > adi_axi_dac 44a00000.dac: probe with driver adi_axi_dac failed with error -2
> >
> > Suggested-by: Nuno Sa <nuno.sa@analog.com>
> > Tested-by: Angelo Dureghello <adureghello@baylibre.com>
> > Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
> > ---
> > Added Angelo as Tested-by since he tested the patch on an internal
> > setup.
> > ---
>
> Reviewed-by: Nuno Sa <nuno.sa@analog.com>
>
Applied,
Thanks,
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-22 18:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-17 15:18 [PATCH] iio: dac: adi-axi-dac: improve probe() error messaging Trevor Gamblin
2024-06-18 8:34 ` Nuno Sá
2024-06-22 18:09 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).