Skip to content

Commit 39d4225

Browse files
M-Vaittinengregkh
authored andcommitted
drivers: fwnode: fix fwnode_irq_get[_byname]()
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: ca0acb5 ("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> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Message-ID: <3e64fe592dc99e27ef9a0b247fc49fa26b6b8a58.1685340157.git.mazziesaccount@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 259b836 commit 39d4225

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

drivers/base/property.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -987,12 +987,18 @@ EXPORT_SYMBOL(fwnode_iomap);
987987
* @fwnode: Pointer to the firmware node
988988
* @index: Zero-based index of the IRQ
989989
*
990-
* Return: Linux IRQ number on success. Other values are determined
991-
* according to acpi_irq_get() or of_irq_get() operation.
990+
* Return: Linux IRQ number on success. Negative errno on failure.
992991
*/
993992
int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index)
994993
{
995-
return fwnode_call_int_op(fwnode, irq_get, index);
994+
int ret;
995+
996+
ret = fwnode_call_int_op(fwnode, irq_get, index);
997+
/* We treat mapping errors as invalid case */
998+
if (ret == 0)
999+
return -EINVAL;
1000+
1001+
return ret;
9961002
}
9971003
EXPORT_SYMBOL(fwnode_irq_get);
9981004

0 commit comments

Comments
 (0)