linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [6/9] ALSA: usb: caiaq: use usb_fill_int_urb()
@ 2018-06-19 21:55 Sebastian Andrzej Siewior
  0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-06-19 21:55 UTC (permalink / raw)
  To: alsa-devel
  Cc: linux-usb, tglx, Takashi Iwai, Jaroslav Kysela,
	Sebastian Andrzej Siewior, Daniel Mack

Using usb_fill_int_urb() helps to find code which initializes an
URB. A grep for members of the struct (like ->complete) reveal lots
of other things, too.

Cc: Daniel Mack <zonque@gmail.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 sound/usb/caiaq/audio.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c
index 15344d39a6cd..e10d5790099f 100644
--- a/sound/usb/caiaq/audio.c
+++ b/sound/usb/caiaq/audio.c
@@ -736,16 +736,17 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret)
 	}
 
 	for (i = 0; i < N_URBS; i++) {
+		void *buf;
+
 		urbs[i] = usb_alloc_urb(FRAMES_PER_URB, GFP_KERNEL);
 		if (!urbs[i]) {
 			*ret = -ENOMEM;
 			return urbs;
 		}
 
-		urbs[i]->transfer_buffer =
-			kmalloc_array(BYTES_PER_FRAME, FRAMES_PER_URB,
-				      GFP_KERNEL);
-		if (!urbs[i]->transfer_buffer) {
+		buf = kmalloc_array(BYTES_PER_FRAME, FRAMES_PER_URB,
+				    GFP_KERNEL);
+		if (!buf) {
 			*ret = -ENOMEM;
 			return urbs;
 		}
@@ -758,15 +759,13 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret)
 			iso->length = BYTES_PER_FRAME;
 		}
 
-		urbs[i]->dev = usb_dev;
-		urbs[i]->pipe = pipe;
-		urbs[i]->transfer_buffer_length = FRAMES_PER_URB
-						* BYTES_PER_FRAME;
-		urbs[i]->context = &cdev->data_cb_info[i];
-		urbs[i]->interval = 1;
+		usb_fill_int_urb(urbs[i], usb_dev, pipe, buf,
+				 FRAMES_PER_URB * BYTES_PER_FRAME,
+				 (dir == SNDRV_PCM_STREAM_CAPTURE) ?
+				 read_completed : write_completed,
+				 &cdev->data_cb_info[i], 1);
+
 		urbs[i]->number_of_packets = FRAMES_PER_URB;
-		urbs[i]->complete = (dir == SNDRV_PCM_STREAM_CAPTURE) ?
-					read_completed : write_completed;
 	}
 
 	*ret = 0;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [6/9] ALSA: usb: caiaq: use usb_fill_int_urb()
@ 2018-06-21 20:19 Daniel Mack
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Mack @ 2018-06-21 20:19 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior, alsa-devel
  Cc: linux-usb, tglx, Takashi Iwai, Jaroslav Kysela

On Tuesday, June 19, 2018 11:55 PM, Sebastian Andrzej Siewior wrote:
> Using usb_fill_int_urb() helps to find code which initializes an
> URB. A grep for members of the struct (like ->complete) reveal lots
> of other things, too.

Acked-by: Daniel Mack <zonque@gmail.com>

> Cc: Jaroslav Kysela <perex@perex.cz>
> Cc: Takashi Iwai <tiwai@suse.com>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>   sound/usb/caiaq/audio.c | 23 +++++++++++------------
>   1 file changed, 11 insertions(+), 12 deletions(-)
> 
> diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c
> index 15344d39a6cd..e10d5790099f 100644
> --- a/sound/usb/caiaq/audio.c
> +++ b/sound/usb/caiaq/audio.c
> @@ -736,16 +736,17 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret)
>   	}
>   
>   	for (i = 0; i < N_URBS; i++) {
> +		void *buf;
> +
>   		urbs[i] = usb_alloc_urb(FRAMES_PER_URB, GFP_KERNEL);
>   		if (!urbs[i]) {
>   			*ret = -ENOMEM;
>   			return urbs;
>   		}
>   
> -		urbs[i]->transfer_buffer =
> -			kmalloc_array(BYTES_PER_FRAME, FRAMES_PER_URB,
> -				      GFP_KERNEL);
> -		if (!urbs[i]->transfer_buffer) {
> +		buf = kmalloc_array(BYTES_PER_FRAME, FRAMES_PER_URB,
> +				    GFP_KERNEL);
> +		if (!buf) {
>   			*ret = -ENOMEM;
>   			return urbs;
>   		}
> @@ -758,15 +759,13 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret)
>   			iso->length = BYTES_PER_FRAME;
>   		}
>   
> -		urbs[i]->dev = usb_dev;
> -		urbs[i]->pipe = pipe;
> -		urbs[i]->transfer_buffer_length = FRAMES_PER_URB
> -						* BYTES_PER_FRAME;
> -		urbs[i]->context = &cdev->data_cb_info[i];
> -		urbs[i]->interval = 1;
> +		usb_fill_int_urb(urbs[i], usb_dev, pipe, buf,
> +				 FRAMES_PER_URB * BYTES_PER_FRAME,
> +				 (dir == SNDRV_PCM_STREAM_CAPTURE) ?
> +				 read_completed : write_completed,
> +				 &cdev->data_cb_info[i], 1);
> +
>   		urbs[i]->number_of_packets = FRAMES_PER_URB;
> -		urbs[i]->complete = (dir == SNDRV_PCM_STREAM_CAPTURE) ?
> -					read_completed : write_completed;
>   	}
>   
>   	*ret = 0;
>
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [6/9] ALSA: usb: caiaq: use usb_fill_int_urb()
@ 2018-06-21 21:16 Sebastian Andrzej Siewior
  0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-06-21 21:16 UTC (permalink / raw)
  To: Daniel Mack; +Cc: alsa-devel, linux-usb, tglx, Takashi Iwai, Jaroslav Kysela

