<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/pwm/core.c, branch v6.18.22</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.18.22</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.18.22'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2026-01-30T09:32:12+00:00</updated>
<entry>
<title>pwm: Ensure ioctl() returns a negative errno on error</title>
<updated>2026-01-30T09:32:12+00:00</updated>
<author>
<name>Uwe Kleine-König</name>
<email>u.kleine-koenig@baylibre.com</email>
</author>
<published>2026-01-19T15:13:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=4230e8cd2f1b49e1021c463bbdc06fb10b22f630'/>
<id>urn:sha1:4230e8cd2f1b49e1021c463bbdc06fb10b22f630</id>
<content type='text'>
[ Upstream commit c198b7773ca5bc3bdfb15b85e414fb9a99a5e5ba ]

copy_to_user() returns the number of bytes not copied, thus if there is
a problem a positive number. However the ioctl callback is supposed to
return a negative error code on error.

This error is a unfortunate as strictly speaking it became ABI with the
introduction of pwm character devices. However I never saw the issue in
real life -- I found this by code inspection -- and it only affects an
error case where readonly memory is passed to the ioctls or the address
mapping changes while the ioctl is active. Also there are already error
cases returning negative values, so the calling code must be prepared to
see such values already.

Fixes: 9c06f26ba5f5 ("pwm: Add support for pwmchip devices for faster and easier userspace access")
Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@baylibre.com&gt;
Link: https://patch.msgid.link/20260119151325.571857-2-u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König &lt;ukleinek@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>pwm: Use %u to printf unsigned int pwm_chip::npwm and pwm_chip::id</title>
<updated>2025-12-18T13:03:00+00:00</updated>
<author>
<name>Uwe Kleine-König</name>
<email>u.kleine-koenig@baylibre.com</email>
</author>
<published>2025-10-06T13:35:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=036bae52e5c1055d225fb2be19d4fedea4192c6e'/>
<id>urn:sha1:036bae52e5c1055d225fb2be19d4fedea4192c6e</id>
<content type='text'>
[ Upstream commit 5f7ff902e7f324c10f2b64c5ba2e5e2d0bc4e07e ]

%u is the right conversion specifier to emit an unsigned int value.

Fixes: 62099abf67a2 ("pwm: Add debugfs interface")
Fixes: 0360a4873372 ("pwm: Mention PWM chip ID in /sys/kernel/debug/pwm")
Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@baylibre.com&gt;
Link: https://patch.msgid.link/20251006133525.2457171-2-u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König &lt;ukleinek@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>pwm: Simplify printf to emit chip-&gt;npwm in $debugfs/pwm</title>
<updated>2025-12-18T13:03:00+00:00</updated>
<author>
<name>Uwe Kleine-König</name>
<email>u.kleine-koenig@baylibre.com</email>
</author>
<published>2025-09-26T16:57:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=a2fb63bc252a8c580cae4d1430bafdc779ab1239'/>
<id>urn:sha1:a2fb63bc252a8c580cae4d1430bafdc779ab1239</id>
<content type='text'>
[ Upstream commit 3cf8e55894b51c14f8500cae5e68ed48b1b0f3fd ]

Instead of caring to correctly pluralize "PWM device(s)" using

	(chip-&gt;npwm != 1) ? "s" : ""

or

	str_plural(chip-&gt;npwm)

just simplify the format to not need a plural-s.

Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@baylibre.com&gt;
Link: https://patch.msgid.link/20250926165702.321514-2-u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König &lt;ukleinek@kernel.org&gt;
Stable-dep-of: 5f7ff902e7f3 ("pwm: Use %u to printf unsigned int pwm_chip::npwm and pwm_chip::id")
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>pwm: Provide a gpio device for waveform drivers</title>
<updated>2025-09-15T09:39:44+00:00</updated>
<author>
<name>Uwe Kleine-König</name>
<email>u.kleine-koenig@baylibre.com</email>
</author>
<published>2025-07-17T15:11:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=e7c9b66b106989aeb17b167f5bbea9a108d26c0d'/>
<id>urn:sha1:e7c9b66b106989aeb17b167f5bbea9a108d26c0d</id>
<content type='text'>
A PWM is a more general concept than an output-only GPIO. When using
duty_length = period_length the PWM looks like an active GPIO, with
duty_length = 0 like an inactive GPIO. With the waveform abstraction
there is enough control over the configuration to ensure that PWMs that
cannot generate a constant signal at both levels error out.

