Skip to contentSkip to conversation

pinctrl: adi2: Convert to devm_ioremap_resource

PATCH In review Axel Lin 3 participants 5 messages Sep 24, 2013 – Oct 8, 2013 Pin control

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/2 pinctrl: adi2: Convert to devm_ioremap_resource

---
 drivers/pinctrl/pinctrl-adi2.c | 38 ++++++--------------------------------
 1 file changed, 6 insertions(+), 32 deletions(-)
drivers/pinctrl/pinctrl-adi2.c +6 -32
index 7a24e59..f2aa877 100644
@@ -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)
Signature · 1 line
1.8.1.2
author
#1 lore raw

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.

---
 drivers/pinctrl/pinctrl-adi2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pinctrl/pinctrl-adi2.c +2 -1
index f2aa877..8089fda 100644
@@ -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);
Signature · 1 line
1.8.1.2
#2 lore raw

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

Quoted 4 lines · Axel Lin

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

Patch applied, thanks Axel.

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

Yours,
Linus Walleij

#3 lore raw

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

Hi Linus,

Quoted 11 lines · Linus Walleij
Quoted 4 lines · Axel Lin

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

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