aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Boyd <swboyd@chromium.org>2019-07-30 01:38:43 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-07-30 07:58:04 -0400
commit7723f4c5ecdb8d832f049f8483beb0d1081cedf6 (patch)
treec45b7bca883818c45f30ba501bd756cb18027e66
parentf87da58b797aa591f2e288c7012faf3ab1e54c55 (diff)
driver core: platform: Add an error message to platform_get_irq*()
A grep of the kernel shows that many drivers print an error message if they fail to get the irq they're looking for. Furthermore, those drivers all decide to print the device name, or not, and the irq they were requesting, or not, etc. Let's consolidate all these error messages into the API itself, allowing us to get rid of the error messages in each driver. Cc: Rob Herring <robh@kernel.org> Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Cc: Javier Martinez Canillas <javierm@redhat.com> Cc: Andrzej Hajda <a.hajda@samsung.com> Cc: Mark Brown <broonie@kernel.org> Cc: Russell King - ARM Linux <linux@armlinux.org.uk> Cc: Marek Szyprowski <m.szyprowski@samsung.com> Cc: Markus Elfring <Markus.Elfring@web.de> Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20190730053845.126834-2-swboyd@chromium.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/base/platform.c42
1 files changed, 34 insertions, 8 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index a174ce5ea17c..9426736551b5 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -99,12 +99,7 @@ void __iomem *devm_platform_ioremap_resource(struct platform_device *pdev,
99EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource); 99EXPORT_SYMBOL_GPL(devm_platform_ioremap_resource);
100#endif /* CONFIG_HAS_IOMEM */ 100#endif /* CONFIG_HAS_IOMEM */
101 101
102/** 102static int __platform_get_irq(struct platform_device *dev, unsigned int num)
103 * platform_get_irq - get an IRQ for a device
104 * @dev: platform device
105 * @num: IRQ number index
106 */
107int platform_get_irq(struct platform_device *dev, unsigned int num)
108{ 103{
109#ifdef CONFIG_SPARC 104#ifdef CONFIG_SPARC
110 /* sparc does not have irqs represented as IORESOURCE_IRQ resources */ 105 /* sparc does not have irqs represented as IORESOURCE_IRQ resources */
@@ -163,6 +158,33 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
163 return -ENXIO; 158 return -ENXIO;
164#endif 159#endif
165} 160}
161
162/**
163 * platform_get_irq - get an IRQ for a device
164 * @dev: platform device
165 * @num: IRQ number index
166 *
167 * Gets an IRQ for a platform device and prints an error message if finding the
168 * IRQ fails. Device drivers should check the return value for errors so as to
169 * not pass a negative integer value to the request_irq() APIs.
170 *
171 * Example:
172 * int irq = platform_get_irq(pdev, 0);
173 * if (irq < 0)
174 * return irq;
175 *
176 * Return: IRQ number on success, negative error number on failure.
177 */
178int platform_get_irq(struct platform_device *dev, unsigned int num)
179{
180 int ret;
181
182 ret = __platform_get_irq(dev, num);
183 if (ret < 0 && ret != -EPROBE_DEFER)
184 dev_err(&dev->dev, "IRQ index %u not found\n", num);
185
186 return ret;
187}
166EXPORT_SYMBOL_GPL(platform_get_irq); 188EXPORT_SYMBOL_GPL(platform_get_irq);
167 189
168/** 190/**
@@ -175,7 +197,7 @@ int platform_irq_count(struct platform_device *dev)
175{ 197{
176 int ret, nr = 0; 198 int ret, nr = 0;
177 199
178 while ((ret = platform_get_irq(dev, nr)) >= 0) 200 while ((ret = __platform_get_irq(dev, nr)) >= 0)
179 nr++; 201 nr++;
180 202
181 if (ret == -EPROBE_DEFER) 203 if (ret == -EPROBE_DEFER)
@@ -228,7 +250,11 @@ int platform_get_irq_byname(struct platform_device *dev, const char *name)
228 } 250 }
229 251
230 r = platform_get_resource_byname(dev, IORESOURCE_IRQ, name); 252 r = platform_get_resource_byname(dev, IORESOURCE_IRQ, name);
231 return r ? r->start : -ENXIO; 253 if (r)
254 return r->start;
255
256 dev_err(&dev->dev, "IRQ %s not found\n", name);
257 return -ENXIO;
232} 258}
233EXPORT_SYMBOL_GPL(platform_get_irq_byname); 259EXPORT_SYMBOL_GPL(platform_get_irq_byname);
234 260