Re: [TECH TOPIC] Rust for Linux

Miguel Ojeda
2021-07-19T17:55:07Z

On Mon, Jul 19, 2021 at 7:45 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> However, the offset given is not a compile-time constant here, thus
> the runtime-check is used. Or we could provide an `unsafe fn` which
> means the caller would be responsible to guarantee the precondition.
> But see next point.

To clarify, by offset here I mean the actual offset passed to the
function, i.e. the second parameter `woffset` (notice the `w`), not
`offset` in the value parameter:

pl061.base.try_writeb((value as u8) << offset, woffset)?;

> (Actually, from a quick look, there are 3 or so `try_*()` that could
> be using the non-`try_*()` version)

e.g.

let _ = pl061.base.try_writeb(gpioie, GPIOIE);

could be:

pl061.base.writeb(gpioie, GPIOIE);

because `GPIOIE` is known at compile-time (vs. the ones with `woffset`).

Cheers,
Miguel