netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/7] fix fwnode_irq_get[_byname()] returnvalue
@ 2023-05-16  7:12 Matti Vaittinen
  2023-05-16  7:12 ` [PATCH v4 1/7] drivers: fwnode: fix fwnode_irq_get[_byname]() Matti Vaittinen
                   ` (7 more replies)
  0 siblings, 8 replies; 17+ messages in thread
From: Matti Vaittinen @ 2023-05-16  7:12 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Rafael J. Wysocki, Lars-Peter Clausen,
	Michael Hennerich, Jonathan Cameron, Andreas Klinger,
	Marcin Wojtas, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jonathan Neuschäfer,
	Linus Walleij, Paul Cercueil, Wolfram Sang, Akhil R, linux-acpi,
	linux-kernel, linux-iio, netdev, openbmc, linux-gpio, linux-mips

[-- Attachment #1: Type: text/plain, Size: 4138 bytes --]

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.

Here we change the fwnode_irq_get() and the fwnode_irq_get_byname() to
always return a negative errno upon failure.

I have audited following callers (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 the change. 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
will gain functional change as well. Here the logic is less
straightforward but boils down to the same question as with the
pinctrl-wpcm450.c. Should all the IRQ getting errors jump to same
'no-IRQ' branch as the DT mapping error, or should the DT mapping error
abort the probe with error same way as other IRQ getting failures do?

Revision history:
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 (7):
  drivers: fwnode: fix fwnode_irq_get[_byname]()
  iio: mb1232: relax return value check for IRQ get
  net-next: mb1232: relax return value check for IRQ get
  pinctrl: wpcm450: elax return value check for IRQ get
  pinctrl: ingenic: relax return value check for IRQ get
  pinctrl: pistachio: relax return value check for IRQ get
  iio: cdc: ad7150: Functional change

 drivers/base/property.c                         | 12 +++++++++---
 drivers/iio/cdc/ad7150.c                        |  3 +--
 drivers/iio/proximity/mb1232.c                  |  4 ++--
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c |  4 ++--
 drivers/pinctrl/nuvoton/pinctrl-wpcm450.c       |  2 --
 drivers/pinctrl/pinctrl-ingenic.c               |  2 --
 drivers/pinctrl/pinctrl-pistachio.c             |  6 ------
 7 files changed, 14 insertions(+), 19 deletions(-)


base-commit: f1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6
-- 
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 =] 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v4 1/7] drivers: fwnode: fix fwnode_irq_get[_byname]()
  2023-05-16  7:12 [PATCH v4 0/7] fix fwnode_irq_get[_byname()] returnvalue Matti Vaittinen
@ 2023-05-16  7:12 ` Matti Vaittinen
  2023-05-16  7:12 ` [PATCH v4 2/7] iio: mb1232: relax return value check for IRQ get Matti Vaittinen
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Matti Vaittinen @ 2023-05-16  7:12 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Rafael J. Wysocki, Lars-Peter Clausen,
	Michael Hennerich, Jonathan Cameron, Andreas Klinger,
	Marcin Wojtas, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jonathan Neuschäfer,
	Linus Walleij, Paul Cercueil, Wolfram Sang, Akhil R, linux-acpi,
	linux-kernel, linux-iio, netdev, openbmc, linux-gpio, linux-mips

[-- Attachment #1: Type: text/plain, Size: 2382 bytes --]

The fwnode_irq_get() and the fwnode_irq_get_byname() return 0 upon
device-tree IRQ mapping failure. This is contradicting the
fwnode_irq_get_byname() function documentation and can potentially be a
source of errors like:

int probe(...) {
	...

	irq = fwnode_irq_get_byname();
	if (irq <= 0)
		return irq;

	...
}

Here we do correctly check the return value from fwnode_irq_get_byname()
but the driver probe will now return success. (There was already one
such user in-tree).

Change the fwnode_irq_get_byname() to work as documented and make also the
fwnode_irq_get() follow same common convention returning a negative errno
upon failure.

Fixes: ca0acb511c21 ("device property: Add fwnode_irq_get_byname")
Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>

---
I dropped the existing reviewed-by tags because change to
fwnode_irq_get() was added.

Revision history:
v3 => v4:
 - Change also the fwnode_irq_get()
---
 drivers/base/property.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/base/property.c b/drivers/base/property.c
index f6117ec9805c..8c40abed7852 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -987,12 +987,18 @@ EXPORT_SYMBOL(fwnode_iomap);
  * @fwnode:	Pointer to the firmware node
  * @index:	Zero-based index of the IRQ
  *
- * Return: Linux IRQ number on success. Other values are determined
- * according to acpi_irq_get() or of_irq_get() operation.
+ * Return: Linux IRQ number on success. Negative errno on failure.
  */
 int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index)
 {
-	return fwnode_call_int_op(fwnode, irq_get, index);
+	int ret;
+
+	ret = fwnode_call_int_op(fwnode, irq_get, index);
+	/* We treat mapping errors as invalid case */
+	if (ret == 0)
+		return -EINVAL;
+
+	return ret;
 }
 EXPORT_SYMBOL(fwnode_irq_get);
 
