All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] ALSA: jack: Remove hard coding of jack_switch_types array size
@ 2019-05-24 20:40 bgoswami
  2019-05-27  7:41 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: bgoswami @ 2019-05-24 20:40 UTC (permalink / raw)
  To: perex, tiwai
  Cc: alsa-devel, Banajit Goswami, plai, Gopikrishnaiah Anandan,
	broonie, srinivas.kandagatla

From: Banajit Goswami <bgoswami@codeaurora.org>

The size for jack_switch_types array is currently controlled by
a MACRO 'SND_JACK_SWITCH_TYPES', whose value needs to be updated
everytime a new jack switch type is added. Remove this MACRO
and use ARRAY_SIZE instead to get size of the array.

Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org>
---
 include/sound/jack.h | 3 ---
 sound/core/jack.c    | 4 ++--
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/include/sound/jack.h b/include/sound/jack.h
index 1e84bfb..b0791c5 100644
--- a/include/sound/jack.h
+++ b/include/sound/jack.h
@@ -68,9 +68,6 @@ enum snd_jack_types {
 	SND_JACK_BTN_5		= 0x0200,
 };
 
-/* Keep in sync with definitions above */
-#define SND_JACK_SWITCH_TYPES 6
-
 struct snd_jack {
 	struct list_head kctl_list;
 	struct snd_card *card;
diff --git a/sound/core/jack.c b/sound/core/jack.c
index 84c2a17..36b047b 100644
--- a/sound/core/jack.c
+++ b/sound/core/jack.c
@@ -33,7 +33,7 @@ struct snd_jack_kctl {
 };
 
 #ifdef CONFIG_SND_JACK_INPUT_DEV
-static int jack_switch_types[SND_JACK_SWITCH_TYPES] = {
+static int jack_switch_types[] = {
 	SW_HEADPHONE_INSERT,
 	SW_MICROPHONE_INSERT,
 	SW_LINEOUT_INSERT,
@@ -250,7 +250,7 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
 
 		jack->type = type;
 
-		for (i = 0; i < SND_JACK_SWITCH_TYPES; i++)
+		for (i = 0; i < ARRAY_SIZE(jack_switch_types); i++)
 			if (type & (1 << i))
 				input_set_capability(jack->input_dev, EV_SW,
 						     jack_switch_types[i]);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/3] ALSA: jack: Remove hard coding of jack_switch_types array size
  2019-05-24 20:40 [PATCH 1/3] ALSA: jack: Remove hard coding of jack_switch_types array size bgoswami
@ 2019-05-27  7:41 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2019-05-27  7:41 UTC (permalink / raw)
  To: bgoswami
  Cc: alsa-devel, plai, Dmitry Torokhov, Gopikrishnaiah Anandan,
	broonie, srinivas.kandagatla, linux-input

On Fri, 24 May 2019 22:40:23 +0200,
<bgoswami@codeaurora.org> wrote:
> 
> From: Banajit Goswami <bgoswami@codeaurora.org>
> 
> The size for jack_switch_types array is currently controlled by
> a MACRO 'SND_JACK_SWITCH_TYPES', whose value needs to be updated
> everytime a new jack switch type is added. Remove this MACRO
> and use ARRAY_SIZE instead to get size of the array.
> 
> Signed-off-by: Gopikrishnaiah Anandan <agopik@codeaurora.org>
> Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org>

The changes in ALSA side (this one and patch 3) look good.

Rather a bigger question is about the addition of the new input bit.
This needs the review and ack from input subsystem people.

Adding to Cc.


thanks,

Takashi


> ---
>  include/sound/jack.h | 3 ---
>  sound/core/jack.c    | 4 ++--
>  2 files changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/include/sound/jack.h b/include/sound/jack.h
> index 1e84bfb..b0791c5 100644
> --- a/include/sound/jack.h
> +++ b/include/sound/jack.h
> @@ -68,9 +68,6 @@ enum snd_jack_types {
>  	SND_JACK_BTN_5		= 0x0200,
>  };
>  
> -/* Keep in sync with definitions above */
> -#define SND_JACK_SWITCH_TYPES 6
> -
>  struct snd_jack {
>  	struct list_head kctl_list;
>  	struct snd_card *card;
> diff --git a/sound/core/jack.c b/sound/core/jack.c
> index 84c2a17..36b047b 100644
> --- a/sound/core/jack.c
> +++ b/sound/core/jack.c
> @@ -33,7 +33,7 @@ struct snd_jack_kctl {
>  };
>  
>  #ifdef CONFIG_SND_JACK_INPUT_DEV
> -static int jack_switch_types[SND_JACK_SWITCH_TYPES] = {
> +static int jack_switch_types[] = {
>  	SW_HEADPHONE_INSERT,
>  	SW_MICROPHONE_INSERT,
>  	SW_LINEOUT_INSERT,
> @@ -250,7 +250,7 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
>  
>  		jack->type = type;
>  
> -		for (i = 0; i < SND_JACK_SWITCH_TYPES; i++)
> +		for (i = 0; i < ARRAY_SIZE(jack_switch_types); i++)
>  			if (type & (1 << i))
>  				input_set_capability(jack->input_dev, EV_SW,
>  						     jack_switch_types[i]);
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-27  7:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-24 20:40 [PATCH 1/3] ALSA: jack: Remove hard coding of jack_switch_types array size bgoswami
2019-05-27  7:41 ` Takashi Iwai

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.