aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2015-06-16 20:02:13 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2015-06-16 20:09:14 -0400
commitea0afac450d2a3aaeb4c51ddf1631e677afe3193 (patch)
tree5b769eba94df0a9775c542bcb633ca221633aa0d
parenteeb64c14275e52740d6410632e62e0ad9b88ca70 (diff)
Input: improve usage of gpiod API
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. Simplify drivers accordingly. Note that in the case of the drv260x driver error checking is more strict now because -ENOSYS is reported to the caller now. But this should only be returned if GPIOLIB is disabled which shouldn't happen as the driver depends on GPIOLIB. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/keyboard/clps711x-keypad.c7
-rw-r--r--drivers/input/misc/drv260x.c13
-rw-r--r--drivers/input/misc/gpio-beeper.c7
3 files changed, 6 insertions, 21 deletions
diff --git a/drivers/input/keyboard/clps711x-keypad.c b/drivers/input/keyboard/clps711x-keypad.c
index 27ef29f8fe6a..b637f1af842e 100644
--- a/drivers/input/keyboard/clps711x-keypad.c
+++ b/drivers/input/keyboard/clps711x-keypad.c
@@ -120,14 +120,9 @@ static int clps711x_keypad_probe(struct platform_device *pdev)
120 for (i = 0; i < priv->row_count; i++) { 120 for (i = 0; i < priv->row_count; i++) {
121 struct clps711x_gpio_data *data = &priv->gpio_data[i]; 121 struct clps711x_gpio_data *data = &priv->gpio_data[i];
122 122
123 data->desc = devm_gpiod_get_index(dev, "row", i); 123 data->desc = devm_gpiod_get_index(dev, "row", i, GPIOD_IN);
124 if (!data->desc)
125 return -EINVAL;
126
127 if (IS_ERR(data->desc)) 124 if (IS_ERR(data->desc))
128 return PTR_ERR(data->desc); 125 return PTR_ERR(data->desc);
129
130 gpiod_direction_input(data->desc);
131 } 126 }
132 127
133 err = of_property_read_u32(np, "poll-interval", &poll_interval); 128 err = of_property_read_u32(np, "poll-interval", &poll_interval);
diff --git a/drivers/input/misc/drv260x.c b/drivers/input/misc/drv260x.c
index 599578042ea0..e5d60ecd29a4 100644
--- a/drivers/input/misc/drv260x.c
+++ b/drivers/input/misc/drv260x.c
@@ -580,15 +580,10 @@ static int drv260x_probe(struct i2c_client *client,
580 return error; 580 return error;
581 } 581 }
582 582
583 haptics->enable_gpio = devm_gpiod_get(&client->dev, "enable"); 583 haptics->enable_gpio = devm_gpiod_get_optional(&client->dev, "enable",
584 if (IS_ERR(haptics->enable_gpio)) { 584 GPIOD_OUT_HIGH);
585 error = PTR_ERR(haptics->enable_gpio); 585 if (IS_ERR(haptics->enable_gpio))
586 if (error != -ENOENT && error != -ENOSYS) 586 return PTR_ERR(haptics->enable_gpio);
587 return error;
588 haptics->enable_gpio = NULL;
589 } else {
590 gpiod_direction_output(haptics->enable_gpio, 1);
591 }
592 587
593 haptics->input_dev = devm_input_allocate_device(&client->dev); 588 haptics->input_dev = devm_input_allocate_device(&client->dev);
594 if (!haptics->input_dev) { 589 if (!haptics->input_dev) {
diff --git a/drivers/input/misc/gpio-beeper.c b/drivers/input/misc/gpio-beeper.c
index 4817c5f0c3e4..16272fffeb7e 100644
--- a/drivers/input/misc/gpio-beeper.c
+++ b/drivers/input/misc/gpio-beeper.c
@@ -66,13 +66,12 @@ static int gpio_beeper_probe(struct platform_device *pdev)
66{ 66{
67 struct gpio_beeper *beep; 67 struct gpio_beeper *beep;
68 struct input_dev *input; 68 struct input_dev *input;
69 int err;
70 69
71 beep = devm_kzalloc(&pdev->dev, sizeof(*beep), GFP_KERNEL); 70 beep = devm_kzalloc(&pdev->dev, sizeof(*beep), GFP_KERNEL);
72 if (!beep) 71 if (!beep)
73 return -ENOMEM; 72 return -ENOMEM;
74 73
75 beep->desc = devm_gpiod_get(&pdev->dev, NULL); 74 beep->desc = devm_gpiod_get(&pdev->dev, NULL, GPIOD_OUT_LOW);
76 if (IS_ERR(beep->desc)) 75 if (IS_ERR(beep->desc))
77 return PTR_ERR(beep->desc); 76 return PTR_ERR(beep->desc);
78 77
@@ -92,10 +91,6 @@ static int gpio_beeper_probe(struct platform_device *pdev)
92 91
93 input_set_capability(input, EV_SND, SND_BELL); 92 input_set_capability(input, EV_SND, SND_BELL);
94 93
95 err = gpiod_direction_output(beep->desc, 0);
96 if (err)
97 return err;
98
99 input_set_drvdata(input, beep); 94 input_set_drvdata(input, beep);
100 95
101 return input_register_device(input); 96 return input_register_device(input);