Skip to content

Commit 40c0f07

Browse files
threexcjic23
authored andcommitted
iio: adc: adi-axi-adc: improve probe() error messaging
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 change: |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> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Link: https://patch.msgid.link/20240613163407.2147884-1-tgamblin@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 2046047 commit 40c0f07

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/iio/adc/adi-axi-adc.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,15 +308,17 @@ static int adi_axi_adc_probe(struct platform_device *pdev)
308308
st->regmap = devm_regmap_init_mmio(&pdev->dev, base,
309309
&axi_adc_regmap_config);
310310
if (IS_ERR(st->regmap))
311-
return PTR_ERR(st->regmap);
311+
return dev_err_probe(&pdev->dev, PTR_ERR(st->regmap),
312+
"failed to init register map\n");
312313

313314
expected_ver = device_get_match_data(&pdev->dev);
314315
if (!expected_ver)
315316
return -ENODEV;
316317

317318
clk = devm_clk_get_enabled(&pdev->dev, NULL);
318319
if (IS_ERR(clk))
319-
return PTR_ERR(clk);
320+
return dev_err_probe(&pdev->dev, PTR_ERR(clk),
321+
"failed to get clock\n");
320322

321323
/*
322324
* Force disable the core. Up to the frontend to enable us. And we can
@@ -344,7 +346,8 @@ static int adi_axi_adc_probe(struct platform_device *pdev)
344346

345347
ret = devm_iio_backend_register(&pdev->dev, &adi_axi_adc_generic, st);
346348
if (ret)
347-
return ret;
349+
return dev_err_probe(&pdev->dev, ret,
350+
"failed to register iio backend\n");
348351

349352
dev_info(&pdev->dev, "AXI ADC IP core (%d.%.2d.%c) probed\n",
350353
ADI_AXI_PCORE_VER_MAJOR(ver),

0 commit comments

Comments
 (0)