Skip to contentSkip to conversation

staging: greybus: audio: Limit scope of jack-related variables

PATCH In review Lee Yongjun 2 participants 2 messages Jan 20

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: greybus: audio: Limit scope of jack-related variables

Move jack-related variable declarations inside the CONFIG_SND_JACK conditional block.

These variables are only used when CONFIG_SND_JACK is enabled, so limiting their scope improves code clarity and avoids unused variable warnings when the option is disabled.

No functional changes intended.

---
 drivers/staging/greybus/audio_codec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/greybus/audio_codec.c +2 -2
index 444c53b4e08d..f752d5fbd685 100644
@@ -935,8 +935,6 @@ static void gbaudio_codec_cleanup(struct gbaudio_module_info *module)
 void gbaudio_unregister_module(struct gbaudio_module_info *module)
 {
 	struct snd_soc_component *comp = gbcodec->component;
-	struct gbaudio_jack *jack, *n;
-	int mask;
 
 	dev_dbg(comp->dev, "Unregister %s module\n", module->name);
 
@@ -948,6 +946,8 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module)
 	mutex_unlock(&gbcodec->lock);
 
 #ifdef CONFIG_SND_JACK
+	struct gbaudio_jack *jack, *n;
+	int mask;
 	/* free jack devices for this module jack_list */
 	list_for_each_entry_safe(jack, n, &module->jack_list, list) {
 		if (jack == &module->headset)
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 28 lines · Lee Yongjun

Move jack-related variable declarations inside the CONFIG_SND_JACK conditional block.

These variables are only used when CONFIG_SND_JACK is enabled, so limiting their scope improves code clarity and avoids unused variable warnings when the option is disabled.

No functional changes intended.

---
 drivers/staging/greybus/audio_codec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/greybus/audio_codec.c +0 -2
index 444c53b4e08d..f752d5fbd685 100644
@@ -935,8 +935,6 @@ static void gbaudio_codec_cleanup(struct gbaudio_module_info *module)
 void gbaudio_unregister_module(struct gbaudio_module_info *module)
 {
 	struct snd_soc_component *comp = gbcodec->component;
-	struct gbaudio_jack *jack, *n;
-	int mask;
 
 	dev_dbg(comp->dev, "Unregister %s module\n", module->name);
 

drivers/staging/greybus/audio_codec.c void gbaudio_unregister_module(struct gbaudio_module_info *module) · line 951

Quoted 6 lines
drivers/staging/greybus/audio_codec.c +2 -0
@@ -948,6 +946,8 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module)
 	mutex_unlock(&gbcodec->lock);
 
 #ifdef CONFIG_SND_JACK
+	struct gbaudio_jack *jack, *n;
+	int mask;
 	/* free jack devices for this module jack_list */

Please no, let's keep the variable definitions at the top of the scope please. The compiler will handle this just fine if they aren't used due to the config option not being enabled.

thanks,

greg k-h