From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: Damien Zammit <damien.zammit@gmail.com>
Cc: alsa-devel@alsa-project.org
Subject: Re: [PATCH] usb-audio: Add mixer control for Digidesign Mbox 1 clock source
Date: Fri, 31 Oct 2014 13:28:58 +0900 [thread overview]
Message-ID: <5453100A.8070602@sakamocchi.jp> (raw)
In-Reply-To: <545309D8.1020600@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1479 bytes --]
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
[-- Attachment #2: 0001-Comments-for-mbox1-spdif-2.patch.patch --]
[-- Type: text/x-patch, Size: 2570 bytes --]
>From 6e889e1fc7d7101cfef14484849a412b002798e9 Mon Sep 17 00:00:00 2001
From: Takashi Sakamoto <mocchi@MocchiSakamoto64.miraclelinux.com>
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
[-- Attachment #3: Type: text/plain, Size: 0 bytes --]
next prev parent reply other threads:[~2014-10-31 4:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-31 1:57 [PATCH] usb-audio: Add mixer control for Digidesign Mbox 1 clock source Damien Zammit
2014-10-31 3:29 ` Takashi Sakamoto
2014-10-31 4:02 ` Damien Zammit
2014-10-31 4:28 ` Takashi Sakamoto [this message]
2014-10-31 4:45 ` Damien Zammit
2014-10-31 5:13 ` Takashi Sakamoto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5453100A.8070602@sakamocchi.jp \
--to=o-takashi@sakamocchi.jp \
--cc=alsa-devel@alsa-project.org \
--cc=damien.zammit@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.