Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

NFC: pn544: use flags argument of devm_gpiod_get to set direction

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>

authored by

Uwe Kleine-König and committed by
Samuel Ortiz
8a2151c5 0cd6f667

+11 -32
+11 -32
drivers/nfc/pn544/i2c.c
··· 895 895 return -ENODEV; 896 896 897 897 /* Get EN GPIO from ACPI */ 898 - gpiod_en = devm_gpiod_get_index(dev, PN544_GPIO_NAME_EN, 1); 898 + gpiod_en = devm_gpiod_get_index(dev, PN544_GPIO_NAME_EN, 1, 899 + GPIOD_OUT_LOW); 899 900 if (IS_ERR(gpiod_en)) { 900 - nfc_err(dev, 901 - "Unable to get EN GPIO\n"); 901 + nfc_err(dev, "Unable to get EN GPIO\n"); 902 902 return -ENODEV; 903 903 } 904 904 905 - phy->gpio_en = desc_to_gpio(gpiod_en); 906 - 907 - /* Configuration EN GPIO */ 908 - ret = gpiod_direction_output(gpiod_en, 0); 909 - if (ret) { 910 - nfc_err(dev, "Fail EN pin direction\n"); 911 - return ret; 912 - } 905 + phy->gpio_en = desc_to_gpio(gpiod_en); 913 906 914 907 /* Get FW GPIO from ACPI */ 915 - gpiod_fw = devm_gpiod_get_index(dev, PN544_GPIO_NAME_FW, 2); 908 + gpiod_fw = devm_gpiod_get_index(dev, PN544_GPIO_NAME_FW, 2, 909 + GPIOD_OUT_LOW); 916 910 if (IS_ERR(gpiod_fw)) { 917 - nfc_err(dev, 918 - "Unable to get FW GPIO\n"); 911 + nfc_err(dev, "Unable to get FW GPIO\n"); 919 912 return -ENODEV; 920 913 } 921 914 922 - phy->gpio_fw = desc_to_gpio(gpiod_fw); 923 - 924 - /* Configuration FW GPIO */ 925 - ret = gpiod_direction_output(gpiod_fw, 0); 926 - if (ret) { 927 - nfc_err(dev, "Fail FW pin direction\n"); 928 - return ret; 929 - } 915 + phy->gpio_fw = desc_to_gpio(gpiod_fw); 930 916 931 917 /* Get IRQ GPIO */ 932 - gpiod_irq = devm_gpiod_get_index(dev, PN544_GPIO_NAME_IRQ, 0); 918 + gpiod_irq = devm_gpiod_get_index(dev, PN544_GPIO_NAME_IRQ, 0, 919 + GPIOD_IN); 933 920 if (IS_ERR(gpiod_irq)) { 934 - nfc_err(dev, 935 - "Unable to get IRQ GPIO\n"); 921 + nfc_err(dev, "Unable to get IRQ GPIO\n"); 936 922 return -ENODEV; 937 923 } 938 924 939 925 phy->gpio_irq = desc_to_gpio(gpiod_irq); 940 - 941 - /* Configure IRQ GPIO */ 942 - ret = gpiod_direction_input(gpiod_irq); 943 - if (ret) { 944 - nfc_err(dev, "Fail IRQ pin direction\n"); 945 - return ret; 946 - } 947 926 948 927 /* Map the pin to an IRQ */ 949 928 ret = gpiod_to_irq(gpiod_irq);