Skip to contentSkip to conversation

usb: hso: correct debug message

PATCH In review Oliver Neukum 2 participants 7 messages Jun 6, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/6 usb: hso: correct debug message

If you do not find the OUT endpoint, you should say so, rather than copy the error message for the IN endpoint. Presumably a copy and paste error.

---
 drivers/net/usb/hso.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/hso.c +1 -1
index d6916f787fce..6a0ecddff310 100644
@@ -2663,7 +2663,7 @@ static struct hso_device *hso_create_bulk_serial_device(
 	if (!
 	    (serial->out_endp =
 	     hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, USB_DIR_OUT))) {
-		dev_err(&interface->dev, "Failed to find BULK IN ep\n");
+		dev_err(&interface->dev, "Failed to find BULK OUT ep\n");
 		goto exit2;
 	}
 
Signature · 1 line
2.16.4
#1 lore raw

PATCH 2/6 usb: hso: no complaint about kmalloc failure

If this fails, kmalloc() will print a report including a stack trace. There is no need for a separate complaint.

---
 drivers/net/usb/hso.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/usb/hso.c +2 -3
index 6a0ecddff310..fe1d7bdc8afe 100644
@@ -2474,10 +2474,9 @@ static void hso_create_rfkill(struct hso_device *hso_dev,
 				       &interface_to_usbdev(interface)->dev,
 				       RFKILL_TYPE_WWAN,
 				       &hso_rfkill_ops, hso_dev);
