mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/6] device: Add #define dev_fmt similar to #define pr_fmt
Date: Tue, 19 Jun 2018 06:31:28 -0700	[thread overview]
Message-ID: <53ed025e7f188c931b99f83066457b2266e69cd6.camel@perches.com> (raw)
In-Reply-To: <3f213f4f9ee604c1797af67360d8da1836b34271.1525878372.git.joe@perches.com>

Greg?  Ping?

The patches to impi have hit -next and the impi code
works differently without this patch.


On Wed, 2018-05-09 at 08:15 -0700, Joe Perches wrote:
> Add a prefixing macro to dev_<level> uses similar to the pr_fmt
> prefixing macro used in pr_<level> calls.
> 
> This can help avoid some string duplication in dev_<level> uses.
> 
> The default, like pr_fmt, is an empty #define dev_fmt(fmt) fmt
> 
> Rename the existing dev_<level> functions to _dev_<level> and
> introduce #define dev_<level> _dev_<level> macros that use the
> new #define dev_fmt
> 
> Miscellanea:
> 
> o Consistently use #defines with fmt, ... and ##__VA_ARGS__
> o Remove unnecessary externs
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  drivers/base/core.c    |  12 +++---
>  include/linux/device.h | 103 ++++++++++++++++++++++++++++---------------------
>  2 files changed, 64 insertions(+), 51 deletions(-)
> 
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index ad7b50897bcc..9c87a41cef82 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -2985,12 +2985,12 @@ void func(const struct device *dev, const char *fmt, ...)	\
>  }								\
>  EXPORT_SYMBOL(func);
>  
> -define_dev_printk_level(dev_emerg, KERN_EMERG);
> -define_dev_printk_level(dev_alert, KERN_ALERT);
> -define_dev_printk_level(dev_crit, KERN_CRIT);
> -define_dev_printk_level(dev_err, KERN_ERR);
> -define_dev_printk_level(dev_warn, KERN_WARNING);
> -define_dev_printk_level(dev_notice, KERN_NOTICE);
> +define_dev_printk_level(_dev_emerg, KERN_EMERG);
> +define_dev_printk_level(_dev_alert, KERN_ALERT);
> +define_dev_printk_level(_dev_crit, KERN_CRIT);
> +define_dev_printk_level(_dev_err, KERN_ERR);
> +define_dev_printk_level(_dev_warn, KERN_WARNING);
> +define_dev_printk_level(_dev_notice, KERN_NOTICE);
>  define_dev_printk_level(_dev_info, KERN_INFO);
>  
>  #endif
> diff --git a/include/linux/device.h b/include/linux/device.h
> index 563077d1cdc1..49c6b5d6a9f8 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -1306,30 +1306,34 @@ struct device_link *device_link_add(struct device *consumer,
>  				    struct device *supplier, u32 flags);
>  void device_link_del(struct device_link *link);
>  
> +#ifndef dev_fmt
> +#define dev_fmt(fmt) fmt
> +#endif
> +
>  #ifdef CONFIG_PRINTK
>  
> -extern __printf(3, 0)
> +__printf(3, 0)
>  int dev_vprintk_emit(int level, const struct device *dev,
>  		     const char *fmt, va_list args);
> -extern __printf(3, 4)
> +__printf(3, 4)
>  int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...);
>  
> -extern __printf(3, 4)
> +__printf(3, 4)
>  void dev_printk(const char *level, const struct device *dev,
>  		const char *fmt, ...);
> -extern __printf(2, 3)
> -void dev_emerg(const struct device *dev, const char *fmt, ...);
> -extern __printf(2, 3)
> -void dev_alert(const struct device *dev, const char *fmt, ...);
> -extern __printf(2, 3)
> -void dev_crit(const struct device *dev, const char *fmt, ...);
> -extern __printf(2, 3)
> -void dev_err(const struct device *dev, const char *fmt, ...);
> -extern __printf(2, 3)
> -void dev_warn(const struct device *dev, const char *fmt, ...);
> -extern __printf(2, 3)
> -void dev_notice(const struct device *dev, const char *fmt, ...);
> -extern __printf(2, 3)
> +__printf(2, 3)
> +void _dev_emerg(const struct device *dev, const char *fmt, ...);
> +__printf(2, 3)
> +void _dev_alert(const struct device *dev, const char *fmt, ...);
> +__printf(2, 3)
> +void _dev_crit(const struct device *dev, const char *fmt, ...);
> +__printf(2, 3)
> +void _dev_err(const struct device *dev, const char *fmt, ...);
> +__printf(2, 3)
> +void _dev_warn(const struct device *dev, const char *fmt, ...);
> +__printf(2, 3)
> +void _dev_notice(const struct device *dev, const char *fmt, ...);
> +__printf(2, 3)
>  void _dev_info(const struct device *dev, const char *fmt, ...);
>  
>  #else
> @@ -1347,26 +1351,26 @@ static inline void __dev_printk(const char *level, const struct device *dev,
>  {}
>  static inline __printf(3, 4)
>  void dev_printk(const char *level, const struct device *dev,
> -		const char *fmt, ...)
> +		 const char *fmt, ...)
>  {}
>  
>  static inline __printf(2, 3)
> -void dev_emerg(const struct device *dev, const char *fmt, ...)
> +void _dev_emerg(const struct device *dev, const char *fmt, ...)
>  {}
>  static inline __printf(2, 3)
> -void dev_crit(const struct device *dev, const char *fmt, ...)
> +void _dev_crit(const struct device *dev, const char *fmt, ...)
>  {}
>  static inline __printf(2, 3)
> -void dev_alert(const struct device *dev, const char *fmt, ...)
> +void _dev_alert(const struct device *dev, const char *fmt, ...)
>  {}
>  static inline __printf(2, 3)
> -void dev_err(const struct device *dev, const char *fmt, ...)
> +void _dev_err(const struct device *dev, const char *fmt, ...)
>  {}
>  static inline __printf(2, 3)
> -void dev_warn(const struct device *dev, const char *fmt, ...)
> +void _dev_warn(const struct device *dev, const char *fmt, ...)
>  {}
>  static inline __printf(2, 3)
> -void dev_notice(const struct device *dev, const char *fmt, ...)
> +void _dev_notice(const struct device *dev, const char *fmt, ...)
>  {}
>  static inline __printf(2, 3)
>  void _dev_info(const struct device *dev, const char *fmt, ...)
> @@ -1375,27 +1379,36 @@ void _dev_info(const struct device *dev, const char *fmt, ...)
>  #endif
>  
>  /*
> - * Stupid hackaround for existing uses of non-printk uses dev_info
> - *
> - * Note that the definition of dev_info below is actually _dev_info
> - * and a macro is used to avoid redefining dev_info
> + * #defines for all the dev_<level> macros to prefix with whatever
> + * possible use of #define dev_fmt(fmt) ...
>   */
>  
> -#define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg)
> +#define dev_emerg(dev, fmt, ...)					\
> +	_dev_emerg(dev, dev_fmt(fmt), ##__VA_ARGS__)
> +#define dev_crit(dev, fmt, ...)						\
> +	_dev_crit(dev, dev_fmt(fmt), ##__VA_ARGS__)
> +#define dev_alert(dev, fmt, ...)					\
> +	_dev_alert(dev, dev_fmt(fmt), ##__VA_ARGS__)
> +#define dev_err(dev, fmt, ...)						\
> +	_dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__)
> +#define dev_warn(dev, fmt, ...)						\
> +	_dev_warn(dev, dev_fmt(fmt), ##__VA_ARGS__)
> +#define dev_notice(dev, fmt, ...)					\
> +	_dev_notice(dev, dev_fmt(fmt), ##__VA_ARGS__)
> +#define dev_info(dev, fmt, ...)						\
> +	_dev_info(dev, dev_fmt(fmt), ##__VA_ARGS__)
>  
>  #if defined(CONFIG_DYNAMIC_DEBUG)
> -#define dev_dbg(dev, format, ...)		     \
> -do {						     \
> -	dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \
> -} while (0)
> +#define dev_dbg(dev, fmt, ...)						\
> +	dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
>  #elif defined(DEBUG)
> -#define dev_dbg(dev, format, arg...)		\
> -	dev_printk(KERN_DEBUG, dev, format, ##arg)
> +#define dev_dbg(dev, fmt, ...)						\
> +	dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__)
>  #else
> -#define dev_dbg(dev, format, arg...)				\
> -({								\
> -	if (0)							\
> -		dev_printk(KERN_DEBUG, dev, format, ##arg);	\
> +#define dev_dbg(dev, fmt, ...)						\
> +({									\
> +	if (0)								\
> +		dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
>  })
>  #endif
>  
> @@ -1467,7 +1480,7 @@ do {									\
>  	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
>  	if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) &&	\
>  	    __ratelimit(&_rs))						\
> -		__dynamic_dev_dbg(&descriptor, dev, fmt,		\
> +		__dynamic_dev_dbg(&descriptor, dev, dev_fmt(fmt),	\
>  				  ##__VA_ARGS__);			\
>  } while (0)
>  #elif defined(DEBUG)
> @@ -1477,23 +1490,23 @@ do {									\
>  				      DEFAULT_RATELIMIT_INTERVAL,	\
>  				      DEFAULT_RATELIMIT_BURST);		\
>  	if (__ratelimit(&_rs))						\
> -		dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__);	\
> +		dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
>  } while (0)
>  #else
>  #define dev_dbg_ratelimited(dev, fmt, ...)				\
>  do {									\
>  	if (0)								\
> -		dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__);	\
> +		dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
>  } while (0)
>  #endif
>  
>  #ifdef VERBOSE_DEBUG
>  #define dev_vdbg	dev_dbg
>  #else
> -#define dev_vdbg(dev, format, arg...)				\
> -({								\
> -	if (0)							\
> -		dev_printk(KERN_DEBUG, dev, format, ##arg);	\
> +#define dev_vdbg(dev, fmt, ...)						\
> +({									\
> +	if (0)								\
> +		dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
>  })
>  #endif
>  

  reply	other threads:[~2018-06-19 13:31 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-09 15:15 [PATCH 0/6] treewide: Add and use dev_fmt similar to pr_fmt Joe Perches
2018-05-09 15:15 ` [PATCH 1/6] x86/early-quirks: Rename duplicate define of dev_err Joe Perches
2018-05-13 13:03   ` Thomas Gleixner
2018-05-13 17:30     ` Joe Perches
2018-05-13 18:09   ` [tip:x86/cleanups] " tip-bot for Joe Perches
2018-05-09 15:15 ` [PATCH 2/6] device: Add #define dev_fmt similar to #define pr_fmt Joe Perches
2018-06-19 13:31   ` Joe Perches [this message]
2018-06-24 15:41     ` Joe Perches
2018-06-25  0:51       ` Greg Kroah-Hartman
2018-07-05 22:57         ` Joe Perches
2018-07-06 13:38           ` Greg Kroah-Hartman
2018-07-06 14:42             ` Joe Perches
2018-07-06 15:30   ` Greg Kroah-Hartman
2018-07-06 15:41     ` Joe Perches
2018-07-06 15:50       ` Greg Kroah-Hartman
2018-07-06 20:50         ` Corey Minyard
2018-07-07  8:35           ` Greg Kroah-Hartman
2018-05-09 15:15 ` [PATCH 3/6] ipmi: msghandler: Add and use pr_fmt and dev_fmt, remove PFX Joe Perches
2018-05-09 15:15 ` [PATCH 4/6] ipmi: Use more common logging styles Joe Perches
2018-05-09 15:15 ` [PATCH 5/6] ipmi: Convert printk(KERN_<level> to pr_<level>( Joe Perches
2018-05-09 15:15 ` [PATCH 6/6] infiniband: qplib_fp: Use dev_fmt Joe Perches
2018-05-15 14:40   ` Doug Ledford
2018-05-15 15:01     ` Selvin Xavier
2018-05-09 16:47 ` [PATCH 0/6] treewide: Add and use dev_fmt similar to pr_fmt Corey Minyard
2018-05-09 17:04   ` Joe Perches
2018-05-09 17:22     ` Corey Minyard

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=53ed025e7f188c931b99f83066457b2266e69cd6.camel@perches.com \
    --to=joe@perches.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®