All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org
Subject: Re: [PATCH 03/10] ALSA: control: Use standard printk	helpers
Date: Wed, 12 Feb 2014 19:56:24 +0100	[thread overview]
Message-ID: <s5hha84f9d3.wl%tiwai@suse.de> (raw)
In-Reply-To: <1392204792-12655-4-git-send-email-tiwai@suse.de>

At Wed, 12 Feb 2014 12:33:05 +0100,
Takashi Iwai wrote:
> 
> Use dev_err() & co as much as possible.  If not available (no device
> assigned at the calling point), use pr_xxx() helpers instead.
> 
> For simplicity, introduce new helpers for pcm stream, pcm_err(), etc.
> 
> Signed-off-by: Takashi Iwai <tiwai@suse.de>

The subject should be "pcm" instead of "control".  Fixed in git tree
topic/snd-card-dev branch.


Takashi

> ---
>  include/sound/pcm.h     |  8 ++++++++
>  sound/core/pcm.c        | 12 +++++++-----
>  sound/core/pcm_lib.c    | 27 +++++++++++++--------------
>  sound/core/pcm_native.c | 47 ++++++++++++++++++++++++-----------------------
>  sound/core/pcm_timer.c  |  4 +++-
>  5 files changed, 55 insertions(+), 43 deletions(-)
> 
> diff --git a/include/sound/pcm.h b/include/sound/pcm.h
> index 4883499ab38b..b4d6697085fe 100644
> --- a/include/sound/pcm.h
> +++ b/include/sound/pcm.h
> @@ -1141,4 +1141,12 @@ static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format)
>  	return 1ULL << (__force int) pcm_format;
>  }
>  
> +/* printk helpers */
> +#define pcm_err(pcm, fmt, args...) \
> +	dev_err((pcm)->card->dev, fmt, ##args)
> +#define pcm_warn(pcm, fmt, args...) \
> +	dev_warn((pcm)->card->dev, fmt, ##args)
> +#define pcm_dbg(pcm, fmt, args...) \
> +	dev_dbg((pcm)->card->dev, fmt, ##args)
> +
>  #endif /* __SOUND_PCM_H */
> diff --git a/sound/core/pcm.c b/sound/core/pcm.c
> index 091a05c1d5b3..9defdaef520b 100644
> --- a/sound/core/pcm.c
> +++ b/sound/core/pcm.c
> @@ -338,7 +338,8 @@ static void snd_pcm_proc_info_read(struct snd_pcm_substream *substream,
>  
>  	info = kmalloc(sizeof(*info), GFP_KERNEL);
>  	if (! info) {
> -		printk(KERN_DEBUG "snd_pcm_proc_info_read: cannot malloc\n");
> +		pcm_dbg(substream->pcm,
> +			"snd_pcm_proc_info_read: cannot malloc\n");
>  		return;
>  	}
>  
> @@ -660,7 +661,7 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
>  	if (substream_count > 0 && !pcm->internal) {
>  		err = snd_pcm_stream_proc_init(pstr);
>  		if (err < 0) {
> -			snd_printk(KERN_ERR "Error in snd_pcm_stream_proc_init\n");
> +			pcm_err(pcm, "Error in snd_pcm_stream_proc_init\n");
>  			return err;
>  		}
>  	}
> @@ -668,7 +669,7 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
>  	for (idx = 0, prev = NULL; idx < substream_count; idx++) {
>  		substream = kzalloc(sizeof(*substream), GFP_KERNEL);
>  		if (substream == NULL) {
> -			snd_printk(KERN_ERR "Cannot allocate PCM substream\n");
> +			pcm_err(pcm, "Cannot allocate PCM substream\n");
>  			return -ENOMEM;
>  		}
>  		substream->pcm = pcm;
> @@ -685,7 +686,8 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count)
>  		if (!pcm->internal) {
>  			err = snd_pcm_substream_proc_init(substream);
>  			if (err < 0) {
> -				snd_printk(KERN_ERR "Error in snd_pcm_stream_proc_init\n");
> +				pcm_err(pcm,
> +					"Error in snd_pcm_stream_proc_init\n");
>  				if (prev == NULL)
>  					pstr->substream = NULL;
>  				else
> @@ -724,7 +726,7 @@ static int _snd_pcm_new(struct snd_card *card, const char *id, int device,
>  		*rpcm = NULL;
>  	pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
>  	if (pcm == NULL) {
> -		snd_printk(KERN_ERR "Cannot allocate PCM\n");
> +		dev_err(card->dev, "Cannot allocate PCM\n");
>  		return -ENOMEM;
>  	}
>  	pcm->card = card;
> diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
> index a2104671f51d..6630a4eb8393 100644
> --- a/sound/core/pcm_lib.c
> +++ b/sound/core/pcm_lib.c
> @@ -174,7 +174,7 @@ static void xrun(struct snd_pcm_substream *substream)
>  	if (xrun_debug(substream, XRUN_DEBUG_BASIC)) {
>  		char name[16];
>  		snd_pcm_debug_name(substream, name, sizeof(name));
> -		snd_printd(KERN_DEBUG "XRUN: %s\n", name);
> +		pcm_warn(substream->pcm, "XRUN: %s\n", name);
>  		dump_stack_on_xrun(substream);
>  	}
>  }
> @@ -184,9 +184,7 @@ static void xrun(struct snd_pcm_substream *substream)
>  	do {								\
>  		if (xrun_debug(substream, XRUN_DEBUG_BASIC)) {		\
>  			xrun_log_show(substream);			\
> -			if (snd_printd_ratelimit()) {			\
> -				snd_printd("PCM: " fmt, ##args);	\
> -			}						\
> +			pr_err_ratelimited("ALSA: PCM: " fmt, ##args);	\
>  			dump_stack_on_xrun(substream);			\
>  		}							\
>  	} while (0)
> @@ -253,7 +251,7 @@ static void xrun_log_show(struct snd_pcm_substream *substream)
>  		entry = &log->entries[idx];
>  		if (entry->period_size == 0)
>  			break;
> -		snd_printd("hwptr log: %s: %sj=%lu, pos=%ld/%ld/%ld, "
> +		pr_info("hwptr log: %s: %sj=%lu, pos=%ld/%ld/%ld, "
>  			   "hwptr=%ld/%ld\n",
>  			   name, entry->in_interrupt ? "[Q] " : "",
>  			   entry->jiffies,
> @@ -342,14 +340,14 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
>  		return -EPIPE;
>  	}
>  	if (pos >= runtime->buffer_size) {
> -		if (snd_printd_ratelimit()) {
> +		if (printk_ratelimit()) {
>  			char name[16];
>  			snd_pcm_debug_name(substream, name, sizeof(name));
>  			xrun_log_show(substream);
> -			snd_printd(KERN_ERR  "BUG: %s, pos = %ld, "
> -				   "buffer size = %ld, period size = %ld\n",
> -				   name, pos, runtime->buffer_size,
> -				   runtime->period_size);
> +			pcm_err(substream->pcm,
> +				"BUG: %s, pos = %ld, buffer size = %ld, period size = %ld\n",
> +				name, pos, runtime->buffer_size,
> +				runtime->period_size);
>  		}
>  		pos = 0;
>  	}
> @@ -394,8 +392,8 @@ static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
>  			XRUN_DEBUG_PERIODUPDATE : XRUN_DEBUG_HWPTRUPDATE)) {
>  		char name[16];
>  		snd_pcm_debug_name(substream, name, sizeof(name));
> -		snd_printd("%s_update: %s: pos=%u/%u/%u, "
> -			   "hwptr=%ld/%ld/%ld/%ld\n",
> +		pcm_dbg(substream->pcm,
> +			"%s_update: %s: pos=%u/%u/%u, hwptr=%ld/%ld/%ld/%ld\n",
>  			   in_interrupt ? "period" : "hwptr",
>  			   name,
>  			   (unsigned int)pos,
> @@ -1941,8 +1939,9 @@ static int wait_for_avail(struct snd_pcm_substream *substream,
>  			continue;
>  		}
>  		if (!tout) {
> -			snd_printd("%s write error (DMA or IRQ trouble?)\n",
> -				   is_playback ? "playback" : "capture");
> +			pcm_dbg(substream->pcm,
> +				"%s write error (DMA or IRQ trouble?)\n",
> +				is_playback ? "playback" : "capture");
>  			err = -EIO;
>  			break;
>  		}
> diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
> index e3664116736b..b653ab001fba 100644
> --- a/sound/core/pcm_native.c
> +++ b/sound/core/pcm_native.c
> @@ -190,12 +190,12 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
>  		if (!(params->rmask & (1 << k)))
>  			continue;
>  #ifdef RULES_DEBUG
> -		printk(KERN_DEBUG "%s = ", snd_pcm_hw_param_names[k]);
> -		printk("%04x%04x%04x%04x -> ", m->bits[3], m->bits[2], m->bits[1], m->bits[0]);
> +		pr_debug("%s = ", snd_pcm_hw_param_names[k]);
> +		pr_cont("%04x%04x%04x%04x -> ", m->bits[3], m->bits[2], m->bits[1], m->bits[0]);
>  #endif
>  		changed = snd_mask_refine(m, constrs_mask(constrs, k));
>  #ifdef RULES_DEBUG
> -		printk("%04x%04x%04x%04x\n", m->bits[3], m->bits[2], m->bits[1], m->bits[0]);
> +		pr_cont("%04x%04x%04x%04x\n", m->bits[3], m->bits[2], m->bits[1], m->bits[0]);
>  #endif
>  		if (changed)
>  			params->cmask |= 1 << k;
> @@ -210,21 +210,21 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
>  		if (!(params->rmask & (1 << k)))
>  			continue;
>  #ifdef RULES_DEBUG
> -		printk(KERN_DEBUG "%s = ", snd_pcm_hw_param_names[k]);
> +		pr_debug("%s = ", snd_pcm_hw_param_names[k]);
>  		if (i->empty)
> -			printk("empty");
> +			pr_cont("empty");
>  		else
> -			printk("%c%u %u%c", 
> +			pr_cont("%c%u %u%c",
>  			       i->openmin ? '(' : '[', i->min,
>  			       i->max, i->openmax ? ')' : ']');
> -		printk(" -> ");
> +		pr_cont(" -> ");
>  #endif
>  		changed = snd_interval_refine(i, constrs_interval(constrs, k));
>  #ifdef RULES_DEBUG
>  		if (i->empty)
> -			printk("empty\n");
> +			pr_cont("empty\n");
>  		else 
> -			printk("%c%u %u%c\n", 
> +			pr_cont("%c%u %u%c\n",
>  			       i->openmin ? '(' : '[', i->min,
>  			       i->max, i->openmax ? ')' : ']');
>  #endif
> @@ -255,18 +255,18 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
>  			if (!doit)
>  				continue;
>  #ifdef RULES_DEBUG
> -			printk(KERN_DEBUG "Rule %d [%p]: ", k, r->func);
> +			pr_debug("Rule %d [%p]: ", k, r->func);
>  			if (r->var >= 0) {
> -				printk("%s = ", snd_pcm_hw_param_names[r->var]);
> +				pr_cont("%s = ", snd_pcm_hw_param_names[r->var]);
>  				if (hw_is_mask(r->var)) {
>  					m = hw_param_mask(params, r->var);
> -					printk("%x", *m->bits);
> +					pr_cont("%x", *m->bits);
>  				} else {
>  					i = hw_param_interval(params, r->var);
>  					if (i->empty)
> -						printk("empty");
> +						pr_cont("empty");
>  					else
> -						printk("%c%u %u%c", 
> +						pr_cont("%c%u %u%c",
>  						       i->openmin ? '(' : '[', i->min,
>  						       i->max, i->openmax ? ')' : ']');
>  				}
> @@ -275,19 +275,19 @@ int snd_pcm_hw_refine(struct snd_pcm_substream *substream,
>  			changed = r->func(params, r);
>  #ifdef RULES_DEBUG
>  			if (r->var >= 0) {
> -				printk(" -> ");
> +				pr_cont(" -> ");
>  				if (hw_is_mask(r->var))
> -					printk("%x", *m->bits);
> +					pr_cont("%x", *m->bits);
>  				else {
>  					if (i->empty)
> -						printk("empty");
> +						pr_cont("empty");
>  					else
> -						printk("%c%u %u%c", 
> +						pr_cont("%c%u %u%c",
>  						       i->openmin ? '(' : '[', i->min,
>  						       i->max, i->openmax ? ')' : ']');
>  				}
>  			}
> -			printk("\n");
> +			pr_cont("\n");
>  #endif
>  			rstamps[k] = stamp;
>  			if (changed && r->var >= 0) {
> @@ -1541,7 +1541,8 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream,
>  			if (substream->runtime->status->state == SNDRV_PCM_STATE_SUSPENDED)
>  				result = -ESTRPIPE;
>  			else {
> -				snd_printd("playback drain error (DMA or IRQ trouble?)\n");
> +				dev_dbg(substream->pcm->card->dev,
> +					"playback drain error (DMA or IRQ trouble?)\n");
>  				snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP);
>  				result = -EIO;
>  			}
> @@ -2066,7 +2067,7 @@ int snd_pcm_open_substream(struct snd_pcm *pcm, int stream,
>  
>  	err = snd_pcm_hw_constraints_init(substream);
>  	if (err < 0) {
> -		snd_printd("snd_pcm_hw_constraints_init failed\n");
> +		pcm_dbg(pcm, "snd_pcm_hw_constraints_init failed\n");
>  		goto error;
>  	}
>  
> @@ -2077,7 +2078,7 @@ int snd_pcm_open_substream(struct snd_pcm *pcm, int stream,
>  
>  	err = snd_pcm_hw_constraints_complete(substream);
>  	if (err < 0) {
> -		snd_printd("snd_pcm_hw_constraints_complete failed\n");
> +		pcm_dbg(pcm, "snd_pcm_hw_constraints_complete failed\n");
>  		goto error;
>  	}
>  
> @@ -2609,7 +2610,7 @@ static int snd_pcm_common_ioctl1(struct file *file,
>  		return res;
>  	}
>  	}
> -	snd_printd("unknown ioctl = 0x%x\n", cmd);
> +	pcm_dbg(substream->pcm, "unknown ioctl = 0x%x\n", cmd);
>  	return -ENOTTY;
>  }
>  
> diff --git a/sound/core/pcm_timer.c b/sound/core/pcm_timer.c
> index b01d9481d632..20ecd8f18080 100644
> --- a/sound/core/pcm_timer.c
> +++ b/sound/core/pcm_timer.c
> @@ -53,7 +53,9 @@ void snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream)
>  		post *= 2;
>  	}
>  	if (rate == 0) {
> -		snd_printk(KERN_ERR "pcm timer resolution out of range (rate = %u, period_size = %lu)\n", runtime->rate, runtime->period_size);
> +		pcm_err(substream->pcm,
> +			"pcm timer resolution out of range (rate = %u, period_size = %lu)\n",
> +			runtime->rate, runtime->period_size);
>  		runtime->timer_resolution = -1;
>  		return;
>  	}
> -- 
> 1.8.5.2
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> 

  reply	other threads:[~2014-02-12 18:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-12 11:33 [PATCH RFC 00/10] Use standard printk helpers for ALSA core codes Takashi Iwai
2014-02-12 11:33 ` [PATCH 01/10] ALSA: seq_oss: Drop debug prints Takashi Iwai
2014-02-12 11:33 ` [PATCH 02/10] ALSA: control: Use standard printk helpers Takashi Iwai
2014-02-12 11:33 ` [PATCH 03/10] " Takashi Iwai
2014-02-12 18:56   ` Takashi Iwai [this message]
2014-02-12 11:33 ` [PATCH 04/10] ALSA: core: " Takashi Iwai
2014-02-12 18:57   ` Takashi Iwai
2014-02-12 11:33 ` [PATCH 05/10] ALSA: rawmidi: " Takashi Iwai
2014-02-12 11:33 ` [PATCH 06/10] ALSA: hwdep: " Takashi Iwai
2014-02-12 11:33 ` [PATCH 07/10] ALSA: oss: " Takashi Iwai
2014-02-12 11:33 ` [PATCH 08/10] ALSA: timer: " Takashi Iwai
2014-02-12 11:33 ` [PATCH 09/10] ALSA: seq: " Takashi Iwai
2014-02-12 11:33 ` [PATCH 10/10] ALSA: seq_oss: " Takashi Iwai
2014-02-14 12:01 ` [PATCH RFC 00/10] Use standard printk helpers for ALSA core codes Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hha84f9d3.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.