summaryrefslogtreecommitdiffstats
path: root/drivers/nfc/pn544
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2015-05-19 03:22:56 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2015-06-08 18:34:19 -0400
commit8a2151c587715e84af676ee6c210fd41b912de76 (patch)
tree25e554acdb674a980351cfd7346ad2905834193b /drivers/nfc/pn544
parent0cd6f66739ac8a936d4660d45ecb99eb801709a4 (diff)
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>
Diffstat (limited to 'drivers/nfc/pn544')
-rw-r--r--drivers/nfc/pn544/i2c.c43
1 files changed, 11 insertions, 32 deletions
diff --git a/drivers/nfc/pn544/i2c.c b/drivers/nfc/pn544/i2c.c
index 6fd986f5ac3e..fa75c53f3fa5 100644
--- a/drivers/nfc/pn544/i2c.c
+++ b/drivers/nfc/pn544/i2c.c
@@ -895,56 +895,35 @@ static int pn544_hci_i2c_acpi_request_resources(struct i2c_client *client)
895 return -ENODEV; 895 return -ENODEV;
896 896
897 /* Get EN GPIO from ACPI */ 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 if (IS_ERR(gpiod_en)) { 900 if (IS_ERR(gpiod_en)) {
900 nfc_err(dev, 901 nfc_err(dev, "Unable to get EN GPIO\n");
901 "Unable to get EN GPIO\n");
902 return -ENODEV; 902 return -ENODEV;
903 } 903 }
904 904
905 phy->gpio_en = desc_to_gpio(gpiod_en); 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 }
913 906
914 /* Get FW GPIO from ACPI */ 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 if (IS_ERR(gpiod_fw)) { 910 if (IS_ERR(gpiod_fw)) {
917 nfc_err(dev, 911 nfc_err(dev, "Unable to get FW GPIO\n");
918 "Unable to get FW GPIO\n");
919 return -ENODEV; 912 return -ENODEV;
920 } 913 }
921 914
922 phy->gpio_fw = desc_to_gpio(gpiod_fw); 915 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 }
930 916
931 /* Get IRQ GPIO */ 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 if (IS_ERR(gpiod_irq)) { 920 if (IS_ERR(gpiod_irq)) {
934 nfc_err(dev, 921 nfc_err(dev, "Unable to get IRQ GPIO\n");
935 "Unable to get IRQ GPIO\n");
936 return -ENODEV; 922 return -ENODEV;
937 } 923 }
938 924
939 phy->gpio_irq = desc_to_gpio(gpiod_irq); 925 phy->gpio_irq = desc_to_gpio(gpiod_irq);
940 926
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
948 /* Map the pin to an IRQ */ 927 /* Map the pin to an IRQ */
949 ret = gpiod_to_irq(gpiod_irq); 928 ret = gpiod_to_irq(gpiod_irq);
950 if (ret < 0) { 929 if (ret < 0) {