[PATCH v2 0/2] Clk improvements for 6.18

Daniel Almeida posted 2 patches 4 hours ago
drivers/cpufreq/rcpufreq_dt.rs |   2 +-
rust/kernel/clk.rs             | 405 ++++++++++++++++++++++++++++-------------
rust/kernel/cpufreq.rs         |   8 +-
3 files changed, 283 insertions(+), 132 deletions(-)
[PATCH v2 0/2] Clk improvements for 6.18
Posted by Daniel Almeida 4 hours ago
This series contains a few improvements that will be soon needed by
drivers:

Patch 1 implements Send and Sync for Clocks, as a raw pointer precludes
the compiler from automatically implementing these traits. This will
lead to an otherwise unnecessary unsafe implementation of Send and Sync
for all drivers that use kernel::clk::Clk. It was included in this
series as it would otherwise conflict with patch 2.

Patch 2 implements the same typestate pattern that has been used
successfully for Regulators. This is needed because otherwise drivers
will be responsible for unpreparing and disabling clocks themselves and
ultimately handling the reference counts on their own. This is
undesirable. The patch automatically encodes this information using the
type system so that no misuse can occur.

---
Changes in v2:
- Added Alice's patch as patch 1, since it is a dependency.
- Added devm helpers (like we did for Regulator<T>)
- Fixed missing clk_put() call in Drop (Danilo)
- Fixed missing parenthesis and wrong docs (Viresh)
- Removed extra "dev" parameter from "shutdown" example (Danilo)
- Removed useless type annotation from example (Danilo)
- Link to v1: https://lore.kernel.org/rust-for-linux/20250729-clk-type-state-v1-1-896b53816f7b@collabora.com/#r

---
Alice Ryhl (1):
      rust: clk: implement Send and Sync

Daniel Almeida (1):
      rust: clk: use the type-state pattern

 drivers/cpufreq/rcpufreq_dt.rs |   2 +-
 rust/kernel/clk.rs             | 405 ++++++++++++++++++++++++++++-------------
 rust/kernel/cpufreq.rs         |   8 +-
 3 files changed, 283 insertions(+), 132 deletions(-)
---
base-commit: 76eeb9b8de9880ca38696b2fb56ac45ac0a25c6c
change-id: 20250909-clk-type-state-c01aa7dd551d

Best regards,
-- 
Daniel Almeida <daniel.almeida@collabora.com>