NFC: pn544: use flags argument of devm_gpiod_get to set direction
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tue, 19 May 2015 07:22:56 +0000 (09:22 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 8 Jun 2015 22:34:19 +0000 (00:34 +0200)
Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*()
functions) which appeared in v3.17-rc1, the gpiod_get* functions
take an additional parameter that allows to specify direction and
initial value for output.

Use this to simplify the driver. Furthermore this is one caller less
that stops us making the flags argument to gpiod_get*() mandatory.

While touching this also do some minor coding style fixes.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/pn544/i2c.c

index 6fd986f5ac3ed522e46a1c226ba418f4576b1711..fa75c53f3fa53878fc6b21136aa2f14d410de59b 100644 (file)
@@ -895,56 +895,35 @@ static int pn544_hci_i2c_acpi_request_resources(struct i2c_client *client)
                return -ENODEV;
 
        /* Get EN GPIO from ACPI */
-       gpiod_en = devm_gpiod_get_index(dev, PN544_GPIO_NAME_EN, 1);
+       gpiod_en = devm_gpiod_get_index(dev, PN544_GPIO_NAME_EN, 1,
+                                       GPIOD_OUT_LOW);
        if (IS_ERR(gpiod_en)) {
-               nfc_err(dev,
-                       "Unable to get EN GPIO\n");
+               nfc_err(dev, "Unable to get EN GPIO\n");
                return -ENODEV;
        }
 
-       phy->gpio_en  = desc_to_gpio(gpiod_en);
-
-       /* Configuration EN GPIO */
-       ret = gpiod_direction_output(gpiod_en, 0);
-       if (ret) {
-               nfc_err(dev, "Fail EN pin direction\n");
-               return ret;
-       }
+       phy->gpio_en = desc_to_gpio(gpiod_en);
 
        /* Get FW GPIO from ACPI */
-       gpiod_fw = devm_gpiod_get_index(dev, PN544_GPIO_NAME_FW, 2);
+       gpiod_fw = devm_gpiod_get_index(dev, PN544_GPIO_NAME_FW, 2,
+                                       GPIOD_OUT_LOW);
        if (IS_ERR(gpiod_fw)) {
-               nfc_err(dev,
-                       "Unable to get FW GPIO\n");
+               nfc_err(dev, "Unable to get FW GPIO\n");
                return -ENODEV;
        }
 
-       phy->gpio_fw  = desc_to_gpio(gpiod_fw);
-
-       /* Configuration FW GPIO */
-       ret = gpiod_direction_output(gpiod_fw, 0);
-       if (ret) {
-               nfc_err(dev, "Fail FW pin direction\n");
-               return ret;
-       }
+       phy->gpio_fw = desc_to_gpio(gpiod_fw);
 
        /* Get IRQ GPIO */
-       gpiod_irq = devm_gpiod_get_index(dev, PN544_GPIO_NAME_IRQ, 0);
+       gpiod_irq = devm_gpiod_get_index(dev, PN544_GPIO_NAME_IRQ, 0,
+                                        GPIOD_IN);
        if (IS_ERR(gpiod_irq)) {
-               nfc_err(dev,
-                       "Unable to get IRQ GPIO\n");
+               nfc_err(dev, "Unable to get IRQ GPIO\n");
                return -ENODEV;
        }
 
        phy->gpio_irq = desc_to_gpio(gpiod_irq);
 
-       /* Configure IRQ GPIO */
-       ret = gpiod_direction_input(gpiod_irq);
-       if (ret) {
-               nfc_err(dev, "Fail IRQ pin direction\n");
-               return ret;
-       }
-
        /* Map the pin to an IRQ */
        ret = gpiod_to_irq(gpiod_irq);
        if (ret < 0) {