modemmanager: fix physdev sysfs path detection in PCIe modems
authorAleksander Morgado <redacted>
Tue, 9 Nov 2021 10:24:00 +0000 (11:24 +0100)
committerRosen Penev <redacted>
Fri, 12 Nov 2021 19:00:04 +0000 (11:00 -0800)
The PCIe physdev path lookup relies on the 'vendor' and 'device'
attribute files, instead of the 'idVendor' and 'idProduct' ones, which
are USB specific.

Signed-off-by: Aleksander Morgado <redacted>
net/modemmanager/files/modemmanager.common

index b898a7798f8cc87f0c99ab7554f44056ac15dde7..b4139abadb1bfec43ba7174d57c031ec7b983d62 100644 (file)
@@ -39,12 +39,21 @@ mm_find_physdev_sysfs_path() {
                # avoid infinite loops iterating
                [ -z "${tmp_path}" ] || [ "${tmp_path}" = "/" ] && return
 
-               # the physical device will be that with a idVendor and idProduct pair of files
+               # For USB devices, the physical device will be that with a idVendor
+               # and idProduct pair of files
                [ -f "${tmp_path}"/idVendor ] && [ -f "${tmp_path}"/idProduct ] && {
                        tmp_path=$(readlink -f "$tmp_path")
                        echo "${tmp_path}"
                        return
                }
+
+               # For PCI devices, the physical device will be that with a vendor
+               # and device pair of files
+               [ -f "${tmp_path}"/vendor ] && [ -f "${tmp_path}"/device ] && {
+                       tmp_path=$(readlink -f "$tmp_path")
+                       echo "${tmp_path}"
+                       return
+               }
        done
 }
 
git clone https://git.99rst.org/PROJECT