How to get device file for USB device using hotplug data

ACTION='bind'
DEVICENAME='2-1:1.0'
DEVPATH='/devices/soc0/80080000.ahb/80080000.usb/ci_hdrc.0/usb2/2-1/2-1:1.0'
DEVTYPE='usb_interface'
DRIVER='usbhid'
INTERFACE='3/0/0'
MODALIAS='usb:v046DpC050d2720dc00dsc00dp00ic03isc01ip02in00'
PRODUCT='4f3/103/107'

This is USB keyboard device plug in. What is the right way to identify what device file to access the keypress/release? No udev in the system, 21.02.

I based my script for persistent tty naming on the following script in the Wiki:

1 Like

Thank you! Seems to be one of valid possible ways. The /sys/devices/soc0/80080000.ahb/80080000.usb/ci_hdrc.0/usb2/2-1/2-1:1.0 contains subdir

drwxr-xr-x    5 root     root             0 Jul 28 15:15 0003:04F3:0103.0005

which can be searched for using product name 4f3/103 (also see here). Then going into this directory and search for device file directory, for this we must know how exactly keyboard interface is named

drwxr-xr-x    3 root     root             0 Jul 28 15:15 hidraw

and then go into this directory to find device file name itself

drwxr-xr-x    3 root     root             0 Jul 28 15:15 hidraw0

Any simpler way? Can't believe there's no system built-in or special application to perform the task... System somehow can report the event in the system log:

Fri Jul 28 14:41:16 2023 kern.info kernel: [551401.928360] usb 2-1: USB disconnect, device number 5
Fri Jul 28 14:41:28 2023 kern.info kernel: [551414.292065] usb 2-1: new low-speed USB device number 6 using ci_hdrc
Fri Jul 28 14:41:28 2023 kern.info kernel: [551414.546483] input: HID 04f3:0103 as /devices/soc0/80080000.ahb/80080000.usb/ci_hdrc.0/usb2/2-1/2-1:1.0/0003:04F3:0103.0005/input/input5
Fri Jul 28 14:41:28 2023 kern.info kernel: [551414.559882] hid-generic 0003:04F3:0103.0005: input,hidraw0: USB HID v1.11 Keyboard [HID 04f3:0103] on usb-ci_hdrc.0-1/input0
Fri Jul 28 14:41:28 2023 kern.info kernel: [551414.668786] input: HID 04f3:0103 Consumer Control as /devices/soc0/80080000.ahb/80080000.usb/ci_hdrc.0/usb2/2-1/2-1:1.1/0003:04F3:0103.0006/input/input6
Fri Jul 28 14:41:28 2023 kern.info kernel: [551414.683759] input: HID 04f3:0103 System Control as /devices/soc0/80080000.ahb/80080000.usb/ci_hdrc.0/usb2/2-1/2-1:1.1/0003:04F3:0103.0006/input/input7
Fri Jul 28 14:41:28 2023 kern.info kernel: [551414.698392] hid-generic 0003:04F3:0103.0006: input,hidraw1: USB HID v1.11 Device [HID 04f3:0103] on usb-ci_hdrc.0-1/input1

then there must be a way to obtain the info from the system (not the log file!!! :crazy_face:)