driver core: clean up the logic to determine which /sys/dev/ directory to use