Re: [PATCH] pwm: Declare waveform stubs for when PWM is not reachable

Uwe Kleine-König
2025-10-09T16:53:44Z

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

Hello Marcelo,

On Tue, Oct 07, 2025 at 07:19:38PM -0300, Marcelo Schmitt wrote:
> Previously, the PWM waveform consumer API would not be declared if
> CONFIG_PWM was not reachable. That caused kernel builds to fail if a
> consumer driver was enabled but PWM disabled. Add stubs for PWM waveform
> functions so client drivers that use, but don't depend on PWM, can build if
> PWM is disabled.
>
> Fixes: 6c5126c6406d ("pwm: Provide new consumer API functions for waveforms")

At the time 6c5126c6406d was applied, there was no user of the API that
doesn't depend on CONFIG_PWM, so I object adding this Fixes line.

> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202509272028.0zLNiR5w-lkp@intel.com/
> Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
> ---
> Cc: Jonathan Cameron <jic23@kernel.org>
> Hi Uwe,
>
> This is a fix based on a report from 0-day bot [1].
> We need this for a sophisticated IIO device that makes direct use of a PWM
> waveform (in addition to indirect use of PWM through SPI_OFFLOAD_TRIGGER_PWM).

Does the driver work in some configuration with the pwm stubs? If not,
the right thing to do is to let it depend on PWM. (Note the inverse
isn't necessarily a good idea.)

And I wonder how you could even compile your driver without PWM support
given that it selects SPI_OFFLOAD_TRIGGER_PWM which depends on PWM.

... some time later ...

OK, I tried to reproduce the problem that the kernel build bot run into.
There is a warning:

WARNING: unmet direct dependencies detected for SPI_OFFLOAD_TRIGGER_PWM
Depends on [n]: SPI [=y] && SPI_OFFLOAD [=y] && PWM [=n]
Selected by [y]:
- AD4030 [=y] && IIO [=y] && SPI [=y] && GPIOLIB [=y]

This is the thing that needs fixing, i.e. don't select a symbol with
dependencies that the selecting symbol doesn't assert to be fulfilled.

Best regards
Uwe

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