Re: drivers/iio/accel/kionix-kx022a.c:1053 kx022a_probe_internal() warn: passing zero to 'dev_err_probe'

From: Matti Vaittinen
Date: Fri May 12 2023 - 01:50:00 EST


On 5/12/23 08:41, Dan Carpenter wrote:
On Fri, May 12, 2023 at 08:16:02AM +0300, Matti Vaittinen wrote:
7c1d1677b3227c Matti Vaittinen 2022-10-24 1046 irq = fwnode_irq_get_byname(fwnode, "INT1");
7c1d1677b3227c Matti Vaittinen 2022-10-24 1047 if (irq > 0) {
7c1d1677b3227c Matti Vaittinen 2022-10-24 1048 data->inc_reg = KX022A_REG_INC1;
7c1d1677b3227c Matti Vaittinen 2022-10-24 1049 data->ien_reg = KX022A_REG_INC4;
7c1d1677b3227c Matti Vaittinen 2022-10-24 1050 } else {
7c1d1677b3227c Matti Vaittinen 2022-10-24 1051 irq = fwnode_irq_get_byname(fwnode, "INT2");
7c1d1677b3227c Matti Vaittinen 2022-10-24 1052 if (irq <= 0)
^^^^^^^^
This code assumes fwnode_irq_get_byname() can return zero.

7c1d1677b3227c Matti Vaittinen 2022-10-24 @1053 return dev_err_probe(dev, irq, "No suitable IRQ\n");

But fortunately, it can't otherwise this would return success.


Ouch. Actually, the fwnode_irq_get_byname() can return zero on device-tree
mapping error. I did actually send a patch to address this some time ago:
https://lore.kernel.org/lkml/cover.1666710197.git.mazziesaccount@xxxxxxxxx/


Ah. I just went by the documentation instead of looking at the code.

Originally a bunch of irq functions return NO_IRQ on error which was a
design mistake... irq_of_parse_and_map() still returns zero on error
instead of negative error codes. I wrote a check for that yesterday.

drivers/gpu/drm/msm/dsi/dsi_host.c:1949 msm_dsi_host_init() warn: irq_of_parse_and_map() returns zero on failure
drivers/dma/ti/edma.c:2405 edma_probe() warn: irq_of_parse_and_map() returns zero on failure
drivers/dma/ti/edma.c:2421 edma_probe() warn: irq_of_parse_and_map() returns zero on failure
drivers/net/ethernet/xilinx/ll_temac_main.c:1570 temac_probe() warn: irq_of_parse_and_map() returns zero on failure
drivers/net/ethernet/xilinx/ll_temac_main.c:1573 temac_probe() warn: irq_of_parse_and_map() returns zero on failure
drivers/ata/sata_mv.c:4094 mv_platform_probe() warn: irq_of_parse_and_map() returns zero on failure

It would be good if we could apply your patch, otherwise I could create
an explicit check for fwnode_irq_get_byname() returns.

I guess I can re-spin the series. Let's see if there is some good suggestion(s) on how to fix the i2c-smbus.

Ideally, everything would just return negative error codes on error.

I definitely agree.


Yours,
-- Matti

--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~