mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: CL Wang <cl634@andestech.com>
To: Bartosz Golaszewski <brgl@kernel.org>
Cc: "CL Wang" <cl634@andestech.com>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Linus Walleij" <linusw@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, tim609@andestech.com
Subject: Re: [PATCH 2/3] gpio: atcgpio100: Add ATCGPIO100 GPIO driver
Date: Tue, 24 Nov 2026 17:41:27 +0800	[thread overview]
Message-ID: <20261124094127.1988037-1-cl634@andestech.com> (raw)
In-Reply-To: <22ifazqg6afr6rcybqg6foah3v554xu4px2c4et35y5xzpg74h@kesthgcvnlgk>

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

  reply	other threads:[~2026-11-24  9:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  4:09 [PATCH 0/3] gpio: Add support for Andes ATCGPIO100 GPIO controller CL Wang
2026-11-16  4:09 ` [PATCH 1/3] dt-bindings: gpio: Add support for " CL Wang
2026-11-23 11:05   ` Krzysztof Kozlowski
2026-11-16  4:09 ` [PATCH 2/3] gpio: atcgpio100: Add ATCGPIO100 GPIO driver CL Wang
2026-11-17 13:54   ` Bartosz Golaszewski
2026-11-24  9:41     ` CL Wang [this message]
2026-11-17 14:10   ` Uwe Kleine-König
2026-11-16  4:09 ` [PATCH 3/3] MAINTAINERS: Add entry for Andes ATCGPIO100 GPIO CL Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261124094127.1988037-1-cl634@andestech.com \
    --to=cl634@andestech.com \
    --cc=brgl@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=tim609@andestech.com \
    --cc=u.kleine-koenig@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®