-- 
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 =] 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 2/7] iio: mb1232: relax return value check for IRQ get
  2023-05-16  7:12 [PATCH v4 0/7] fix fwnode_irq_get[_byname()] returnvalue Matti Vaittinen
  2023-05-16  7:12 ` [PATCH v4 1/7] drivers: fwnode: fix fwnode_irq_get[_byname]() Matti Vaittinen
@ 2023-05-16  7:12 ` Matti Vaittinen
  2023-05-17 16:47   ` Andy Shevchenko
  2023-05-16  7:12 ` [PATCH v4 3/7] net-next: " Matti Vaittinen
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Matti Vaittinen @ 2023-05-16  7:12 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Rafael J. Wysocki, Lars-Peter Clausen,
	Michael Hennerich, Jonathan Cameron, Andreas Klinger,
	Marcin Wojtas, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jonathan Neuschäfer,
	Linus Walleij, Paul Cercueil, Wolfram Sang, Akhil R, linux-acpi,
	linux-kernel, linux-iio, netdev, openbmc, linux-gpio, linux-mips

[-- Attachment #1: Type: text/plain, Size: 1537 bytes --]

fwnode_irq_get() was changed to not return 0 anymore.

Drop check for return value 0.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>

---

The first patch of the series changes the fwnode_irq_get() so this depends
on the first patch of the series and should not be applied alone.
---
 drivers/iio/proximity/mb1232.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/proximity/mb1232.c b/drivers/iio/proximity/mb1232.c
index e70cac8240af..2ab3e3fb2bae 100644
--- a/drivers/iio/proximity/mb1232.c
+++ b/drivers/iio/proximity/mb1232.c
@@ -76,7 +76,7 @@ static s16 mb1232_read_distance(struct mb1232_data *data)
 		goto error_unlock;
 	}
 
