All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] iio: adc: rzt2h: Make POWER_SEQUENCING dependency optional
@ 2026-11-26  8:11 Chen-Yu Tsai
  2026-11-26  8:11 ` [PATCH v2 1/2] power: sequencing: Allow desc=NULL in enable/disable stub functions Chen-Yu Tsai
  2026-11-26  8:11 ` [PATCH v2 2/2] iio: adc: rzt2h: depend on POWER_SEQUENCING instead of selecting it Chen-Yu Tsai
  0 siblings, 2 replies; 8+ messages in thread
From: Chen-Yu Tsai @ 2026-11-26  8:11 UTC (permalink / raw)
  To: Bartosz Golaszewski, Cosmin Tanislav, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko
  Cc: Chen-Yu Tsai, linux-pm, linux-iio, linux-renesas-soc,
	Lad Prabhakar, Geert Uytterhoeven

Hi folks,

This is v2 of making the POWER_SEQUENCING dependency for RZT2H_ADC optional.

Changes since v1:
- Added blank lines before return statements in patch 1 (Bartosz)
- Collected Biju's Reviewed-by tag on patch 1
- Link to v1:
  https://lore.kernel.org/all/20261123113755.3033436-1-wenst@chromium.org/

Commit bdfc454e8567 ("iio: adc: rzt2h: Add support for RZ/V2H(P) SoC")
in the IIO tree added power sequencing support to the rzt2h_adc driver
and made rzt2h_adc select POWER_SEQUENCING. When combined with the
in-flight USB core power sequencing integration [1], this introduces a
recursive Kconfig dependency:

	error: recursive dependency detected!
		symbol USB depends on POWER_SEQUENCING
		symbol POWER_SEQUENCING is selected by RZT2H_ADC
		symbol RZT2H_ADC depends on IIO
		symbol IIO is implied by HID_MCP2221
		symbol HID_MCP2221 depends on USB_HID
		symbol USB_HID depends on USB

Since RZ/T2H and RZ/N2H do not use a power sequencer, rzt2h_adc does not
strictly require POWER_SEQUENCING at build time and can use an optional
dependency instead. However, rzt2h_adc calls pwrseq_{enable,disable}()
unconditionally in its runtime PM callbacks with adc->pwrseq == NULL on
RZ/T2H and RZ/N2H, whereas the !CONFIG_POWER_SEQUENCING stubs currently
return -ENOSYS even for a NULL descriptor.

Patch 1 aligns the pwrseq_{enable,disable}() stubs with the core
implementation so they act as no-ops (returning 0) when desc is NULL.

Patch 2 switches rzt2h_adc from selecting POWER_SEQUENCING to an
optional dependency on it.

Patch 2 relies on patch 1 at runtime when POWER_SEQUENCING=n on RZ/T2H
and RZ/N2H. On v1, Bartosz noted he would "prefer to pick up patch 1/2
and provide an immutable branch to the IIO subsystem".


Thanks
ChenYu

[1] https://lore.kernel.org/all/20260916075745.3549953-1-wenst@chromium.org/


Chen-Yu Tsai (2):
  power: sequencing: Allow desc=NULL in enable/disable stub functions
  iio: adc: rzt2h: depend on POWER_SEQUENCING instead of selecting it

 drivers/iio/adc/Kconfig         | 2 +-
 include/linux/pwrseq/consumer.h | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/2] power: sequencing: Allow desc=NULL in enable/disable stub functions
  2026-11-26  8:11 [PATCH v2 0/2] iio: adc: rzt2h: Make POWER_SEQUENCING dependency optional Chen-Yu Tsai
