core: Disable probe() as well as init() in case of disable_auto_init 23/290323/4
authorYoungjae Cho <y0.cho@samsung.com>
Thu, 23 Mar 2023 01:08:06 +0000 (10:08 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Mon, 27 Mar 2023 04:51:06 +0000 (13:51 +0900)
The disable_auto_init was orignally intended to prevent a module from
being initialized automatically by the deviced's initializing process.
Instead, it gives its initialization responsibility to another module.
Commonly, a pair of core module and its subordinate plugin module use
this disable_auto_init feature. Core module is declared without
disable_auto_init whereas plugin module is declared with it. In this
manner, the core module is automatically initialized by the deviced,
and it triggers its plugin module that wouldn't have been initialized
automatically by the deviced. In this sense, keeping order between core
and plugin module, it is proper to prevent probe() as well as init()
for module declared with disable_auto_init.

Change-Id: Idb9af18342ac205962b50b4188bd8cf965a5be40
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
src/core/devices.c

index 0dd4e15..1ed1caa 100644 (file)
@@ -63,6 +63,9 @@ void devices_init(void *data)
        dev_head = g_list_sort(dev_head, compare_priority);
 
        SYS_G_LIST_FOREACH_SAFE(dev_head, elem, elem_n, dev) {
+               if (dev->disable_auto_init)
+                       continue;
+
                if (dev->probe && dev->probe(data) != 0) {
                        _E("[%s] Failed to probe.", dev->name);
                        SYS_G_LIST_REMOVE(dev_head, dev);
@@ -71,10 +74,10 @@ void devices_init(void *data)
        }
 
        SYS_G_LIST_FOREACH_SAFE(dev_head, elem, elem_n, dev) {
-               if (dev->init) {
-                       if (dev->disable_auto_init)
-                               continue;
+               if (dev->disable_auto_init)
+                       continue;
 
+               if (dev->init) {
                        _D("[%s] Initialization.", dev->name);
                        dev->init(data);
                }