summaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/mos7840.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-06-06 10:32:00 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-06-10 14:46:40 -0700
commit1143832eca8f1d64da7d85642c956ae9d25c69e1 (patch)
treee8ed5dedb8673c57d90f59c6e47df5cbc6986711 /drivers/usb/serial/mos7840.c
parent141dc40ee343ab532717b235dd645e2d25ae3092 (diff)
downloadop-kernel-dev-1143832eca8f1d64da7d85642c956ae9d25c69e1.zip
op-kernel-dev-1143832eca8f1d64da7d85642c956ae9d25c69e1.tar.gz
USB: serial: ports: add minor and port number
The usb_serial_port structure had the number field, which was the minor number for the port, which almost no one really cared about. They really wanted the number of the port within the device, which you had to subtract from the minor of the parent usb_serial_device structure. To clean this up, provide the real minor number of the port, and the number of the port within the serial device separately, as these numbers might not be related in the future. Bonus is that this cleans up a lot of logic in the drivers, and saves lines overall. Tested-by: Tobias Winter <tobias@linuxdingsda.de> Reviewed-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> -- drivers/staging/serqt_usb2/serqt_usb2.c | 21 +++-------- drivers/usb/serial/ark3116.c | 2 - drivers/usb/serial/bus.c | 6 +-- drivers/usb/serial/console.c | 2 - drivers/usb/serial/cp210x.c | 2 - drivers/usb/serial/cypress_m8.c | 4 +- drivers/usb/serial/digi_acceleport.c | 6 --- drivers/usb/serial/f81232.c | 5 +- drivers/usb/serial/garmin_gps.c | 6 +-- drivers/usb/serial/io_edgeport.c | 58 ++++++++++++-------------------- drivers/usb/serial/io_ti.c | 21 ++++------- drivers/usb/serial/keyspan.c | 29 +++++++--------- drivers/usb/serial/metro-usb.c | 4 +- drivers/usb/serial/mos7720.c | 37 +++++++++----------- drivers/usb/serial/mos7840.c | 52 +++++++++------------------- drivers/usb/serial/opticon.c | 2 - drivers/usb/serial/pl2303.c | 2 - drivers/usb/serial/quatech2.c | 7 +-- drivers/usb/serial/sierra.c | 2 - drivers/usb/serial/ti_usb_3410_5052.c | 10 ++--- drivers/usb/serial/usb-serial.c | 7 ++- drivers/usb/serial/usb_wwan.c | 2 - drivers/usb/serial/whiteheat.c | 20 +++++------ include/linux/usb/serial.h | 6 ++- 24 files changed, 133 insertions(+), 180 deletions(-)
Diffstat (limited to 'drivers/usb/serial/mos7840.c')
-rw-r--r--drivers/usb/serial/mos7840.c52
1 files changed, 18 insertions, 34 deletions
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 7e99808..f981b08 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -303,15 +303,12 @@ static int mos7840_set_uart_reg(struct usb_serial_port *port, __u16 reg,
/* For the UART control registers, the application number need
to be Or'ed */
if (port->serial->num_ports == 4) {
- val |= (((__u16) port->number -
- (__u16) (port->serial->minor)) + 1) << 8;
+ val |= ((__u16)port->port_number + 1) << 8;
} else {
- if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) {
- val |= (((__u16) port->number -
- (__u16) (port->serial->minor)) + 1) << 8;
+ if (port->port_number == 0) {
+ val |= ((__u16)port->port_number + 1) << 8;
} else {
- val |= (((__u16) port->number -
- (__u16) (port->serial->minor)) + 2) << 8;
+ val |= ((__u16)port->port_number + 2) << 8;
}
}
dev_dbg(&port->dev, "%s application number is %x\n", __func__, val);
@@ -340,16 +337,12 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
/* Wval is same as application number */
if (port->serial->num_ports == 4) {
- Wval =
- (((__u16) port->number - (__u16) (port->serial->minor)) +
- 1) << 8;
+ Wval = ((__u16)port->port_number + 1) << 8;
} else {
- if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) {
- Wval = (((__u16) port->number -
- (__u16) (port->serial->minor)) + 1) << 8;
+ if (port->port_number == 0) {
+ Wval = ((__u16)port->port_number + 1) << 8;
} else {
- Wval = (((__u16) port->number -
- (__u16) (port->serial->minor)) + 2) << 8;
+ Wval = ((__u16)port->port_number + 2) << 8;
}
}
dev_dbg(&port->dev, "%s application number is %x\n", __func__, Wval);
@@ -631,9 +624,7 @@ static void mos7840_interrupt_callback(struct urb *urb)
for (i = 0; i < serial->num_ports; i++) {
mos7840_port = mos7840_get_port_private(serial->port[i]);
- wval =
- (((__u16) serial->port[i]->number -
- (__u16) (serial->minor)) + 1) << 8;
+ wval = ((__u16)serial->port[i]->port_number + 1) << 8;
if (mos7840_port->open) {
if (sp[i] & 0x01) {
dev_dbg(&urb->dev->dev, "SP%d No Interrupt !!!\n", i);
@@ -1065,8 +1056,8 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
* (can't set it up in mos7840_startup as the *
* structures were not set up at that time.) */
- dev_dbg(&port->dev, "port number is %d\n", port->number);
- dev_dbg(&port->dev, "serial number is %d\n", port->serial->minor);
+ dev_dbg(&port->dev, "port number is %d\n", port->port_number);
+ dev_dbg(&port->dev, "minor number is %d\n", port->serial->minor);
dev_dbg(&port->dev, "Bulkin endpoint is %d\n", port->bulk_in_endpointAddress);
dev_dbg(&port->dev, "BulkOut endpoint is %d\n", port->bulk_out_endpointAddress);
dev_dbg(&port->dev, "Interrupt endpoint is %d\n", port->interrupt_in_endpointAddress);
@@ -1074,9 +1065,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port)
mos7840_port->read_urb = port->read_urb;
/* set up our bulk in urb */
- if ((serial->num_ports == 2)
- && ((((__u16)port->number -
- (__u16)(port->serial->minor)) % 2) != 0)) {
+ if ((serial->num_ports == 2) && (((__u16)port->port_number % 2) != 0)) {
usb_fill_bulk_urb(mos7840_port->read_urb,
serial->dev,
usb_rcvbulkpipe(serial->dev,
@@ -1199,7 +1188,7 @@ static void mos7840_close(struct usb_serial_port *port)
mos7840_port->read_urb_busy = false;
port0->open_ports--;
- dev_dbg(&port->dev, "%s in close%d:in port%d\n", __func__, port0->open_ports, port->number);
+ dev_dbg(&port->dev, "%s in close%d\n", __func__, port0->open_ports);
if (port0->open_ports == 0) {
if (serial->port[0]->interrupt_in_urb) {
dev_dbg(&port->dev, "Shutdown interrupt_in_urb\n");
@@ -1435,9 +1424,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
memcpy(urb->transfer_buffer, current_position, transfer_size);
/* fill urb with data and submit */
- if ((serial->num_ports == 2)
- && ((((__u16)port->number -
- (__u16)(port->serial->minor)) % 2) != 0)) {
+ if ((serial->num_ports == 2) && (((__u16)port->port_number % 2) != 0)) {
usb_fill_bulk_urb(urb,
serial->dev,
usb_sndbulkpipe(serial->dev,
@@ -1732,10 +1719,9 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
if (mos7840_serial_paranoia_check(port->serial, __func__))
return -1;
- number = mos7840_port->port->number - mos7840_port->port->serial->minor;
+ number = mos7840_port->port->port_number;
- dev_dbg(&port->dev, "%s - port = %d, baud = %d\n", __func__,
- mos7840_port->port->number, baudRate);
+ dev_dbg(&port->dev, "%s - baud = %d\n", __func__, baudRate);
/* reset clk_uart_sel in spregOffset */
if (baudRate > 115200) {
#ifdef HW_flow_control
@@ -2016,7 +2002,6 @@ static void mos7840_set_termios(struct tty_struct *tty,
tty->termios.c_cflag, RELEVANT_IFLAG(tty->termios.c_iflag));
dev_dbg(&port->dev, "%s - old clfag %08x old iflag %08x\n", __func__,
old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag));
- dev_dbg(&port->dev, "%s - port %d\n", __func__, port->number);
/* change the port settings to the new ones specified */
@@ -2084,7 +2069,7 @@ static int mos7840_get_serial_info(struct moschip_port *mos7840_port,
tmp.type = PORT_16550A;
tmp.line = mos7840_port->port->serial->minor;
- tmp.port = mos7840_port->port->number;
+ tmp.port = mos7840_port->port->port_number;
tmp.irq = 0;
tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE;
@@ -2240,7 +2225,7 @@ static int mos7840_port_probe(struct usb_serial_port *port)
/* we set up the pointers to the endpoints in the mos7840_open *
* function, as the structures aren't created yet. */
- pnum = port->number - serial->minor;
+ pnum = port->port_number;
dev_dbg(&port->dev, "mos7840_startup: configuring port %d\n", pnum);
mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL);
@@ -2261,7 +2246,6 @@ static int mos7840_port_probe(struct usb_serial_port *port)
* usb-serial.c:get_free_serial() and cannot therefore be used
* to index device instances */
mos7840_port->port_num = pnum + 1;
- dev_dbg(&port->dev, "port->number = %d\n", port->number);
dev_dbg(&port->dev, "port->serial->minor = %d\n", port->serial->minor);
dev_dbg(&port->dev, "mos7840_port->port_num = %d\n", mos7840_port->port_num);
dev_dbg(&port->dev, "serial->minor = %d\n", serial->minor);
OpenPOWER on IntegriCloud