Skip to contentSkip to conversation

iio: adc: rzt2h: Make POWER_SEQUENCING dependency optional

PATCH In review Chen-Yu Tsai 5 participants 8 messages Nov 26

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover iio: adc: rzt2h: Make POWER_SEQUENCING dependency optional

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/[email protected]/

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/[email protected]/

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(-)
Signature · 1 line
2.56.1.839.g22a8290db9-goog
#1 lore raw

PATCH v2 1/2 power: sequencing: Allow desc=NULL in enable/disable stub functions

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.

---
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(+)
include/linux/pwrseq/consumer.h +6 -0
index b69117ad3fa7..d3f5f37603d6 100644
@@ -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;
 }
 
Signature · 1 line
2.56.1.839.g22a8290db9-goog
Reviewed-by Lad Prabhakar on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] power: sequencing: Allow desc=NULL in enable/disable stub functions

Quoted 17 lines · Chen-Yu Tsai

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.

Quoted 8 lines

---
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(+)

Cheers,
Prabhakar

Quoted 26 lines
include/linux/pwrseq/consumer.h +6 -1
index b69117ad3fa7..d3f5f37603d6 100644
@@ -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

Reviewed-by
#3 lore raw

Re: [PATCH v2 1/2] power: sequencing: Allow desc=NULL in enable/disable stub functions

Quoted 7 lines

include/linux/pwrseq/consumer.h devm_pwrseq_get(struct device *dev, const char *target) · line 53

Quoted 7 lines

static inline int pwrseq_enable(struct pwrseq_desc *desc) {

include/linux/pwrseq/consumer.h +3 -0
+       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:

#4 lore raw

Re: [PATCH v2 1/2] power: sequencing: Allow desc=NULL in enable/disable stub functions

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

...

Quoted 11 lines
Quoted 6 lines

include/linux/pwrseq/consumer.h devm_pwrseq_get(struct device *dev, const char *target) · line 53

Quoted 6 lines

static inline int pwrseq_enable(struct pwrseq_desc *desc) {

include/linux/pwrseq/consumer.h +3 -0
+       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.)

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw

Re: [PATCH v2 1/2] power: sequencing: Allow desc=NULL in enable/disable stub functions

Quoted 11 lines · Andy Shevchenko

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

...

Quoted 7 lines
Quoted 6 lines
Quoted 6 lines

static inline int pwrseq_enable(struct pwrseq_desc *desc) {

include/linux/pwrseq/consumer.h +3 -0
+       if (!desc)
+               return 0;
+
        return -ENOSYS;
Quoted 8 lines
Quoted 4 lines

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

#6 lore raw

PATCH v2 2/2 iio: adc: rzt2h: depend on POWER_SEQUENCING instead of selecting it

In reply to Chen-Yu Tsai

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.

---
 drivers/iio/adc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/Kconfig +1 -1
index 1d6ed49041ab..7874d0e78e9e 100644
@@ -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
Signature · 1 line
2.56.1.839.g22a8290db9-goog
Reviewed-by Lad Prabhakar on v2 2/2
#7 lore raw

Re: [PATCH v2 2/2] iio: adc: rzt2h: depend on POWER_SEQUENCING instead of selecting it

Quoted 20 lines · Chen-Yu Tsai

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.

Quoted 9 lines

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.

---
 drivers/iio/adc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Cheers,
Prabhakar

Quoted 17 lines
drivers/iio/adc/Kconfig +1 -2
index 1d6ed49041ab..7874d0e78e9e 100644
@@ -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