Skip to content

Do not restrict "weak authority" option to Android - #925

Closed
tormodvolden wants to merge 1 commit into
libusb:masterfrom
tormodvolden:weak_authority
Closed

tormodvolden wants to merge 1 commit into
libusb:masterfrom
tormodvolden:weak_authority

Conversation

@tormodvolden

Copy link
Copy Markdown
Contributor

libusb_wrap_sys_device() is an often needed feature on Android, but can
also be very convenient on other Linux platforms.

In many cases the initial device scanning is not needed and
LIBUSB_OPTION_WEAK_AUTHORITY thus provides a performance enhancement.

Signed-off-by: Tormod Volden [email protected]

libusb_wrap_sys_device() is an often needed feature on Android, but can
also be very convenient on other Linux platforms.

In many cases the initial device scanning is not needed and
LIBUSB_OPTION_WEAK_AUTHORITY thus provides a performance enhancement.

Signed-off-by: Tormod Volden <[email protected]>
@tormodvolden

Copy link
Copy Markdown
Contributor Author

My own use case for libusb_wrap_sys_device() is using udev rules to create device node aliases that includes the serial number of the devices. Since libusb cannot filter on serial numbers without opening each device and querying the serial number, this is how I avoid a lot of device communication. With the proposed change I can avoid point-less enumeration and further save execution time. My program which simply sends a vendor-specific control transfer to a given device is now 3 times faster (full execution measured with the shell builtin "time").

@mcuee mcuee added the linux label Jun 8, 2021
@mcuee

mcuee commented Jun 8, 2021

Copy link
Copy Markdown
Member

Looks fine to me.

@mcuee mcuee mentioned this pull request Jun 8, 2021
@LudovicRousseau

Copy link
Copy Markdown
Member

I may also benefit from this.
In my case I used libudev for hotplug. I have to rescan the USB bug with libusb to find the device again.
Using libusb_wrap_sys_device() on GNU/Linux would simplify the code (and make it faster).

@tormodvolden

Copy link
Copy Markdown
Contributor Author

IMO the name of the option is obscure, and with extended use it becomes awkward. It reflects the original motivation for one use-case but not what the option does. We should maybe add a new option, e.g. LIBUSB_OPTION_NO_ENUMERATION, and unless there are plans for having LIBUSB_OPTION_WEAK_AUTHORITY do more than this, let the latter die rather sooner than later.

@mcuee

mcuee commented Jun 8, 2021 •

Copy link
Copy Markdown
Member

@tormodvolden So what is your suggestion? LIBUSB_OPTION_NO_ENUMERATION sounds an interesting name. One possibility is take this pull request in 1.0.25, then we can come out with a better one in the next release.

Or we just do not take this pull request, then you can create another pull request for LIBUSB_OPTION_NO_ENUMERATION.

@mcuee

mcuee commented Jun 8, 2021 •

Copy link
Copy Markdown
Member

@LudovicRousseau @hjelmn Please comment we should take this in 1.0.25 or not.

@tormodvolden

Copy link
Copy Markdown
Contributor Author

I can create another pull request for LIBUSB_OPTION_NO_ENUMERATION but probably not before next week. Ideally it should be included in 1.0.25 as well, to avoid further adoption of the old option, which should be marked as obsolete unless it will be extended to do something else.

@mcuee

mcuee commented Jun 8, 2021

Copy link
Copy Markdown
Member

@tormodvolden No problem, take your time.

@LudovicRousseau

Copy link
Copy Markdown
Member

I also prefer the name LIBUSB_OPTION_NO_ENUMERATION as it is more explicit.

LIBUSB_OPTION_WEAK_AUTHORITY was introduced in the previous libusb version: 1.0.24.
We can add LIBUSB_OPTION_NO_ENUMERATION with the same value and deprecate LIBUSB_OPTION_WEAK_AUTHORITY to not break the API.

@hjelmn

hjelmn commented Jun 11, 2021

Copy link
Copy Markdown
Member

@LudovicRousseau Sounds good to me. @tormodvolden Let me know when you have made that change and I will merge this.

@tormodvolden

Copy link
Copy Markdown
Contributor Author

My thought was that this can go in anyway, but renaming and obsoleting the old is something I will look at in the weekend.

Comment thread libusb/libusb.h
* and used together with libusb_wrap_sys_device().
*
* Only valid for Android builds.
* Only valid on Linux.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"Only valid on Linux and Android."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I kind of think we need to emphasize Android as well.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Andoid uses Linux. No? :-)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, that is true as well. So I just approved the changes.

@hjelmn hjelmn closed this in 5360a17 Jun 11, 2021
@tormodvolden

Copy link
Copy Markdown
Contributor Author

@LudovicRousseau Sounds good to me. @tormodvolden Let me know when you have made that change and I will merge this.

@hjelmn pull request #935

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants