[PATCH] pwm: Declare waveform stubs for when PWM is not reachable
From: Marcelo Schmitt
Date: Tue Oct 07 2025 - 18:20:05 EST
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")
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Closes: https://lore.kernel.org/oe-kbuild-all/202509272028.0zLNiR5w-lkp@xxxxxxxxx/
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@xxxxxxxxxx>
---
Cc: Jonathan Cameron <jic23@xxxxxxxxxx>
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).
I'm not very familiar with the details of how it works for series of
patches that update multiple subsystems. Documentation says such sets may go
through the -mm tree. Though, this is a small change and the consumer driver set
depends on it. Would it be okay if this gets picked up through Jonathan's IIO tree?
[1]: https://lore.kernel.org/linux-iio/202509272028.0zLNiR5w-lkp@xxxxxxxxx/
Thanks,
Marcelo
include/linux/pwm.h | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index 549ac4aaad59..a20ddc40a32a 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -504,6 +504,25 @@ struct pwm_device *devm_fwnode_pwm_get(struct device *dev,
struct fwnode_handle *fwnode,
const char *con_id);
#else
+static inline int pwm_round_waveform_might_sleep(struct pwm_device *pwm, struct pwm_waveform *wf)
+{
+ might_sleep();
+ return -EOPNOTSUPP;
+}
+
+static inline int pwm_get_waveform_might_sleep(struct pwm_device *pwm, struct pwm_waveform *wf)
+{
+ might_sleep();
+ return -EOPNOTSUPP;
+}
+
+static inline int pwm_set_waveform_might_sleep(struct pwm_device *pwm,
+ const struct pwm_waveform *wf, bool exact)
+{
+ might_sleep();
+ return -EOPNOTSUPP;
+}
+
static inline bool pwm_might_sleep(struct pwm_device *pwm)
{
return true;
base-commit: 8f2689f194b8d1bff41150ae316abdfccf191309
--
2.39.2