Re: [PATCH 2/2] gpio: realtek-otto: decide bank_read/write by device endianness

From: Bartosz Golaszewski

Date: Wed Jul 15 2026 - 05:45:44 EST


On Fri, 10 Jul 2026 20:34:39 +0200, Rustam Adilov <adilov@xxxxxxxxxxx> said:
> In order to have a working gpio controller with SWAP_IO_SPACE,
> the way bank_read and bank_write are defined must be changed and
> separated from GPIO_PORTS_REVERSED flag. That also includes the
> flags parameter used by gpio_generic_chip_config.
>
> To achieve it, use the device_is_big_endian() to decide the
> bank_read/write parameter and the flag.
>
> Signed-off-by: Rustam Adilov <adilov@xxxxxxxxxxx>
> ---
> drivers/gpio/gpio-realtek-otto.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpio/gpio-realtek-otto.c b/drivers/gpio/gpio-realtek-otto.c
> index 491fde846d46..f96072fbce92 100644
> --- a/drivers/gpio/gpio-realtek-otto.c
> +++ b/drivers/gpio/gpio-realtek-otto.c
> @@ -393,16 +393,19 @@ static int realtek_gpio_probe(struct platform_device *pdev)
>
> raw_spin_lock_init(&ctrl->lock);
>
> - if (dev_flags & GPIO_PORTS_REVERSED) {
> - gen_gc_flags = 0;
> - ctrl->bank_read = realtek_gpio_bank_read;
> - ctrl->bank_write = realtek_gpio_bank_write;
> + if (dev_flags & GPIO_PORTS_REVERSED)
> ctrl->line_imr_pos = realtek_gpio_line_imr_pos;
> - } else {
> + else
> + ctrl->line_imr_pos = realtek_gpio_line_imr_pos_swapped;
> +
> + if (device_is_big_endian(dev)) {
> gen_gc_flags = GPIO_GENERIC_BIG_ENDIAN_BYTE_ORDER;
> ctrl->bank_read = realtek_gpio_bank_read_swapped;
> ctrl->bank_write = realtek_gpio_bank_write_swapped;
> - ctrl->line_imr_pos = realtek_gpio_line_imr_pos_swapped;
> + } else {
> + gen_gc_flags = 0;
> + ctrl->bank_read = realtek_gpio_bank_read;
> + ctrl->bank_write = realtek_gpio_bank_write;
> }
>
> config = (struct gpio_generic_chip_config) {
> --
> 2.55.0
>
>

Can you look at the sashiko report? I think it's right about this change
possibly breaking existing devicetrees. Can we keep big-endian as the
default?

Bart