From patchwork Fri May 4 01:23:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ruslan Bilovol X-Patchwork-Id: 10379615 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 4B08C60327 for ; Fri, 4 May 2018 01:32:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B314292E6 for ; Fri, 4 May 2018 01:32:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FBCC292E8; Fri, 4 May 2018 01:32:35 +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=-2.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F9DE292EC for ; Fri, 4 May 2018 01:32:34 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E12812675FA; Fri, 4 May 2018 03:25:02 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id A5A6626735E; Fri, 4 May 2018 03:24:54 +0200 (CEST) Received: from mail-lf0-f67.google.com (mail-lf0-f67.google.com [209.85.215.67]) by alsa0.perex.cz (Postfix) with ESMTP id 5E47426728A for ; Fri, 4 May 2018 03:24:51 +0200 (CEST) Received: by mail-lf0-f67.google.com with SMTP id u21-v6so28646485lfu.9 for ; Thu, 03 May 2018 18:24:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=H5vJWHKWV9CGG9PIc83wP5ray5Q7ZibphnB5OCN5klw=; b=sXQevBicwwYCn6D9KuobnWUTcepEGZFCG27Ud4BEeNs9YcptIROpoYdCwE8A2cn5QL Xd7XV1WbfEsl9F1C76Agy5F+toE35nkVwhnlS6PCo12ByOhhJgLNj6KtuL4E3bn/POsQ lRdXbieFl1kFC75S4bUfRMxeQDdLIYK4pk2FMhEi0lpUtsIGmfAT0uMwjxiWEeSOc0TM SUIuznkmOC6YLC4Gngu7dHq/q90Wu8+yu4yOnABIQ3Th6u4kkarCnMx87/RCkwmAS7Hi XYOwUfFxSH8b5gJh1aJJu4yPoIiisNMZE2SO4xGL9A6ZlxaAaRL2RM6kqFPYrnVdqGC8 YXlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=H5vJWHKWV9CGG9PIc83wP5ray5Q7ZibphnB5OCN5klw=; b=dj4S6NfWiSv0tl7+EW+Kdi8gkjrggoeToDXMaKS0eVMNQbnqWfwKMBgPAZ++H05RJ1 BoUFxDO8hboaOSkn8DDq0mxyLQ4NG55ny/bxNaFIRqkrctqfeibnnpERhAu6m2GYDaxL 8zzA3Ax0w/mgOGRDFscyoJDk5+3nbYnVSqlp5bYfl1Fki/NvYMAQtR0LgCRH8fIpMBn9 ZHMMNoxITGCrRliiMV5O8g5cZ2bLsGU2RxlS5j16fitORAuCV5FjJYCrUvSuBkP1w5Gm v7B1GJL+zDpPPQ2nWnedjDS02huMmv2fTuurcyGuJw/Z38/N3E8b2PYI1Q5PFzKxqCkj GtiQ== X-Gm-Message-State: ALQs6tCfnDU2IgdhEubEYQjemUh70lNOpDy3/AxUAsh/Jo3e8nlOYBJK iuOdOm+iCmNARnUePNQgrzk= X-Google-Smtp-Source: AB8JxZqCrr/E/IezXaM1PRkvwyxy3GX0QoR9KqmkF3VjH/MjxGs+8C3hPi00Dm7pxx0T0/sZjNxd9A== X-Received: by 2002:a19:c148:: with SMTP id r69-v6mr16518625lff.85.1525397090677; Thu, 03 May 2018 18:24:50 -0700 (PDT) Received: from localhost ([62.216.57.27]) by smtp.gmail.com with ESMTPSA id x24-v6sm3038773ljj.54.2018.05.03.18.24.49 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 03 May 2018 18:24:50 -0700 (PDT) From: Ruslan Bilovol To: Takashi Iwai Date: Fri, 4 May 2018 04:23:58 +0300 Message-Id: <1525397044-15080-2-git-send-email-ruslan.bilovol@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1525397044-15080-1-git-send-email-ruslan.bilovol@gmail.com> References: <1525397044-15080-1-git-send-email-ruslan.bilovol@gmail.com> Cc: Jorge , alsa-devel@alsa-project.org, Andrew Chant , linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: [alsa-devel] [PATCH v2 1/7] ALSA: usb: stream: move audioformat alloc/init into separate function X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Offload snd_usb_parse_audio_interface() function which became quite long after adding UAC3 spec support. Move audioformat allocation and initialization into separate function, this will make easier future refactoring. Attributes left in the original func because it'll be used for UAC3 BADD profiles suport in the future There is no functional change. Signed-off-by: Ruslan Bilovol --- sound/usb/stream.c | 52 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/sound/usb/stream.c b/sound/usb/stream.c index 956be9f..8ec0a52 100644 --- a/sound/usb/stream.c +++ b/sound/usb/stream.c @@ -626,6 +626,37 @@ static int parse_uac_endpoint_attributes(struct snd_usb_audio *chip, return NULL; } +static struct audioformat * +audio_format_alloc_init(struct snd_usb_audio *chip, + struct usb_host_interface *alts, + int protocol, int iface_no, int altset_idx, + int altno, int num_channels, int clock) +{ + struct audioformat *fp; + + fp = kzalloc(sizeof(*fp), GFP_KERNEL); + if (!fp) + return NULL; + + fp->iface = iface_no; + fp->altsetting = altno; + fp->altset_idx = altset_idx; + fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; + fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; + fp->datainterval = snd_usb_parse_datainterval(chip, alts); + fp->protocol = protocol; + fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); + fp->channels = num_channels; + if (snd_usb_get_speed(chip->dev) == USB_SPEED_HIGH) + fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) + * (fp->maxpacksize & 0x7ff); + fp->clock = clock; + INIT_LIST_HEAD(&fp->list); + + return fp; +} + + int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no) { struct usb_device *dev; @@ -928,25 +959,14 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no) continue; } - fp = kzalloc(sizeof(*fp), GFP_KERNEL); + fp = audio_format_alloc_init(chip, alts, protocol, iface_no, i, + altno, num_channels, clock); if (!fp) return -ENOMEM; - fp->iface = iface_no; - fp->altsetting = altno; - fp->altset_idx = i; - fp->endpoint = get_endpoint(alts, 0)->bEndpointAddress; - fp->ep_attr = get_endpoint(alts, 0)->bmAttributes; - fp->datainterval = snd_usb_parse_datainterval(chip, alts); - fp->protocol = protocol; - fp->maxpacksize = le16_to_cpu(get_endpoint(alts, 0)->wMaxPacketSize); - fp->channels = num_channels; - if (snd_usb_get_speed(dev) == USB_SPEED_HIGH) - fp->maxpacksize = (((fp->maxpacksize >> 11) & 3) + 1) - * (fp->maxpacksize & 0x7ff); - fp->attributes = parse_uac_endpoint_attributes(chip, alts, protocol, iface_no); - fp->clock = clock; - INIT_LIST_HEAD(&fp->list); + fp->attributes = parse_uac_endpoint_attributes(chip, alts, + protocol, + iface_no); /* some quirks for attributes here */ snd_usb_audioformat_attributes_quirk(chip, fp, stream);