Re: [PATCH 2/3] gpio: atcgpio100: Add ATCGPIO100 GPIO driver

From: CL Wang

Date: Tue Nov 24 2026 - 04:42:40 EST


Hi Bartosz,

Thanks for the review.

On Tue, Nov 17, 2026 at 02:54:06PM +0100, Bartosz Golaszewski wrote:
> > +#include <linux/mod_devicetable.h>
>
> Uwe would probably say you should only pull in the individual headers
> that you require from include/linux/device-id/.

As Uwe pointed out, <linux/platform_device.h> already provides
of_device_id, so I will drop <linux/mod_devicetable.h> in v2.

> > + config = (struct gpio_generic_chip_config) {
> > + .dev = &priv->pdev->dev,
> > + .sz = 4,
> > + .dat = priv->base + REG_DATA_IN,
> > + .set = priv->base + REG_DATA_OUT,
> > + .dirout = priv->base + REG_CHAN_DIR,
> > + .flags = GPIO_GENERIC_READ_OUTPUT_REG_SET,
> > + };
>
> I think you could save even more code by using the gpio-regmap helper
> here instead. Could you see if that's possible here?

I tried it. The conversion is doable, but the driver grows from 641 to
721 lines. The extra code comes from:

- IRQ handling: gpio-regmap only accepts an external irq_domain, so the
driver has to create the domain and duplicate what GPIOLIB_IRQCHIP
provides today (map/xlate ops, lockdep classes, resource
request/release callbacks, and removing the chained handler and
disposing of the mappings on unbind). This accounts for most of the
growth. Using regmap-irq instead would turn the chained hardirq
handler into a threaded one, and the 3-bit trigger mode fields (one
per line, spread across four registers) would still need a custom
set_type_config() callback.

- Output readback: the datasheet documents DATA_IN for input lines
only, so output lines are read back from DATA_OUT. With gpio-mmio
this is handled by GPIO_GENERIC_READ_OUTPUT_REG_SET; with gpio-regmap
it requires a reg_mask_xlate() callback that reads the direction
register on every get.

- Shared debounce cleanup: the debounce period is shared by all lines,
and the driver clears a line's debounce enable bit in .free() so that
a released line does not block a different period on another line.
gpio-regmap does not let the driver provide .free(), so the enable
bit stays set after release and the conflict check has to skip lines
that are no longer requested.

Given that, I would prefer to keep gpio-mmio for v2. If you still
prefer gpio-regmap, I can send that version instead.

> > + if (priv->chan_num > ATCGPIO_CHAN_NUM_MAX || !priv->chan_num) {
> > + dev_warn(&priv->pdev->dev,
>
> Use a local variable to store the adress of dev for better readability.

Will do in v2, both here in atcgpio_init_controller() and in
atcgpio_init_resources().

> > + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
>
> Use devm_kzalloc_obj(). Same elsewhere.

Will do in v2. I will also convert the parents array to
devm_kzalloc_objs().

Thanks,
CL