rust: add device::Data.#570
Conversation
5ddd62f to
f2a7e6f
Compare
|
Rebased. |
f2a7e6f to
4bfae74
Compare
|
Fixed issues reported by bjorn3. PTAL. |
| regs: RevocableMutex<Reg>, | ||
| res: Revocable<Res>, |
There was a problem hiding this comment.
Maybe write these out fully? I initially confused regs for registers.
| #[doc(hidden)] | ||
| #[macro_export] | ||
| macro_rules! new_device_data { | ||
| ($reg:expr, $res:expr, $gen:expr, $name:literal) => {{ |
There was a problem hiding this comment.
I think there is the potential for people to mess up the order of the fields. Maybe do
let data = new_device_data! {
registration: reg,
resource: res,
general: gen,
name: "foo",
};? With a potential shorthand when the variable name matches the field name just like with struct.
There was a problem hiding this comment.
The types are different and need to be spelled out elsewhere (as opposed to being inferred) because this is usually the Data type of a Driver trait. Here's an example of it being used: https://github.com/Rust-for-Linux/linux/pull/571/files#diff-0b4ec144d8f0479a497eca5a2e4ab8c1009b0debcdb00ece09f79e5baa8faac9R272
IOW, if people mess up the order, they'll get a compilation error.
|
All unsafe code LGTM. |
This allows access to registrations and io resources to be automatically revoked when devices are removed, even if the ref count to their state is non-zero. This is the last piece needed by the PL061 driver. Signed-off-by: Wedson Almeida Filho <wedsonaf@google.com>
4bfae74 to
9d7d482
Compare
This allows access to registrations and io resources to be automatically
revoked when devices are removed, even if the ref count to their state
is non-zero.
This is the last piece needed by the PL061 driver.
Signed-off-by: Wedson Almeida Filho wedsonaf@google.com