Skip to content

fix fwnode_irq_get[_byname()] returnvalue

Matti Vaittinen linux-gpio linux-i2c linux-iio linux-mips lkml netdev 5 versions – NAK

Status from this message: NAK.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v8 Latest8 patches 5 repliesNAK
  2. v79 patches 4 repliesSuperseded
  3. v68 patches 7 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v58 patches9 repliesSuperseded
v47 patches9 repliesSuperseded

Changes in v8 from the cover letter

- drop ptach 1/N which was merged during 6.4 development.
- rebase on top of the v6.5-rc4.

Patches in v8

#Subject and filesSizeRepliesApplied
1/8iio: mb1232: relax return value check for IRQ getdrivers/iio/proximity/mb1232.c+2 -51 reply
2/8iio: cdc: ad7150: relax return value check for IRQ getdrivers/iio/cdc/ad7150.c+5 -51 reply
3/8pinctrl: wpcm450: relax return value check for IRQ getdrivers/pinctrl/nuvoton/pinctrl-wpcm450.c+0 -20 replies
4/8pinctrl: ingenic: relax return value check for IRQ getdrivers/pinctrl/pinctrl-ingenic.c+0 -20 replies
5/8pinctrl: pistachio: relax return value check for IRQ getdrivers/pinctrl/pinctrl-pistachio.c+0 -60 replies
6/8i2c: i2c-smbus: fwnode_irq_get_byname() return value fixdrivers/i2c/i2c-smbus.c+1 -10 replies
7/8net-next: mvpp2: relax return value check for IRQ getdrivers/net/ethernet/marvell/mvpp2/mvpp2_main.c+2 -22 replies
8/8net-next: mvpp2: don't shadow errordrivers/net/ethernet/marvell/mvpp2/mvpp2_main.c+5 -51 reply

Reviews trailers per patch

6 of 8 patches have a Reviewed-by or Acked-by.

PatchJonathan CameronJonathan NeuschäferLinus WalleijPaul CercueilSakari AilusAndy Shevchenko
1/8A-b R-b
2/8R-b
3/8R-b R-b A-b
4/8R-b A-b R-b
5/8R-b A-b
6/8R-b R-b R-b
7/8
8/8

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 6 reviewers.

Read the v8 thread

Cover letter [PATCH v8 0/8] fix fwnode_irq_get[_byname()] returnvalue

The fwnode_irq_get() and the fwnode_irq_get_byname() may have returned zero if mapping the IRQ fails. This contradicts the fwnode_irq_get_byname() documentation. Furthermore, returning zero or errno on error is unepected and can easily lead to problems like:

int probe(foo)
{
...

	ret = fwnode_irq_get_byname(...);
	if (ret < 0)
		return ret;

...
}

or

int probe(foo)
{
...

	ret = fwnode_irq_get_byname(...);
	if (ret <= 0)
		return ret;

...
}

which are both likely to be wrong. First treats zero as successful call and misses the IRQ mapping failure. Second returns zero from probe even though it detects the IRQ mapping failure correvtly.

Thus the fwnode_irq_get() and the fwnode_irq_get_byname() were changed to always return a negative errno upon failure.

https://lore.kernel.org/all/[email protected]/

This is a clean-up patch to adjust callers. Please note that callers were audited based on v6.4-rc2:

fwnode_irq_get_byname():
drivers/i2c/i2c-smbus.c
drivers/iio/accel/adxl355_core.c
drivers/iio/accel/kionix-kx022a.c
drivers/iio/adc/ad4130.c
drivers/iio/adc/max11410.c
drivers/iio/addac/ad74115.c
drivers/iio/gyro/fxas21002c_core.c
drivers/iio/imu/adis16480.c
drivers/iio/imu/bmi160/bmi160_core.c
drivers/iio/imu/bmi160/bmi160_core.c

fwnode_irq_get():
drivers/gpio/gpio-dwapb.c
drivers/iio/chemical/scd30_serial.c
drivers/iio/proximity/mb1232.c
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
drivers/net/mdio/fwnode_mdio.c
drivers/pinctrl/pinctrl-ingenic.c
drivers/pinctrl/pinctrl-microchip-sgpio.c
drivers/pinctrl/pinctrl-pistachio.c

and it seems to me these calls will be Ok after this clean-up. The i2c-smbus.c and kionix-kx022a.c will gain a functional change (bugfix?) as after this patch the probe will return -EINVAL should the IRQ mapping fail. The series will also adjust the return value check for zero to be omitted.

NOTES:

Changes are compile-tested only.

drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
will also gain a functional change. The pinctrl-wpcm450.c change is easy to see - after this series the device-tree mapping failures will be handled as any other errors - probe will be aborted with -EINVAL. Other feasible option could be treating other errors in IRQ getting same way as the DT mapping failures - just silently skip the IRQ. Please see comment in the respective patch.

drivers/iio/cdc/ad7150.c
Changed logic so that all the IRQ getting errors jump to the same 'no-IRQ' branch as the DT mapping error did.

Revision history:
v7 => v8:
- drop ptach 1/N which was merged during 6.4 development.
- rebase on top of the v6.5-rc4.
v6 => v7:
- re-ordered patches per subsystem
- mvpp2 - added a patch for not shadowing the return value
v5 => v6:
- iio: cdc: ad7150 - never abort probe if IRQ getting fails
v4 => v5:
- Fix subject lines for mvpp2 and wpcm450
- drop unnecessary irqno assignment from mb1232
- add back the drivers/i2c/i2c-smbus.c change which was accidentally dropped during v3 => v4 work
v3 => v4:
- Change also the fwnode_irq_get() as was suggested by Jonathan.
Changelog v2 => v3:
- rebase/resend/add kx022a fix.
Changelog v1 => v2:
- minor styling

---

Matti Vaittinen (8):
iio: mb1232: relax return value check for IRQ get
iio: cdc: ad7150: relax return value check for IRQ get
pinctrl: wpcm450: relax return value check for IRQ get
pinctrl: ingenic: relax return value check for IRQ get
pinctrl: pistachio: relax return value check for IRQ get
i2c: i2c-smbus: fwnode_irq_get_byname() return value fix
net-next: mvpp2: relax return value check for IRQ get
net-next: mvpp2: don't shadow error

 drivers/i2c/i2c-smbus.c                         |  2 +-
 drivers/iio/cdc/ad7150.c                        | 10 +++++-----
 drivers/iio/proximity/mb1232.c                  |  7 ++-----
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 12 ++++++------
 drivers/pinctrl/nuvoton/pinctrl-wpcm450.c       |  2 --
 drivers/pinctrl/pinctrl-ingenic.c               |  2 --
 drivers/pinctrl/pinctrl-pistachio.c             |  6 ------
 7 files changed, 14 insertions(+), 27 deletions(-)

base-commit: 5d0c230f1de8c7515b6567d9afba1f196fb4e2f4

Signature · 14 lines
2.40.1


-- 
Matti Vaittinen, Linux device drivers
ROHM Semiconductors, Finland SWDC
Kiviharjunlenkki 1E
90220 OULU
FINLAND

~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
Simon says - in Latin please.
~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
Thanks to Simon Glass for the translation =]