[1/2] gpio: davinci: Move fetching IRQ to beginning of probe

Message ID 1528276734-1483-1-git-send-email-j-keerthy@ti.com
State New
Headers show
Series
  • [1/2] gpio: davinci: Move fetching IRQ to beginning of probe
Related show

Commit Message

Keerthy June 6, 2018, 9:18 a.m.
Currently IRQ resource fetching is done at the very end of probe.
In case the of IRQ resource not being ready, we defer probe
and need to revert prior changes. Hence move it to the beginning of
the probe so as to avoid reverting.

Signed-off-by: Keerthy <j-keerthy@ti.com>
---

Tested for GPIO Interrupts on da850-lcdk and keystone-k2g-evm boards.

 drivers/gpio/gpio-davinci.c | 29 +++++++++++------------------
 1 file changed, 11 insertions(+), 18 deletions(-)

Comments

Linus Walleij June 12, 2018, 1:09 p.m. | #1
On Wed, Jun 6, 2018 at 11:18 AM, Keerthy <j-keerthy@ti.com> wrote:

> Currently IRQ resource fetching is done at the very end of probe.
> In case the of IRQ resource not being ready, we defer probe
> and need to revert prior changes. Hence move it to the beginning of
> the probe so as to avoid reverting.
>
> Signed-off-by: Keerthy <j-keerthy@ti.com>

Patch applied for v4.19.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keerthy June 12, 2018, 2:35 p.m. | #2
On 6/12/2018 6:39 PM, Linus Walleij wrote:
> On Wed, Jun 6, 2018 at 11:18 AM, Keerthy <j-keerthy@ti.com> wrote:
> 
>> Currently IRQ resource fetching is done at the very end of probe.
>> In case the of IRQ resource not being ready, we defer probe
>> and need to revert prior changes. Hence move it to the beginning of
>> the probe so as to avoid reverting.
>>
>> Signed-off-by: Keerthy <j-keerthy@ti.com>
> 
> Patch applied for v4.19.

Linus,

There is a minor fix in v3.

https://patchwork.kernel.org/patch/10459591/

Also v3 of Patch 2 Here:

https://lkml.org/lkml/2018/6/12/146

Regards,
Keerthy
> 
> Yours,
> Linus Walleij
> --
> To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keerthy June 13, 2018, 3:48 a.m. | #3
On Tuesday 12 June 2018 08:05 PM, J, KEERTHY wrote:
> 
> 
> On 6/12/2018 6:39 PM, Linus Walleij wrote:
>> On Wed, Jun 6, 2018 at 11:18 AM, Keerthy <j-keerthy@ti.com> wrote:
>>
>>> Currently IRQ resource fetching is done at the very end of probe.
>>> In case the of IRQ resource not being ready, we defer probe
>>> and need to revert prior changes. Hence move it to the beginning of
>>> the probe so as to avoid reverting.
>>>
>>> Signed-off-by: Keerthy <j-keerthy@ti.com>
>>
>> Patch applied for v4.19.
> 
> Linus,
> 
> There is a minor fix in v3.
> 
> https://patchwork.kernel.org/patch/10459591/
> 
> Also v3 of Patch 2 Here:
> 
> https://lkml.org/lkml/2018/6/12/146


Posted a v4:

Patch 1: https://patchwork.ozlabs.org/patch/928638/
Patch 2: https://patchwork.ozlabs.org/patch/928639/


> 
> Regards,
> Keerthy
>>
>> Yours,
>> Linus Walleij
>> -- 
>> To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 987126c..861f35b 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -55,7 +55,7 @@  static inline struct davinci_gpio_regs __iomem *irq2regs(struct irq_data *d)
 	return g;
 }
 
-static int davinci_gpio_irq_setup(struct platform_device *pdev);
+static int davinci_gpio_irq_setup(struct platform_device *pdev, int bank_irq);
 
 /*--------------------------------------------------------------------------*/
 
@@ -168,7 +168,7 @@  static int davinci_gpio_probe(struct platform_device *pdev)
 {
 	static int ctrl_num, bank_base;
 	int gpio, bank, ret = 0;
-	unsigned ngpio, nbank;
+	unsigned int ngpio, nbank, bank_irq;
 	struct davinci_gpio_controller *chips;
 	struct davinci_gpio_platform_data *pdata;
 	struct device *dev = &pdev->dev;
@@ -209,6 +209,12 @@  static int davinci_gpio_probe(struct platform_device *pdev)
 	if (IS_ERR(gpio_base))
 		return PTR_ERR(gpio_base);
 
+	bank_irq = platform_get_irq(pdev, 0);
+	if (bank_irq < 0) {
+		dev_dbg(dev, "IRQ not populated\n");
+		return bank_irq;
+	}
+
 	snprintf(label, MAX_LABEL_SIZE, "davinci_gpio.%d", ctrl_num++);
 	chips->chip.label = devm_kstrdup(dev, label, GFP_KERNEL);
 		if (!chips->chip.label)
@@ -243,7 +249,7 @@  static int davinci_gpio_probe(struct platform_device *pdev)
 		goto err;
 
 	platform_set_drvdata(pdev, chips);
-	ret = davinci_gpio_irq_setup(pdev);
+	ret = davinci_gpio_irq_setup(pdev, bank_irq);
 	if (ret)
 		goto err;
 
@@ -452,16 +458,15 @@  static struct irq_chip *keystone_gpio_get_irq_chip(unsigned int irq)
  * (dm6446) can be set appropriately for GPIOV33 pins.
  */
 
-static int davinci_gpio_irq_setup(struct platform_device *pdev)
+static int davinci_gpio_irq_setup(struct platform_device *pdev, int bank_irq)
 {
 	unsigned	gpio, bank;
 	int		irq;
 	int		ret;
 	struct clk	*clk;
 	u32		binten = 0;
-	unsigned	ngpio, bank_irq;
+	unsigned int	ngpio;
 	struct device *dev = &pdev->dev;
-	struct resource	*res;
 	struct davinci_gpio_controller *chips = platform_get_drvdata(pdev);
 	struct davinci_gpio_platform_data *pdata = dev->platform_data;
 	struct davinci_gpio_regs __iomem *g;
@@ -481,18 +486,6 @@  static int davinci_gpio_irq_setup(struct platform_device *pdev)
 		gpio_get_irq_chip = (gpio_get_irq_chip_cb_t)match->data;
 
 	ngpio = pdata->ngpio;
-	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (!res) {
-		dev_err(dev, "Invalid IRQ resource\n");
-		return -EBUSY;
-	}
-
-	bank_irq = res->start;
-
-	if (!bank_irq) {
-		dev_err(dev, "Invalid IRQ resource\n");
-		return -ENODEV;
-	}
 
 	clk = devm_clk_get(dev, "gpio");
 	if (IS_ERR(clk)) {