aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2019-10-05 17:04:47 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-10-07 06:52:44 -0400
commitf1da567f1dc1b55d178b8f2d0cfe8353858aac19 (patch)
tree755f6e8ae6dc1264b6f3ef679a19fb8fa704d23b
parente2fbe600433c5f4876ec9f0d9e91d8b0b37a6e87 (diff)
driver core: platform: Add platform_get_irq_byname_optional()
Some drivers (e.g dwc3) first try to get an IRQ byname and then fall back to the one at index 0. In this case we do not want the error(s) printed by platform_get_irq_byname(). This commit adds a new platform_get_irq_byname_optional(), which does not print errors, for this. While at it also improve the kdoc text for platform_get_irq_byname() a bit. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=205037 Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://lore.kernel.org/r/20191005210449.3926-2-hdegoede@redhat.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/base/platform.c46
-rw-r--r--include/linux/platform_device.h2
2 files changed, 41 insertions, 7 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index b6c6c7d97d5b..b230beb6ccb4 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -241,12 +241,8 @@ struct resource *platform_get_resource_byname(struct platform_device *dev,
241} 241}
242EXPORT_SYMBOL_GPL(platform_get_resource_byname); 242EXPORT_SYMBOL_GPL(platform_get_resource_byname);
243 243
244/** 244static int __platform_get_irq_byname(struct platform_device *dev,
245 * platform_get_irq_byname - get an IRQ for a device by name 245 const char *name)
246 * @dev: platform device
247 * @name: IRQ name
248 */
249int platform_get_irq_byname(struct platform_device *dev, const char *name)
250{ 246{
251 struct resource *r; 247 struct resource *r;
252 248
@@ -262,12 +258,48 @@ int platform_get_irq_byname(struct platform_device *dev, const char *name)
262 if (r) 258 if (r)
263 return r->start; 259 return r->start;
264 260
265 dev_err(&dev->dev, "IRQ %s not found\n", name);
266 return -ENXIO; 261 return -ENXIO;
267} 262}
263
264/**
265 * platform_get_irq_byname - get an IRQ for a device by name
266 * @dev: platform device
267 * @name: IRQ name
268 *
269 * Get an IRQ like platform_get_irq(), but then by name rather then by index.
270 *
271 * Return: IRQ number on success, negative error number on failure.
272 */
273int platform_get_irq_byname(struct platform_device *dev, const char *name)
274{
275 int ret;
276
277 ret = __platform_get_irq_byname(dev, name);
278 if (ret < 0 && ret != -EPROBE_DEFER)
279 dev_err(&dev->dev, "IRQ %s not found\n", name);
280
281 return ret;
282}
268EXPORT_SYMBOL_GPL(platform_get_irq_byname); 283EXPORT_SYMBOL_GPL(platform_get_irq_byname);
269 284
270/** 285/**
286 * platform_get_irq_byname_optional - get an optional IRQ for a device by name
287 * @dev: platform device
288 * @name: IRQ name
289 *
290 * Get an optional IRQ by name like platform_get_irq_byname(). Except that it
291 * does not print an error message if an IRQ can not be obtained.
292 *
293 * Return: IRQ number on success, negative error number on failure.
294 */
295int platform_get_irq_byname_optional(struct platform_device *dev,
296 const char *name)
297{
298 return __platform_get_irq_byname(dev, name);
299}
300EXPORT_SYMBOL_GPL(platform_get_irq_byname_optional);
301
302/**
271 * platform_add_devices - add a numbers of platform devices 303 * platform_add_devices - add a numbers of platform devices
272 * @devs: array of platform devices to add 304 * @devs: array of platform devices to add
273 * @num: number of platform devices in array 305 * @num: number of platform devices in array
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 1b5cec067533..f2688404d1cd 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -64,6 +64,8 @@ extern struct resource *platform_get_resource_byname(struct platform_device *,
64 unsigned int, 64 unsigned int,
65 const char *); 65 const char *);
66extern int platform_get_irq_byname(struct platform_device *, const char *); 66extern int platform_get_irq_byname(struct platform_device *, const char *);
67extern int platform_get_irq_byname_optional(struct platform_device *dev,
68 const char *name);
67extern int platform_add_devices(struct platform_device **, int); 69extern int platform_add_devices(struct platform_device **, int);
68 70
69struct platform_device_info { 71struct platform_device_info {