Skip to contentSkip to conversation

NFC: st21nfca: Convert to use devm_gpio_request_one

PATCH In review Axel Lin 2 participants 2 messages May 26, 2014 – Jul 25, 2014 1 message not in the archive NFC

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 NFC: st21nfca: Convert to use devm_gpio_request_one

This simplifies the code a bit.

---
 drivers/nfc/st21nfca/i2c.c | 28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)
drivers/nfc/st21nfca/i2c.c +6 -22
index 3f954ed..0e096ad 100644
@@ -524,17 +524,13 @@ static int st21nfca_hci_i2c_of_request_resources(struct i2c_client *client)
 	}
 
 	/* GPIO request and configuration */
-	r = devm_gpio_request(&client->dev, gpio, "clf_enable");
+	r = devm_gpio_request_one(&client->dev, gpio, GPIOF_OUT_INIT_HIGH,
+				  "clf_enable");
 	if (r) {
 		nfc_err(&client->dev, "Failed to request enable pin\n");
 		return -ENODEV;
 	}
 
-	r = gpio_direction_output(gpio, 1);
-	if (r) {
-		nfc_err(&client->dev, "Failed to set enable pin direction as output\n");
-		return -ENODEV;
-	}
 	phy->gpio_ena = gpio;
 
 	/* IRQ */
@@ -575,32 +571,20 @@ static int st21nfca_hci_i2c_request_resources(struct i2c_client *client)
 	phy->gpio_ena = pdata->gpio_ena;
 	phy->irq_polarity = pdata->irq_polarity;
 
-	r = devm_gpio_request(&client->dev, phy->gpio_irq, "wake_up");
+	r = devm_gpio_request_one(&client->dev, phy->gpio_irq, GPIOF_IN,
+				  "wake_up");
 	if (r) {
 		pr_err("%s : gpio_request failed\n", __FILE__);
 		return -ENODEV;
 	}
 
-	r = gpio_direction_input(phy->gpio_irq);
-	if (r) {
-		pr_err("%s : gpio_direction_input failed\n", __FILE__);
-		return -ENODEV;
-	}
-
 	if (phy->gpio_ena > 0) {
-		r = devm_gpio_request(&client->dev,
-					phy->gpio_ena, "clf_enable");
+		r = devm_gpio_request_one(&client->dev, phy->gpio_ena,
+					  GPIOF_OUT_INIT_HIGH, "clf_enable");
 		if (r) {
 			pr_err("%s : ena gpio_request failed\n", __FILE__);
 			return -ENODEV;
 		}
-		r = gpio_direction_output(phy->gpio_ena, 1);
-
-		if (r) {
-			pr_err("%s : ena gpio_direction_output failed\n",
-			       __FILE__);
-			return -ENODEV;
-		}
 	}
 
 	/* IRQ */
Signature · 1 line
1.8.3.2

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 69 lines · On Mon, 26 May 2014 16:00:08 +0200 Axel Lin <[email protected]> wrote:

This simplifies the code a bit.

---
 drivers/nfc/st21nfca/i2c.c | 28 ++++++----------------------
 1 file changed, 6 insertions(+), 22 deletions(-)
drivers/nfc/st21nfca/i2c.c +3 -6
index 3f954ed..0e096ad 100644 --- a/drivers/nfc/st21nfca/i2c.c
+++ b/drivers/nfc/st21nfca/i2c.c
@@ -524,17 +524,13 @@ static int
 st21nfca_hci_i2c_of_request_resources(struct i2c_client *client) }
 
 	/* GPIO request and configuration */
-	r = devm_gpio_request(&client->dev, gpio, "clf_enable");
+	r = devm_gpio_request_one(&client->dev, gpio,
 GPIOF_OUT_INIT_HIGH,
+				  "clf_enable");
 	if (r) {
 		nfc_err(&client->dev, "Failed to request enable
 pin\n"); return -ENODEV;
 	}
 
-	r = gpio_direction_output(gpio, 1);
-	if (r) {
-		nfc_err(&client->dev, "Failed to set enable pin
 direction as output\n");
-		return -ENODEV;
-	}
 	phy->gpio_ena = gpio;
drivers/nfc/st21nfca/i2c.c +0 -0
 	/* IRQ */
@@ -575,32 +571,20 @@ static int
 st21nfca_hci_i2c_request_resources(struct i2c_client *client)

phy->gpio_ena = pdata->gpio_ena; phy->irq_polarity = pdata->irq_polarity;

drivers/nfc/st21nfca/i2c.c +0 -1
-	r = devm_gpio_request(&client->dev, phy->gpio_irq,

"wake_up");

drivers/nfc/st21nfca/i2c.c +1 -0
+	r = devm_gpio_request_one(&client->dev, phy->gpio_irq,

GPIOF_IN,

drivers/nfc/st21nfca/i2c.c +1 -3
+				  "wake_up");
 	if (r) {
 		pr_err("%s : gpio_request failed\n", __FILE__);
 		return -ENODEV;
 	}
 
-	r = gpio_direction_input(phy->gpio_irq);
-	if (r) {
-		pr_err("%s : gpio_direction_input failed\n",

__FILE__);

drivers/nfc/st21nfca/i2c.c +1 -5
-		return -ENODEV;
-	}
-
 	if (phy->gpio_ena > 0) {
-		r = devm_gpio_request(&client->dev,
-					phy->gpio_ena, "clf_enable");
+		r = devm_gpio_request_one(&client->dev,

phy->gpio_ena,

drivers/nfc/st21nfca/i2c.c +1 -0
+					  GPIOF_OUT_INIT_HIGH,

"clf_enable"); if (r) {
pr_err("%s : ena gpio_request failed\n",
__FILE__); return -ENODEV;

drivers/nfc/st21nfca/i2c.c +0 -4
 		}
-		r = gpio_direction_output(phy->gpio_ena, 1);
-
-		if (r) {
-			pr_err("%s : ena gpio_direction_output

failed\n",

drivers/nfc/st21nfca/i2c.c static int st21nfca_hci_i2c_request_resources(struct i2c_client *client) · line 590

Quoted 6 lines
drivers/nfc/st21nfca/i2c.c +0 -3
-			       __FILE__);
-			return -ENODEV;
-		}
 	}
 
 	/* IRQ */