Re: patch to shift memory allocations to usb_alloc_urb()

Oliver Neukum <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
Am Freitag, 29. Juni 2007 schrieb Alan Stern:
> On Fri, 29 Jun 2007, Oliver Neukum wrote:
> 
> > Hi,
> > 
> > this proved harder than it looks like. I can use cdc-acm over ohci with
> > this patch. So what do you think?
> 
> It tries to do an awful lot all at once.  A good place to start would 
> be to use separate allocation for the Iso packet structures.  This 
> could be a simple standalone change.

Here's a patch separating the iso structures. This will allow unification
of the urb priv structures and the official urb. In addition pools specific
to hcds can be used.
Is that what you had in mind?

	Regards
		Oliver
----

diff -urp linux-2.6.22rc6vanilla/include/linux/usb.h linux-2.6.22-rc6-iso/include/linux/usb.h
--- linux-2.6.22rc6vanilla/include/linux/usb.h	2007-06-29 13:33:17.000000000 +0200
+++ linux-2.6.22-rc6-iso/include/linux/usb.h	2007-06-29 22:31:29.000000000 +0200
@@ -1152,7 +1152,7 @@ struct urb
 	int error_count;		/* (return) number of ISO errors */
 	void *context;			/* (in) context for completion */
 	usb_complete_t complete;	/* (in) completion routine */
-	struct usb_iso_packet_descriptor iso_frame_desc[0];
+	struct usb_iso_packet_descriptor *iso_frames;
 					/* (in) ISO ONLY */
 };
 
