All of lore.kernel.org
 help / color / mirror / Atom feed
* export pcm_debug_name?
@ 2011-03-30 22:08 Eliot Blennerhassett
  2011-03-31  9:52 ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Eliot Blennerhassett @ 2011-03-30 22:08 UTC (permalink / raw)
  To: alsa-devel; +Cc: Takashi Iwai

Currently defined locally in pcm_lib.c, this function would be useful
for debug output from drivers too?

Any objection to exporting this function?


> static void pcm_debug_name(struct snd_pcm_substream *substream,
> 			   char *name, size_t len)
> {
> 	snprintf(name, len, "pcmC%dD%d%c:%d",
> 		 substream->pcm->card->number,
> 		 substream->pcm->device,
> 		 substream->stream ? 'c' : 'p',
> 		 substream->number);
> }

-- 
Eliot Blennerhassett
AudioScience Inc.

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

* Re: export pcm_debug_name?
  2011-03-30 22:08 export pcm_debug_name? Eliot Blennerhassett
@ 2011-03-31  9:52 ` Takashi Iwai
  2011-03-31 23:41   ` Eliot Blennerhassett
  0 siblings, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2011-03-31  9:52 UTC (permalink / raw)
  To: Eliot Blennerhassett; +Cc: alsa-devel

At Thu, 31 Mar 2011 11:08:24 +1300,
Eliot Blennerhassett wrote:
> 
> Currently defined locally in pcm_lib.c, this function would be useful
> for debug output from drivers too?
> 
> Any objection to exporting this function?

It's fine to me.  Or, can this be a static inline function?


thanks,

Takashi

> 
> 
> > static void pcm_debug_name(struct snd_pcm_substream *substream,
> > 			   char *name, size_t len)
> > {
> > 	snprintf(name, len, "pcmC%dD%d%c:%d",
> > 		 substream->pcm->card->number,
> > 		 substream->pcm->device,
> > 		 substream->stream ? 'c' : 'p',
> > 		 substream->number);
> > }
> 
> -- 
> Eliot Blennerhassett
> AudioScience Inc.
> 

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

* Re: export pcm_debug_name?
  2011-03-31  9:52 ` Takashi Iwai
@ 2011-03-31 23:41   ` Eliot Blennerhassett
  2011-04-01 13:07     ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Eliot Blennerhassett @ 2011-03-31 23:41 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

On 31/03/11 22:52, Takashi Iwai wrote:
> At Thu, 31 Mar 2011 11:08:24 +1300,
> Eliot Blennerhassett wrote:
>>
>> Currently  pcm_debug_name is defined locally in pcm_lib.c, this function would be useful
>> for debug output from drivers too?
>>
>> Any objection to exporting this function?
> 
> It's fine to me.  Or, can this be a static inline function?

Thanks Takashi

I'm happy either way. I'd leave it to you and Jaroslav to decide.

BTW Should it become "snd_pcm_debug_name" ?

One thing I'm not sure about is whether this is a debug_only function,
and if so, what to do about the necessary variable required to hold the
name for printing? I.e when debug is turned off, will get warnings about
unused variable "name"

#ifdef CONFIG_SND_DEBUG
static inline pcm_debug_name etc.
#else
#define pcm_debug_name(s,n,l) while (0) do {}
#endif

Typical usage

static int somefunc(struct snd_pcm_substream * substream)
{
#ifdef CONFIG_SND_DEBUG
  char name[16];
#endif

  pcm_debug_name(substream, name, sizeof(name))
  snd_printd("%s foo %d\n", name, other);
  ...
}

Is there a nice way to avoid the #ifdef around name[]?

--
Eliot

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

* Re: export pcm_debug_name?
  2011-03-31 23:41   ` Eliot Blennerhassett
@ 2011-04-01 13:07     ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2011-04-01 13:07 UTC (permalink / raw)
  To: Eliot Blennerhassett; +Cc: alsa-devel

At Fri, 01 Apr 2011 12:41:15 +1300,
Eliot Blennerhassett wrote:
> 
> On 31/03/11 22:52, Takashi Iwai wrote:
> > At Thu, 31 Mar 2011 11:08:24 +1300,
> > Eliot Blennerhassett wrote:
> >>
> >> Currently  pcm_debug_name is defined locally in pcm_lib.c, this function would be useful
> >> for debug output from drivers too?
> >>
> >> Any objection to exporting this function?
> > 
> > It's fine to me.  Or, can this be a static inline function?
> 
> Thanks Takashi
> 
> I'm happy either way. I'd leave it to you and Jaroslav to decide.
> 
> BTW Should it become "snd_pcm_debug_name" ?

Yes, I suppose so.


> One thing I'm not sure about is whether this is a debug_only function,
> and if so, what to do about the necessary variable required to hold the
> name for printing? I.e when debug is turned off, will get warnings about
> unused variable "name"
> 
> #ifdef CONFIG_SND_DEBUG
> static inline pcm_debug_name etc.
> #else
> #define pcm_debug_name(s,n,l) while (0) do {}
> #endif
> 
> Typical usage
> 
> static int somefunc(struct snd_pcm_substream * substream)
> {
> #ifdef CONFIG_SND_DEBUG
>   char name[16];
> #endif
> 
>   pcm_debug_name(substream, name, sizeof(name))
>   snd_printd("%s foo %d\n", name, other);
>   ...
> }
> 
> Is there a nice way to avoid the #ifdef around name[]?

I guess it can be avoided by defining a dummy function as static inline,

static inline void
snd_pcm_debug_name(struct snd_pcm_substream *stream, char *buf, size_t size)
{
}

But, I'm not sure whether it's good.  For example, in your case above,
one might think to change from snd_printd() to printk().  Now you'll get
garbages in the name field, and it might give Oops.
So, I guess at least it should initialize the string,

static inline void
snd_pcm_debug_name(struct snd_pcm_substream *stream, char *buf, size_t size)
{
	*buf = 0;
}

The compiler would optimize out such ops, anyway.


thanks,

Takashi

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

end of thread, other threads:[~2011-04-01 13:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-30 22:08 export pcm_debug_name? Eliot Blennerhassett
2011-03-31  9:52 ` Takashi Iwai
2011-03-31 23:41   ` Eliot Blennerhassett
2011-04-01 13:07     ` 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.