]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commitf157f2953c02e9595e956d0a924e20560364c456
tree8a03c837d1ef7df86a21b36acfdc1cbf6d9595f1
parent9b8057e7f937f20763a90a8fc2333168af101732
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