aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asm-generic/vmlinux.lds.h10
-rw-r--r--include/linux/device.h18
-rw-r--r--include/linux/dynamic_printk.h93
-rw-r--r--include/linux/kernel.h7
-rw-r--r--include/linux/module.h1
-rw-r--r--include/linux/platform_device.h2
-rw-r--r--include/linux/sysfs.h36
7 files changed, 158 insertions, 9 deletions
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 7440a0dceddb..74c5faf26c05 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -268,7 +268,15 @@
268 CPU_DISCARD(init.data) \ 268 CPU_DISCARD(init.data) \
269 CPU_DISCARD(init.rodata) \ 269 CPU_DISCARD(init.rodata) \
270 MEM_DISCARD(init.data) \ 270 MEM_DISCARD(init.data) \
271 MEM_DISCARD(init.rodata) 271 MEM_DISCARD(init.rodata) \
272 /* implement dynamic printk debug */ \
273 VMLINUX_SYMBOL(__start___verbose_strings) = .; \
274 *(__verbose_strings) \
275 VMLINUX_SYMBOL(__stop___verbose_strings) = .; \
276 . = ALIGN(8); \
277 VMLINUX_SYMBOL(__start___verbose) = .; \
278 *(__verbose) \
279 VMLINUX_SYMBOL(__stop___verbose) = .;
272 280
273#define INIT_TEXT \ 281#define INIT_TEXT \
274 *(.init.text) \ 282 *(.init.text) \
diff --git a/include/linux/device.h b/include/linux/device.h
index 246937c9cbc7..987f5912720a 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -90,6 +90,9 @@ int __must_check bus_for_each_drv(struct bus_type *bus,
90 struct device_driver *start, void *data, 90 struct device_driver *start, void *data,
91 int (*fn)(struct device_driver *, void *)); 91 int (*fn)(struct device_driver *, void *));
92 92
93void bus_sort_breadthfirst(struct bus_type *bus,
94 int (*compare)(const struct device *a,
95 const struct device *b));
93/* 96/*
94 * Bus notifiers: Get notified of addition/removal of devices 97 * Bus notifiers: Get notified of addition/removal of devices
95 * and binding/unbinding of drivers to devices. 98 * and binding/unbinding of drivers to devices.
@@ -502,7 +505,6 @@ extern struct device *device_create(struct class *cls, struct device *parent,
502 dev_t devt, void *drvdata, 505 dev_t devt, void *drvdata,
503 const char *fmt, ...) 506 const char *fmt, ...)
504 __attribute__((format(printf, 5, 6))); 507 __attribute__((format(printf, 5, 6)));
505#define device_create_drvdata device_create
506extern void device_destroy(struct class *cls, dev_t devt); 508extern void device_destroy(struct class *cls, dev_t devt);
507 509
508/* 510/*
@@ -551,7 +553,11 @@ extern const char *dev_driver_string(const struct device *dev);
551#define dev_info(dev, format, arg...) \ 553#define dev_info(dev, format, arg...) \
552 dev_printk(KERN_INFO , dev , format , ## arg) 554 dev_printk(KERN_INFO , dev , format , ## arg)
553 555
554#ifdef DEBUG 556#if defined(CONFIG_DYNAMIC_PRINTK_DEBUG)
557#define dev_dbg(dev, format, ...) do { \
558 dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \
559 } while (0)
560#elif defined(DEBUG)
555#define dev_dbg(dev, format, arg...) \ 561#define dev_dbg(dev, format, arg...) \
556 dev_printk(KERN_DEBUG , dev , format , ## arg) 562 dev_printk(KERN_DEBUG , dev , format , ## arg)
557#else 563#else
@@ -567,6 +573,14 @@ extern const char *dev_driver_string(const struct device *dev);
567 ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) 573 ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; })
568#endif 574#endif
569 575
576/*
577 * dev_WARN() acts like dev_printk(), but with the key difference
578 * of using a WARN/WARN_ON to get the message out, including the
579 * file/line information and a backtrace.
580 */
581#define dev_WARN(dev, format, arg...) \
582 WARN(1, "Device: %s\n" format, dev_driver_string(dev), ## arg);
583
570/* Create alias, so I can be autoloaded. */ 584/* Create alias, so I can be autoloaded. */
571#define MODULE_ALIAS_CHARDEV(major,minor) \ 585#define MODULE_ALIAS_CHARDEV(major,minor) \
572 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) 586 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
diff --git a/include/linux/dynamic_printk.h b/include/linux/dynamic_printk.h
new file mode 100644
index 000000000000..2d528d009074
--- /dev/null
+++ b/include/linux/dynamic_printk.h
@@ -0,0 +1,93 @@
1#ifndef _DYNAMIC_PRINTK_H
2#define _DYNAMIC_PRINTK_H
3
4#define DYNAMIC_DEBUG_HASH_BITS 6
5#define DEBUG_HASH_TABLE_SIZE (1 << DYNAMIC_DEBUG_HASH_BITS)
6
7#define TYPE_BOOLEAN 1
8
9#define DYNAMIC_ENABLED_ALL 0
10#define DYNAMIC_ENABLED_NONE 1
11#define DYNAMIC_ENABLED_SOME 2
12
13extern int dynamic_enabled;
14
15/* dynamic_printk_enabled, and dynamic_printk_enabled2 are bitmasks in which
16 * bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They
17 * use independent hash functions, to reduce the chance of false positives.
18 */
19extern long long dynamic_printk_enabled;
20extern long long dynamic_printk_enabled2;
21
22struct mod_debug {
23 char *modname;
24 char *logical_modname;
25 char *flag_names;
26 int type;
27 int hash;
28 int hash2;
29} __attribute__((aligned(8)));
30
31int register_dynamic_debug_module(char *mod_name, int type, char *share_name,
32 char *flags, int hash, int hash2);
33
34#if defined(CONFIG_DYNAMIC_PRINTK_DEBUG)
35extern int unregister_dynamic_debug_module(char *mod_name);
36extern int __dynamic_dbg_enabled_helper(char *modname, int type,
37 int value, int hash);
38
39#define __dynamic_dbg_enabled(module, type, value, level, hash) ({ \
40 int __ret = 0; \
41 if (unlikely((dynamic_printk_enabled & (1LL << DEBUG_HASH)) && \
42 (dynamic_printk_enabled2 & (1LL << DEBUG_HASH2)))) \
43 __ret = __dynamic_dbg_enabled_helper(module, type, \
44 value, hash);\
45 __ret; })
46
47#define dynamic_pr_debug(fmt, ...) do { \
48 static char mod_name[] \
49 __attribute__((section("__verbose_strings"))) \
50 = KBUILD_MODNAME; \
51 static struct mod_debug descriptor \
52 __used \
53 __attribute__((section("__verbose"), aligned(8))) = \
54 { mod_name, mod_name, NULL, TYPE_BOOLEAN, DEBUG_HASH, DEBUG_HASH2 };\
55 if (__dynamic_dbg_enabled(KBUILD_MODNAME, TYPE_BOOLEAN, \
56 0, 0, DEBUG_HASH)) \
57 printk(KERN_DEBUG KBUILD_MODNAME ":" fmt, \
58 ##__VA_ARGS__); \
59 } while (0)
60
61#define dynamic_dev_dbg(dev, format, ...) do { \
62 static char mod_name[] \
63 __attribute__((section("__verbose_strings"))) \
64 = KBUILD_MODNAME; \
65 static struct mod_debug descriptor \
66 __used \
67 __attribute__((section("__verbose"), aligned(8))) = \
68 { mod_name, mod_name, NULL, TYPE_BOOLEAN, DEBUG_HASH, DEBUG_HASH2 };\
69 if (__dynamic_dbg_enabled(KBUILD_MODNAME, TYPE_BOOLEAN, \
70 0, 0, DEBUG_HASH)) \
71 dev_printk(KERN_DEBUG, dev, \
72 KBUILD_MODNAME ": " format, \
73 ##__VA_ARGS__); \
74 } while (0)
75
76#else
77
78static inline int unregister_dynamic_debug_module(const char *mod_name)
79{
80 return 0;
81}
82static inline int __dynamic_dbg_enabled_helper(char *modname, int type,
83 int value, int hash)
84{
85 return 0;
86}
87
88#define __dynamic_dbg_enabled(module, type, value, level, hash) ({ 0; })
89#define dynamic_pr_debug(fmt, ...) do { } while (0)
90#define dynamic_dev_dbg(dev, format, ...) do { } while (0)
91#endif
92
93#endif
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index e971c55f45ac..1f3cd8ad0523 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -16,6 +16,7 @@
16#include <linux/log2.h> 16#include <linux/log2.h>
17#include <linux/typecheck.h> 17#include <linux/typecheck.h>
18#include <linux/ratelimit.h> 18#include <linux/ratelimit.h>
19#include <linux/dynamic_printk.h>
19#include <asm/byteorder.h> 20#include <asm/byteorder.h>
20#include <asm/bug.h> 21#include <asm/bug.h>
21 22
@@ -304,8 +305,12 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
304#define pr_info(fmt, arg...) \ 305#define pr_info(fmt, arg...) \
305 printk(KERN_INFO fmt, ##arg) 306 printk(KERN_INFO fmt, ##arg)
306 307
307#ifdef DEBUG
308/* If you are writing a driver, please use dev_dbg instead */ 308/* If you are writing a driver, please use dev_dbg instead */
309#if defined(CONFIG_DYNAMIC_PRINTK_DEBUG)
310#define pr_debug(fmt, ...) do { \
311 dynamic_pr_debug(fmt, ##__VA_ARGS__); \
312 } while (0)
313#elif defined(DEBUG)
309#define pr_debug(fmt, arg...) \ 314#define pr_debug(fmt, arg...) \
310 printk(KERN_DEBUG fmt, ##arg) 315 printk(KERN_DEBUG fmt, ##arg)
311#else 316#else
diff --git a/include/linux/module.h b/include/linux/module.h
index 68e09557c951..a41555cbe00a 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -345,7 +345,6 @@ struct module
345 /* Reference counts */ 345 /* Reference counts */
346 struct module_ref ref[NR_CPUS]; 346 struct module_ref ref[NR_CPUS];
347#endif 347#endif
348
349}; 348};
350#ifndef MODULE_ARCH_INIT 349#ifndef MODULE_ARCH_INIT
351#define MODULE_ARCH_INIT {} 350#define MODULE_ARCH_INIT {}
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 95ac21ab3a09..4b8cc6a32479 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -37,6 +37,8 @@ extern int platform_add_devices(struct platform_device **, int);
37 37
38extern struct platform_device *platform_device_register_simple(const char *, int id, 38extern struct platform_device *platform_device_register_simple(const char *, int id,
39 struct resource *, unsigned int); 39 struct resource *, unsigned int);
40extern struct platform_device *platform_device_register_data(struct device *,
41 const char *, int, const void *, size_t);
40 42
41extern struct platform_device *platform_device_alloc(const char *name, int id); 43extern struct platform_device *platform_device_alloc(const char *name, int id);
42extern int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num); 44extern int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num);
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 37fa24152bd8..b330e289d71f 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -78,6 +78,8 @@ struct sysfs_ops {
78 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); 78 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t);
79}; 79};
80 80
81struct sysfs_dirent;
82
81#ifdef CONFIG_SYSFS 83#ifdef CONFIG_SYSFS
82 84
83int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *), 85int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *),
@@ -117,9 +119,14 @@ int sysfs_add_file_to_group(struct kobject *kobj,
117void sysfs_remove_file_from_group(struct kobject *kobj, 119void sysfs_remove_file_from_group(struct kobject *kobj,
118 const struct attribute *attr, const char *group); 120 const struct attribute *attr, const char *group);
119 121
120void sysfs_notify(struct kobject *kobj, char *dir, char *attr); 122void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
121 123void sysfs_notify_dirent(struct sysfs_dirent *sd);
122extern int __must_check sysfs_init(void); 124struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
125 const unsigned char *name);
126struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd);
127void sysfs_put(struct sysfs_dirent *sd);
128void sysfs_printk_last_file(void);
129int __must_check sysfs_init(void);
123 130
124#else /* CONFIG_SYSFS */ 131#else /* CONFIG_SYSFS */
125 132
@@ -222,7 +229,24 @@ static inline void sysfs_remove_file_from_group(struct kobject *kobj,
222{ 229{
223} 230}
224 231
225static inline void sysfs_notify(struct kobject *kobj, char *dir, char *attr) 232static inline void sysfs_notify(struct kobject *kobj, const char *dir,
233 const char *attr)
234{
235}
236static inline void sysfs_notify_dirent(struct sysfs_dirent *sd)
237{
238}
239static inline
240struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
241 const unsigned char *name)
242{
243 return NULL;
244}
245static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd)
246{
247 return NULL;
248}
249static inline void sysfs_put(struct sysfs_dirent *sd)
226{ 250{
227} 251}
228 252
@@ -231,6 +255,10 @@ static inline int __must_check sysfs_init(void)
231 return 0; 255 return 0;
232} 256}
233 257
258static inline void sysfs_printk_last_file(void)
259{
260}
261
234#endif /* CONFIG_SYSFS */ 262#endif /* CONFIG_SYSFS */
235 263
236#endif /* _SYSFS_H_ */ 264#endif /* _SYSFS_H_ */