From patchwork Tue Jun 19 21:55:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 10475555 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E3C1E60353 for ; Tue, 19 Jun 2018 21:55:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D53B928CCE for ; Tue, 19 Jun 2018 21:55:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA1A728CD4; Tue, 19 Jun 2018 21:55:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6966B28CCE for ; Tue, 19 Jun 2018 21:55:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030232AbeFSVzx (ORCPT ); Tue, 19 Jun 2018 17:55:53 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:58378 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757240AbeFSVzf (ORCPT ); Tue, 19 Jun 2018 17:55:35 -0400 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1fVOb7-0004KO-5V; Tue, 19 Jun 2018 23:55:33 +0200 From: Sebastian Andrzej Siewior To: alsa-devel@alsa-project.org Cc: linux-usb@vger.kernel.org, tglx@linutronix.de, Takashi Iwai , Jaroslav Kysela , Sebastian Andrzej Siewior Subject: [PATCH 8/9] ALSA: usx2y: usbusx2yaudio: use usb_fill_int_urb() Date: Tue, 19 Jun 2018 23:55:20 +0200 Message-Id: <20180619215521.13688-9-bigeasy@linutronix.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619215521.13688-1-bigeasy@linutronix.de> References: <20180619215521.13688-1-bigeasy@linutronix.de> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. The "&& !(*purb)->transfer_buffer" check has been removed because the URB has been freshly allocated a few lines above so ->transfer_buffer has to be NULL here. The `dev' and `transfer_size' assignments have been moved from usX2Y_urbs_start() to usX2Y_urbs_allocate() because they don't change overtime. Cc: Jaroslav Kysela Cc: Takashi Iwai Signed-off-by: Sebastian Andrzej Siewior --- sound/usb/usx2y/usbusx2yaudio.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index 2b833054e3b0..9a49bdb07508 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c @@ -425,6 +425,9 @@ static int usX2Y_urbs_allocate(struct snd_usX2Y_substream *subs) /* allocate and initialize data urbs */ for (i = 0; i < NRURBS; i++) { struct urb **purb = subs->urb + i; + void *buf = NULL; + unsigned int len = 0; + if (*purb) { usb_kill_urb(*purb); continue; @@ -434,22 +437,18 @@ static int usX2Y_urbs_allocate(struct snd_usX2Y_substream *subs) usX2Y_urbs_release(subs); return -ENOMEM; } - if (!is_playback && !(*purb)->transfer_buffer) { + if (!is_playback) { /* allocate a capture buffer per urb */ - (*purb)->transfer_buffer = - kmalloc_array(subs->maxpacksize, - nr_of_packs(), GFP_KERNEL); - if (NULL == (*purb)->transfer_buffer) { + len = subs->maxpacksize * nr_of_packs(); + buf = kmalloc(len, GFP_KERNEL); + if (!buf) { usX2Y_urbs_release(subs); return -ENOMEM; } } - (*purb)->dev = dev; - (*purb)->pipe = pipe; + usb_fill_int_urb(*purb, dev, pipe, buf, len, + i_usX2Y_subs_startup, subs, 1); (*purb)->number_of_packets = nr_of_packs(); - (*purb)->context = subs; - (*purb)->interval = 1; - (*purb)->complete = i_usX2Y_subs_startup; } return 0; } @@ -485,12 +484,10 @@ static int usX2Y_urbs_start(struct snd_usX2Y_substream *subs) unsigned long pack; if (0 == i) atomic_set(&subs->state, state_STARTING3); - urb->dev = usX2Y->dev; 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->transfer_buffer_length = subs->maxpacksize * nr_of_packs(); if ((err = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { snd_printk (KERN_ERR "cannot submit datapipe for urb %d, err = %d\n", i, err); err = -EPIPE;