|
发表于 2017-2-25 15:51:34
只看该作者
沙发
方法:
drivers/usb/serial/usb-serial.c
//根据USB232的USB路径设置定义
+#define DEVPATH_TTYUSB0 "1.4.1"
+#define DEVPATH_TTYUSB1 "1.4.2"
+#define DEVPATH_TTYUSB2 "1.4.3"
@@ -117,6 +116,15 @@ static struct usb_serial *get_free_serial(struct usb_serial *serial,
a= BP_USB_PORT;
#endif
//预留ttyUSB0/1/2
+ // reserved minor 0-2 for build in usb-serial
+ if ((strcmp(serial->dev->devpath, DEVPATH_TTYUSB0) != 0) ||
+ (strcmp(serial->dev->devpath, DEVPATH_TTYUSB1) != 0) ||
+ (strcmp(serial->dev->devpath, DEVPATH_TTYUSB2) != 0) ){
+ a = 3;
+ dbg("\n%s - not build in usb serail device, minor from = %d\n", __func__, a);
+ }
+
+
for (i = a; i < SERIAL_TTY_MINORS; ++i) {
if (serial_table[i])
continue;
@@ -131,7 +139,20 @@ static struct usb_serial *get_free_serial(struct usb_serial *serial,
if (good_spot == 0)
continue;
//检测到USB232设备,分配已经留的设备名
+ // defined minor 0-2 for build in usb-serial
+ if (strcmp(serial->dev->devpath, DEVPATH_TTYUSB0) == 0) {
+ i = 0;
+ dbg("\n%s - devpath = %s, force minor = %d\n", __func__, serial->dev->devpath, i);
+ }else if (strcmp(serial->dev->devpath, DEVPATH_TTYUSB1) == 0) {
+ i = 1;
+ dbg("\n%s - devpath = %s, force minor = %d\n", __func__, serial->dev->devpath, i);
+ } else if (strcmp(serial->dev->devpath, DEVPATH_TTYUSB2) == 0) {
+ i = 2;
+ dbg("\n%s - devpath = %s, force minor = %d\n", __func__, serial->dev->devpath, i);
+ }
+
*minor = i;
+
j = 0;
dbg("%s - minor base = %d", __func__, *minor);
for (i = *minor; (i < (*minor + num_ports)) && (i < SERIAL_TTY_MINORS); ++i) {
|
|