module.h 19 KB

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