Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Joe Perches <joe@perches.com>, alsa-devel@alsa-project.org
Subject: Re: [PATCH 1/2] ALSA: convert "snd_printk(KERN_INFO" to "pr_info("
Date: Fri, 07 Jun 2013 07:41:14 +0200	[thread overview]
Message-ID: <s5hr4geqxz9.wl%tiwai@suse.de> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1306061643290.878-100000@iolanthe.rowland.org>

At Thu, 6 Jun 2013 16:54:06 -0400 (EDT),
Alan Stern wrote:
> 
> On Wed, 5 Jun 2013, Takashi Iwai wrote:
> 
> > At Tue, 4 Jun 2013 13:20:40 -0400 (EDT),
> > Alan Stern wrote:
> > > 
> > > The snd_printk() function prints kernel log messages, including the
> > > filename and line number if CONFIG_SND_PRINTK_VERBOSE is enabled.
> > > This may make sense for errors and warnings, but not for informational
> > > messages.  For those, a simple pr_info() is what we want.
> > > 
> > > This patch mechanically converts all occurrences of
> > > "snd_printk(KERN_INFO" to "pr_info(".  It doesn't try to tell whether
> > > the message really is informational; it relies on the existing
> > > KERN_INFO tag.
> > 
> > I agree conversion in this way.  But looking at the patch, some places
> > should be better convert with pr_warning() or pr_err().
> 
> How often do those places get printed?  I would assume that warnings 
> and errors are relatively infrequent, in which case there would be no 
> harm in changing "snd_printk(KERN_INFO" to "snd_printk(KERN_WARN" or 
> "snd_printk(KERN_ERR".

Yes.  That's my intention, too.  These shouldn't have been KERN_INFO
from the beginning.

> > Also, many places miss proper prefix, thus you'll still see the
> 
> What exactly do you mean by "proper prefix"?  KBUILD_MODNAME?  The 
> filename and line number?  The device and driver names?  Or something 
> else?

I don't mind any way if it's unique enough to identify from where the
message comes, but some people prefer (over-)unification.
Usually KBUILD_MODNAME should suffice, I guess, but still function
name or file name might be needed in addition if similar messages
appear multiple times in the same driver.  This must be all
case-by-case decision.

> > original issue the thread started from (no clue who prints the stuff).
> > This is because originally snd_printk() printed the prefix and line
> > number always.  CONFIG_SND_VERBOSE_PRINTK was introduced later since
> > some people complained about too verbose output, IIRC, while many
> > codes weren't fixed to give a proper prefix with
> > CONFIG_SND_VERBOSE_PRINTK=n.
> 
> After this patch (or after an updated version of this patch), none of 
> the snd_printk calls will be informational.  They will all be things 
> like errors and warnings.  This means they won't get printed very 
> often, so always using the verbose form shouldn't make things too bad.

Yes, it's the reason I suggested to apply always
CONFIG_SND_VERBOSE_PRINTK and drop the kconfig :)

