Skip to content
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

Keep ownership of spi::DriverRegistration #46

Merged
merged 2 commits into from
May 4, 2021
Merged

Conversation

CohenArthur
Copy link
Member

@CohenArthur CohenArthur commented May 3, 2021

Needs ks0n/linux#4.
Closes #41

@CohenArthur CohenArthur requested review from n1tram1 and Skallwar May 3, 2021 20:27
spi::DriverRegistration::new(&THIS_MODULE, cstr!("mfrc522")).with_probe(mfrc522_probe);
spi.register()?;
spi::DriverRegistration::new_pinned(&THIS_MODULE, cstr!("mfrc522"))?
.with_probe(mfrc522_probe);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we just call .register here ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's why the FIXME is here for now cause I think it's ugly to do spi.as_mut().register().

We have a solution, which helps with cleanliness: remove the builder pattern (which I agree with) and pass all spi methods in the new_pinned function, and register the driver in the new_pinned function (this is what miscdev.rs does). The downside is that the function takes 3 more arguments, which will be None most of the time

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm removing the builder pattern

@CohenArthur CohenArthur requested review from n1tram1 and Skallwar May 4, 2021 13:31
@n1tram1 n1tram1 merged commit 959ca1a into master May 4, 2021
@n1tram1 n1tram1 deleted the keep-spi-ownership branch May 4, 2021 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make spi::DriverRegistration use Pin<> and Sync
3 participants