Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
[linux-2.6-block.git] / include / linux / module.h
CommitLineData
1da177e4
LT
1#ifndef _LINUX_MODULE_H
2#define _LINUX_MODULE_H
3/*
4 * Dynamic loading of modules into the kernel.
5 *
6 * Rewritten by Richard Henderson <rth@tamu.edu> Dec 1996
7 * Rewritten again by Rusty Russell, 2002
8 */
1da177e4
LT
9#include <linux/list.h>
10#include <linux/stat.h>
11#include <linux/compiler.h>
12#include <linux/cache.h>
13#include <linux/kmod.h>
14#include <linux/elf.h>
15#include <linux/stringify.h>
16#include <linux/kobject.h>
17#include <linux/moduleparam.h>
97e1c18e 18#include <linux/tracepoint.h>
1da177e4 19
e1783a24 20#include <linux/percpu.h>
1da177e4
LT
21#include <asm/module.h>
22
7ead8b83
LZ
23#include <trace/events/module.h>
24
1da177e4
LT
25/* Not Yet Implemented */
26#define MODULE_SUPPORTED_DEVICE(name)
27
9e1b9b80
AJ
28/* Some toolchains use a `_' prefix for all user symbols. */
29#ifdef CONFIG_SYMBOL_PREFIX
30#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX
31#else
1da177e4
LT
32#define MODULE_SYMBOL_PREFIX ""
33#endif
34
730b69d2 35#define MODULE_NAME_LEN MAX_PARAM_PREFIX_LEN
1da177e4
LT
36
37struct kernel_symbol
38{
39 unsigned long value;
40 const char *name;
41};
42
43struct modversion_info
44{
45 unsigned long crc;
46 char name[MODULE_NAME_LEN];
47};
48
49struct module;
50
4befb026
KS
51struct module_kobject {
52 struct kobject kobj;
53 struct module *mod;
54 struct kobject *drivers_dir;
55 struct module_param_attrs *mp;
56};
57
1da177e4 58struct module_attribute {
4befb026
KS
59 struct attribute attr;
60 ssize_t (*show)(struct module_attribute *, struct module_kobject *,
61 char *);
62 ssize_t (*store)(struct module_attribute *, struct module_kobject *,
1da177e4 63 const char *, size_t count);
c988d2b2
MD
64 void (*setup)(struct module *, const char *);
65 int (*test)(struct module *);
66 void (*free)(struct module *);
1da177e4
LT
67};
68
e94965ed
DT
69struct module_version_attribute {
70 struct module_attribute mattr;
71 const char *module_name;
72 const char *version;
98562ad8 73} __attribute__ ((__aligned__(sizeof(void *))));
e94965ed 74
9b73a584 75extern ssize_t __modver_version_show(struct module_attribute *,
4befb026 76 struct module_kobject *, char *);
9b73a584 77
88bfa324 78extern struct module_attribute module_uevent;
1da177e4
LT
79
80/* These are either module local, or the kernel's dummy ones. */
81extern int init_module(void);
82extern void cleanup_module(void);
83
84/* Archs provide a method of finding the correct exception table. */
85struct exception_table_entry;
86
87const struct exception_table_entry *
88search_extable(const struct exception_table_entry *first,
89 const struct exception_table_entry *last,
90 unsigned long value);
91void sort_extable(struct exception_table_entry *start,
92 struct exception_table_entry *finish);
93void sort_main_extable(void);
ad6561df 94void trim_init_extable(struct module *m);
1da177e4 95
1da177e4
LT
96#ifdef MODULE
97#define MODULE_GENERIC_TABLE(gtype,name) \
98extern const struct gtype##_id __mod_##gtype##_table \
99 __attribute__ ((unused, alias(__stringify(name))))
100
101extern struct module __this_module;
102#define THIS_MODULE (&__this_module)
103#else /* !MODULE */
104#define MODULE_GENERIC_TABLE(gtype,name)
105#define THIS_MODULE ((struct module *)0)
106#endif
107
108/* Generic info of form tag = "info" */
109#define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
110
111/* For userspace: you can also call me... */
112#define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
113
114/*
115 * The following license idents are currently accepted as indicating free
116 * software modules
117 *
118 * "GPL" [GNU Public License v2 or later]
119 * "GPL v2" [GNU Public License v2]
120 * "GPL and additional rights" [GNU Public License v2 rights and more]
121 * "Dual BSD/GPL" [GNU Public License v2
122 * or BSD license choice]
8d27e908
XVP
123 * "Dual MIT/GPL" [GNU Public License v2
124 * or MIT license choice]
1da177e4
LT
125 * "Dual MPL/GPL" [GNU Public License v2
126 * or Mozilla license choice]
127 *
128 * The following other idents are available
129 *
130 * "Proprietary" [Non free products]
131 *
132 * There are dual licensed components, but when running with Linux it is the
133 * GPL that is relevant so this is a non issue. Similarly LGPL linked with GPL
134 * is a GPL combined work.
135 *
136 * This exists for several reasons
137 * 1. So modinfo can show license info for users wanting to vet their setup
138 * is free
139 * 2. So the community can ignore bug reports including proprietary modules
140 * 3. So vendors can do likewise based on their own policies
141 */
142#define MODULE_LICENSE(_license) MODULE_INFO(license, _license)
143
1d7015ca
JB
144/*
145 * Author(s), use "Name <email>" or just "Name", for multiple
146 * authors use multiple MODULE_AUTHOR() statements/lines.
147 */
1da177e4
LT
148#define MODULE_AUTHOR(_author) MODULE_INFO(author, _author)
149
150/* What your module does. */
151#define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
152
153/* One for each parameter, describing how to use it. Some files do
154 multiple of these per line, so can't just use MODULE_INFO. */
155#define MODULE_PARM_DESC(_parm, desc) \
156 __MODULE_INFO(parm, _parm, #_parm ":" desc)
157
158#define MODULE_DEVICE_TABLE(type,name) \
159 MODULE_GENERIC_TABLE(type##_device,name)
160
161/* Version of form [<epoch>:]<version>[-<extra-version>].
162 Or for CVS/RCS ID version, everything but the number is stripped.
163 <epoch>: A (small) unsigned integer which allows you to start versions
164 anew. If not mentioned, it's zero. eg. "2:1.0" is after
165 "1:2.0".
166 <version>: The <version> may contain only alphanumerics and the
167 character `.'. Ordered by numeric sort for numeric parts,
168 ascii sort for ascii parts (as per RPM or DEB algorithm).
169 <extraversion>: Like <version>, but inserted for local
170 customizations, eg "rh3" or "rusty1".
171
172 Using this automatically adds a checksum of the .c files and the
173 local headers in "srcversion".
174*/
e94965ed 175
3b90a5b2 176#if defined(MODULE) || !defined(CONFIG_SYSFS)
1da177e4 177#define MODULE_VERSION(_version) MODULE_INFO(version, _version)
e94965ed
DT
178#else
179#define MODULE_VERSION(_version) \
b4bc8428 180 static struct module_version_attribute ___modver_attr = { \
e94965ed
DT
181 .mattr = { \
182 .attr = { \
183 .name = "version", \
184 .mode = S_IRUGO, \
185 }, \
186 .show = __modver_version_show, \
187 }, \
188 .module_name = KBUILD_MODNAME, \
189 .version = _version, \
b4bc8428
DT
190 }; \
191 static const struct module_version_attribute \
192 __used __attribute__ ((__section__ ("__modver"))) \
193 * __moduleparam_const __modver_attr = &___modver_attr
e94965ed 194#endif
1da177e4 195
187afbed
JM
196/* Optional firmware file (or files) needed by the module
197 * format is simply firmware file name. Multiple firmware
198 * files require multiple MODULE_FIRMWARE() specifiers */
199#define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware)
200
1da177e4
LT
201/* Given an address, look for it in the exception tables */
202const struct exception_table_entry *search_exception_tables(unsigned long add);
203
204struct notifier_block;
205
206#ifdef CONFIG_MODULES
207
5ed10910 208extern int modules_disabled; /* for sysctl */
1da177e4
LT
209/* Get/put a kernel symbol (calls must be symmetric) */
210void *__symbol_get(const char *symbol);
211void *__symbol_get_gpl(const char *symbol);
212#define symbol_get(x) ((typeof(&x))(__symbol_get(MODULE_SYMBOL_PREFIX #x)))
213
c8e21ced
RR
214/* modules using other modules: kdb wants to see this. */
215struct module_use {
216 struct list_head source_list;
217 struct list_head target_list;
218 struct module *source, *target;
219};
220
1da177e4
LT
221#ifndef __GENKSYMS__
222#ifdef CONFIG_MODVERSIONS
223/* Mark the CRC weak since genksyms apparently decides not to
224 * generate a checksums for some symbols */
225#define __CRC_SYMBOL(sym, sec) \
226 extern void *__crc_##sym __attribute__((weak)); \
227 static const unsigned long __kcrctab_##sym \
3ff6eecc 228 __used \
f02e8a65 229 __attribute__((section("___kcrctab" sec "+" #sym), unused)) \
1da177e4
LT
230 = (unsigned long) &__crc_##sym;
231#else
232#define __CRC_SYMBOL(sym, sec)
233#endif
234
235/* For every exported symbol, place a struct in the __ksymtab section */
236#define __EXPORT_SYMBOL(sym, sec) \
a1a8feed 237 extern typeof(sym) sym; \
1da177e4
LT
238 __CRC_SYMBOL(sym, sec) \
239 static const char __kstrtab_##sym[] \
ea01e798 240 __attribute__((section("__ksymtab_strings"), aligned(1))) \
1da177e4
LT
241 = MODULE_SYMBOL_PREFIX #sym; \
242 static const struct kernel_symbol __ksymtab_##sym \
3ff6eecc 243 __used \
f02e8a65 244 __attribute__((section("___ksymtab" sec "+" #sym), unused)) \
1da177e4
LT
245 = { (unsigned long)&sym, __kstrtab_##sym }
246
247#define EXPORT_SYMBOL(sym) \
248 __EXPORT_SYMBOL(sym, "")
249
250#define EXPORT_SYMBOL_GPL(sym) \
251 __EXPORT_SYMBOL(sym, "_gpl")
252
9f28bb7e
GKH
253#define EXPORT_SYMBOL_GPL_FUTURE(sym) \
254 __EXPORT_SYMBOL(sym, "_gpl_future")
255
f71d20e9
AV
256
257#ifdef CONFIG_UNUSED_SYMBOLS
258#define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused")
259#define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl")
260#else
261#define EXPORT_UNUSED_SYMBOL(sym)
262#define EXPORT_UNUSED_SYMBOL_GPL(sym)
263#endif
264
1da177e4
LT
265#endif
266
1da177e4
LT
267enum module_state
268{
269 MODULE_STATE_LIVE,
270 MODULE_STATE_COMING,
271 MODULE_STATE_GOING,
272};
273
1da177e4
LT
274struct module
275{
276 enum module_state state;
277
278 /* Member of list of modules */
279 struct list_head list;
280
281 /* Unique handle for this module */
282 char name[MODULE_NAME_LEN];
283
284 /* Sysfs stuff. */
285 struct module_kobject mkobj;
03e88ae1 286 struct module_attribute *modinfo_attrs;
c988d2b2
MD
287 const char *version;
288 const char *srcversion;
270a6c4c 289 struct kobject *holders_dir;
1da177e4
LT
290
291 /* Exported symbols */
292 const struct kernel_symbol *syms;
1da177e4 293 const unsigned long *crcs;
af540689 294 unsigned int num_syms;
1da177e4 295
e180a6b7
RR
296 /* Kernel parameters. */
297 struct kernel_param *kp;
298 unsigned int num_kp;
299
1da177e4 300 /* GPL-only exported symbols. */
1da177e4 301 unsigned int num_gpl_syms;
af540689 302 const struct kernel_symbol *gpl_syms;
1da177e4
LT
303 const unsigned long *gpl_crcs;
304
f7f5b675 305#ifdef CONFIG_UNUSED_SYMBOLS
f71d20e9
AV
306 /* unused exported symbols. */
307 const struct kernel_symbol *unused_syms;
f71d20e9 308 const unsigned long *unused_crcs;
af540689
RK
309 unsigned int num_unused_syms;
310
f71d20e9 311 /* GPL-only, unused exported symbols. */
f71d20e9 312 unsigned int num_unused_gpl_syms;
af540689 313 const struct kernel_symbol *unused_gpl_syms;
f71d20e9 314 const unsigned long *unused_gpl_crcs;
f7f5b675 315#endif
f71d20e9 316
9f28bb7e
GKH
317 /* symbols that will be GPL-only in the near future. */
318 const struct kernel_symbol *gpl_future_syms;
9f28bb7e 319 const unsigned long *gpl_future_crcs;
af540689 320 unsigned int num_gpl_future_syms;
9f28bb7e 321
1da177e4
LT
322 /* Exception table */
323 unsigned int num_exentries;
5e458cc0 324 struct exception_table_entry *extable;
1da177e4
LT
325
326 /* Startup function. */
327 int (*init)(void);
328
329 /* If this is non-NULL, vfree after init() returns */
330 void *module_init;
331
332 /* Here is the actual code + data, vfree'd on unload. */
333 void *module_core;
334
335 /* Here are the sizes of the init and core sections */
2f0f2a33 336 unsigned int init_size, core_size;
1da177e4
LT
337
338 /* The size of the executable code in each section. */
2f0f2a33 339 unsigned int init_text_size, core_text_size;
1da177e4 340
84e1c6bb 341 /* Size of RO sections of the module (text+rodata) */
342 unsigned int init_ro_size, core_ro_size;
343
1da177e4
LT
344 /* Arch-specific module values */
345 struct mod_arch_specific arch;
346
2bc2d61a
RD
347 unsigned int taints; /* same bits as kernel:tainted */
348
7664c5a1
JF
349#ifdef CONFIG_GENERIC_BUG
350 /* Support for BUG */
af540689 351 unsigned num_bugs;
7664c5a1
JF
352 struct list_head bug_list;
353 struct bug_entry *bug_table;
1da177e4
LT
354#endif
355
356#ifdef CONFIG_KALLSYMS
4a496226
JB
357 /*
358 * We keep the symbol and string tables for kallsyms.
359 * The core_* fields below are temporary, loader-only (they
360 * could really be discarded after module init).
361 */
362 Elf_Sym *symtab, *core_symtab;
363 unsigned int num_symtab, core_num_syms;
554bdfe5 364 char *strtab, *core_strtab;
1da177e4
LT
365
366 /* Section attributes */
367 struct module_sect_attrs *sect_attrs;
6d760133
RM
368
369 /* Notes attributes */
370 struct module_notes_attrs *notes_attrs;
1da177e4
LT
371#endif
372
a288bd65
RK
373 /* The command line arguments (may be mangled). People like
374 keeping pointers to this stuff */
375 char *args;
376
259354de 377#ifdef CONFIG_SMP
1da177e4 378 /* Per-cpu data. */
259354de
TH
379 void __percpu *percpu;
380 unsigned int percpu_size;
381#endif
1da177e4 382
97e1c18e 383#ifdef CONFIG_TRACEPOINTS
97e1c18e 384 unsigned int num_tracepoints;
a288bd65 385 struct tracepoint * const *tracepoints_ptrs;
97e1c18e 386#endif
bf5438fc
JB
387#ifdef HAVE_JUMP_LABEL
388 struct jump_entry *jump_entries;
389 unsigned int num_jump_entries;
390#endif
769b0441 391#ifdef CONFIG_TRACING
1ba28e02 392 unsigned int num_trace_bprintk_fmt;
a288bd65 393 const char **trace_bprintk_fmt_start;
1ba28e02 394#endif
6d723736 395#ifdef CONFIG_EVENT_TRACING
e4a9ea5e 396 struct ftrace_event_call **trace_events;
6d723736
SR
397 unsigned int num_trace_events;
398#endif
93eb677d 399#ifdef CONFIG_FTRACE_MCOUNT_RECORD
93eb677d 400 unsigned int num_ftrace_callsites;
a288bd65 401 unsigned long *ftrace_callsites;
93eb677d 402#endif
1ba28e02 403
af540689
RK
404#ifdef CONFIG_MODULE_UNLOAD
405 /* What modules depend on me? */
2c02dfe7
LT
406 struct list_head source_list;
407 /* What modules do I depend on? */
408 struct list_head target_list;
af540689
RK
409
410 /* Who is waiting for us to be unloaded */
411 struct task_struct *waiter;
412
413 /* Destruction function. */
414 void (*exit)(void);
415
e1783a24 416 struct module_ref {
5fbfb18d
NP
417 unsigned int incs;
418 unsigned int decs;
43cf38eb 419 } __percpu *refptr;
af540689 420#endif
b99b87f7
PO
421
422#ifdef CONFIG_CONSTRUCTORS
423 /* Constructor functions. */
424 ctor_fn_t *ctors;
425 unsigned int num_ctors;
426#endif
1da177e4 427};
e61a1c1c
RZ
428#ifndef MODULE_ARCH_INIT
429#define MODULE_ARCH_INIT {}
430#endif
1da177e4 431
c6b37801
TA
432extern struct mutex module_mutex;
433
1da177e4
LT
434/* FIXME: It'd be nice to isolate modules during init, too, so they
435 aren't used before they (may) fail. But presently too much code
436 (IDE & SCSI) require entry into the module during init.*/
437static inline int module_is_live(struct module *mod)
438{
439 return mod->state != MODULE_STATE_GOING;
440}
441
1da177e4 442struct module *__module_text_address(unsigned long addr);
e610499e
RR
443struct module *__module_address(unsigned long addr);
444bool is_module_address(unsigned long addr);
10fad5e4 445bool is_module_percpu_address(unsigned long addr);
e610499e 446bool is_module_text_address(unsigned long addr);
1da177e4 447
a06f6211
MH
448static inline int within_module_core(unsigned long addr, struct module *mod)
449{
450 return (unsigned long)mod->module_core <= addr &&
451 addr < (unsigned long)mod->module_core + mod->core_size;
452}
453
454static inline int within_module_init(unsigned long addr, struct module *mod)
455{
456 return (unsigned long)mod->module_init <= addr &&
457 addr < (unsigned long)mod->module_init + mod->init_size;
458}
459
c6b37801
TA
460/* Search for module by name: must hold module_mutex. */
461struct module *find_module(const char *name);
462
463struct symsearch {
464 const struct kernel_symbol *start, *stop;
465 const unsigned long *crcs;
466 enum {
467 NOT_GPL_ONLY,
468 GPL_ONLY,
469 WILL_BE_GPL_ONLY,
470 } licence;
471 bool unused;
472};
473
474/* Search for an exported symbol by name. */
475const struct kernel_symbol *find_symbol(const char *name,
476 struct module **owner,
477 const unsigned long **crc,
478 bool gplok,
479 bool warn);
480
481/* Walk the exported symbol table */
de4d8d53
RR
482bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
483 struct module *owner,
484 void *data), void *data);
c6b37801 485
ea07890a 486/* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
1da177e4 487 symnum out of range. */
ea07890a
AD
488int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
489 char *name, char *module_name, int *exported);
1da177e4
LT
490
491/* Look for this name: can be of form module:name. */
492unsigned long module_kallsyms_lookup_name(const char *name);
493
75a66614
AK
494int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
495 struct module *, unsigned long),
496 void *data);
497
1da177e4
LT
498extern void __module_put_and_exit(struct module *mod, long code)
499 __attribute__((noreturn));
500#define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code);
501
502#ifdef CONFIG_MODULE_UNLOAD
503unsigned int module_refcount(struct module *mod);
504void __symbol_put(const char *symbol);
505#define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x)
506void symbol_put_addr(void *addr);
507
508/* Sometimes we know we already have a refcount, and it's easier not
509 to handle the error case (which only happens with rmmod --wait). */
510static inline void __module_get(struct module *module)
511{
512 if (module) {
e1783a24 513 preempt_disable();
5fbfb18d 514 __this_cpu_inc(module->refptr->incs);
ae832d1e 515 trace_module_get(module, _THIS_IP_);
e1783a24 516 preempt_enable();
1da177e4
LT
517 }
518}
519
520static inline int try_module_get(struct module *module)
521{
522 int ret = 1;
523
524 if (module) {
e1783a24
CL
525 preempt_disable();
526
7ead8b83 527 if (likely(module_is_live(module))) {
5fbfb18d 528 __this_cpu_inc(module->refptr->incs);
ae832d1e 529 trace_module_get(module, _THIS_IP_);
5fbfb18d 530 } else
1da177e4 531 ret = 0;
e1783a24
CL
532
533 preempt_enable();
1da177e4
LT
534 }
535 return ret;
536}
537
f6a57033 538extern void module_put(struct module *module);
1da177e4
LT
539
540#else /*!CONFIG_MODULE_UNLOAD*/
541static inline int try_module_get(struct module *module)
542{
543 return !module || module_is_live(module);
544}
545static inline void module_put(struct module *module)
546{
547}
548static inline void __module_get(struct module *module)
549{
550}
551#define symbol_put(x) do { } while(0)
552#define symbol_put_addr(p) do { } while(0)
553
554#endif /* CONFIG_MODULE_UNLOAD */
dfd62d1d 555int ref_module(struct module *a, struct module *b);
1da177e4
LT
556
557/* This is a #define so the string doesn't get put in every .o file */
558#define module_name(mod) \
559({ \
560 struct module *__mod = (mod); \
561 __mod ? __mod->name : "kernel"; \
562})
563
6dd06c9f
RR
564/* For kallsyms to ask for address resolution. namebuf should be at
565 * least KSYM_NAME_LEN long: a pointer to namebuf is returned if
566 * found, otherwise NULL. */
92dfc9dc 567const char *module_address_lookup(unsigned long addr,
6dd06c9f
RR
568 unsigned long *symbolsize,
569 unsigned long *offset,
570 char **modname,
571 char *namebuf);
9d65cb4a 572int lookup_module_symbol_name(unsigned long addr, char *symname);
a5c43dae 573int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name);
1da177e4
LT
574
575/* For extable.c to search modules' exception tables. */
576const struct exception_table_entry *search_module_extables(unsigned long addr);
577
578int register_module_notifier(struct notifier_block * nb);
579int unregister_module_notifier(struct notifier_block * nb);
580
581extern void print_modules(void);
582
1da177e4
LT
583#else /* !CONFIG_MODULES... */
584#define EXPORT_SYMBOL(sym)
585#define EXPORT_SYMBOL_GPL(sym)
9f28bb7e 586#define EXPORT_SYMBOL_GPL_FUTURE(sym)
f71d20e9
AV
587#define EXPORT_UNUSED_SYMBOL(sym)
588#define EXPORT_UNUSED_SYMBOL_GPL(sym)
1da177e4
LT
589
590/* Given an address, look for it in the exception tables. */
591static inline const struct exception_table_entry *
592search_module_extables(unsigned long addr)
593{
594 return NULL;
595}
596
e610499e
RR
597static inline struct module *__module_address(unsigned long addr)
598{
599 return NULL;
600}
601
1da177e4
LT
602static inline struct module *__module_text_address(unsigned long addr)
603{
604 return NULL;
605}
606
e610499e
RR
607static inline bool is_module_address(unsigned long addr)
608{
609 return false;
610}
611
d5e50daf
RD
612static inline bool is_module_percpu_address(unsigned long addr)
613{
614 return false;
615}
616
e610499e 617static inline bool is_module_text_address(unsigned long addr)
4d435f9d 618{
e610499e 619 return false;
4d435f9d
IM
620}
621
1da177e4
LT
622/* Get/put a kernel symbol (calls should be symmetric) */
623#define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); })
624#define symbol_put(x) do { } while(0)
625#define symbol_put_addr(x) do { } while(0)
626
627static inline void __module_get(struct module *module)
628{
629}
630
631static inline int try_module_get(struct module *module)
632{
633 return 1;
634}
635
636static inline void module_put(struct module *module)
637{
638}
639
640#define module_name(mod) "kernel"
641
1da177e4 642/* For kallsyms to ask for address resolution. NULL means not found. */
92dfc9dc 643static inline const char *module_address_lookup(unsigned long addr,
6dd06c9f
RR
644 unsigned long *symbolsize,
645 unsigned long *offset,
646 char **modname,
647 char *namebuf)
1da177e4
LT
648{
649 return NULL;
650}
651
9d65cb4a
AD
652static inline int lookup_module_symbol_name(unsigned long addr, char *symname)
653{
654 return -ERANGE;
655}
656
a5c43dae
AD
657static inline int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name)
658{
659 return -ERANGE;
660}
661
ea07890a
AD
662static inline int module_get_kallsym(unsigned int symnum, unsigned long *value,
663 char *type, char *name,
664 char *module_name, int *exported)
1da177e4 665{
ea07890a 666 return -ERANGE;
1da177e4
LT
667}
668
669static inline unsigned long module_kallsyms_lookup_name(const char *name)
670{
671 return 0;
672}
673
75a66614
AK
674static inline int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
675 struct module *,
676 unsigned long),
677 void *data)
678{
679 return 0;
680}
681
1da177e4
LT
682static inline int register_module_notifier(struct notifier_block * nb)
683{
684 /* no events will happen anyway, so this can always succeed */
685 return 0;
686}
687
688static inline int unregister_module_notifier(struct notifier_block * nb)
689{
690 return 0;
691}
692
693#define module_put_and_exit(code) do_exit(code)
694
695static inline void print_modules(void)
696{
697}
ef665c1a
RD
698#endif /* CONFIG_MODULES */
699
ef665c1a 700#ifdef CONFIG_SYSFS
7405c1e1
GKH
701extern struct kset *module_kset;
702extern struct kobj_type module_ktype;
703extern int module_sysfs_initialized;
ef665c1a
RD
704#endif /* CONFIG_SYSFS */
705
1da177e4
LT
706#define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
707
708/* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */
709
1da177e4
LT
710#define __MODULE_STRING(x) __stringify(x)
711
84e1c6bb 712#ifdef CONFIG_DEBUG_SET_MODULE_RONX
713extern void set_all_modules_text_rw(void);
714extern void set_all_modules_text_ro(void);
715#else
716static inline void set_all_modules_text_rw(void) { }
717static inline void set_all_modules_text_ro(void) { }
718#endif
0d9c25dd
AM
719
720#ifdef CONFIG_GENERIC_BUG
5336377d 721void module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *,
0d9c25dd
AM
722 struct module *);
723void module_bug_cleanup(struct module *);
724
725#else /* !CONFIG_GENERIC_BUG */
726
5336377d 727static inline void module_bug_finalize(const Elf_Ehdr *hdr,
0d9c25dd
AM
728 const Elf_Shdr *sechdrs,
729 struct module *mod)
730{
0d9c25dd
AM
731}
732static inline void module_bug_cleanup(struct module *mod) {}
733#endif /* CONFIG_GENERIC_BUG */
734
1da177e4 735#endif /* _LINUX_MODULE_H */