-
Notifications
You must be signed in to change notification settings - Fork 465
rust: add device::Data
.
#570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
5ddd62f
to
f2a7e6f
Compare
Rebased. |
f2a7e6f
to
4bfae74
Compare
Fixed issues reported by bjorn3. PTAL. |
rust/kernel/device.rs
Outdated
regs: RevocableMutex<Reg>, | ||
res: Revocable<Res>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe write these out fully? I initially confused regs for registers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll make this change.
#[doc(hidden)] | ||
#[macro_export] | ||
macro_rules! new_device_data { | ||
($reg:expr, $res:expr, $gen:expr, $name:literal) => {{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
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 [email protected]