From: William Breathitt Gray <william.gray@linaro.org>
To: linus.walleij@linaro.org, brgl@bgdev.pl
Cc: andriy.shevchenko@linux.intel.com, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org, michael@walle.cc,
William Breathitt Gray <william.gray@linaro.org>
Subject: [PATCH v5 1/8] gpio: regmap: Always set gpio_chip get_direction
Date: Tue, 27 Dec 2022 09:09:39 -0500 [thread overview]
Message-ID: <a3181025b434fc0148d74bf37f2a16569c85ed1c.1672149007.git.william.gray@linaro.org> (raw)
In-Reply-To: <cover.1672149007.git.william.gray@linaro.org>
If you only have reg_dat_base set, then it is input-only; if you only
have reg_set_base set, then it is output-only. Thus, we can always set
gpio_chip get_direction to gpio_regmap_get_direction and return
GPIO_LINE_DIRECTION_IN/GPIO_LINE_DIRECTION_OUT given the respective
register base addresses configuration.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Michael Walle <michael@walle.cc>
Signed-off-by: William Breathitt Gray <william.gray@linaro.org>
---
drivers/gpio/gpio-regmap.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
index 6383136cbe59..f907c9c19fce 100644
--- a/drivers/gpio/gpio-regmap.c
+++ b/drivers/gpio/gpio-regmap.c
@@ -111,6 +111,11 @@ static int gpio_regmap_get_direction(struct gpio_chip *chip,
unsigned int base, val, reg, mask;
int invert, ret;
+ if (gpio->reg_dat_base && !gpio->reg_set_base)
+ return GPIO_LINE_DIRECTION_IN;
+ if (gpio->reg_set_base && !gpio->reg_dat_base)
+ return GPIO_LINE_DIRECTION_OUT;
+
if (gpio->reg_dir_out_base) {
base = gpio_regmap_addr(gpio->reg_dir_out_base);
invert = 0;
@@ -265,8 +270,8 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
else if (gpio->reg_set_base)
chip->set = gpio_regmap_set;
+ chip->get_direction = gpio_regmap_get_direction;
if (gpio->reg_dir_in_base || gpio->reg_dir_out_base) {
- chip->get_direction = gpio_regmap_get_direction;
chip->direction_input = gpio_regmap_direction_input;
chip->direction_output = gpio_regmap_direction_output;
}
--
2.38.1
next prev parent reply other threads:[~2022-12-27 14:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-27 14:09 [PATCH v5 0/8] Migrate i8255 GPIO drivers to regmap API William Breathitt Gray
2022-12-27 14:09 ` William Breathitt Gray [this message]
2022-12-27 14:09 ` [PATCH v5 2/8] gpio: 104-dio-48e: Migrate to the regmap-irq API William Breathitt Gray
2022-12-27 14:09 ` [PATCH v5 3/8] gpio: 104-idi-48: " William Breathitt Gray
2022-12-27 14:09 ` [PATCH v5 4/8] gpio: 104-idi-48: Migrate to gpio-regmap API William Breathitt Gray
2022-12-27 14:09 ` [PATCH v5 5/8] gpio: i8255: " William Breathitt Gray
2022-12-27 14:09 ` [PATCH v5 6/8] gpio: 104-dio-48e: Migrate to regmap API William Breathitt Gray
2022-12-27 14:09 ` [PATCH v5 7/8] gpio: gpio-mm: " William Breathitt Gray
2022-12-27 14:09 ` [PATCH v5 8/8] gpio: i8255: Remove unused legacy interface William Breathitt Gray
2022-12-30 13:07 ` [PATCH v5 0/8] Migrate i8255 GPIO drivers to regmap API Bartosz Golaszewski
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=a3181025b434fc0148d74bf37f2a16569c85ed1c.1672149007.git.william.gray@linaro.org \
--to=william.gray@linaro.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=brgl@bgdev.pl \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael@walle.cc \
/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).