From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Janani Sunil <janani.sunil@analog.com>
Cc: "Nuno Sá" <nuno.sa@analog.com>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Olivier Moysan" <olivier.moysan@foss.st.com>,
"Philipp Zabel" <p.zabel@pengutronix.de>,
"Linus Walleij" <linusw@kernel.org>,
"Bartosz Golaszewski" <brgl@kernel.org>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Michael Walle" <mwalle@kernel.org>,
linux@analog.com, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-doc@vger.kernel.org,
jananisunil.dev@gmail.com,
"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
Subject: Re: [PATCH v2 5/7] gpio: regmap: Add runtime PM and read_output_reg_set support
Date: Fri, 7 Aug 2026 03:02:15 +0300 [thread overview]
Message-ID: <anUgh6qgESzpRJwa@ashevche-desk.local> (raw)
In-Reply-To: <20260806-ad7768-driver-v2-5-027ac5e2a641@analog.com>
On Thu, Aug 06, 2026 at 05:41:24PM +0200, Janani Sunil wrote:
> The new pm_dev field in gpio_regmap_config allows a driver to supply a
> device for runtime PM. All operations call pm_runtime_resume_and_get()
> before accessing the regmap and pm_runtime_put_autosuspend() on return.
>
> The new read_output_reg_set flag when set, gpio_regmap_get() checks the
> pin direction first and reads from reg_set_base instead of reg_dat_base
> for output pins. Requires both reg_dat_base and reg_set_base to be
> configured.
...
> struct gpio_regmap {
> unsigned int reg_clr_base;
> unsigned int reg_dir_in_base;
> unsigned int reg_dir_out_base;
> + struct device *pm_dev;
> + bool read_output_reg_set;
> unsigned long *fixed_direction_mask;
> unsigned long *fixed_direction_output;
> }
Have you run `pahole`? Is it okay to put bool there and not after one of
unsigned int:s (just from the given context, it might be even better location)?
...
> +static int gpio_regmap_runtime_get(struct gpio_regmap *gpio)
> +{
> + if (!gpio->pm_dev)
> + return 0;
> +
> + return pm_runtime_resume_and_get(gpio->pm_dev);
> +}
> +
> +static void gpio_regmap_runtime_put(struct gpio_regmap *gpio)
> +{
> + if (gpio->pm_dev)
> + pm_runtime_put_autosuspend(gpio->pm_dev);
Same pattern as per above.
> +}
...
> +static int gpio_regmap_get_direction(struct gpio_chip *chip,
> + unsigned int offset);
Can this be avoidable?
...
> /* ensure we don't spoil any register cache with pin input values */
> if (gpio->reg_dat_base == gpio->reg_set_base)
> ret = regmap_read_bypassed(gpio->regmap, reg, &val);
> else
> ret = regmap_read(gpio->regmap, reg, &val);
> - if (ret)
> - return ret;
> + if (!ret)
> + ret = !!(val & mask);
>
> - return !!(val & mask);
You want regmap_test_bits() in one case, and the regular pattern in the other.
> +out_pm:
labels should be marked better to show what will be when goto them.
out_pm_put:
> + gpio_regmap_runtime_put(gpio);
> + return ret;
...
> +out_pm:
> + gpio_regmap_runtime_put(gpio);
> return ret;
Ditto.
...
> ret = regmap_read(gpio->regmap, reg, &val);
> if (ret)
> - return ret;
> + goto out_pm;
>
> if (!!(val & mask) ^ invert)
> - return GPIO_LINE_DIRECTION_OUT;
> + ret = GPIO_LINE_DIRECTION_OUT;
> else
> - return GPIO_LINE_DIRECTION_IN;
> + ret = GPIO_LINE_DIRECTION_IN;
Also can be transformed to use regmap_test_bits() (but in a separate change).
...
> struct gpio_regmap_config {
> unsigned int reg_clr_base;
> unsigned int reg_dir_in_base;
> unsigned int reg_dir_out_base;
> + struct device *pm_dev;
> + bool read_output_reg_set;
> int reg_stride;
> int ngpio_per_reg;
> struct irq_domain *irq_domain;
`pahole`?
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-08-07 0:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 15:41 [PATCH v2 0/7] iio: adc: Add AD7768/AD7768-4 ADC driver support Janani Sunil
2026-08-06 15:41 ` [PATCH v2 1/7] dt-bindings: iio: adc: Add AD7768 Janani Sunil
2026-08-06 15:41 ` [PATCH v2 2/7] iio: backend: Add support for CRC Janani Sunil
2026-08-06 15:41 ` [PATCH v2 3/7] iio: adc: adi-axi-adc: " Janani Sunil
2026-08-06 15:41 ` [PATCH v2 4/7] iio: adc: Add AD7768 IIO Driver support Janani Sunil
2026-08-07 0:28 ` Andy Shevchenko
2026-08-06 15:41 ` [PATCH v2 5/7] gpio: regmap: Add runtime PM and read_output_reg_set support Janani Sunil
2026-08-06 21:31 ` Linus Walleij
2026-08-07 0:02 ` Andy Shevchenko [this message]
2026-08-06 15:41 ` [PATCH v2 6/7] gpio: ad7768: Add AD7768 GPIO auxiliary driver Janani Sunil
2026-08-06 15:41 ` [PATCH v2 7/7] Documentation: iio: Add AD7768 Documentation Janani Sunil
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=anUgh6qgESzpRJwa@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=brgl@kernel.org \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=janani.sunil@analog.com \
--cc=jananisunil.dev@gmail.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@analog.com \
--cc=mwalle@kernel.org \
--cc=nuno.sa@analog.com \
--cc=olivier.moysan@foss.st.com \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=skhan@linuxfoundation.org \
--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