Linux Kernels

gpio: tc3589x: add .get_direction() and small cleanup

This change “gpio: tc3589x: add .get_direction() and small cleanup” (commit 14063d7) in Linux kernel is authored by Linus Walleij <linus.walleij [at] linaro.org> on Mon Sep 19 10:08:56 2016 +0200.

Description of "gpio: tc3589x: add .get_direction() and small cleanup"

The change “gpio: tc3589x: add .get_direction() and small cleanup” introduces changes as follows.

gpio: tc3589x: add .get_direction() and small cleanup

This adds a .get_direction() callback to the TC3589x and
renames the function for setting single-ended mode to be
more to the point.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Linux kernel releases containing commit 14063d7

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "gpio: tc3589x: add .get_direction() and small cleanup"

There are 29 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/gpio/gpio-tc3589x.c | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)
 
diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c
index 5baa45768ec5..537a4335ddec 100644
--- a/drivers/gpio/gpio-tc3589x.c
+++ b/drivers/gpio/gpio-tc3589x.c
@@ -84,9 +84,25 @@ static int tc3589x_gpio_direction_input(struct gpio_chip *chip,
 	return tc3589x_set_bits(tc3589x, reg, BIT(pos), 0);
 }
 
-static int tc3589x_gpio_single_ended(struct gpio_chip *chip,
-				     unsigned offset,
-				     enum single_ended_mode mode)
+static int tc3589x_gpio_get_direction(struct gpio_chip *chip,
+				      unsigned offset)
+{
+	struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip);
+	struct tc3589x *tc3589x = tc3589x_gpio->tc3589x;
+	u8 reg = TC3589x_GPIODIR0 + offset / 8;
+	unsigned pos = offset % 8;
+	int ret;
+
+	ret = tc3589x_reg_read(tc3589x, reg);
+	if (ret < 0)
+		return ret;
+
+	return !!(ret & BIT(pos));
+}
+
+static int tc3589x_gpio_set_single_ended(struct gpio_chip *chip,
+					 unsigned offset,
+					 enum single_ended_mode mode)
 {
 	struct tc3589x_gpio *tc3589x_gpio = gpiochip_get_data(chip);
 	struct tc3589x *tc3589x = tc3589x_gpio->tc3589x;
@@ -127,11 +143,12 @@ static int tc3589x_gpio_single_ended(struct gpio_chip *chip,
 static const struct gpio_chip template_chip = {
 	.label			= "tc3589x",
 	.owner			= THIS_MODULE,
-	.direction_input	= tc3589x_gpio_direction_input,
 	.get			= tc3589x_gpio_get,
-	.direction_output	= tc3589x_gpio_direction_output,
 	.set			= tc3589x_gpio_set,
-	.set_single_ended	= tc3589x_gpio_single_ended,
+	.direction_output	= tc3589x_gpio_direction_output,
+	.direction_input	= tc3589x_gpio_direction_input,
+	.get_direction		= tc3589x_gpio_get_direction,
+	.set_single_ended	= tc3589x_gpio_set_single_ended,
 	.can_sleep		= true,
 };
 

The commit for this change in Linux stable tree is 14063d7 (patch).

Last modified: 2020/01/11 09:34