aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/device.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/device.h')
-rw-r--r--include/linux/device.h92
1 files changed, 64 insertions, 28 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index 52a5f15a2223..86ef6ab553b1 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -536,6 +536,10 @@ extern void *__devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
536#else 536#else
537extern void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp); 537extern void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp);
538#endif 538#endif
539extern void devres_for_each_res(struct device *dev, dr_release_t release,
540 dr_match_t match, void *match_data,
541 void (*fn)(struct device *, void *, void *),
542 void *data);
539extern void devres_free(void *res); 543extern void devres_free(void *res);
540extern void devres_add(struct device *dev, void *res); 544extern void devres_add(struct device *dev, void *res);
541extern void *devres_find(struct device *dev, dr_release_t release, 545extern void *devres_find(struct device *dev, dr_release_t release,
@@ -772,6 +776,13 @@ static inline void pm_suspend_ignore_children(struct device *dev, bool enable)
772 dev->power.ignore_children = enable; 776 dev->power.ignore_children = enable;
773} 777}
774 778
779static inline void dev_pm_syscore_device(struct device *dev, bool val)
780{
781#ifdef CONFIG_PM_SLEEP
782 dev->power.syscore = val;
783#endif
784}
785
775static inline void device_lock(struct device *dev) 786static inline void device_lock(struct device *dev)
776{ 787{
777 mutex_lock(&dev->mutex); 788 mutex_lock(&dev->mutex);
@@ -891,12 +902,15 @@ extern const char *dev_driver_string(const struct device *dev);
891 902
892#ifdef CONFIG_PRINTK 903#ifdef CONFIG_PRINTK
893 904
894extern int __dev_printk(const char *level, const struct device *dev, 905extern __printf(3, 0)
895 struct va_format *vaf); 906int dev_vprintk_emit(int level, const struct device *dev,
907 const char *fmt, va_list args);
908extern __printf(3, 4)
909int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...);
910
896extern __printf(3, 4) 911extern __printf(3, 4)
897int dev_printk(const char *level, const struct device *dev, 912int dev_printk(const char *level, const struct device *dev,
898 const char *fmt, ...) 913 const char *fmt, ...);
899 ;
900extern __printf(2, 3) 914extern __printf(2, 3)
901int dev_emerg(const struct device *dev, const char *fmt, ...); 915int dev_emerg(const struct device *dev, const char *fmt, ...);
902extern __printf(2, 3) 916extern __printf(2, 3)
@@ -914,6 +928,14 @@ int _dev_info(const struct device *dev, const char *fmt, ...);
914 928
915#else 929#else
916 930
931static inline __printf(3, 0)
932int dev_vprintk_emit(int level, const struct device *dev,
933 const char *fmt, va_list args)
934{ return 0; }
935static inline __printf(3, 4)
936int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...)
937{ return 0; }
938
917static inline int __dev_printk(const char *level, const struct device *dev, 939static inline int __dev_printk(const char *level, const struct device *dev,
918 struct va_format *vaf) 940 struct va_format *vaf)
919{ return 0; } 941{ return 0; }
@@ -946,6 +968,32 @@ int _dev_info(const struct device *dev, const char *fmt, ...)
946 968
947#endif 969#endif
948 970
971/*
972 * Stupid hackaround for existing uses of non-printk uses dev_info
973 *
974 * Note that the definition of dev_info below is actually _dev_info
975 * and a macro is used to avoid redefining dev_info
976 */
977
978#define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg)
979
980#if defined(CONFIG_DYNAMIC_DEBUG)
981#define dev_dbg(dev, format, ...) \
982do { \
983 dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \
984} while (0)
985#elif defined(DEBUG)
986#define dev_dbg(dev, format, arg...) \
987 dev_printk(KERN_DEBUG, dev, format, ##arg)
988#else
989#define dev_dbg(dev, format, arg...) \
990({ \
991 if (0) \
992 dev_printk(KERN_DEBUG, dev, format, ##arg); \
993 0; \
994})
995#endif
996
949#define dev_level_ratelimited(dev_level, dev, fmt, ...) \ 997#define dev_level_ratelimited(dev_level, dev, fmt, ...) \
950do { \ 998do { \
951 static DEFINE_RATELIMIT_STATE(_rs, \ 999 static DEFINE_RATELIMIT_STATE(_rs, \
@@ -969,33 +1017,21 @@ do { \
969 dev_level_ratelimited(dev_notice, dev, fmt, ##__VA_ARGS__) 1017 dev_level_ratelimited(dev_notice, dev, fmt, ##__VA_ARGS__)
970#define dev_info_ratelimited(dev, fmt, ...) \ 1018#define dev_info_ratelimited(dev, fmt, ...) \
971 dev_level_ratelimited(dev_info, dev, fmt, ##__VA_ARGS__) 1019 dev_level_ratelimited(dev_info, dev, fmt, ##__VA_ARGS__)
1020#if defined(CONFIG_DYNAMIC_DEBUG) || defined(DEBUG)
972#define dev_dbg_ratelimited(dev, fmt, ...) \ 1021#define dev_dbg_ratelimited(dev, fmt, ...) \
973 dev_level_ratelimited(dev_dbg, dev, fmt, ##__VA_ARGS__) 1022do { \
974 1023 static DEFINE_RATELIMIT_STATE(_rs, \
975/* 1024 DEFAULT_RATELIMIT_INTERVAL, \
976 * Stupid hackaround for existing uses of non-printk uses dev_info 1025 DEFAULT_RATELIMIT_BURST); \
977 * 1026 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
978 * Note that the definition of dev_info below is actually _dev_info 1027 if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \
979 * and a macro is used to avoid redefining dev_info 1028 __ratelimit(&_rs)) \
980 */ 1029 __dynamic_pr_debug(&descriptor, pr_fmt(fmt), \
981 1030 ##__VA_ARGS__); \
982#define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg)
983
984#if defined(CONFIG_DYNAMIC_DEBUG)
985#define dev_dbg(dev, format, ...) \
986do { \
987 dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \
988} while (0) 1031} while (0)
989#elif defined(DEBUG)
990#define dev_dbg(dev, format, arg...) \
991 dev_printk(KERN_DEBUG, dev, format, ##arg)
992#else 1032#else
993#define dev_dbg(dev, format, arg...) \ 1033#define dev_dbg_ratelimited(dev, fmt, ...) \
994({ \ 1034 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
995 if (0) \
996 dev_printk(KERN_DEBUG, dev, format, ##arg); \
997 0; \
998})
999#endif 1035#endif
1000 1036
1001#ifdef VERBOSE_DEBUG 1037#ifdef VERBOSE_DEBUG