-	if (data->irqnr >= 0) {
+	if (data->irqnr > 0) {
 		/* it cannot take more than 100 ms */
 		ret = wait_for_completion_killable_timeout(&data->ranging,
 									HZ/10);
@@ -212,7 +212,7 @@ static int mb1232_probe(struct i2c_client *client)
 	init_completion(&data->ranging);
 
 	data->irqnr = fwnode_irq_get(dev_fwnode(&client->dev), 0);
-	if (data->irqnr <= 0) {
+	if (data->irqnr < 0) {
 		/* usage of interrupt is optional */
 		data->irqnr = -1;
 	} else {
-- 
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 =] 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 3/7] net-next: mb1232: relax return value check for IRQ get
  2023-05-16  7:12 [PATCH v4 0/7] fix fwnode_irq_get[_byname()] returnvalue Matti Vaittinen
  2023-05-16  7:12 ` [PATCH v4 1/7] drivers: fwnode: fix fwnode_irq_get[_byname]() Matti Vaittinen
  2023-05-16  7:12 ` [PATCH v4 2/7] iio: mb1232: relax return value check for IRQ get Matti Vaittinen
@ 2023-05-16  7:12 ` Matti Vaittinen
  2023-05-16  7:13 ` [PATCH v4 4/7] pinctrl: wpcm450: elax " Matti Vaittinen
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Matti Vaittinen @ 2023-05-16  7:12 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Rafael J. Wysocki, Lars-Peter Clausen,
	Michael Hennerich, Jonathan Cameron, Andreas Klinger,
	Marcin Wojtas, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jonathan Neuschäfer,
	Linus Walleij, Paul Cercueil, Wolfram Sang, Akhil R, linux-acpi,
	linux-kernel, linux-iio, netdev, openbmc, linux-gpio, linux-mips

[-- Attachment #1: Type: text/plain, Size: 1586 bytes --]

fwnode_irq_get[_byname]() were changed to not return 0 anymore.

Drop check for return value 0.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>

---

The first patch of the series changes the fwnode_irq_get() so this depends
on the first patch of the series and should not be applied alone.
---
 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index adc953611913..5b987af306a5 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -5833,7 +5833,7 @@ static int mvpp2_multi_queue_vectors_init(struct mvpp2_port *port,
 			v->irq = of_irq_get_byname(port_node, irqname);
 		else
 			v->irq = fwnode_irq_get(port->fwnode, i);
-		if (v->irq <= 0) {
+		if (v->irq < 0) {
 			ret = -EINVAL;
 			goto err;
 		}
@@ -6764,7 +6764,7 @@ static int mvpp2_port_probe(struct platform_device *pdev,
 		err = -EPROBE_DEFER;
 		goto err_deinit_qvecs;
 	}
-	if (port->port_irq <= 0)
+	if (port->port_irq < 0)
 		/* the link irq is optional */
 		port->port_irq = 0;
 
-- 
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 =] 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 4/7] pinctrl: wpcm450: elax return value check for IRQ get
  2023-05-16  7:12 [PATCH v4 0/7] fix fwnode_irq_get[_byname()] returnvalue Matti Vaittinen
                   ` (2 preceding siblings ...)
  2023-05-16  7:12 ` [PATCH v4 3/7] net-next: " Matti Vaittinen
@ 2023-05-16  7:13 ` Matti Vaittinen
  2023-05-16 16:32   ` Jonathan Neuschäfer
  2023-05-16  7:13 ` [PATCH v4 5/7] pinctrl: ingenic: relax " Matti Vaittinen
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Matti Vaittinen @ 2023-05-16  7:13 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Rafael J. Wysocki, Lars-Peter Clausen,
	Michael Hennerich, Jonathan Cameron, Andreas Klinger,
	Marcin Wojtas, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jonathan Neuschäfer,
	Linus Walleij, Paul Cercueil, Wolfram Sang, Akhil R, linux-acpi,
	linux-kernel, linux-iio, netdev, openbmc, linux-gpio, linux-mips

[-- Attachment #1: Type: text/plain, Size: 2984 bytes --]

fwnode_irq_get[_byname]() were changed to not return 0 anymore. The
special error case where device-tree based IRQ mapping fails can't no
longer be reliably detected from this return value. This yields a
functional change in the driver where the mapping failure is treated as
an error.

The mapping failure can occur for example when the device-tree IRQ
information translation call-back(s) (xlate) fail, IRQ domain is not
found, IRQ type conflicts, etc. In most cases this indicates an error in
the device-tree and special handling is not really required.

One more thing to note is that ACPI APIs do not return zero for any
failures so this special handling did only apply on device-tree based
systems.

Drop the special (no error, just skip the IRQ) handling for DT mapping
failures as these can no longer be separated from other errors at driver
side.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>

---

The special handling in this driver was added when fixing a problem
where returning zero from fwnode_irq_get[_byname]() was treated as
succes yielding zero being used as a valid IRQ by the driver.
f4a31facfa80 ("pinctrl: wpcm450: Correct the fwnode_irq_get() return value check")
The commit message does not mention if choosing not to abort the probe
on device-tree mapping failure (as is done on other errors) was chosen
because: a) Abort would have broken some existing setup. b) Because skipping
an IRQ on failure is "the right thing to do", or c) because it sounded like
a way to minimize risk of breaking something.

If the reason is a) - then I'd appreciate receiving some more
information and a suggestion how to proceed (if possible). If the reason
is b), then it might be best to just skip the IRQ instead of aborting
the probe for all errors on IRQ getting. Finally, in case of c), well,
by acking this change you will now accept the risk :)

The first patch of the series changes the fwnode_irq_get() so this depends
on the first patch of the series and should not be applied alone.
---
 drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
index 2d1c1652cfd9..f9326210b5eb 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
@@ -1106,8 +1106,6 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
 			irq = fwnode_irq_get(child, i);
 			if (irq < 0)
 				break;
-			if (!irq)
-				continue;
 
 			girq->parents[i] = irq;
 			girq->num_parents++;
-- 
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 =] 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 5/7] pinctrl: ingenic: relax return value check for IRQ get
  2023-05-16  7:12 [PATCH v4 0/7] fix fwnode_irq_get[_byname()] returnvalue Matti Vaittinen
                   ` (3 preceding siblings ...)
  2023-05-16  7:13 ` [PATCH v4 4/7] pinctrl: wpcm450: elax " Matti Vaittinen
@ 2023-05-16  7:13 ` Matti Vaittinen
  2023-05-16  7:49   ` Paul Cercueil
  2023-05-16  7:13 ` [PATCH v4 6/7] pinctrl: pistachio: " Matti Vaittinen
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Matti Vaittinen @ 2023-05-16  7:13 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Rafael J. Wysocki, Lars-Peter Clausen,
	Michael Hennerich, Jonathan Cameron, Andreas Klinger,
	Marcin Wojtas, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jonathan Neuschäfer,
	Linus Walleij, Paul Cercueil, Wolfram Sang, Akhil R, linux-acpi,
	linux-kernel, linux-iio, netdev, openbmc, linux-gpio, linux-mips

[-- Attachment #1: Type: text/plain, Size: 1196 bytes --]

fwnode_irq_get[_byname]() were changed to not return 0 anymore.

Drop check for return value 0.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>

---

The first patch of the series changes the fwnode_irq_get() so this depends
on the first patch of the series and should not be applied alone.
---
 drivers/pinctrl/pinctrl-ingenic.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
index 2f220a47b749..86e71ad703a5 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -4201,8 +4201,6 @@ static int __init ingenic_gpio_probe(struct ingenic_pinctrl *jzpc,
 	err = fwnode_irq_get(fwnode, 0);
 	if (err < 0)
 		return err;
-	if (!err)
-		return -EINVAL;
 	jzgc->irq = err;
 
 	girq = &jzgc->gc.irq;
-- 
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 =] 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 6/7] pinctrl: pistachio: relax return value check for IRQ get
  2023-05-16  7:12 [PATCH v4 0/7] fix fwnode_irq_get[_byname()] returnvalue Matti Vaittinen
                   ` (4 preceding siblings ...)
  2023-05-16  7:13 ` [PATCH v4 5/7] pinctrl: ingenic: relax " Matti Vaittinen
@ 2023-05-16  7:13 ` Matti Vaittinen
  2023-05-16  7:14 ` [PATCH v4 7/7] iio: cdc: ad7150: Functional change Matti Vaittinen
  2023-05-17 12:43 ` [PATCH v4 0/7] fix fwnode_irq_get[_byname()] returnvalue Linus Walleij
  7 siblings, 0 replies; 17+ messages in thread
From: Matti Vaittinen @ 2023-05-16  7:13 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Rafael J. Wysocki, Lars-Peter Clausen,
	Michael Hennerich, Jonathan Cameron, Andreas Klinger,
	Marcin Wojtas, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jonathan Neuschäfer,
	Linus Walleij, Paul Cercueil, Wolfram Sang, Akhil R, linux-acpi,
	linux-kernel, linux-iio, netdev, openbmc, linux-gpio, linux-mips

[-- Attachment #1: Type: text/plain, Size: 1342 bytes --]

fwnode_irq_get[_byname]() were changed to not return 0 anymore.

Drop check for return value 0.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>

---

The first patch of the series changes the fwnode_irq_get() so this depends
on the first patch of the series and should not be applied alone.
---
 drivers/pinctrl/pinctrl-pistachio.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-pistachio.c b/drivers/pinctrl/pinctrl-pistachio.c
index 53408344927a..8c50e0091b32 100644
--- a/drivers/pinctrl/pinctrl-pistachio.c
+++ b/drivers/pinctrl/pinctrl-pistachio.c
@@ -1393,12 +1393,6 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
 			dev_err(pctl->dev, "Failed to retrieve IRQ for bank %u\n", i);
 			goto err;
 		}
-		if (!ret) {
-			fwnode_handle_put(child);
-			dev_err(pctl->dev, "No IRQ for bank %u\n", i);
-			ret = -EINVAL;
-			goto err;
-		}
 		irq = ret;
 
 		bank = &pctl->gpio_banks[i];
-- 
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 =] 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v4 7/7] iio: cdc: ad7150: Functional change
  2023-05-16  7:12 [PATCH v4 0/7] fix fwnode_irq_get[_byname()] returnvalue Matti Vaittinen
                   ` (5 preceding siblings ...)
  2023-05-16  7:13 ` [PATCH v4 6/7] pinctrl: pistachio: " Matti Vaittinen
@ 2023-05-16  7:14 ` Matti Vaittinen
  2023-05-17 12:43 ` [PATCH v4 0/7] fix fwnode_irq_get[_byname()] returnvalue Linus Walleij
  7 siblings, 0 replies; 17+ messages in thread
From: Matti Vaittinen @ 2023-05-16  7:14 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Rafael J. Wysocki, Lars-Peter Clausen,
	Michael Hennerich, Jonathan Cameron, Andreas Klinger,
	Marcin Wojtas, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jonathan Neuschäfer,
	Linus Walleij, Paul Cercueil, Wolfram Sang, Akhil R, linux-acpi,
	linux-kernel, linux-iio, netdev, openbmc, linux-gpio, linux-mips

[-- Attachment #1: Type: text/plain, Size: 3428 bytes --]

fwnode_irq_get[_byname]() were changed to not return 0 anymore. The
special error case where device-tree based IRQ mapping fails can't no
longer be reliably detected from this return value. This yields a
functional change in the driver where the mapping failure is treated as
an error.

The mapping failure can occur for example when the device-tree IRQ
information translation call-back(s) (xlate) fail, IRQ domain is not
found, IRQ type conflicts, etc. In most cases this indicates an error in
the device-tree and special handling is not really required.

One more thing to note is that ACPI APIs do not return zero for any
failures so this special handling did only apply on device-tree based
systems.

Drop the special handling for DT mapping failures as these can no longer
be separated from other errors at driver side.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>

---

Please note that I don't have the hardware to test this change.
Furthermore, testing this type of device-tree error cases is not
trivial, as the question we probably dive in is "what happens with the
existing users who have errors in the device-tree". Answering to this
question is not simple.

I did this patch with minimal code changes - but a question is if we
should really jump into the else branch below on all IRQ getting errors?

        } else {
                indio_dev->info = &ad7150_info_no_irq;
                switch (id->driver_data) {
                case AD7150:
                        indio_dev->channels = ad7150_channels_no_irq;
                        indio_dev->num_channels =
                                ARRAY_SIZE(ad7150_channels_no_irq);
                        break;
                case AD7151:
                        indio_dev->channels = ad7151_channels_no_irq;
                        indio_dev->num_channels =
                                ARRAY_SIZE(ad7151_channels_no_irq);
                        break;
                default:
                        return -EINVAL;
                }

Why do we have special handling for !chip->interrupts[0] while other
errors on getting the fwnode_irq_get(dev_fwnode(&client->dev), 0); will
abort the probe?

The first patch of the series changes the fwnode_irq_get() so this depends
on the first patch of the series and should not be applied alone.
---
 drivers/iio/cdc/ad7150.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iio/cdc/ad7150.c b/drivers/iio/cdc/ad7150.c
index 79aeb0aaea67..d7ba50b9780d 100644
--- a/drivers/iio/cdc/ad7150.c
+++ b/drivers/iio/cdc/ad7150.c
@@ -567,8 +567,7 @@ static int ad7150_probe(struct i2c_client *client)
 		if (chip->interrupts[1] < 0)
 			return chip->interrupts[1];
 	}
-	if (chip->interrupts[0] &&
-	    (id->driver_data == AD7151 || chip->interrupts[1])) {
+	if (id->driver_data == AD7151 || chip->interrupts[1]) {
 		irq_set_status_flags(chip->interrupts[0], IRQ_NOAUTOEN);
 		ret = devm_request_threaded_irq(&client->dev,
 						chip->interrupts[0],
-- 
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 =] 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 5/7] pinctrl: ingenic: relax return value check for IRQ get
  2023-05-16  7:13 ` [PATCH v4 5/7] pinctrl: ingenic: relax " Matti Vaittinen
@ 2023-05-16  7:49   ` Paul Cercueil
  0 siblings, 0 replies; 17+ messages in thread
From: Paul Cercueil @ 2023-05-16  7:49 UTC (permalink / raw)
  To: Matti Vaittinen, Matti Vaittinen
  Cc: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Rafael J. Wysocki, Lars-Peter Clausen,
	Michael Hennerich, Jonathan Cameron, Andreas Klinger,
	Marcin Wojtas, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jonathan Neuschäfer,
	Linus Walleij, Wolfram Sang, Akhil R, linux-acpi, linux-kernel,
	linux-iio, netdev, openbmc, linux-gpio, linux-mips

Hi Matti,

Le mardi 16 mai 2023 à 10:13 +0300, Matti Vaittinen a écrit :
> fwnode_irq_get[_byname]() were changed to not return 0 anymore.
> 
> Drop check for return value 0.
> 
> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>

Reviewed-by: Paul Cercueil <paul@crapouillou.net>

Cheers,
-Paul

> 
> ---
> 
> The first patch of the series changes the fwnode_irq_get() so this
> depends
> on the first patch of the series and should not be applied alone.
> ---
>  drivers/pinctrl/pinctrl-ingenic.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-ingenic.c
> b/drivers/pinctrl/pinctrl-ingenic.c
> index 2f220a47b749..86e71ad703a5 100644
> --- a/drivers/pinctrl/pinctrl-ingenic.c
> +++ b/drivers/pinctrl/pinctrl-ingenic.c
> @@ -4201,8 +4201,6 @@ static int __init ingenic_gpio_probe(struct
> ingenic_pinctrl *jzpc,
>         err = fwnode_irq_get(fwnode, 0);
>         if (err < 0)
>                 return err;
> -       if (!err)
> -               return -EINVAL;
>         jzgc->irq = err;
>  
>         girq = &jzgc->gc.irq;
> -- 
> 2.40.1
> 
> 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 4/7] pinctrl: wpcm450: elax return value check for IRQ get
  2023-05-16  7:13 ` [PATCH v4 4/7] pinctrl: wpcm450: elax " Matti Vaittinen
@ 2023-05-16 16:32   ` Jonathan Neuschäfer
  2023-05-17  5:41     ` Vaittinen, Matti
  2023-05-17 17:03     ` Andy Shevchenko
  0 siblings, 2 replies; 17+ messages in thread
From: Jonathan Neuschäfer @ 2023-05-16 16:32 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: Matti Vaittinen, Andy Shevchenko, Daniel Scally, Heikki Krogerus,
	Sakari Ailus, Greg Kroah-Hartman, Rafael J. Wysocki,
	Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Andreas Klinger, Marcin Wojtas, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jonathan Neuschäfer, Linus Walleij, Paul Cercueil,
	Wolfram Sang, Akhil R, linux-acpi, linux-kernel, linux-iio,
	netdev, openbmc, linux-gpio, linux-mips

[-- Attachment #1: Type: text/plain, Size: 3259 bytes --]

Hello,

> [PATCH v4 4/7] pinctrl: wpcm450: elax return value check for IRQ get

Typo ("elax") in the subject line.

>
On Tue, May 16, 2023 at 10:13:14AM +0300, Matti Vaittinen wrote:
> fwnode_irq_get[_byname]() were changed to not return 0 anymore. The
> special error case where device-tree based IRQ mapping fails can't no
> longer be reliably detected from this return value. This yields a
> functional change in the driver where the mapping failure is treated as
> an error.
> 
> The mapping failure can occur for example when the device-tree IRQ
> information translation call-back(s) (xlate) fail, IRQ domain is not
> found, IRQ type conflicts, etc. In most cases this indicates an error in
> the device-tree and special handling is not really required.
> 
> One more thing to note is that ACPI APIs do not return zero for any
> failures so this special handling did only apply on device-tree based
> systems.
> 
> Drop the special (no error, just skip the IRQ) handling for DT mapping
> failures as these can no longer be separated from other errors at driver
> side.
> 
> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
> 
> ---
> 
> The special handling in this driver was added when fixing a problem
> where returning zero from fwnode_irq_get[_byname]() was treated as
> succes yielding zero being used as a valid IRQ by the driver.
> f4a31facfa80 ("pinctrl: wpcm450: Correct the fwnode_irq_get() return value check")
> The commit message does not mention if choosing not to abort the probe
> on device-tree mapping failure (as is done on other errors) was chosen
> because: a) Abort would have broken some existing setup. b) Because skipping
> an IRQ on failure is "the right thing to do", or c) because it sounded like
> a way to minimize risk of breaking something.
> 
> If the reason is a) - then I'd appreciate receiving some more
> information and a suggestion how to proceed (if possible). If the reason
> is b), then it might be best to just skip the IRQ instead of aborting
> the probe for all errors on IRQ getting. Finally, in case of c), well,
> by acking this change you will now accept the risk :)
> 
> The first patch of the series changes the fwnode_irq_get() so this depends
> on the first patch of the series and should not be applied alone.

Thanks for investigating this!

It's not a), because there are no existing setups that rely on broken
IRQs connected to this pinctrl/GPIO controller.

I suspect b) or c), but I'll let Andy give a more definite answer.

> ---
>  drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
> index 2d1c1652cfd9..f9326210b5eb 100644
> --- a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
> +++ b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
> @@ -1106,8 +1106,6 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
>  			irq = fwnode_irq_get(child, i);
>  			if (irq < 0)
>  				break;
> -			if (!irq)
> -				continue;
>  
>  			girq->parents[i] = irq;
>  			girq->num_parents++;

Anyway, this looks good to me.

Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 4/7] pinctrl: wpcm450: elax return value check for IRQ get
  2023-05-16 16:32   ` Jonathan Neuschäfer
@ 2023-05-17  5:41     ` Vaittinen, Matti
  2023-05-17 17:03     ` Andy Shevchenko
  1 sibling, 0 replies; 17+ messages in thread
From: Vaittinen, Matti @ 2023-05-17  5:41 UTC (permalink / raw)
  To: Jonathan Neuschäfer, Matti Vaittinen
  Cc: Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Rafael J. Wysocki, Lars-Peter Clausen,
	Michael Hennerich, Jonathan Cameron, Andreas Klinger,
	Marcin Wojtas, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Linus Walleij, Paul Cercueil,
	Wolfram Sang, Akhil R, linux-acpi, linux-kernel, linux-iio,
	netdev, openbmc, linux-gpio, linux-mips

Thanks for taking a look at this Jonathan.

On 5/16/23 19:32, Jonathan Neuschäfer wrote:
> Hello,
> 
>> [PATCH v4 4/7] pinctrl: wpcm450: elax return value check for IRQ get
> 
> Typo ("elax") in the subject line.

It mut've ben the leter eatng moster :)

I'll take care of this when re-spinning.

> On Tue, May 16, 2023 at 10:13:14AM +0300, Matti Vaittinen wrote:
>> The special handling in this driver was added when fixing a problem
>> where returning zero from fwnode_irq_get[_byname]() was treated as
>> succes yielding zero being used as a valid IRQ by the driver.
>> f4a31facfa80 ("pinctrl: wpcm450: Correct the fwnode_irq_get() return value check")
>> The commit message does not mention if choosing not to abort the probe
>> on device-tree mapping failure (as is done on other errors) was chosen
>> because: a) Abort would have broken some existing setup. b) Because skipping
>> an IRQ on failure is "the right thing to do", or c) because it sounded like
>> a way to minimize risk of breaking something.
>>
>> If the reason is a) - then I'd appreciate receiving some more
>> information and a suggestion how to proceed (if possible). If the reason
>> is b), then it might be best to just skip the IRQ instead of aborting
>> the probe for all errors on IRQ getting. Finally, in case of c), well,
>> by acking this change you will now accept the risk :)
>>
>> The first patch of the series changes the fwnode_irq_get() so this depends
>> on the first patch of the series and should not be applied alone.
> 
> Thanks for investigating this!
> 
> It's not a), because there are no existing setups that rely on broken
> IRQs connected to this pinctrl/GPIO controller.

