Subject: Re: [PATCH 0/3] gpio: idio-16: Fix regmap initialization errors

From: Bartosz Golaszewski <[email-masked]>
Date: Fri, 17 Oct 2025 10:26:55 +0200

On Fri, Oct 17, 2025 at 2:58 AM William Breathitt Gray <[email-masked]> wrote:
>
> The migration of IDIO-16 GPIO drivers to the regmap API resulted in some
> regressions to the gpio-104-idio-16, gpio-pci-idio-16, and gpio-idio-16
> modules. Specifically, the 104-idio-16 and pci-idio-16 GPIO drivers
> utilize regmap caching and thus must set max_register for their
> regmap_config, while gpio-idio-16 requires fixed_direction_output to
> represent the fixed direction of the IDIO-16 GPIO lines. Fixes for these
> regressions are provided by this series.
>
> Link: https://lore.kernel.org/r/[email-masked]
> Link: https://lore.kernel.org/r/[email-masked]
> Signed-off-by: William Breathitt Gray <[email-masked]>
> ---
> William Breathitt Gray (3):
>       gpio: 104-idio-16: Define maximum valid register address offset
>       gpio: pci-idio-16: Define maximum valid register address offset
>       gpio: idio-16: Define fixed direction of the GPIO lines
>
>  drivers/gpio/gpio-104-idio-16.c | 1 +
>  drivers/gpio/gpio-idio-16.c     | 5 +++++
>  drivers/gpio/gpio-pci-idio-16.c | 1 +
>  3 files changed, 7 insertions(+)
> ---
> base-commit: eba11116f39533d2e38cc5898014f2c95f32d23a
> change-id: 20251017-fix-gpio-idio-16-regmap-1282cdc56a19
>
> Best regards,
> --
> William Breathitt Gray <[email-masked]>
>
>

Please use get_maintainer.pl or b4 --auto-to-cc. This is the address
I'm using for reviews.

Bartosz

---

From: William Breathitt Gray <[email-masked]>
Date: Fri, 17 Oct 2025 09:58:01 +0900

Attempting to load the 104-idio-16 module fails during regmap
initialization with a return error -EINVAL. This is a result of the
regmap cache failing initialization. Set the idio_16_regmap_config
max_register member to fix this failure.

Fixes: 2c210c9a34a3 ("gpio: 104-idio-16: Migrate to the regmap API")
Reported-by: Mark Cave-Ayland <[email-masked]>
Link: https://lore.kernel.org/r/[email-masked]
Suggested-by: Mark Cave-Ayland <[email-masked]>
Cc: [email-masked]
Signed-off-by: William Breathitt Gray <[email-masked]>
---
 drivers/gpio/gpio-104-idio-16.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpio/gpio-104-idio-16.c b/drivers/gpio/gpio-104-idio-16.c
index ffe7e1cb6b238856b9d13b2a278fe6c44b9cc8d3..fe5c10cd5c327ace1b715e9a27590211dce06fb0 100644
--- a/drivers/gpio/gpio-104-idio-16.c
+++ b/drivers/gpio/gpio-104-idio-16.c
@@ -59,6 +59,7 @@ static const struct regmap_config idio_16_regmap_config = {
 	.reg_stride = 1,
 	.val_bits = 8,
 	.io_port = true,
+	.max_register = 0x5,
 	.wr_table = &idio_16_wr_table,
 	.rd_table = &idio_16_rd_table,
 	.volatile_table = &idio_16_rd_table,

-- 
2.51.0

---

From: William Breathitt Gray <[email-masked]>
Date: Fri, 17 Oct 2025 09:58:02 +0900

Attempting to load the pci-idio-16 module fails during regmap
initialization with a return error -EINVAL. This is a result of the
regmap cache failing initialization. Set the idio_16_regmap_config
max_register member to fix this failure.

Fixes: 73d8f3efc5c2 ("gpio: pci-idio-16: Migrate to the regmap API")

diff --git a/drivers/gpio/gpio-pci-idio-16.c b/drivers/gpio/gpio-pci-idio-16.c
index 476cea1b5ed774d18511aaf71d8ca2d71bcc9ff0..9d28ca8e1d6fac4bdc105b850583607b5e5a87ea 100644
--- a/drivers/gpio/gpio-pci-idio-16.c
+++ b/drivers/gpio/gpio-pci-idio-16.c
@@ -41,6 +41,7 @@ static const struct regmap_config idio_16_regmap_config = {
 	.reg_stride = 1,
 	.val_bits = 8,
 	.io_port = true,
+	.max_register = 0x7,
 	.wr_table = &idio_16_wr_table,
 	.rd_table = &idio_16_rd_table,
 	.volatile_table = &idio_16_rd_table,

-- 
2.51.0

---

From: William Breathitt Gray <[email-masked]>
Date: Fri, 17 Oct 2025 09:58:03 +0900

The direction of the IDIO-16 GPIO lines is fixed with the first 16 lines
as output and the remaining 16 lines as input. Set the gpio_config
fixed_direction_output member to represent the fixed direction of the
GPIO lines.

Fixes: db02247827ef ("gpio: idio-16: Migrate to the regmap API")
Reported-by: Mark Cave-Ayland <[email-masked]>
Link: https://lore.kernel.org/r/[email-masked]
Suggested-by: Michael Walle <[email-masked]>
Cc: [email-masked] # ae495810cffe: gpio: regmap: add the .fixed_direction_output configuration parameter
Cc: [email-masked]
Signed-off-by: William Breathitt Gray <[email-masked]>
---
 drivers/gpio/gpio-idio-16.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpio/gpio-idio-16.c b/drivers/gpio/gpio-idio-16.c
index 0103be977c66bb8d165c1c92123368be6832d120..4fbae6f6a49727df40f2793b42ca207d78ec272b 100644
--- a/drivers/gpio/gpio-idio-16.c
+++ b/drivers/gpio/gpio-idio-16.c
@@ -6,6 +6,7 @@
 
 #define DEFAULT_SYMBOL_NAMESPACE "GPIO_IDIO_16"
 
+#include <linux/bitmap.h>
 #include <linux/bits.h>
 #include <linux/device.h>
 #include <linux/err.h>
@@ -107,6 +108,7 @@ int devm_idio_16_regmap_register(struct device *const dev,
 	struct idio_16_data *data;
 	struct regmap_irq_chip *chip;
 	struct regmap_irq_chip_data *chip_data;
+	DECLARE_BITMAP(fixed_direction_output, IDIO_16_NGPIO);
 
 	if (!config->parent)
 		return -EINVAL;
@@ -164,6 +166,9 @@ int devm_idio_16_regmap_register(struct device *const dev,
 	gpio_config.irq_domain = regmap_irq_get_domain(chip_data);
 	gpio_config.reg_mask_xlate = idio_16_reg_mask_xlate;
 
+	bitmap_from_u64(fixed_direction_output, GENMASK_U64(15, 0));
+	gpio_config.fixed_direction_output = fixed_direction_output;
+
 	return PTR_ERR_OR_ZERO(devm_gpio_regmap_register(dev, &gpio_config));
 }
 EXPORT_SYMBOL_GPL(devm_idio_16_regmap_register);

-- 
2.51.0

---

From: William Breathitt Gray <[email-masked]>
Date: Fri, 17 Oct 2025 09:58:00 +0900

Best regards,