[PATCH 7/7] usb/isp1760: Cleanup and bugfixes

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

 



This patch series is meant to clean up the code (removing more of the legacy from the original and quite frankly horrible Philips drivers), and also contain some small bug fixes.

* Patch 7: Remove "toggle" member from struct isp1760_qtd, and store toggle status in struct isp1760_qh only.

 drivers/usb/host/isp1760-hcd.c |   55 ++++++++++++-------------------
 1 file changed, 22 insertions(+), 33 deletions(-)

diff -Nurp linux-2.6.37-isp1760-006/drivers/usb/host/isp1760-hcd.c linux-2.6.37-isp1760-007/drivers/usb/host/isp1760-hcd.c
--- linux-2.6.37-isp1760-006/drivers/usb/host/isp1760-hcd.c	2011-02-23 13:26:59.321345798 +0100
+++ linux-2.6.37-isp1760-007/drivers/usb/host/isp1760-hcd.c	2011-02-23 13:29:18.225095730 +0100
@@ -77,8 +77,6 @@ static inline struct isp1760_hcd *hcd_to
 
 struct isp1760_qtd {
 	u8 packet_type;
-	u8 toggle;
-
 	void *data_buffer;
 	u32 payload_addr;
 
@@ -576,6 +574,18 @@ static u32 base_to_chip(u32 base)
 	return ((base - 0x400) >> 3);
 }
 
+static int last_qtd_of_urb(struct isp1760_qtd *qtd, struct isp1760_qh *qh)
+{
+	struct urb *urb;
+
+	if (list_is_last(&qtd->qtd_list, &qh->qtd_list))
+		return 1;
+
+	urb = qtd->urb;
+	qtd = list_entry(qtd->qtd_list.next, typeof(*qtd), qtd_list);
+	return (qtd->urb != urb);
+}
+
 static void transform_into_atl(struct isp1760_qh *qh,
 			struct isp1760_qtd *qtd, struct ptd *ptd)
 {
@@ -643,11 +653,14 @@ static void transform_into_atl(struct is
 	ptd->dw3 |= PTD_NAC_CNT(nak);
 
 	/* DW3 */
-	if (usb_pipecontrol(qtd->urb->pipe))
-		ptd->dw3 |= PTD_DATA_TOGGLE(qtd->toggle);
-	else
-		ptd->dw3 |= qh->toggle;
-
+	ptd->dw3 |= qh->toggle;
+	if (usb_pipecontrol(qtd->urb->pipe)) {
+		if (qtd->data_buffer == qtd->urb->setup_packet) {
+			ptd->dw3 &= ~PTD_DATA_TOGGLE(1);
+		} else if (last_qtd_of_urb(qtd, qh)) {
+			ptd->dw3 |= PTD_DATA_TOGGLE(1);
+		}
+	}
 
 	ptd->dw3 |= PTD_ACTIVE;
 	/* Cerr */
@@ -719,7 +732,6 @@ static int qtd_fill(struct isp1760_qtd *
 
 	qtd->data_buffer = databuffer;
 	qtd->packet_type = GET_QTD_TOKEN_TYPE(token);
-	qtd->toggle = GET_DATA_TOGGLE(token);
 
 	if (len > MAX_PAYLOAD_SIZE)
 		count = MAX_PAYLOAD_SIZE;
@@ -954,18 +966,6 @@ static struct isp1760_qtd *clean_up_qtdl
 	return qtd;
 }
 
-static int last_qtd_of_urb(struct isp1760_qtd *qtd, struct isp1760_qh *qh)
-{
-	struct urb *urb;
-
-	if (list_is_last(&qtd->qtd_list, &qh->qtd_list))
-		return 1;
-
-	urb = qtd->urb;
-	qtd = list_entry(qtd->qtd_list.next, typeof(*qtd), qtd_list);
-	return (qtd->urb != urb);
-}
-
 static void do_atl_int(struct usb_hcd *hcd)
 {
 	struct isp1760_hcd *priv = hcd_to_priv(hcd);
@@ -1079,12 +1079,8 @@ static void do_atl_int(struct usb_hcd *h
 			priv->atl_ints[slot].qh->ping = 0;
 			qtd->urb->status = -EPIPE;
 		} else {
-			if (usb_pipetype(qtd->urb->pipe) == PIPE_BULK) {
-				priv->atl_ints[slot].qh->toggle = ptd.dw3 &
-					(1 << 25);
-				priv->atl_ints[slot].qh->ping = ptd.dw3 &
-					(1 << 26);
-			}
+			priv->atl_ints[slot].qh->toggle = ptd.dw3 & (1 << 25);
+			priv->atl_ints[slot].qh->ping = ptd.dw3 & (1 << 26);
 		}
 
 		length = PTD_XFERRED_LENGTH(ptd.dw3);
@@ -1420,7 +1416,6 @@ static struct list_head *qh_urb_transact
 				token | SETUP_PID);
 
 		/* ... and always at least one more pid */
-		token ^= DATA_TOGGLE;
 		qtd = isp1760_qtd_alloc(flags);
 		if (!qtd)
 			goto cleanup;
@@ -1463,10 +1458,6 @@ static struct list_head *qh_urb_transact
 		len -= this_qtd_len;
 		buf += this_qtd_len;
 
-		/* qh makes control packets use qtd toggle; maybe switch it */
-		if ((maxpacket & (this_qtd_len + (maxpacket - 1))) == 0)
-			token ^= DATA_TOGGLE;
-
 		if (len <= 0)
 			break;
 
@@ -1488,8 +1479,6 @@ static struct list_head *qh_urb_transact
 			one_more = 1;
 			/* "in" <--> "out"  */
 			token ^= IN_PID;
-			/* force DATA1 */
-			token |= DATA_TOGGLE;
 		} else if (usb_pipebulk(urb->pipe)
 				&& (urb->transfer_flags & URB_ZERO_PACKET)
 				&& !(urb->transfer_buffer_length % maxpacket)) {

Signed-off-by: Arvid Brodin <arvid.brodin@xxxxxxxx>

-- 
Arvid Brodin
Enea Services Stockholm AB


--
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