* [PATCH v2 0/2] Improvement spotted during patch review.
@ 2026-05-08 12:51 Linus Walleij
2026-05-08 12:51 ` [PATCH v2 1/2] gpio: regmap: Support sparsed fixed direction Linus Walleij
` (3 more replies)
0 siblings, 4 replies; 14+ messages in thread
From: Linus Walleij @ 2026-05-08 12:51 UTC (permalink / raw)
To: Michael Walle, Bartosz Golaszewski
Cc: linux-gpio, linux-kernel, Linus Walleij, Alex Elder, Sashiko
Support sparse unidirectional GPIO lines.
To be used in a forthcoming submission.
Signed-off-by: Linus Walleij <linusw@kernel.org>
---
Changes in v2:
- Make a second patch to exclude setting on unidirectional
lines.
- Link to v1: https://patch.msgid.link/20260507-regmap-gpio-sparse-fixed-dir-v1-1-a2e5855e2701@kernel.org
---
Linus Walleij (2):
gpio: regmap: Support sparsed fixed direction
gpio: regmap: Don't set a fixed direction line
drivers/gpio/gpio-regmap.c | 40 ++++++++++++++++++++++++++++++++++++----
include/linux/gpio/regmap.h | 7 +++++++
2 files changed, 43 insertions(+), 4 deletions(-)
---
base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
change-id: 20260507-regmap-gpio-sparse-fixed-dir-1d5c0d2e2c6f
Best regards,
--
Linus Walleij <linusw@kernel.org>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2 1/2] gpio: regmap: Support sparsed fixed direction
2026-05-08 12:51 [PATCH v2 0/2] Improvement spotted during patch review Linus Walleij
@ 2026-05-08 12:51 ` Linus Walleij
2026-05-08 13:03 ` Alex Elder
2026-05-11 7:18 ` Michael Walle
2026-05-08 12:51 ` [PATCH v2 2/2] gpio: regmap: Don't set a fixed direction line Linus Walleij
` (2 subsequent siblings)
3 siblings, 2 replies; 14+ messages in thread
From: Linus Walleij @ 2026-05-08 12:51 UTC (permalink / raw)
To: Michael Walle, Bartosz Golaszewski
Cc: linux-gpio, linux-kernel, Linus Walleij, Alex Elder
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..f45a432e8ebe 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_sparse;
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_sparse &&
+ !test_bit(offset, gpio->fixed_direction_sparse))
+ 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_sparse) {
+ gpio->fixed_direction_sparse = bitmap_alloc(chip->ngpio,
+ GFP_KERNEL);
+ if (!gpio->fixed_direction_sparse) {
+ ret = -ENOMEM;
+ goto err_free_gpio;
+ }
+ bitmap_copy(gpio->fixed_direction_sparse,
+ config->fixed_direction_sparse, 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_sparse;
}
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_sparse:
+ bitmap_free(gpio->fixed_direction_sparse);
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_sparse);
kfree(gpio);
}
EXPORT_SYMBOL_GPL(gpio_regmap_unregister);
diff --git a/include/linux/gpio/regmap.h b/include/linux/gpio/regmap.h
index 12d154732ca9..ff00b4aeaf1c 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_sparse:
+ * (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_sparse;
unsigned long *fixed_direction_output;
#ifdef CONFIG_REGMAP_IRQ
--
2.54.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v2 2/2] gpio: regmap: Don't set a fixed direction line
2026-05-08 12:51 [PATCH v2 0/2] Improvement spotted during patch review Linus Walleij
2026-05-08 12:51 ` [PATCH v2 1/2] gpio: regmap: Support sparsed fixed direction Linus Walleij
@ 2026-05-08 12:51 ` Linus Walleij
2026-05-11 7:24 ` Michael Walle
2026-05-11 9:56 ` [PATCH v2 0/2] Improvement spotted during patch review Bartosz Golaszewski
2026-05-11 12:32 ` Bartosz Golaszewski
3 siblings, 1 reply; 14+ messages in thread
From: Linus Walleij @ 2026-05-08 12:51 UTC (permalink / raw)
To: Michael Walle, Bartosz Golaszewski
Cc: linux-gpio, linux-kernel, Linus Walleij, Sashiko
If a GPIO line has a fixed direction, there is no point in
trying to set the direction.
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.
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 | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
index f45a432e8ebe..52a67dea8107 100644
--- a/drivers/gpio/gpio-regmap.c
+++ b/drivers/gpio/gpio-regmap.c
@@ -203,6 +203,9 @@ static int gpio_regmap_set_direction(struct gpio_chip *chip,
unsigned int base, val, reg, mask;
int invert, ret;
+ if (gpio_regmap_fixed_direction(gpio, offset))
+ return 0;
+
if (gpio->reg_dir_out_base) {
base = gpio_regmap_addr(gpio->reg_dir_out_base);
invert = 0;
--
2.54.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] gpio: regmap: Support sparsed fixed direction
2026-05-08 12:51 ` [PATCH v2 1/2] gpio: regmap: Support sparsed fixed direction Linus Walleij
@ 2026-05-08 13:03 ` Alex Elder
2026-05-10 13:31 ` Alex Elder
2026-05-11 7:18 ` Michael Walle
1 sibling, 1 reply; 14+ messages in thread
From: Alex Elder @ 2026-05-08 13:03 UTC (permalink / raw)
To: Linus Walleij, Michael Walle, Bartosz Golaszewski
Cc: linux-gpio, linux-kernel
On 5/8/26 7:51 AM, 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>
In addition, it would be fine with me if you merged this together
iwth your new patch:
https://lore.kernel.org/lkml/20260508-regmap-gpio-sparse-fixed-dir-v2-2-deee84df3027@kernel.org/
It makes sense and it is logically part of the same change.
I even tested with that change applied, even though I know
just by inspection it will do what's desired.
Anyway, for both (or a combined single patch), these apply:
Tested-by: Alex Elder <elder@riscstar.com>
Reviewed-by: Alex Elder <elder@riscstar.com>
-Alex
> ---
> 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..f45a432e8ebe 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_sparse;
> 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_sparse &&
> + !test_bit(offset, gpio->fixed_direction_sparse))
> + 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_sparse) {
> + gpio->fixed_direction_sparse = bitmap_alloc(chip->ngpio,
> + GFP_KERNEL);
> + if (!gpio->fixed_direction_sparse) {
> + ret = -ENOMEM;
> + goto err_free_gpio;
> + }
> + bitmap_copy(gpio->fixed_direction_sparse,
> + config->fixed_direction_sparse, 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_sparse;
> }
> 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_sparse:
> + bitmap_free(gpio->fixed_direction_sparse);
> 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_sparse);
> kfree(gpio);
> }
> EXPORT_SYMBOL_GPL(gpio_regmap_unregister);
> diff --git a/include/linux/gpio/regmap.h b/include/linux/gpio/regmap.h
> index 12d154732ca9..ff00b4aeaf1c 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_sparse:
> + * (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_sparse;
> unsigned long *fixed_direction_output;
>
> #ifdef CONFIG_REGMAP_IRQ
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] gpio: regmap: Support sparsed fixed direction
2026-05-08 13:03 ` Alex Elder
@ 2026-05-10 13:31 ` Alex Elder
0 siblings, 0 replies; 14+ messages in thread
From: Alex Elder @ 2026-05-10 13:31 UTC (permalink / raw)
To: Linus Walleij, Michael Walle, Bartosz Golaszewski
Cc: linux-gpio, linux-kernel
On 5/8/26 8:03 AM, Alex Elder wrote:
> On 5/8/26 7:51 AM, 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>
>
>
>
> In addition, it would be fine with me if you merged this together
> iwth your new patch:
>
>
> https://lore.kernel.org/lkml/20260508-regmap-gpio-sparse-fixed-dir-v2-2-
> deee84df3027@kernel.org/
>
> It makes sense and it is logically part of the same change.
>
> I even tested with that change applied, even though I know
> just by inspection it will do what's desired.
>
> Anyway, for both (or a combined single patch), these apply:
>
> Tested-by: Alex Elder <elder@riscstar.com>
> Reviewed-by: Alex Elder <elder@riscstar.com>
>
>
> -Alex
I had another look at this and I had two more comments. I
don't care whether you address them or not, but I thought
I'd mention them.
The first is, in gpio_regmap_set_direction(), if a request to
set the direction to something that isn't supported (e.g. set
the direction to input on an output-only GPIO), shouldn't it
return an error to indicate nothing happened? (-EINVAL or
-ENOTSUP maybe?)
Doing that might not be as simple as it seems, and maybe you
just opted to keep it simple. gpio_regmap_direction_output()
calls gpio_regmap_set() before setting the direction, so
checking whether it's valid happens later than desired.
The second is a missing blank line that I didn't expect,
in gpio_regmap_get_direction(). I mention it in context
below.
-Alex
>> ---
>> 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..f45a432e8ebe 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_sparse;
>> 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_sparse &&
>> + !test_bit(offset, gpio->fixed_direction_sparse))
>> + 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;
This isn't new, but why is there no blank line here?
>> - 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_sparse) {
>> + gpio->fixed_direction_sparse = bitmap_alloc(chip->ngpio,
>> + GFP_KERNEL);
>> + if (!gpio->fixed_direction_sparse) {
>> + ret = -ENOMEM;
>> + goto err_free_gpio;
>> + }
>> + bitmap_copy(gpio->fixed_direction_sparse,
>> + config->fixed_direction_sparse, 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_sparse;
>> }
>> 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_sparse:
>> + bitmap_free(gpio->fixed_direction_sparse);
>> 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_sparse);
>> kfree(gpio);
>> }
>> EXPORT_SYMBOL_GPL(gpio_regmap_unregister);
>> diff --git a/include/linux/gpio/regmap.h b/include/linux/gpio/regmap.h
>> index 12d154732ca9..ff00b4aeaf1c 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_sparse:
>> + * (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_sparse;
>> unsigned long *fixed_direction_output;
>> #ifdef CONFIG_REGMAP_IRQ
>>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] gpio: regmap: Support sparsed fixed direction
2026-05-08 12:51 ` [PATCH v2 1/2] gpio: regmap: Support sparsed fixed direction Linus Walleij
2026-05-08 13:03 ` Alex Elder
@ 2026-05-11 7:18 ` Michael Walle
2026-05-11 19:00 ` Linus Walleij
1 sibling, 1 reply; 14+ messages in thread
From: Michael Walle @ 2026-05-11 7:18 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski; +Cc: linux-gpio, linux-kernel, Alex Elder
[-- Attachment #1: Type: text/plain, Size: 669 bytes --]
Hi,
On Fri May 8, 2026 at 2:51 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.
Thanks, this patch looks good. But could we invert the logic and use
fixed_direction_mask as that feels more natural to me?
And for legacy reasons, so we don't have to change the drivers:
if (!fixed_direction_mask && fixed_direction_output)
fixed_direction_mask = ~1
Or we just go ahead and change the two drivers. Up to you.
-michael
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 297 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 2/2] gpio: regmap: Don't set a fixed direction line
2026-05-08 12:51 ` [PATCH v2 2/2] gpio: regmap: Don't set a fixed direction line Linus Walleij
@ 2026-05-11 7:24 ` Michael Walle
0 siblings, 0 replies; 14+ messages in thread
From: Michael Walle @ 2026-05-11 7:24 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski; +Cc: linux-gpio, linux-kernel, Sashiko
[-- Attachment #1: Type: text/plain, Size: 1349 bytes --]
Hi,
On Fri May 8, 2026 at 2:51 PM CEST, Linus Walleij wrote:
> If a GPIO line has a fixed direction, there is no point in
> trying to set the direction.
>
> 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.
>
> 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 | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
> index f45a432e8ebe..52a67dea8107 100644
> --- a/drivers/gpio/gpio-regmap.c
> +++ b/drivers/gpio/gpio-regmap.c
> @@ -203,6 +203,9 @@ static int gpio_regmap_set_direction(struct gpio_chip *chip,
> unsigned int base, val, reg, mask;
> int invert, ret;
>
> + if (gpio_regmap_fixed_direction(gpio, offset))
> + return 0;
> +
Shall we check if the user wants to set an incorrect direction and
return -EINVAL?
-michael
> if (gpio->reg_dir_out_base) {
> base = gpio_regmap_addr(gpio->reg_dir_out_base);
> invert = 0;
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 297 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/2] Improvement spotted during patch review.
2026-05-08 12:51 [PATCH v2 0/2] Improvement spotted during patch review Linus Walleij
2026-05-08 12:51 ` [PATCH v2 1/2] gpio: regmap: Support sparsed fixed direction Linus Walleij
2026-05-08 12:51 ` [PATCH v2 2/2] gpio: regmap: Don't set a fixed direction line Linus Walleij
@ 2026-05-11 9:56 ` Bartosz Golaszewski
2026-05-11 12:15 ` Linus Walleij
2026-05-11 12:32 ` Bartosz Golaszewski
3 siblings, 1 reply; 14+ messages in thread
From: Bartosz Golaszewski @ 2026-05-11 9:56 UTC (permalink / raw)
To: Linus Walleij
Cc: Michael Walle, linux-gpio, linux-kernel, Alex Elder, Sashiko
On Fri, May 8, 2026 at 2:51 PM Linus Walleij <linusw@kernel.org> wrote:
>
> Support sparse unidirectional GPIO lines.
>
> To be used in a forthcoming submission.
>
Should I apply it or will Alex just include it in his series?
Bart
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/2] Improvement spotted during patch review.
2026-05-11 9:56 ` [PATCH v2 0/2] Improvement spotted during patch review Bartosz Golaszewski
@ 2026-05-11 12:15 ` Linus Walleij
2026-05-11 12:18 ` Alex Elder
0 siblings, 1 reply; 14+ messages in thread
From: Linus Walleij @ 2026-05-11 12:15 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Michael Walle, linux-gpio, linux-kernel, Alex Elder, Sashiko
On Mon, May 11, 2026 at 11:56 AM Bartosz Golaszewski <brgl@kernel.org> wrote:
> On Fri, May 8, 2026 at 2:51 PM Linus Walleij <linusw@kernel.org> wrote:
> >
> > Support sparse unidirectional GPIO lines.
> >
> > To be used in a forthcoming submission.
>
> Should I apply it or will Alex just include it in his series?
I think it's easiest if you just apply it then Alex can just base his
patch series off your for-next branch (or cherry-pick those
underneath his patch series).
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/2] Improvement spotted during patch review.
2026-05-11 12:15 ` Linus Walleij
@ 2026-05-11 12:18 ` Alex Elder
0 siblings, 0 replies; 14+ messages in thread
From: Alex Elder @ 2026-05-11 12:18 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski
Cc: Michael Walle, linux-gpio, linux-kernel, Sashiko
On 5/11/26 7:15 AM, Linus Walleij wrote:
> On Mon, May 11, 2026 at 11:56 AM Bartosz Golaszewski <brgl@kernel.org> wrote:
>> On Fri, May 8, 2026 at 2:51 PM Linus Walleij <linusw@kernel.org> wrote:
>>>
>>> Support sparse unidirectional GPIO lines.
>>>
>>> To be used in a forthcoming submission.
>>
>> Should I apply it or will Alex just include it in his series?
>
> I think it's easiest if you just apply it then Alex can just base his
> patch series off your for-next branch (or cherry-pick those
> underneath his patch series).
>
> Yours,
> Linus Walleij
I'm good with that plan. -Alex
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/2] Improvement spotted during patch review.
2026-05-08 12:51 [PATCH v2 0/2] Improvement spotted during patch review Linus Walleij
` (2 preceding siblings ...)
2026-05-11 9:56 ` [PATCH v2 0/2] Improvement spotted during patch review Bartosz Golaszewski
@ 2026-05-11 12:32 ` Bartosz Golaszewski
2026-05-11 12:39 ` Michael Walle
3 siblings, 1 reply; 14+ messages in thread
From: Bartosz Golaszewski @ 2026-05-11 12:32 UTC (permalink / raw)
To: Michael Walle, Bartosz Golaszewski, Linus Walleij
Cc: Bartosz Golaszewski, linux-gpio, linux-kernel, Alex Elder,
Sashiko
On Fri, 08 May 2026 14:51:25 +0200, Linus Walleij wrote:
> Support sparse unidirectional GPIO lines.
>
> To be used in a forthcoming submission.
>
>
Applied, thanks!
[1/2] gpio: regmap: Support sparsed fixed direction
https://git.kernel.org/brgl/c/ae99219270a3d85ec38eee9458829bd45c11aeec
[2/2] gpio: regmap: Don't set a fixed direction line
https://git.kernel.org/brgl/c/c3566b4a08707587fd52342f53cda1d7ee2607ca
Best regards,
--
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/2] Improvement spotted during patch review.
2026-05-11 12:32 ` Bartosz Golaszewski
@ 2026-05-11 12:39 ` Michael Walle
2026-05-11 12:44 ` Bartosz Golaszewski
0 siblings, 1 reply; 14+ messages in thread
From: Michael Walle @ 2026-05-11 12:39 UTC (permalink / raw)
To: Bartosz Golaszewski, Bartosz Golaszewski, Linus Walleij
Cc: linux-gpio, linux-kernel, Alex Elder, Sashiko
[-- Attachment #1: Type: text/plain, Size: 689 bytes --]
Hi,
On Mon May 11, 2026 at 2:32 PM CEST, Bartosz Golaszewski wrote:
>
> On Fri, 08 May 2026 14:51:25 +0200, Linus Walleij wrote:
>> Support sparse unidirectional GPIO lines.
>>
>> To be used in a forthcoming submission.
>>
>>
>
> Applied, thanks!
>
> [1/2] gpio: regmap: Support sparsed fixed direction
> https://git.kernel.org/brgl/c/ae99219270a3d85ec38eee9458829bd45c11aeec
> [2/2] gpio: regmap: Don't set a fixed direction line
> https://git.kernel.org/brgl/c/c3566b4a08707587fd52342f53cda1d7ee2607ca
>
Mh, my review comment [1] made it through, didn't it?
-michael
[1] https://lore.kernel.org/linux-gpio/DIFNX8HLL7X3.JGSENU7W32X4@kernel.org/
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 297 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 0/2] Improvement spotted during patch review.
2026-05-11 12:39 ` Michael Walle
@ 2026-05-11 12:44 ` Bartosz Golaszewski
0 siblings, 0 replies; 14+ messages in thread
From: Bartosz Golaszewski @ 2026-05-11 12:44 UTC (permalink / raw)
To: Michael Walle
Cc: Bartosz Golaszewski, Bartosz Golaszewski, Linus Walleij,
linux-gpio, linux-kernel, Alex Elder, Sashiko
On Mon, 11 May 2026 14:39:03 +0200, Michael Walle <mwalle@kernel.org> said:
> Hi,
>
> On Mon May 11, 2026 at 2:32 PM CEST, Bartosz Golaszewski wrote:
>>
>> On Fri, 08 May 2026 14:51:25 +0200, Linus Walleij wrote:
>>> Support sparse unidirectional GPIO lines.
>>>
>>> To be used in a forthcoming submission.
>>>
>>>
>>
>> Applied, thanks!
>>
>> [1/2] gpio: regmap: Support sparsed fixed direction
>> https://git.kernel.org/brgl/c/ae99219270a3d85ec38eee9458829bd45c11aeec
>> [2/2] gpio: regmap: Don't set a fixed direction line
>> https://git.kernel.org/brgl/c/c3566b4a08707587fd52342f53cda1d7ee2607ca
>>
>
> Mh, my review comment [1] made it through, didn't it?
>
> -michael
>
> [1] https://lore.kernel.org/linux-gpio/DIFNX8HLL7X3.JGSENU7W32X4@kernel.org/
>
I missed it, sorry. I'll back these out for now and wait for Linus' respin.
Bart
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 1/2] gpio: regmap: Support sparsed fixed direction
2026-05-11 7:18 ` Michael Walle
@ 2026-05-11 19:00 ` Linus Walleij
0 siblings, 0 replies; 14+ messages in thread
From: Linus Walleij @ 2026-05-11 19:00 UTC (permalink / raw)
To: Michael Walle; +Cc: Bartosz Golaszewski, linux-gpio, linux-kernel, Alex Elder
On Mon, May 11, 2026 at 9:18 AM Michael Walle <mwalle@kernel.org> wrote:
> On Fri May 8, 2026 at 2:51 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.
>
> Thanks, this patch looks good. But could we invert the logic and use
> fixed_direction_mask as that feels more natural to me?
Sure!
> And for legacy reasons, so we don't have to change the drivers:
I don't think any drivers would need changing, the idea was that
if the new *sparse bitmap is NULL (as in the old drivers) all lines are
assumed to be fixed direction.
But I think your idea is maybe more intuitive so let's try that.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-05-11 19:01 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-08 12:51 [PATCH v2 0/2] Improvement spotted during patch review Linus Walleij
2026-05-08 12:51 ` [PATCH v2 1/2] gpio: regmap: Support sparsed fixed direction Linus Walleij
2026-05-08 13:03 ` Alex Elder
2026-05-10 13:31 ` Alex Elder
2026-05-11 7:18 ` Michael Walle
2026-05-11 19:00 ` Linus Walleij
2026-05-08 12:51 ` [PATCH v2 2/2] gpio: regmap: Don't set a fixed direction line Linus Walleij
2026-05-11 7:24 ` Michael Walle
2026-05-11 9:56 ` [PATCH v2 0/2] Improvement spotted during patch review Bartosz Golaszewski
2026-05-11 12:15 ` Linus Walleij
2026-05-11 12:18 ` Alex Elder
2026-05-11 12:32 ` Bartosz Golaszewski
2026-05-11 12:39 ` Michael Walle
2026-05-11 12:44 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox