Get USB Device Class Type and Mount point
Greg KH
greg at kroah.com
Thu Feb 9 07:23:48 EST 2012
On Thu, Feb 09, 2012 at 11:40:16AM +0530, Abhijit Pawar wrote:
> Hi ,
> Is there any way we can get the class type of the attached USB device through
> struct usb_device in a kernel module?
>
> I tried getting the device descriptor and interface descriptor and then use
> them to get the Device and Interface Class and Subclass.
>
> struct usb_device_descriptor *descriptor = &usbDev->descriptor;
>
> struct usb_interface_descriptor *idesc = to_usb_interface(usbDev);
>
> Whenever I run my kernel module, I get 0 for DeviceClass and Interface Class. I
> checked the meaning and it says its the information and to be gathered through
> interface.
That is correct, look at the interface pointer given to your driver.
> Am I missing something here? What I want is to get the mount point / device
> path of the USB devices. Like for Storage Device I would like to get its mount
> path and for HID I would like to get its device path.
Both of those things make no sense within the kernel, and you will not
be able to detect them from your driver, especially as it is not your
driver bound to this type of device, the in-kernel drivers are. Also,
these have nothing to do with the class type of a device's interface.
What are you trying to solve here that you feel you need this
information that is easily found from userspace?
greg k-h
More information about the Kernelnewbies
mailing list