summaryrefslogtreecommitdiff
path: root/drivers/staging/serqt_usb2
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-06-07 11:04:28 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-06-17 13:30:02 -0700
commite5b1e2062e0535e8ffef79bb34d857e21380d101 (patch)
tree75376f4cb69f6a1cd05b323803ae6a1a8fc4db90 /drivers/staging/serqt_usb2
parent1508124d8a4e0995362d93d82e5555a74bfc998f (diff)
USB: serial: make minor allocation dynamic
This moves the allocation of minor device numbers from a static array to be dynamic, using the idr interface. This means that you could potentially get "gaps" in a minor number range for a single USB serial device with multiple ports, but all should still work properly. We remove the 'minor' field from the usb_serial structure, as it no longer makes any sense for it (use the field in the usb_serial_port structure if you really want to know this number), and take the fact that we were overloading a number in this field to determine if we had initialized the minor numbers or not, and just use a flag variable instead. Note, we still have the limitation of 255 USB to serial devices in the system, as that is all we are registering with the TTY layer at this point in time. Tested-by: Tobias Winter <tobias@linuxdingsda.de> Reviewed-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/serqt_usb2')
-rw-r--r--drivers/staging/serqt_usb2/serqt_usb2.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c
index 4f891dba2faa..880f5c0011f2 100644
--- a/drivers/staging/serqt_usb2/serqt_usb2.c
+++ b/drivers/staging/serqt_usb2/serqt_usb2.c
@@ -906,7 +906,7 @@ static int qt_open(struct tty_struct *tty,
qt_submit_urb_from_open(serial, port);
}
- dev_dbg(&port->dev, "serial number is %d\n", port->serial->minor);
+ dev_dbg(&port->dev, "minor number is %d\n", port->minor);
dev_dbg(&port->dev,
"Bulkin endpoint is %d\n", port->bulk_in_endpointAddress);
dev_dbg(&port->dev,
@@ -1002,7 +1002,7 @@ static void qt_close(struct usb_serial_port *port)
status = 0;
tty = tty_port_tty_get(&port->port);
- index = tty->index - serial->minor;
+ index = port->port_number;
qt_port = qt_get_port_private(port);
port0 = qt_get_port_private(serial->port[0]);
@@ -1129,12 +1129,11 @@ static int qt_ioctl(struct tty_struct *tty,
{
struct usb_serial_port *port = tty->driver_data;
struct quatech_port *qt_port = qt_get_port_private(port);
- struct usb_serial *serial = get_usb_serial(port, __func__);
unsigned int index;
dev_dbg(&port->dev, "%s cmd 0x%04x\n", __func__, cmd);
- index = tty->index - serial->minor;
+ index = port->port_number;
if (cmd == TIOCMIWAIT) {
while (qt_port != NULL) {
@@ -1180,7 +1179,7 @@ static void qt_set_termios(struct tty_struct *tty,
int baud, divisor, remainder;
int status;
- index = tty->index - port->serial->minor;
+ index = port->port_number;
switch (cflag & CSIZE) {
case CS5:
@@ -1296,7 +1295,7 @@ static void qt_break(struct tty_struct *tty, int break_state)
u16 index, onoff;
unsigned int result;
- index = tty->index - serial->minor;
+ index = port->port_number;
qt_port = qt_get_port_private(port);
@@ -1325,7 +1324,7 @@ static inline int qt_real_tiocmget(struct tty_struct *tty,
int status;
unsigned int index;
- index = tty->index - serial->minor;
+ index = port->port_number;
status =
BoxGetRegister(port->serial, index, MODEM_CONTROL_REGISTER, &mcr);
if (status >= 0) {
@@ -1364,7 +1363,7 @@ static inline int qt_real_tiocmset(struct tty_struct *tty,
int status;
unsigned int index;
- index = tty->index - serial->minor;
+ index = port->port_number;
status =
BoxGetRegister(port->serial, index, MODEM_CONTROL_REGISTER, &mcr);
if (status < 0)