include: Add support for specifying kernel module parameters modparams
authorFlorian Fainelli <f.fainelli@gmail.com>
Tue, 13 Jun 2017 22:19:24 +0000 (15:19 -0700)
committerFlorian Fainelli <florian.fainelli@broadcom.com>
Wed, 21 Jun 2017 00:03:22 +0000 (17:03 -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..565a96c6a90dbd9da0f7d96d5dceb127b57e6aa2 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 "$$$$$$$$mod" >> $(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)