* [PATCH v3 1/2] gpio: regmap: Support sparsed fixed direction
2026-05-11 19:43 [PATCH v3 0/2] Support sparse unidirectional GPIO lines Linus Walleij
@ 2026-05-11 19:43 ` Linus Walleij
2026-05-11 21:06 ` Alex Elder
2026-05-12 6:55 ` Michael Walle
2026-05-11 19:43 ` [PATCH v3 2/2] gpio: regmap: Don't set a fixed direction line Linus Walleij
2026-05-12 9:54 ` [PATCH v3 0/2] Support sparse unidirectional GPIO lines Bartosz Golaszewski
2 siblings, 2 replies; 10+ messages in thread
From: Linus Walleij @ 2026-05-11 19:43 UTC (permalink / raw)
To: Alex Elder, Michael Walle, Bartosz Golaszewski
Cc: linux-gpio, linux-kernel, Linus Walleij
On some regmapped GPIOs apparently only a sparser selection
of the lines (not all) are actually fixed direction.
Support this situation by adding an optional bitmap indicating
which GPIOs are actually fixed direction and which are not.
Cc: Alex Elder <elder@riscstar.com>
Link: https://lore.kernel.org/linux-gpio/20260501155421.3329862-10-elder@riscstar.com/
Tested-by: Alex Elder <elder@riscstar.com>
Signed-off-by: Linus Walleij <linusw@kernel.org>
---
drivers/gpio/gpio-regmap.c | 37 +++++++++++++++++++++++++++++++++----
include/linux/gpio/regmap.h | 7 +++++++
2 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
index 9ae4a41a2427..b3b4e77ec147 100644
--- a/drivers/gpio/gpio-regmap.c
+++ b/drivers/gpio/gpio-regmap.c
@@ -31,6 +31,7 @@ struct gpio_regmap {
unsigned int reg_clr_base;
unsigned int reg_dir_in_base;
unsigned int reg_dir_out_base;
+ unsigned long *fixed_direction_mask;
unsigned long *fixed_direction_output;
#ifdef CONFIG_REGMAP_IRQ
@@ -138,6 +139,20 @@ static int gpio_regmap_set_with_clear(struct gpio_chip *chip,
return regmap_write(gpio->regmap, reg, mask);
}
+static bool gpio_regmap_fixed_direction(struct gpio_regmap *gpio,
+ unsigned int offset)
+{
+ if (!gpio->fixed_direction_output)
+ return false;
+
+ /* In this case only some GPIOs are fixed as input/output */
+ if (gpio->fixed_direction_mask &&
+ !test_bit(offset, gpio->fixed_direction_mask))
+ return false;
+
+ return true;
+}
+
static int gpio_regmap_get_direction(struct gpio_chip *chip,
unsigned int offset)
{
@@ -145,7 +160,7 @@ static int gpio_regmap_get_direction(struct gpio_chip *chip,
unsigned int base, val, reg, mask;
int invert, ret;
- if (gpio->fixed_direction_output) {
+ if (gpio_regmap_fixed_direction(gpio, offset)) {
if (test_bit(offset, gpio->fixed_direction_output))
return GPIO_LINE_DIRECTION_OUT;
else
@@ -302,12 +317,23 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
goto err_free_gpio;
}
+ if (config->fixed_direction_mask) {
+ gpio->fixed_direction_mask = bitmap_alloc(chip->ngpio,
+ GFP_KERNEL);
+ if (!gpio->fixed_direction_mask) {
+ ret = -ENOMEM;
+ goto err_free_gpio;
+ }
+ bitmap_copy(gpio->fixed_direction_mask,
+ config->fixed_direction_mask, chip->ngpio);
+ }
+
if (config->fixed_direction_output) {
gpio->fixed_direction_output = bitmap_alloc(chip->ngpio,
GFP_KERNEL);
if (!gpio->fixed_direction_output) {
ret = -ENOMEM;
- goto err_free_gpio;
+ goto err_free_bitmap_dirmask;
}
bitmap_copy(gpio->fixed_direction_output,
config->fixed_direction_output, chip->ngpio);
@@ -329,7 +355,7 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
ret = gpiochip_add_data(chip, gpio);
if (ret < 0)
- goto err_free_bitmap;
+ goto err_free_bitmap_output;
#ifdef CONFIG_REGMAP_IRQ
if (config->regmap_irq_chip) {
@@ -355,8 +381,10 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
err_remove_gpiochip:
gpiochip_remove(chip);
-err_free_bitmap:
+err_free_bitmap_output:
bitmap_free(gpio->fixed_direction_output);
+err_free_bitmap_dirmask:
+ bitmap_free(gpio->fixed_direction_mask);
err_free_gpio:
kfree(gpio);
return ERR_PTR(ret);
@@ -376,6 +404,7 @@ void gpio_regmap_unregister(struct gpio_regmap *gpio)
gpiochip_remove(&gpio->gpio_chip);
bitmap_free(gpio->fixed_direction_output);
+ bitmap_free(gpio->fixed_direction_mask);
kfree(gpio);
}
EXPORT_SYMBOL_GPL(gpio_regmap_unregister);
diff --git a/include/linux/gpio/regmap.h b/include/linux/gpio/regmap.h
index 12d154732ca9..06255756710d 100644
--- a/include/linux/gpio/regmap.h
+++ b/include/linux/gpio/regmap.h
@@ -38,6 +38,12 @@ struct regmap;
* offset to a register/bitmask pair. If not
* given the default gpio_regmap_simple_xlate()
* is used.
+ * @fixed_direction_mask:
+ * (Optional) Bitmap representing the GPIO lines that
+ * make use of the @fixed_direction_output list to
+ * enforce direction of the GPIO. If this is NULL
+ * and @fixed_direction_output is defined, ALL GPIOs
+ * are assumed to be fixed direction (out or in).
* @fixed_direction_output:
* (Optional) Bitmap representing the fixed direction of
* the GPIO lines. Useful when there are GPIO lines with a
@@ -89,6 +95,7 @@ struct gpio_regmap_config {
int reg_stride;
int ngpio_per_reg;
struct irq_domain *irq_domain;
+ unsigned long *fixed_direction_mask;
unsigned long *fixed_direction_output;
#ifdef CONFIG_REGMAP_IRQ
--
2.54.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v3 1/2] gpio: regmap: Support sparsed fixed direction
2026-05-11 19:43 ` [PATCH v3 1/2] gpio: regmap: Support sparsed fixed direction Linus Walleij
@ 2026-05-11 21:06 ` Alex Elder
2026-05-12 6:55 ` Michael Walle
1 sibling, 0 replies; 10+ messages in thread
From: Alex Elder @ 2026-05-11 21:06 UTC (permalink / raw)
To: Linus Walleij, Michael Walle, Bartosz Golaszewski
Cc: linux-gpio, linux-kernel
On 5/11/26 2:43 PM, Linus Walleij wrote:
> On some regmapped GPIOs apparently only a sparser selection
> of the lines (not all) are actually fixed direction.
>
> Support this situation by adding an optional bitmap indicating
> which GPIOs are actually fixed direction and which are not.
>
> Cc: Alex Elder <elder@riscstar.com>
> Link: https://lore.kernel.org/linux-gpio/20260501155421.3329862-10-elder@riscstar.com/
> Tested-by: Alex Elder <elder@riscstar.com>
> Signed-off-by: Linus Walleij <linusw@kernel.org>
Reviewed-by: Alex Elder <elder@riscstar.com>
You renamed "test_direction_sparse" so I had to do that too, but
I tested this again as well.
> ---
> drivers/gpio/gpio-regmap.c | 37 +++++++++++++++++++++++++++++++++----
> include/linux/gpio/regmap.h | 7 +++++++
> 2 files changed, 40 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
> index 9ae4a41a2427..b3b4e77ec147 100644
> --- a/drivers/gpio/gpio-regmap.c
> +++ b/drivers/gpio/gpio-regmap.c
> @@ -31,6 +31,7 @@ struct gpio_regmap {
> unsigned int reg_clr_base;
> unsigned int reg_dir_in_base;
> unsigned int reg_dir_out_base;
> + unsigned long *fixed_direction_mask;
> unsigned long *fixed_direction_output;
>
> #ifdef CONFIG_REGMAP_IRQ
> @@ -138,6 +139,20 @@ static int gpio_regmap_set_with_clear(struct gpio_chip *chip,
> return regmap_write(gpio->regmap, reg, mask);
> }
>
> +static bool gpio_regmap_fixed_direction(struct gpio_regmap *gpio,
> + unsigned int offset)
> +{
> + if (!gpio->fixed_direction_output)
> + return false;
> +
> + /* In this case only some GPIOs are fixed as input/output */
> + if (gpio->fixed_direction_mask &&
> + !test_bit(offset, gpio->fixed_direction_mask))
> + return false;
> +
> + return true;
> +}
> +
> static int gpio_regmap_get_direction(struct gpio_chip *chip,
> unsigned int offset)
> {
> @@ -145,7 +160,7 @@ static int gpio_regmap_get_direction(struct gpio_chip *chip,
> unsigned int base, val, reg, mask;
> int invert, ret;
>
> - if (gpio->fixed_direction_output) {
> + if (gpio_regmap_fixed_direction(gpio, offset)) {
> if (test_bit(offset, gpio->fixed_direction_output))
> return GPIO_LINE_DIRECTION_OUT;
> else
> @@ -302,12 +317,23 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
> goto err_free_gpio;
> }
>
> + if (config->fixed_direction_mask) {
> + gpio->fixed_direction_mask = bitmap_alloc(chip->ngpio,
> + GFP_KERNEL);
> + if (!gpio->fixed_direction_mask) {
> + ret = -ENOMEM;
> + goto err_free_gpio;
> + }
> + bitmap_copy(gpio->fixed_direction_mask,
> + config->fixed_direction_mask, chip->ngpio);
> + }
> +
> if (config->fixed_direction_output) {
> gpio->fixed_direction_output = bitmap_alloc(chip->ngpio,
> GFP_KERNEL);
> if (!gpio->fixed_direction_output) {
> ret = -ENOMEM;
> - goto err_free_gpio;
> + goto err_free_bitmap_dirmask;
> }
> bitmap_copy(gpio->fixed_direction_output,
> config->fixed_direction_output, chip->ngpio);
> @@ -329,7 +355,7 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
>
> ret = gpiochip_add_data(chip, gpio);
> if (ret < 0)
> - goto err_free_bitmap;
> + goto err_free_bitmap_output;
>
> #ifdef CONFIG_REGMAP_IRQ
> if (config->regmap_irq_chip) {
> @@ -355,8 +381,10 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config
>
> err_remove_gpiochip:
> gpiochip_remove(chip);
> -err_free_bitmap:
> +err_free_bitmap_output:
> bitmap_free(gpio->fixed_direction_output);
> +err_free_bitmap_dirmask:
> + bitmap_free(gpio->fixed_direction_mask);
> err_free_gpio:
> kfree(gpio);
> return ERR_PTR(ret);
> @@ -376,6 +404,7 @@ void gpio_regmap_unregister(struct gpio_regmap *gpio)
>
> gpiochip_remove(&gpio->gpio_chip);
> bitmap_free(gpio->fixed_direction_output);
> + bitmap_free(gpio->fixed_direction_mask);
> kfree(gpio);
> }
> EXPORT_SYMBOL_GPL(gpio_regmap_unregister);
> diff --git a/include/linux/gpio/regmap.h b/include/linux/gpio/regmap.h
> index 12d154732ca9..06255756710d 100644
> --- a/include/linux/gpio/regmap.h
> +++ b/include/linux/gpio/regmap.h
> @@ -38,6 +38,12 @@ struct regmap;
> * offset to a register/bitmask pair. If not
> * given the default gpio_regmap_simple_xlate()
> * is used.
> + * @fixed_direction_mask:
> + * (Optional) Bitmap representing the GPIO lines that
> + * make use of the @fixed_direction_output list to
> + * enforce direction of the GPIO. If this is NULL
> + * and @fixed_direction_output is defined, ALL GPIOs
> + * are assumed to be fixed direction (out or in).
> * @fixed_direction_output:
> * (Optional) Bitmap representing the fixed direction of
> * the GPIO lines. Useful when there are GPIO lines with a
> @@ -89,6 +95,7 @@ struct gpio_regmap_config {
> int reg_stride;
> int ngpio_per_reg;
> struct irq_domain *irq_domain;
> + unsigned long *fixed_direction_mask;
> unsigned long *fixed_direction_output;
>
> #ifdef CONFIG_REGMAP_IRQ
>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v3 1/2] gpio: regmap: Support sparsed fixed direction
2026-05-11 19:43 ` [PATCH v3 1/2] gpio: regmap: Support sparsed fixed direction Linus Walleij
2026-05-11 21:06 ` Alex Elder
@ 2026-05-12 6:55 ` Michael Walle
1 sibling, 0 replies; 10+ messages in thread
From: Michael Walle @ 2026-05-12 6:55 UTC (permalink / raw)
To: Linus Walleij, Alex Elder, Bartosz Golaszewski; +Cc: linux-gpio, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 602 bytes --]
On Mon May 11, 2026 at 9:43 PM CEST, Linus Walleij wrote:
> On some regmapped GPIOs apparently only a sparser selection
> of the lines (not all) are actually fixed direction.
>
> Support this situation by adding an optional bitmap indicating
> which GPIOs are actually fixed direction and which are not.
>
> Cc: Alex Elder <elder@riscstar.com>
> Link: https://lore.kernel.org/linux-gpio/20260501155421.3329862-10-elder@riscstar.com/
> Tested-by: Alex Elder <elder@riscstar.com>
> Signed-off-by: Linus Walleij <linusw@kernel.org>
Reviewed-by: Michael Walle <mwalle@kernel.org>
-michael
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 297 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 2/2] gpio: regmap: Don't set a fixed direction line
2026-05-11 19:43 [PATCH v3 0/2] Support sparse unidirectional GPIO lines Linus Walleij
2026-05-11 19:43 ` [PATCH v3 1/2] gpio: regmap: Support sparsed fixed direction Linus Walleij
@ 2026-05-11 19:43 ` Linus Walleij
2026-05-11 21:06 ` Alex Elder
2026-05-12 7:00 ` Michael Walle
2026-05-12 9:54 ` [PATCH v3 0/2] Support sparse unidirectional GPIO lines Bartosz Golaszewski
2 siblings, 2 replies; 10+ messages in thread
From: Linus Walleij @ 2026-05-11 19:43 UTC (permalink / raw)
To: Alex Elder, Michael Walle, Bartosz Golaszewski
Cc: linux-gpio, linux-kernel, Linus Walleij, Sashiko
If a GPIO line has a fixed direction, report an error
is a consumer anyway tries to set the direction to
something other than what it is hardcoded to.
This didn't happen much before because what we supported was
all lines input or output and then the implementer would
probably not specify the direction registers, but with
sparse fixed direction we can have a mixture so let's take
this into account.
As a consequence, since gpio_regmap_set_direction() can
now fail, alter the semantics in
gpio_regmap_direction_output() such that we first check
if we can set the direction to output before we set the
value and the direction.
Suggested-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20260507-regmap-gpio-sparse-fixed-dir-v1-1-a2e5855e2701%40kernel.org
Signed-off-by: Linus Walleij <linusw@kernel.org>
---
drivers/gpio/gpio-regmap.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
index b3b4e77ec147..51b4d69b8740 100644
--- a/drivers/gpio/gpio-regmap.c
+++ b/drivers/gpio/gpio-regmap.c
@@ -196,6 +196,22 @@ static int gpio_regmap_get_direction(struct gpio_chip *chip,
return GPIO_LINE_DIRECTION_IN;
}
+static int gpio_regmap_try_direction_fixed(struct gpio_regmap *gpio,
+ unsigned int offset, bool output)
+{
+ if (test_bit(offset, gpio->fixed_direction_output)) {
+ if (output)
+ return 0;
+ else
+ return -EINVAL;
+ } else {
+ if (output)
+ return -EINVAL;
+ else
+ return 0;
+ }
+}
+
static int gpio_regmap_set_direction(struct gpio_chip *chip,
unsigned int offset, bool output)
{
@@ -203,6 +219,13 @@ static int gpio_regmap_set_direction(struct gpio_chip *chip,
unsigned int base, val, reg, mask;
int invert, ret;
+ /*
+ * If the direction is fixed, only accept the fixed
+ * direction in this call.
+ */
+ if (gpio_regmap_fixed_direction(gpio, offset))
+ return gpio_regmap_try_direction_fixed(gpio, offset, output);
+
if (gpio->reg_dir_out_base) {
base = gpio_regmap_addr(gpio->reg_dir_out_base);
invert = 0;
@@ -234,6 +257,20 @@ static int gpio_regmap_direction_input(struct gpio_chip *chip,
static int gpio_regmap_direction_output(struct gpio_chip *chip,
unsigned int offset, int value)
{
+ struct gpio_regmap *gpio = gpiochip_get_data(chip);
+ int ret;
+
+ /*
+ * First check if this is gonna work on a fixed direction line,
+ * if it doesn't (i.e. this is a fixed input line), then do not
+ * attempt to set the output value either and just bail out.
+ */
+ if (gpio_regmap_fixed_direction(gpio, offset)) {
+ ret = gpio_regmap_try_direction_fixed(gpio, offset, true);
+ if (ret)
+ return ret;
+ }
+
gpio_regmap_set(chip, offset, value);
return gpio_regmap_set_direction(chip, offset, true);
--
2.54.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v3 2/2] gpio: regmap: Don't set a fixed direction line
2026-05-11 19:43 ` [PATCH v3 2/2] gpio: regmap: Don't set a fixed direction line Linus Walleij
@ 2026-05-11 21:06 ` Alex Elder
2026-05-11 21:45 ` Linus Walleij
2026-05-12 7:00 ` Michael Walle
1 sibling, 1 reply; 10+ messages in thread
From: Alex Elder @ 2026-05-11 21:06 UTC (permalink / raw)
To: Linus Walleij, Michael Walle, Bartosz Golaszewski
Cc: linux-gpio, linux-kernel, Sashiko
On 5/11/26 2:43 PM, Linus Walleij wrote:
> If a GPIO line has a fixed direction, report an error
> is a consumer anyway tries to set the direction to
s/is/if/
> something other than what it is hardcoded to.
>
> This didn't happen much before because what we supported was
> all lines input or output and then the implementer would
> probably not specify the direction registers, but with
> sparse fixed direction we can have a mixture so let's take
> this into account.
>
> As a consequence, since gpio_regmap_set_direction() can
> now fail, alter the semantics in
> gpio_regmap_direction_output() such that we first check
> if we can set the direction to output before we set the
> value and the direction.
>
> Suggested-by: Sashiko <sashiko-bot@kernel.org>
> Link: https://sashiko.dev/#/patchset/20260507-regmap-gpio-sparse-fixed-dir-v1-1-a2e5855e2701%40kernel.org
> Signed-off-by: Linus Walleij <linusw@kernel.org>
Reviewed-by: Alex Elder <elder@riscstar.com>
Tested-by: Alex Elder <elder@riscstar.com>
> ---
> drivers/gpio/gpio-regmap.c | 37 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 37 insertions(+)
>
> diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
> index b3b4e77ec147..51b4d69b8740 100644
> --- a/drivers/gpio/gpio-regmap.c
> +++ b/drivers/gpio/gpio-regmap.c
> @@ -196,6 +196,22 @@ static int gpio_regmap_get_direction(struct gpio_chip *chip,
> return GPIO_LINE_DIRECTION_IN;
> }
>
> +static int gpio_regmap_try_direction_fixed(struct gpio_regmap *gpio,
> + unsigned int offset, bool output)
> +{
> + if (test_bit(offset, gpio->fixed_direction_output)) {
> + if (output)
> + return 0;
> + else
> + return -EINVAL;
> + } else {
> + if (output)
> + return -EINVAL;
> + else
> + return 0;
> + }
> +}
> +
> static int gpio_regmap_set_direction(struct gpio_chip *chip,
> unsigned int offset, bool output)
> {
> @@ -203,6 +219,13 @@ static int gpio_regmap_set_direction(struct gpio_chip *chip,
> unsigned int base, val, reg, mask;
> int invert, ret;
>
> + /*
> + * If the direction is fixed, only accept the fixed
> + * direction in this call.
> + */
> + if (gpio_regmap_fixed_direction(gpio, offset))
> + return gpio_regmap_try_direction_fixed(gpio, offset, output);
> +
> if (gpio->reg_dir_out_base) {
> base = gpio_regmap_addr(gpio->reg_dir_out_base);
> invert = 0;
> @@ -234,6 +257,20 @@ static int gpio_regmap_direction_input(struct gpio_chip *chip,
> static int gpio_regmap_direction_output(struct gpio_chip *chip,
> unsigned int offset, int value)
> {
> + struct gpio_regmap *gpio = gpiochip_get_data(chip);
> + int ret;
> +
> + /*
> + * First check if this is gonna work on a fixed direction line,
> + * if it doesn't (i.e. this is a fixed input line), then do not
> + * attempt to set the output value either and just bail out.
> + */
> + if (gpio_regmap_fixed_direction(gpio, offset)) {
> + ret = gpio_regmap_try_direction_fixed(gpio, offset, true);
> + if (ret)
> + return ret;
> + }
> +
> gpio_regmap_set(chip, offset, value);
>
> return gpio_regmap_set_direction(chip, offset, true);
>
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH v3 2/2] gpio: regmap: Don't set a fixed direction line
2026-05-11 21:06 ` Alex Elder
@ 2026-05-11 21:45 ` Linus Walleij
2026-05-12 9:55 ` Bartosz Golaszewski
0 siblings, 1 reply; 10+ messages in thread
From: Linus Walleij @ 2026-05-11 21:45 UTC (permalink / raw)
To: Alex Elder
Cc: Michael Walle, Bartosz Golaszewski, linux-gpio, linux-kernel,
Sashiko
On Mon, May 11, 2026 at 11:07 PM Alex Elder <elder@riscstar.com> wrote:
> On 5/11/26 2:43 PM, Linus Walleij wrote:
> > If a GPIO line has a fixed direction, report an error
> > is a consumer anyway tries to set the direction to
>
> s/is/if/
Ooops hopefully Bartosz can fix when applying if there
are no further issues.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 2/2] gpio: regmap: Don't set a fixed direction line
2026-05-11 21:45 ` Linus Walleij
@ 2026-05-12 9:55 ` Bartosz Golaszewski
0 siblings, 0 replies; 10+ messages in thread
From: Bartosz Golaszewski @ 2026-05-12 9:55 UTC (permalink / raw)
To: Linus Walleij
Cc: Alex Elder, Michael Walle, linux-gpio, linux-kernel, Sashiko
On Mon, May 11, 2026 at 11:45 PM Linus Walleij <linusw@kernel.org> wrote:
>
> On Mon, May 11, 2026 at 11:07 PM Alex Elder <elder@riscstar.com> wrote:
> > On 5/11/26 2:43 PM, Linus Walleij wrote:
>
> > > If a GPIO line has a fixed direction, report an error
> > > is a consumer anyway tries to set the direction to
> >
> > s/is/if/
>
> Ooops hopefully Bartosz can fix when applying if there
> are no further issues.
>
I did and I also allowed myself to break the lines a little bit less
eagerly, the soft limit is 75 characters. :)
Bart
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 2/2] gpio: regmap: Don't set a fixed direction line
2026-05-11 19:43 ` [PATCH v3 2/2] gpio: regmap: Don't set a fixed direction line Linus Walleij
2026-05-11 21:06 ` Alex Elder
@ 2026-05-12 7:00 ` Michael Walle
1 sibling, 0 replies; 10+ messages in thread
From: Michael Walle @ 2026-05-12 7:00 UTC (permalink / raw)
To: Linus Walleij, Alex Elder, Bartosz Golaszewski
Cc: linux-gpio, linux-kernel, Sashiko
[-- Attachment #1: Type: text/plain, Size: 1008 bytes --]
On Mon May 11, 2026 at 9:43 PM CEST, Linus Walleij wrote:
> If a GPIO line has a fixed direction, report an error
> is a consumer anyway tries to set the direction to
> something other than what it is hardcoded to.
>
> This didn't happen much before because what we supported was
> all lines input or output and then the implementer would
> probably not specify the direction registers, but with
> sparse fixed direction we can have a mixture so let's take
> this into account.
>
> As a consequence, since gpio_regmap_set_direction() can
> now fail, alter the semantics in
> gpio_regmap_direction_output() such that we first check
> if we can set the direction to output before we set the
> value and the direction.
>
> Suggested-by: Sashiko <sashiko-bot@kernel.org>
> Link: https://sashiko.dev/#/patchset/20260507-regmap-gpio-sparse-fixed-dir-v1-1-a2e5855e2701%40kernel.org
> Signed-off-by: Linus Walleij <linusw@kernel.org>
Reviewed-by: Michael Walle <mwalle@kernel.org>
-michael
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 297 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 0/2] Support sparse unidirectional GPIO lines.
2026-05-11 19:43 [PATCH v3 0/2] Support sparse unidirectional GPIO lines Linus Walleij
2026-05-11 19:43 ` [PATCH v3 1/2] gpio: regmap: Support sparsed fixed direction Linus Walleij
2026-05-11 19:43 ` [PATCH v3 2/2] gpio: regmap: Don't set a fixed direction line Linus Walleij
@ 2026-05-12 9:54 ` Bartosz Golaszewski
2 siblings, 0 replies; 10+ messages in thread
From: Bartosz Golaszewski @ 2026-05-12 9:54 UTC (permalink / raw)
To: Alex Elder, Michael Walle, Bartosz Golaszewski, Linus Walleij
Cc: Bartosz Golaszewski, linux-gpio, linux-kernel, Sashiko
On Mon, 11 May 2026 21:43:42 +0200, Linus Walleij wrote:
> This adds a fixed_direction_mask bitmap to the regmap GPIO
> config and state holder. This works the following way:
>
> - If the bitmap is NULL all GPIOs are assumed to be fixed
> direction and that is specified in fixed_direction_output.
> This makes sure old drivers keep working as before.
>
> [...]
Applied, thanks!
[1/2] gpio: regmap: Support sparsed fixed direction
https://git.kernel.org/brgl/c/68d801eabda5219dcc25c9de98d3bbdb5b51b0a5
[2/2] gpio: regmap: Don't set a fixed direction line
https://git.kernel.org/brgl/c/806e7acf7f331008637b4f8ecf211eb0a082e6eb
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 10+ messages in thread