init: Ensure we try to load given module only once 32/318932/2
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 5 Feb 2025 11:58:48 +0000 (12:58 +0100)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 5 Feb 2025 12:00:46 +0000 (13:00 +0100)
This will be used later when multiple kernel module loading
passes will be introduced.

Additionally, simplify module loading function a bit.

Change-Id: Icbfe1c3d2b89a54c3e00aa5be9a63cb36a0058ac

scripts/init.sh

index b748e949aee2b22f5f42d4422d47f48fd397a25b..cd948c3ab07f47c1233ad9dd4451e8d473aa42b3 100755 (executable)
@@ -445,11 +445,13 @@ function load_kernel_modules
     for conf in $(compgen -G $MODULES_INITRD_MNT"/modules-load.d/*.conf")
     do
         echo "Read module conf: $conf"
-        while read module
+        while read module junk
         do
-            module=$(echo "$module" | /bin/xargs)            # trim white space
-            if [ "$module" = "" ]; then continue; fi         # skip blank line
-            if [ "${module:0:1}" = "#" ]; then continue; fi  # skip # commented line
+            # skip blank lines, # commented lines & already loaded modules
+            if [ "$module" = "" -o "${module:0:1}" = "#" -o -d "/sys/module/${module}" ]
+            then
+                 continue
+            fi
 
             echo "Loading module: $module"
             /sbin/modprobe $module &