Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Using ARRAY_SIZE macro when setting up ASoC audio map?
@ 2008-02-27 11:49 Jarkko Nikula
  2008-02-27 12:34 ` Mark Brown
  2008-02-27 16:15 ` Takashi Iwai
  0 siblings, 2 replies; 6+ messages in thread
From: Jarkko Nikula @ 2008-02-27 11:49 UTC (permalink / raw)
  To: alsa-devel

Does an example patch to spitz below make any sense? Yep, noticed when forgot to add array terminator to own code :-)

diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c
index d56709e..1cffcd3 100644
--- a/sound/soc/pxa/spitz.c
+++ b/sound/soc/pxa/spitz.c
@@ -268,8 +268,6 @@ static const char *audio_map[][3] = {
 
 	/* line is connected to input 1 - no bias */
 	{"LINPUT1", NULL, "Line Jack"},
-
-	{NULL, NULL, NULL},
 };
 
 static const char *jack_function[] = {"Headphone", "Mic", "Line", "Headset",
@@ -317,7 +315,7 @@ static int spitz_wm8750_init(struct snd_soc_codec *codec)
 	}
 
 	/* Set up spitz specific audio path audio_map */
-	for (i = 0; audio_map[i][0] != NULL; i++) {
+	for (i = 0; i < ARRAY_SIZE(audio_map); i++) {
 		snd_soc_dapm_connect_input(codec, audio_map[i][0],
 			audio_map[i][1], audio_map[i][2]);
 	}

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

* Re: Using ARRAY_SIZE macro when setting up ASoC audio map?
  2008-02-27 11:49 Using ARRAY_SIZE macro when setting up ASoC audio map? Jarkko Nikula
@ 2008-02-27 12:34 ` Mark Brown
  2008-02-27 13:11   ` Jarkko Nikula
  2008-02-27 16:15 ` Takashi Iwai
  1 sibling, 1 reply; 6+ messages in thread
From: Mark Brown @ 2008-02-27 12:34 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: alsa-devel

On Wed, Feb 27, 2008 at 01:49:23PM +0200, Jarkko Nikula wrote:
> Does an example patch to spitz below make any sense? Yep, noticed when forgot to add array terminator to own code :-)

Yes, sure.

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

* Re: Using ARRAY_SIZE macro when setting up ASoC audio map?
  2008-02-27 12:34 ` Mark Brown
@ 2008-02-27 13:11   ` Jarkko Nikula
  2008-02-27 22:01     ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Jarkko Nikula @ 2008-02-27 13:11 UTC (permalink / raw)
  To: ext Mark Brown; +Cc: alsa-devel

On Wed, 27 Feb 2008 12:34:18 +0000
"ext Mark Brown" <broonie@opensource.wolfsonmicro.com> wrote:

> On Wed, Feb 27, 2008 at 01:49:23PM +0200, Jarkko Nikula wrote:
> > Does an example patch to spitz below make any sense? Yep, noticed
> > when forgot to add array terminator to own code :-)
> 
> Yes, sure.
>
Ok. Probably not worth to change now to n different drivers but worth
to take into account when reviewing new ones or doing some other
cleanups.

-- 
Jarkko

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

* Re: Using ARRAY_SIZE macro when setting up ASoC audio map?
  2008-02-27 11:49 Using ARRAY_SIZE macro when setting up ASoC audio map? Jarkko Nikula
  2008-02-27 12:34 ` Mark Brown
@ 2008-02-27 16:15 ` Takashi Iwai
  2008-02-28  7:15   ` Jarkko Nikula
  1 sibling, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2008-02-27 16:15 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: alsa-devel

At Wed, 27 Feb 2008 13:49:23 +0200,
Jarkko Nikula wrote:
> 
> Does an example patch to spitz below make any sense? Yep, noticed when forgot to add array terminator to own code :-)
> 
> diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c
> index d56709e..1cffcd3 100644
> --- a/sound/soc/pxa/spitz.c
> +++ b/sound/soc/pxa/spitz.c
> @@ -268,8 +268,6 @@ static const char *audio_map[][3] = {
>  
>  	/* line is connected to input 1 - no bias */
>  	{"LINPUT1", NULL, "Line Jack"},
> -
> -	{NULL, NULL, NULL},
>  };
>  
>  static const char *jack_function[] = {"Headphone", "Mic", "Line", "Headset",
> @@ -317,7 +315,7 @@ static int spitz_wm8750_init(struct snd_soc_codec *codec)
>  	}
>  
>  	/* Set up spitz specific audio path audio_map */
> -	for (i = 0; audio_map[i][0] != NULL; i++) {
> +	for (i = 0; i < ARRAY_SIZE(audio_map); i++) {

Does ARRAY_SIZE() work with two-dimensional arrays?  Just wondering...


Takashi

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

* Re: Using ARRAY_SIZE macro when setting up ASoC audio map?
  2008-02-27 13:11   ` Jarkko Nikula
@ 2008-02-27 22:01     ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2008-02-27 22:01 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: alsa-devel

On Wed, Feb 27, 2008 at 03:11:51PM +0200, Jarkko Nikula wrote:

> Ok. Probably not worth to change now to n different drivers but worth
> to take into account when reviewing new ones or doing some other
> cleanups.

For ASoC v2 we've been adding bulk registration functions for everything
which should encourage that.  This hasn't been done for paths yet but
that should be done shortly.

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

* Re: Using ARRAY_SIZE macro when setting up ASoC audio map?
  2008-02-27 16:15 ` Takashi Iwai
@ 2008-02-28  7:15   ` Jarkko Nikula
  0 siblings, 0 replies; 6+ messages in thread
From: Jarkko Nikula @ 2008-02-28  7:15 UTC (permalink / raw)
  To: ext Takashi Iwai; +Cc: alsa-devel

On Wed, 27 Feb 2008 17:15:49 +0100
"ext Takashi Iwai" <tiwai@suse.de> wrote:

> >  	/* Set up spitz specific audio path audio_map */
> > -	for (i = 0; audio_map[i][0] != NULL; i++) {
> > +	for (i = 0; i < ARRAY_SIZE(audio_map); i++) {
> 
> Does ARRAY_SIZE() work with two-dimensional arrays?  Just wondering...
> 
Yes it does when counting number of rows since sizeof(arr[0])
operator in ARRAY_SIZE returns a row size in bytes when used with
two-dimensional array.

-- 
Jarkko

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

end of thread, other threads:[~2008-02-28  7:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-27 11:49 Using ARRAY_SIZE macro when setting up ASoC audio map? Jarkko Nikula
2008-02-27 12:34 ` Mark Brown
2008-02-27 13:11   ` Jarkko Nikula
2008-02-27 22:01     ` Mark Brown
2008-02-27 16:15 ` Takashi Iwai
2008-02-28  7:15   ` Jarkko Nikula

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox