diff options
| author | Takashi Iwai <tiwai@suse.de> | 2009-05-04 10:00:16 -0400 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2009-05-04 10:00:16 -0400 |
| commit | 3a20ac2c52b1317f5a5f0bd9cd3cbe8495ddd026 (patch) | |
| tree | 9a912f2609cefb9698b5cce09cd240bd6dbd09fb /include/linux/module.h | |
| parent | 18cc8d8d9b74c446832336d8f6e1afb145f9431b (diff) | |
| parent | 3e5b50165fd0be080044586f43fcdd460ed27610 (diff) | |
Merge branch 'fix/pcm-jiffies-check' into fix/asoc
Diffstat (limited to 'include/linux/module.h')
| -rw-r--r-- | include/linux/module.h | 94 |
1 files changed, 76 insertions, 18 deletions
diff --git a/include/linux/module.h b/include/linux/module.h index 4f7ea12463d3..627ac082e2a6 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
| @@ -219,11 +219,6 @@ void *__symbol_get_gpl(const char *symbol); | |||
| 219 | 219 | ||
| 220 | #endif | 220 | #endif |
| 221 | 221 | ||
| 222 | struct module_ref | ||
| 223 | { | ||
| 224 | local_t count; | ||
| 225 | } ____cacheline_aligned; | ||
| 226 | |||
| 227 | enum module_state | 222 | enum module_state |
| 228 | { | 223 | { |
| 229 | MODULE_STATE_LIVE, | 224 | MODULE_STATE_LIVE, |
| @@ -253,6 +248,10 @@ struct module | |||
| 253 | const unsigned long *crcs; | 248 | const unsigned long *crcs; |
| 254 | unsigned int num_syms; | 249 | unsigned int num_syms; |
| 255 | 250 | ||
| 251 | /* Kernel parameters. */ | ||
| 252 | struct kernel_param *kp; | ||
| 253 | unsigned int num_kp; | ||
| 254 | |||
| 256 | /* GPL-only exported symbols. */ | 255 | /* GPL-only exported symbols. */ |
| 257 | unsigned int num_gpl_syms; | 256 | unsigned int num_gpl_syms; |
| 258 | const struct kernel_symbol *gpl_syms; | 257 | const struct kernel_symbol *gpl_syms; |
| @@ -334,6 +333,11 @@ struct module | |||
| 334 | unsigned int num_tracepoints; | 333 | unsigned int num_tracepoints; |
| 335 | #endif | 334 | #endif |
| 336 | 335 | ||
| 336 | #ifdef CONFIG_TRACING | ||
| 337 | const char **trace_bprintk_fmt_start; | ||
| 338 | unsigned int num_trace_bprintk_fmt; | ||
| 339 | #endif | ||
| 340 | |||
| 337 | #ifdef CONFIG_MODULE_UNLOAD | 341 | #ifdef CONFIG_MODULE_UNLOAD |
| 338 | /* What modules depend on me? */ | 342 | /* What modules depend on me? */ |
| 339 | struct list_head modules_which_use_me; | 343 | struct list_head modules_which_use_me; |
| @@ -344,14 +348,19 @@ struct module | |||
| 344 | /* Destruction function. */ | 348 | /* Destruction function. */ |
| 345 | void (*exit)(void); | 349 | void (*exit)(void); |
| 346 | 350 | ||
| 347 | /* Reference counts */ | 351 | #ifdef CONFIG_SMP |
| 348 | struct module_ref ref[NR_CPUS]; | 352 | char *refptr; |
| 353 | #else | ||
| 354 | local_t ref; | ||
| 355 | #endif | ||
| 349 | #endif | 356 | #endif |
| 350 | }; | 357 | }; |
| 351 | #ifndef MODULE_ARCH_INIT | 358 | #ifndef MODULE_ARCH_INIT |
| 352 | #define MODULE_ARCH_INIT {} | 359 | #define MODULE_ARCH_INIT {} |
| 353 | #endif | 360 | #endif |
| 354 | 361 | ||
| 362 | extern struct mutex module_mutex; | ||
| 363 | |||
| 355 | /* FIXME: It'd be nice to isolate modules during init, too, so they | 364 | /* FIXME: It'd be nice to isolate modules during init, too, so they |
| 356 | aren't used before they (may) fail. But presently too much code | 365 | aren't used before they (may) fail. But presently too much code |
| 357 | (IDE & SCSI) require entry into the module during init.*/ | 366 | (IDE & SCSI) require entry into the module during init.*/ |
| @@ -360,10 +369,10 @@ static inline int module_is_live(struct module *mod) | |||
| 360 | return mod->state != MODULE_STATE_GOING; | 369 | return mod->state != MODULE_STATE_GOING; |
| 361 | } | 370 | } |
| 362 | 371 | ||
| 363 | /* Is this address in a module? (second is with no locks, for oops) */ | ||
| 364 | struct module *module_text_address(unsigned long addr); | ||
| 365 | struct module *__module_text_address(unsigned long addr); | 372 | struct module *__module_text_address(unsigned long addr); |
| 366 | int is_module_address(unsigned long addr); | 373 | struct module *__module_address(unsigned long addr); |
| 374 | bool is_module_address(unsigned long addr); | ||
| 375 | bool is_module_text_address(unsigned long addr); | ||
| 367 | 376 | ||
| 368 | static inline int within_module_core(unsigned long addr, struct module *mod) | 377 | static inline int within_module_core(unsigned long addr, struct module *mod) |
| 369 | { | 378 | { |
| @@ -377,6 +386,31 @@ static inline int within_module_init(unsigned long addr, struct module *mod) | |||
| 377 | addr < (unsigned long)mod->module_init + mod->init_size; | 386 | addr < (unsigned long)mod->module_init + mod->init_size; |
| 378 | } | 387 | } |
| 379 | 388 | ||
| 389 | /* Search for module by name: must hold module_mutex. */ | ||
| 390 | struct module *find_module(const char *name); | ||
| 391 | |||
| 392 | struct symsearch { | ||
| 393 | const struct kernel_symbol *start, *stop; | ||
| 394 | const unsigned long *crcs; | ||
| 395 | enum { | ||
| 396 | NOT_GPL_ONLY, | ||
| 397 | GPL_ONLY, | ||
| 398 | WILL_BE_GPL_ONLY, | ||
| 399 | } licence; | ||
| 400 | bool unused; | ||
| 401 | }; | ||
| 402 | |||
| 403 | /* Search for an exported symbol by name. */ | ||
| 404 | const struct kernel_symbol *find_symbol(const char *name, | ||
| 405 | struct module **owner, | ||
| 406 | const unsigned long **crc, | ||
| 407 | bool gplok, | ||
| 408 | bool warn); | ||
| 409 | |||
| 410 | /* Walk the exported symbol table */ | ||
| 411 | bool each_symbol(bool (*fn)(const struct symsearch *arr, struct module *owner, | ||
| 412 | unsigned int symnum, void *data), void *data); | ||
| 413 | |||
| 380 | /* Returns 0 and fills in value, defined and namebuf, or -ERANGE if | 414 | /* Returns 0 and fills in value, defined and namebuf, or -ERANGE if |
| 381 | symnum out of range. */ | 415 | symnum out of range. */ |
| 382 | int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, | 416 | int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, |
| @@ -385,6 +419,10 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, | |||
| 385 | /* Look for this name: can be of form module:name. */ | 419 | /* Look for this name: can be of form module:name. */ |
| 386 | unsigned long module_kallsyms_lookup_name(const char *name); | 420 | unsigned long module_kallsyms_lookup_name(const char *name); |
| 387 | 421 | ||
| 422 | int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, | ||
| 423 | struct module *, unsigned long), | ||
| 424 | void *data); | ||
| 425 | |||
| 388 | extern void __module_put_and_exit(struct module *mod, long code) | 426 | extern void __module_put_and_exit(struct module *mod, long code) |
| 389 | __attribute__((noreturn)); | 427 | __attribute__((noreturn)); |
| 390 | #define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code); | 428 | #define module_put_and_exit(code) __module_put_and_exit(THIS_MODULE, code); |
| @@ -395,13 +433,21 @@ void __symbol_put(const char *symbol); | |||
| 395 | #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x) | 433 | #define symbol_put(x) __symbol_put(MODULE_SYMBOL_PREFIX #x) |
| 396 | void symbol_put_addr(void *addr); | 434 | void symbol_put_addr(void *addr); |
| 397 | 435 | ||
| 436 | static inline local_t *__module_ref_addr(struct module *mod, int cpu) | ||
| 437 | { | ||
| 438 | #ifdef CONFIG_SMP | ||
| 439 | return (local_t *) (mod->refptr + per_cpu_offset(cpu)); | ||
| 440 | #else | ||
| 441 | return &mod->ref; | ||
| 442 | #endif | ||
| 443 | } | ||
| 444 | |||
| 398 | /* Sometimes we know we already have a refcount, and it's easier not | 445 | /* Sometimes we know we already have a refcount, and it's easier not |
| 399 | to handle the error case (which only happens with rmmod --wait). */ | 446 | to handle the error case (which only happens with rmmod --wait). */ |
| 400 | static inline void __module_get(struct module *module) | 447 | static inline void __module_get(struct module *module) |
| 401 | { | 448 | { |
| 402 | if (module) { | 449 | if (module) { |
| 403 | BUG_ON(module_refcount(module) == 0); | 450 | local_inc(__module_ref_addr(module, get_cpu())); |
| 404 | local_inc(&module->ref[get_cpu()].count); | ||
| 405 | put_cpu(); | 451 | put_cpu(); |
| 406 | } | 452 | } |
| 407 | } | 453 | } |
| @@ -413,7 +459,7 @@ static inline int try_module_get(struct module *module) | |||
| 413 | if (module) { | 459 | if (module) { |
| 414 | unsigned int cpu = get_cpu(); | 460 | unsigned int cpu = get_cpu(); |
| 415 | if (likely(module_is_live(module))) | 461 | if (likely(module_is_live(module))) |
| 416 | local_inc(&module->ref[cpu].count); | 462 | local_inc(__module_ref_addr(module, cpu)); |
| 417 | else | 463 | else |
| 418 | ret = 0; | 464 | ret = 0; |
| 419 | put_cpu(); | 465 | put_cpu(); |
| @@ -438,6 +484,7 @@ static inline void __module_get(struct module *module) | |||
| 438 | #define symbol_put_addr(p) do { } while(0) | 484 | #define symbol_put_addr(p) do { } while(0) |
| 439 | 485 | ||
| 440 | #endif /* CONFIG_MODULE_UNLOAD */ | 486 | #endif /* CONFIG_MODULE_UNLOAD */ |
| 487 | int use_module(struct module *a, struct module *b); | ||
| 441 | 488 | ||
| 442 | /* This is a #define so the string doesn't get put in every .o file */ | 489 | /* This is a #define so the string doesn't get put in every .o file */ |
| 443 | #define module_name(mod) \ | 490 | #define module_name(mod) \ |
| @@ -484,21 +531,24 @@ search_module_extables(unsigned long addr) | |||
| 484 | return NULL; | 531 | return NULL; |
| 485 | } | 532 | } |
| 486 | 533 | ||
| 487 | /* Is this address in a module? */ | 534 | static inline struct module *__module_address(unsigned long addr) |
| 488 | static inline struct module *module_text_address(unsigned long addr) | ||
| 489 | { | 535 | { |
| 490 | return NULL; | 536 | return NULL; |
| 491 | } | 537 | } |
| 492 | 538 | ||
| 493 | /* Is this address in a module? (don't take a lock, we're oopsing) */ | ||
| 494 | static inline struct module *__module_text_address(unsigned long addr) | 539 | static inline struct module *__module_text_address(unsigned long addr) |
| 495 | { | 540 | { |
| 496 | return NULL; | 541 | return NULL; |
| 497 | } | 542 | } |
| 498 | 543 | ||
| 499 | static inline int is_module_address(unsigned long addr) | 544 | static inline bool is_module_address(unsigned long addr) |
| 500 | { | 545 | { |
| 501 | return 0; | 546 | return false; |
| 547 | } | ||
| 548 | |||
| 549 | static inline bool is_module_text_address(unsigned long addr) | ||
| 550 | { | ||
| 551 | return false; | ||
| 502 | } | 552 | } |
| 503 | 553 | ||
| 504 | /* Get/put a kernel symbol (calls should be symmetric) */ | 554 | /* Get/put a kernel symbol (calls should be symmetric) */ |
| @@ -553,6 +603,14 @@ static inline unsigned long module_kallsyms_lookup_name(const char *name) | |||
| 553 | return 0; | 603 | return 0; |
| 554 | } | 604 | } |
| 555 | 605 | ||
| 606 | static inline int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, | ||
| 607 | struct module *, | ||
| 608 | unsigned long), | ||
| 609 | void *data) | ||
| 610 | { | ||
| 611 | return 0; | ||
| 612 | } | ||
| 613 | |||
| 556 | static inline int register_module_notifier(struct notifier_block * nb) | 614 | static inline int register_module_notifier(struct notifier_block * nb) |
| 557 | { | 615 | { |
| 558 | /* no events will happen anyway, so this can always succeed */ | 616 | /* no events will happen anyway, so this can always succeed */ |
