module.h 19 KB

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