Merge branch 'for-linux-next' of git://linux-c6x.org/git/projects/linux-c6x-upstreaming
[cascardo/linux.git] / drivers / base / platform.c
index 1dd6d3b..73e3994 100644 (file)
@@ -116,6 +116,26 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
 }
 EXPORT_SYMBOL_GPL(platform_get_irq);
 
+/**
+ * platform_irq_count - Count the number of IRQs a platform device uses
+ * @dev: platform device
+ *
+ * Return: Number of IRQs a platform device uses or EPROBE_DEFER
+ */
+int platform_irq_count(struct platform_device *dev)
+{
+       int ret, nr = 0;
+
+       while ((ret = platform_get_irq(dev, nr)) >= 0)
+               nr++;
+
+       if (ret == -EPROBE_DEFER)
+               return ret;
+
+       return nr;
+}
+EXPORT_SYMBOL_GPL(platform_irq_count);
+
 /**
  * platform_get_resource_byname - get a resource for a device by name
  * @dev: platform device