@ 2026-11-26  8:11 ` Chen-Yu Tsai
  2026-11-26 11:45   ` Lad, Prabhakar
  2026-11-26  8:11 ` [PATCH v2 2/2] iio: adc: rzt2h: depend on POWER_SEQUENCING instead of selecting it Chen-Yu Tsai
  1 sibling, 1 reply; 8+ messages in thread
From: Chen-Yu Tsai @ 2026-11-26  8:11 UTC (permalink / raw)
  To: Bartosz Golaszewski, Cosmin Tanislav, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko
  Cc: Chen-Yu Tsai, linux-pm, linux-iio, linux-renesas-soc,
	Lad Prabhakar, Geert Uytterhoeven, Biju Das

The non-stub versions of pwrseq_{enable,disable}() are no-ops when
the descriptor is NULL; however the stub versions always return -ENOSYS.

This would require more code to deal with on the consumer side if the
power sequencer is only needed for a subset of the supported devices.
One such example is the rzt2h_adc driver. Only one of its two supported
hardware blocks requires a power sequencer. The driver could be built
without power sequencing support and the other supported hardware block
would still work (provided the Kconfig dependencies are changed).

Align the pwrseq_{enable,disable}() stub functions so that they also
return success on NULL descriptors, acting as no-ops like their non-stub
counterparts.

Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
---
Changes since v1:
- Added blank lines before return statements (Bartosz)
- Collected Biju's Reviewed-by tag
---
 include/linux/pwrseq/consumer.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/pwrseq/consumer.h b/include/linux/pwrseq/consumer.h
index b69117ad3fa7..d3f5f37603d6 100644
--- a/include/linux/pwrseq/consumer.h
+++ b/include/linux/pwrseq/consumer.h
@@ -47,11 +47,17 @@ devm_pwrseq_get(struct device *dev, const char *target)
 
 static inline int pwrseq_enable(struct pwrseq_desc *desc)
 {
+	if (!desc)
+		return 0;
+
 	return -ENOSYS;
 }
 
 static inline int pwrseq_disable(struct pwrseq_desc *desc)
 {
+	if (!desc)
+		return 0;
+
 	return -ENOSYS;
 }
 
-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/2] iio: adc: rzt2h: depend on POWER_SEQUENCING instead of selecting it
  2026-11-26  8:11 [PATCH v2 0/2] iio: adc: rzt2h: Make POWER_SEQUENCING dependency optional Chen-Yu Tsai
  2026-11-26  8:11 ` [PATCH v2 1/2] power: sequencing: Allow desc=NULL in enable/disable stub functions Chen-Yu Tsai
@ 2026-11-26  8:11 ` Chen-Yu Tsai
  2026-11-26 11:52   ` Lad, Prabhakar
  1 sibling, 1 reply; 8+ messages in thread
From: Chen-Yu Tsai @ 2026-11-26  8:11 UTC (permalink / raw)
  To: Bartosz Golaszewski, Cosmin Tanislav, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko
  Cc: Chen-Yu Tsai, linux-pm, linux-iio, linux-renesas-soc,
	Lad Prabhakar, Geert Uytterhoeven

Commit bdfc454e8567 ("iio: adc: rzt2h: Add support for RZ/V2H(P) SoC")
recently added usage of the power sequencing API to the rzt2h_adc
driver, and directly selects POWER_SEQUENCING.

This new Kconfig select causes a recursive dependency when combined with
the in-flight power sequencing integration into the USB core:

	error: recursive dependency detected!
		symbol USB depends on POWER_SEQUENCING
		symbol POWER_SEQUENCING is selected by RZT2H_ADC
		symbol RZT2H_ADC depends on IIO
		symbol IIO is implied by HID_MCP2221
		symbol HID_MCP2221 depends on USB_HID
		symbol USB_HID depends on USB

Power sequencing is not needed for RZ/T2H and RZ/N2H, whereas RZ/V2H(P)
and RZ/V2N do need it. But it is not a strict build time requirement
for the driver. Change it to an optional depends on.

This also requires a change to the pwrseq stub functions so that the
pwrseq_{enable,disable}() calls in the driver still work without a
power sequencing descriptor with POWER_SEQUENCING=n.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
---
 drivers/iio/adc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index 1d6ed49041ab..7874d0e78e9e 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -1631,7 +1631,7 @@ config RZT2H_ADC
 	select IIO_ADC_HELPER
 	select IIO_BUFFER
 	select IIO_KFIFO_BUF
-	select POWER_SEQUENCING
+	depends on POWER_SEQUENCING if POWER_SEQUENCING
 	help
 	  Say yes here to build support for the ADC found in Renesas SoCs:
 	  - RZ/N2H
