Skip to contentSkip to conversation

mfd: aat2870-core: Use gpio_request_one

PATCH In review Axel Lin 4 participants 10 messages Dec 1, 2011 – Dec 19, 2011

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/4 mfd: aat2870-core: Use gpio_request_one

Use gpio_request_one() instead of multiple gpiolib calls.

---
 drivers/mfd/aat2870-core.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/mfd/aat2870-core.c +2 -2
index 02c4201..7620617 100644
@@ -407,13 +407,13 @@ static int aat2870_i2c_probe(struct i2c_client *client,
 		aat2870->init(aat2870);
 
 	if (aat2870->en_pin >= 0) {
-		ret = gpio_request(aat2870->en_pin, "aat2870-en");
+		ret = gpio_request_one(aat2870->en_pin, GPIOF_OUT_INIT_HIGH,
+				       "aat2870-en");
 		if (ret < 0) {
 			dev_err(&client->dev,
 				"Failed to request GPIO %d\n", aat2870->en_pin);
 			goto out_kfree;
 		}
-		gpio_direction_output(aat2870->en_pin, 1);
 	}
 
 	aat2870_enable(aat2870);
Signature · 1 line
1.7.5.4
author
#1 lore raw

PATCH 2/4 mfd: dm355evm_msp: Use gpio_request_one

Use gpio_request_one() instead of multiple gpiolib calls.

---
 drivers/mfd/dm355evm_msp.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/mfd/dm355evm_msp.c +1 -2
index 8ad88da..7710227 100644
@@ -308,8 +308,7 @@ static int add_children(struct i2c_client *client)
 	for (i = 0; i < ARRAY_SIZE(config_inputs); i++) {
 		int gpio = dm355evm_msp_gpio.base + config_inputs[i].offset;
 
-		gpio_request(gpio, config_inputs[i].label);
-		gpio_direction_input(gpio);
+		gpio_request_one(gpio, GPIOF_IN, config_inputs[i].label);
 
 		/* make it easy for userspace to see these */
 		gpio_export(gpio, false);
Signature · 1 line
1.7.5.4
author
#2 lore raw

PATCH 3/4 mfd: omap-usb-host: Use gpio_request_one

In reply to Axel Lin

Use gpio_request_one() instead of multiple gpiolib calls.

---
 drivers/mfd/omap-usb-host.c |   20 +++++++-------------
 1 files changed, 7 insertions(+), 13 deletions(-)
drivers/mfd/omap-usb-host.c +6 -12
index 86e1458..6533ecc 100644
@@ -715,19 +715,13 @@ static int usbhs_enable(struct device *dev)
 	clk_enable(omap->usbtll_ick);
 
 	if (pdata->ehci_data->phy_reset) {
-		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) {
-			gpio_request(pdata->ehci_data->reset_gpio_port[0],
-						"USB1 PHY reset");
-			gpio_direction_output
-				(pdata->ehci_data->reset_gpio_port[0], 0);
-		}
+		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
+			gpio_request_one(pdata->ehci_data->reset_gpio_port[0],
+					 GPIOF_OUT_INIT_LOW, "USB1 PHY reset");
 
-		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) {
-			gpio_request(pdata->ehci_data->reset_gpio_port[1],
-						"USB2 PHY reset");
-			gpio_direction_output
-				(pdata->ehci_data->reset_gpio_port[1], 0);
-		}
+		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
+			gpio_request_one(pdata->ehci_data->reset_gpio_port[1],
+					 GPIOF_OUT_INIT_LOW, "USB2 PHY reset");
 
 		/* Hold the PHY in RESET for enough time till DIR is high */
 		udelay(10);
Signature · 1 line
1.7.5.4
#3 lore raw

Re: [PATCH 3/4] mfd: omap-usb-host: Use gpio_request_one

Hi Axel,

Quoted 24 lines · Axel Lin

Use gpio_request_one() instead of multiple gpiolib calls.

---
 drivers/mfd/omap-usb-host.c |   20 +++++++-------------
 1 files changed, 7 insertions(+), 13 deletions(-)
drivers/mfd/omap-usb-host.c +3 -6
index 86e1458..6533ecc 100644
@@ -715,19 +715,13 @@ static int usbhs_enable(struct device *dev)
 	clk_enable(omap->usbtll_ick);
 
 	if (pdata->ehci_data->phy_reset) {
-		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0])) {
-			gpio_request(pdata->ehci_data->reset_gpio_port[0],
-						"USB1 PHY reset");
-			gpio_direction_output
-				(pdata->ehci_data->reset_gpio_port[0], 0);
-		}
+		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[0]))
+			gpio_request_one(pdata->ehci_data->reset_gpio_port[0],
+					 GPIOF_OUT_INIT_LOW, "USB1 PHY reset");

