Page MenuHomeFreeBSD

libusb: implement `libusb_get_parent`
Needs ReviewPublic

Authored by obiwac_gmail.com on Oct 7 2024, 5:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 26, 11:52 PM
Unknown Object (File)
Wed, Dec 11, 4:49 AM
Unknown Object (File)
Dec 9 2024, 5:51 AM
Unknown Object (File)
Dec 3 2024, 2:46 PM
Unknown Object (File)
Dec 3 2024, 2:23 PM
Unknown Object (File)
Nov 28 2024, 1:58 PM
Unknown Object (File)
Nov 21 2024, 12:26 PM
Unknown Object (File)
Nov 18 2024, 7:52 AM

Details

Reviewers
danfe
kevans
Group Reviewers
USB
Summary

Newer versions of drivers such as libwacom (graphics tablets) or libfprint (fingerprint scanners) call g_usb_device_get_parent. This in turn calls libusb_get_parent on platforms which implement it, and returns NULL on platforms that don't. This patch implements this function on FreeBSD.

Test Plan

Tried different combinations of different devices connected to different hubs and it all seems to work. Tried on the AMD Framework 13. Used an ad-hoc program to test this but I'd eventually like to add a tree view kind of thing to usbconfig like in lsusb.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 61612
Build 58496: arc lint + arc unit

Event Timeline

kevans added a subscriber: kevans.

Implementation wise, this looks fine to me. Can you update libusb.3 as well and document this, maybe right around libusb_get_device, please?

  • libusb.3: add libusb_get_parent
  • libusb.3: add libusb_get_parent
lib/libusb/libusb.3
227

Boy Scout Rule - It seems many functions are all listed under "LIBRARY INITIALISATION / DEINITIALISATION" while they better be under their own section.

I would say at least align them with libusb.h.

lib/libusb/libusb10.c
6

This one is just a question being curious, I see your name added here but not in the other header files. Is this intentional or a mistake ?

Add missing section header in libusb.3 manpage

lib/libusb/libusb.3
227

Good catch!

lib/libusb/libusb10.c
6

I never really know what amount of code changes warrants adding my name to the copyright header, and I assumed that just adding a prototype in a header or adding a small manpage entry didn't qualify :)

markmi_dsl-only.net added inline comments.
lib/libusb/libusb10.h
129

monwarez on Discord wrote: "this seems to change the ABI of the struct, does running without relinking work ?" but no specific text was indicated for what "this" is to refer to.

So: I assume that is for the above addition to the middle of the libusb_device struct.

It would appear to change the Binary Interface involved for at least all the functions that have a parameter like (for example):

libusb_device * dev

Note: I've not analyzed anything signficant. I'm just trying to make the monwarez note part of the review.

lib/libusb/libusb10.h
129

libusb_device is opaque to the application, the size/layout is never exposed.