The pwm-pca9685 driver already provides a gpio chip. When this driver is
converted to the waveform callbacks, the gpio part can just be dropped.

Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@baylibre.com&gt;
Reviewed-by: Bartosz Golaszewski &lt;bartosz.golaszewski@linaro.org&gt;
Link: https://lore.kernel.org/r/20250717151117.1828585-2-u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König &lt;ukleinek@kernel.org&gt;
</content>
</entry>
<entry>
<title>pwm: Check actual period and duty_cycle for ignored polarity test</title>
<updated>2025-09-15T09:39:44+00:00</updated>
<author>
<name>Uwe Kleine-König</name>
<email>u.kleine-koenig@baylibre.com</email>
</author>
<published>2025-07-08T17:18:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=b871d093f1caebeb39b12136a33e7529b8fdea50'/>
<id>urn:sha1:b871d093f1caebeb39b12136a33e7529b8fdea50</id>
<content type='text'>
When a lowlevel driver configures the wrong period that might
(historically) be ok if the emitted signal has a 100% relative duty_cycle
as that just corresponds to rounding down the duty_cycle to 0 which is an
allowed thing to do for a lowlevel driver.

Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@baylibre.com&gt;
Link: https://lore.kernel.org/r/bc511c0250ea2f6390e4209ab1ea9c08a3c18612.1751994988.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König &lt;ukleinek@kernel.org&gt;
</content>
</entry>
<entry>
<title>pwm: Disable PWM_DEBUG check for disabled states</title>
<updated>2025-09-15T09:39:44+00:00</updated>
<author>
<name>Uwe Kleine-König</name>
<email>u.kleine-koenig@baylibre.com</email>
</author>
<published>2025-07-08T17:18:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=5364e70b013c204088dfcd888a5517a81f0b1836'/>
<id>urn:sha1:5364e70b013c204088dfcd888a5517a81f0b1836</id>
<content type='text'>
When a PWM is requested to be disabled, the result is unspecified, the only
intention is to save some power. So skip all checks in this case.

All but two checks already only triggered for states with .enabled = true.
The first resulted in some false positive diagnostics, the other checked
for a condition that depending on hardware might not be implementable.

Similar if the lowlevel driver disabled the hardware this might be a valid
reaction and with .enabled = false all other state parameters are
unreliable, so skip further tests in this case, too.

All later usages of .enabled can be assumed to yield true, and so several
if conditions can be simplified.

Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@baylibre.com&gt;
Link: https://lore.kernel.org/r/16d29212b09b66c286c1232b1ab0ec0f8d510aae.1751994988.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König &lt;ukleinek@kernel.org&gt;
</content>
</entry>
<entry>
<title>pwm: Fix incorrect variable used in error message</title>
<updated>2025-09-15T09:39:43+00:00</updated>
<author>
<name>Colin Ian King</name>
<email>colin.i.king@gmail.com</email>
</author>
<published>2025-09-02T13:03:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=afe872274edc7da46719a2029bfa4eab142b15f6'/>
<id>urn:sha1:afe872274edc7da46719a2029bfa4eab142b15f6</id>
<content type='text'>
The dev_err message is reporting the incorrect return value ret_tohw,
it should be reporting the value in ret_fromhw. Fix this by using
ret_fromhw instead of ret_tohw.

Fixes: 6c5126c6406d ("pwm: Provide new consumer API functions for waveforms")
Signed-off-by: Colin Ian King &lt;colin.i.king@gmail.com&gt;
Link: https://lore.kernel.org/r/20250902130348.2630053-1-colin.i.king@gmail.com
Cc: stable@vger.kernel.org
Signed-off-by: Uwe Kleine-König &lt;ukleinek@kernel.org&gt;
</content>
</entry>
<entry>
<title>pwm: Expose PWM_WFHWSIZE in public header</title>
<updated>2025-07-07T06:39:36+00:00</updated>
<author>
<name>Michal Wilczynski</name>
<email>m.wilczynski@samsung.com</email>
</author>
<published>2025-07-02T13:45:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=edd3bcb1801e1bb98f4f81485140e18c86406ced'/>
<id>urn:sha1:edd3bcb1801e1bb98f4f81485140e18c86406ced</id>
<content type='text'>
The WFHWSIZE constant defines the maximum size for the hardware-specific
waveform representation buffer. It is currently local to
drivers/pwm/core.c, which makes it inaccessible to external tools like
bindgen.

