From ea0afac450d2a3aaeb4c51ddf1631e677afe3193 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Tue, 16 Jun 2015 17:02:13 -0700 Subject: Input: improve usage of gpiod API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Linus Walleij Signed-off-by: Dmitry Torokhov --- drivers/input/misc/drv260x.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'drivers/input/misc/drv260x.c') 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, return error; } - haptics->enable_gpio = devm_gpiod_get(&client->dev, "enable"); - if (IS_ERR(haptics->enable_gpio)) { - error = PTR_ERR(haptics->enable_gpio); - if (error != -ENOENT && error != -ENOSYS) - return error; - haptics->enable_gpio = NULL; - } else { - gpiod_direction_output(haptics->enable_gpio, 1); - } + haptics->enable_gpio = devm_gpiod_get_optional(&client->dev, "enable", + GPIOD_OUT_HIGH); + if (IS_ERR(haptics->enable_gpio)) + return PTR_ERR(haptics->enable_gpio); haptics->input_dev = devm_input_allocate_device(&client->dev); if (!haptics->input_dev) { -- cgit v1.2.3