> > Just taking a quick glance:
> > 
> > > --- usb-3.10.orig/sound/isa/opti9xx/miro.c
> > > +++ usb-3.10/sound/isa/opti9xx/miro.c
> > > @@ -1346,11 +1346,11 @@ static int snd_miro_probe(struct snd_car
> > >  		default:
> > >  			sprintf(card->shortname, 
> > >  				"unknown miro");
> > > -			snd_printk(KERN_INFO "unknown miro aci id\n");
> > > +			pr_info("unknown miro aci id\n");
> > >  			break;
> > >  		}
> > >  	} else {
> > > -		snd_printk(KERN_INFO "found unsupported aci card\n");
> > > +		pr_info("found unsupported aci card\n");
> > >  		sprintf(card->shortname, "unknown Cardinal Technologies");
> > 
> > These need proper prefix, and should be rather pr_warning().
> 
> I don't understand.  pr_warning doesn't print any prefixes, by default.  
> They would have to added to the format string.  Why not change it to 
> "snd_printk(KERN_WARN"?

Yes, this should be snd_printk(KERN_WARN) *and* it needs a proper
prefix depending on CONFIG_SND_VERBOSE_PRINTK:

#ifdef CONFIG_SND_VERBOSE_PRINTK
#define PREFIX	""
#else
#define PREFIX	"miro: "
#endif
....
	snd_printk(KERN_WARNING PFX "found unsupported aci card\n");

The same check should be applied to all snd_printk() lines.

Once after all snd_printk() have the unified prefix, we can convert
straightforwardly like

#define pr_fmt	"miro: "
....
	pr_warn("found unsupported aci card\n");


In other words, toward the final conversions, we need to audit:
- Whether each message is really marked properly with KERN_* level,
- Whether messages have consistent prefix through the whole module,
- whether messages are unique enough to be identified,
- optionally, check typos


Takashi

  reply	other threads:[~2013-06-07  5:40 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-03 20:18 [PATCH] ALSA: get rid of CONFIG_SND_VERBOSE_PRINTK Alan Stern
2013-06-03 20:24 ` Joe Perches
2013-06-03 20:40   ` Alan Stern
2013-06-03 20:49     ` Joe Perches
2013-06-04  9:13 ` Takashi Iwai
2013-06-04 14:49   ` Alan Stern
2013-06-04 15:03     ` Takashi Iwai
2013-06-04 17:20       ` [PATCH 1/2] ALSA: convert "snd_printk(KERN_INFO" to "pr_info(" Alan Stern
2013-06-05  5:52         ` Takashi Iwai
2013-06-05  6:07           ` Joe Perches
2013-06-05  6:16             ` Takashi Iwai
2013-06-06 20:54           ` Alan Stern
2013-06-07  5:41             ` Takashi Iwai [this message]
2013-06-07 15:51               ` Alan Stern
2013-06-04 17:20       ` [PATCH 2/2 v.2] ALSA: get rid of CONFIG_SND_VERBOSE_PRINTK Alan Stern
2013-06-04 19:32       ` [PATCH] " Alan Stern
2013-06-04 19:45         ` Joe Perches
2013-06-04 20:54           ` Alan Stern
2013-06-04 21:19             ` Joe Perches
2013-06-06 20:42               ` Alan Stern
2013-06-06 20:59                 ` Joe Perches
2013-06-07 14:40                   ` Alan Stern
2013-06-07 16:10                     ` Joe Perches
2013-06-05  6:04             ` Takashi Iwai
2013-06-05  6:15               ` Joe Perches
2013-06-05  6:32                 ` Takashi Iwai
2013-06-05  6:52                   ` Joe Perches
2013-06-05  6:54                     ` Takashi Iwai
2013-06-05  7:07                       ` Joe Perches
2013-06-05  7:22                         ` Takashi Iwai
2013-06-05  7:34                           ` Joe Perches
2013-06-05  7:47                             ` CONFIG_SND_DEBUG (was: Re: [alsa-devel] [PATCH] ALSA: get rid of CONFIG_SND_VERBOSE_PRINTK) David Henningsson
2013-06-05  8:46                               ` CONFIG_SND_DEBUG (was: " Takashi Iwai
2013-06-05 10:53                               ` CONFIG_SND_DEBUG (was: Re: [alsa-devel] " Andy Whitcroft
2013-06-05 11:38                                 ` CONFIG_SND_DEBUG David Henningsson
2013-06-05 11:43                                   ` CONFIG_SND_DEBUG Takashi Iwai
2013-06-05 14:11                                     ` CONFIG_SND_DEBUG Alan Stern
2013-06-05 14:28                                       ` CONFIG_SND_DEBUG Takashi Iwai
2013-06-05 14:47                                         ` CONFIG_SND_DEBUG Alan Stern
2013-06-06 21:28               ` [PATCH] ALSA: get rid of CONFIG_SND_VERBOSE_PRINTK Alan Stern
2013-06-06 21:50                 ` Joe Perches
2013-06-07  5:57                   ` Takashi Iwai
2013-06-07 15:34                     ` Alan Stern
2013-06-07  5:53                 ` 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=s5hr4geqxz9.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=joe@perches.com \
    --cc=stern@rowland.harvard.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox