Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f87158e authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman
Browse files

USB: remove references to port->port.count from the serial drivers



This patch (as1344) removes references to port->port.count from the
USB serial drivers.  Now that serial ports are properly reference
counted, port.count checking is unnecessary and incorrect.  Drivers
should assume that the port is in use from the time the open method
runs until the close method is called.

Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent a108bfcb
Loading
Loading
Loading
Loading
+13 −21
Original line number Diff line number Diff line
@@ -468,10 +468,6 @@ static void aircable_read_bulk_callback(struct urb *urb)

	if (status) {
		dbg("%s - urb status = %d", __func__, status);
		if (!port->port.count) {
			dbg("%s - port is closed, exiting.", __func__);
			return;
		}
		if (status == -EPROTO) {
			dbg("%s - caught -EPROTO, resubmitting the urb",
			    __func__);
@@ -530,8 +526,7 @@ static void aircable_read_bulk_callback(struct urb *urb)
	}
	tty_kref_put(tty);

	/* Schedule the next read _if_ we are still open */
	if (port->port.count) {
	/* Schedule the next read */
	usb_fill_bulk_urb(port->read_urb, port->serial->dev,
			  usb_rcvbulkpipe(port->serial->dev,
				  port->bulk_in_endpointAddress),
@@ -540,15 +535,12 @@ static void aircable_read_bulk_callback(struct urb *urb)
			  aircable_read_bulk_callback, port);

	result = usb_submit_urb(urb, GFP_ATOMIC);
		if (result)
	if (result && result != -EPERM)
		dev_err(&urb->dev->dev,
			"%s - failed resubmitting read urb, error %d\n",
			__func__, result);
}

	return;
}

/* Based on ftdi_sio.c throttle */
static void aircable_throttle(struct tty_struct *tty)
{
+3 −3
Original line number Diff line number Diff line
@@ -1321,9 +1321,9 @@ static void cypress_read_int_callback(struct urb *urb)
continue_read:
	tty_kref_put(tty);

	/* Continue trying to always read... unless the port has closed. */
	/* Continue trying to always read */

	if (port->port.count > 0 && priv->comm_is_ok) {
	if (priv->comm_is_ok) {
		usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev,
				usb_rcvintpipe(port->serial->dev,
					port->interrupt_in_endpointAddress),
@@ -1332,7 +1332,7 @@ continue_read:
				cypress_read_int_callback, port,
				priv->read_urb_interval);
		result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
		if (result) {
		if (result && result != -EPERM) {
			dev_err(&urb->dev->dev, "%s - failed resubmitting "
					"read urb, error %d\n", __func__,
					result);
+8 −11
Original line number Diff line number Diff line
@@ -1262,10 +1262,10 @@ static void digi_write_bulk_callback(struct urb *urb)
		return;
	}

	/* try to send any buffered data on this port, if it is open */
	/* try to send any buffered data on this port */
	spin_lock(&priv->dp_port_lock);
	priv->dp_write_urb_in_use = 0;
	if (port->port.count && priv->dp_out_buf_len > 0) {
	if (priv->dp_out_buf_len > 0) {
		*((unsigned char *)(port->write_urb->transfer_buffer))
			= (unsigned char)DIGI_CMD_SEND_DATA;
		*((unsigned char *)(port->write_urb->transfer_buffer) + 1)
@@ -1288,7 +1288,7 @@ static void digi_write_bulk_callback(struct urb *urb)
	schedule_work(&priv->dp_wakeup_work);

	spin_unlock(&priv->dp_port_lock);
	if (ret)
	if (ret && ret != -EPERM)
		dev_err(&port->dev,
			"%s: usb_submit_urb failed, ret=%d, port=%d\n",
			__func__, ret, priv->dp_port_num);
@@ -1353,8 +1353,7 @@ static int digi_open(struct tty_struct *tty, struct usb_serial_port *port)
	struct digi_port *priv = usb_get_serial_port_data(port);
	struct ktermios not_termios;

	dbg("digi_open: TOP: port=%d, open_count=%d",
		priv->dp_port_num, port->port.count);
	dbg("digi_open: TOP: port=%d", priv->dp_port_num);

	/* be sure the device is started up */
	if (digi_startup_device(port->serial) != 0)
@@ -1393,8 +1392,7 @@ static void digi_close(struct usb_serial_port *port)
	unsigned char buf[32];
	struct digi_port *priv = usb_get_serial_port_data(port);

	dbg("digi_close: TOP: port=%d, open_count=%d",
		priv->dp_port_num, port->port.count);
	dbg("digi_close: TOP: port=%d", priv->dp_port_num);

	mutex_lock(&port->serial->disc_mutex);
	/* if disconnected, just clear flags */
@@ -1629,7 +1627,7 @@ static void digi_read_bulk_callback(struct urb *urb)
	/* continue read */
	urb->dev = port->serial->dev;
	ret = usb_submit_urb(urb, GFP_ATOMIC);
	if (ret != 0) {
	if (ret != 0 && ret != -EPERM) {
		dev_err(&port->dev,
			"%s: failed resubmitting urb, ret=%d, port=%d\n",
			__func__, ret, priv->dp_port_num);
@@ -1662,7 +1660,7 @@ static int digi_read_inb_callback(struct urb *urb)

	/* do not process callbacks on closed ports */
	/* but do continue the read chain */
	if (port->port.count == 0)
	if (urb->status == -ENOENT)
		return 0;

	/* short/multiple packet check */
@@ -1767,7 +1765,6 @@ static int digi_read_oob_callback(struct urb *urb)

		tty = tty_port_tty_get(&port->port);
		rts = 0;
		if (port->port.count)
		rts = tty->termios->c_cflag & CRTSCTS;
		
		if (opcode == DIGI_CMD_READ_INPUT_SIGNALS) {
+2 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <linux/usb/serial.h>
#include <linux/uaccess.h>
#include <linux/kfifo.h>
#include <linux/serial.h>

static int debug;

@@ -585,7 +586,7 @@ int usb_serial_generic_resume(struct usb_serial *serial)

	for (i = 0; i < serial->num_ports; i++) {
		port = serial->port[i];
		if (!port->port.count)
		if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags))
			continue;

		if (port->read_urb) {
+0 −5
Original line number Diff line number Diff line
@@ -445,11 +445,6 @@ static void ir_read_bulk_callback(struct urb *urb)

	dbg("%s - port %d", __func__, port->number);

	if (!port->port.count) {
		dbg("%s - port closed.", __func__);
		return;
	}

	switch (status) {
	case 0: /* Successful */
		/*
Loading