diff --git a/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/SysfsUsbSerialScanner.java b/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/SysfsUsbSerialScanner.java index 50483ab06..0da7cd35b 100644 --- a/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/SysfsUsbSerialScanner.java +++ b/bundles/org.openhab.core.config.discovery.usbserial.linuxsysfs/src/main/java/org/openhab/core/config/discovery/usbserial/linuxsysfs/internal/SysfsUsbSerialScanner.java @@ -222,7 +222,10 @@ public class SysfsUsbSerialScanner implements UsbSerialScanner { * of a USB device. */ private @Nullable Path getUsbInterfaceParentPath(Path sysfsPath) { - if (sysfsPath.getFileName() == null) { + if (sysfsPath.toString().indexOf('-') == -1) { + // a fast path to avoid pattern matching for dozens of not matching directories + return null; + } else if (sysfsPath.getFileName() == null) { return null; } else if (SYSFS_USB_INTERFACE_DIRECTORY_PATTERN.matcher(sysfsPath.getFileName().toString()).matches()) { return sysfsPath;