From patchwork Sat Nov 29 20:58:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 5407071 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D7D0F9F301 for ; Sat, 29 Nov 2014 20:58:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E6AF4201FA for ; Sat, 29 Nov 2014 20:58:39 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 787EA201B4 for ; Sat, 29 Nov 2014 20:58:38 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id E050C260526; Sat, 29 Nov 2014 21:58:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 92934260438; Sat, 29 Nov 2014 21:58:26 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8EE1826043E; Sat, 29 Nov 2014 21:58:25 +0100 (CET) Received: from smtprelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by alsa0.perex.cz (Postfix) with ESMTP id 61732260436 for ; Sat, 29 Nov 2014 21:58:17 +0100 (CET) Received: from filter.hostedemail.com (unknown [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id C081E29DDDF; Sat, 29 Nov 2014 20:58:15 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: geese08_6520fdc480b46 X-Filterd-Recvd-Size: 5074 Received: from joe-X200MA.home (pool-71-103-235-196.lsanca.fios.verizon.net [71.103.235.196]) (Authenticated sender: joe@perches.com) by omf12.hostedemail.com (Postfix) with ESMTPA; Sat, 29 Nov 2014 20:58:14 +0000 (UTC) Message-ID: <1417294692.818.3.camel@perches.com> From: Joe Perches To: Takashi Iwai Date: Sat, 29 Nov 2014 12:58:12 -0800 In-Reply-To: References: <1417201196-12392-1-git-send-email-KyleChamberlin@project20million.org> X-Mailer: Evolution 3.12.7-0ubuntu1 Mime-Version: 1.0 Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH] sound: use enum names instead of magic numbers X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP There's an enum defined for these magic numbers, might as well use it. Miscellanea: o Use ##__VA_ARGS__ Signed-off-by: Joe Perches --- include/sound/core.h | 28 +++++++++++++++------------- sound/core/misc.c | 6 +++--- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/include/sound/core.h b/include/sound/core.h index 1df3f2f..40418e7 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -325,7 +325,7 @@ void release_and_free_resource(struct resource *res); /* --- */ /* sound printk debug levels */ -enum { +enum snd_level { SND_PR_ALWAYS, SND_PR_DEBUG, SND_PR_VERBOSE, @@ -333,11 +333,11 @@ enum { #if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK) __printf(4, 5) -void __snd_printk(unsigned int level, const char *file, int line, +void __snd_printk(enum snd_level snd_level, const char *file, int line, const char *format, ...); #else -#define __snd_printk(level, file, line, format, args...) \ - printk(format, ##args) +#define __snd_printk(snd_level, file, line, format, ...) \ + printk(format, ##__VA_ARGS__) #endif /** @@ -347,8 +347,8 @@ void __snd_printk(unsigned int level, const char *file, int line, * Works like printk() but prints the file and the line of the caller * when configured with CONFIG_SND_VERBOSE_PRINTK. */ -#define snd_printk(fmt, args...) \ - __snd_printk(0, __FILE__, __LINE__, fmt, ##args) +#define snd_printk(fmt, ...) \ + __snd_printk(SND_PR_ALWAYS, __FILE__, __LINE__, fmt, ##__VA_ARGS__) #ifdef CONFIG_SND_DEBUG /** @@ -358,10 +358,10 @@ void __snd_printk(unsigned int level, const char *file, int line, * Works like snd_printk() for debugging purposes. * Ignored when CONFIG_SND_DEBUG is not set. */ -#define snd_printd(fmt, args...) \ - __snd_printk(1, __FILE__, __LINE__, fmt, ##args) -#define _snd_printd(level, fmt, args...) \ - __snd_printk(level, __FILE__, __LINE__, fmt, ##args) +#define snd_printd(fmt, ...) \ + __snd_printk(SND_PR_DEBUG, __FILE__, __LINE__, fmt, ##__VA_ARGS__) +#define _snd_printd(level, fmt, ...) \ + __snd_printk(level, __FILE__, __LINE__, fmt, ##__VA_ARGS__) /** * snd_BUG - give a BUG warning message and stack trace @@ -390,7 +390,8 @@ void __snd_printk(unsigned int level, const char *file, int line, __printf(1, 2) static inline void snd_printd(const char *format, ...) {} __printf(2, 3) -static inline void _snd_printd(int level, const char *format, ...) {} +static inline void _snd_printd(enum snd_level snd_level, + const char *format, ...) {} #define snd_BUG() do { } while (0) @@ -411,8 +412,9 @@ static inline bool snd_printd_ratelimit(void) { return false; } * Works like snd_printk() for debugging purposes. * Ignored when CONFIG_SND_DEBUG_VERBOSE is not set. */ -#define snd_printdd(format, args...) \ - __snd_printk(2, __FILE__, __LINE__, format, ##args) +#define snd_printdd(format, ...) \ + __snd_printk(SND_PR_VERBOSE, __FILE__, __LINE__, \ + format, ##__VA_ARGS__) #else __printf(1, 2) static inline void snd_printdd(const char *format, ...) {} diff --git a/sound/core/misc.c b/sound/core/misc.c index f2e8226..03b3f56 100644 --- a/sound/core/misc.c +++ b/sound/core/misc.c @@ -63,7 +63,7 @@ static const char *sanity_file_name(const char *path) #endif #if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK) -void __snd_printk(unsigned int level, const char *path, int line, +void __snd_printk(enum snd_level snd_level, const char *path, int line, const char *format, ...) { va_list args; @@ -74,7 +74,7 @@ void __snd_printk(unsigned int level, const char *path, int line, #endif #ifdef CONFIG_SND_DEBUG - if (debug < level) + if (debug < snd_level) return; #endif @@ -88,7 +88,7 @@ void __snd_printk(unsigned int level, const char *path, int line, const char *end_of_header = printk_skip_level(format); memcpy(verbose_fmt, format, end_of_header - format); vaf.fmt = end_of_header; - } else if (level) + } else if (snd_level) memcpy(verbose_fmt, KERN_DEBUG, sizeof(KERN_DEBUG) - 1); printk(verbose_fmt, sanity_file_name(path), line, &vaf);