module.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  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. */
  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>
  18. #include <linux/tracepoint.h>
  19. #include <linux/percpu.h>
  20. #include <asm/module.h>
  21. #include <trace/events/module.h>
  22. /* Not Yet Implemented */
  23. #define MODULE_SUPPORTED_DEVICE(name)
  24. /* Some toolchains use a `_' prefix for all user symbols. */
  25. #ifdef CONFIG_SYMBOL_PREFIX
  26. #define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX
  27. #else
  28. #define MODULE_SYMBOL_PREFIX ""
  29. #endif
  30. #define MODULE_NAME_LEN MAX_PARAM_PREFIX_LEN
  31. struct kernel_symbol
  32. {
  33. unsigned long value;
  34. const char *name;
  35. };
  36. struct modversion_info
  37. {
  38. unsigned long crc;
  39. char name[MODULE_NAME_LEN];
  40. };
  41. struct module;
  42. struct module_attribute {
  43. struct attribute attr;
  44. ssize_t (*show)(struct module_attribute *, struct module *, char *);
  45. ssize_t (*store)(struct module_attribute *, struct module *,
  46. const char *, size_t count);
  47. void (*setup)(struct module *, const char *);
  48. int (*test)(struct module *);
  49. void (*free)(struct module *);
  50. };
  51. struct module_kobject
  52. {
  53. struct kobject kobj;
  54. struct module *mod;
  55. struct kobject *drivers_dir;
  56. struct module_param_attrs *mp;
  57. };
  58. /* These are either module local, or the kernel's dummy ones. */
  59. extern int init_module(void);
  60. extern void cleanup_module(void);
  61. /* Archs provide a method of finding the correct exception table. */
  62. struct exception_table_entry;
  63. const struct exception_table_entry *
  64. search_extable(const struct exception_table_entry *first,
  65. const struct exception_table_entry *last,
  66. unsigned long value);
  67. void sort_extable(struct exception_table_entry *start,
  68. struct exception_table_entry *finish);
  69. void sort_main_extable(void);
  70. void trim_init_extable(struct module *m);
  71. #ifdef MODULE
  72. #define MODULE_GENERIC_TABLE(gtype,name) \
  73. extern const struct gtype##_id __mod_##gtype##_table \
  74. __attribute__ ((unused, alias(__stringify(name))))
  75. extern struct module __this_module;
  76. #define THIS_MODULE (&__this_module)
  77. #else /* !MODULE */
  78. #define MODULE_GENERIC_TABLE(gtype,name)
  79. #define THIS_MODULE ((struct module *)0)
  80. #endif
  81. /* Generic info of form tag = "info" */
  82. #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
  83. /* For userspace: you can also call me... */
  84. #define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
  85. /*
  86. * The following license idents are currently accepted as indicating free
  87. * software modules
  88. *
  89. * "GPL" [GNU Public License v2 or later]
  90. * "GPL v2" [GNU Public License v2]
  91. * "GPL and additional rights" [GNU Public License v2 rights and more]
  92. * "Dual BSD/GPL" [GNU Public License v2
  93. * or BSD license choice]
  94. * "Dual MIT/GPL" [GNU Public License v2
  95. * or MIT license choice]
  96. * "Dual MPL/GPL" [GNU Public License v2
  97. * or Mozilla license choice]
  98. *
  99. * The following other idents are available
  100. *
  101. * "Proprietary" [Non free products]
  102. *
  103. * There are dual licensed components, but when running with Linux it is the
  104. * GPL that is relevant so this is a non issue. Similarly LGPL linked with GPL
  105. * is a GPL combined work.
  106. *
  107. * This exists for several reasons
  108. * 1. So modinfo can show license info for users wanting to vet their setup
  109. * is free
  110. * 2. So the community can ignore bug reports including proprietary modules
  111. * 3. So vendors can do likewise based on their own policies
  112. */
  113. #define MODULE_LICENSE(_license) MODULE_INFO(license, _license)
  114. /*
  115. * Author(s), use "Name <email>" or just "Name", for multiple
  116. * authors use multiple MODULE_AUTHOR() statements/lines.
  117. */
  118. #define MODULE_AUTHOR(_author) MODULE_INFO(author, _author)
  119. /* What your module does. */
  120. #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
  121. /* One for each parameter, describing how to use it. Some files do
  122. multiple of these per line, so can't just use MODULE_INFO. */
  123. #define MODULE_PARM_DESC(_parm, desc) \
  124. __MODULE_INFO(parm, _parm, #_parm ":" desc)
  125. #define MODULE_DEVICE_TABLE(type,name) \
  126. MODULE_GENERIC_TABLE(type##_device,name)
  127. /* Version of form [<epoch>:]<version>[-<extra-version>].
  128. Or for CVS/RCS ID version, everything but the number is stripped.
  129. <epoch>: A (small) unsigned integer which allows you to start versions
  130. anew. If not mentioned, it's zero. eg. "2:1.0" is after
  131. "1:2.0".
  132. <version>: The <version> may contain only alphanumerics and the
  133. character `.'. Ordered by numeric sort for numeric parts,
  134. ascii sort for ascii parts (as per RPM or DEB algorithm).
  135. <extraversion>: Like <version>, but inserted for local
  136. customizations, eg "rh3" or "rusty1".
  137. Using this automatically adds a checksum of the .c files and the
  138. local headers in "srcversion".
  139. */
  140. #define MODULE_VERSION(_version) MODULE_INFO(version, _version)
  141. /* Optional firmware file (or files) needed by the module
  142. * format is simply firmware file name. Multiple firmware
  143. * files require multiple MODULE_FIRMWARE() specifiers */
  144. #define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware)
  145. /* Given an address, look for it in the exception tables */
  146. const struct exception_table_entry *search_exception_tables(unsigned long add);
  147. struct notifier_block;
  148. #ifdef CONFIG_MODULES
  149. extern int modules_disabled; /* for sysctl */
  150. /* Get/put a kernel symbol (calls must be symmetric) */
  151. void *__symbol_get(const char *symbol);
  152. void *__symbol_get_gpl(const char *symbol);
  153. #define symbol_get(x) ((typeof(&x))(__symbol_get(MODULE_SYMBOL_PREFIX #x)))
  154. /* modules using other modules: kdb wants to see this. */
  155. struct module_use {
  156. struct list_head source_list;
  157. struct list_head target_list;
  158. struct module *source, *target;
  159. };
  160. #ifndef __GENKSYMS__
  161. #ifdef CONFIG_MODVERSIONS
  162. /* Mark the CRC weak since genksyms apparently decides not to
  163. * generate a checksums for some symbols */
  164. #define __CRC_SYMBOL(sym, sec) \
  165. extern void *__crc_##sym __attribute__((weak)); \
  166. static const unsigned long __kcrctab_##sym \
  167. __used \
  168. __attribute__((section("__kcrctab" sec), unused)) \
  169. = (unsigned long) &__crc_##sym;
  170. #else
  171. #define __CRC_SYMBOL(sym, sec)
  172. #endif
  173. /* For every exported symbol, place a struct in the __ksymtab section */
  174. #define __EXPORT_SYMBOL(sym, sec) \
  175. extern typeof(sym) sym; \
  176. __CRC_SYMBOL(sym, sec) \
  177. static const char __kstrtab_##sym[] \
  178. __attribute__((section("__ksymtab_strings"), aligned(1))) \
  179. = MODULE_SYMBOL_PREFIX #sym; \
  180. static const struct kernel_symbol __ksymtab_##sym \
  181. __used \
  182. __attribute__((section("__ksymtab" sec), unused)) \
  183. = { (unsigned long)&sym, __kstrtab_##sym }
  184. #define EXPORT_SYMBOL(sym) \
  185. __EXPORT_SYMBOL(sym, "")
  186. #define EXPORT_SYMBOL_GPL(sym) \
  187. __EXPORT_SYMBOL(sym, "_gpl")
  188. #define EXPORT_SYMBOL_GPL_FUTURE(sym) \
  189. __EXPORT_SYMBOL(sym, "_gpl_future")
  190. #ifdef CONFIG_UNUSED_SYMBOLS
  191. #define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused")
  192. #define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl")
  193. #else
  194. #define EXPORT_UNUSED_SYMBOL(sym)
  195. #define EXPORT_UNUSED_SYMBOL_GPL(sym)
  196. #endif
  197. #endif
  198. enum module_state
  199. {
  200. MODULE_STATE_LIVE,
  201. MODULE_STATE_COMING,
  202. MODULE_STATE_GOING,
  203. };
  204. struct module
  205. {
  206. enum module_state state;
  207. /* Member of list of modules */
  208. struct list_head list;
  209. /* Unique handle for this module */
  210. char name[MODULE_NAME_LEN];
  211. /* Sysfs stuff. */
  212. struct module_kobject mkobj;
  213. struct module_attribute *modinfo_attrs;
  214. const char *version;
  215. const char *srcversion;
  216. struct kobject *holders_dir;
  217. /* Exported symbols */
  218. const struct kernel_symbol *syms;
  219. const unsigned long *crcs;
  220. unsigned int num_syms;
  221. /* Kernel parameters. */
  222. struct kernel_param *kp;
  223. unsigned int num_kp;
  224. /* GPL-only exported symbols. */
  225. unsigned int num_gpl_syms;
  226. const struct kernel_symbol *gpl_syms;
  227. const unsigned long *gpl_crcs;
  228. #ifdef CONFIG_UNUSED_SYMBOLS
  229. /* unused exported symbols. */
  230. const struct kernel_symbol *unused_syms;
  231. const unsigned long *unused_crcs;
  232. unsigned int num_unused_syms;
  233. /* GPL-only, unused exported symbols. */
  234. unsigned int num_unused_gpl_syms;
  235. const struct kernel_symbol *unused_gpl_syms;
  236. const unsigned long *unused_gpl_crcs;
  237. #endif
  238. /* symbols that will be GPL-only in the near future. */
  239. const struct kernel_symbol *gpl_future_syms;
  240. const unsigned long *gpl_future_crcs;
  241. unsigned int num_gpl_future_syms;
  242. /* Exception table */
  243. unsigned int num_exentries;
  244. struct exception_table_entry *extable;
  245. /* Startup function. */
  246. int (*init)(void);
  247. /* If this is non-NULL, vfree after init() returns */
  248. void *module_init;
  249. /* Here is the actual code + data, vfree'd on unload. */
  250. void *module_core;
  251. /* Here are the sizes of the init and core sections */
  252. unsigned int init_size, core_size;
  253. /* The size of the executable code in each section. */
  254. unsigned int init_text_size, core_text_size;
  255. /* Arch-specific module values */
  256. struct mod_arch_specific arch;
  257. unsigned int taints; /* same bits as kernel:tainted */
  258. #ifdef CONFIG_GENERIC_BUG
  259. /* Support for BUG */
  260. unsigned num_bugs;
  261. struct list_head bug_list;
  262. struct bug_entry *bug_table;
  263. #endif
  264. #ifdef CONFIG_KALLSYMS
  265. /*
  266. * We keep the symbol and string tables for kallsyms.
  267. * The core_* fields below are temporary, loader-only (they
  268. * could really be discarded after module init).
  269. */
  270. Elf_Sym *symtab, *core_symtab;
  271. unsigned int num_symtab, core_num_syms;
  272. char *strtab, *core_strtab;
  273. /* Section attributes */
  274. struct module_sect_attrs *sect_attrs;
  275. /* Notes attributes */
  276. struct module_notes_attrs *notes_attrs;
  277. #endif
  278. #ifdef CONFIG_SMP
  279. /* Per-cpu data. */
  280. void __percpu *percpu;
  281. unsigned int percpu_size;
  282. #endif
  283. /* The command line arguments (may be mangled). People like
  284. keeping pointers to this stuff */
  285. char *args;
  286. #ifdef CONFIG_TRACEPOINTS
  287. struct tracepoint *tracepoints;
  288. unsigned int num_tracepoints;
  289. #endif
  290. #ifdef CONFIG_TRACING
  291. const char **trace_bprintk_fmt_start;
  292. unsigned int num_trace_bprintk_fmt;
  293. #endif
  294. #ifdef CONFIG_EVENT_TRACING
  295. struct ftrace_event_call *trace_events;
  296. unsigned int num_trace_events;
  297. #endif
  298. #ifdef CONFIG_FTRACE_MCOUNT_RECORD
  299. unsigned long *ftrace_callsites;
  300. unsigned int num_ftrace_callsites;
  301. #endif
  302. #ifdef CONFIG_MODULE_UNLOAD
  303. /* What modules depend on me? */
  304. struct list_head source_list;
  305. /* What modules do I depend on? */
  306. struct list_head target_list;
  307. /* Who is waiting for us to be unloaded */
  308. struct task_struct *waiter;
  309. /* Destruction function. */
  310. void (*exit)(void);
  311. struct module_ref {
  312. unsigned int incs;
  313. unsigned int decs;
  314. } __percpu *refptr;
  315. #endif
  316. #ifdef CONFIG_CONSTRUCTORS
  317. /* Constructor functions. */
  318. ctor_fn_t *ctors;
  319. unsigned int num_ctors;
  320. #endif
  321. };
  322. #ifndef MODULE_ARCH_INIT
  323. #define MODULE_ARCH_INIT {}
  324. #endif
  325. extern struct mutex module_mutex;
  326. /* FIXME: It'd be nice to isolate modules during init, too, so they
  327. aren't used before they (may) fail. But presently too much code
  328. (IDE & SCSI) require entry into the module during init.*/
  329. static inline int module_is_live(struct module *mod)
  330. {
  331. return mod->state != MODULE_STATE_GOING;
  332. }
  333. struct module *__module_text_address(unsigned long addr);
  334. struct module *__module_address(unsigned long addr);
  335. bool is_module_address(unsigned long addr);
  336. bool is_module_percpu_address(unsigned long addr);
  337. bool is_module_text_address(unsigned long addr);
  338. static inline int within_module_core(unsigned long addr, struct module *mod)
  339. {
  340. return (unsigned long)mod->module_core <= addr &&
  341. addr < (unsigned long)mod->module_core + mod->core_size;
  342. }
  343. static inline int within_module_init(unsigned long addr, struct module *mod)
  344. {
  345. return (unsigned long)mod->module_init <= addr &&
  346. addr < (unsigned long)mod->module_init + mod->init_size;
  347. }
  348. /* Search for module by name: must hold module_mutex. */
  349. struct module *find_module(const char *name);
  350. struct symsearch {
  351. const struct kernel_symbol *start, *stop;
  352. const unsigned long *crcs;
  353. enum {
  354. NOT_GPL_ONLY,
  355. GPL_ONLY,
  356. WILL_BE_GPL_ONLY,
  357. } licence;
  358. bool unused;
  359. };
  360. /* Search for an exported symbol by name. */
  361. const struct kernel_symbol *find_symbol(const char *name,
  362. struct module **owner,
  363. const unsigned long **crc,
  364. bool gplok,
  365. bool warn);
  366. /* Walk the exported symbol table */
  367. bool each_symbol(bool (*fn)(const struct symsearch *arr, struct module *owner,
  368. unsigned int symnum, void *data), void *data);
  369. /* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
  370. symnum out of range. */
  371. int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
  372. char *name, char *module_name, int *exported);
  373. /* Look for this name: can be of form module:name. */
  374. unsigned long module_kallsyms_lookup_name(const char *name);
  375. int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
  376. struct module *, unsigned long),
  377. void *data);
  378. extern void __module_put_and_exit(struct module *mod, long code)
  379. __attribute__((noreturn));
  380. #define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code);
  381. #ifdef CONFIG_MODULE_UNLOAD
  382. unsigned int module_refcount(struct module *mod);
  383. void __symbol_put(const char *symbol);
  384. #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x)
  385. void symbol_put_addr(void *addr);
  386. /* Sometimes we know we already have a refcount, and it's easier not
  387. to handle the error case (which only happens with rmmod --wait). */
  388. static inline void __module_get(struct module *module)
  389. {
  390. if (module) {
  391. preempt_disable();
  392. __this_cpu_inc(module->refptr->incs);
  393. trace_module_get(module, _THIS_IP_);
  394. preempt_enable();
  395. }
  396. }
  397. static inline int try_module_get(struct module *module)
  398. {
  399. int ret = 1;
  400. if (module) {
  401. preempt_disable();
  402. if (likely(module_is_live(module))) {
  403. __this_cpu_inc(module->refptr->incs);
  404. trace_module_get(module, _THIS_IP_);
  405. } else
  406. ret = 0;
  407. preempt_enable();
  408. }
  409. return ret;
  410. }
  411. extern void module_put(struct module *module);
  412. #else /*!CONFIG_MODULE_UNLOAD*/
  413. static inline int try_module_get(struct module *module)
  414. {
  415. return !module || module_is_live(module);
  416. }
  417. static inline void module_put(struct module *module)
  418. {
  419. }
  420. static inline void __module_get(struct module *module)
  421. {
  422. }
  423. #define symbol_put(x) do { } while(0)
  424. #define symbol_put_addr(p) do { } while(0)
  425. #endif /* CONFIG_MODULE_UNLOAD */
  426. int use_module(struct module *a, struct module *b);
  427. /* This is a #define so the string doesn't get put in every .o file */
  428. #define module_name(mod) \
  429. ({ \
  430. struct module *__mod = (mod); \
  431. __mod ? __mod->name : "kernel"; \
  432. })
  433. /* For kallsyms to ask for address resolution. namebuf should be at
  434. * least KSYM_NAME_LEN long: a pointer to namebuf is returned if
  435. * found, otherwise NULL. */
  436. const char *module_address_lookup(unsigned long addr,
  437. unsigned long *symbolsize,
  438. unsigned long *offset,
  439. char **modname,
  440. char *namebuf);
  441. int lookup_module_symbol_name(unsigned long addr, char *symname);
  442. int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name);
  443. /* For extable.c to search modules' exception tables. */
  444. const struct exception_table_entry *search_module_extables(unsigned long addr);
  445. int register_module_notifier(struct notifier_block * nb);
  446. int unregister_module_notifier(struct notifier_block * nb);
  447. extern void print_modules(void);
  448. extern void module_update_tracepoints(void);
  449. extern int module_get_iter_tracepoints(struct tracepoint_iter *iter);
  450. #else /* !CONFIG_MODULES... */
  451. #define EXPORT_SYMBOL(sym)
  452. #define EXPORT_SYMBOL_GPL(sym)
  453. #define EXPORT_SYMBOL_GPL_FUTURE(sym)
  454. #define EXPORT_UNUSED_SYMBOL(sym)
  455. #define EXPORT_UNUSED_SYMBOL_GPL(sym)
  456. /* Given an address, look for it in the exception tables. */
  457. static inline const struct exception_table_entry *
  458. search_module_extables(unsigned long addr)
  459. {
  460. return NULL;
  461. }
  462. static inline struct module *__module_address(unsigned long addr)
  463. {
  464. return NULL;
  465. }
  466. static inline struct module *__module_text_address(unsigned long addr)
  467. {
  468. return NULL;
  469. }
  470. static inline bool is_module_address(unsigned long addr)
  471. {
  472. return false;
  473. }
  474. static inline bool is_module_percpu_address(unsigned long addr)
  475. {
  476. return false;
  477. }
  478. static inline bool is_module_text_address(unsigned long addr)
  479. {
  480. return false;
  481. }
  482. /* Get/put a kernel symbol (calls should be symmetric) */
  483. #define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); })
  484. #define symbol_put(x) do { } while(0)
  485. #define symbol_put_addr(x) do { } while(0)
  486. static inline void __module_get(struct module *module)
  487. {
  488. }
  489. static inline int try_module_get(struct module *module)
  490. {
  491. return 1;
  492. }
  493. static inline void module_put(struct module *module)
  494. {
  495. }
  496. #define module_name(mod) "kernel"
  497. /* For kallsyms to ask for address resolution. NULL means not found. */
  498. static inline const char *module_address_lookup(unsigned long addr,
  499. unsigned long *symbolsize,
  500. unsigned long *offset,
  501. char **modname,
  502. char *namebuf)
  503. {
  504. return NULL;
  505. }
  506. static inline int lookup_module_symbol_name(unsigned long addr, char *symname)
  507. {
  508. return -ERANGE;
  509. }
  510. static inline int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name)
  511. {
  512. return -ERANGE;
  513. }
  514. static inline int module_get_kallsym(unsigned int symnum, unsigned long *value,
  515. char *type, char *name,
  516. char *module_name, int *exported)
  517. {
  518. return -ERANGE;
  519. }
  520. static inline unsigned long module_kallsyms_lookup_name(const char *name)
  521. {
  522. return 0;
  523. }
  524. static inline int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
  525. struct module *,
  526. unsigned long),
  527. void *data)
  528. {
  529. return 0;
  530. }
  531. static inline int register_module_notifier(struct notifier_block * nb)
  532. {
  533. /* no events will happen anyway, so this can always succeed */
  534. return 0;
  535. }
  536. static inline int unregister_module_notifier(struct notifier_block * nb)
  537. {
  538. return 0;
  539. }
  540. #define module_put_and_exit(code) do_exit(code)
  541. static inline void print_modules(void)
  542. {
  543. }
  544. static inline void module_update_tracepoints(void)
  545. {
  546. }
  547. static inline int module_get_iter_tracepoints(struct tracepoint_iter *iter)
  548. {
  549. return 0;
  550. }
  551. #endif /* CONFIG_MODULES */
  552. struct device_driver;
  553. #ifdef CONFIG_SYSFS
  554. struct module;
  555. extern struct kset *module_kset;
  556. extern struct kobj_type module_ktype;
  557. extern int module_sysfs_initialized;
  558. int mod_sysfs_init(struct module *mod);
  559. int mod_sysfs_setup(struct module *mod,
  560. struct kernel_param *kparam,
  561. unsigned int num_params);
  562. int module_add_modinfo_attrs(struct module *mod);
  563. void module_remove_modinfo_attrs(struct module *mod);
  564. #else /* !CONFIG_SYSFS */
  565. static inline int mod_sysfs_init(struct module *mod)
  566. {
  567. return 0;
  568. }
  569. static inline int mod_sysfs_setup(struct module *mod,
  570. struct kernel_param *kparam,
  571. unsigned int num_params)
  572. {
  573. return 0;
  574. }
  575. static inline int module_add_modinfo_attrs(struct module *mod)
  576. {
  577. return 0;
  578. }
  579. static inline void module_remove_modinfo_attrs(struct module *mod)
  580. { }
  581. #endif /* CONFIG_SYSFS */
  582. #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
  583. /* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */
  584. #define __MODULE_STRING(x) __stringify(x)
  585. #ifdef CONFIG_GENERIC_BUG
  586. int module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *,
  587. struct module *);
  588. void module_bug_cleanup(struct module *);
  589. #else /* !CONFIG_GENERIC_BUG */
  590. static inline int module_bug_finalize(const Elf_Ehdr *hdr,
  591. const Elf_Shdr *sechdrs,
  592. struct module *mod)
  593. {
  594. return 0;
  595. }
  596. static inline void module_bug_cleanup(struct module *mod) {}
  597. #endif /* CONFIG_GENERIC_BUG */
  598. #endif /* _LINUX_MODULE_H */