-- 
2.56.1.839.g22a8290db9-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] power: sequencing: Allow desc=NULL in enable/disable stub functions
  2026-11-26  8:11 ` [PATCH v2 1/2] power: sequencing: Allow desc=NULL in enable/disable stub functions Chen-Yu Tsai
@ 2026-11-26 11:45   ` Lad, Prabhakar
  2026-11-26 12:39     ` Wolfram Sang
  0 siblings, 1 reply; 8+ messages in thread
From: Lad, Prabhakar @ 2026-11-26 11:45 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Bartosz Golaszewski, Cosmin Tanislav, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, linux-pm, linux-iio,
	linux-renesas-soc, Lad Prabhakar, Geert Uytterhoeven, Biju Das

On Thu, Nov 26, 2026 at 8:12 AM Chen-Yu Tsai <wenst@chromium.org> wrote:
>
> The non-stub versions of pwrseq_{enable,disable}() are no-ops when
> the descriptor is NULL; however the stub versions always return -ENOSYS.
>
> This would require more code to deal with on the consumer side if the
> power sequencer is only needed for a subset of the supported devices.
> One such example is the rzt2h_adc driver. Only one of its two supported
> hardware blocks requires a power sequencer. The driver could be built
> without power sequencing support and the other supported hardware block
> would still work (provided the Kconfig dependencies are changed).
>
> Align the pwrseq_{enable,disable}() stub functions so that they also
> return success on NULL descriptors, acting as no-ops like their non-stub
> counterparts.
>
> Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
> ---
> Changes since v1:
> - Added blank lines before return statements (Bartosz)
> - Collected Biju's Reviewed-by tag
> ---
>  include/linux/pwrseq/consumer.h | 6 ++++++
>  1 file changed, 6 insertions(+)
>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

Cheers,
Prabhakar

> diff --git a/include/linux/pwrseq/consumer.h b/include/linux/pwrseq/consumer.h
> index b69117ad3fa7..d3f5f37603d6 100644
> --- a/include/linux/pwrseq/consumer.h
> +++ b/include/linux/pwrseq/consumer.h
> @@ -47,11 +47,17 @@ devm_pwrseq_get(struct device *dev, const char *target)
>
>  static inline int pwrseq_enable(struct pwrseq_desc *desc)
>  {
> +       if (!desc)
> +               return 0;
> +
>         return -ENOSYS;
>  }
>
>  static inline int pwrseq_disable(struct pwrseq_desc *desc)
>  {
> +       if (!desc)
> +               return 0;
> +
>         return -ENOSYS;
>  }
>
> --
> 2.56.1.839.g22a8290db9-goog
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] iio: adc: rzt2h: depend on POWER_SEQUENCING instead of selecting it
  2026-11-26  8:11 ` [PATCH v2 2/2] iio: adc: rzt2h: depend on POWER_SEQUENCING instead of selecting it Chen-Yu Tsai
@ 2026-11-26 11:52   ` Lad, Prabhakar
  0 siblings, 0 replies; 8+ messages in thread
From: Lad, Prabhakar @ 2026-11-26 11:52 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Bartosz Golaszewski, Cosmin Tanislav, Jonathan Cameron,
	David Lechner, Nuno Sá, Andy Shevchenko, linux-pm, linux-iio,
	linux-renesas-soc, Lad Prabhakar, Geert Uytterhoeven

On Thu, Nov 26, 2026 at 8:12 AM Chen-Yu Tsai <wenst@chromium.org> wrote:
>
> Commit bdfc454e8567 ("iio: adc: rzt2h: Add support for RZ/V2H(P) SoC")
> recently added usage of the power sequencing API to the rzt2h_adc
> driver, and directly selects POWER_SEQUENCING.
>
> This new Kconfig select causes a recursive dependency when combined with
> the in-flight power sequencing integration into the USB core:
>
>         error: recursive dependency detected!
>                 symbol USB depends on POWER_SEQUENCING
>                 symbol POWER_SEQUENCING is selected by RZT2H_ADC
>                 symbol RZT2H_ADC depends on IIO
>                 symbol IIO is implied by HID_MCP2221
>                 symbol HID_MCP2221 depends on USB_HID
>                 symbol USB_HID depends on USB
>
> Power sequencing is not needed for RZ/T2H and RZ/N2H, whereas RZ/V2H(P)
> and RZ/V2N do need it. But it is not a strict build time requirement
> for the driver. Change it to an optional depends on.
>
> This also requires a change to the pwrseq stub functions so that the
> pwrseq_{enable,disable}() calls in the driver still work without a
> power sequencing descriptor with POWER_SEQUENCING=n.
>
> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
> ---
>  drivers/iio/adc/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

Cheers,
Prabhakar

> diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
> index 1d6ed49041ab..7874d0e78e9e 100644
> --- a/drivers/iio/adc/Kconfig
> +++ b/drivers/iio/adc/Kconfig
> @@ -1631,7 +1631,7 @@ config RZT2H_ADC
>         select IIO_ADC_HELPER
>         select IIO_BUFFER
>         select IIO_KFIFO_BUF
> -       select POWER_SEQUENCING
> +       depends on POWER_SEQUENCING if POWER_SEQUENCING
>         help
>           Say yes here to build support for the ADC found in Renesas SoCs:
>           - RZ/N2H
> --
> 2.56.1.839.g22a8290db9-goog
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] power: sequencing: Allow desc=NULL in enable/disable stub functions
  2026-11-26 11:45   ` Lad, Prabhakar
