Received: by 10.192.165.148 with SMTP id m20csp4402577imm; Tue, 24 Apr 2018 02:03:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx4//cncqhC7faGPbiEQC3vHEVUovCQQXGQ4yUR3uuD1iITTo7Gy9kQIOXqDwTwJYzMmyuxi9 X-Received: by 10.99.144.196 with SMTP id a187mr19492076pge.189.1524560581391; Tue, 24 Apr 2018 02:03:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524560581; cv=none; d=google.com; s=arc-20160816; b=BXopUAFDyL870EyQBjQNADdTD6pijHD75c0T7S0a3j9HIdncCgtbckvaElMrfAUuGt 69psEVvhEo69lQQzRERrQ+lR4byBsRLYDJfgogbbYGrW4uiyVMk7AfSYH0GBHC3aWfst ngV/GHtgoMLfLW2PlV4gZGhUzYDd02oLQsVdXPBZy6IS6LjVH7+JTptm4bCjxbeY5oLt 5RDqKTPoj9rc5OzTofu5l+O0FkQKxUjBH9CzBbOLKXvf23IOesnH1o6pmN8ZkmYiPd1S tB6px893kJzidSB+fslGepzWZF6MhzYeqnaCP8mAjKkpdg/DPq2lw+k/bieobsDoGQYH xr4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=hI74kssGDBdtLU66N7OlMYHeHFByoIdl6xJlEvDaiA0=; b=fHwjWStf6UDdsKi89FJ+pOW8EPfjqyS/xpcfebyqqKeHNRVVIov5pHXh2FxLxmwmb6 J+/KQQLed9VEGMWjtx3BMpmcXHL/9K2gp07s9Uwat1JWl/APVyq6SNeh8oPbz65l7rwd 6Mm8mb3sdyfyV8jTNhFOw9VPB3P9C2OSt23cbOxp5kvxHDd6AuFGYCzJT5c5XxJQ5pZd Mln/r7CXM+tT9CLql+M5effaYePIaPawT8CuV9cf6Xw8VgR1PVrGaUSY0bbzGCaicy/2 /eQYwNZK+CCz1d0fuj+IJUL95/TdIMs6xGPoOUuC47u3C/zlwAeS3qvndPXnl8Pc6v2M rCcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fcnOuDro; 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 f9si7996479pge.639.2018.04.24.02.02.46; Tue, 24 Apr 2018 02:03:01 -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=fcnOuDro; 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 S932461AbeDXHvr (ORCPT + 99 others); Tue, 24 Apr 2018 03:51:47 -0400 Received: from mail-ot0-f170.google.com ([74.125.82.170]:38133 "EHLO mail-ot0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752030AbeDXHvo (ORCPT ); Tue, 24 Apr 2018 03:51:44 -0400 Received: by mail-ot0-f170.google.com with SMTP id j27-v6so20074253ota.5 for ; Tue, 24 Apr 2018 00:51:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=hI74kssGDBdtLU66N7OlMYHeHFByoIdl6xJlEvDaiA0=; b=fcnOuDroUYia3G4JAOl1zqT9NWXJMI4c6vsUoEHPAPa9iYWTZwKhe15Xn1GpxU/fkp Zn5YOcqz0CY11oMxgNQxH8wIsjBRNQi1hYsetdvc+FMYY7/dwdcOSpDeROpNvq1nQrxk DKXBKgr+aoKTUlv9zsHsL1tsY3mWlF70ODRERn5WwalrAT8Kppf1p/dtP9GsrjXbvv4a zDkcNqEBb9ZLD/al/tDmgM9apJFVvJ41zPvjwXU3zP4D6Q7T8EkIjAv1KQXbb2HBZ9bz 3MVy2jay5o1idN8jgnDQwQSHLiIbZKmG2O8jmH3EWEm3pME1wxz5LxOtdw+5gCXSgEza UjGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=hI74kssGDBdtLU66N7OlMYHeHFByoIdl6xJlEvDaiA0=; b=R1HIn6MNHh+GU4ZFSzDtG14KkSjoXebvN4kW4r7r+IZryI4JCb1hF1vxpPgChTt9K/ 1Yy9U/3ICN5QNLkJUfVC9cw9tpz1c25Bm4Lj4J1XwO9/RLrNhuuGf6Yus/KDUEjaOuYg EGC+4dz/37Qp8/PVPhEZaFKoLTT2JkpYjcyDNfhm47e5nkMKqbI0x6wfJ40J/+y4co2O Vf+s26U5EqrnUyJN54NlQ3/4agDKqov5EGy8cgDqWGyEBWZDU0wNFAylWngUBcVbAUB0 KeO5ODFjoWhsCa6x20ucgDRUpkEf5gjXocHQJDdMCofP6tAXglWWcS1ZBB+S7HYyXM+w jSAA== X-Gm-Message-State: ALQs6tDzMHROgWMCE4mEytdeMuF3eB/qXVY/dk1WEdMoom9Dwqn1XYx4 TF+idTVq5GQg8H4U6UujRvNGfpvlBalHDCnC01o= X-Received: by 2002:a9d:6258:: with SMTP id i24-v6mr14613437otk.239.1524556303931; Tue, 24 Apr 2018 00:51:43 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:1e8a:0:0:0:0:0 with HTTP; Tue, 24 Apr 2018 00:51:43 -0700 (PDT) In-Reply-To: References: <1523658266-2259-1-git-send-email-ruslan.bilovol@gmail.com> <1523658266-2259-5-git-send-email-ruslan.bilovol@gmail.com> From: Ruslan Bilovol Date: Tue, 24 Apr 2018 10:51:43 +0300 Message-ID: Subject: Re: [alsa-devel] [PATCH 4/4] ALSA: usb: add UAC3 BADD profiles support To: Takashi Iwai Cc: Jorge , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 19, 2018 at 1:19 PM, Takashi Iwai wrote: > On Sat, 14 Apr 2018 00:24:26 +0200, > Ruslan Bilovol wrote: >> >> +static void build_feature_ctl_badd(struct usb_mixer_interface *mixer, >> + unsigned int ctl_mask, int control, int unitid, >> + const struct usbmix_name_map *badd_map) >> +{ > .... >> + kctl = snd_ctl_new1(&usb_feature_unit_ctl, cval); >> + >> + if (!kctl) { >> + usb_audio_err(mixer->chip, "cannot malloc kcontrol\n"); > > No need for error message after malloc failure. The kernel is already > chatty about it. Okay. BTW, I'm trying to avoid separate badd variant of build_feature_ctl(), so this most probably will go away. There are many existing places in usb-snd which can be cleaned up though. > > >> +static int snd_usb_mixer_controls_badd(struct usb_mixer_interface *mixer, >> + int ctrlif) >> +{ >> + struct usb_device *dev = mixer->chip->dev; >> + struct usb_interface_assoc_descriptor *assoc; >> + int badd_profile = mixer->chip->badd_profile; >> + const struct usbmix_ctl_map *map; >> + int p_chmask = 0, c_chmask = 0, st_chmask = 0; >> + int i; >> + >> + assoc = usb_ifnum_to_if(dev, ctrlif)->intf_assoc; >> + >> + /* Detect BADD capture/playback channels from AS EP descriptors */ >> + for (i = 0; i < assoc->bInterfaceCount; i++) { >> + int intf = assoc->bFirstInterface + i; >> + >> + if (intf != ctrlif) { > > In this case, it's better to skip like > > if (intf == ctrlif) > continue; > > so that we can save an indentation for the whole long block. Good point, will do it > >> + switch (badd_profile) { >> + default: >> + return -EINVAL; >> + case UAC3_FUNCTION_SUBCLASS_GENERIC_IO: >> + /* >> + * BAIF, BAOF or combination of both >> + * IN: Mono or Stereo cfg, Mono alt possible >> + * OUT: Mono or Stereo cfg, Mono alt possible >> + */ >> + /* c_chmask := DYNAMIC */ >> + /* p_chmask := DYNAMIC */ >> + if (!c_chmask && !p_chmask) { >> + usb_audio_err(mixer->chip, >> + "BADD GENERIC_IO profile: no channels?\n"); >> + return -EINVAL; >> + } >> + break; > > Maybe we can simplify the whole switch/case with a table lookup. Yes, it should be possible, I'll implent it that way Thanks, Ruslan > For example, > > for (f = uac3_func_tables; f->name; f++) { > if (badd_profile == f->subclass) > break; > } > if (!f->name) > return -EINVAL; > if (!uac3_func_has_valid_channels(mixer, f, c_chmask, p_chmask)) > return -EINVAL; > st_chmask = f->st_chmask; > > and in uac3_func_has_valid_channels(), > > static bool uac3_func_has_valid_channels() > { > if ((f->c_chmask < 0 && !c_chmask) || > (f->c_chmask >= 0 && f->c_chmask != c_chmask)) { > usb_audio_warn(mixer->chip, "BAAD %s c_chmask mismatch", > f->name); > return false; > } > if ((f->p_chmask < 0 && !p_chmask) || > (f->p_chmask >= 0 && f->p_chmask != p_chmask)) { > usb_audio_warn(mixer->chip, "BAAD %s p_chmask mismatch", > f->name); > return false; > } > return true; > } > > > thanks, > > Takashi