Glad to know. Then we should be able to "unify" the error handling no 
matter what fails when IRQ is tried to be obtained. Either by always 
aborting the probe or by skipping the broken IRQs.

> I suspect b) or c), but I'll let Andy give a more definite answer.
> 
>> ---
>>   drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 2 --
>>   1 file changed, 2 deletions(-)
>>
>> diff --git a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
>> index 2d1c1652cfd9..f9326210b5eb 100644
>> --- a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
>> +++ b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
>> @@ -1106,8 +1106,6 @@ static int wpcm450_gpio_register(struct platform_device *pdev,
>>   			irq = fwnode_irq_get(child, i);
>>   			if (irq < 0)
>>   				break;
>> -			if (!irq)
>> -				continue;
>>   
>>   			girq->parents[i] = irq;
>>   			girq->num_parents++;
> 
> Anyway, this looks good to me.
> 
> Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>

Yours,
	-- Matti

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

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


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 0/7] fix fwnode_irq_get[_byname()] returnvalue
  2023-05-16  7:12 [PATCH v4 0/7] fix fwnode_irq_get[_byname()] returnvalue Matti Vaittinen
                   ` (6 preceding siblings ...)
  2023-05-16  7:14 ` [PATCH v4 7/7] iio: cdc: ad7150: Functional change Matti Vaittinen
@ 2023-05-17 12:43 ` Linus Walleij
  2023-05-17 13:09   ` Matti Vaittinen
  7 siblings, 1 reply; 17+ messages in thread
From: Linus Walleij @ 2023-05-17 12:43 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: Matti Vaittinen, Andy Shevchenko, Daniel Scally, Heikki Krogerus,
	Sakari Ailus, Greg Kroah-Hartman, Rafael J. Wysocki,
	Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Andreas Klinger, Marcin Wojtas, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jonathan Neuschäfer, Paul Cercueil, Wolfram Sang, Akhil R,
	linux-acpi, linux-kernel, linux-iio, netdev, openbmc, linux-gpio,
	linux-mips

On Tue, May 16, 2023 at 9:12 AM Matti Vaittinen
<mazziesaccount@gmail.com> wrote:

> 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:

Also, zero is not really a valid IRQ, it means NO_IRQ:
https://lwn.net/Articles/470820/

I'll apply the pinctrl patches.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 0/7] fix fwnode_irq_get[_byname()] returnvalue
  2023-05-17 12:43 ` [PATCH v4 0/7] fix fwnode_irq_get[_byname()] returnvalue Linus Walleij
@ 2023-05-17 13:09   ` Matti Vaittinen
  0 siblings, 0 replies; 17+ messages in thread
From: Matti Vaittinen @ 2023-05-17 13:09 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Matti Vaittinen, Andy Shevchenko, Daniel Scally, Heikki Krogerus,
	Sakari Ailus, Greg Kroah-Hartman, Rafael J. Wysocki,
	Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Andreas Klinger, Marcin Wojtas, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jonathan Neuschäfer, Paul Cercueil, Wolfram Sang, Akhil R,
	linux-acpi, linux-kernel, linux-iio, netdev, openbmc, linux-gpio,
	linux-mips

On 5/17/23 15:43, Linus Walleij wrote:
> On Tue, May 16, 2023 at 9:12 AM Matti Vaittinen
> <mazziesaccount@gmail.com> wrote:
> 
>> 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:
> 
> Also, zero is not really a valid IRQ, it means NO_IRQ:
> https://lwn.net/Articles/470820/
> 
> I'll apply the pinctrl patches.

Thanks Linus. I guess you noticed but please wait until the patch 1/7 
gets in as the pinctrl patches won't do "the right thing" without it. 
(Just ensuring we are on a same page ;) )

Yours,
	-- Matti

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

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


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 2/7] iio: mb1232: relax return value check for IRQ get
  2023-05-16  7:12 ` [PATCH v4 2/7] iio: mb1232: relax return value check for IRQ get Matti Vaittinen
@ 2023-05-17 16:47   ` Andy Shevchenko
  2023-05-19  5:00     ` Matti Vaittinen
  0 siblings, 1 reply; 17+ messages in thread
From: Andy Shevchenko @ 2023-05-17 16:47 UTC (permalink / raw)
  To: Matti Vaittinen
  Cc: Matti Vaittinen, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Rafael J. Wysocki, Lars-Peter Clausen,
	Michael Hennerich, Jonathan Cameron, Andreas Klinger,
	Marcin Wojtas, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jonathan Neuschäfer,
	Linus Walleij, Paul Cercueil, Wolfram Sang, Akhil R, linux-acpi,
	linux-kernel, linux-iio, netdev, openbmc, linux-gpio, linux-mips

On Tue, May 16, 2023 at 10:12:41AM +0300, Matti Vaittinen wrote:
> fwnode_irq_get() was changed to not return 0 anymore.
> 
> Drop check for return value 0.

...

> -	if (data->irqnr <= 0) {
> +	if (data->irqnr < 0) {
>  		/* usage of interrupt is optional */
>  		data->irqnr = -1;
>  	} else {


After this change I'm not sure we need this branch at all, I mean that -errn is
equal to -1 in the code (but needs to be checked for silly checks like == -1).

Hence

Entire excerpt can be replaced with

	if (data->irqnr > 0) {

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 4/7] pinctrl: wpcm450: elax return value check for IRQ get
  2023-05-16 16:32   ` Jonathan Neuschäfer
  2023-05-17  5:41     ` Vaittinen, Matti
@ 2023-05-17 17:03     ` Andy Shevchenko
  1 sibling, 0 replies; 17+ messages in thread
