浅析/dev/bus/usb/下的major主设备号189和动态253对应的内核驱动
drivers/usb/core/devio.c
usb_devio_init
==>
const struct file_operations usbdev_file_operations = {
.owner = THIS_MODULE,
.llseek = usbdev_lseek,
.read = usbdev_read,
.poll = usbdev_poll,
.ioctl = usbdev_ioctl,
.open = usbdev_open,
.release = usbdev_release,
};
usbdev_ioctl
==>
#define USBDEVFS_CONTROL _IOWR('U', 0, struct usbdevfs_ctrltransfer)
#define USBDEVFS_BULK _IOWR('U', 2, struct usbdevfs_bulktransfer)
case USBDEVFS_CONTROL:
proc_control(ps, p);
luther@gliethttp:~$ ll /dev/bus/usb/001/
total 0
crw-rw-r-- 1 root root 189, 4 2009-07-15 08:10 005
crw-rw-r-- 1 root root 189, 5 2009-07-15 08:12 006
crw-rw-r-- 1 root root 189, 0 2009-07-15 15:17 001
至于/dev/usbdev*主设备号253,是每个usb设备具有的端点控制接口
generic_probe
==>usb_create_sysfs_dev_files
==*>usb_create_ep_files(dev, &udev->ep0, udev);
==**>ep_dev->dev.devt = MKDEV(usb_endpoint_major, ep_dev->minor); // 这里usb_endpoint_major就是253
init_endpoint_class
==>usb_endpoint_major_init();
#define MAX_ENDPOINT_MINORS (64*128*32) // 最多观测endpoint数目
==*>alloc_chrdev_region(&dev, 0, MAX_ENDPOINT_MINORS, "usb_endpoint");
==*>usb_endpoint_major = MAJOR(dev); // 将alloc_chrdev_region动态申请的major号添进去.
luther@gliethttp:/vobs/libusb$ ll /dev/usbdev*
crw-rw---- 1 root root 253, 9 2009-07-14 18:48 /dev/usbdev1.5_ep00
crw-rw---- 1 root root 253, 6 2009-07-14 18:48 /dev/usbdev1.5_ep01
crw-rw---- 1 root root 253, 7 2009-07-14 18:48 /dev/usbdev1.5_ep82
crw-rw---- 1 root root 253, 8 2009-07-14 18:48 /dev/usbdev1.5_ep83
crw-rw---- 1 root root 253, 10 2009-07-14 19:33 /dev/usbdev2.19_ep81
crw-rw---- 1 root root 253, 11 2009-07-14 19:33 /dev/usbdev2.19_ep00
crw-rw---- 1 root root 253, 14 2009-07-14 19:33 /dev/usbdev2.20_ep00
crw-rw---- 1 root root 253, 12 2009-07-14 19:33 /dev/usbdev2.20_ep81
crw-rw---- 1 root root 253, 13 2009-07-14 19:33 /dev/usbdev2.20_ep02
crw-rw---- 1 root root 253, 0 2009-07-15 02:03 /dev/usbdev1.1_ep81
crw-rw---- 1 root root 253, 1 2009-07-15 02:03 /dev/usbdev1.1_ep00
crw-rw---- 1 root root 253, 3 2009-07-15 02:03 /dev/usbdev2.1_ep00
crw-rw---- 1 root root 253, 2 2009-07-15 02:03 /dev/usbdev2.1_ep81
crw-rw---- 1 root root 253, 5 2009-07-15 02:03 /dev/usbdev2.2_ep00
crw-rw---- 1 root root 253, 4 2009-07-15 02:03 /dev/usbdev2.2_ep81
luther@gliethttp:~$ ls /sys/class/usb_endpoint
usbdev1.1_ep00 usbdev1.3_ep81 usbdev2.1_ep00 usbdev3.1_ep81 usbdev5.1_ep00 usbdev6.1_ep81
usbdev1.1_ep81 usbdev1.5_ep00 usbdev2.1_ep81 usbdev4.1_ep00 usbdev5.1_ep81 usbdev7.1_ep00
usbdev1.3_ep00 usbdev1.5_ep81 usbdev3.1_ep00 usbdev4.1_ep81 usbdev6.1_ep00 usbdev7.1_ep81
阅读(6447) | 评论(0) | 转发(0) |