OSDN Git Service

driver core: platform: Clarify that IRQ 0 is invalid
authorBjorn Helgaas <bhelgaas@google.com>
Mon, 16 Mar 2020 21:43:38 +0000 (16:43 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 12 May 2020 13:14:29 +0000 (08:14 -0500)
commita85a6c86c25be2d2a5f9c31491f612ce0edc7869
tree8a03c837d1ef7df86a21b36acfdc1cbf6d9595f1
parent8f3d9f354286745c751374f5f1fcafee6b3f3136
driver core: platform: Clarify that IRQ 0 is invalid

These interfaces return a negative error number or an IRQ:

  platform_get_irq()
  platform_get_irq_optional()
  platform_get_irq_byname()
  platform_get_irq_byname_optional()

The function comments suggest checking for error like this:

  irq = platform_get_irq(...);
  if (irq < 0)
    return irq;

which is what most callers (~900 of 1400) do, so it's implicit that IRQ 0
is invalid.  But some callers check for "irq <= 0", and it's not obvious
from the source that we never return an IRQ 0.

Make this more explicit by updating the comments to say that an IRQ number
is always non-zero and adding a WARN() if we ever do return zero.  If we do
return IRQ 0, it likely indicates a bug in the arch-specific parts of
platform_get_irq().

Relevant prior discussion at [1, 2].

[1] https://lore.kernel.org/r/Pine.LNX.4.64.0701250940220.25027@woody.linux-foundation.org/
[2] https://lore.kernel.org/r/Pine.LNX.4.64.0701252029570.25027@woody.linux-foundation.org/
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
drivers/base/platform.c