Received: by 10.192.165.156 with SMTP id m28csp532218imm; Thu, 19 Apr 2018 03:21:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/maNUzPJ2+3znCHxOa/LQ5JA2AgN5sEE6DndAIY1tj1EXnHASETZigqEecW2cjOHnCq6zB X-Received: by 10.101.96.141 with SMTP id t13mr4723430pgu.222.1524133268344; Thu, 19 Apr 2018 03:21:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524133268; cv=none; d=google.com; s=arc-20160816; b=VUQqoRf9EnZCnlvHZR39g9cljKxeJf3so89et8erpENqsM9NSZ+mBAjSwARx/83bwb BSxn3nFjIRcsOpYD/4umZKpIEG2HiFKg75/yDoRcy+GGok36HvcGaePMfNbEMNJtFqGE cIgILshAJWn1X7kdB2b4TD72ne2KzxI82u2qr3dO0B/dSLFZfRwx98tWowkeT5DiP+Qq 9EeLVixUWQ7OOliAMl7z0maWrLmrGP/5QCKCfFGsrB3YM482HuKIlD5TZlnhEL4ZTtgD NNQCK+yTTtKlgfrGvx38enIbfws8BAqBehPl62sOZqXXKcCuG1ytFqCgJh1BUFxowhrG UrQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:subject:cc:to:from:message-id:date :arc-authentication-results; bh=MoMHwtBopEkJ2xR1X2d6gN7DCagCo0O6IofSb+0nuRk=; b=v0G0dGf/e/a277fEUYlj152KBd0ZMI1BVkQx/B75WjyBYUCKcnp3S+DqVIC05rWDCd 5JRffCV4DxfxBE69DqZyuTfCTcV0IP96f3me6hnRYb5zcaLTEpL5qhZyyvMKt9PbI2pD Ql8c7ilA37bj4Lsyd1+eiZ3stT4qlQm0PBvUkNLmhGg+l7pRAgOyOGZfbhCPNa7u505C MPfTyst/LXsXLy8fDZcNuVvNuV52ElM6zOe5Bac2afg47E67RrNdXKcAUiomx06hudZs w7MAy9FYNA1zmvTIoEUsW2dmYRhzNxgHYo2juuIzNxP4iPI1NIeEccCARA44PSR4fcG2 SuFA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w34-v6si3108788pla.319.2018.04.19.03.20.53; Thu, 19 Apr 2018 03:21:08 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752633AbeDSKTS (ORCPT + 99 others); Thu, 19 Apr 2018 06:19:18 -0400 Received: from mx2.suse.de ([195.135.220.15]:39887 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752496AbeDSKTR (ORCPT ); Thu, 19 Apr 2018 06:19:17 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 091C4ADE2; Thu, 19 Apr 2018 10:19:15 +0000 (UTC) Date: Thu, 19 Apr 2018 12:19:15 +0200 Message-ID: From: Takashi Iwai To: Ruslan Bilovol Cc: Jorge , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: Re: [alsa-devel] [PATCH 4/4] ALSA: usb: add UAC3 BADD profiles support In-Reply-To: <1523658266-2259-5-git-send-email-ruslan.bilovol@gmail.com> References: <1523658266-2259-1-git-send-email-ruslan.bilovol@gmail.com> <1523658266-2259-5-git-send-email-ruslan.bilovol@gmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > +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. > + 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. 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