Received: by 10.192.165.148 with SMTP id m20csp213542imm; Thu, 3 May 2018 18:26:59 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpfCpIoOzYFj4BWgEzd9xv0gIMSD8g87W/vGJcqYEH77tFJeHRy+3Xt0ZBCZ1evD/NPtYPm X-Received: by 2002:a17:902:566:: with SMTP id 93-v6mr26420911plf.327.1525397219855; Thu, 03 May 2018 18:26:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525397219; cv=none; d=google.com; s=arc-20160816; b=VBi/qnpAWB0N99g2SmmVFOzWpFKc8UcUqUc4gurUBb9ojoO1gjOlNAAfHjzpjX9Mvx 1HCarf14lB0D4H1l01ODHh7J5ry33G6sjfwX+AtqotFZFBgrBqZH15Kc29Od6biBXMTE HooMVKGsrhwQbvfq/FExB4CGvfbrATSWlqI3H4qF3IzRWeNP+favHGzlynoqIRx64V5/ ybRocs7gT37Uj4Ukcp9vIk6iOtLitopaCN+0/+h25flQ9Yd2FK0pc+xgUwc9rq1b2bnR Ky25xmvh3+nnNVh5hlnvHuzreitgTCSMuPBtuRcL4jBimNrsj4l4A1EN7shw42G2yZbU XVKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=H5vJWHKWV9CGG9PIc83wP5ray5Q7ZibphnB5OCN5klw=; b=CkD7MBTIB2dHOiff6XOSRvS5zMCPHncxEsk0DXATwFiCwDi6KYaxbgOHwrUJsnDoSB r9bmIa4yLJVm2fLVkn9HBDYEUvk5ouhC/6ChdkYwLHlDEcwnX27IRV5YkRlWeID4QhNB Dv90oWEaaseG0E5NZuUaGVnoLN6mR+iS7QluZVz3hdy3XVorBqMcnv8u7xUIlKo3xfSQ e/VyxhTnRbDVtGUEYGD53KcocD4qXXCzNNCKr3g5kFeLW19UlQyDVNEM9ULKcGl1ngun gEioOBpxq+BpCl8+lvDA3ZwOOV2EdYYpvE6vWRhmpmyAodJ3ogmakA282ugX7n0C3F0Z OoJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sXQevBic; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x4-v6si11984835pgc.411.2018.05.03.18.26.45; Thu, 03 May 2018 18:26:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sXQevBic; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751476AbeEDBYz (ORCPT + 99 others); Thu, 3 May 2018 21:24:55 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:40497 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751236AbeEDBYw (ORCPT ); Thu, 3 May 2018 21:24:52 -0400 Received: by mail-lf0-f68.google.com with SMTP id j16-v6so28647437lfb.7 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=pUhenGNvvWzM1gFFkE2snJihyvYRCnIrYndwGMxqKZ9/gOGBgqWhErIuQSIg2xek9/ N/6RlDkDgngYvrV50+clfIkeSNdW8T/ZKppqIMgYvL8GjnxQVk/vs6KmLqzuECucsj6n jJl3Cv47+5IylqIcXcfvun0ULo5zPcL4DAqGhAn0hU5TG3VpY9slty3XOZHkxhPYclRo w4iYg3t8mqIspXXlX7BTr+iqmDULg757VwvG0WCHtLJ2+Jq4Q9B06df4ACFk+ozezTED VKP7GSzUMplkFdQEvCSiCwxxqg8LxFHWK/BPlzUe9A7SRY+FgaZ0K3ia+es9vfGaYVSc HE1Q== X-Gm-Message-State: ALQs6tBD+6A2SGlHDCK3pLVEMGlCtswqshiSxOohf++lJZWdRWRskCn6 6PXHfS0CrS1sfcZTROXrHUOXKv+z3VE= 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 Cc: Jorge , Andrew Chant , Greg Kroah-Hartman , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/7] ALSA: usb: stream: move audioformat alloc/init into separate function 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 1.9.1