Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 905e46ac authored by Bhumika Goyal's avatar Bhumika Goyal Committed by Takashi Iwai
Browse files

ALSA: declare snd_kcontrol_new structures as const



Declare snd_kcontrol_new structures as const as they are only passed 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.
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;

Cross compiled these files:
sound/aoa/codecs/tas.c - powerpc
sound/mips/{hal2.c/sgio2audio.c} - mips
sound/ppc/{awacs.c/beep.c/tumbler.c} - powerpc
sound/soc/sh/siu_dai.c - sh
Could not find an architecture to compile sound/sh/aica.c.

Signed-off-by: default avatarBhumika Goyal <bhumirks@gmail.com>
Acked-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 2c4842d3
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -271,7 +271,7 @@ static int tas_snd_vol_put(struct snd_kcontrol *kcontrol,
	return 1;
}

static struct snd_kcontrol_new volume_control = {
static const struct snd_kcontrol_new volume_control = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Master Playback Volume",
	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
@@ -314,7 +314,7 @@ static int tas_snd_mute_put(struct snd_kcontrol *kcontrol,
	return 1;
}

static struct snd_kcontrol_new mute_control = {
static const struct snd_kcontrol_new mute_control = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Master Playback Switch",
	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
@@ -426,7 +426,7 @@ static int tas_snd_drc_range_put(struct snd_kcontrol *kcontrol,
	return 1;
}

static struct snd_kcontrol_new drc_range_control = {
static const struct snd_kcontrol_new drc_range_control = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "DRC Range",
	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
@@ -466,7 +466,7 @@ static int tas_snd_drc_switch_put(struct snd_kcontrol *kcontrol,
	return 1;
}

static struct snd_kcontrol_new drc_switch_control = {
static const struct snd_kcontrol_new drc_switch_control = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "DRC Range Switch",
	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
@@ -524,7 +524,7 @@ static int tas_snd_capture_source_put(struct snd_kcontrol *kcontrol,
	return 1;
}

static struct snd_kcontrol_new capture_source_control = {
static const struct snd_kcontrol_new capture_source_control = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	/* If we name this 'Input Source', it properly shows up in
	 * alsamixer as a selection, * but it's shown under the
@@ -586,7 +586,7 @@ static int tas_snd_treble_put(struct snd_kcontrol *kcontrol,
	return 1;
}

static struct snd_kcontrol_new treble_control = {
static const struct snd_kcontrol_new treble_control = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Treble",
	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
@@ -637,7 +637,7 @@ static int tas_snd_bass_put(struct snd_kcontrol *kcontrol,
	return 1;
}

static struct snd_kcontrol_new bass_control = {
static const struct snd_kcontrol_new bass_control = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Bass",
	.access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
+4 −4
Original line number Diff line number Diff line
@@ -707,7 +707,7 @@ static int detect_choice_put(struct snd_kcontrol *kcontrol,
	return 1;
}

static struct snd_kcontrol_new headphone_detect_choice = {
static const struct snd_kcontrol_new headphone_detect_choice = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Headphone Detect Autoswitch",
	.info = control_info,
@@ -717,7 +717,7 @@ static struct snd_kcontrol_new headphone_detect_choice = {
	.private_value = 0,
};

static struct snd_kcontrol_new lineout_detect_choice = {
static const struct snd_kcontrol_new lineout_detect_choice = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Line-Out Detect Autoswitch",
	.info = control_info,
@@ -749,7 +749,7 @@ static int detected_get(struct snd_kcontrol *kcontrol,
	return 0;
}

static struct snd_kcontrol_new headphone_detected = {
static const struct snd_kcontrol_new headphone_detected = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Headphone Detected",
	.info = control_info,
@@ -758,7 +758,7 @@ static struct snd_kcontrol_new headphone_detected = {
	.private_value = 0,
};

static struct snd_kcontrol_new lineout_detected = {
static const struct snd_kcontrol_new lineout_detected = {
	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
	.name = "Line-Out Detected",
	.info = control_info,
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ static int jack_detect_kctl_get(struct snd_kcontrol *kcontrol,
	return 0;
}

static struct snd_kcontrol_new jack_detect_kctl = {
static const struct snd_kcontrol_new jack_detect_kctl = {
	/* name is filled later */
	.iface = SNDRV_CTL_ELEM_IFACE_CARD,
	.access = SNDRV_CTL_ELEM_ACCESS_READ,
+12 −12
Original line number Diff line number Diff line
@@ -455,7 +455,7 @@ static int vx_output_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_ele
	return 0;
}

static struct snd_kcontrol_new vx_control_output_level = {
static const struct snd_kcontrol_new vx_control_output_level = {
	.iface =	SNDRV_CTL_ELEM_IFACE_MIXER,
	.access =	(SNDRV_CTL_ELEM_ACCESS_READWRITE |
			 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
@@ -514,7 +514,7 @@ static int vx_audio_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v
	return 0;
}

static struct snd_kcontrol_new vx_control_audio_src = {
static const struct snd_kcontrol_new vx_control_audio_src = {
	.iface =	SNDRV_CTL_ELEM_IFACE_MIXER,
	.name =		"Capture Source",
	.info =		vx_audio_src_info,
@@ -558,7 +558,7 @@ static int vx_clock_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
	return 0;
}

static struct snd_kcontrol_new vx_control_clock_mode = {
static const struct snd_kcontrol_new vx_control_clock_mode = {
	.iface =	SNDRV_CTL_ELEM_IFACE_MIXER,
	.name =		"Clock Mode",
	.info =		vx_clock_mode_info,
@@ -717,7 +717,7 @@ static int vx_monitor_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_

static const DECLARE_TLV_DB_SCALE(db_scale_audio_gain, -10975, 25, 0);

static struct snd_kcontrol_new vx_control_audio_gain = {
static const struct snd_kcontrol_new vx_control_audio_gain = {
	.iface =	SNDRV_CTL_ELEM_IFACE_MIXER,
	.access =	(SNDRV_CTL_ELEM_ACCESS_READWRITE |
			 SNDRV_CTL_ELEM_ACCESS_TLV_READ),
@@ -727,14 +727,14 @@ static struct snd_kcontrol_new vx_control_audio_gain = {
	.put =          vx_audio_gain_put,
	.tlv = { .p = db_scale_audio_gain },
};
static struct snd_kcontrol_new vx_control_output_switch = {
static const struct snd_kcontrol_new vx_control_output_switch = {
	.iface =	SNDRV_CTL_ELEM_IFACE_MIXER,
	.name =         "PCM Playback Switch",
	.info =         vx_audio_sw_info,
	.get =          vx_audio_sw_get,
	.put =          vx_audio_sw_put
};
static struct snd_kcontrol_new vx_control_monitor_gain = {
static const struct snd_kcontrol_new vx_control_monitor_gain = {
	.iface =	SNDRV_CTL_ELEM_IFACE_MIXER,
	.name =         "Monitoring Volume",
	.access =	(SNDRV_CTL_ELEM_ACCESS_READWRITE |
@@ -744,7 +744,7 @@ static struct snd_kcontrol_new vx_control_monitor_gain = {
	.put =          vx_audio_monitor_put,
	.tlv = { .p = db_scale_audio_gain },
};
static struct snd_kcontrol_new vx_control_monitor_switch = {
static const struct snd_kcontrol_new vx_control_monitor_switch = {
	.iface =	SNDRV_CTL_ELEM_IFACE_MIXER,
	.name =         "Monitoring Switch",
	.info =         vx_audio_sw_info,	/* shared */
@@ -805,7 +805,7 @@ static int vx_iec958_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_valu
	return 0;
}

static struct snd_kcontrol_new vx_control_iec958_mask = {
static const struct snd_kcontrol_new vx_control_iec958_mask = {
	.access =	SNDRV_CTL_ELEM_ACCESS_READ,
	.iface =	SNDRV_CTL_ELEM_IFACE_PCM,
	.name =		SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK),
@@ -813,7 +813,7 @@ static struct snd_kcontrol_new vx_control_iec958_mask = {
	.get =		vx_iec958_mask_get,
};

static struct snd_kcontrol_new vx_control_iec958 = {
static const struct snd_kcontrol_new vx_control_iec958 = {
	.iface =	SNDRV_CTL_ELEM_IFACE_PCM,
	.name =         SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
	.info =         vx_iec958_info,
@@ -878,7 +878,7 @@ static int vx_saturation_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_
	return 0;
}

static struct snd_kcontrol_new vx_control_vu_meter = {
static const struct snd_kcontrol_new vx_control_vu_meter = {
	.iface =	SNDRV_CTL_ELEM_IFACE_MIXER,
	.access =	SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
	/* name will be filled later */
@@ -886,7 +886,7 @@ static struct snd_kcontrol_new vx_control_vu_meter = {
	.get =		vx_vu_meter_get,
};

static struct snd_kcontrol_new vx_control_peak_meter = {
static const struct snd_kcontrol_new vx_control_peak_meter = {
	.iface =	SNDRV_CTL_ELEM_IFACE_MIXER,
	.access =	SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
	/* name will be filled later */
@@ -894,7 +894,7 @@ static struct snd_kcontrol_new vx_control_peak_meter = {
	.get =		vx_peak_meter_get,
};

static struct snd_kcontrol_new vx_control_saturation = {
static const struct snd_kcontrol_new vx_control_saturation = {
	.iface =	SNDRV_CTL_ELEM_IFACE_MIXER,
	.name =		"Input Saturation",
	.access =	SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
+4 −4
Original line number Diff line number Diff line
@@ -396,7 +396,7 @@ static int special_clk_ctl_put(struct snd_kcontrol *kctl,

	return err;
}
static struct snd_kcontrol_new special_clk_ctl = {
static const struct snd_kcontrol_new special_clk_ctl = {
	.name	= "Clock Source",
	.iface	= SNDRV_CTL_ELEM_IFACE_MIXER,
	.access	= SNDRV_CTL_ELEM_ACCESS_READWRITE,
@@ -429,7 +429,7 @@ static int special_sync_ctl_get(struct snd_kcontrol *kctl,

	return 0;
}
static struct snd_kcontrol_new special_sync_ctl = {
static const struct snd_kcontrol_new special_sync_ctl = {
	.name	= "Sync Status",
	.iface	= SNDRV_CTL_ELEM_IFACE_MIXER,
	.access	= SNDRV_CTL_ELEM_ACCESS_READ,
@@ -521,7 +521,7 @@ static int special_dig_in_iface_ctl_set(struct snd_kcontrol *kctl,
	mutex_unlock(&bebob->mutex);
	return err;
}
static struct snd_kcontrol_new special_dig_in_iface_ctl = {
static const struct snd_kcontrol_new special_dig_in_iface_ctl = {
	.name	= "Digital Input Interface",
	.iface	= SNDRV_CTL_ELEM_IFACE_MIXER,
	.access	= SNDRV_CTL_ELEM_ACCESS_READWRITE,
@@ -577,7 +577,7 @@ static int special_dig_out_iface_ctl_set(struct snd_kcontrol *kctl,
	mutex_unlock(&bebob->mutex);
	return err;
}
static struct snd_kcontrol_new special_dig_out_iface_ctl = {
static const struct snd_kcontrol_new special_dig_out_iface_ctl = {
	.name	= "Digital Output Interface",
	.iface	= SNDRV_CTL_ELEM_IFACE_MIXER,
	.access	= SNDRV_CTL_ELEM_ACCESS_READWRITE,
Loading