-	if (!hso_net->rfkill) {
-		dev_err(dev, "%s - Out of memory\n", __func__);
+	if (!hso_net->rfkill)
 		return;
-	}
+
 	if (rfkill_register(hso_net->rfkill) < 0) {
 		rfkill_destroy(hso_net->rfkill);
 		hso_net->rfkill = NULL;
Signature · 1 line
2.16.4
#2 lore raw

PATCH 3/6 usb: hso: switch definitions to the BIT macro

In reply to Oliver Neukum

This is just a minor improvement in readability.

---
 drivers/net/usb/hso.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/usb/hso.c +7 -7
index fe1d7bdc8afe..ab18dbe169f3 100644
@@ -177,13 +177,13 @@ enum rx_ctrl_state{
 #define W_VALUE         (0x0)
 #define W_LENGTH        (0x2)
 
-#define B_OVERRUN       (0x1<<6)
-#define B_PARITY        (0x1<<5)
-#define B_FRAMING       (0x1<<4)
-#define B_RING_SIGNAL   (0x1<<3)
-#define B_BREAK         (0x1<<2)
-#define B_TX_CARRIER    (0x1<<1)
-#define B_RX_CARRIER    (0x1<<0)
+#define B_OVERRUN       BIT(6)
+#define B_PARITY        BIT(5)
+#define B_FRAMING       BIT(4)
+#define B_RING_SIGNAL   BIT(3)
+#define B_BREAK         BIT(2)
+#define B_TX_CARRIER    BIT(1)
+#define B_RX_CARRIER    BIT(0)
 
 struct hso_serial_state_notification {
 	u8 bmRequestType;
Signature · 1 line
2.16.4
#3 lore raw

PATCH 4/6 usb: hso: declare endianness

In reply to Oliver Neukum

The driver declares data structures with defined endianness as u16. Be more precise.

---
 drivers/net/usb/hso.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/usb/hso.c +5 -5
index ab18dbe169f3..7379df01cd98 100644
@@ -188,10 +188,10 @@ enum rx_ctrl_state{
 struct hso_serial_state_notification {
 	u8 bmRequestType;
 	u8 bNotification;
-	u16 wValue;
-	u16 wIndex;
-	u16 wLength;
-	u16 UART_state_bitmap;
+	__le16 wValue;
+	__le16 wIndex;
+	__le16 wLength;
+	__le16 UART_state_bitmap;
 } __packed;
 
 struct hso_tiocmget {
@@ -201,7 +201,7 @@ struct hso_tiocmget {
 	struct usb_endpoint_descriptor *endp;
 	struct urb *urb;
 	struct hso_serial_state_notification serial_state_notification;
-	u16    prev_UART_state_bitmap;
+	__le16    prev_UART_state_bitmap;
 	struct uart_icount icount;
 };
 
Signature · 1 line
2.16.4
#4 lore raw

PATCH 5/6 usb: hso: obey DMA rules in tiocmget

In reply to Oliver Neukum

The serial state information must not be embedded into another data structure, as this interferes with cache handling for DMA. Allocating it separately.

---
 drivers/net/usb/hso.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/usb/hso.c +9 -4
index 7379df01cd98..489024f0ae62 100644
@@ -200,7 +200,7 @@ struct hso_tiocmget {
 	int    intr_completed;
 	struct usb_endpoint_descriptor *endp;
 	struct urb *urb;
-	struct hso_serial_state_notification serial_state_notification;
+	struct hso_serial_state_notification *serial_state_notification;
 	__le16    prev_UART_state_bitmap;
 	struct uart_icount icount;
 };
@@ -1446,7 +1446,7 @@ static int tiocmget_submit_urb(struct hso_serial *serial,
 			 usb_rcvintpipe(usb,
 					tiocmget->endp->
 					bEndpointAddress & 0x7F),
-			 &tiocmget->serial_state_notification,
+			 tiocmget->serial_state_notification,
 			 sizeof(struct hso_serial_state_notification),
 			 tiocmget_intr_callback, serial,
 			 tiocmget->endp->bInterval);
@@ -1493,7 +1493,7 @@ static void tiocmget_intr_callback(struct urb *urb)
 	/* wIndex should be the USB interface number of the port to which the
 	 * notification applies, which should always be the Modem port.
 	 */
-	serial_state_notification = &tiocmget->serial_state_notification;
+	serial_state_notification = tiocmget->serial_state_notification;
 	if (serial_state_notification->bmRequestType != BM_REQUEST_TYPE ||
 	    serial_state_notification->bNotification != B_NOTIFICATION ||
 	    le16_to_cpu(serial_state_notification->wValue) != W_VALUE ||
@@ -2578,6 +2578,8 @@ static void hso_free_tiomget(struct hso_serial *serial)
 		usb_free_urb(tiocmget->urb);
 		tiocmget->urb = NULL;
 		serial->tiocmget = NULL;
+		kfree(tiocmget->serial_state_notification);
+		tiocmget->serial_state_notification = NULL;
 		kfree(tiocmget);
 	}
 }
@@ -2628,10 +2630,13 @@ static struct hso_device *hso_create_bulk_serial_device(
 		num_urbs = 2;
 		serial->tiocmget = kzalloc(sizeof(struct hso_tiocmget),
 					   GFP_KERNEL);
+		serial->tiocmget->serial_state_notification
+		      	= kzalloc(sizeof(struct hso_serial_state_notification),
+					   GFP_KERNEL);
 		/* it isn't going to break our heart if serial->tiocmget
 		 *  allocation fails don't bother checking this.
 		 */
-		if (serial->tiocmget) {
+		if (serial->tiocmget && serial->tiocmget->serial_state_notification) {
 			tiocmget = serial->tiocmget;
 			tiocmget->urb = usb_alloc_urb(0, GFP_KERNEL);
 			if (tiocmget->urb) {
Signature · 1 line
2.16.4
#5 lore raw

PATCH 6/6 usb: hso: remove bogus check for EINPROGRESS

In reply to Oliver Neukum

This check makes no sense. It is an inherent race.

---
 drivers/net/usb/hso.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/usb/hso.c +1 -2
index 489024f0ae62..f7976a6fa570 100644
@@ -845,8 +845,7 @@ static void hso_net_tx_timeout(struct net_device *net)
 	dev_warn(&net->dev, "Tx timed out.\n");
 
 	/* Tear the waiting frame off the list */
-	if (odev->mux_bulk_tx_urb &&
-	    (odev->mux_bulk_tx_urb->status == -EINPROGRESS))
+	if (odev->mux_bulk_tx_urb)
 		usb_unlink_urb(odev->mux_bulk_tx_urb);
 
 	/* Update statistics */
Signature · 1 line
2.16.4
maintainer
#6 lore raw
In reply to Oliver Neukum

Oliver, can you please start providing proper header postings with your patch series that explains at a high level what the patch series is doing, how it is doing it, and why it is doing it that way?

Also, you need to tag your Subject lines properly with what tree you are targetting with these changes. Either net or net-next.

Thank you.