From: Andy Shevchenko @ 2023-05-17 17:03 UTC (permalink / raw)
  To: Jonathan Neuschäfer
  Cc: Matti Vaittinen, Matti Vaittinen, Daniel Scally, Heikki Krogerus,
	Sakari Ailus, Greg Kroah-Hartman, Rafael J. Wysocki,
	Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Andreas Klinger, Marcin Wojtas, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Walleij,
	Paul Cercueil, Wolfram Sang, Akhil R, linux-acpi, linux-kernel,
	linux-iio, netdev, openbmc, linux-gpio, linux-mips

On Tue, May 16, 2023 at 06:32:09PM +0200, Jonathan Neuschäfer wrote:
> On Tue, May 16, 2023 at 10:13:14AM +0300, Matti Vaittinen wrote:

> > The special handling in this driver was added when fixing a problem
> > where returning zero from fwnode_irq_get[_byname]() was treated as
> > succes yielding zero being used as a valid IRQ by the driver.
> > f4a31facfa80 ("pinctrl: wpcm450: Correct the fwnode_irq_get() return value check")
> > The commit message does not mention if choosing not to abort the probe
> > on device-tree mapping failure (as is done on other errors) was chosen
> > because: a) Abort would have broken some existing setup. b) Because skipping
> > an IRQ on failure is "the right thing to do", or c) because it sounded like
> > a way to minimize risk of breaking something.
> > 
> > If the reason is a) - then I'd appreciate receiving some more
> > information and a suggestion how to proceed (if possible). If the reason
> > is b), then it might be best to just skip the IRQ instead of aborting
> > the probe for all errors on IRQ getting. Finally, in case of c), well,
> > by acking this change you will now accept the risk :)

From my side it was c).

> > The first patch of the series changes the fwnode_irq_get() so this depends
> > on the first patch of the series and should not be applied alone.
> 
> Thanks for investigating this!
> 
> It's not a), because there are no existing setups that rely on broken
> IRQs connected to this pinctrl/GPIO controller.
> 
> I suspect b) or c), but I'll let Andy give a more definite answer.


-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 2/7] iio: mb1232: relax return value check for IRQ get
  2023-05-17 16:47   ` Andy Shevchenko
@ 2023-05-19  5:00     ` Matti Vaittinen
  2023-05-19  5:26       ` Matti Vaittinen
  0 siblings, 1 reply; 17+ messages in thread
From: Matti Vaittinen @ 2023-05-19  5:00 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Matti Vaittinen, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Rafael J. Wysocki, Lars-Peter Clausen,
	Michael Hennerich, Jonathan Cameron, Andreas Klinger,
	Marcin Wojtas, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jonathan Neuschäfer,
	Linus Walleij, Paul Cercueil, Wolfram Sang, Akhil R, linux-acpi,
	linux-kernel, linux-iio, netdev, openbmc, linux-gpio, linux-mips

On 5/17/23 19:47, Andy Shevchenko wrote:
> On Tue, May 16, 2023 at 10:12:41AM +0300, Matti Vaittinen wrote:
>> fwnode_irq_get() was changed to not return 0 anymore.
>>
>> Drop check for return value 0.
> 
> ...
> 
>> -	if (data->irqnr <= 0) {
>> +	if (data->irqnr < 0) {
>>   		/* usage of interrupt is optional */
>>   		data->irqnr = -1;
>>   	} else {
> 
> 
> After this change I'm not sure we need this branch at all, I mean that -errn is
> equal to -1 in the code (but needs to be checked for silly checks like == -1).
> 
> Hence
> 
> Entire excerpt can be replaced with
> 
> 	if (data->irqnr > 0) {
> 

I agree. Furthermore, at a quick glance it seems the whole irqnr could 
be dropped from the private data, and the private data struct could 
probably be static. I'd send them as separate clean-ups though as those 
changes are not really related to this return-value series.

Yours,
	-- Matti

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

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


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v4 2/7] iio: mb1232: relax return value check for IRQ get
  2023-05-19  5:00     ` Matti Vaittinen
@ 2023-05-19  5:26       ` Matti Vaittinen
  0 siblings, 0 replies; 17+ messages in thread
From: Matti Vaittinen @ 2023-05-19  5:26 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Matti Vaittinen, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Greg Kroah-Hartman, Rafael J. Wysocki, Lars-Peter Clausen,
	Michael Hennerich, Jonathan Cameron, Andreas Klinger,
	Marcin Wojtas, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jonathan Neuschäfer,
	Linus Walleij, Paul Cercueil, Wolfram Sang, Akhil R, linux-acpi,
	linux-kernel, linux-iio, netdev, openbmc, linux-gpio, linux-mips

On 5/19/23 08:00, Matti Vaittinen wrote:
> On 5/17/23 19:47, Andy Shevchenko wrote:
>> On Tue, May 16, 2023 at 10:12:41AM +0300, Matti Vaittinen wrote:
>>> fwnode_irq_get() was changed to not return 0 anymore.
>>>
>>> Drop check for return value 0.
>>
>> ...
>>
>>> -    if (data->irqnr <= 0) {
>>> +    if (data->irqnr < 0) {
>>>           /* usage of interrupt is optional */
>>>           data->irqnr = -1;
>>>       } else {
>>
>>
>> After this change I'm not sure we need this branch at all, I mean that 
>> -errn is
>> equal to -1 in the code (but needs to be checked for silly checks like 
>> == -1).
>>
>> Hence
>>
>> Entire excerpt can be replaced with
>>
>>     if (data->irqnr > 0) {
>>
> 
> I agree. Furthermore, at a quick glance it seems the whole irqnr could 
> be dropped from the private data, and the private data struct could 
> probably be static. I'd send them as separate clean-ups though as those 
> changes are not really related to this return-value series.

Please, ignore everything I wrote above, except that I agree to your 
suggestion. I was writing utter nonsense. Sorry for the noise.

> 
> Yours,
>      -- Matti
> 

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

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


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2023-05-19  5:26 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-16  7:12 [PATCH v4 0/7] fix fwnode_irq_get[_byname()] returnvalue Matti Vaittinen
2023-05-16  7:12 ` [PATCH v4 1/7] drivers: fwnode: fix fwnode_irq_get[_byname]() Matti Vaittinen
2023-05-16  7:12 ` [PATCH v4 2/7] iio: mb1232: relax return value check for IRQ get Matti Vaittinen
2023-05-17 16:47   ` Andy Shevchenko
2023-05-19  5:00     ` Matti Vaittinen
2023-05-19  5:26       ` Matti Vaittinen
2023-05-16  7:12 ` [PATCH v4 3/7] net-next: " Matti Vaittinen
2023-05-16  7:13 ` [PATCH v4 4/7] pinctrl: wpcm450: elax " Matti Vaittinen
2023-05-16 16:32   ` Jonathan Neuschäfer
2023-05-17  5:41     ` Vaittinen, Matti
2023-05-17 17:03     ` Andy Shevchenko
2023-05-16  7:13 ` [PATCH v4 5/7] pinctrl: ingenic: relax " Matti Vaittinen
2023-05-16  7:49   ` Paul Cercueil
2023-05-16  7:13 ` [PATCH v4 6/7] pinctrl: pistachio: " Matti Vaittinen
2023-05-16  7:14 ` [PATCH v4 7/7] iio: cdc: ad7150: Functional change Matti Vaittinen
2023-05-17 12:43 ` [PATCH v4 0/7] fix fwnode_irq_get[_byname()] returnvalue Linus Walleij
2023-05-17 13:09   ` Matti Vaittinen

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).