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

Nuno Sá
2025-10-10T10:26:20Z

On Thu, 2025-10-09 at 18:53 +0200, Uwe Kleine-König wrote:
> 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.
>

Agreed. Seems to be one of those cases where we select a symbol that depends on
something.

However, this driver can indeed work without spi offload and hence PWM and
SPI_OFFLOAD (AFAIR) are optional so I wonder what's the right approach. Looking
at the new series I already see:

select SPI_OFFLOAD_TRIGGER_PWM if (SPI_OFFLOAD && PWM)

Which makes more sense but I guess we still need the stubs with the above. But
I would also expect stubs to be needed for spi/offload/consumer.h. Maybe I'm
missing something though...

I did not tested but I also wonder if 'imply SPI_OFFLOAD_TRIGGER_PWM' is not
similar to the above.

- Nuno Sá

> Best regards
> Uwe