rust: Add basic clock abstractions
Subsystems (2)
v4 cover rust: Add basic clock abstractions
Hello,
This adds initial abstractions for the clk APIs. These provide the minimal functionality needed for common use cases, making them straightforward to introduce in the first iteration.
These will be used by Rust based cpufreq / OPP layers to begin with.
For now I have added them under the maintainership umbrella of the common clk framework, please let me know if I should do it differently.
If possible, I would like to get these merged via the PM tree along with cpufreq/OPP abstractions, but its okay otherwise too.
Miguel: I have dropped the changes related to a Guard implementation for clk APIs as the discussion wasn't conclusive enough. Maybe we can tackle that later if required.
--
Viresh
V3->V4:
- Enable clk abstractions only for cfg(CONFIG_COMMON_CLK) (Stephen Boyd).
- New struct implementation of Hertz.
- Added examples for all the structures.
- Make methods inline.
- Improved comments, Invariants, INVARIANT, SAFETY sections / comments, use intra-doc links.
- Other minor improvements.
V2->V3:
- Add type Hertz (Daniel Almeida).
- Improved comments in helpers.rs (Daniel Almeida).
- s/Clk::new/Clk::get/ (Daniel Almeida).
- Implement OptionalClk as well (Rob Herring).
- Fix Safety comments (Danilo Krummrich).
- Add tags from Daniel Almeida.
V1->V2:
- Post this as an independent series.
- Include more APIs, apart from clk_get() and clk_put().
Viresh Kumar (2):
rust: Add clk helpers
rust: Add initial clk abstractions
MAINTAINERS | 2 + rust/bindings/bindings_helper.h | 1 + rust/helpers/clk.c | 66 +++++++ rust/helpers/helpers.c | 1 + rust/kernel/clk.rs | 304 ++++++++++++++++++++++++++++++++ rust/kernel/lib.rs | 2 + 6 files changed, 376 insertions(+) create mode 100644 rust/helpers/clk.c create mode 100644 rust/kernel/clk.rs
Signature · 1 line
2.31.1.272.g89b43f80a514
PATCH v4 1/2 rust: Add clk helpers
Non-trivial C macros and inlined C functions cannot be used directly in the Rust code and are used via functions ("helpers") that wrap those so that they can be called from Rust.
In order to prepare for adding Rust abstractions for the clock APIs, add clock helpers required by the Rust implementation.
--- MAINTAINERS | 1 + rust/bindings/bindings_helper.h | 1 + rust/helpers/clk.c | 66 +++++++++++++++++++++++++++++++++ rust/helpers/helpers.c | 1 + 4 files changed, 69 insertions(+) create mode 100644 rust/helpers/clk.c
MAINTAINERS +1 -0
@@ -5778,6 +5778,7 @@ F: include/dt-bindings/clock/ F: include/linux/clk-pr* F: include/linux/clk/ F: include/linux/of_clk.h +F: rust/helpers/clk.c X: drivers/clk/clkdev.c COMMON INTERNET FILE SYSTEM CLIENT (CIFS and SMB3)
rust/bindings/bindings_helper.h +1 -0
@@ -10,6 +10,7 @@#include <linux/blk-mq.h> #include <linux/blk_types.h> #include <linux/blkdev.h> +#include <linux/clk.h> #include <linux/cred.h> #include <linux/errname.h> #include <linux/ethtool.h>
rust/helpers/clk.c new file +66 -0
66 lines not on this page · raw message
rust/helpers/helpers.c +1 -0
@@ -11,6 +11,7 @@#include "bug.c" #include "build_assert.c" #include "build_bug.c" +#include "clk.c" #include "cred.c" #include "device.c" #include "err.c"
Signature · 1 line
2.31.1.272.g89b43f80a514
PATCH v4 2/2 rust: Add initial clk abstractions
In reply to Viresh KumarAdd initial abstractions for the clk APIs. These provide the minimal functionality needed for common use cases, making them straightforward to introduce in the first iteration.
These will be used by Rust based cpufreq / OPP layers to begin with.
--- MAINTAINERS | 1 + rust/kernel/clk.rs | 304 +++++++++++++++++++++++++++++++++++++++++++++ rust/kernel/lib.rs | 2 + 3 files changed, 307 insertions(+) create mode 100644 rust/kernel/clk.rs
MAINTAINERS +1 -0
@@ -5779,6 +5779,7 @@ F: include/linux/clk-pr* F: include/linux/clk/ F: include/linux/of_clk.h F: rust/helpers/clk.c +F: rust/kernel/clk.rs X: drivers/clk/clkdev.c COMMON INTERNET FILE SYSTEM CLIENT (CIFS and SMB3)
rust/kernel/clk.rs new file +304 -0
304 lines not on this page · raw message
rust/kernel/lib.rs +2 -0
@@ -40,6 +40,8 @@pub mod block;#[doc(hidden)] pub mod build_assert; +#[cfg( CONFIG_COMMON_CLK )] +pub mod clk;pub mod cred;pub mod device;pub mod device_id;
Signature · 1 line
2.31.1.272.g89b43f80a514