module.h 19 KB

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