From patchwork Fri Oct 31 04:28:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Sakamoto X-Patchwork-Id: 5202161 X-Patchwork-Delegate: tiwai@suse.de Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A0D959F318 for ; Fri, 31 Oct 2014 04:29:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AB1ED201B4 for ; Fri, 31 Oct 2014 04:29:25 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id DDDB420176 for ; Fri, 31 Oct 2014 04:29:23 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8B40B2654A4; Fri, 31 Oct 2014 05:29:22 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 5F4BA265336; Fri, 31 Oct 2014 05:29:11 +0100 (CET) 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 81877265372; Fri, 31 Oct 2014 05:29:10 +0100 (CET) Received: from smtp310.phy.lolipop.jp (smtp310.phy.lolipop.jp [210.157.22.78]) by alsa0.perex.cz (Postfix) with ESMTP id 3F08326067A for ; Fri, 31 Oct 2014 05:29:01 +0100 (CET) Received: from smtp310.phy.lolipop.lan (HELO smtp310.phy.lolipop.jp) (172.17.1.10) (smtp-auth username m12129643-o-takashi , mechanism plain) by smtp310.phy.lolipop.jp (qpsmtpd/0.82) with ESMTPA; Fri, 31 Oct 2014 13:28:59 +0900 Received: from 127.0.0.1 (127.0.0.1) by smtp310.phy.lolipop.jp (LOLIPOP-Fsecure); Fri, 31 Oct 2014 13:28:58 +0900 (JST) X-Virus-Status: clean(LOLIPOP-Fsecure) Message-ID: <5453100A.8070602@sakamocchi.jp> Date: Fri, 31 Oct 2014 13:28:58 +0900 From: Takashi Sakamoto User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Damien Zammit References: <5452EC80.8060005@gmail.com> <54530212.7000804@sakamocchi.jp> <545309D8.1020600@gmail.com> In-Reply-To: <545309D8.1020600@gmail.com> Cc: alsa-devel@alsa-project.org Subject: Re: [alsa-devel] [PATCH] usb-audio: Add mixer control for Digidesign Mbox 1 clock source 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Damien, On Oct 31 2014 13:02, Damien Zammit wrote: > Hi, sorry for the style problems. See attached for better version. 4 points. 1. please use white-spaces or tabs for indentation to align parameters to function-start blacket: > +static int snd_mbox1_switch_put(struct snd_kcontrol *kctl, > + struct snd_ctl_elem_value *ucontrol) > +static int snd_mbox1_switch_info(struct snd_kcontrol *kcontrol, > + struct snd_ctl_elem_info *uinfo) > +static int snd_mbox1_switch_put(struct snd_kcontrol *kctl, > + struct snd_ctl_elem_value *ucontrol) 2.please use 'const char *const' for immutable arrays for immutable strings: > + static const char *texts[2] = {"Internal", > + "S/PDIF" > + }; > + 3. I think in your case, snd_ctl_enum_info() is available in struct snd_kcontrol_new.info() callback. Please read this thread: [alsa-devel] [PATCH 00/43] Spread usage of snd_ctl_elem_info() http://mailman.alsa-project.org/pipermail/alsa-devel/2014-October/082573.html 4. I think 'err' local variable in snd_mbox1_create_sync_switch() can be removed because it's assign and evaluated at once: > + err = snd_ctl_add(mixer->chip->card, kctl); > + if (err < 0) > + return err; > + > + return 0; See attached patch. Regards Takashi Sakamoto o-takashi@sakamocchi.jp From 6e889e1fc7d7101cfef14484849a412b002798e9 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Fri, 31 Oct 2014 13:17:19 +0900 Subject: [PATCH] Comments for mbox1-spdif-2.patch See: [alsa-devel] [PATCH] usb-audio: Add mixer control for Digidesign Mbox 1 clock source http://mailman.alsa-project.org/pipermail/alsa-devel/2014-October/083264.html --- sound/usb/mixer_quirks.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c index 6a21dec..87f121f 100644 --- a/sound/usb/mixer_quirks.c +++ b/sound/usb/mixer_quirks.c @@ -574,7 +574,7 @@ struct snd_mbox1_switch_priv_val { }; static int snd_mbox1_switch_get(struct snd_kcontrol *kctl, - struct snd_ctl_elem_value *ucontrol) + struct snd_ctl_elem_value *ucontrol) { struct snd_mbox1_switch_priv_val *pval; unsigned char value; @@ -597,7 +597,7 @@ static int snd_mbox1_switch_get(struct snd_kcontrol *kctl, } static int snd_mbox1_switch_put(struct snd_kcontrol *kctl, - struct snd_ctl_elem_value *ucontrol) + struct snd_ctl_elem_value *ucontrol) { struct snd_usb_audio *chip; struct snd_mbox1_switch_priv_val *pval; @@ -692,21 +692,14 @@ static int snd_mbox1_switch_put(struct snd_kcontrol *kctl, } static int snd_mbox1_switch_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) + struct snd_ctl_elem_info *uinfo) { - static const char *texts[2] = {"Internal", - "S/PDIF" + static const char *const texts[2] = { + "Internal", + "S/PDIF" }; - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; - uinfo->count = 1; - uinfo->value.enumerated.items = 2; - if (uinfo->value.enumerated.item > 1) - uinfo->value.enumerated.item = 1; - strcpy(uinfo->value.enumerated.name, - texts[uinfo->value.enumerated.item]); - - return 0; + return snd_ctl_enum_info(uinfo, 1, ARRAY_SIZE(texts), texts);; } static int snd_mbox1_create_sync_switch(struct usb_mixer_interface *mixer) @@ -722,7 +715,6 @@ static int snd_mbox1_create_sync_switch(struct usb_mixer_interface *mixer) .put = snd_mbox1_switch_put }; - int err; struct snd_kcontrol *kctl; struct snd_mbox1_switch_priv_val *pval; @@ -741,11 +733,7 @@ static int snd_mbox1_create_sync_switch(struct usb_mixer_interface *mixer) return -ENOMEM; } - err = snd_ctl_add(mixer->chip->card, kctl); - if (err < 0) - return err; - - return 0; + return snd_ctl_add(mixer->chip->card, kctl); } /* Native Instruments device quirks */ -- 1.9.1