diff options
Diffstat (limited to 'kernel/module.c')
-rw-r--r-- | kernel/module.c | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/kernel/module.c b/kernel/module.c index d03fcd9d652c..dc4d3f5ce820 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -2501,93 +2501,6 @@ void print_modules(void) | |||
2501 | printk("\n"); | 2501 | printk("\n"); |
2502 | } | 2502 | } |
2503 | 2503 | ||
2504 | #ifdef CONFIG_SYSFS | ||
2505 | static char *make_driver_name(struct device_driver *drv) | ||
2506 | { | ||
2507 | char *driver_name; | ||
2508 | |||
2509 | driver_name = kmalloc(strlen(drv->name) + strlen(drv->bus->name) + 2, | ||
2510 | GFP_KERNEL); | ||
2511 | if (!driver_name) | ||
2512 | return NULL; | ||
2513 | |||
2514 | sprintf(driver_name, "%s:%s", drv->bus->name, drv->name); | ||
2515 | return driver_name; | ||
2516 | } | ||
2517 | |||
2518 | static void module_create_drivers_dir(struct module_kobject *mk) | ||
2519 | { | ||
2520 | if (!mk || mk->drivers_dir) | ||
2521 | return; | ||
2522 | |||
2523 | mk->drivers_dir = kobject_create_and_add("drivers", &mk->kobj); | ||
2524 | } | ||
2525 | |||
2526 | void module_add_driver(struct module *mod, struct device_driver *drv) | ||
2527 | { | ||
2528 | char *driver_name; | ||
2529 | int no_warn; | ||
2530 | struct module_kobject *mk = NULL; | ||
2531 | |||
2532 | if (!drv) | ||
2533 | return; | ||
2534 | |||
2535 | if (mod) | ||
2536 | mk = &mod->mkobj; | ||
2537 | else if (drv->mod_name) { | ||
2538 | struct kobject *mkobj; | ||
2539 | |||
2540 | /* Lookup built-in module entry in /sys/modules */ | ||
2541 | mkobj = kset_find_obj(module_kset, drv->mod_name); | ||
2542 | if (mkobj) { | ||
2543 | mk = container_of(mkobj, struct module_kobject, kobj); | ||
2544 | /* remember our module structure */ | ||
2545 | drv->mkobj = mk; | ||
2546 | /* kset_find_obj took a reference */ | ||
2547 | kobject_put(mkobj); | ||
2548 | } | ||
2549 | } | ||
2550 | |||
2551 | if (!mk) | ||
2552 | return; | ||
2553 | |||
2554 | /* Don't check return codes; these calls are idempotent */ | ||
2555 | no_warn = sysfs_create_link(&drv->kobj, &mk->kobj, "module"); | ||
2556 | driver_name = make_driver_name(drv); | ||
2557 | if (driver_name) { | ||
2558 | module_create_drivers_dir(mk); | ||
2559 | no_warn = sysfs_create_link(mk->drivers_dir, &drv->kobj, | ||
2560 | driver_name); | ||
2561 | kfree(driver_name); | ||
2562 | } | ||
2563 | } | ||
2564 | EXPORT_SYMBOL(module_add_driver); | ||
2565 | |||
2566 | void module_remove_driver(struct device_driver *drv) | ||
2567 | { | ||
2568 | struct module_kobject *mk = NULL; | ||
2569 | char *driver_name; | ||
2570 | |||
2571 | if (!drv) | ||
2572 | return; | ||
2573 | |||
2574 | sysfs_remove_link(&drv->kobj, "module"); | ||
2575 | |||
2576 | if (drv->owner) | ||
2577 | mk = &drv->owner->mkobj; | ||
2578 | else if (drv->mkobj) | ||
2579 | mk = drv->mkobj; | ||
2580 | if (mk && mk->drivers_dir) { | ||
2581 | driver_name = make_driver_name(drv); | ||
2582 | if (driver_name) { | ||
2583 | sysfs_remove_link(mk->drivers_dir, driver_name); | ||
2584 | kfree(driver_name); | ||
2585 | } | ||
2586 | } | ||
2587 | } | ||
2588 | EXPORT_SYMBOL(module_remove_driver); | ||
2589 | #endif | ||
2590 | |||
2591 | #ifdef CONFIG_MODVERSIONS | 2504 | #ifdef CONFIG_MODVERSIONS |
2592 | /* Generate the signature for struct module here, too, for modversions. */ | 2505 | /* Generate the signature for struct module here, too, for modversions. */ |
2593 | void struct_module(struct module *mod) { return; } | 2506 | void struct_module(struct module *mod) { return; } |