module.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  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 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. /* Get/put a kernel symbol (calls must be symmetric) */
  150. void *__symbol_get(const char *symbol);
  151. void *__symbol_get_gpl(const char *symbol);
  152. #define symbol_get(x) ((typeof(&x))(__symbol_get(MODULE_SYMBOL_PREFIX #x)))
  153. #ifndef __GENKSYMS__
  154. #ifdef CONFIG_MODVERSIONS
  155. /* Mark the CRC weak since genksyms apparently decides not to
  156. * generate a checksums for some symbols */
  157. #define __CRC_SYMBOL(sym, sec) \
  158. extern void *__crc_##sym __attribute__((weak)); \
  159. static const unsigned long __kcrctab_##sym \
  160. __used \
  161. __attribute__((section("__kcrctab" sec), unused)) \
  162. = (unsigned long) &__crc_##sym;
  163. #else
  164. #define __CRC_SYMBOL(sym, sec)
  165. #endif
  166. /* For every exported symbol, place a struct in the __ksymtab section */
  167. #define __EXPORT_SYMBOL(sym, sec) \
  168. extern typeof(sym) sym; \
  169. __CRC_SYMBOL(sym, sec) \
  170. static const char __kstrtab_##sym[] \
  171. __attribute__((section("__ksymtab_strings"), aligned(1))) \
  172. = MODULE_SYMBOL_PREFIX #sym; \
  173. static const struct kernel_symbol __ksymtab_##sym \
  174. __used \
  175. __attribute__((section("__ksymtab" sec), unused)) \
  176. = { (unsigned long)&sym, __kstrtab_##sym }
  177. #define EXPORT_SYMBOL(sym) \
  178. __EXPORT_SYMBOL(sym, "")
  179. #define EXPORT_SYMBOL_GPL(sym) \
  180. __EXPORT_SYMBOL(sym, "_gpl")
  181. #define EXPORT_SYMBOL_GPL_FUTURE(sym) \
  182. __EXPORT_SYMBOL(sym, "_gpl_future")
  183. #ifdef CONFIG_UNUSED_SYMBOLS
  184. #define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused")
  185. #define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl")
  186. #else
  187. #define EXPORT_UNUSED_SYMBOL(sym)
  188. #define EXPORT_UNUSED_SYMBOL_GPL(sym)
  189. #endif
  190. #endif
  191. enum module_state
  192. {
  193. MODULE_STATE_LIVE,
  194. MODULE_STATE_COMING,
  195. MODULE_STATE_GOING,
  196. };
  197. struct module
  198. {
  199. enum module_state state;
  200. /* Member of list of modules */
  201. struct list_head list;
  202. /* Unique handle for this module */
  203. char name[MODULE_NAME_LEN];
  204. /* Sysfs stuff. */
  205. struct module_kobject mkobj;
  206. struct module_attribute *modinfo_attrs;
  207. const char *version;
  208. const char *srcversion;
  209. struct kobject *holders_dir;
  210. /* Exported symbols */
  211. const struct kernel_symbol *syms;
  212. const unsigned long *crcs;
  213. unsigned int num_syms;
  214. /* Kernel parameters. */
  215. struct kernel_param *kp;
  216. unsigned int num_kp;
  217. /* GPL-only exported symbols. */
  218. unsigned int num_gpl_syms;
  219. const struct kernel_symbol *gpl_syms;
  220. const unsigned long *gpl_crcs;
  221. #ifdef CONFIG_UNUSED_SYMBOLS
  222. /* unused exported symbols. */
  223. const struct kernel_symbol *unused_syms;
  224. const unsigned long *unused_crcs;
  225. unsigned int num_unused_syms;
  226. /* GPL-only, unused exported symbols. */
  227. unsigned int num_unused_gpl_syms;
  228. const struct kernel_symbol *unused_gpl_syms;
  229. const unsigned long *unused_gpl_crcs;
  230. #endif
  231. /* symbols that will be GPL-only in the near future. */
  232. const struct kernel_symbol *gpl_future_syms;
  233. const unsigned long *gpl_future_crcs;
  234. unsigned int num_gpl_future_syms;
  235. /* Exception table */
  236. unsigned int num_exentries;
  237. struct exception_table_entry *extable;
  238. /* Startup function. */
  239. int (*init)(void);
  240. /* If this is non-NULL, vfree after init() returns */
  241. void *module_init;
  242. /* Here is the actual code + data, vfree'd on unload. */
  243. void *module_core;
  244. /* Here are the sizes of the init and core sections */
  245. unsigned int init_size, core_size;
  246. /* The size of the executable code in each section. */
  247. unsigned int init_text_size, core_text_size;
  248. /* Arch-specific module values */
  249. struct mod_arch_specific arch;
  250. unsigned int taints; /* same bits as kernel:tainted */
  251. #ifdef CONFIG_GENERIC_BUG
  252. /* Support for BUG */
  253. unsigned num_bugs;
  254. struct list_head bug_list;
  255. struct bug_entry *bug_table;
  256. #endif
  257. #ifdef CONFIG_KALLSYMS
  258. /*
  259. * We keep the symbol and string tables for kallsyms.
  260. * The core_* fields below are temporary, loader-only (they
  261. * could really be discarded after module init).
  262. */
  263. Elf_Sym *symtab, *core_symtab;
  264. unsigned int num_symtab, core_num_syms;
  265. char *strtab, *core_strtab;
  266. /* Section attributes */
  267. struct module_sect_attrs *sect_attrs;
  268. /* Notes attributes */
  269. struct module_notes_attrs *notes_attrs;
  270. #endif
  271. /* Per-cpu data. */
  272. void *percpu;
  273. /* The command line arguments (may be mangled). People like
  274. keeping pointers to this stuff */
  275. char *args;
  276. #ifdef CONFIG_TRACEPOINTS
  277. struct tracepoint *tracepoints;
  278. unsigned int num_tracepoints;
  279. #endif
  280. #ifdef CONFIG_TRACING
  281. const char **trace_bprintk_fmt_start;
  282. unsigned int num_trace_bprintk_fmt;
  283. #endif
  284. #ifdef CONFIG_EVENT_TRACING
  285. struct ftrace_event_call *trace_events;
  286. unsigned int num_trace_events;
  287. #endif
  288. #ifdef CONFIG_FTRACE_MCOUNT_RECORD
  289. unsigned long *ftrace_callsites;
  290. unsigned int num_ftrace_callsites;
  291. #endif
  292. #ifdef CONFIG_MODULE_UNLOAD
  293. /* What modules depend on me? */
  294. struct list_head modules_which_use_me;
  295. /* Who is waiting for us to be unloaded */
  296. struct task_struct *waiter;
  297. /* Destruction function. */
  298. void (*exit)(void);
  299. #ifdef CONFIG_SMP
  300. char *refptr;
  301. #else
  302. local_t ref;
  303. #endif
  304. #endif
  305. #ifdef CONFIG_CONSTRUCTORS
  306. /* Constructor functions. */
  307. ctor_fn_t *ctors;
  308. unsigned int num_ctors;
  309. #endif
  310. };
  311. #ifndef MODULE_ARCH_INIT
  312. #define MODULE_ARCH_INIT {}
  313. #endif
  314. extern struct mutex module_mutex;
  315. /* FIXME: It'd be nice to isolate modules during init, too, so they
  316. aren't used before they (may) fail. But presently too much code
  317. (IDE & SCSI) require entry into the module during init.*/
  318. static inline int module_is_live(struct module *mod)
  319. {
  320. return mod->state != MODULE_STATE_GOING;
  321. }
  322. struct module *__module_text_address(unsigned long addr);
  323. struct module *__module_address(unsigned long addr);
  324. bool is_module_address(unsigned long addr);
  325. bool is_module_text_address(unsigned long addr);
  326. static inline int within_module_core(unsigned long addr, struct module *mod)
  327. {
  328. return (unsigned long)mod->module_core <= addr &&
  329. addr < (unsigned long)mod->module_core + mod->core_size;
  330. }
  331. static inline int within_module_init(unsigned long addr, struct module *mod)
  332. {
  333. return (unsigned long)mod->module_init <= addr &&
  334. addr < (unsigned long)mod->module_init + mod->init_size;
  335. }
  336. /* Search for module by name: must hold module_mutex. */
  337. struct module *find_module(const char *name);
  338. struct symsearch {
  339. const struct kernel_symbol *start, *stop;
  340. const unsigned long *crcs;
  341. enum {
  342. NOT_GPL_ONLY,
  343. GPL_ONLY,
  344. WILL_BE_GPL_ONLY,
  345. } licence;
  346. bool unused;
  347. };
  348. /* Search for an exported symbol by name. */
  349. const struct kernel_symbol *find_symbol(const char *name,
  350. struct module **owner,
  351. const unsigned long **crc,
  352. bool gplok,
  353. bool warn);
  354. /* Walk the exported symbol table */
  355. bool each_symbol(bool (*fn)(const struct symsearch *arr, struct module *owner,
  356. unsigned int symnum, void *data), void *data);
  357. /* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
  358. symnum out of range. */
  359. int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
  360. char *name, char *module_name, int *exported);
  361. /* Look for this name: can be of form module:name. */
  362. unsigned long module_kallsyms_lookup_name(const char *name);
  363. int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
  364. struct module *, unsigned long),
  365. void *data);
  366. extern void __module_put_and_exit(struct module *mod, long code)
  367. __attribute__((noreturn));
  368. #define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code);
  369. #ifdef CONFIG_MODULE_UNLOAD
  370. unsigned int module_refcount(struct module *mod);
  371. void __symbol_put(const char *symbol);
  372. #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x)
  373. void symbol_put_addr(void *addr);
  374. static inline local_t *__module_ref_addr(struct module *mod, int cpu)
  375. {
  376. #ifdef CONFIG_SMP
  377. return (local_t *) (mod->refptr + per_cpu_offset(cpu));
  378. #else
  379. return &mod->ref;
  380. #endif
  381. }
  382. /* Sometimes we know we already have a refcount, and it's easier not
  383. to handle the error case (which only happens with rmmod --wait). */
  384. static inline void __module_get(struct module *module)
  385. {
  386. if (module) {
  387. unsigned int cpu = get_cpu();
  388. local_inc(__module_ref_addr(module, cpu));
  389. trace_module_get(module, _THIS_IP_,
  390. local_read(__module_ref_addr(module, cpu)));
  391. put_cpu();
  392. }
  393. }
  394. static inline int try_module_get(struct module *module)
  395. {
  396. int ret = 1;
  397. if (module) {
  398. unsigned int cpu = get_cpu();
  399. if (likely(module_is_live(module))) {
  400. local_inc(__module_ref_addr(module, cpu));
  401. trace_module_get(module, _THIS_IP_,
  402. local_read(__module_ref_addr(module, cpu)));
  403. }
  404. else
  405. ret = 0;
  406. put_cpu();
  407. }
  408. return ret;
  409. }
  410. extern void module_put(struct module *module);
  411. #else /*!CONFIG_MODULE_UNLOAD*/
  412. static inline int try_module_get(struct module *module)
  413. {
  414. return !module || module_is_live(module);
  415. }
  416. static inline void module_put(struct module *module)
  417. {
  418. }
  419. static inline void __module_get(struct module *module)
  420. {
  421. }
  422. #define symbol_put(x) do { } while(0)
  423. #define symbol_put_addr(p) do { } while(0)
  424. #endif /* CONFIG_MODULE_UNLOAD */
  425. int use_module(struct module *a, struct module *b);
  426. /* This is a #define so the string doesn't get put in every .o file */
  427. #define module_name(mod) \
  428. ({ \
  429. struct module *__mod = (mod); \
  430. __mod ? __mod->name : "kernel"; \
  431. })
  432. /* For kallsyms to ask for address resolution. namebuf should be at
  433. * least KSYM_NAME_LEN long: a pointer to namebuf is returned if
  434. * found, otherwise NULL. */
  435. const char *module_address_lookup(unsigned long addr,
  436. unsigned long *symbolsize,
  437. unsigned long *offset,
  438. char **modname,
  439. char *namebuf);
  440. int lookup_module_symbol_name(unsigned long addr, char *symname);
  441. int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name);
  442. /* For extable.c to search modules' exception tables. */
  443. const struct exception_table_entry *search_module_extables(unsigned long addr);
  444. int register_module_notifier(struct notifier_block * nb);
  445. int unregister_module_notifier(struct notifier_block * nb);
  446. extern void print_modules(void);
  447. extern void module_update_tracepoints(void);
  448. extern int module_get_iter_tracepoints(struct tracepoint_iter *iter);
  449. #else /* !CONFIG_MODULES... */
  450. #define EXPORT_SYMBOL(sym)
  451. #define EXPORT_SYMBOL_GPL(sym)
  452. #define EXPORT_SYMBOL_GPL_FUTURE(sym)
  453. #define EXPORT_UNUSED_SYMBOL(sym)
  454. #define EXPORT_UNUSED_SYMBOL_GPL(sym)
  455. /* Given an address, look for it in the exception tables. */
  456. static inline const struct exception_table_entry *
  457. search_module_extables(unsigned long addr)
  458. {
  459. return NULL;
  460. }
  461. static inline struct module *__module_address(unsigned long addr)
  462. {
  463. return NULL;
  464. }
  465. static inline struct module *__module_text_address(unsigned long addr)
  466. {
  467. return NULL;
  468. }
  469. static inline bool is_module_address(unsigned long addr)
  470. {
  471. return false;
  472. }
  473. static inline bool is_module_text_address(unsigned long addr)
  474. {
  475. return false;
  476. }
  477. /* Get/put a kernel symbol (calls should be symmetric) */
  478. #define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); })
  479. #define symbol_put(x) do { } while(0)
  480. #define symbol_put_addr(x) do { } while(0)
  481. static inline void __module_get(struct module *module)
  482. {
  483. }
  484. static inline int try_module_get(struct module *module)
  485. {
  486. return 1;
  487. }
  488. static inline void module_put(struct module *module)
  489. {
  490. }
  491. #define module_name(mod) "kernel"
  492. /* For kallsyms to ask for address resolution. NULL means not found. */
  493. static inline const char *module_address_lookup(unsigned long addr,
  494. unsigned long *symbolsize,
  495. unsigned long *offset,
  496. char **modname,
  497. char *namebuf)
  498. {
  499. return NULL;
  500. }
  501. static inline int lookup_module_symbol_name(unsigned long addr, char *symname)
  502. {
  503. return -ERANGE;
  504. }
  505. static inline int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name)
  506. {
  507. return -ERANGE;
  508. }
  509. static inline int module_get_kallsym(unsigned int symnum, unsigned long *value,
  510. char *type, char *name,
  511. char *module_name, int *exported)
  512. {
  513. return -ERANGE;
  514. }
  515. static inline unsigned long module_kallsyms_lookup_name(const char *name)
  516. {
  517. return 0;
  518. }
  519. static inline int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
  520. struct module *,
  521. unsigned long),
  522. void *data)
  523. {
  524. return 0;
  525. }
  526. static inline int register_module_notifier(struct notifier_block * nb)
  527. {
  528. /* no events will happen anyway, so this can always succeed */
  529. return 0;
  530. }
  531. static inline int unregister_module_notifier(struct notifier_block * nb)
  532. {
  533. return 0;
  534. }
  535. #define module_put_and_exit(code) do_exit(code)
  536. static inline void print_modules(void)
  537. {
  538. }
  539. static inline void module_update_tracepoints(void)
  540. {
  541. }
  542. static inline int module_get_iter_tracepoints(struct tracepoint_iter *iter)
  543. {
  544. return 0;
  545. }
  546. #endif /* CONFIG_MODULES */
  547. struct device_driver;
  548. #ifdef CONFIG_SYSFS
  549. struct module;
  550. extern struct kset *module_kset;
  551. extern struct kobj_type module_ktype;
  552. extern int module_sysfs_initialized;
  553. int mod_sysfs_init(struct module *mod);
  554. int mod_sysfs_setup(struct module *mod,
  555. struct kernel_param *kparam,
  556. unsigned int num_params);
  557. int module_add_modinfo_attrs(struct module *mod);
  558. void module_remove_modinfo_attrs(struct module *mod);
  559. #else /* !CONFIG_SYSFS */
  560. static inline int mod_sysfs_init(struct module *mod)
  561. {
  562. return 0;
  563. }
  564. static inline int mod_sysfs_setup(struct module *mod,
  565. struct kernel_param *kparam,
  566. unsigned int num_params)
  567. {
  568. return 0;
  569. }
  570. static inline int module_add_modinfo_attrs(struct module *mod)
  571. {
  572. return 0;
  573. }
  574. static inline void module_remove_modinfo_attrs(struct module *mod)
  575. { }
  576. #endif /* CONFIG_SYSFS */
  577. #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
  578. /* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */
  579. #define __MODULE_STRING(x) __stringify(x)
  580. #ifdef CONFIG_GENERIC_BUG
  581. int module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *,
  582. struct module *);
  583. void module_bug_cleanup(struct module *);
  584. #else /* !CONFIG_GENERIC_BUG */
  585. static inline int module_bug_finalize(const Elf_Ehdr *hdr,
  586. const Elf_Shdr *sechdrs,
  587. struct module *mod)
  588. {
  589. return 0;
  590. }
  591. static inline void module_bug_cleanup(struct module *mod) {}
  592. #endif /* CONFIG_GENERIC_BUG */
  593. #endif /* _LINUX_MODULE_H */