-
Notifications
You must be signed in to change notification settings - Fork 133
Add a DetachKernelDriver wrapper #136
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
base: master
Are you sure you want to change the base?
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
I think this is generally fine, but I'm curious about the use case. Please update the PR description. gofmt has something to say about your changes; see the test failures. |
|
The library already has a function to detach all drivers from a device upon opening it, but sometimes you might only want to detach the driver from only one interface, like in my case, using go-ncm on one specific interface of the phone but still leave the previous usbmuxer do its job managing the other ones. |
|
|
||
| // DetachKernelDriver detaches the driver currently attached to the given | ||
| // interface. | ||
| func (d *Device) DetachKernelDriver(ifNumber int) error { |
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 this should be on the Configuration rather than the Device? Once a Device is opened, you would need to select a configuration before you know what interfaces are available.
|
I'm wondering if there could be a universal approach to detaching kernel drivers. Right now the API is mixing two approaches:
And the implementation is also inconsistent, since calling Device.SetAutoDetach affects two things:
It would be nice to have a consistent approach. I would lean towards disabling autodetach and preferring explicit DetachKernelDriver(int) and DetachKernelDriverAll() on the configuration. An alternative would be to add Configuration.SetAutoDetach(), which would auto-detach on claimed interface, like Device.SetAutoDetach() auto-detaches on all interfaces of a configuration. Or both. I don't know. Calling @stapelberg for a gut feeling check. |
It’s been years since I last worked with USB APIs 😅 I don’t think my gut tells me anything on these questions, sorry. |
Allows the library user to detach kernel drivers only for specific interfaces, which is useful when handling only a part of a more complex device.