system/corennnnn
Révision | a9d5cda0617319b66aeaa96fd2a22c0b12530fc7 (tree) |
---|---|
l'heure | 2016-07-27 03:52:25 |
Auteur | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Jaap Jan Meijer |
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.
@@ -875,14 +875,12 @@ out: | ||
875 | 875 | return ret; |
876 | 876 | } |
877 | 877 | |
878 | -static int load_module_by_device_modalias(const char *id) | |
878 | +static int do_load_module_by_device_modalias(const char *id) | |
879 | 879 | { |
880 | 880 | struct listnode *alias_node; |
881 | 881 | struct module_alias_node *alias; |
882 | 882 | int ret = -1; |
883 | 883 | |
884 | - if (!id) goto out; | |
885 | - | |
886 | 884 | list_for_each(alias_node, &modules_aliases_map) { |
887 | 885 | alias = node_to_item(alias_node, struct module_alias_node, list); |
888 | 886 |
@@ -901,27 +899,38 @@ static int load_module_by_device_modalias(const char *id) | ||
901 | 899 | /* loading was successful */ |
902 | 900 | INFO("loaded module %s due to uevents\n", alias->name); |
903 | 901 | ret = 0; |
904 | - goto out; | |
902 | + break; | |
905 | 903 | } |
906 | 904 | } |
907 | 905 | } |
908 | 906 | } |
909 | 907 | } |
910 | 908 | |
911 | -out: | |
912 | 909 | return ret; |
913 | 910 | } |
914 | 911 | |
915 | -static void handle_deferred_module_loading() | |
912 | +static void load_module_by_device_modalias(const char *id) | |
916 | 913 | { |
917 | - struct listnode *node = NULL; | |
918 | - struct listnode *next = NULL; | |
919 | - struct module_alias_node *alias = NULL; | |
914 | + if (id) { | |
915 | + pid_t pid = fork(); | |
916 | + if (!pid) { | |
917 | + exit(do_load_module_by_device_modalias(id)); | |
918 | + } else if (pid < 0) { | |
919 | + ERROR("failed to fork for loading %s\n", id); | |
920 | + } | |
921 | + } | |
922 | +} | |
920 | 923 | |
924 | +static void handle_deferred_module_loading() | |
925 | +{ | |
921 | 926 | /* try to read the module alias mapping if map is empty |
922 | 927 | * if succeed, loading all the modules in the queue |
923 | 928 | */ |
924 | 929 | if (!list_empty(&modules_aliases_map)) { |
930 | + struct listnode *node = NULL; | |
931 | + struct listnode *next = NULL; | |
932 | + struct module_alias_node *alias = NULL; | |
933 | + | |
925 | 934 | list_for_each_safe(node, next, &deferred_module_loading_list) { |
926 | 935 | alias = node_to_item(node, struct module_alias_node, list); |
927 | 936 |
@@ -945,7 +954,7 @@ int module_probe(const char *modalias) | ||
945 | 954 | return -1; |
946 | 955 | } |
947 | 956 | |
948 | - return load_module_by_device_modalias(modalias); | |
957 | + return modalias ? do_load_module_by_device_modalias(modalias) : -1; | |
949 | 958 | } |
950 | 959 | |
951 | 960 | static void handle_module_loading(const char *modalias) |