diff -urp linux-2.6.22rc6vanilla/sound/usb/caiaq/caiaq-audio.c linux-2.6.22-rc6-iso/sound/usb/caiaq/caiaq-audio.c
--- linux-2.6.22rc6vanilla/sound/usb/caiaq/caiaq-audio.c	2007-06-29 13:33:36.000000000 +0200
+++ linux-2.6.22-rc6-iso/sound/usb/caiaq/caiaq-audio.c	2007-06-30 00:41:26.000000000 +0200
@@ -483,17 +483,17 @@ static void read_completed(struct urb *u
 	/* read the recently received packet and send back one which has
 	 * the same layout */
 	for (frame = 0; frame < FRAMES_PER_URB; frame++) {
-		if (urb->iso_frame_desc[frame].status)
+		if (urb->iso_frames[frame].status)
 			continue;
 
-		len = urb->iso_frame_desc[outframe].actual_length;
-		out->iso_frame_desc[outframe].length = len;
-		out->iso_frame_desc[outframe].actual_length = 0;
-		out->iso_frame_desc[outframe].offset = BYTES_PER_FRAME * frame;
+		len = urb->iso_frames[outframe].actual_length;
+		out->iso_frames[outframe].length = len;
+		out->iso_frames[outframe].actual_length = 0;
+		out->iso_frames[outframe].offset = BYTES_PER_FRAME * frame;
 		
 		if (len > 0) {
-			fill_out_urb(dev, out, &out->iso_frame_desc[outframe]);
-			read_in_urb(dev, urb, &urb->iso_frame_desc[frame]);
+			fill_out_urb(dev, out, &out->iso_frames[outframe]);
+			read_in_urb(dev, urb, &urb->iso_frames[frame]);
 			send_it = 1;
 		}
 
@@ -508,9 +508,9 @@ static void read_completed(struct urb *u
 	
 	/* re-submit inbound urb */
 	for (frame = 0; frame < FRAMES_PER_URB; frame++) {
-		urb->iso_frame_desc[frame].offset = BYTES_PER_FRAME * frame;
-		urb->iso_frame_desc[frame].length = BYTES_PER_FRAME;
-		urb->iso_frame_desc[frame].actual_length = 0;
+		urb->iso_frames[frame].offset = BYTES_PER_FRAME * frame;
+		urb->iso_frames[frame].length = BYTES_PER_FRAME;
+		urb->iso_frames[frame].actual_length = 0;
 	}
 	
 	urb->number_of_packets = FRAMES_PER_URB;
@@ -565,7 +565,7 @@ static struct urb **alloc_urbs(struct sn
 		
 		for (frame = 0; frame < FRAMES_PER_URB; frame++) {
 			struct usb_iso_packet_descriptor *iso = 
-				&urbs[i]->iso_frame_desc[frame];
+				&urbs[i]->iso_frames[frame];
 			
 			iso->offset = BYTES_PER_FRAME * frame;
 			iso->length = BYTES_PER_FRAME;
diff -urp linux-2.6.22rc6vanilla/sound/usb/usbaudio.c linux-2.6.22-rc6-iso/sound/usb/usbaudio.c
--- linux-2.6.22rc6vanilla/sound/usb/usbaudio.c	2007-06-29 13:33:36.000000000 +0200
+++ linux-2.6.22-rc6-iso/sound/usb/usbaudio.c	2007-06-30 00:39:14.000000000 +0200
@@ -257,8 +257,8 @@ static int prepare_capture_sync_urb(stru
 	struct snd_urb_ctx *ctx = urb->context;
 
 	urb->dev = ctx->subs->dev; /* we need to set this at each time */
-	urb->iso_frame_desc[0].length = 3;
-	urb->iso_frame_desc[0].offset = 0;
+	urb->iso_frames[0].length = 3;
+	urb->iso_frames[0].offset = 0;
 	cp[0] = subs->freqn >> 2;
 	cp[1] = subs->freqn >> 10;
 	cp[2] = subs->freqn >> 18;
@@ -279,8 +279,8 @@ static int prepare_capture_sync_urb_hs(s
 	struct snd_urb_ctx *ctx = urb->context;
 
 	urb->dev = ctx->subs->dev; /* we need to set this at each time */
-	urb->iso_frame_desc[0].length = 4;
-	urb->iso_frame_desc[0].offset = 0;
+	urb->iso_frames[0].length = 4;
+	urb->iso_frames[0].offset = 0;
 	cp[0] = subs->freqn;
 	cp[1] = subs->freqn >> 8;
 	cp[2] = subs->freqn >> 16;
@@ -319,8 +319,8 @@ static int prepare_capture_urb(struct sn
 	offs = 0;
 	urb->dev = ctx->subs->dev; /* we need to set this at each time */
 	for (i = 0; i < ctx->packets; i++) {
-		urb->iso_frame_desc[i].offset = offs;
-		urb->iso_frame_desc[i].length = subs->curpacksize;
+		urb->iso_frames[i].offset = offs;
+		urb->iso_frames[i].length = subs->curpacksize;
 		offs += subs->curpacksize;
 	}
 	urb->transfer_buffer_length = offs;
@@ -347,12 +347,12 @@ static int retire_capture_urb(struct snd
 	stride = runtime->frame_bits >> 3;
 
 	for (i = 0; i < urb->number_of_packets; i++) {
-		cp = (unsigned char *)urb->transfer_buffer + urb->iso_frame_desc[i].offset;
-		if (urb->iso_frame_desc[i].status) {
-			snd_printd(KERN_ERR "frame %d active: %d\n", i, urb->iso_frame_desc[i].status);
+		cp = (unsigned char *)urb->transfer_buffer + urb->iso_frames[i].offset;
+		if (urb->iso_frames[i].status) {
+			snd_printd(KERN_ERR "frame %d active: %d\n", i, urb->iso_frames[i].status);
 			// continue;
 		}
-		len = urb->iso_frame_desc[i].actual_length / stride;
+		len = urb->iso_frames[i].actual_length / stride;
 		if (! len)
 			continue;
 		/* update the current pointer */
@@ -406,8 +406,8 @@ static int prepare_playback_sync_urb(str
 	struct snd_urb_ctx *ctx = urb->context;
 
 	urb->dev = ctx->subs->dev; /* we need to set this at each time */
-	urb->iso_frame_desc[0].length = 3;
-	urb->iso_frame_desc[0].offset = 0;
+	urb->iso_frames[0].length = 3;
+	urb->iso_frames[0].offset = 0;
 	return 0;
 }
 
@@ -424,8 +424,8 @@ static int prepare_playback_sync_urb_hs(
 	struct snd_urb_ctx *ctx = urb->context;
 
 	urb->dev = ctx->subs->dev; /* we need to set this at each time */
-	urb->iso_frame_desc[0].length = 4;
-	urb->iso_frame_desc[0].offset = 0;
+	urb->iso_frames[0].length = 4;
+	urb->iso_frames[0].offset = 0;
 	return 0;
 }
 
@@ -442,8 +442,8 @@ static int retire_playback_sync_urb(stru
 	unsigned int f;
 	unsigned long flags;
 
-	if (urb->iso_frame_desc[0].status == 0 &&
-	    urb->iso_frame_desc[0].actual_length == 3) {
+	if (urb->iso_frames[0].status == 0 &&
+	    urb->iso_frames[0].actual_length == 3) {
 		f = combine_triple((u8*)urb->transfer_buffer) << 2;
 		if (f >= subs->freqn - subs->freqn / 8 && f <= subs->freqmax) {
 			spin_lock_irqsave(&subs->lock, flags);
@@ -468,8 +468,8 @@ static int retire_playback_sync_urb_hs(s
 	unsigned int f;
 	unsigned long flags;
 
-	if (urb->iso_frame_desc[0].status == 0 &&
-	    urb->iso_frame_desc[0].actual_length == 4) {
+	if (urb->iso_frames[0].status == 0 &&
+	    urb->iso_frames[0].actual_length == 4) {
 		f = combine_quad((u8*)urb->transfer_buffer) & 0x0fffffff;
 		if (f >= subs->freqn - subs->freqn / 8 && f <= subs->freqmax) {
 			spin_lock_irqsave(&subs->lock, flags);
@@ -511,8 +511,8 @@ static int prepare_nodata_playback_urb(s
 	urb->number_of_packets = subs->packs_per_ms;
 	for (i = 0; i < subs->packs_per_ms; ++i) {
 		counts = snd_usb_audio_next_packet_size(subs);
-		urb->iso_frame_desc[i].offset = offs * stride;
-		urb->iso_frame_desc[i].length = counts * stride;
+		urb->iso_frames[i].offset = offs * stride;
+		urb->iso_frames[i].length = counts * stride;
 		offs += counts;
 	}
 	urb->transfer_buffer_length = offs * stride;
@@ -549,8 +549,8 @@ static int prepare_playback_urb(struct s
 	for (i = 0; i < ctx->packets; i++) {
 		counts = snd_usb_audio_next_packet_size(subs);
 		/* set up descriptor */
-		urb->iso_frame_desc[i].offset = offs * stride;
-		urb->iso_frame_desc[i].length = counts * stride;
+		urb->iso_frames[i].offset = offs * stride;
+		urb->iso_frames[i].length = counts * stride;
 		offs += counts;
 		urb->number_of_packets++;
 		subs->transfer_done += counts;
@@ -563,16 +563,16 @@ static int prepare_playback_urb(struct s
 					 * supported yet */
 					offs -= subs->transfer_done;
 					counts -= subs->transfer_done;
-					urb->iso_frame_desc[i].length =
+					urb->iso_frames[i].length =
 						counts * stride;
 					subs->transfer_done = 0;
 				}
 				i++;
 				if (i < ctx->packets) {
 					/* add a transfer delimiter */
-					urb->iso_frame_desc[i].offset =
+					urb->iso_frames[i].offset =
 						offs * stride;
-					urb->iso_frame_desc[i].length = 0;
+					urb->iso_frames[i].length = 0;
 					urb->number_of_packets++;
 				}
 				break;
diff -urp linux-2.6.22rc6vanilla/sound/usb/usx2y/usbusx2yaudio.c linux-2.6.22-rc6-iso/sound/usb/usx2y/usbusx2yaudio.c
--- linux-2.6.22rc6vanilla/sound/usb/usx2y/usbusx2yaudio.c	2007-02-04 19:44:54.000000000 +0100
+++ linux-2.6.22-rc6-iso/sound/usb/usx2y/usbusx2yaudio.c	2007-06-30 00:46:30.000000000 +0200
@@ -76,14 +76,14 @@ static int usX2Y_urb_capt_retire(struct 
 	struct usX2Ydev	*usX2Y = subs->usX2Y;
 
 	for (i = 0; i < nr_of_packs(); i++) {
-		cp = (unsigned char*)urb->transfer_buffer + urb->iso_frame_desc[i].offset;
-		if (urb->iso_frame_desc[i].status) { /* active? hmm, skip this */
+		cp = (unsigned char*)urb->transfer_buffer + urb->iso_frames[i].offset;
+		if (urb->iso_frames[i].status) { /* active? hmm, skip this */
 			snd_printk(KERN_ERR "active frame status %i. "
 				   "Most propably some hardware problem.\n",
-				   urb->iso_frame_desc[i].status);
-			return urb->iso_frame_desc[i].status;
+				   urb->iso_frames[i].status);
+			return urb->iso_frames[i].status;
 		}
-		len = urb->iso_frame_desc[i].actual_length / usX2Y->stride;
+		len = urb->iso_frames[i].actual_length / usX2Y->stride;
 		if (! len) {
 			snd_printd("0 == len ERROR!\n");
 			continue;
@@ -134,18 +134,18 @@ static int usX2Y_urb_play_prepare(struct
 	count = 0;
 	for (pack = 0; pack <  nr_of_packs(); pack++) {
 		/* calculate the size of a packet */
-		counts = cap_urb->iso_frame_desc[pack].actual_length / usX2Y->stride;
+		counts = cap_urb->iso_frames[pack].actual_length / usX2Y->stride;
 		count += counts;
 		if (counts < 43 || counts > 50) {
 			snd_printk(KERN_ERR "should not be here with counts=%i\n", counts);
 			return -EPIPE;
 		}
 		/* set up descriptor */
-		urb->iso_frame_desc[pack].offset = pack ?
-			urb->iso_frame_desc[pack - 1].offset +
-			urb->iso_frame_desc[pack - 1].length :
+		urb->iso_frames[pack].offset = pack ?
+			urb->iso_frames[pack - 1].offset +
+			urb->iso_frames[pack - 1].length :
 			0;
-		urb->iso_frame_desc[pack].length = cap_urb->iso_frame_desc[pack].actual_length;
+		urb->iso_frames[pack].length = cap_urb->iso_frames[pack].actual_length;
 	}
 	if (atomic_read(&subs->state) >= state_PRERUNNING)
 		if (subs->hwptr + count > runtime->buffer_size) {
@@ -503,8 +503,8 @@ static int usX2Y_urbs_start(struct snd_u
 			urb->dev = usX2Y->chip.dev;
 			urb->transfer_flags = URB_ISO_ASAP;
 			for (pack = 0; pack < nr_of_packs(); pack++) {
-				urb->iso_frame_desc[pack].offset = subs->maxpacksize * pack;
-				urb->iso_frame_desc[pack].length = subs->maxpacksize;
+				urb->iso_frames[pack].offset = subs->maxpacksize * pack;
+				urb->iso_frames[pack].length = subs->maxpacksize;
 			}
 			urb->transfer_buffer_length = subs->maxpacksize * nr_of_packs(); 
 			if ((err = usb_submit_urb(urb, GFP_ATOMIC)) < 0) {
diff -urp linux-2.6.22rc6vanilla/sound/usb/usx2y/usx2yhwdeppcm.c linux-2.6.22-rc6-iso/sound/usb/usx2y/usx2yhwdeppcm.c
--- linux-2.6.22rc6vanilla/sound/usb/usx2y/usx2yhwdeppcm.c	2007-02-04 19:44:54.000000000 +0100
+++ linux-2.6.22-rc6-iso/sound/usb/usx2y/usx2yhwdeppcm.c	2007-06-30 00:45:32.000000000 +0200
@@ -72,11 +72,11 @@ static int usX2Y_usbpcm_urb_capt_retire(
 		snd_printdd("cap start %i\n", head);
 	}
 	for (i = 0; i < nr_of_packs(); i++) {
-		if (urb->iso_frame_desc[i].status) { /* active? hmm, skip this */
-			snd_printk(KERN_ERR "activ frame status %i. Most propably some hardware problem.\n", urb->iso_frame_desc[i].status);
-			return urb->iso_frame_desc[i].status;
+		if (urb->iso_frames[i].status) { /* active? hmm, skip this */
+			snd_printk(KERN_ERR "activ frame status %i. Most propably some hardware problem.\n", urb->iso_frames[i].status);
+			return urb->iso_frames[i].status;
 		}
-		lens += urb->iso_frame_desc[i].actual_length / usX2Y->stride;
+		lens += urb->iso_frames[i].actual_length / usX2Y->stride;
 	}
 	if ((hwptr_done += lens) >= runtime->buffer_size)
 		hwptr_done -= runtime->buffer_size;
@@ -131,11 +131,11 @@ static int usX2Y_hwdep_urb_play_prepare(
 			return -EPIPE;
 		}
 		/* set up descriptor */
-		urb->iso_frame_desc[pack].offset = shm->captured_iso[shm->playback_iso_head].offset;
-		urb->iso_frame_desc[pack].length = shm->captured_iso[shm->playback_iso_head].length;
+		urb->iso_frames[pack].offset = shm->captured_iso[shm->playback_iso_head].offset;
+		urb->iso_frames[pack].length = shm->captured_iso[shm->playback_iso_head].length;
 		if (atomic_read(&subs->state) != state_RUNNING)
-			memset((char *)urb->transfer_buffer + urb->iso_frame_desc[pack].offset, 0,
-			       urb->iso_frame_desc[pack].length);
+			memset((char *)urb->transfer_buffer + urb->iso_frames[pack].offset, 0,
+			       urb->iso_frames[pack].length);
 		if (++shm->playback_iso_head >= ARRAY_SIZE(shm->captured_iso))
 			shm->playback_iso_head = 0;
 		count += counts;
@@ -150,7 +150,7 @@ static inline void usX2Y_usbpcm_urb_capt
 {
 	int pack;
 	for (pack = 0; pack < nr_of_packs(); ++pack) {
-		struct usb_iso_packet_descriptor *desc = urb->iso_frame_desc + pack;
+		struct usb_iso_packet_descriptor *desc = urb->iso_frames + pack;
 		if (NULL != subs) {
 			struct snd_usX2Y_hwdep_pcm_shm *shm = subs->usX2Y->hwdep_pcm_shm;
 			int head = shm->captured_iso_head + 1;
@@ -444,8 +444,8 @@ static int usX2Y_usbpcm_urbs_start(struc
 					urb->dev = usX2Y->chip.dev;
 					urb->transfer_flags = URB_ISO_ASAP;
 					for (pack = 0; pack < nr_of_packs(); pack++) {
-						urb->iso_frame_desc[pack].offset = subs->maxpacksize * (pack + u * nr_of_packs());
-						urb->iso_frame_desc[pack].length = subs->maxpacksize;
+						urb->iso_frames[pack].offset = subs->maxpacksize * (pack + u * nr_of_packs());
+						urb->iso_frames[pack].length = subs->maxpacksize;
 					}
 					urb->transfer_buffer_length = subs->maxpacksize * nr_of_packs(); 
 					if ((err = usb_submit_urb(urb, GFP_KERNEL)) < 0) {
diff -urp linux-2.6.22rc6vanilla/drivers/media/dvb/b2c2/flexcop-usb.c linux-2.6.22-rc6-iso/drivers/media/dvb/b2c2/flexcop-usb.c
--- linux-2.6.22rc6vanilla/drivers/media/dvb/b2c2/flexcop-usb.c	2007-02-04 19:44:54.000000000 +0100
+++ linux-2.6.22-rc6-iso/drivers/media/dvb/b2c2/flexcop-usb.c	2007-06-30 00:09:07.000000000 +0200
@@ -337,18 +337,18 @@ static void flexcop_usb_urb_complete(str
 		deb_ts("urb completed, bufsize: %d actlen; %d\n",urb->transfer_buffer_length, urb->actual_length);
 
 	for (i = 0; i < urb->number_of_packets; i++) {
-		if (urb->iso_frame_desc[i].status < 0) {
-			err("iso frame descriptor %d has an error: %d\n",i,urb->iso_frame_desc[i].status);
+		if (urb->iso_frames[i].status < 0) {
+			err("iso frame descriptor %d has an error: %d\n",i,urb->iso_frames[i].status);
 		} else
-			if (urb->iso_frame_desc[i].actual_length > 0) {
-				deb_ts("passed %d bytes to the demux\n",urb->iso_frame_desc[i].actual_length);
+			if (urb->iso_frames[i].actual_length > 0) {
+				deb_ts("passed %d bytes to the demux\n",urb->iso_frames[i].actual_length);
 
 				flexcop_usb_process_frame(fc_usb,
-					urb->transfer_buffer + urb->iso_frame_desc[i].offset,
-					urb->iso_frame_desc[i].actual_length);
+					urb->transfer_buffer + urb->iso_frames[i].offset,
+					urb->iso_frames[i].actual_length);
 		}
-		urb->iso_frame_desc[i].status = 0;
-		urb->iso_frame_desc[i].actual_length = 0;
+		urb->iso_frames[i].status = 0;
+		urb->iso_frames[i].actual_length = 0;
 	}
 
 	usb_submit_urb(urb,GFP_ATOMIC);
@@ -414,8 +414,8 @@ static int flexcop_usb_transfer_init(str
 		buffer_offset += frame_size * B2C2_USB_FRAMES_PER_ISO;
 		for (j = 0; j < B2C2_USB_FRAMES_PER_ISO; j++) {
 			deb_ts("urb no: %d, frame: %d, frame_offset: %d\n",i,j,frame_offset);
-			urb->iso_frame_desc[j].offset = frame_offset;
-			urb->iso_frame_desc[j].length = frame_size;
+			urb->iso_frames[j].offset = frame_offset;
+			urb->iso_frames[j].length = frame_size;
 			frame_offset += frame_size;
 		}
 
diff -urp linux-2.6.22rc6vanilla/drivers/media/dvb/dvb-usb/usb-urb.c linux-2.6.22-rc6-iso/drivers/media/dvb/dvb-usb/usb-urb.c
--- linux-2.6.22rc6vanilla/drivers/media/dvb/dvb-usb/usb-urb.c	2007-02-04 19:44:54.000000000 +0100
+++ linux-2.6.22-rc6-iso/drivers/media/dvb/dvb-usb/usb-urb.c	2007-06-30 00:11:47.000000000 +0200
@@ -41,13 +41,13 @@ static void usb_urb_complete(struct urb 
 		case PIPE_ISOCHRONOUS:
 			for (i = 0; i < urb->number_of_packets; i++) {
 
-				if (urb->iso_frame_desc[i].status != 0)
-					deb_ts("iso frame descriptor has an error: %d\n",urb->iso_frame_desc[i].status);
-				else if (urb->iso_frame_desc[i].actual_length > 0)
-					stream->complete(stream, b + urb->iso_frame_desc[i].offset, urb->iso_frame_desc[i].actual_length);
+				if (urb->iso_frames[i].status != 0)
+					deb_ts("iso frame descriptor has an error: %d\n",urb->iso_frames[i].status);
+				else if (urb->iso_frames[i].actual_length > 0)
+					stream->complete(stream, b + urb->iso_frames[i].offset, urb->iso_frames[i].actual_length);
 
-				urb->iso_frame_desc[i].status = 0;
-				urb->iso_frame_desc[i].actual_length = 0;
+				urb->iso_frames[i].status = 0;
+				urb->iso_frames[i].actual_length = 0;
 			}
 			debug_dump(b,20,deb_uxfer);
 			break;
@@ -188,8 +188,8 @@ static int usb_isoc_urb_init(struct usb_
 		urb->transfer_dma = stream->dma_addr[i];
 
 		for (j = 0; j < stream->props.u.isoc.framesperurb; j++) {
-			urb->iso_frame_desc[j].offset = frame_offset;
-			urb->iso_frame_desc[j].length = stream->props.u.isoc.framesize;
+			urb->iso_frames[j].offset = frame_offset;
+			urb->iso_frames[j].length = stream->props.u.isoc.framesize;
 			frame_offset += stream->props.u.isoc.framesize;
 		}
 
diff -urp linux-2.6.22rc6vanilla/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c linux-2.6.22-rc6-iso/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
--- linux-2.6.22rc6vanilla/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c	2007-06-29 13:27:42.000000000 +0200
+++ linux-2.6.22-rc6-iso/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c	2007-06-30 00:27:28.000000000 +0200
@@ -765,7 +765,7 @@ static void ttusb_iso_irq(struct urb *ur
 				lastj = jiffies;
 				numpkt = 0;
 			}
-			d = &urb->iso_frame_desc[i];
+			d = &urb->iso_frames[i];
 			data = urb->transfer_buffer + d->offset;
 			len = d->actual_length;
 			d->actual_length = 0;
@@ -859,8 +859,8 @@ static int ttusb_start_iso_xfer(struct t
 		buffer_offset += ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF;
 
 		for (j = 0; j < FRAMES_PER_ISO_BUF; j++) {
-			urb->iso_frame_desc[j].offset = frame_offset;
-			urb->iso_frame_desc[j].length = ISO_FRAME_SIZE;
+			urb->iso_frames[j].offset = frame_offset;
+			urb->iso_frames[j].length = ISO_FRAME_SIZE;
 			frame_offset += ISO_FRAME_SIZE;
 		}
 	}
diff -urp linux-2.6.22rc6vanilla/drivers/media/dvb/ttusb-dec/ttusb_dec.c linux-2.6.22-rc6-iso/drivers/media/dvb/ttusb-dec/ttusb_dec.c
--- linux-2.6.22rc6vanilla/drivers/media/dvb/ttusb-dec/ttusb_dec.c	2007-06-29 13:27:42.000000000 +0200
+++ linux-2.6.22-rc6-iso/drivers/media/dvb/ttusb-dec/ttusb_dec.c	2007-06-30 00:34:49.000000000 +0200
@@ -769,7 +769,7 @@ static void ttusb_dec_process_urb(struct
 			int length;
 			struct urb_frame *frame;
 
-			d = &urb->iso_frame_desc[i];
+			d = &urb->iso_frames[i];
 			b = urb->transfer_buffer + d->offset;
 			length = d->actual_length;
 
@@ -824,8 +824,8 @@ static void ttusb_dec_setup_urbs(struct 
 		buffer_offset += ISO_FRAME_SIZE * FRAMES_PER_ISO_BUF;
 
 		for (j = 0; j < FRAMES_PER_ISO_BUF; j++) {
-			urb->iso_frame_desc[j].offset = frame_offset;
-			urb->iso_frame_desc[j].length = ISO_FRAME_SIZE;
+			urb->iso_frames[j].offset = frame_offset;
+			urb->iso_frames[j].length = ISO_FRAME_SIZE;
 			frame_offset += ISO_FRAME_SIZE;
 		}
 	}
diff -urp linux-2.6.22rc6vanilla/drivers/usb/core/devio.c linux-2.6.22-rc6-iso/drivers/usb/core/devio.c
--- linux-2.6.22rc6vanilla/drivers/usb/core/devio.c	2007-06-29 13:33:00.000000000 +0200
+++ linux-2.6.22-rc6-iso/drivers/usb/core/devio.c	2007-06-29 23:43:03.000000000 +0200
@@ -1053,8 +1053,8 @@ static int proc_do_submiturb(struct dev_
         as->urb->context = as;
         as->urb->complete = async_completed;
 	for (totlen = u = 0; u < uurb->number_of_packets; u++) {
-		as->urb->iso_frame_desc[u].offset = totlen;
-		as->urb->iso_frame_desc[u].length = isopkt[u].length;
+		as->urb->iso_frames[u].offset = totlen;
+		as->urb->iso_frames[u].length = isopkt[u].length;
 		totlen += isopkt[u].length;
 	}
 	kfree(isopkt);
@@ -1128,10 +1128,10 @@ static int processcompl(struct async *as
 
 	if (usb_pipeisoc(urb->pipe)) {
 		for (i = 0; i < urb->number_of_packets; i++) {
-			if (put_user(urb->iso_frame_desc[i].actual_length,
+			if (put_user(urb->iso_frames[i].actual_length,
 				     &userurb->iso_frame_desc[i].actual_length))
 				return -EFAULT;
-			if (put_user(urb->iso_frame_desc[i].status,
+			if (put_user(urb->iso_frames[i].status,
 				     &userurb->iso_frame_desc[i].status))
 				return -EFAULT;
 		}
@@ -1242,10 +1242,10 @@ static int processcompl_compat(struct as
 
 	if (usb_pipeisoc(urb->pipe)) {
 		for (i = 0; i < urb->number_of_packets; i++) {
-			if (put_user(urb->iso_frame_desc[i].actual_length,
+			if (put_user(urb->iso_frames[i].actual_length,
 				     &userurb->iso_frame_desc[i].actual_length))
 				return -EFAULT;
-			if (put_user(urb->iso_frame_desc[i].status,
+			if (put_user(urb->iso_frames[i].status,
 				     &userurb->iso_frame_desc[i].status))
 				return -EFAULT;
 		}
diff -urp linux-2.6.22rc6vanilla/drivers/usb/core/urb.c linux-2.6.22-rc6-iso/drivers/usb/core/urb.c
--- linux-2.6.22rc6vanilla/drivers/usb/core/urb.c	2007-06-29 13:28:31.000000000 +0200
+++ linux-2.6.22-rc6-iso/drivers/usb/core/urb.c	2007-06-29 23:41:50.000000000 +0200
@@ -11,6 +11,7 @@
 static void urb_destroy(struct kref *kref)
 {
 	struct urb *urb = to_urb(kref);
+	kfree(urb->iso_frames);
 	kfree(urb);
 }
 
@@ -56,15 +57,22 @@ void usb_init_urb(struct urb *urb)
 struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags)
 {
 	struct urb *urb;
+	struct usb_iso_packet_descriptor *frames = NULL;
 
-	urb = kmalloc(sizeof(struct urb) +
-		iso_packets * sizeof(struct usb_iso_packet_descriptor),
-		mem_flags);
+	if (iso_packets) {
+		frames = kmalloc(iso_packets * sizeof(struct usb_iso_packet_descriptor), mem_flags);
+		if (!frames)
+			return NULL;
+	}
+
+	urb = kmalloc(sizeof(struct urb), mem_flags);
 	if (!urb) {
 		err("alloc_urb: kmalloc failed");
+		kfree(frames);
 		return NULL;
 	}
-	usb_init_urb(urb);
+	urb->iso_frames = frames;
+
 	return urb;
 }
 
@@ -278,11 +286,11 @@ int usb_submit_urb(struct urb *urb, gfp_
 		if (urb->number_of_packets <= 0)		    
 			return -EINVAL;
 		for (n = 0; n < urb->number_of_packets; n++) {
-			len = urb->iso_frame_desc[n].length;
+			len = urb->iso_frames[n].length;
 			if (len < 0 || len > max) 
 				return -EMSGSIZE;
-			urb->iso_frame_desc[n].status = -EXDEV;
-			urb->iso_frame_desc[n].actual_length = 0;
+			urb->iso_frames[n].status = -EXDEV;
+			urb->iso_frames[n].actual_length = 0;
 		}
 	}
 
diff -urp linux-2.6.22rc6vanilla/drivers/usb/host/ehci-sched.c linux-2.6.22-rc6-iso/drivers/usb/host/ehci-sched.c
--- linux-2.6.22rc6vanilla/drivers/usb/host/ehci-sched.c	2007-06-29 13:28:33.000000000 +0200
+++ linux-2.6.22-rc6-iso/drivers/usb/host/ehci-sched.c	2007-06-29 23:54:02.000000000 +0200
@@ -1098,8 +1098,8 @@ itd_sched_init (
 		dma_addr_t		buf;
 		u32			trans;
 
-		length = urb->iso_frame_desc [i].length;
-		buf = dma + urb->iso_frame_desc [i].offset;
+		length = urb->iso_frames[i].length;
+		buf = dma + urb->iso_frames[i].offset;
 
 		trans = EHCI_ISOC_ACTIVE;
 		trans |= buf & 0x0fff;
@@ -1568,7 +1568,7 @@ itd_complete (
 		if (likely (itd->index[uframe] == -1))
 			continue;
 		urb_index = itd->index[uframe];
-		desc = &urb->iso_frame_desc [urb_index];
+		desc = &urb->iso_frames[urb_index];
 
 		t = le32_to_cpup (&itd->hw_transaction [uframe]);
 		itd->hw_transaction [uframe] = 0;
@@ -1721,8 +1721,8 @@ sitd_sched_init (
 		dma_addr_t		buf;
 		u32			trans;
 
-		length = urb->iso_frame_desc [i].length & 0x03ff;
-		buf = dma + urb->iso_frame_desc [i].offset;
+		length = urb->iso_frames[i].length & 0x03ff;
+		buf = dma + urb->iso_frames[i].offset;
 
 		trans = SITD_STS_ACTIVE;
 		if (((i + 1) == urb->number_of_packets)
@@ -1939,7 +1939,7 @@ sitd_complete (
 	struct usb_device			*dev;
 
 	urb_index = sitd->index;
-	desc = &urb->iso_frame_desc [urb_index];
+	desc = &urb->iso_frames[urb_index];
 	t = le32_to_cpup (&sitd->hw_results);
 
 	/* report transfer status */
diff -urp linux-2.6.22rc6vanilla/drivers/usb/host/ohci-q.c linux-2.6.22-rc6-iso/drivers/usb/host/ohci-q.c
--- linux-2.6.22rc6vanilla/drivers/usb/host/ohci-q.c	2007-02-04 19:44:54.000000000 +0100
+++ linux-2.6.22-rc6-iso/drivers/usb/host/ohci-q.c	2007-06-29 23:44:53.000000000 +0200
@@ -686,8 +686,8 @@ static void td_submit_urb (
 			frame += cnt * urb->interval;
 			frame &= 0xffff;
 			td_fill (ohci, TD_CC | TD_ISO | frame,
-				data + urb->iso_frame_desc [cnt].offset,
-				urb->iso_frame_desc [cnt].length, urb, cnt);
+				data + urb->iso_frames[cnt].offset,
+				urb->iso_frames[cnt].length, urb, cnt);
 		}
 		periodic = ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs++ == 0
 			&& ohci_to_hcd(ohci)->self.bandwidth_int_reqs == 0;
@@ -732,7 +732,7 @@ static void td_done (struct ohci_hcd *oh
 			return;
 
 		if (usb_pipeout (urb->pipe))
-			dlen = urb->iso_frame_desc [td->index].length;
+			dlen = urb->iso_frames[td->index].length;
 		else {
 			/* short reads are always OK for ISO */
 			if (cc == TD_DATAUNDERRUN)
@@ -740,8 +740,8 @@ static void td_done (struct ohci_hcd *oh
 			dlen = tdPSW & 0x3ff;
 		}
 		urb->actual_length += dlen;
-		urb->iso_frame_desc [td->index].actual_length = dlen;
-		urb->iso_frame_desc [td->index].status = cc_to_error [cc];
+		urb->iso_frames[td->index].actual_length = dlen;
+		urb->iso_frames[td->index].status = cc_to_error [cc];
 
 		if (cc != TD_CC_NOERROR)
 			ohci_vdbg (ohci,
diff -urp linux-2.6.22rc6vanilla/drivers/usb/host/uhci-q.c linux-2.6.22-rc6-iso/drivers/usb/host/uhci-q.c
--- linux-2.6.22rc6vanilla/drivers/usb/host/uhci-q.c	2007-06-29 13:33:01.000000000 +0200
+++ linux-2.6.22-rc6-iso/drivers/usb/host/uhci-q.c	2007-06-29 23:56:19.000000000 +0200
@@ -1305,9 +1305,9 @@ static int uhci_submit_isochronous(struc
 
 		uhci_add_td_to_urbp(td, urbp);
 		uhci_fill_td(td, status, destination |
-				uhci_explen(urb->iso_frame_desc[i].length),
+				uhci_explen(urb->iso_frames[i].length),
 				urb->transfer_dma +
-					urb->iso_frame_desc[i].offset);
+					urb->iso_frames[i].offset);
 	}
 
 	/* Set the interrupt-on-completion flag on the last packet. */
@@ -1321,7 +1321,7 @@ static int uhci_submit_isochronous(struc
 	}
 
 	if (list_empty(&qh->queue)) {
-		qh->iso_packet_desc = &urb->iso_frame_desc[0];
+		qh->iso_packet_desc = urb->iso_frames;
 		qh->iso_frame = urb->start_frame;
 		qh->iso_status = 0;
 	}
@@ -1497,7 +1497,7 @@ __acquires(uhci->lock)
 		struct urb *nurb = list_entry(urbp->node.next,
 				struct urb_priv, node)->urb;
 
-		qh->iso_packet_desc = &nurb->iso_frame_desc[0];
+		qh->iso_packet_desc = nurb->iso_frames;
 		qh->iso_frame = nurb->start_frame;
 		qh->iso_status = 0;
 	}
diff -urp linux-2.6.22rc6vanilla/drivers/usb/mon/mon_text.c linux-2.6.22-rc6-iso/drivers/usb/mon/mon_text.c
--- linux-2.6.22rc6vanilla/drivers/usb/mon/mon_text.c	2007-06-29 13:33:01.000000000 +0200
+++ linux-2.6.22-rc6-iso/drivers/usb/mon/mon_text.c	2007-06-29 23:47:31.000000000 +0200
@@ -223,7 +223,7 @@ static void mon_text_event(struct mon_re
 	if (usb_pipeisoc(urb->pipe) && urb->number_of_packets > 0) {
 		if ((ndesc = urb->number_of_packets) > ISODESC_MAX)
 			ndesc = ISODESC_MAX;
-		fp = urb->iso_frame_desc;
+		fp = urb->iso_frames;
 		dp = ep->isodesc;
 		for (i = 0; i < ndesc; i++) {
 			dp->status = fp->status;

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
[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.