From: Laxman Dewangan <ldewangan@nvidia.com>
To: linus.walleij@linaro.org, gnurou@gmail.com
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Laxman Dewangan <ldewangan@nvidia.com>
Subject: [PATCH 2/3] gpio: max77620: Implement gpio_get_direction callback
Date: Tue, 24 May 2016 18:43:45 +0530 [thread overview]
Message-ID: <1464095626-28424-2-git-send-email-ldewangan@nvidia.com> (raw)
In-Reply-To: <1464095626-28424-1-git-send-email-ldewangan@nvidia.com>
Implement gpio_get_direction() callback for MAX77620 GPIO.
This is useful for debugfs and the userspace ABI.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
drivers/gpio/gpio-max77620.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/gpio/gpio-max77620.c b/drivers/gpio/gpio-max77620.c
index 35f365c..0bb6d93 100644
--- a/drivers/gpio/gpio-max77620.c
+++ b/drivers/gpio/gpio-max77620.c
@@ -9,6 +9,7 @@
*/
#include <linux/gpio/driver.h>
+#include <linux/gpio.h>
#include <linux/interrupt.h>
#include <linux/mfd/max77620.h>
#include <linux/module.h>
@@ -152,6 +153,23 @@ static int max77620_gpio_dir_output(struct gpio_chip *gc, unsigned int offset,
return ret;
}
+static int max77620_gpio_get_direction(struct gpio_chip *gc,
+ unsigned int offset)
+{
+ struct max77620_gpio *mgpio = gpiochip_get_data(gc);
+ unsigned int val;
+ int ret;
+
+ ret = regmap_read(mgpio->rmap, GPIO_REG_ADDR(offset), &val);
+ if (ret < 0) {
+ dev_err(mgpio->dev, "GPIO register read failed: %d\n", ret);
+ return ret;
+ }
+
+ return (val & MAX77620_CNFG_GPIO_DIR_MASK) ?
+ GPIOF_DIR_IN : GPIOF_DIR_OUT;
+}
+
static int max77620_gpio_set_debounce(struct gpio_chip *gc,
unsigned int offset,
unsigned int debounce)
@@ -236,6 +254,7 @@ static int max77620_gpio_probe(struct platform_device *pdev)
mgpio->gpio_chip.direction_input = max77620_gpio_dir_input;
mgpio->gpio_chip.get = max77620_gpio_get;
mgpio->gpio_chip.direction_output = max77620_gpio_dir_output;
+ mgpio->gpio_chip.get_direction = max77620_gpio_get_direction;
mgpio->gpio_chip.set_debounce = max77620_gpio_set_debounce;
mgpio->gpio_chip.set = max77620_gpio_set;
mgpio->gpio_chip.to_irq = max77620_gpio_to_irq;
--
2.1.4
next prev parent reply other threads:[~2016-05-24 13:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-24 13:13 [PATCH 1/3] gpio: max77620: Configure interrupt trigger level Laxman Dewangan
2016-05-24 13:13 ` Laxman Dewangan [this message]
2016-05-30 15:03 ` [PATCH 2/3] gpio: max77620: Implement gpio_get_direction callback Linus Walleij
2016-05-31 5:53 ` Laxman Dewangan
2016-05-24 13:13 ` [PATCH 3/3] gpio: max77620: use the new open drain callback Laxman Dewangan
2016-05-30 15:05 ` Linus Walleij
2016-05-30 15:01 ` [PATCH 1/3] gpio: max77620: Configure interrupt trigger level Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1464095626-28424-2-git-send-email-ldewangan@nvidia.com \
--to=ldewangan@nvidia.com \
--cc=gnurou@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).