drivers/mfd/omap-usb-host.c static int usbhs_enable(struct device *dev) · line 724

Quoted 10 lines
drivers/mfd/omap-usb-host.c +3 -6
 
-		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1])) {
-			gpio_request(pdata->ehci_data->reset_gpio_port[1],
-						"USB2 PHY reset");
-			gpio_direction_output
-				(pdata->ehci_data->reset_gpio_port[1], 0);
-		}
+		if (gpio_is_valid(pdata->ehci_data->reset_gpio_port[1]))
+			gpio_request_one(pdata->ehci_data->reset_gpio_port[1],
+					 GPIOF_OUT_INIT_LOW, "USB2 PHY reset");

I was wondering, if we need the gpio_is_valid() check here and above? gpio_request() already does the gpio_is_valid() check,
so why should we double check?

Signature · 2 lines
Regards,
Igor.
author
#4 lore raw

PATCH 4/4 mfd: twl6040-core: Use gpio_request_one

In reply to Axel Lin

Use gpio_request_one() instead of multiple gpiolib calls.

---
 drivers/mfd/twl6040-core.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
drivers/mfd/twl6040-core.c +2 -5
index 268f80f..e57b1d1 100644
@@ -509,13 +509,10 @@ static int __devinit twl6040_probe(struct platform_device *pdev)
 		twl6040->audpwron = -EINVAL;
 
 	if (gpio_is_valid(twl6040->audpwron)) {
-		ret = gpio_request(twl6040->audpwron, "audpwron");
+		ret = gpio_request_one(twl6040->audpwron, GPIOF_OUT_INIT_LOW,
+				       "audpwron");
 		if (ret)
 			goto gpio1_err;
-
-		ret = gpio_direction_output(twl6040->audpwron, 0);
-		if (ret)
-			goto gpio2_err;
 	}
 
 	/* codec interrupt */
Signature · 1 line
1.7.5.4
#5 lore raw

Re: [PATCH 4/4] mfd: twl6040-core: Use gpio_request_one

Quoted 15 lines · Axel Lin

Use gpio_request_one() instead of multiple gpiolib calls.

---
 drivers/mfd/twl6040-core.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
drivers/mfd/twl6040-core.c +0 -0
index 268f80f..e57b1d1 100644
@@ -509,13 +509,10 @@ static int __devinit twl6040_probe(struct platform_device *pdev)
 		twl6040->audpwron = -EINVAL;
 
 	if (gpio_is_valid(twl6040->audpwron)) {

drivers/mfd/twl6040-core.c static int __devinit twl6040_probe(struct platform_device *pdev) · line 516

Quoted 10 lines
drivers/mfd/twl6040-core.c +2 -5
-		ret = gpio_request(twl6040->audpwron, "audpwron");
+		ret = gpio_request_one(twl6040->audpwron, GPIOF_OUT_INIT_LOW,
+				       "audpwron");
 		if (ret)
 			goto gpio1_err;
-
-		ret = gpio_direction_output(twl6040->audpwron, 0);
-		if (ret)
-			goto gpio2_err;
 	}

same here, double check gpio_is_valid()?

Signature · 2 lines
Regards,
Igor.
author
#6 lore raw

Re: [PATCH 4/4] mfd: twl6040-core: Use gpio_request_one

2011/12/1 Igor Grinberg <[email protected]>:

Quoted 15 lines · Axel Lin
Quoted 14 lines

Use gpio_request_one() instead of multiple gpiolib calls.

---
 drivers/mfd/twl6040-core.c |    7 ++-----

 1 files changed, 2 insertions(+), 5 deletions(-)
drivers/mfd/twl6040-core.c +0 -0
index 268f80f..e57b1d1 100644
@@ -509,13 +509,10 @@ static int __devinit twl6040_probe(struct platform_device *pdev)
               twl6040->audpwron = -EINVAL;
 
