Re: [RFC PATCH 3/5] gpio: generic: add io_port to struct gpio_generic_chip
From: Linus Walleij
Date: Thu Apr 09 2026 - 04:22:19 EST
On Tue, Apr 7, 2026 at 8:49 PM Jose Javier Rodriguez Barbarin
<dev-josejavier.rodriguez@xxxxxxxxxx> wrote:
> @@ -645,6 +645,7 @@ int gpio_generic_chip_init(struct gpio_generic_chip *chip,
> gc->base = -1;
> gc->request = gpio_mmio_request;
> chip->be_bits = !!(flags & GPIO_GENERIC_BIG_ENDIAN);
> + chip->io_port = !!(flags & GPIO_GENERIC_PORT_MAPPED);
Actually, if you follow my idead to use a special config for port-based
chips, struct gpio_generic_port_chip_config, that means that you will
need to refactor-split this:
int gpio_generic_chip_init(struct gpio_generic_chip *chip,
const struct gpio_generic_chip_config *cfg)
Something like this:
static int gpio_generic_chip_init_common(struct gpio_generic_chip *chip,
unsigned long flags, struct device *dev)
int gpio_generic_chip_init(struct gpio_generic_chip *chip,
const struct gpio_generic_chip_config *cfg)
int gpio_generic_port_chip_init(struct gpio_generic_chip *chip,
const struct gpio_generic_port_chip_config *cfg)
(Those prototypes half-guessed by looking at the code...)
So that each variant calls the common code for the generic part and
the MMIO-only respective port-only portions are kept inside
the specialized init functions, with gpio_generic_port_chip_init()
ifdef:ed out for !PORT_IO.
In that case, chip->io_port can just uncoditionally be assigned
true from gpio_generic_port_chip_init() and you don't even need
the special flag for port mapped IO.
Yours,
Linus Walleij