/sys/bus/usb/devices下的文件命名
2016-01-13 11:17
232 查看
/sys/bus/usb/devices下的文件命名:
root@Four-Faith:/sys/bus/usb/devices# ls -l
lrwxrwxrwx 1 root root 0 Jan 1 1970 1-0:1.0 -> ../../../devices/platform/xhc_mtk/usb1/1-0:1.0
lrwxrwxrwx 1 root root 0 Jan 8 23:27 1-2 -> ../../../devices/platform/xhc_mtk/usb1/1-2
lrwxrwxrwx 1 root root 0 Jan 8 23:28 1-2:1.0 -> ../../../devices/platform/xhc_mtk/usb1/1-2/1-2:1.0
lrwxrwxrwx 1 root root 0 Jan 8 23:28 1-2:1.1 -> ../../../devices/platform/xhc_mtk/usb1/1-2/1-2:1.1
lrwxrwxrwx 1 root root 0 Jan 8 23:27 1-2:1.2 -> ../../../devices/platform/xhc_mtk/usb1/1-2/1-2:1.2
lrwxrwxrwx 1 root root 0 Jan 8 23:28 1-2:1.3 -> ../../../devices/platform/xhc_mtk/usb1/1-2/1-2:1.3
lrwxrwxrwx 1 root root 0 Jan 8 23:28 1-2:1.4 -> ../../../devices/platform/xhc_mtk/usb1/1-2/1-2:1.4
lrwxrwxrwx 1 root root 0 Jan 8 23:28 1-2:1.5 -> ../../../devices/platform/xhc_mtk/usb1/1-2/1-2:1.5
lrwxrwxrwx 1 root root 0 Jan 1 1970 2-0:1.0 -> ../../../devices/platform/xhc_mtk/usb2/2-0:1.0
lrwxrwxrwx 1 root root 0 Jan 1 1970 usb1 -> ../../../devices/platform/xhc_mtk/usb1
lrwxrwxrwx 1 root root 0 Jan 1 1970 usb2 -> ../../../devices/platform/xhc_mtk/usb2
如上可知:/sys/bus/usb/devices都是实际指向/sys/devices/platform/下的文件,文件的命名是根据USB命名的规则,比如:
/sys/bus/usb/devices/usb1,usb2表示表示两个usb hub,是root bug,usb1/内有属于usb bug device的一些属性,可以看一下:
root@Four-Faith:/sys/devices/platform/xhc_mtk/usb1# ls
1-0:1.0 bcdDevice maxchild
1-2 bmAttributes product
authorized busnum quirks
authorized_default configuration remove
avoid_reset_quirk descriptors serial
bConfigurationValue dev speed
bDeviceClass devnum subsystem
bDeviceProtocol devpath uevent
bDeviceSubClass driver urbnum
bMaxPacketSize0 ep_00 usb_device
bMaxPower idProduct version
bNumConfigurations idVendor
bNumInterfaces manufacturer
一个hub也是一个usb decice,因此一个usb device ,直接引用include/linux/usb/ch9.h中的定义是:(+表示在该目录下存在)
这些字段在这里都包括了,但是在什么地方体现这个device 是hub呢??
cat bDeviceClass显示9,在ch9.h中定义:
hub当然还是一个hub device,它具有普通usb device没有的一些性质, struct usb_hub_descriptor,但这些信息没有在sysfs中显示,可能是一个普通用户不需要知道hub的信息吧,所以内核开发者没有在sysfs中显示
**************以上是device(或者是USB hub)级别的信息,一个usb device有1个或多个interface.下面开始讲interface
1-0:1.0就是interface的目录,表示root hub1-port0上的configuration1的interface0,
命名规则是:roothub-port:configuration.interface.
看看1-0:1.0目录下的内容:
root@Four-Faith:/sys/devices/platform/xhc_mtk/usb1/1-0:1.0# ls
bAlternateSetting bInterfaceSubClass modalias
bInterfaceClass bNumEndpoints subsystem
bInterfaceNumber driver supports_autosuspend
bInterfaceProtocol ep_81 uevent
其实1-0:1.0是usb hub1自己占有的,在没有接入任何usb设备的时候,1-0:1.0都存在并且可以在usb1中找到,在用户接入USB设备之后并且该设备挂载在ubs
hug1下,那么就会在usb1下多出1-2/目录,打开看:
drwxr-xr-x
5 root root 0 Jan 9 13:46 1-2:1.0
drwxr-xr-x 6 root root 0 Jan 9 13:46 1-2:1.1
drwxr-xr-x 6 root root 0 Jan 9 13:45 1-2:1.2
drwxr-xr-x 6 root root 0 Jan 9 13:46 1-2:1.3
drwxr-xr-x 6 root root 0 Jan 9 13:46 1-2:1.4
drwxr-xr-x 5 root root 0 Jan 9 13:46 1-2:1.5
-rw-r--r-- 1 root root 4096 Jan 9 13:46 authorized
-rw-r--r-- 1 root root 4096 Jan 9 13:46 avoid_reset_quirk
-rw-r--r-- 1 root root 4096 Jan 9 13:46 bConfigurationValue
-r--r--r-- 1 root root 4096 Jan 9 13:46 bDeviceClass
-r--r--r-- 1 root root 4096 Jan 9 13:46 bDeviceProtocol
-r--r--r-- 1 root root 4096 Jan 9 13:46 bDeviceSubClass
-r--r--r-- 1 root root 4096 Jan 9 13:46 bMaxPacketSize0
-r--r--r-- 1 root root 4096 Jan 9 13:46 bMaxPower
-r--r--r-- 1 root root 4096 Jan 9 13:46 bNumConfigurations
-r--r--r-- 1 root root 4096 Jan 9 13:46 bNumInterfaces
-r--r--r-- 1 root root 4096 Jan 9 13:46 bcdDevice
-r--r--r-- 1 root root 4096 Jan 9 13:46 bmAttributes
-r--r--r-- 1 root root 4096 Jan 9 13:46 busnum
-r--r--r-- 1 root root 4096 Jan 9 13:46 configuration
-r--r--r-- 1 root root 65553 Jan 9 13:46 descriptors
-r--r--r-- 1 root root 4096 Jan 9 13:46 dev
-r--r--r-- 1 root root 4096 Jan 9 13:46 devnum
-r--r--r-- 1 root root 4096 Jan 9 13:46 devpath
lrwxrwxrwx 1 root root 0 Jan 9 13:46 driver -> ../../../../../bus/usb/drivers/usb
drwxr-xr-x 2 root root 0 Jan 9 13:46 ep_00
-r--r--r-- 1 root root 4096 Jan 9 13:45 idProduct
-r--r--r-- 1 root root 4096 Jan 9 13:45 idVendor
-r--r--r-- 1 root root 4096 Jan 9 13:46 manufacturer
-r--r--r-- 1 root root 4096 Jan 9 13:46 maxchild
-r--r--r-- 1 root root 4096 Jan 9 13:46 product
-r--r--r-- 1 root root 4096 Jan 9 13:46 quirks
--w------- 1 root root 4096 Jan 9 13:46 remove
-r--r--r-- 1 root root 4096 Jan 9 13:46 serial
-r--r--r-- 1 root root 4096 Jan 9 13:46 speed
lrwxrwxrwx 1 root root 0 Jan 9 13:46 subsystem -> ../../../../../bus/usb
-rw-r--r-- 1 root root 4096 Jan 9 13:46 uevent
-r--r--r-- 1 root root 4096 Jan 9 13:46 urbnum
drwxr-xr-x 3 root root 0 Jan 9 13:46 usb_device
-r--r--r-- 1 root root 4096 Jan 9 13:46 version
会多出如下:
drwxr-xr-x
5 root root 0 Jan 9 13:46 1-2:1.0
drwxr-xr-x 6 root root 0 Jan 9 13:46 1-2:1.1
drwxr-xr-x 6 root root 0 Jan 9 13:45 1-2:1.2
drwxr-xr-x 6 root root 0 Jan 9 13:46 1-2:1.3
drwxr-xr-x 6 root root 0 Jan 9 13:46 1-2:1.4
drwxr-xr-x 5 root root 0 Jan 9 13:46 1-2:1.5
这些就是用户刚刚挂载在ubs1 这个bug下的设备,他们占用usb bub1中port1,configuration都为1,而interface0 - 6都被用户占用,在1-2:1.0可以找到ttyUSB0/,ttyUSB0就是/dev/ttyUSB0相关。我现在挂载在usb hub1上的设备是usb转串口的lte模块,所以名字是ttyUSB*
root@Four-Faith:/sys/bus/usb/devices# ls -l
lrwxrwxrwx 1 root root 0 Jan 1 1970 1-0:1.0 -> ../../../devices/platform/xhc_mtk/usb1/1-0:1.0
lrwxrwxrwx 1 root root 0 Jan 8 23:27 1-2 -> ../../../devices/platform/xhc_mtk/usb1/1-2
lrwxrwxrwx 1 root root 0 Jan 8 23:28 1-2:1.0 -> ../../../devices/platform/xhc_mtk/usb1/1-2/1-2:1.0
lrwxrwxrwx 1 root root 0 Jan 8 23:28 1-2:1.1 -> ../../../devices/platform/xhc_mtk/usb1/1-2/1-2:1.1
lrwxrwxrwx 1 root root 0 Jan 8 23:27 1-2:1.2 -> ../../../devices/platform/xhc_mtk/usb1/1-2/1-2:1.2
lrwxrwxrwx 1 root root 0 Jan 8 23:28 1-2:1.3 -> ../../../devices/platform/xhc_mtk/usb1/1-2/1-2:1.3
lrwxrwxrwx 1 root root 0 Jan 8 23:28 1-2:1.4 -> ../../../devices/platform/xhc_mtk/usb1/1-2/1-2:1.4
lrwxrwxrwx 1 root root 0 Jan 8 23:28 1-2:1.5 -> ../../../devices/platform/xhc_mtk/usb1/1-2/1-2:1.5
lrwxrwxrwx 1 root root 0 Jan 1 1970 2-0:1.0 -> ../../../devices/platform/xhc_mtk/usb2/2-0:1.0
lrwxrwxrwx 1 root root 0 Jan 1 1970 usb1 -> ../../../devices/platform/xhc_mtk/usb1
lrwxrwxrwx 1 root root 0 Jan 1 1970 usb2 -> ../../../devices/platform/xhc_mtk/usb2
如上可知:/sys/bus/usb/devices都是实际指向/sys/devices/platform/下的文件,文件的命名是根据USB命名的规则,比如:
/sys/bus/usb/devices/usb1,usb2表示表示两个usb hub,是root bug,usb1/内有属于usb bug device的一些属性,可以看一下:
root@Four-Faith:/sys/devices/platform/xhc_mtk/usb1# ls
1-0:1.0 bcdDevice maxchild
1-2 bmAttributes product
authorized busnum quirks
authorized_default configuration remove
avoid_reset_quirk descriptors serial
bConfigurationValue dev speed
bDeviceClass devnum subsystem
bDeviceProtocol devpath uevent
bDeviceSubClass driver urbnum
bMaxPacketSize0 ep_00 usb_device
bMaxPower idProduct version
bNumConfigurations idVendor
bNumInterfaces manufacturer
一个hub也是一个usb decice,因此一个usb device ,直接引用include/linux/usb/ch9.h中的定义是:(+表示在该目录下存在)
216 /* USB_DT_DEVICE: Device descriptor */ 217 struct usb_device_descriptor { 218 __u8 bLength; 219 __u8 bDescriptorType; //+descriptors 220 221 __le16 bcdUSB; //+version 222 __u8 bDeviceClass; //+ 223 __u8 bDeviceSubClass; //+ 224 __u8 bDeviceProtocol; //+ 225 __u8 bMaxPacketSize0; //+ 226 __le16 idVendor; //+ 227 __le16 idProduct; //+ 228 __le16 bcdDevice; //+ 229 __u8 iManufacturer; //+manufacturer 230 __u8 iProduct; //+product 231 __u8 iSerialNumber; //+serial 232 __u8 bNumConfigurations; //+ 233 } __attribute__ ((packed)); |
cat bDeviceClass显示9,在ch9.h中定义:
#define USB_CLASS_HUB 9 |
lzj@lzj-laptop:/sys/bus/usb/devices/usb1$ cat bDeviceClass 09 |
**************以上是device(或者是USB hub)级别的信息,一个usb device有1个或多个interface.下面开始讲interface
1-0:1.0就是interface的目录,表示root hub1-port0上的configuration1的interface0,
命名规则是:roothub-port:configuration.interface.
看看1-0:1.0目录下的内容:
root@Four-Faith:/sys/devices/platform/xhc_mtk/usb1/1-0:1.0# ls
bAlternateSetting bInterfaceSubClass modalias
bInterfaceClass bNumEndpoints subsystem
bInterfaceNumber driver supports_autosuspend
bInterfaceProtocol ep_81 uevent
其实1-0:1.0是usb hub1自己占有的,在没有接入任何usb设备的时候,1-0:1.0都存在并且可以在usb1中找到,在用户接入USB设备之后并且该设备挂载在ubs
hug1下,那么就会在usb1下多出1-2/目录,打开看:
drwxr-xr-x
5 root root 0 Jan 9 13:46 1-2:1.0
drwxr-xr-x 6 root root 0 Jan 9 13:46 1-2:1.1
drwxr-xr-x 6 root root 0 Jan 9 13:45 1-2:1.2
drwxr-xr-x 6 root root 0 Jan 9 13:46 1-2:1.3
drwxr-xr-x 6 root root 0 Jan 9 13:46 1-2:1.4
drwxr-xr-x 5 root root 0 Jan 9 13:46 1-2:1.5
-rw-r--r-- 1 root root 4096 Jan 9 13:46 authorized
-rw-r--r-- 1 root root 4096 Jan 9 13:46 avoid_reset_quirk
-rw-r--r-- 1 root root 4096 Jan 9 13:46 bConfigurationValue
-r--r--r-- 1 root root 4096 Jan 9 13:46 bDeviceClass
-r--r--r-- 1 root root 4096 Jan 9 13:46 bDeviceProtocol
-r--r--r-- 1 root root 4096 Jan 9 13:46 bDeviceSubClass
-r--r--r-- 1 root root 4096 Jan 9 13:46 bMaxPacketSize0
-r--r--r-- 1 root root 4096 Jan 9 13:46 bMaxPower
-r--r--r-- 1 root root 4096 Jan 9 13:46 bNumConfigurations
-r--r--r-- 1 root root 4096 Jan 9 13:46 bNumInterfaces
-r--r--r-- 1 root root 4096 Jan 9 13:46 bcdDevice
-r--r--r-- 1 root root 4096 Jan 9 13:46 bmAttributes
-r--r--r-- 1 root root 4096 Jan 9 13:46 busnum
-r--r--r-- 1 root root 4096 Jan 9 13:46 configuration
-r--r--r-- 1 root root 65553 Jan 9 13:46 descriptors
-r--r--r-- 1 root root 4096 Jan 9 13:46 dev
-r--r--r-- 1 root root 4096 Jan 9 13:46 devnum
-r--r--r-- 1 root root 4096 Jan 9 13:46 devpath
lrwxrwxrwx 1 root root 0 Jan 9 13:46 driver -> ../../../../../bus/usb/drivers/usb
drwxr-xr-x 2 root root 0 Jan 9 13:46 ep_00
-r--r--r-- 1 root root 4096 Jan 9 13:45 idProduct
-r--r--r-- 1 root root 4096 Jan 9 13:45 idVendor
-r--r--r-- 1 root root 4096 Jan 9 13:46 manufacturer
-r--r--r-- 1 root root 4096 Jan 9 13:46 maxchild
-r--r--r-- 1 root root 4096 Jan 9 13:46 product
-r--r--r-- 1 root root 4096 Jan 9 13:46 quirks
--w------- 1 root root 4096 Jan 9 13:46 remove
-r--r--r-- 1 root root 4096 Jan 9 13:46 serial
-r--r--r-- 1 root root 4096 Jan 9 13:46 speed
lrwxrwxrwx 1 root root 0 Jan 9 13:46 subsystem -> ../../../../../bus/usb
-rw-r--r-- 1 root root 4096 Jan 9 13:46 uevent
-r--r--r-- 1 root root 4096 Jan 9 13:46 urbnum
drwxr-xr-x 3 root root 0 Jan 9 13:46 usb_device
-r--r--r-- 1 root root 4096 Jan 9 13:46 version
会多出如下:
drwxr-xr-x
5 root root 0 Jan 9 13:46 1-2:1.0
drwxr-xr-x 6 root root 0 Jan 9 13:46 1-2:1.1
drwxr-xr-x 6 root root 0 Jan 9 13:45 1-2:1.2
drwxr-xr-x 6 root root 0 Jan 9 13:46 1-2:1.3
drwxr-xr-x 6 root root 0 Jan 9 13:46 1-2:1.4
drwxr-xr-x 5 root root 0 Jan 9 13:46 1-2:1.5
这些就是用户刚刚挂载在ubs1 这个bug下的设备,他们占用usb bub1中port1,configuration都为1,而interface0 - 6都被用户占用,在1-2:1.0可以找到ttyUSB0/,ttyUSB0就是/dev/ttyUSB0相关。我现在挂载在usb hub1上的设备是usb转串口的lte模块,所以名字是ttyUSB*
相关文章推荐
- C#源代码—统计从键盘输入一行字符英文字母的个数
- RxJava开发精要3-向响应式世界问好
- unity3d 音频无缝循环
- 本地Git仓库和远程仓库的创建及关联
- git stash
- 简单完整的代码,通过这个代码你将对RSA加密算法在Java中的实现方法有一个初步的了解,这个类,你可以直接使用,水平高的,就自己修改完善下代码。
- RxJava开发精要2-为什么是Observables?
- 【教程】如何修改路由表?
- 关于github上边phonecat的路由与多视图解析
- matlab恢复默认界面布局
- BZOJ 1264: [AHOI2006]基因匹配Match|动态规划
- Java中使用MATLAB作图
- Mondrian异常
- 使用ListView实现汽泡短信聊天
- java特种兵读书笔记(3-4)——java程序员的OS之对象内存结构
- Android编程开发之在Canvas中利用Path绘制基本图形(圆形,矩形,椭圆,三角形等)
- iOS性能优化三部曲(中级)
- 仿Ios弹窗效果二
- C#源代码—在windows窗体中添加一个名为lblShow的Lable控件4,创建可变字符串,字符串转换为字符型
- 损失函数(Loss Function)