Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4809C2D0E2 for ; Tue, 22 Sep 2020 10:03:55 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 14FA0238A1 for ; Tue, 22 Sep 2020 10:03:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="TbQJI3Pi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 14FA0238A1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 6EAA916AC; Tue, 22 Sep 2020 12:03:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6EAA916AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1600769032; bh=9gNgIEu46iD4xitwkQOnxYa405Tc6MTjCIwBdJ3P1C4=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=TbQJI3PiUx4ILO4gVRJwO4R1G+kF0pJu23UEicLdzPm45oFyZDcYGQ1AKa4ScygWr 9pQJl4+ZbKPvO86hl1E6U0fZOZHPu6uKA4dONABIS/sLW9q6saH0gyuc4184KYQGu9 Y0EJpvGMEJpt1aQ47rGN4k8kLSmB3TxQ6JeCL3mg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DF0DAF80229; Tue, 22 Sep 2020 12:03:01 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4BE28F80232; Tue, 22 Sep 2020 12:03:00 +0200 (CEST) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 1A2ADF8015F for ; Tue, 22 Sep 2020 12:02:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1A2ADF8015F X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D4DEEAC4F; Tue, 22 Sep 2020 10:03:29 +0000 (UTC) Date: Tue, 22 Sep 2020 12:02:53 +0200 Message-ID: From: Takashi Iwai To: =?UTF-8?B?RnJhbnRpxaFlayBLdcSNZXJh?= Subject: Re: [PATCH] ALSA: usb-audio: Add mixer support for Pioneer DJ DJM-250MK2 In-Reply-To: <20200921190936.5110-1-konference@frantovo.cz> References: <20200921190936.5110-1-konference@frantovo.cz> 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=UTF-8 Content-Transfer-Encoding: 8bit Cc: alsa-devel@alsa-project.org, =?UTF-8?B?RnJhbnRpxaFlayBLdcSNZXJh?= X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Mon, 21 Sep 2020 21:09:36 +0200, František Kučera wrote: > > From: František Kučera > > This patch extends support for DJM-250MK2 and allows mapping > playback and capture channels to available sources. > Configures the card through USB commands. First off, your Signed-off-by line is missing. This should have been pointed by checkpatch.pl. About the code changes: > +static const struct snd_pioneer_djm_option SND_PIONEER_DJM_OPTIONS_CAPTURE_LEVEL[] = { Avoid using the capital letters unless macros. Ditto for other snd_pioneer_djm_option items. > +struct snd_pioneer_djm_option_group { > + const char *name; > + const struct snd_pioneer_djm_option *options; > + const size_t count; > + const u16 default_value; > +} snd_pioneer_djm_option_group; Why you define an object here (snd_pioneer_djm_option_group), not only struct? I guess it was forgotten to remove when dropping typedef? > +static int snd_pioneer_djm_controls_info(struct snd_kcontrol *kctl, struct snd_ctl_elem_info *info) > +{ > + u16 group_index = kctl->private_value >> SND_PIONEER_DJM_GROUP_SHIFT; > + size_t count; > + const char *name; > + const struct snd_pioneer_djm_option_group *group; > + > + if (group_index < ARRAY_SIZE(SND_PIONEER_DJM_OPTION_GROUPS)) { > + group = &SND_PIONEER_DJM_OPTION_GROUPS[group_index]; > + count = group->count; > + if (info->value.enumerated.item >= count) > + info->value.enumerated.item = count - 1; > + name = group->options[info->value.enumerated.item].name; > + strlcpy(info->value.enumerated.name, name, sizeof(info->value.enumerated.name)); > + info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; > + info->count = 1; > + info->value.enumerated.items = count; > + return 0; > + } else { > + return -EINVAL; > + } This can be a bit simpler if you write like: if (group_index >= ARRAY_SIZE(....)) return -EINVAL; group = &SND_PIONEER_DJM_OPTION_GROUPS[group_index]; count = group->count; ..... The same applied to other functions. > +static int snd_pioneer_djm_controls_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *elem) > +{ > + struct usb_mixer_elem_list *list = snd_kcontrol_chip(kctl); > + struct usb_mixer_interface *mixer = list->mixer; > + unsigned long private_value = kctl->private_value; > + > + u16 group = (private_value & SND_PIONEER_DJM_GROUP_MASK) >> SND_PIONEER_DJM_GROUP_SHIFT; Avoid the unnecessary blank line in the above. > + u16 value = elem->value.enumerated.item[0]; > + > + kctl->private_value = group << SND_PIONEER_DJM_GROUP_SHIFT | value; Better to wrap write parentheses around the bit operation for avoiding confusions. (Also a similar expression is found in another place). thanks, Takashi