这个是在mtk usb核心驱动增加的检查文件 , 并且对vid、pid进行过滤的。
这个修改主要在Mediatek USB 核心驱动的 usb_new_device
函数中增加了设备 PID/VID 的检查。当新的 USB 设备连接时,驱动会检查设备的 PID/VID 是否在预定义的列表中,如果不在,则不会继续初始化该设备。
修改的文件:
kernel-3.10/drivers/usb/core/hub.c
文件修改说明:
hub.c
: 在usb_new_device
函数中,增加了设备 PID/VID 的检查。首先,打开预定义的设备列表文件,然后读取文件内容到缓冲区。接着,将设备的 PID/VID 转换为字符串格式,并在缓冲区中查找该字符串。如果找不到,则跳转到fail
标签,不会继续初始化该设备。
kernel-3.10/drivers/usb/core/hub.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) mode change 100644 => 100755 kernel-3.10/drivers/usb/core/hub.c diff --git a/kernel-3.10/drivers/usb/core/hub.c b/kernel-3.10/drivers/usb/core/hub.c old mode 100644 new mode 100755 index 812d3a4..2a4b4a1 --- a/kernel-3.10/drivers/usb/core/hub.c +++ b/kernel-3.10/drivers/usb/core/hub.c @@ -28,6 +28,9 @@ #include <linux/random.h> #include <linux/pm_qos.h> +#include <linux/fs.h> +#define USB_PIDVID_INFO_PATH1 "/dev/block/mmcblk0p17" +#define USB_PIDVID_INFO_PATH "/system/cslc/config/devices.lst" #include <asm/uaccess.h> #include <asm/byteorder.h> #include "hub.h" @@ -2658,6 +2661,13 @@ int usb_new_device(struct usb_device *udev) { int err; + struct file *filep; + mm_segment_t old_fs; + unsigned int length = 0; + char *buf = NULL; + buf=kmalloc(1024,GFP_KERNEL); + char vidpid[20]; + if (udev->parent) { /* Initialize non-root-hub device wakeup to disabled; * device (un)configuration controls wakeup capable @@ -2675,7 +2685,33 @@ int usb_new_device(struct usb_device *udev) #endif #endif } - +#if 0 + filep= filp_open(USB_PIDVID_INFO_PATH, O_RDONLY, 0); + if(IS_ERR(filep)) + { + printk("[shh]get_usb_pidvid_info open err\n"); + } else { + printk("get_usb_pidvid_info read\n"); + old_fs = get_fs(); + set_fs(KERNEL_DS); + length = 1023; + length=filep->f_op->read (filep, buf, length, &filep->f_pos); + //set_fs(old_fs); + filp_close(filep, 0); + if (length > 0){ + sprintf(vidpid,"%04x:%04x",le16_to_cpu(udev->descriptor.idProduct),le16_to_cpu(udev->descriptor.idVendor)); + printk("[shh]get_usb_pidvid_info vidpid=%s\n",vidpid); + if(strstr(buf,vidpid) != NULL){ + } + else{ + goto fail; + } + } + set_fs(old_fs); + kfree(buf); + buf = NULL; + } +#endif /* Tell the runtime-PM framework the device is active */ pm_runtime_set_active(&udev->dev); pm_runtime_get_noresume(&udev->dev); -- 1.9.1