* [PATCH] ALSA: usb-audio: constify snd_kcontrol_new structures
@ 2017-02-21 20:03 Bhumika Goyal
2017-02-21 21:10 ` Takashi Iwai
0 siblings, 1 reply; 4+ messages in thread
From: Bhumika Goyal @ 2017-02-21 20:03 UTC (permalink / raw)
To: julia.lawall, perex, tiwai, alsa-devel, linux-kernel; +Cc: Bhumika Goyal
Declare snd_kcontrol_new structures as const as they are only passed as
an argument to the function add_new_ctl. This agrument is of type const,
so snd_kcontrol_new structures having this property can be made const
too.
Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
---
sound/usb/mixer_scarlett.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/sound/usb/mixer_scarlett.c b/sound/usb/mixer_scarlett.c
index 7438e7c..c33e237 100644
--- a/sound/usb/mixer_scarlett.c
+++ b/sound/usb/mixer_scarlett.c
@@ -477,7 +477,7 @@ static int scarlett_ctl_meter_get(struct snd_kcontrol *kctl,
return 0;
}
-static struct snd_kcontrol_new usb_scarlett_ctl_switch = {
+static const struct snd_kcontrol_new usb_scarlett_ctl_switch = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "",
.info = scarlett_ctl_switch_info,
@@ -487,7 +487,7 @@ static int scarlett_ctl_meter_get(struct snd_kcontrol *kctl,
static const DECLARE_TLV_DB_SCALE(db_scale_scarlett_gain, -12800, 100, 0);
-static struct snd_kcontrol_new usb_scarlett_ctl = {
+static const struct snd_kcontrol_new usb_scarlett_ctl = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
SNDRV_CTL_ELEM_ACCESS_TLV_READ,
@@ -499,7 +499,7 @@ static int scarlett_ctl_meter_get(struct snd_kcontrol *kctl,
.tlv = { .p = db_scale_scarlett_gain }
};
-static struct snd_kcontrol_new usb_scarlett_ctl_master = {
+static const struct snd_kcontrol_new usb_scarlett_ctl_master = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
SNDRV_CTL_ELEM_ACCESS_TLV_READ,
@@ -511,7 +511,7 @@ static int scarlett_ctl_meter_get(struct snd_kcontrol *kctl,
.tlv = { .p = db_scale_scarlett_gain }
};
-static struct snd_kcontrol_new usb_scarlett_ctl_enum = {
+static const struct snd_kcontrol_new usb_scarlett_ctl_enum = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "",
.info = scarlett_ctl_enum_info,
@@ -519,7 +519,7 @@ static int scarlett_ctl_meter_get(struct snd_kcontrol *kctl,
.put = scarlett_ctl_enum_put,
};
-static struct snd_kcontrol_new usb_scarlett_ctl_dynamic_enum = {
+static const struct snd_kcontrol_new usb_scarlett_ctl_dynamic_enum = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "",
.info = scarlett_ctl_enum_dynamic_info,
@@ -527,7 +527,7 @@ static int scarlett_ctl_meter_get(struct snd_kcontrol *kctl,
.put = scarlett_ctl_enum_put,
};
-static struct snd_kcontrol_new usb_scarlett_ctl_sync = {
+static const struct snd_kcontrol_new usb_scarlett_ctl_sync = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
.name = "",
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] ALSA: usb-audio: constify snd_kcontrol_new structures
2017-02-21 20:03 [PATCH] ALSA: usb-audio: constify snd_kcontrol_new structures Bhumika Goyal
@ 2017-02-21 21:10 ` Takashi Iwai
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2017-02-21 21:10 UTC (permalink / raw)
To: Bhumika Goyal; +Cc: alsa-devel, julia.lawall, perex, linux-kernel
On Tue, 21 Feb 2017 21:03:27 +0100,
Bhumika Goyal wrote:
>
> Declare snd_kcontrol_new structures as const as they are only passed as
> an argument to the function add_new_ctl. This agrument is of type const,
> so snd_kcontrol_new structures having this property can be made const
> too.
>
> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Well, this is again no urgent fix, so I'll postpone this to 4.12.
In general, please try to stop posting this kind of patches during the
merge window. During the merge window, we concentrate only on the
stuff for the upcoming rc1, and receiving repeatedly non-urgent
cleanup patches is often just annoyance.
Of course, once after the merge window is closed, it's perfectly fine
to take such patches.
thanks,
Takashi
> ---
> sound/usb/mixer_scarlett.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/sound/usb/mixer_scarlett.c b/sound/usb/mixer_scarlett.c
> index 7438e7c..c33e237 100644
> --- a/sound/usb/mixer_scarlett.c
> +++ b/sound/usb/mixer_scarlett.c
> @@ -477,7 +477,7 @@ static int scarlett_ctl_meter_get(struct snd_kcontrol *kctl,
> return 0;
> }
>
> -static struct snd_kcontrol_new usb_scarlett_ctl_switch = {
> +static const struct snd_kcontrol_new usb_scarlett_ctl_switch = {
> .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> .name = "",
> .info = scarlett_ctl_switch_info,
> @@ -487,7 +487,7 @@ static int scarlett_ctl_meter_get(struct snd_kcontrol *kctl,
>
> static const DECLARE_TLV_DB_SCALE(db_scale_scarlett_gain, -12800, 100, 0);
>
> -static struct snd_kcontrol_new usb_scarlett_ctl = {
> +static const struct snd_kcontrol_new usb_scarlett_ctl = {
> .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
> SNDRV_CTL_ELEM_ACCESS_TLV_READ,
> @@ -499,7 +499,7 @@ static int scarlett_ctl_meter_get(struct snd_kcontrol *kctl,
> .tlv = { .p = db_scale_scarlett_gain }
> };
>
> -static struct snd_kcontrol_new usb_scarlett_ctl_master = {
> +static const struct snd_kcontrol_new usb_scarlett_ctl_master = {
> .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
> SNDRV_CTL_ELEM_ACCESS_TLV_READ,
> @@ -511,7 +511,7 @@ static int scarlett_ctl_meter_get(struct snd_kcontrol *kctl,
> .tlv = { .p = db_scale_scarlett_gain }
> };
>
> -static struct snd_kcontrol_new usb_scarlett_ctl_enum = {
> +static const struct snd_kcontrol_new usb_scarlett_ctl_enum = {
> .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> .name = "",
> .info = scarlett_ctl_enum_info,
> @@ -519,7 +519,7 @@ static int scarlett_ctl_meter_get(struct snd_kcontrol *kctl,
> .put = scarlett_ctl_enum_put,
> };
>
> -static struct snd_kcontrol_new usb_scarlett_ctl_dynamic_enum = {
> +static const struct snd_kcontrol_new usb_scarlett_ctl_dynamic_enum = {
> .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> .name = "",
> .info = scarlett_ctl_enum_dynamic_info,
> @@ -527,7 +527,7 @@ static int scarlett_ctl_meter_get(struct snd_kcontrol *kctl,
> .put = scarlett_ctl_enum_put,
> };
>
> -static struct snd_kcontrol_new usb_scarlett_ctl_sync = {
> +static const struct snd_kcontrol_new usb_scarlett_ctl_sync = {
> .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
> .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
> .name = "",
> --
> 1.9.1
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] ALSA: usb-audio: constify snd_kcontrol_new structures
@ 2017-04-12 13:08 Bhumika Goyal
2017-04-12 13:35 ` Takashi Iwai
0 siblings, 1 reply; 4+ messages in thread
From: Bhumika Goyal @ 2017-04-12 13:08 UTC (permalink / raw)
To: julia.lawall, clemens, perex, tiwai, alsa-devel, linux-kernel
Cc: Bhumika Goyal
Declare snd_kcontrol_new strcutures as const as they are only passed as
an argument to the function snd_ctl_new1. This argument is of type const,
so snd_kcontrol_new structures having this property can be made const too.
Done using Coccinelle:
@r disable optional_qualifier@
identifier x;
position p;
@@
static struct snd_kcontrol_new x@p={...};
@ok@
identifier r.x;
position p;
@@
snd_ctl_new1(&x@p,...)
@bad@
position p != {r.p,ok.p};
identifier r.x;
@@
x@p
@depends on !bad disable optional_qualifier@
identifier r.x;
@@
+const
struct snd_kcontrol_new x;
Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
---
sound/usb/midi.c | 2 +-
sound/usb/mixer.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/sound/usb/midi.c b/sound/usb/midi.c
index 6e763bc..a35f414 100644
--- a/sound/usb/midi.c
+++ b/sound/usb/midi.c
@@ -1922,7 +1922,7 @@ static int roland_load_put(struct snd_kcontrol *kcontrol,
return changed;
}
-static struct snd_kcontrol_new roland_load_ctl = {
+static const struct snd_kcontrol_new roland_load_ctl = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "MIDI Input Mode",
.info = roland_load_info,
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 4703cae..082736c 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -1172,7 +1172,7 @@ static struct snd_kcontrol_new usb_feature_unit_ctl = {
};
/* the read-only variant */
-static struct snd_kcontrol_new usb_feature_unit_ctl_ro = {
+static const struct snd_kcontrol_new usb_feature_unit_ctl_ro = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "", /* will be filled later manually */
.info = mixer_ctl_feature_info,
@@ -1745,7 +1745,7 @@ static int mixer_ctl_procunit_put(struct snd_kcontrol *kcontrol,
}
/* alsa control interface for processing/extension unit */
-static struct snd_kcontrol_new mixer_procunit_ctl = {
+static const struct snd_kcontrol_new mixer_procunit_ctl = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "", /* will be filled later */
.info = mixer_ctl_feature_info,
@@ -2033,7 +2033,7 @@ static int mixer_ctl_selector_put(struct snd_kcontrol *kcontrol,
}
/* alsa control interface for selector unit */
-static struct snd_kcontrol_new mixer_selectunit_ctl = {
+static const struct snd_kcontrol_new mixer_selectunit_ctl = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.name = "", /* will be filled later */
.info = mixer_ctl_selector_info,
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] ALSA: usb-audio: constify snd_kcontrol_new structures
2017-04-12 13:08 Bhumika Goyal
@ 2017-04-12 13:35 ` Takashi Iwai
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2017-04-12 13:35 UTC (permalink / raw)
To: Bhumika Goyal; +Cc: alsa-devel, clemens, julia.lawall, perex, linux-kernel
On Wed, 12 Apr 2017 15:08:06 +0200,
Bhumika Goyal wrote:
>
> Declare snd_kcontrol_new strcutures as const as they are only passed as
> an argument to the function snd_ctl_new1. This argument is of type const,
> so snd_kcontrol_new structures having this property can be made const too.
> Done using Coccinelle:
>
> @r disable optional_qualifier@
> identifier x;
> position p;
> @@
> static struct snd_kcontrol_new x@p={...};
>
> @ok@
> identifier r.x;
> position p;
> @@
> snd_ctl_new1(&x@p,...)
>
> @bad@
> position p != {r.p,ok.p};
> identifier r.x;
> @@
> x@p
>
> @depends on !bad disable optional_qualifier@
> identifier r.x;
> @@
> +const
> struct snd_kcontrol_new x;
>
> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Applied, thanks.
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-04-12 13:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-21 20:03 [PATCH] ALSA: usb-audio: constify snd_kcontrol_new structures Bhumika Goyal
2017-02-21 21:10 ` Takashi Iwai
-- strict thread matches above, loose matches on Subject: below --
2017-04-12 13:08 Bhumika Goyal
2017-04-12 13:35 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox