2013-09-24 07:46:17

by Axel Lin

[permalink] [raw]
Subject: [PATCH 1/2] pinctrl: adi2: Convert to devm_ioremap_resource

Signed-off-by: Axel Lin <[email protected]>
---
drivers/pinctrl/pinctrl-adi2.c | 38 ++++++--------------------------------
1 file changed, 6 insertions(+), 32 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-adi2.c b/drivers/pinctrl/pinctrl-adi2.c
index 7a24e59..f2aa877 100644
--- a/drivers/pinctrl/pinctrl-adi2.c
+++ b/drivers/pinctrl/pinctrl-adi2.c
@@ -855,22 +855,9 @@ static int adi_gpio_pint_probe(struct platform_device *pdev)
}

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(dev, "Invalid mem resource\n");
- return -ENODEV;
- }
-
- if (!devm_request_mem_region(dev, res->start, resource_size(res),
- pdev->name)) {
- dev_err(dev, "Region already claimed\n");
- return -EBUSY;
- }
-
- pint->base = devm_ioremap(dev, res->start, resource_size(res));
- if (!pint->base) {
- dev_err(dev, "Could not ioremap\n");
- return -ENOMEM;
- }
+ pint->base = devm_ioremap_resource(dev, res);
+ if (IS_ERR(pint->base))
+ return PTR_ERR(pint->base);

pint->regs = (struct gpio_pint_regs *)pint->base;

@@ -984,22 +971,9 @@ static int adi_gpio_probe(struct platform_device *pdev)
}

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res) {
- dev_err(dev, "Invalid mem resource\n");
- return -ENODEV;
- }
-
- if (!devm_request_mem_region(dev, res->start, resource_size(res),
- pdev->name)) {
- dev_err(dev, "Region already claimed\n");
- return -EBUSY;
- }
-
- port->base = devm_ioremap(dev, res->start, resource_size(res));
- if (!port->base) {
- dev_err(dev, "Could not ioremap\n");
- return -ENOMEM;
- }
+ port->base = devm_ioremap_resource(dev, res);
+ if (IS_ERR(port->base))
+ return PTR_ERR(port->base);

res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res)
--
1.8.1.2



2013-09-24 07:47:45

by Axel Lin

[permalink] [raw]
Subject: [PATCH 2/2] pinctrl: adi2: Fix dead lock in adi_gpio_direction_output

Current code hold port->lock spinlock and then try to grab the lock again
in adi_gpio_set_value(). Fix it.

Signed-off-by: Axel Lin <[email protected]>
---
drivers/pinctrl/pinctrl-adi2.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-adi2.c b/drivers/pinctrl/pinctrl-adi2.c
index f2aa877..8089fda 100644
--- a/drivers/pinctrl/pinctrl-adi2.c
+++ b/drivers/pinctrl/pinctrl-adi2.c
@@ -776,10 +776,11 @@ static int adi_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
struct gpio_port_t *regs = port->regs;
unsigned long flags;

+ adi_gpio_set_value(chip, offset, value);
+
spin_lock_irqsave(&port->lock, flags);

writew(readw(&regs->inen) & ~(1 << offset), &regs->inen);
- adi_gpio_set_value(chip, offset, value);
writew(1 << offset, &regs->dir_set);

spin_unlock_irqrestore(&port->lock, flags);
--
1.8.1.2


2013-09-27 12:19:31

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 1/2] pinctrl: adi2: Convert to devm_ioremap_resource

On Tue, Sep 24, 2013 at 9:46 AM, Axel Lin <[email protected]> wrote:

> Signed-off-by: Axel Lin <[email protected]>

Patch applied, thanks Axel.

I should have caught this in review :-(

Yours,
Linus Walleij

2013-09-27 12:20:45

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 2/2] pinctrl: adi2: Fix dead lock in adi_gpio_direction_output

On Tue, Sep 24, 2013 at 9:47 AM, Axel Lin <[email protected]> wrote:

> Current code hold port->lock spinlock and then try to grab the lock again
> in adi_gpio_set_value(). Fix it.
>
> Signed-off-by: Axel Lin <[email protected]>

Patch applied, thanks Axel.

Sonic, when you see patches like this please look at and ACK
them.

Yours,
Linus Walleij

2013-10-08 02:59:37

by Sonic Zhang

[permalink] [raw]
Subject: Re: [PATCH 2/2] pinctrl: adi2: Fix dead lock in adi_gpio_direction_output

Hi Linus,

On Fri, Sep 27, 2013 at 8:20 PM, Linus Walleij <[email protected]> wrote:
> On Tue, Sep 24, 2013 at 9:47 AM, Axel Lin <[email protected]> wrote:
>
>> Current code hold port->lock spinlock and then try to grab the lock again
>> in adi_gpio_set_value(). Fix it.
>>
>> Signed-off-by: Axel Lin <[email protected]>
>
> Patch applied, thanks Axel.
>
> Sonic, when you see patches like this please look at and ACK
> them.

Sorry, I am on vacation since Sep. 24.
I will do it in future.

Regards,

Sonic