On 2018-06-21 22:19:32 [+0200], Daniel Mack wrote:
> On Tuesday, June 19, 2018 11:55 PM, Sebastian Andrzej Siewior wrote:
> > Using usb_fill_int_urb() helps to find code which initializes an
> > URB. A grep for members of the struct (like ->complete) reveal lots
> > of other things, too.
> 
> Acked-by: Daniel Mack <zonque@gmail.com>

nope, please don't.
Takashi, please ignore the usb_fill_.* patches. I will be doing another
spin with usb_fill_iso_urb() instead.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [6/9] ALSA: usb: caiaq: use usb_fill_int_urb()
@ 2018-06-22  8:49 Takashi Iwai
  0 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2018-06-22  8:49 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior; +Cc: Daniel Mack, alsa-devel, linux-usb, tglx

On Thu, 21 Jun 2018 23:16:39 +0200,
Sebastian Andrzej Siewior wrote:
> 
> On 2018-06-21 22:19:32 [+0200], Daniel Mack wrote:
> > On Tuesday, June 19, 2018 11:55 PM, Sebastian Andrzej Siewior wrote:
> > > Using usb_fill_int_urb() helps to find code which initializes an
> > > URB. A grep for members of the struct (like ->complete) reveal lots
> > > of other things, too.
> > 
> > Acked-by: Daniel Mack <zonque@gmail.com>
> 
> nope, please don't.
> Takashi, please ignore the usb_fill_.* patches. I will be doing another
> spin with usb_fill_iso_urb() instead.

This sounds like a better approach, indeed.


thanks,

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [6/9] ALSA: usb: caiaq: use usb_fill_int_urb()
@ 2018-06-22 10:01 Daniel Mack
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Mack @ 2018-06-22 10:01 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: alsa-devel, linux-usb, tglx, Takashi Iwai, Jaroslav Kysela

On Thursday, June 21, 2018 11:16 PM, Sebastian Andrzej Siewior wrote:
> On 2018-06-21 22:19:32 [+0200], Daniel Mack wrote:
>> On Tuesday, June 19, 2018 11:55 PM, Sebastian Andrzej Siewior wrote:
>>> Using usb_fill_int_urb() helps to find code which initializes an
>>> URB. A grep for members of the struct (like ->complete) reveal lots
>>> of other things, too.
>>
>> Acked-by: Daniel Mack <zonque@gmail.com>
> 
> nope, please don't.
> Takashi, please ignore the usb_fill_.* patches. I will be doing another
> spin with usb_fill_iso_urb() instead.

Hmm, there is no such thing as usb_fill_iso_urb() in my tree, are you 
going to add that?

The only part that needs attention is the interval parameter, which is 
passed to usb_fill_int_urb() as 1 now, and hence urb->interval will also 
be 1, just like the open-coded version before. Unless I miss anything, 
your conversion should work, but I haven't tested it yet.

But I agree the function name is misleading, so we should probably get a 
usb_fill_iso_urb() and use it where appropriate. AFAICS, it will be 
identical to usb_fill_bulk_urb(), as the endpoint type is encoded in the 
pipe. Maybe it's worth adding a check?


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [6/9] ALSA: usb: caiaq: use usb_fill_int_urb()
@ 2018-06-22 10:14 Sebastian Andrzej Siewior
  0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Andrzej Siewior @ 2018-06-22 10:14 UTC (permalink / raw)
  To: Daniel Mack; +Cc: alsa-devel, linux-usb, tglx, Takashi Iwai, Jaroslav Kysela

On 2018-06-22 12:01:13 [+0200], Daniel Mack wrote:
> Hmm, there is no such thing as usb_fill_iso_urb() in my tree, are you going
> to add that?

Yes.

> The only part that needs attention is the interval parameter, which is
> passed to usb_fill_int_urb() as 1 now, and hence urb->interval will also be
> 1, just like the open-coded version before. Unless I miss anything, your
> conversion should work, but I haven't tested it yet.

It should work in most cases. The point is that the argument expects
bInterval (from the endpoint) which has a different encoding on FS vs
HS/SS for INTR endpoints but not for ISOC endpoints and I got this wrong
initially.

> But I agree the function name is misleading, so we should probably get a
> usb_fill_iso_urb() and use it where appropriate. AFAICS, it will be
> identical to usb_fill_bulk_urb(), as the endpoint type is encoded in the
> pipe. Maybe it's worth adding a check?

What check?
it should be identical to INTR without the speed check (always the HS
version should be used). I need to check if it makes sense to extend the
parameters to cover ->number_of_packets and so on.
Any way, I plan to first RFC the function, land it upstream and then
convert the users.

> Thanks,
> Daniel

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-06-22 10:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-19 21:55 [6/9] ALSA: usb: caiaq: use usb_fill_int_urb() Sebastian Andrzej Siewior
  -- strict thread matches above, loose matches on Subject: below --
2018-06-21 20:19 Daniel Mack
2018-06-21 21:16 Sebastian Andrzej Siewior
2018-06-22  8:49 Takashi Iwai
2018-06-22 10:01 Daniel Mack
2018-06-22 10:14 Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).