kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: greg@kroah.com (Greg KH)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Get USB Device Class Type and Mount point
Date: Thu, 9 Feb 2012 06:47:17 -0800	[thread overview]
Message-ID: <20120209144717.GA19643@kroah.com> (raw)
In-Reply-To: <4F33CEC5.7000900@gmail.com>

On Thu, Feb 09, 2012 at 07:18:53PM +0530, Abhijit Pawar wrote:
> Hi Greg,
> On 02/09/2012 05:53 PM, Greg KH wrote:
> >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.
> Yes. As I am dealing with USB Core, I am not in  a position to get
> the interface directly. However I checked the
> usb_dump_interface_descriptor( ) from usb/core/devices.c and it
> gives the interface class ( 8 for Storage) correctly.
> Isnt it forwared to my module which is relying on the linux usb
> notifier chain? This chain gives me the device pointer and I am
> trying to enumerate its interface to know its class.

Ah, I thought you were a "real" driver.  Yes, just enumerate the
interfaces of the device.

Have a pointer to your code anywhere?

> >What are you trying to solve here that you feel you need this
> >information that is easily found from userspace?
> I am trying to use USB notifier chains to get the device details and
> then find out its mount path ( in case of Storage).  Are you saying
> that I should be looking into sysFS and udev rules for getting this
> mount path?

I'm saying you shouldn't be doing any of this from within the kernel at
all, as again, it can be trivially found from userspace today with no
kernel changes needed.

Step back again, what is the problem you are trying to solve?

greg k-h

  reply	other threads:[~2012-02-09 14:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-09  6:10 Get USB Device Class Type and Mount point Abhijit Pawar
2012-02-09  6:22 ` Abhijit Pawar
2012-02-09 12:23 ` Greg KH
2012-02-09 13:48   ` Abhijit Pawar
2012-02-09 14:47     ` Greg KH [this message]
2012-02-10 13:49       ` Abhijit Pawar
2012-02-10 14:12         ` Greg KH
2012-02-13 12:14       ` Abhijit Pawar
2012-02-13 12:21         ` Mandeep Sandhu
2012-02-13 12:31           ` Abhijit Pawar
2012-02-13 15:02         ` Greg KH
2012-02-14 11:38           ` Abhijit Pawar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120209144717.GA19643@kroah.com \
    --to=greg@kroah.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).