Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 663336ee authored by Joe Perches's avatar Joe Perches Committed by Greg Kroah-Hartman
Browse files

device: Add #define dev_fmt similar to #define pr_fmt



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: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0a50f61c
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -3002,12 +3002,12 @@ void func(const struct device *dev, const char *fmt, ...) \
}								\
}								\
EXPORT_SYMBOL(func);
EXPORT_SYMBOL(func);


define_dev_printk_level(dev_emerg, KERN_EMERG);
define_dev_printk_level(_dev_emerg, KERN_EMERG);
define_dev_printk_level(dev_alert, KERN_ALERT);
define_dev_printk_level(_dev_alert, KERN_ALERT);
define_dev_printk_level(dev_crit, KERN_CRIT);
define_dev_printk_level(_dev_crit, KERN_CRIT);
define_dev_printk_level(dev_err, KERN_ERR);
define_dev_printk_level(_dev_err, KERN_ERR);
define_dev_printk_level(dev_warn, KERN_WARNING);
define_dev_printk_level(_dev_warn, KERN_WARNING);
define_dev_printk_level(dev_notice, KERN_NOTICE);
define_dev_printk_level(_dev_notice, KERN_NOTICE);
define_dev_printk_level(_dev_info, KERN_INFO);
define_dev_printk_level(_dev_info, KERN_INFO);


#endif
#endif
+58 −45
Original line number Original line Diff line number Diff line
@@ -1317,30 +1317,34 @@ struct device_link *device_link_add(struct device *consumer,
				    struct device *supplier, u32 flags);
				    struct device *supplier, u32 flags);
void device_link_del(struct device_link *link);
void device_link_del(struct device_link *link);


#ifndef dev_fmt
#define dev_fmt(fmt) fmt
#endif

#ifdef CONFIG_PRINTK
#ifdef CONFIG_PRINTK


extern __printf(3, 0)
__printf(3, 0)
int dev_vprintk_emit(int level, const struct device *dev,
int dev_vprintk_emit(int level, const struct device *dev,
		     const char *fmt, va_list args);
		     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, ...);
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,
void dev_printk(const char *level, const struct device *dev,
		const char *fmt, ...);
		const char *fmt, ...);
extern __printf(2, 3)
__printf(2, 3)
void dev_emerg(const struct device *dev, const char *fmt, ...);
void _dev_emerg(const struct device *dev, const char *fmt, ...);
extern __printf(2, 3)
__printf(2, 3)
void dev_alert(const struct device *dev, const char *fmt, ...);
void _dev_alert(const struct device *dev, const char *fmt, ...);
extern __printf(2, 3)
__printf(2, 3)
void dev_crit(const struct device *dev, const char *fmt, ...);
void _dev_crit(const struct device *dev, const char *fmt, ...);
extern __printf(2, 3)
__printf(2, 3)
void dev_err(const struct device *dev, const char *fmt, ...);
void _dev_err(const struct device *dev, const char *fmt, ...);
extern __printf(2, 3)
__printf(2, 3)
void dev_warn(const struct device *dev, const char *fmt, ...);
void _dev_warn(const struct device *dev, const char *fmt, ...);
extern __printf(2, 3)
__printf(2, 3)
void dev_notice(const struct device *dev, const char *fmt, ...);
void _dev_notice(const struct device *dev, const char *fmt, ...);
extern __printf(2, 3)
__printf(2, 3)
void _dev_info(const struct device *dev, const char *fmt, ...);
void _dev_info(const struct device *dev, const char *fmt, ...);


#else
#else
@@ -1362,22 +1366,22 @@ void dev_printk(const char *level, const struct device *dev,
{}
{}


static inline __printf(2, 3)
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)
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)
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)
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)
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)
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)
static inline __printf(2, 3)
void _dev_info(const struct device *dev, const char *fmt, ...)
void _dev_info(const struct device *dev, const char *fmt, ...)
@@ -1386,27 +1390,36 @@ void _dev_info(const struct device *dev, const char *fmt, ...)
#endif
#endif


/*
/*
 * Stupid hackaround for existing uses of non-printk uses dev_info
 * #defines for all the dev_<level> macros to prefix with whatever
 *
 * possible use of #define dev_fmt(fmt) ...
 * Note that the definition of dev_info below is actually _dev_info
 * and a macro is used to avoid redefining dev_info
 */
 */


#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)
#if defined(CONFIG_DYNAMIC_DEBUG)
#define dev_dbg(dev, format, ...)		     \
#define dev_dbg(dev, fmt, ...)						\
do {						     \
	dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
	dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \
} while (0)
#elif defined(DEBUG)
#elif defined(DEBUG)
#define dev_dbg(dev, format, arg...)		\
#define dev_dbg(dev, fmt, ...)						\
	dev_printk(KERN_DEBUG, dev, format, ##arg)
	dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__)
#else
#else
#define dev_dbg(dev, format, arg...)				\
#define dev_dbg(dev, fmt, ...)						\
({									\
({									\
	if (0)								\
	if (0)								\
		dev_printk(KERN_DEBUG, dev, format, ##arg);	\
		dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
})
})
#endif
#endif


@@ -1478,7 +1491,7 @@ do { \
	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
	DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt);			\
	if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) &&	\
	if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) &&	\
	    __ratelimit(&_rs))						\
	    __ratelimit(&_rs))						\
		__dynamic_dev_dbg(&descriptor, dev, fmt,		\
		__dynamic_dev_dbg(&descriptor, dev, dev_fmt(fmt),	\
				  ##__VA_ARGS__);			\
				  ##__VA_ARGS__);			\
} while (0)
} while (0)
#elif defined(DEBUG)
#elif defined(DEBUG)
@@ -1488,23 +1501,23 @@ do { \
				      DEFAULT_RATELIMIT_INTERVAL,	\
				      DEFAULT_RATELIMIT_INTERVAL,	\
				      DEFAULT_RATELIMIT_BURST);		\
				      DEFAULT_RATELIMIT_BURST);		\
	if (__ratelimit(&_rs))						\
	if (__ratelimit(&_rs))						\
		dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__);	\
		dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
} while (0)
} while (0)
#else
#else
#define dev_dbg_ratelimited(dev, fmt, ...)				\
#define dev_dbg_ratelimited(dev, fmt, ...)				\
do {									\
do {									\
	if (0)								\
	if (0)								\
		dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__);	\
		dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
} while (0)
} while (0)
#endif
#endif


#ifdef VERBOSE_DEBUG
#ifdef VERBOSE_DEBUG
#define dev_vdbg	dev_dbg
#define dev_vdbg	dev_dbg
#else
#else
#define dev_vdbg(dev, format, arg...)				\
#define dev_vdbg(dev, fmt, ...)						\
({									\
({									\
	if (0)								\
	if (0)								\
		dev_printk(KERN_DEBUG, dev, format, ##arg);	\
		dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
})
})
#endif
#endif