]> git.pld-linux.org Git - projects/geninitrd.git/commitdiff
usbkbd: find usb controllers attached to any bus
authorJan Palus <atler@pld-linux.org>
Tue, 20 Sep 2022 00:18:28 +0000 (02:18 +0200)
committerJan Palus <atler@pld-linux.org>
Tue, 20 Sep 2022 00:18:28 +0000 (02:18 +0200)
fallback to pci-exclusive method if none were found

functions
mod-usbkbd.sh

index 186b96751f33a205e7649e71de0c9a74929360f4..5f38115d6bfc56f33715b505108535abbd7157f6 100644 (file)
--- a/functions
+++ b/functions
@@ -186,11 +186,15 @@ dm_node() {
        printf "/dev/mapper/%s" $(dm_name "$node")
 }
 
+is_kmod() {
+       modprobe --version | grep -q "^kmod"
+}
+
 # find modules by class
 # find_modules_by_class 0106 - finds modules for SATA devices in the system
 # find_modules_by_class 0c03 - finds modules for USB controllers
 find_modules_by_class() {
-       if modprobe --version | grep -q "^kmod"; then
+       if is_kmod; then
                find_modules_by_class_kmod $@
        else
                find_modules_by_class_mit $@
index dd2ab95b3fb002d5d3c2206f1cc34d861d545554..4857bd4fdc04d099c31980ed1ad25ff1042d45f7 100644 (file)
@@ -57,9 +57,22 @@ find_modules_usbkbd() {
 
        if [ -n "$modules" ]; then
                # usb controllers
-               for m in $(find_modules_by_class "0c03"); do
-                       find_module "$m"
-               done
+               if is_kmod; then
+                       # find parent devices of usb hubs
+                       for hub_dc in `grep -l 09 /sys/bus/usb/devices/*/bDeviceClass`; do
+                               ctrl=$(dirname $(dirname $(readlink -f $hub_dc)))
+                               if [ -f "$ctrl/modalias" ]; then
+                                       find_module $(cat "$ctrl/modalias")
+                                       usb_ctrl_found=1
+                               fi
+                       done
+               fi
+               if [ -z "$usb_ctrl_found" ]; then
+                       # fallback to old pci only method
+                       for m in $(find_modules_by_class "0c03"); do
+                               find_module "$m"
+                       done
+               fi
 
                # always add hid-generic
                find_module "-hid-generic"
This page took 0.530436 seconds and 4 git commands to generate.