LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 06-20-2014, 12:28 AM   #1
amenita
LQ Newbie
 
Registered: Jun 2014
Posts: 2

Rep: Reputation: Disabled
Unhappy How to find USB device by product ID and vendor ID in kernel space?


Hello All,

I want to know how to find USB device information by product ID and Vendor ID in kernel space.
Just want to refer the device information(*), do not need to write data using the resource.
transfer the data using libftdi driver instead, so can not use MODULE_DEVICE_TABLE to call probe().

(*) should be.. struct device or struct usb_interface or struct usb_device

kernel: 3.2.0-35-generic-pae

thanx
 
Old 06-20-2014, 08:31 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 5,936
Blog Entries: 12

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
Depending on when you need to accesss it, my first answer is "Same way you'd find it in the user space".

The /sys tree hierarchy contains all this information, typically in the uevent file once you find the correct sub-directory for that specific USB technology type. One example:

Code:
# ls /sys/class/tty
/dev/ttyACM0
# cat /sys/class/tty/ttyACM0/device/uevent 
DEVTYPE=usb_interface
DRIVER=cdc_acm
PRODUCT=2047/854/1366
TYPE=2/0/0
INTERFACE=2/2/1
MODALIAS=usb:v2047p0854d1366dc02dsc00dp00ic02isc02ip01
You break the PRODUCT string down into VendorID, DeviceID, and (I believe) Serial Number

However this means that my CDC-ACM driver has loaded. If you're looking to detect a device prior to a common kernel driver detecting it and installing it as a device to your system, then sorry, beyond this level of recommendation.

Obviously there's a way to detect any USB device and therefore if you need to do it in the same manner as the USB driver, then I'd look at the source, http://www.linux-usb.org/ and here's some reference material on how the driver works http://www.opensourceforu.com/2011/1...rs-in-linux-1/.

Last edited by rtmistler; 06-20-2014 at 08:36 AM.
 
Old 06-22-2014, 08:49 PM   #3
amenita
LQ Newbie
 
Registered: Jun 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
hi
thanks for the reply.

exactly i need to access it prior to a common kernel driver detecting it and installing it as a device.
i will look the source a little more.
thanks for the information!
 
Old 06-23-2014, 01:25 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,669
Blog Entries: 4

Rep: Reputation: 3019Reputation: 3019Reputation: 3019Reputation: 3019Reputation: 3019Reputation: 3019Reputation: 3019Reputation: 3019Reputation: 3019Reputation: 3019Reputation: 3019
That's what "hotplug" is all about. (There's also a "coldplug.")
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
udev not reporting USB vendor or product ID FLLinux Slackware 2 09-09-2009 12:48 PM
How to apply a vendor ID for USB device on fedora linux alchen1999 Programming 1 01-06-2009 12:43 PM
How to apply a vendor ID for USB device on fedora linux alchen1999 Linux - General 1 01-06-2009 12:41 PM
how can i see the vendor and product id of webcam Misbah Naveed Linux - Newbie 1 06-04-2008 07:44 AM
how do i manually load a device with known vendor and product IDs to devices? pyenos Linux - Hardware 0 03-01-2005 11:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 03:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration