Skip to contentSkip to conversation

Make qcom pinctrl drivers tristate again

PATCH In review Stephen Boyd 6 participants 13 messages Jan 7, 2016

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover Make qcom pinctrl drivers tristate again

One of my recent changes to the qcom pinctrl drivers introduced a module build failure due to of_irq_count() missing an export. Rob doesn't want us to export that API though, so this series introduces platform_irq_count() and uses it in the pinctrl drivers. Linus changed the Kconfig to bool so that the build failure went away, so I've reverted that patch here after we fix the build failure with the new API.

Greg, please ack the first patch so it can go through Linus' tree.

Cc Rob Herring <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Andy Gross <[email protected]>

Stephen Boyd (3):
driver-core: platform: Add platform_irq_count()
pinctrl: qcom: Use platform_irq_count() instead of of_irq_count() Revert "pinctrl: qcom: make PMIC drivers bool"

 drivers/base/platform.c                  | 20 ++++++++++++++++++++
 drivers/pinctrl/qcom/Kconfig             |  4 ++--
 drivers/pinctrl/qcom/pinctrl-spmi-gpio.c |  4 +++-
 drivers/pinctrl/qcom/pinctrl-spmi-mpp.c  |  4 +++-
 drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c |  9 ++++++---
 drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c  |  9 ++++++---
 include/linux/platform_device.h          |  1 +
 7 files changed, 41 insertions(+), 10 deletions(-)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#1 lore raw

PATCH 1/3 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 Rob Herring <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Andy Gross <[email protected]>
---
 drivers/base/platform.c         | 20 ++++++++++++++++++++
 include/linux/platform_device.h |  1 +
 2 files changed, 21 insertions(+)
drivers/base/platform.c +20 -0
index d77ed0c946dd..8dcbb266643b 100644
@@ -118,6 +118,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
  * @type: resource type
include/linux/platform_device.h +1 -0
index dba40b1c41dc..03b755521fd9 100644
@@ -52,6 +52,7 @@ extern void arch_setup_pdev_archdata(struct platform_device *);
 extern struct resource *platform_get_resource(struct platform_device *,
 					      unsigned int, unsigned int);
 extern int platform_get_irq(struct platform_device *, unsigned int);
+extern int platform_irq_count(struct platform_device *);
 extern struct resource *platform_get_resource_byname(struct platform_device *,
 						     unsigned int,
 						     const char *);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#6 lore raw

PATCH 2/3 pinctrl: qcom: Use platform_irq_count() instead of of_irq_count()

In reply to Stephen Boyd

of_irq_count() is not an exported symbol (and it shouldn't be used by platform drivers anyway) so use platform_irq_count() instead. This allows us to make the qcom pinctrl drivers modular again.

Cc Rob Herring <[email protected]>
Cc Andy Gross <[email protected]>
---
 drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 4 +++-
 drivers/pinctrl/qcom/pinctrl-spmi-mpp.c  | 4 +++-
 drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c | 9 ++++++---
 drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c  | 9 ++++++---
 4 files changed, 18 insertions(+), 8 deletions(-)
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +3 -1
index 60b922274879..9ed2b4eba1f8 100644
@@ -702,9 +702,11 @@ static int pmic_gpio_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	npins = of_irq_count(dev->of_node);
+	npins = platform_irq_count(pdev);
 	if (!npins)
 		return -EINVAL;
+	if (npins < 0)
+		return npins;
 
 	BUG_ON(npins > ARRAY_SIZE(pmic_gpio_groups));
 
drivers/pinctrl/qcom/pinctrl-spmi-mpp.c +3 -1
index 5654287c382c..3fd04a6888a4 100644
@@ -804,9 +804,11 @@ static int pmic_mpp_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	npins = of_irq_count(dev->of_node);
+	npins = platform_irq_count(pdev);
 	if (!npins)
 		return -EINVAL;
+	if (npins < 0)
+		return npins;
 
 	BUG_ON(npins > ARRAY_SIZE(pmic_mpp_groups));
 
drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c +6 -3
index df054e716dc0..bde2aa684dc1 100644
@@ -667,16 +667,19 @@ static int pm8xxx_gpio_probe(struct platform_device *pdev)
 	struct pinctrl_pin_desc *pins;
 	struct pm8xxx_gpio *pctrl;
 	int ret;
-	int i;
+	int i, npins;
 
 	pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);
 	if (!pctrl)
 		return -ENOMEM;
 
 	pctrl->dev = &pdev->dev;
