Seeking Assistance: Implementing USB Device Suspend/Resume in User Space Driver

Alan Stern stern at rowland.harvard.edu
Mon May 13 14:09:24 EDT 2024


On Mon, May 13, 2024 at 11:14:44PM +0530, Muni Sekhar wrote:
> In the context of the Linux kernel and USB devices, what are the
> similarities and differences between usbfs and sysfs?

They are totally different.  usbfs gives you direct communication with 
the various USB devices on your system.  sysfs presents interfaces for 
monitoring and controlling your entire system (including information 
about how it manages its USB devices) but doesn't provide a way to 
communicate with the devices.

> Before invoking the ioctl() system call, we need to obtain a file
> descriptor by invoking the open() system call. How do we identify the
> device node in the usbfs interface?
> For example, can you please explain how to identify the device node
> location of a Human Interface Device(shown below in lsusb -t output)
> as the first argument in the open() system call.
> 
> $ lsusb -t
> /:  Bus 001.Port 001: Dev 001, Class=root_hub, Driver=uhci_hcd/2p, 12M
> /:  Bus 002.Port 001: Dev 001, Class=root_hub, Driver=ehci-pci/3p, 480M
>     |__ Port 001: Dev 002, If 0, Class=Hub, Driver=hub/8p, 480M
> /:  Bus 003.Port 001: Dev 001, Class=root_hub, Driver=ehci-pci/4p, 480M
> /:  Bus 004.Port 001: Dev 001, Class=root_hub, Driver=ehci-pci/3p, 480M
>     |__ Port 001: Dev 002, If 0, Class=Hub, Driver=hub/6p, 480M
>         |__ Port 002: Dev 003, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
> /:  Bus 005.Port 001: Dev 001, Class=root_hub, Driver=uhci_hcd/2p, 12M
> /:  Bus 006.Port 001: Dev 001, Class=root_hub, Driver=xhci_hcd/15p, 480M
> /:  Bus 007.Port 001: Dev 001, Class=root_hub, Driver=xhci_hcd/6p, 5000M

The Human Interface Device is Device 003 on Bus 004.  Therefore the 
device node is /dev/bus/usb/004/003.

Alan Stern



More information about the Kernelnewbies mailing list