Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

driver-core: platform: Add platform_irq_count()

A recent patch added calls to of_irq_count() in the qcom pinctrl
drivers and that caused module build failures because
of_irq_count() is not an exported symbol. We shouldn't export
of_irq_count() to modules because it's an internal OF API that
shouldn't be used by drivers. Platform drivers should use
platform device APIs instead. Therefore, add a platform_irq_count()
API that mirrors the of_irq_count() API so that platform drivers
can stay DT agnostic.

Cc: Andy Gross <andy.gross@linaro.org>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Stephen Boyd and committed by
Linus Walleij
4b83555d c9f294ff

+21
+20
drivers/base/platform.c
··· 117 117 EXPORT_SYMBOL_GPL(platform_get_irq); 118 118 119 119 /** 120 + * platform_irq_count - Count the number of IRQs a platform device uses 121 + * @dev: platform device 122 + * 123 + * Return: Number of IRQs a platform device uses or EPROBE_DEFER 124 + */ 125 + int platform_irq_count(struct platform_device *dev) 126 + { 127 + int ret, nr = 0; 128 + 129 + while ((ret = platform_get_irq(dev, nr)) >= 0) 130 + nr++; 131 + 132 + if (ret == -EPROBE_DEFER) 133 + return ret; 134 + 135 + return nr; 136 + } 137 + EXPORT_SYMBOL_GPL(platform_irq_count); 138 + 139 + /** 120 140 * platform_get_resource_byname - get a resource for a device by name 121 141 * @dev: platform device 122 142 * @type: resource type
+1
include/linux/platform_device.h
··· 51 51 extern struct resource *platform_get_resource(struct platform_device *, 52 52 unsigned int, unsigned int); 53 53 extern int platform_get_irq(struct platform_device *, unsigned int); 54 + extern int platform_irq_count(struct platform_device *); 54 55 extern struct resource *platform_get_resource_byname(struct platform_device *, 55 56 unsigned int, 56 57 const char *);