-	pctrl->npins = of_irq_count(pdev->dev.of_node);
-	if (!pctrl->npins)
+	npins = platform_irq_count(pdev);
+	if (!npins)
 		return -EINVAL;
+	if (npins < 0)
+		return npins;
+	pctrl->npins = npins;
 
 	pctrl->regmap = dev_get_regmap(pdev->dev.parent, NULL);
 	if (!pctrl->regmap) {
drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c +6 -3
index 3ddb4cc38f1c..37ae6b72ea35 100644
@@ -758,16 +758,19 @@ static int pm8xxx_mpp_probe(struct platform_device *pdev)
 	struct pinctrl_pin_desc *pins;
 	struct pm8xxx_mpp *pctrl;
 	int ret;
-	int i;
+	int i, npins;
 
 	pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);
 	if (!pctrl)
 		return -ENOMEM;
 
 	pctrl->dev = &pdev->dev;
-	pctrl->npins = of_irq_count(pdev->dev.of_node);
-	if (!pctrl->npins)
+	npins = of_irq_count(pdev->dev.of_node);
+	if (!npins)
 		return -EINVAL;
+	if (npins < 0)
+		return npins;
+	pctrl->npins = npins;
 
 	pctrl->regmap = dev_get_regmap(pdev->dev.parent, NULL);
 	if (!pctrl->regmap) {
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#11 lore raw

PATCH 3/3 Revert "pinctrl: qcom: make PMIC drivers bool"

In reply to Stephen Boyd

This reverts commit bda7c4c2b9767ce2af4394754498662d62079af5. These drivers build as modules now that we use platform_irq_count() instead of of_irq_count().

Cc Rob Herring <[email protected]>
Cc Andy Gross <[email protected]>
---
 drivers/pinctrl/qcom/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/qcom/Kconfig +2 -2
index c658d9bce285..eeac8cba8a21 100644
@@ -80,7 +80,7 @@ config PINCTRL_QDF2XXX
 	  Qualcomm Technologies QDF2xxx SOCs.
 
 config PINCTRL_QCOM_SPMI_PMIC
-       bool "Qualcomm SPMI PMIC pin controller driver"
+       tristate "Qualcomm SPMI PMIC pin controller driver"
        depends on GPIOLIB && OF && SPMI
        select REGMAP_SPMI
        select PINMUX
@@ -93,7 +93,7 @@ config PINCTRL_QCOM_SPMI_PMIC
          devices are pm8841, pm8941 and pma8084.
 
 config PINCTRL_QCOM_SSBI_PMIC
-       bool "Qualcomm SSBI PMIC pin controller driver"
+       tristate "Qualcomm SSBI PMIC pin controller driver"
        depends on GPIOLIB && OF
        select PINMUX
        select PINCONF
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
Acked-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] driver-core: platform: Add platform_irq_count()

In reply to Stephen Boyd
Quoted 9 lines · Stephen Boyd

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.

Quoted 4 lines
Cc Rob Herring <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Andy Gross <[email protected]>
#7 lore raw

Re: [PATCH 2/3] pinctrl: qcom: Use platform_irq_count() instead of of_irq_count()

In reply to Stephen Boyd
Quoted 5 lines · Stephen Boyd

of_irq_count() is not an exported symbol (and it shouldn't be used by platform drivers anyway) so use platform_irq_count() instead. This allows us to make the qcom pinctrl drivers modular again.

[..]

Quoted 9 lines
drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c +0 -1
index 3ddb4cc38f1c..37ae6b72ea35 100644
@@ -758,16 +758,19 @@ static int pm8xxx_mpp_probe(struct platform_device *pdev)
        struct pinctrl_pin_desc *pins;
        struct pm8xxx_mpp *pctrl;
        int ret;
-       int i;

drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c static int pm8xxx_mpp_probe(struct platform_device *pdev) · line 768

Quoted 10 lines
drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c +2 -2
+       int i, npins;
 
        pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);
        if (!pctrl)
                return -ENOMEM;
 
        pctrl->dev = &pdev->dev;
