[PATCH 003/008] [RESUBMIT2] USB: serial: adding sierra_submit_rx_urbs() function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Subject: [PATCH 003/008] [RESUBMIT2] USB: serial: adding sierra_submit_rx_urbs()
function
From: Elina Pasheva <epasheva@xxxxxxxxxxxxxxxxxx>

The following is summary of changes we have made to sierra.c driver in
[PATCH 003/008] from the series dealing with improving urb handling:
- Added new function sierra_submit_rx_urbs() that handles the submission of
receive urbs and interrupt urbs (if any) during the interface activation. This
function is to be called by sierra_open(). Added a second parameter to pass
the memory allocation (as suggested by Oliver Neukum) so that this function can
be used in post_reset() and resume(). 
Signed-off-by: Elina Pasheva <epasheva@xxxxxxxxxxxxxxxxxx>
---

 drivers/usb/serial/sierra.c |   37 ++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

--- a/drivers/usb/serial/sierra.c	2009-05-22 14:02:24.000000000 -0700
+++ b/drivers/usb/serial/sierra.c	2009-05-22 14:09:14.000000000 -0700
@@ -624,6 +624,43 @@ static void sierra_stop_rx_urbs(struct u
 	usb_kill_urb(port->interrupt_in_urb);
 }
 
+static int sierra_submit_rx_urbs(struct usb_serial_port *port, gfp_t mem_flags)
+{
+	int ok_cnt;
+	int err = -EINVAL;
+	int i;
+	struct urb *urb;
+	struct sierra_port_private *portdata = usb_get_serial_port_data(port);
+
+	ok_cnt = 0;
+	for (i = 0; i < ARRAY_SIZE(portdata->in_urbs); i++) {
+		urb = portdata->in_urbs[i];
+		if (!urb)
+			continue;
+		err = usb_submit_urb(urb, mem_flags);
+		if (err) {
+			dev_err(&port->dev, "%s: submit urb failed: %d\n",
+				__func__, err);
+		} else {
+			ok_cnt++;
+		}
+	}
+
+	if (ok_cnt && port->interrupt_in_urb) {
+		err = usb_submit_urb(port->interrupt_in_urb, mem_flags);
+		if (err) {
+			dev_err(&port->dev, "%s: submit intr urb failed: %d\n",
+				__func__, err);
+		}
+	}
+
+	if (ok_cnt > 0) /* at least one rx urb submitted */
+		return 0;
+	else
+		return err;
+}
+
+
 static int sierra_open(struct tty_struct *tty,
 			struct usb_serial_port *port, struct file *filp)
 {



--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux