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 6de94151ff6f..af92883bb4a6 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -36,6 +36,7 @@ struct subsys_private;
36struct bus_type; 36struct bus_type;
37struct device_node; 37struct device_node;
38struct iommu_ops; 38struct iommu_ops;
39struct iommu_group;
39 40
40struct bus_attribute { 41struct bus_attribute {
41 struct attribute attr; 42 struct attribute attr;
@@ -535,6 +536,10 @@ extern void *__devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
535#else 536#else
536extern 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);
537#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);
538extern void devres_free(void *res); 543extern void devres_free(void *res);
539extern void devres_add(struct device *dev, void *res); 544extern void devres_add(struct device *dev, void *res);
540extern void *devres_find(struct device *dev, dr_release_t release, 545extern void *devres_find(struct device *dev, dr_release_t release,
@@ -687,8 +692,14 @@ struct device {
687 const struct attribute_group **groups; /* optional groups */ 692 const struct attribute_group **groups; /* optional groups */
688 693
689 void (*release)(struct device *dev); 694 void (*release)(struct device *dev);
695 struct iommu_group *iommu_group;
690}; 696};
691 697
698static inline struct device *kobj_to_dev(struct kobject *kobj)
699{
700 return container_of(kobj, struct device, kobj);
701}
702
692/* Get the wakeup routines, which depend on struct device */ 703/* Get the wakeup routines, which depend on struct device */
693#include <linux/pm_wakeup.h> 704#include <linux/pm_wakeup.h>
694 705
@@ -884,12 +895,15 @@ extern const char *dev_driver_string(const struct device *dev);
884 895
885#ifdef CONFIG_PRINTK 896#ifdef CONFIG_PRINTK
886 897
887extern int __dev_printk(const char *level, const struct device *dev, 898extern __printf(3, 0)
888 struct va_format *vaf); 899int dev_vprintk_emit(int level, const struct device *dev,
900 const char *fmt, va_list args);
901extern __printf(3, 4)
902int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...);
903
889extern __printf(3, 4) 904extern __printf(3, 4)
890int dev_printk(const char *level, const struct device *dev, 905int dev_printk(const char *level, const struct device *dev,
891 const char *fmt, ...) 906 const char *fmt, ...);
892 ;
893extern __printf(2, 3) 907extern __printf(2, 3)
894int dev_emerg(const struct device *dev, const char *fmt, ...); 908int dev_emerg(const struct device *dev, const char *fmt, ...);
895extern __printf(2, 3) 909extern __printf(2, 3)
@@ -907,6 +921,14 @@ int _dev_info(const struct device *dev, const char *fmt, ...);
907 921
908#else 922#else
909 923
924static inline __printf(3, 0)
925int dev_vprintk_emit(int level, const struct device *dev,
926 const char *fmt, va_list args)
927{ return 0; }
928static inline __printf(3, 4)
929int dev_printk_emit(int level, const struct device *dev, const char *fmt, ...)
930{ return 0; }
931
910static inline int __dev_printk(const char *level, const struct device *dev, 932static inline int __dev_printk(const char *level, const struct device *dev,
911 struct va_format *vaf) 933 struct va_format *vaf)
912{ return 0; } 934{ return 0; }
@@ -939,6 +961,32 @@ int _dev_info(const struct device *dev, const char *fmt, ...)
939 961
940#endif 962#endif
941 963
964/*
965 * Stupid hackaround for existing uses of non-printk uses dev_info
966 *
967 * Note that the definition of dev_info below is actually _dev_info
968 * and a macro is used to avoid redefining dev_info
969 */
970
971#define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg)
972
973#if defined(CONFIG_DYNAMIC_DEBUG)
974#define dev_dbg(dev, format, ...) \
975do { \
976 dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \
977} while (0)
978#elif defined(DEBUG)
979#define dev_dbg(dev, format, arg...) \
980 dev_printk(KERN_DEBUG, dev, format, ##arg)
981#else
982#define dev_dbg(dev, format, arg...) \
983({ \
984 if (0) \
985 dev_printk(KERN_DEBUG, dev, format, ##arg); \
986 0; \
987})
988#endif
989
942#define dev_level_ratelimited(dev_level, dev, fmt, ...) \ 990#define dev_level_ratelimited(dev_level, dev, fmt, ...) \
943do { \ 991do { \
944 static DEFINE_RATELIMIT_STATE(_rs, \ 992 static DEFINE_RATELIMIT_STATE(_rs, \
@@ -962,33 +1010,21 @@ do { \
962 dev_level_ratelimited(dev_notice, dev, fmt, ##__VA_ARGS__) 1010 dev_level_ratelimited(dev_notice, dev, fmt, ##__VA_ARGS__)
963#define dev_info_ratelimited(dev, fmt, ...) \ 1011#define dev_info_ratelimited(dev, fmt, ...) \
964 dev_level_ratelimited(dev_info, dev, fmt, ##__VA_ARGS__) 1012 dev_level_ratelimited(dev_info, dev, fmt, ##__VA_ARGS__)
1013#if defined(CONFIG_DYNAMIC_DEBUG) || defined(DEBUG)
965#define dev_dbg_ratelimited(dev, fmt, ...) \ 1014#define dev_dbg_ratelimited(dev, fmt, ...) \
966 dev_level_ratelimited(dev_dbg, dev, fmt, ##__VA_ARGS__) 1015do { \
967 1016 static DEFINE_RATELIMIT_STATE(_rs, \
968/* 1017 DEFAULT_RATELIMIT_INTERVAL, \
969 * Stupid hackaround for existing uses of non-printk uses dev_info 1018 DEFAULT_RATELIMIT_BURST); \
970 * 1019 DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
971 * Note that the definition of dev_info below is actually _dev_info 1020 if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \
972 * and a macro is used to avoid redefining dev_info 1021 __ratelimit(&_rs)) \
973 */ 1022 __dynamic_pr_debug(&descriptor, pr_fmt(fmt), \
974 1023 ##__VA_ARGS__); \
975#define dev_info(dev, fmt, arg...) _dev_info(dev, fmt, ##arg)
976
977#if defined(CONFIG_DYNAMIC_DEBUG)
978#define dev_dbg(dev, format, ...) \
979do { \
980 dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \
981} while (0) 1024} while (0)
982#elif defined(DEBUG)
983#define dev_dbg(dev, format, arg...) \
984 dev_printk(KERN_DEBUG, dev, format, ##arg)
985#else 1025#else
986#define dev_dbg(dev, format, arg...) \ 1026#define dev_dbg_ratelimited(dev, fmt, ...) \
987({ \ 1027 no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
988 if (0) \
989 dev_printk(KERN_DEBUG, dev, format, ##arg); \
990 0; \
991})
992#endif 1028#endif
993 1029
994#ifdef VERBOSE_DEBUG 1030#ifdef VERBOSE_DEBUG