-
Notifications
You must be signed in to change notification settings - Fork 438
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
Simple Rust driver that touches real hardware: PR 3/6 #301
Conversation
Add the `PlatformDriver` trait, which driver writers may implement in order to define a platform driver in the kernel. For sake of simplicity and ease of review, `PlatformDriver` consists of two functions for now - `probe()` and `remove()`. Signed-off-by: Sven Van Asbroeck <thesven73@gmail.com>
Implement this in the simplest possible way: by printing a `pr_info` log message on `probe()`/`remove()`. Signed-off-by: Sven Van Asbroeck <thesven73@gmail.com>
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.
Is it right that follow up PRs will allow probe
to return state?
Absolutely! That will happen in the DrvData step. |
This PR should be relatively straightforward, to give everyone involved a well-deserved break :) |
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.
Excellent :-)
That was quick ! Thank you !! 💯 |
|
||
/// Trait for implementers of platform drivers. | ||
/// | ||
/// Implement this trait whenever you create a platform driver. |
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.
Super nit: here you're using the imperative mode "Implement this [...]" while in the functions below you use the indicative mode "Implementers should attempt [...]".
I think we should be consistent and use the same structure in both cases. Personally, I favor the indicative because we are providing information to the reader, not giving them orders. (Though admittedly opinions vary here.)
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.
Agreed ! And these are probably more important than super-nits. Please do provide that info, so I can improve my "internal algorithm".
struct RngDriver; | ||
|
||
impl PlatformDriver for RngDriver { | ||
fn probe(device_id: i32) -> Result { |
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.
Is it correct to assume that we'll eventually provide more information than device_id
?
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.
Absolutely!! device_id
is just a placeholder. Watch this space :)
Simple Rust driver that touches real h/w: step 3 of 6
@alex and @ojeda suggested that #254 should be split into smaller PRs, so they can be reviewed and merged individually.
Roadmap: