system/core
Revision | 11c6ac28c34f548ff57f0a3407e0b32170b4c3c9 (tree) |
---|---|
Time | 2013-07-25 17:05:39 |
Author | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
ueventd: load modules in a forked process
Loading some modules (e.g., ath3k) will be blocked to wait for
firmware. The forking is necessary, otherwise ueventd has no
chance to load the firmware.
@@ -720,14 +720,12 @@ out: | ||
720 | 720 | return ret; |
721 | 721 | } |
722 | 722 | |
723 | -static int load_module_by_device_modalias(const char *id) | |
723 | +static int do_load_module_by_device_modalias(const char *id) | |
724 | 724 | { |
725 | 725 | struct listnode *alias_node; |
726 | 726 | struct module_alias_node *alias; |
727 | 727 | int ret = -1; |
728 | 728 | |
729 | - if (!id) goto out; | |
730 | - | |
731 | 729 | list_for_each(alias_node, &modules_aliases_map) { |
732 | 730 | alias = node_to_item(alias_node, struct module_alias_node, list); |
733 | 731 |
@@ -746,27 +744,38 @@ static int load_module_by_device_modalias(const char *id) | ||
746 | 744 | /* loading was successful */ |
747 | 745 | INFO("loaded module %s due to uevents\n", alias->name); |
748 | 746 | ret = 0; |
749 | - goto out; | |
747 | + break; | |
750 | 748 | } |
751 | 749 | } |
752 | 750 | } |
753 | 751 | } |
754 | 752 | } |
755 | 753 | |
756 | -out: | |
757 | 754 | return ret; |
758 | 755 | } |
759 | 756 | |
760 | -static void handle_deferred_module_loading() | |
757 | +static void load_module_by_device_modalias(const char *id) | |
761 | 758 | { |
762 | - struct listnode *node = NULL; | |
763 | - struct listnode *next = NULL; | |
764 | - struct module_alias_node *alias = NULL; | |
759 | + if (id) { | |
760 | + pid_t pid = fork(); | |
761 | + if (!pid) { | |
762 | + exit(do_load_module_by_device_modalias(id)); | |
763 | + } else if (pid < 0) { | |
764 | + ERROR("failed to fork for loading %s\n", id); | |
765 | + } | |
766 | + } | |
767 | +} | |
765 | 768 | |
769 | +static void handle_deferred_module_loading() | |
770 | +{ | |
766 | 771 | /* try to read the module alias mapping if map is empty |
767 | 772 | * if succeed, loading all the modules in the queue |
768 | 773 | */ |
769 | 774 | if (!list_empty(&modules_aliases_map)) { |
775 | + struct listnode *node = NULL; | |
776 | + struct listnode *next = NULL; | |
777 | + struct module_alias_node *alias = NULL; | |
778 | + | |
770 | 779 | list_for_each_safe(node, next, &deferred_module_loading_list) { |
771 | 780 | alias = node_to_item(node, struct module_alias_node, list); |
772 | 781 |
@@ -790,7 +799,7 @@ int module_probe(const char *modalias) | ||
790 | 799 | return -1; |
791 | 800 | } |
792 | 801 | |
793 | - return load_module_by_device_modalias(modalias); | |
802 | + return modalias ? do_load_module_by_device_modalias(modalias) : -1; | |
794 | 803 | } |
795 | 804 | |
796 | 805 | static void handle_module_loading(const char *modalias) |