Character device interface for USB device drivers - linux-kernel

In Kernel USB subsystem is registering chardevices using "usb_major_init()" and "usb_devio_init()" functions.
How these character device drivers linked to the actual USB drivers registered using "usb_register_driver" and "usb_register_device_driver" functions in the kernel source?

Related

Linux: look for USB "client" driver example

I want to write a USB communication driver for Embedded Linux device. The embedded Linux device connects to the Linux PC as a device.
So, I'm going to write two USB drivers, one for Linux PC and one for embedded Linux device.
I can refer to USB-skeleton.c for drivers on Linux PC, but is there a reference code for drivers on embedded Linux device?

NVMe PCIe Hard Disk on Freescale LS2080A not recognised

I have a Freescale LS2080 box for which I am developing a custom linux 4.1.8 kernel using the Freescale Yocto project.
I have an NVMe hard disk attached to the LS2080 via a PCIe card, but the disk is not recognised when I boot up the board with my custom linux kernel.
I plugged the same combination of NVMe disk and PCIe card into a linux 3.16.7 desktop PC and it was detected and mounted without problem.
When building the LS2080 kernel using the Yocto project, I have enabled the NVMe block device driver and I have verified that this module is present in the kernel when booting on the board.
The PCIe slot on the board is working fine because I have tried it with a PCIe Ethernet card and a PCIe SATA disk.
I suspect that I am missing something in the kernel configuration or device tree, but I'm not sure what. When I add the NVMe driver to the kernel using menuconfig, the NVMe driver dependencies are supposed to be resolved.
Can anyone provide insight into what I am missing?
First make sure that PCIe device is recognized using lspci.
If device is not shown in lspci list this is enumeration problem, to check the error use PCIe analyzers.
If the device is shown in the list then simply add the device vendor id and device ID to NVMe driver and recompile to load the driver for your device.

How to do USB mode switch on Windows

I am working on LTE USB modem driver installation.
While plugin USB device it detect as CD-ROM and we need to switch it to USB modem before installing windows modem driver on the device.
How does one go about executing a USB switch mode on Windows?.
I found it can be done using DeviceIOControl() IOCTL_SCSI_PASS_THROUGH_DIRECT. But I am unclear as to what values need to passed in struct SCSI_PASS_THROUGH_DIRECT.
Is there any other method to do USB mode switch ?
Otherwise, what values need to pass in scsi ioctl?

How to identify USB device is a mass storage device on Mac OSX?

How to identify a device connected on USB port is a mass storage device with the help of Mac OSX IO Kit library? Lets an example USB keyboard and USB flash drive is connected on Mac OSX system. How can i differentiate ONLY the mass storage USB device?
You can access the IOService node (IOMedia object) corresponding to a specific disk using the Disk Arbitration framework's DADiskCopyIOMedia function. You can walk up the IOService tree to your IOUSBInterface/IOUSBDevice from there.
Alternatively, you can use I/O Kit matching to find all USB mass storage or USB attached SCSI (UAS) nodes in the system by their IOKit classes. Similarly for keyboards (they are part of the I/O Kit's HID family).
I suggest taking a look at the IOService tree of your system in IORegistryExplorer.

Use of xHCI driver and USB_STORAGE driver

I'm currently learning driver programming and am at very nascent stage. I'm unable to get the difference of use of xHCI, EHCI, or OHCI drivers and usb_storage.
When I plug my USB device (pen drive) and observe dmesg output, it says that my device is using the ehci driver, but my device stops working when I rmmod usb_storage.
There are many drivers for different kind of USB devices let it be mouse, keyboard, camera, etc.
As of now, I assume that the xHCI driver is for USB host and the other driver is for the device we connect to our USB host. Am I correct? If not, what is the explanation?
*HCI are specifications of USB hosts:
xHCI - for USB 3.0
EHCI - for USB 2.0
OHCI and UHCI - for USB 1.x
usb_storage is a upper level driver working on the USB host side, and it is responsible for communication only with USB storage devices, not keyboard, mouse, etc.
The USB is maintained in form of a stack and *hci drivers are the lowest level in that stack. usb-storage and other drivers are located on a higher level of this stack.

Resources