@ 2026-11-26 12:39     ` Wolfram Sang
  2026-11-26 15:18       ` Andy Shevchenko
  0 siblings, 1 reply; 8+ messages in thread
From: Wolfram Sang @ 2026-11-26 12:39 UTC (permalink / raw)
  To: Lad, Prabhakar
  Cc: Chen-Yu Tsai, Bartosz Golaszewski, Cosmin Tanislav,
	Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	linux-pm, linux-iio, linux-renesas-soc, Lad Prabhakar,
	Geert Uytterhoeven, Biju Das

[-- Attachment #1: Type: text/plain, Size: 350 bytes --]


> >  static inline int pwrseq_enable(struct pwrseq_desc *desc)
> >  {
> > +       if (!desc)
> > +               return 0;
> > +
> >         return -ENOSYS;

Bike-shedding alert: What about the ternary operator? It is nicely
concise here:

	return desc ? -ENOSYS : 0;

Other than that:

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] power: sequencing: Allow desc=NULL in enable/disable stub functions
  2026-11-26 12:39     ` Wolfram Sang
@ 2026-11-26 15:18       ` Andy Shevchenko
  2026-11-26 15:33         ` Bartosz Golaszewski
  0 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2026-11-26 15:18 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Lad, Prabhakar, Chen-Yu Tsai, Bartosz Golaszewski,
	Cosmin Tanislav, Jonathan Cameron, David Lechner, Nuno Sá,
	Andy Shevchenko, linux-pm, linux-iio, linux-renesas-soc,
	Lad Prabhakar, Geert Uytterhoeven, Biju Das

On Thu, Nov 26, 2026 at 01:39:09PM +0100, Wolfram Sang wrote:

...

> > >  static inline int pwrseq_enable(struct pwrseq_desc *desc)
> > >  {
> > > +       if (!desc)
> > > +               return 0;
> > > +
> > >         return -ENOSYS;
> 
> Bike-shedding alert: What about the ternary operator? It is nicely
> concise here:
> 
> 	return desc ? -ENOSYS : 0;

In long term this may grow to something else and ternary would be harder
to read. (Gave a comment with my true love to ternary and Elvis in particular.)

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] power: sequencing: Allow desc=NULL in enable/disable stub functions
  2026-11-26 15:18       ` Andy Shevchenko
@ 2026-11-26 15:33         ` Bartosz Golaszewski
  0 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2026-11-26 15:33 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Wolfram Sang, Lad, Prabhakar, Chen-Yu Tsai, Cosmin Tanislav,
	Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	linux-pm, linux-iio, linux-renesas-soc, Lad Prabhakar,
	Geert Uytterhoeven, Biju Das

On Thu, Nov 26, 2026 at 05:18:02PM +0200, Andy Shevchenko wrote:
> On Thu, Nov 26, 2026 at 01:39:09PM +0100, Wolfram Sang wrote:
> 
> ...
> 
> > > >  static inline int pwrseq_enable(struct pwrseq_desc *desc)
> > > >  {
> > > > +       if (!desc)
> > > > +               return 0;
> > > > +
> > > >         return -ENOSYS;
> > 
> > Bike-shedding alert: What about the ternary operator? It is nicely
> > concise here:
> > 
> > 	return desc ? -ENOSYS : 0;
> 
> In long term this may grow to something else and ternary would be harder
> to read. (Gave a comment with my true love to ternary and Elvis in particular.)
>

I prefer an explicit early return.

Bart

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-26 15:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26  8:11 [PATCH v2 0/2] iio: adc: rzt2h: Make POWER_SEQUENCING dependency optional Chen-Yu Tsai
2026-11-26  8:11 ` [PATCH v2 1/2] power: sequencing: Allow desc=NULL in enable/disable stub functions Chen-Yu Tsai
2026-11-26 11:45   ` Lad, Prabhakar
2026-11-26 12:39     ` Wolfram Sang
2026-11-26 15:18       ` Andy Shevchenko
2026-11-26 15:33         ` Bartosz Golaszewski
2026-11-26  8:11 ` [PATCH v2 2/2] iio: adc: rzt2h: depend on POWER_SEQUENCING instead of selecting it Chen-Yu Tsai
2026-11-26 11:52   ` Lad, Prabhakar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.