*** usbserial.c Fri Nov 28 12:26:20 2003 --- usbserial.c.12_dec_2003 Fri Apr 30 09:02:56 2004 *************** *** 12,21 **** --- 12,24 ---- * This driver was originally based on the ACM driver by Armin Fuerst (which was * based on a driver by Brad Keryan) * * See Documentation/usb/usb-serial.txt for more information on using this driver * + * (12/11/2003) al borchers + * added initial support for assigning port assignments via adapter serial + * number (reserve_ports[]). * (10/10/2001) gkh * usb_serial_disconnect() now sets the serial->dev pointer is to NULL to * help prevent child drivers from accessing the device since it is now * gone. * *************** *** 309,319 **** #include "pl2303.h" /* * Version Information */ ! #define DRIVER_VERSION "v1.4" #define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com, http://www.kroah.com/linux-usb/" #define DRIVER_DESC "USB Serial Driver core" /* function prototypes for a "generic" type serial converter (no flow control, not all endpoints needed) */ /* need to always compile these in, as some of the other devices use these functions as their own. */ --- 312,322 ---- #include "pl2303.h" /* * Version Information */ ! #define DRIVER_VERSION "v1.4A" #define DRIVER_AUTHOR "Greg Kroah-Hartman, greg@kroah.com, http://www.kroah.com/linux-usb/" #define DRIVER_DESC "USB Serial Driver core" /* function prototypes for a "generic" type serial converter (no flow control, not all endpoints needed) */ /* need to always compile these in, as some of the other devices use these functions as their own. */ *************** *** 383,392 **** --- 386,396 ---- static struct tty_driver serial_tty_driver; static struct tty_struct * serial_tty[SERIAL_TTY_MINORS]; static struct termios * serial_termios[SERIAL_TTY_MINORS]; static struct termios * serial_termios_locked[SERIAL_TTY_MINORS]; static struct usb_serial *serial_table[SERIAL_TTY_MINORS]; /* initially all NULL */ + static char *reserve_ports[SERIAL_TTY_MINORS]; /* initially all NULL */ static LIST_HEAD(usb_serial_driver_list); *************** *** 394,419 **** { return serial_table[minor]; } ! static struct usb_serial *get_free_serial (int num_ports, int *minor) { struct usb_serial *serial = NULL; int i, j; int good_spot; dbg("%s %d", __FUNCTION__, num_ports); *minor = 0; for (i = 0; i < SERIAL_TTY_MINORS; ++i) { ! if (serial_table[i]) continue; good_spot = 1; for (j = 1; j <= num_ports-1; ++j) ! if (serial_table[i+j]) good_spot = 0; if (good_spot == 0) continue; if (!(serial = kmalloc(sizeof(struct usb_serial), GFP_KERNEL))) { --- 398,426 ---- { return serial_table[minor]; } ! static struct usb_serial *get_free_serial (int num_ports, int *minor, ! char *serial_number) { struct usb_serial *serial = NULL; int i, j; int good_spot; dbg("%s %d", __FUNCTION__, num_ports); *minor = 0; for (i = 0; i < SERIAL_TTY_MINORS; ++i) { ! if (serial_table[i] ! || (reserve_ports[i] && strcmp(reserve_ports[i],serial_number) != 0)) continue; good_spot = 1; for (j = 1; j <= num_ports-1; ++j) ! if (serial_table[i+j] || (reserve_ports[i+j] ! && strcmp(reserve_ports[i+j],serial_number) != 0)) good_spot = 0; if (good_spot == 0) continue; if (!(serial = kmalloc(sizeof(struct usb_serial), GFP_KERNEL))) { *************** *** 1130,1139 **** --- 1137,1147 ---- int num_bulk_in = 0; int num_bulk_out = 0; int num_ports; int max_endpoints; const struct usb_device_id *id_pattern = NULL; + char serial_number[256]; /* loop through our list of known serial converters, and see if this device matches. */ found = 0; interface = &dev->actconfig->interface[ifnum]; *************** *** 1232,1242 **** } } else #endif num_ports = type->num_ports; ! serial = get_free_serial (num_ports, &minor); if (serial == NULL) { err("No more free serial devices"); return NULL; } --- 1240,1255 ---- } } else #endif num_ports = type->num_ports; ! if( dev->descriptor.iSerialNumber ) ! usb_string(dev, dev->descriptor.iSerialNumber, serial_number, 256); ! else ! *serial_number = '\0'; ! ! serial = get_free_serial (num_ports, &minor, serial_number); if (serial == NULL) { err("No more free serial devices"); return NULL; } *************** *** 1603,1614 **** --- 1616,1633 ---- MODULE_LICENSE("GPL"); MODULE_PARM(debug, "i"); MODULE_PARM_DESC(debug, "Debug enabled or not"); + #define usb_serial_cat_str_num_str(a,b,c) _usb_serial_cat_str_num_str(a,b,c) + #define _usb_serial_cat_str_num_str(a,b,c) a #b c + MODULE_PARM(reserve_ports, usb_serial_cat_str_num_str("1-",SERIAL_TTY_MINORS,"s")); + MODULE_PARM_DESC(reserve_ports, usb_serial_cat_str_num_str("Reserve tty devices for these serial numbers, 1-",SERIAL_TTY_MINORS," strings")); + #ifdef CONFIG_USB_SERIAL_GENERIC MODULE_PARM(vendor, "h"); MODULE_PARM_DESC(vendor, "User specified USB idVendor"); MODULE_PARM(product, "h"); MODULE_PARM_DESC(product, "User specified USB idProduct"); #endif +