Move the constant to include/linux/pwm.h to make it part of the public
API. As part of this change, rename it to PWM_WFHWSIZE to follow
standard kernel conventions for namespacing macros in public headers.

This allows bindgen to automatically generate a corresponding constant
for the Rust PWM abstractions, ensuring the value remains synchronized
between the C core and Rust code and preventing future maintenance
issues.

Signed-off-by: Michal Wilczynski &lt;m.wilczynski@samsung.com&gt;
Link: https://lore.kernel.org/r/20250702-rust-next-pwm-working-fan-for-sending-v7-1-67ef39ff1d29@samsung.com
Signed-off-by: Uwe Kleine-König &lt;ukleinek@kernel.org&gt;
</content>
</entry>
<entry>
<title>pwm: Add support for pwmchip devices for faster and easier userspace access</title>
<updated>2025-07-07T06:39:33+00:00</updated>
<author>
<name>Uwe Kleine-König</name>
<email>u.kleine-koenig@baylibre.com</email>
</author>
<published>2025-04-30T11:56:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=9c06f26ba5f5da14bcac405c7a652dcf578a785d'/>
<id>urn:sha1:9c06f26ba5f5da14bcac405c7a652dcf578a785d</id>
<content type='text'>
With this change each pwmchip defining the new-style waveform callbacks
can be accessed from userspace via a character device. Compared to the
sysfs-API this is faster and allows to pass the whole configuration in a
single ioctl allowing atomic application and thus reducing glitches.

On an STM32MP13 I see:

	root@DistroKit:~ time pwmtestperf
	real	0m 1.27s
	user	0m 0.02s
	sys	0m 1.21s
	root@DistroKit:~ rm /dev/pwmchip0
	root@DistroKit:~ time pwmtestperf
	real	0m 3.61s
	user	0m 0.27s
	sys	0m 3.26s

pwmtestperf does essentially:

	for i in 0 .. 50000:
		pwm_set_waveform(duty_length_ns=i, period_length_ns=50000, duty_offset_ns=0)

and in the presence of /dev/pwmchip0 is uses the ioctls introduced here,
without that device it uses /sys/class/pwm/pwmchip0.

Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@baylibre.com&gt;
Link: https://lore.kernel.org/r/ad4a4e49ae3f8ea81e23cac1ac12b338c3bf5c5b.1746010245.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König &lt;ukleinek@kernel.org&gt;
</content>
</entry>
<entry>
<title>pwm: Fix invalid state detection</title>
<updated>2025-07-07T06:33:44+00:00</updated>
<author>
<name>Uwe Kleine-König</name>
<email>u.kleine-koenig@baylibre.com</email>
</author>
<published>2025-07-04T17:24:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=9ee124caae1b0defd0e02c65686f539845a3ac9b'/>
<id>urn:sha1:9ee124caae1b0defd0e02c65686f539845a3ac9b</id>
<content type='text'>
Commit 9dd42d019e63 ("pwm: Allow pwm state transitions from an invalid
state") intended to allow some state transitions that were not allowed
before. The idea is sane and back then I also got the code comment
right, but the check for enabled is bogus. This resulted in state
transitions for enabled states to be allowed to have invalid duty/period
settings and thus it can happen that low-level drivers get requests for
invalid states🙄.

Invert the check to allow state transitions for disabled states only.

Fixes: 9dd42d019e63 ("pwm: Allow pwm state transitions from an invalid state")
Signed-off-by: Uwe Kleine-König &lt;u.kleine-koenig@baylibre.com&gt;
Link: https://lore.kernel.org/r/20250704172416.626433-2-u.kleine-koenig@baylibre.com
Cc: stable@vger.kernel.org
Signed-off-by: Uwe Kleine-König &lt;ukleinek@kernel.org&gt;
</content>
</entry>
</feed>
