Skip to contentSkip to conversation

of/irq: Export of_irq_count()

PATCH In review Mark Brown 4 participants 6 messages Dec 22, 2015 – Jan 5, 2016 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 of/irq: Export of_irq_count()

Some of the Qualcomm pinctrl drivers have started trying to use of_irq_count() in modular code but this fails to build as the symbol is not exported. Since there doesn't seem to be any reason not to export the symbol make it available to modules.

---
 drivers/of/irq.c | 1 +
 1 file changed, 1 insertion(+)
drivers/of/irq.c +1 -0
index 4fa916dffc91..2cea06a0c751 100644
@@ -449,6 +449,7 @@ int of_irq_count(struct device_node *dev)
 
 	return nr;
 }
+EXPORT_SYMBOL_GPL(of_irq_count);
 
 /**
  * of_irq_to_resource_table - Fill in resource table with node's IRQ info
Signature · 6 lines
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1450786942-13292-1-git-send-email-broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org

Reviewed-by
#2 lore raw
Quoted 6 lines · Mark Brown

Some of the Qualcomm pinctrl drivers have started trying to use of_irq_count() in modular code but this fails to build as the symbol is not exported. Since there doesn't seem to be any reason not to export the symbol make it available to modules.

Thanks Mark.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to a message not in the archive
Quoted 4 lines · Mark Brown

Some of the Qualcomm pinctrl drivers have started trying to use of_irq_count() in modular code but this fails to build as the symbol is not exported. Since there doesn't seem to be any reason not to export the symbol make it available to modules.

The reason it has not been exported is because we want to stick with the platform_* APIs for IRQs. There's not really an equivalent function though. Perhaps we should make one? Usually it is just used for allocating some driver data. If that is the case, is it really enough data to not just allocate the max?

Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CAL_JsqJELQc316UkkpzLrbSsYMYh69uxX5Jw8p4TpWm6eqmfuA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#5 lore raw
Quoted 11 lines · Rob Herring
Quoted 4 lines · Mark Brown

Some of the Qualcomm pinctrl drivers have started trying to use of_irq_count() in modular code but this fails to build as the symbol is not exported. Since there doesn't seem to be any reason not to export the symbol make it available to modules.

The reason it has not been exported is because we want to stick with the platform_* APIs for IRQs. There's not really an equivalent function though. Perhaps we should make one? Usually it is just used for allocating some driver data. If that is the case, is it really enough data to not just allocate the max?

Hm that seems like a bigger solution. Should we try to mitigate the issue by making the Qualcomm drivers builtin for the time being?

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
In reply to a message not in the archive
Quoted 6 lines · Rob Herring
Quoted 4 lines · Mark Brown

Some of the Qualcomm pinctrl drivers have started trying to use of_irq_count() in modular code but this fails to build as the symbol is not exported. Since there doesn't seem to be any reason not to export the symbol make it available to modules.

Quoted 6 lines

The reason it has not been exported is because we want to stick with the platform_* APIs for IRQs. There's not really an equivalent function though. Perhaps we should make one? Usually it is just used for allocating some driver data. If that is the case, is it really enough data to not just allocate the max?

It's mostly used for allocation but we also do some pin type discovery by reading registers and that would fail if we went past the actual number of pins there are.

So how about implementing platform_irq_count()? I'd like to keep these drivers as tristate if possible.

----8<----

drivers/base/platform.c +19 -0
index d77ed0c946dd..421c67f8fdef 100644
@@ -118,6 +118,25 @@ 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;
+}
+
+/**
  * platform_get_resource_byname - get a resource for a device by name
  * @dev: platform device
  * @type: resource type
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw
Quoted 14 lines · Stephen Boyd
Quoted 6 lines · Rob Herring
Quoted 4 lines · Mark Brown

Some of the Qualcomm pinctrl drivers have started trying to use of_irq_count() in modular code but this fails to build as the symbol is not exported. Since there doesn't seem to be any reason not to export the symbol make it available to modules.

Quoted 6 lines

The reason it has not been exported is because we want to stick with the platform_* APIs for IRQs. There's not really an equivalent function though. Perhaps we should make one? Usually it is just used for allocating some driver data. If that is the case, is it really enough data to not just allocate the max?

Quoted 6 lines

It's mostly used for allocation but we also do some pin type discovery by reading registers and that would fail if we went past the actual number of pins there are.

So how about implementing platform_irq_count()? I'd like to keep these drivers as tristate if possible.

Ack.

Quoted 16 lines

----8<----

drivers/base/platform.c +7 -0
index d77ed0c946dd..421c67f8fdef 100644
@@ -118,6 +118,25 @@ 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)
+{

drivers/base/platform.c int platform_get_irq(struct platform_device *dev, unsigned int num) · line 137

Quoted 10 lines
drivers/base/platform.c +10 -0
+       int ret, nr = 0;
+
+       while ((ret = platform_get_irq(dev, nr)) == 0)
+               nr++;
+
+       if (ret == -EPROBE_DEFER)
+               return ret;
+
+       return nr;
+}

Don't forget the export here. :)

Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html