Skip to content

Commit 8019059

Browse files
committed
ofpathname: Could not retrieve logical device name for Open Firmware path
Could not retrieve logical device name pci device type without patch : ofpathname -l /pci@800000020000048/pci15b3,1003@0 ofpathname: Could not retrieve logical device name for Open Firmware path "/pci@800000020000021/pci15b3,1003@0". with patch : ofpathname -l /pci@800000020000048/pci15b3,1003@0 enP72p1s0 ofpathname enP72p1s0 /pci@800000020000048/pci15b3,1003@0 Signed-off-by: Seeteena Thoufeek <[email protected]>
1 parent f3ddb50 commit 8019059

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

scripts/ofpathname

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,7 @@ ofpathname_to_logical()
12061206
usb ) of2l_usb ;;
12071207
nvme ) of2l_nvme ;;
12081208
nvmf ) of2l_nvmf ;;
1209+
pci* ) of2l_pci ;;
12091210
esac
12101211

12111212
if [[ -z $LOGICAL_DEVNAME ]]; then
@@ -1227,6 +1228,51 @@ ofpathname_to_logical()
12271228
echo $LOGICAL_DEVNAME
12281229
}
12291230

1231+
#
1232+
# of2l_pci
1233+
# Conversion routine for OF path => logical name for pci devices
1234+
#
1235+
1236+
of2l_pci() {
1237+
# Example: DEVNAME=/pci@800000020000048/pci15b3,1003@0
1238+
# You may want to extract the PCI address and try to find a matching device
1239+
1240+
# Extract PCI address.
1241+
local pci_addr
1242+
pci_addr=$(echo "$DEVICE" | grep -o '[0-9a-fA-F]\{4\},[0-9a-fA-F]\{4\}@[0-9]\+')
1243+
1244+
if [[ -z "$pci_addr" ]]; then
1245+
# Could not extract PCI address
1246+
LOGICAL_DEVNAME=""
1247+
return
1248+
fi
1249+
1250+
# Try to find the corresponding device in /sys/bus/pci/devices
1251+
for sysdev in /sys/bus/pci/devices/*; do
1252+
if grep -qi "$pci_addr" "$sysdev/uevent" 2>/dev/null; then
1253+
# Try to find a block device under this PCI device
1254+
for blockdev in "$sysdev"/block/*; do
1255+
if [[ -b "/dev/$(basename "$blockdev")" ]]; then
1256+
LOGICAL_DEVNAME="/dev/$(basename "$blockdev")"
1257+
return
1258+
fi
1259+
done
1260+
# Or try to find a network device
1261+
for netdev in "$sysdev"/net/*; do
1262+
if [[ -d "$netdev" ]]; then
1263+
LOGICAL_DEVNAME="$(basename "$netdev")"
1264+
return
1265+
fi
1266+
done
1267+
fi
1268+
done
1269+
1270+
# If nothing found
1271+
LOGICAL_DEVNAME=""
1272+
1273+
echo $LOGICAL_DEVNAME
1274+
}
1275+
12301276
#
12311277
# of2l_ide
12321278
# Conversion routine for OF path => logical name for ide devices

0 commit comments

Comments
 (0)