summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmil Velikov <emil.l.velikov@gmail.com>2023-10-14 12:24:35 +0100
committerEmil Velikov <emil.l.velikov@gmail.com>2023-10-14 17:54:52 +0100
commit0cb3f74b650550f5d8515ae5b6490663c918cbe1 (patch)
tree6702d1565ee6b19e8ca7d98ce4bc2406c6ff311e
parentb8f91b24e32d0dbf4de9a3d3e12ca38040a79908 (diff)
add_module_from_symbol: rework the API
Currently the API stands out as very inconsistent wrt the existing ones. Furthermore the documentation explicitly calls implementation details which is rarely a good idea. Rework it to align with add_all_modules/add_checked_modules. Namely: - use plural, we add module_s_ - drop the -c flag and use two separate functions v2: - use local -a mods Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
-rw-r--r--functions23
-rw-r--r--install/kms2
-rw-r--r--man/mkinitcpio.8.adoc10
3 files changed, 19 insertions, 16 deletions
diff --git a/functions b/functions
index a8c9103..8b1f1be 100644
--- a/functions
+++ b/functions
@@ -1089,21 +1089,20 @@ find_module_from_symbol() {
done
}
-add_module_from_symbol() {
- local mods
- local -i use_add_checked_modules=0
+add_all_modules_from_symbol() {
+ local -a mods
- if [[ "$1" == '-c' ]]; then
- use_add_checked_modules=1
- shift
- fi
mapfile -t mods < <(find_module_from_symbol "$@")
(( ${#mods[@]} )) || return 1
- if (( use_add_checked_modules )); then
- map add_checked_modules "${mods[@]}" || :
- else
- map add_module "${mods[@]}"
- fi
+ map add_module "${mods[@]}"
+}
+
+add_checked_modules_from_symbol() {
+ local -a mods
+
+ mapfile -t mods < <(find_module_from_symbol "$@")
+ (( ${#mods[*]} )) || return 1
+ map add_checked_modules "${mods[@]}" || :
}
# vim: set ft=sh ts=4 sw=4 et:
diff --git a/install/kms b/install/kms
index 9fa6487..f1e10b0 100644
--- a/install/kms
+++ b/install/kms
@@ -6,7 +6,7 @@ build() {
map add_checked_modules '/drivers/char/agp/' '/drivers/gpu/drm/'
# modules that implement the privacy screen interface
- add_module_from_symbol -c 'drm_privacy_screen_register' '=drivers/platform'
+ add_checked_modules_from_symbol 'drm_privacy_screen_register' '=drivers/platform'
}
help() {
diff --git a/man/mkinitcpio.8.adoc b/man/mkinitcpio.8.adoc
index d3f3c50..3571ca0 100644
--- a/man/mkinitcpio.8.adoc
+++ b/man/mkinitcpio.8.adoc
@@ -272,11 +272,15 @@ functions exist to facilitate this.
and added. The argument can be a rule file name (discovered from well known
udev paths) or an absolute path.
-*add_module_from_symbol* [ *-c* ] _symbol_ _paths..._::
+*add_all_modules_from_symbol* _symbol_ _paths_::
Adds modules from the _paths_ directories containing the _symbol_ to the
image.
- Uses *add_module* by default, but by specifying the *-c* flag,
- *add_checked_modules* will be used instead.
+
+*add_checked_modules_from_symbol* _symbol_ _paths_::
+ Similar to *add_all_modules_from_symbol* with the constraint that only
+ modules matching the whitelist generated by the autodetect hook will be
+ added to the image. If the autodetect hook is not present in the image, this
+ function is identical to *add_all_modules_from_symbol*.
== About runtime hooks