Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: dac: adi-axi-dac: improve probe() error messaging

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>
Link: https://patch.msgid.link/20240617151820.3337034-1-tgamblin@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Trevor Gamblin and committed by
Jonathan Cameron
d9b329a9 04eb9499

+6 -3
+6 -3
drivers/iio/dac/adi-axi-dac.c
··· 545 545 546 546 clk = devm_clk_get_enabled(&pdev->dev, NULL); 547 547 if (IS_ERR(clk)) 548 - return PTR_ERR(clk); 548 + return dev_err_probe(&pdev->dev, PTR_ERR(clk), 549 + "failed to get clock\n"); 549 550 550 551 base = devm_platform_ioremap_resource(pdev, 0); 551 552 if (IS_ERR(base)) ··· 556 555 st->regmap = devm_regmap_init_mmio(&pdev->dev, base, 557 556 &axi_dac_regmap_config); 558 557 if (IS_ERR(st->regmap)) 559 - return PTR_ERR(st->regmap); 558 + return dev_err_probe(&pdev->dev, PTR_ERR(st->regmap), 559 + "failed to init register map\n"); 560 560 561 561 /* 562 562 * Force disable the core. Up to the frontend to enable us. And we can ··· 603 601 mutex_init(&st->lock); 604 602 ret = devm_iio_backend_register(&pdev->dev, &axi_dac_generic, st); 605 603 if (ret) 606 - return ret; 604 + return dev_err_probe(&pdev->dev, ret, 605 + "failed to register iio backend\n"); 607 606 608 607 dev_info(&pdev->dev, "AXI DAC IP core (%d.%.2d.%c) probed\n", 609 608 ADI_AXI_PCORE_VER_MAJOR(ver),