Quoted 13 lines

drivers/mfd/twl6040-core.c static int __devinit twl6040_probe(struct platform_device *pdev) · line 516

Quoted 11 lines
drivers/mfd/twl6040-core.c +2 -5
       if (gpio_is_valid(twl6040->audpwron)) {
-             ret = gpio_request(twl6040->audpwron, "audpwron");
+             ret = gpio_request_one(twl6040->audpwron, GPIOF_OUT_INIT_LOW,
+                                    "audpwron");
               if (ret)
                       goto gpio1_err;
-
-             ret = gpio_direction_output(twl6040->audpwron, 0);
-             if (ret)
-                     goto gpio2_err;
       }

same here, double check gpio_is_valid()?

In the case of
twl6040->audpwron = -EINVAL; ( see line 509 ) gpio_is_valid returns false, we just don't request gpio.

If we remove the gpio_is_valid checking here,
then gpio_request_one will return -EINVAL.
Then the code always goes to the error path if twl6040->audpwron is -EINVAL.

Axel

Quoted 5 lines

--
Regards,
Igor.

#7 lore raw

Re: [PATCH 4/4] mfd: twl6040-core: Use gpio_request_one

Quoted 30 lines · Axel Lin

2011/12/1 Igor Grinberg <[email protected]>:

Quoted 15 lines · Axel Lin
Quoted 14 lines

Use gpio_request_one() instead of multiple gpiolib calls.

---
 drivers/mfd/twl6040-core.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
drivers/mfd/twl6040-core.c +0 -0
index 268f80f..e57b1d1 100644
@@ -509,13 +509,10 @@ static int __devinit twl6040_probe(struct platform_device *pdev)
              twl6040->audpwron = -EINVAL;
 
Quoted 13 lines

drivers/mfd/twl6040-core.c static int __devinit twl6040_probe(struct platform_device *pdev) · line 516

Quoted 11 lines
drivers/mfd/twl6040-core.c +2 -5
      if (gpio_is_valid(twl6040->audpwron)) {
-             ret = gpio_request(twl6040->audpwron, "audpwron");
+             ret = gpio_request_one(twl6040->audpwron, GPIOF_OUT_INIT_LOW,
+                                    "audpwron");
              if (ret)
                      goto gpio1_err;
-
-             ret = gpio_direction_output(twl6040->audpwron, 0);
-             if (ret)
-                     goto gpio2_err;
      }

same here, double check gpio_is_valid()?

Quoted 7 lines

In the case of
twl6040->audpwron = -EINVAL; ( see line 509 ) gpio_is_valid returns false, we just don't request gpio.

If we remove the gpio_is_valid checking here,
then gpio_request_one will return -EINVAL.
Then the code always goes to the error path if twl6040->audpwron is -EINVAL.

Thanks for the explanation.
So the GPIO is optional - now it makes sense to me.

Signature · 2 lines
Regards,
Igor.
Acked-by on v1 1/4
#8 lore raw
In reply to Axel Lin
Quoted 27 lines · Axel Lin

Use gpio_request_one() instead of multiple gpiolib calls.

---
  drivers/mfd/aat2870-core.c |    4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
drivers/mfd/aat2870-core.c +2 -2
index 02c4201..7620617 100644
@@ -407,13 +407,13 @@ static int aat2870_i2c_probe(struct i2c_client *client,
  		aat2870->init(aat2870);
 
  	if (aat2870->en_pin>= 0) {
-		ret = gpio_request(aat2870->en_pin, "aat2870-en");
+		ret = gpio_request_one(aat2870->en_pin, GPIOF_OUT_INIT_HIGH,
+				       "aat2870-en");
  		if (ret<  0) {
  			dev_err(&client->dev,
  				"Failed to request GPIO %d\n", aat2870->en_pin);
  			goto out_kfree;
  		}
-		gpio_direction_output(aat2870->en_pin, 1);
  	}
 
  	aat2870_enable(aat2870);
#9 lore raw
In reply to Axel Lin

Hi Axel,

Quoted 1 line · Axel Lin

Use gpio_request_one() instead of multiple gpiolib calls.

All 4 patches applied, thanks.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/