]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
rust: pwm: Add UnregisteredChip wrapper around Chip
authorMarkus Probst <markus.probst@posteo.de>
Tue, 2 Dec 2025 18:17:52 +0000 (18:17 +0000)
committerUwe Kleine-König <ukleinek@kernel.org>
Tue, 20 Jan 2026 17:38:05 +0000 (18:38 +0100)
commit85a5ffbd56b236e96a7a22a631f9febf36d7ead5
tree396ca6eb22cff8c927555515a9236c97a0abfae8
parent5025569cb63060255834c95ab3779905aecf67b0
rust: pwm: Add UnregisteredChip wrapper around Chip

The `pwm::Registration::register` function provides no guarantee that the
function isn't called twice with the same pwm chip, which is considered
unsafe.

Add `pwm::UnregisteredChip` as wrapper around `pwm::Chip`.
Implement `pwm::UnregisteredChip::register` for the registration. This
function takes ownership of `pwm::UnregisteredChip` and therefore
guarantees that the registration can't be called twice on the same pwm
chip.

Signed-off-by: Markus Probst <markus.probst@posteo.de>
Tested-by: Michal Wilczynski <m.wilczynski@samsung.com>
Acked-by: Michal Wilczynski <m.wilczynski@samsung.com>
Link: https://patch.msgid.link/20251202-pwm_safe_register-v2-1-7a2e0d1e287f@posteo.de
[ukleinek: fixes a typo that Michal pointed out during review]
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
drivers/pwm/pwm_th1520.rs
rust/kernel/pwm.rs