include: Add support for specifying kernel module parameters
authorFlorian Fainelli <f.fainelli@gmail.com>
Tue, 13 Jun 2017 22:19:24 +0000 (15:19 -0700)
committerFlorian Fainelli <f.fainelli@gmail.com>
Sat, 15 Jul 2017 17:35:21 +0000 (10:35 -0700)
A number of people have requested that feature to be added in the past
(OpenWrt tickets #1458, #2359) so make that possible now.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
include/kernel.mk

index 7674f0dadc202a4aa02c609296acc191377a3cad..a901c7136aaa10426043a0d5ed1bfcc9ded21458 100644 (file)
@@ -132,12 +132,17 @@ define ModuleAutoLoad
        export modules=; \
        probe_module() { \
                local mods="$$$$$$$$1"; \
+               params="$$$$$$$$3"; \
                local boot="$$$$$$$$2"; \
                local mod; \
-               shift 2; \
+               shift 3; \
                for mod in $$$$$$$$mods; do \
                        mkdir -p $(2)/etc/modules.d; \
-                       echo "$$$$$$$$mod" >> $(2)/etc/modules.d/$(1); \
+                       if [ -n "$$$$$$$$params" ]; then \
+                               echo "$$$$$$$$mod $$$$$$$$params" >> $(2)/etc/modules.d/$(1); \
+                       else \
+                               echo "$$$$$$$$mod" >> $(2)/etc/modules.d/$(1); \
+                       fi; \
                done; \
                if [ -e $(2)/etc/modules.d/$(1) ]; then \
                        if [ "$$$$$$$$boot" = "1" -a ! -e $(2)/etc/modules-boot.d/$(1) ]; then \
@@ -151,11 +156,16 @@ define ModuleAutoLoad
                local priority="$$$$$$$$1"; \
                local mods="$$$$$$$$2"; \
                local boot="$$$$$$$$3"; \
+               params="$$$$$$$$4"; \
                local mod; \
-               shift 3; \
+               shift 4; \
                for mod in $$$$$$$$mods; do \
                        mkdir -p $(2)/etc/modules.d; \
-                       echo "$$$$$$$$mod" >> $(2)/etc/modules.d/$$$$$$$$priority-$(1); \
+                       if [ -n "$$$$$$$$params" ]; then \
+                               echo "$$$$$$$$mod $$$$$$$$params" >> $(2)/etc/modules.d/$$$$$$$$priority-$(1); \
+                       else \
+                               echo "$$$$$$$$mods" >> $(2)/etc/modules.d/$$$$$$$$priority-$(1); \
+                       fi; \
                done; \
                if [ -e $(2)/etc/modules.d/$$$$$$$$priority-$(1) ]; then \
                        if [ "$$$$$$$$boot" = "1" -a ! -e $(2)/etc/modules-boot.d/$$$$$$$$priority-$(1) ]; then \
@@ -266,11 +276,11 @@ endef
 version_filter=$(if $(findstring @,$(1)),$(shell $(SCRIPT_DIR)/package-metadata.pl version_filter $(KERNEL_PATCHVER) $(1)),$(1))
 
 define AutoLoad
-  add_module "$(1)" "$(call version_filter,$(2))" "$(3)";
+  add_module "$(1)" "$(call version_filter,$(2))" "$(3)" "$(4)";
 endef
 
 define AutoProbe
-  probe_module "$(call version_filter,$(1))" "$(2)";
+  probe_module "$(call version_filter,$(1))" "$(2)" "$(3)";
 endef
 
 version_field=$(if $(word $(1),$(2)),$(word $(1),$(2)),0)