Make qcom pinctrl drivers tristate again
Subsystems (5)
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.
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
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.
--- drivers/base/platform.c | 20 ++++++++++++++++++++ include/linux/platform_device.h | 1 + 2 files changed, 21 insertions(+)
drivers/base/platform.c +20 -0
@@ -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
@@ -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
Re: [PATCH 1/3] driver-core: platform: Add platform_irq_count()
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 becauseof_irq_count()is not an exported symbol. We shouldn't exportof_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 aplatform_irq_count()API that mirrors theof_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]>Signed-off-by Stephen Boyd <[email protected]>
Re: [PATCH 1/3] driver-core: platform: Add platform_irq_count()
In reply to Stephen BoydQuoted 9 lines · Stephen Boyd
A recent patch added calls to
of_irq_count()in the qcom pinctrl drivers and that caused module build failures becauseof_irq_count()is not an exported symbol. We shouldn't exportof_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 aplatform_irq_count()API that mirrors theof_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]>Signed-off-by Stephen Boyd <[email protected]>--- drivers/base/platform.c | 20 ++++++++++++++++++++ include/linux/platform_device.h | 1 + 2 files changed, 21 insertions(+)
Re: [PATCH 1/3] driver-core: platform: Add platform_irq_count()
In reply to Stephen BoydQuoted 9 lines · Stephen Boyd
A recent patch added calls to
of_irq_count()in the qcom pinctrl drivers and that caused module build failures becauseof_irq_count()is not an exported symbol. We shouldn't exportof_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 aplatform_irq_count()API that mirrors theof_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]>Signed-off-by Stephen Boyd <[email protected]>
Patch applied with Rob's and Greg's ACKs.
Yours,
Linus Walleij
Re: [PATCH 1/3] driver-core: platform: Add platform_irq_count()
In reply to Stephen BoydQuoted 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 becauseof_irq_count()is not an exported symbol. We shouldn't exportof_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 aplatform_irq_count()API that mirrors theof_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]>Signed-off-by Stephen Boyd <[email protected]>
I think there are a couple of other drivers that can use this too.
Arnd
PATCH 2/3 pinctrl: qcom: Use platform_irq_count() instead of of_irq_count()
In reply to Stephen Boydof_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.
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
Re: [PATCH 2/3] pinctrl: qcom: Use platform_irq_count() instead of of_irq_count()
Quoted 5 lines · Stephen Boyd
of_irq_count()is not an exported symbol (and it shouldn't be used by platform drivers anyway) so useplatform_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@@ -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
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 useplatform_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@@ -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
-2pctrl->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
PATCH v2 2/3 pinctrl: qcom: Use platform_irq_count() instead of of_irq_count()
In reply to Bjorn Anderssonof_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.
---
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
@@ -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
@@ -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
@@ -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
@@ -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
Re: [PATCH v2 2/3] pinctrl: qcom: Use platform_irq_count() instead of of_irq_count()
Quoted 5 lines · Stephen Boyd
of_irq_count()is not an exported symbol (and it shouldn't be used by platform drivers anyway) so useplatform_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]>Signed-off-by Stephen Boyd <[email protected]>---
Changes from v1:
* Fixed one wrongof_irq_count()noticed by Bjorn
This v2 patch applied.
Yours,
Linus Walleij
PATCH 3/3 Revert "pinctrl: qcom: make PMIC drivers bool"
In reply to Stephen BoydThis reverts commit bda7c4c2b9767ce2af4394754498662d62079af5. These drivers build as modules now that we use platform_irq_count() instead of of_irq_count().
--- drivers/pinctrl/qcom/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/qcom/Kconfig +2 -2
@@ -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
Re: [PATCH 3/3] Revert "pinctrl: qcom: make PMIC drivers bool"
Quoted 7 lines · Stephen Boyd
This reverts commit
bda7c4c2b9767ce2af4394754498662d62079af5. These drivers build as modules now that we useplatform_irq_count()instead ofof_irq_count().Cc Rob Herring <[email protected]>Cc Andy Gross <[email protected]>Signed-off-by Stephen Boyd <[email protected]>
Patch applied.
Thanks for digging in and fixing this, excellent work as always.
Yours,
Linus Walleij