-       pctrl->npins = of_irq_count(pdev->dev.of_node);
-       if (!pctrl->npins)
+       npins = of_irq_count(pdev->dev.of_node);

platform_irq_count(pdev)

drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c static int pm8xxx_mpp_probe(struct platform_device *pdev) · line 776

Quoted 8 lines
drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c +4 -0
+       if (!npins)
                return -EINVAL;
+       if (npins < 0)
+               return npins;
+       pctrl->npins = npins;
 
        pctrl->regmap = dev_get_regmap(pdev->dev.parent, NULL);
        if (!pctrl->regmap) {

Regards,
Bjorn

#8 lore raw

Re: [PATCH 2/3] pinctrl: qcom: Use platform_irq_count() instead of of_irq_count()

Quoted 22 lines · Bjorn Andersson
Quoted 5 lines · Stephen Boyd

of_irq_count() is not an exported symbol (and it shouldn't be used by platform drivers anyway) so use platform_irq_count() instead. This allows us to make the qcom pinctrl drivers modular again.

[..]

Quoted 15 lines
drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c +1 -1
index 3ddb4cc38f1c..37ae6b72ea35 100644
@@ -758,16 +758,19 @@ static int pm8xxx_mpp_probe(struct platform_device *pdev)
        struct pinctrl_pin_desc *pins;
        struct pm8xxx_mpp *pctrl;
        int ret;
-       int i;
+       int i, npins;
 
        pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);
        if (!pctrl)
                return -ENOMEM;
 
Quoted 5 lines

drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c static int pm8xxx_mpp_probe(struct platform_device *pdev) · line 768

Quoted 4 lines
drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c +1 -2
        pctrl->dev = &pdev->dev;
-       pctrl->npins = of_irq_count(pdev->dev.of_node);
-       if (!pctrl->npins)
+       npins = of_irq_count(pdev->dev.of_node);

platform_irq_count(pdev)

Ouch. So many duplicates the odds were against me.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#9 lore raw

PATCH v2 2/3 pinctrl: qcom: Use platform_irq_count() instead of of_irq_count()

In reply to Bjorn Andersson

of_irq_count() is not an exported symbol (and it shouldn't be used by platform drivers anyway) so use platform_irq_count() instead. This allows us to make the qcom pinctrl drivers modular again.

Cc Rob Herring <[email protected]>
Cc Andy Gross <[email protected]>
Cc Bjorn Andersson <[email protected]>

---

Changes from v1:
* Fixed one wrong of_irq_count() noticed by Bjorn

 drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 4 +++-
 drivers/pinctrl/qcom/pinctrl-spmi-mpp.c  | 4 +++-
 drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c | 9 ++++++---
 drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c  | 9 ++++++---
 4 files changed, 18 insertions(+), 8 deletions(-)
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +3 -1
index f46dbbf7ff25..4e12ded3c773 100644
@@ -697,9 +697,11 @@ static int pmic_gpio_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	npins = of_irq_count(dev->of_node);
+	npins = platform_irq_count(pdev);
 	if (!npins)
 		return -EINVAL;
+	if (npins < 0)
+		return npins;
 
 	BUG_ON(npins > ARRAY_SIZE(pmic_gpio_groups));
 
drivers/pinctrl/qcom/pinctrl-spmi-mpp.c +3 -1
index 5c7935012e3a..2f18323571a6 100644
@@ -799,9 +799,11 @@ static int pmic_mpp_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	npins = of_irq_count(dev->of_node);
+	npins = platform_irq_count(pdev);
 	if (!npins)
 		return -EINVAL;
+	if (npins < 0)
+		return npins;
 
 	BUG_ON(npins > ARRAY_SIZE(pmic_mpp_groups));
 
drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c +6 -3
index f75e482073b7..cd8580d9741d 100644
@@ -667,16 +667,19 @@ static int pm8xxx_gpio_probe(struct platform_device *pdev)
 	struct pinctrl_pin_desc *pins;
 	struct pm8xxx_gpio *pctrl;
 	int ret;
-	int i;
+	int i, npins;
 
 	pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);
 	if (!pctrl)
 		return -ENOMEM;
 
 	pctrl->dev = &pdev->dev;
-	pctrl->npins = of_irq_count(pdev->dev.of_node);
-	if (!pctrl->npins)
+	npins = platform_irq_count(pdev);
+	if (!npins)
 		return -EINVAL;
+	if (npins < 0)
+		return npins;
+	pctrl->npins = npins;
 
 	pctrl->regmap = dev_get_regmap(pdev->dev.parent, NULL);
 	if (!pctrl->regmap) {
drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c +6 -3
index 3e19c12a315a..54a5402a9079 100644
@@ -758,16 +758,19 @@ static int pm8xxx_mpp_probe(struct platform_device *pdev)
 	struct pinctrl_pin_desc *pins;
 	struct pm8xxx_mpp *pctrl;
 	int ret;
-	int i;
+	int i, npins;
 
 	pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);
 	if (!pctrl)
 		return -ENOMEM;
 
 	pctrl->dev = &pdev->dev;
-	pctrl->npins = of_irq_count(pdev->dev.of_node);
-	if (!pctrl->npins)
+	npins = platform_irq_count(pdev);
+	if (!npins)
 		return -EINVAL;
+	if (npins < 0)
+		return npins;
+	pctrl->npins = npins;
 
 	pctrl->regmap = dev_get_regmap(pdev->dev.parent, NULL);
 	if (!pctrl->regmap) {
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
maintainer Acked-by on v1 1/3
#3 lore raw

Re: [PATCH 1/3] driver-core: platform: Add platform_irq_count()

In reply to Stephen Boyd
Quoted 9 lines · Stephen Boyd

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.

Quoted 8 lines
Cc Rob Herring <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Andy Gross <[email protected]>
---
 drivers/base/platform.c         | 20 ++++++++++++++++++++
 include/linux/platform_device.h |  1 +
 2 files changed, 21 insertions(+)
#4 lore raw

Re: [PATCH 1/3] driver-core: platform: Add platform_irq_count()

In reply to Stephen Boyd
Quoted 9 lines · Stephen Boyd

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.

Quoted 4 lines
Cc Rob Herring <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Andy Gross <[email protected]>

Patch applied with Rob's and Greg's ACKs.

Yours,
Linus Walleij

#10 lore raw

Re: [PATCH v2 2/3] pinctrl: qcom: Use platform_irq_count() instead of of_irq_count()

In reply to Stephen Boyd
Quoted 5 lines · Stephen Boyd

of_irq_count() is not an exported symbol (and it shouldn't be used by platform drivers anyway) so use platform_irq_count() instead. This allows us to make the qcom pinctrl drivers modular again.

Quoted 8 lines
Cc Rob Herring <[email protected]>
Cc Andy Gross <[email protected]>
Cc Bjorn Andersson <[email protected]>

---

Changes from v1:
* Fixed one wrong of_irq_count() noticed by Bjorn

This v2 patch applied.

Yours,
Linus Walleij

#12 lore raw

Re: [PATCH 3/3] Revert "pinctrl: qcom: make PMIC drivers bool"

In reply to Stephen Boyd
Quoted 7 lines · Stephen Boyd

This reverts commit bda7c4c2b9767ce2af4394754498662d62079af5. These drivers build as modules now that we use platform_irq_count() instead of of_irq_count().

Cc Rob Herring <[email protected]>
Cc Andy Gross <[email protected]>

Patch applied.

Thanks for digging in and fixing this, excellent work as always.

Yours,
Linus Walleij

Acked-by on v1 1/3
#5 lore raw

Re: [PATCH 1/3] driver-core: platform: Add platform_irq_count()

In reply to Stephen Boyd
Quoted 9 lines · On Wednesday 06 January 2016 17:12:47 Stephen Boyd wrote:

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.

Quoted 5 lines
Cc Rob Herring <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Andy Gross <[email protected]>

I think there are a couple of other drivers that can use this too.

Arnd