• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

Révisiona9d5cda0617319b66aeaa96fd2a22c0b12530fc7 (tree)
l'heure2016-07-27 03:52:25
AuteurChih-Wei Huang <cwhuang@linu...>
CommiterJaap Jan Meijer

Message de Log

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.

Change Summary

Modification

--- a/init/devices.cpp
+++ b/init/devices.cpp
@@ -875,14 +875,12 @@ out:
875875 return ret;
876876 }
877877
878-static int load_module_by_device_modalias(const char *id)
878+static int do_load_module_by_device_modalias(const char *id)
879879 {
880880 struct listnode *alias_node;
881881 struct module_alias_node *alias;
882882 int ret = -1;
883883
884- if (!id) goto out;
885-
886884 list_for_each(alias_node, &modules_aliases_map) {
887885 alias = node_to_item(alias_node, struct module_alias_node, list);
888886
@@ -901,27 +899,38 @@ static int load_module_by_device_modalias(const char *id)
901899 /* loading was successful */
902900 INFO("loaded module %s due to uevents\n", alias->name);
903901 ret = 0;
904- goto out;
902+ break;
905903 }
906904 }
907905 }
908906 }
909907 }
910908
911-out:
912909 return ret;
913910 }
914911
915-static void handle_deferred_module_loading()
912+static void load_module_by_device_modalias(const char *id)
916913 {
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+}
920923
924+static void handle_deferred_module_loading()
925+{
921926 /* try to read the module alias mapping if map is empty
922927 * if succeed, loading all the modules in the queue
923928 */
924929 if (!list_empty(&modules_aliases_map)) {
930+ struct listnode *node = NULL;
931+ struct listnode *next = NULL;
932+ struct module_alias_node *alias = NULL;
933+
925934 list_for_each_safe(node, next, &deferred_module_loading_list) {
926935 alias = node_to_item(node, struct module_alias_node, list);
927936
@@ -945,7 +954,7 @@ int module_probe(const char *modalias)
945954 return -1;
946955 }
947956
948- return load_module_by_device_modalias(modalias);
957+ return modalias ? do_load_module_by_device_modalias(modalias) : -1;
949958 }
950959
951960 static void handle_module_loading(const char *modalias)