[PATCH v3 1/3] rust: clk: use the type-state pattern

Danilo Krummrich dakr at kernel.org
Thu Feb 12 06:01:31 PST 2026


On Thu Feb 12, 2026 at 10:23 AM CET, Danilo Krummrich wrote:
> In particular, I don't think we need an unsafe API until we see a concrete
> example where the proposed safe API does not work (and no other safe API would
> work either).

One additional note for clarification, I'm not saying that I'm against an unsafe
API if it is necessary.

In fact, I have added an unsafe API for drivers myself with the dma::Device
trait [1]. This was not an easy decision and I discussed this back and forth
with a lot of people and, unfortunately, we had to come to the conclusion that
any attempt to make this safe from the Rust side of things would cause
unreasonable overhead and can't be considered an overall improvement.

But as I said, I am convinced that need clear evidence that an unsafe API is
actually needed and that there is no reasonable alternative.

[1] https://rust.docs.kernel.org/kernel/dma/trait.Device.html



More information about the linux-riscv mailing list