From 01e704eba982fbc1517287cd261d229ff8e0a779 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 3 Nov 2022 09:39:36 +0900 Subject: [PATCH 1/3] udev: first set properties based on usb subsystem After 479da1107a0d4e2f7ef5cd938512b87a0e45f180, the usb_id builtin command does not set ID_SERIAL if ID_BUS is already set. Before the commit, all properties set based on pci bus were overwritten by the usb_id, hence now it is sufficient setting them only when ID_BUS is not set yet. Fixes #25238. --- rules.d/60-serial.rules | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rules.d/60-serial.rules b/rules.d/60-serial.rules index f303e27fd5..c133f26109 100644 --- a/rules.d/60-serial.rules +++ b/rules.d/60-serial.rules @@ -3,9 +3,10 @@ ACTION=="remove", GOTO="serial_end" SUBSYSTEM!="tty", GOTO="serial_end" -SUBSYSTEMS=="pci", ENV{ID_BUS}="pci", ENV{ID_VENDOR_ID}="$attr{vendor}", ENV{ID_MODEL_ID}="$attr{device}" -SUBSYSTEMS=="pci", IMPORT{builtin}="hwdb --subsystem=pci" SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id", IMPORT{builtin}="hwdb --subsystem=usb" +SUBSYSTEMS=="pci", ENV{ID_BUS}=="", ENV{ID_BUS}="pci", \ + ENV{ID_VENDOR_ID}="$attr{vendor}", ENV{ID_MODEL_ID}="$attr{device}", \ + IMPORT{builtin}="hwdb --subsystem=pci" # /dev/serial/by-path/, /dev/serial/by-id/ for USB devices KERNEL!="ttyUSB[0-9]*|ttyACM[0-9]*", GOTO="serial_end" From b2e53f5a0f12db65c88404477fedee5c57d201ba Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 3 Nov 2022 09:43:14 +0900 Subject: [PATCH 2/3] udev: drop redundant call of usb_id and assignment of ID_USB_INTERFACE_NUM The usb_id builtin command is already called in the above, and the command sets the ID_USB_INTERFACE_NUM property. --- rules.d/60-serial.rules | 2 -- 1 file changed, 2 deletions(-) diff --git a/rules.d/60-serial.rules b/rules.d/60-serial.rules index c133f26109..2c1488e930 100644 --- a/rules.d/60-serial.rules +++ b/rules.d/60-serial.rules @@ -17,9 +17,7 @@ IMPORT{builtin}="path_id" ENV{ID_PATH}=="?*", ENV{.ID_PORT}=="", SYMLINK+="serial/by-path/$env{ID_PATH}" ENV{ID_PATH}=="?*", ENV{.ID_PORT}=="?*", SYMLINK+="serial/by-path/$env{ID_PATH}-port$env{.ID_PORT}" -IMPORT{builtin}="usb_id" ENV{ID_SERIAL}=="", GOTO="serial_end" -SUBSYSTEMS=="usb", ENV{ID_USB_INTERFACE_NUM}="$attr{bInterfaceNumber}" ENV{ID_USB_INTERFACE_NUM}=="", GOTO="serial_end" ENV{.ID_PORT}=="", SYMLINK+="serial/by-id/$env{ID_BUS}-$env{ID_SERIAL}-if$env{ID_USB_INTERFACE_NUM}" ENV{.ID_PORT}=="?*", SYMLINK+="serial/by-id/$env{ID_BUS}-$env{ID_SERIAL}-if$env{ID_USB_INTERFACE_NUM}-port$env{.ID_PORT}" From 5286da064c97d2ac934cb301066aaa8605a3c8f9 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 3 Nov 2022 09:52:23 +0900 Subject: [PATCH 3/3] udev: add safe guard for setting by-id symlink The ID_BUS property is necessary for creating by-id symlinks. --- rules.d/60-serial.rules | 1 + 1 file changed, 1 insertion(+) diff --git a/rules.d/60-serial.rules b/rules.d/60-serial.rules index 2c1488e930..a0e66323a9 100644 --- a/rules.d/60-serial.rules +++ b/rules.d/60-serial.rules @@ -17,6 +17,7 @@ IMPORT{builtin}="path_id" ENV{ID_PATH}=="?*", ENV{.ID_PORT}=="", SYMLINK+="serial/by-path/$env{ID_PATH}" ENV{ID_PATH}=="?*", ENV{.ID_PORT}=="?*", SYMLINK+="serial/by-path/$env{ID_PATH}-port$env{.ID_PORT}" +ENV{ID_BUS}=="", GOTO="serial_end" ENV{ID_SERIAL}=="", GOTO="serial_end" ENV{ID_USB_INTERFACE_NUM}=="", GOTO="serial_end" ENV{.ID_PORT}=="", SYMLINK+="serial/by-id/$env{ID_BUS}-$env{ID_SERIAL}-if$env{ID_USB_INTERFACE_NUM}"