[PATCH 2/3] ehci-hcd: slimm struct ehci_itd, remove index[]

Karsten Wiese <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
ehci_itd's member index[8] stored the offset in an urb's
iso_frame_desc[] for status updates while in itd_scan().
Replace member index[] by new member urb_index.
urb_index is updated in itd_scan() to provide the same
information as index[uframe] did before.
Saves 6*4=24 bytes.

Signed-off-by: Karsten Wiese <[email protected]>
---
 drivers/usb/host/ehci-dbg.c   |    6 ++----
 drivers/usb/host/ehci-sched.c |   25 +++++++++++--------------
 drivers/usb/host/ehci.h       |    4 +++-
 3 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index c9cc441..ef6ea56 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -165,10 +165,8 @@ dbg_itd (const char *label, struct ehci_hcd *ehci, struct ehci_itd *itd)
 		hc32_to_cpu(ehci, itd->hw_bufp[4]),
 		hc32_to_cpu(ehci, itd->hw_bufp[5]),
 		hc32_to_cpu(ehci, itd->hw_bufp[6]));
-	ehci_dbg (ehci, "  index: %d %d %d %d %d %d %d %d\n",
-		itd->index[0], itd->index[1], itd->index[2],
-		itd->index[3], itd->index[4], itd->index[5],
-		itd->index[6], itd->index[7]);
+	ehci_dbg(ehci, "  urb_index: %d  uframe_scan: %d\n",
+		itd->urb_index, itd->uframe_scan);
 }
 
 static void __maybe_unused
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index 2d4fda5..38a7901 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -1430,17 +1430,12 @@ static inline void
 itd_init(struct ehci_hcd *ehci, struct ehci_iso_stream *stream,
 		struct ehci_itd *itd)
 {
-	int i;
-
 	/* it's been recently zeroed */
 	itd->hw_next = EHCI_LIST_END(ehci);
 	itd->hw_bufp [0] = stream->buf0;
 	itd->hw_bufp [1] = stream->buf1;
 	itd->hw_bufp [2] = stream->buf2;
 
-	for (i = 0; i < 8; i++)
-		itd->index[i] = -1;
-
 	/* All other fields are filled when scheduling */
 }
 
@@ -1458,9 +1453,6 @@ itd_patch(
 
 	// BUG_ON (pg == 6 && uf->cross);
 
-	uframe &= 0x07;
-	itd->index [uframe] = index;
-
 	itd->hw_transaction[uframe] = uf->transaction;
 	itd->hw_transaction[uframe] |= cpu_to_hc32(ehci, pg << 12);
 	itd->hw_bufp[pg] |= cpu_to_hc32(ehci, uf->bufp & ~(u32)0);
@@ -1519,6 +1511,7 @@ itd_link_urb (
 
 	/* fill iTDs uframe by uframe */
 	for (packet = 0, itd = NULL; packet < urb->number_of_packets; ) {
+		uframe = next_uframe & 0x07;
 		if (itd == NULL) {
 			/* ASSERT:  we have all necessary itds */
 			// BUG_ON (list_empty (&iso_sched->td_list));
@@ -1531,9 +1524,10 @@ itd_link_urb (
 			itd->stream = iso_stream_get (stream);
 			itd->urb = usb_get_urb (urb);
 			itd_init (ehci, stream, itd);
+			itd->uframe_scan = uframe;
+			itd->urb_index = packet;
 		}
 
-		uframe = next_uframe & 0x07;
 		frame = next_uframe >> 3;
 
 		itd->usecs [uframe] = stream->usecs;
@@ -1576,17 +1570,18 @@ itd_scan(struct ehci_hcd *ehci, struct ehci_itd *itd, unsigned uframe_after)
 	struct usb_iso_packet_descriptor	*desc;
 	u32					t;
 	unsigned				uframe;
-	int					urb_index = -1;
+	int					urb_index;
 	struct ehci_iso_stream			*stream = itd->stream;
 	unsigned				complete = 0;
 
 	/* for each uframe with a packet */
-	for (uframe = itd->uframe_scan; uframe < uframe_after; uframe++) {
+	urb_index = itd->urb_index;
+	uframe = itd->uframe_scan;
+	for (; uframe < uframe_after; uframe += stream->interval) {
 
-		if (likely (itd->index[uframe] == -1))
+		if (!urb)
 			continue;
 
-		urb_index = itd->index[uframe];
 		desc = &urb->iso_frame_desc [urb_index];
 
 		t = hc32_to_cpup(ehci, &itd->hw_transaction [uframe]);
@@ -1616,8 +1611,9 @@ itd_scan(struct ehci_hcd *ehci, struct ehci_itd *itd, unsigned uframe_after)
 			WARN_ON(1);
 		}
 
+		urb_index++;
 		/* handle completion now? */
-		if (urb_index + 1 != urb->number_of_packets)
+		if (urb_index < urb->number_of_packets)
 			continue;
 
 #if 1
@@ -1636,6 +1632,7 @@ itd_scan(struct ehci_hcd *ehci, struct ehci_itd *itd, unsigned uframe_after)
 
 	if (uframe < 8) {
 		itd->uframe_scan = uframe;
+		itd->urb_index = urb_index;
 		return complete;
 	}
 
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index dcd031a..135dfae 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -581,12 +581,14 @@ struct ehci_itd {
 	struct urb		*urb;
 	struct ehci_iso_stream	*stream;	/* endpoint's queue */
 	struct list_head	itd_list;	/* list of stream's itds */
+
+	/* at which uframe to look at which index next in itd_scan() */
 	unsigned		uframe_scan;
+	unsigned		urb_index;	/* in urb->iso_frame_desc[] */
 
 	/* any/all hw_transactions here may be used by that urb */
 	unsigned		frame;		/* where scheduled */
 	unsigned		pg;
-	unsigned		index[8];	/* in urb->iso_frame_desc */
 	u8			usecs[8];
 } __attribute__ ((aligned (32)));
 
-- 
1.5.3.3


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.