<div dir="ltr"><div>>> On Sat, Apr 25, 2020 at 1:46 AM Sohaib Mhmd <<a href="mailto:xunilams@gmail.com" target="_blank">xunilams@gmail.com</a>> wrote:</div><div>>> Hi everyone, I made a very <a href="https://gist.github.com/smalinux/3d6a5b000a32b97250b2d0c86b90711b" target="_blank">simple USB driver</a>,</div><div dir="ltr">>> but the problem is that the probe and disconnect functions never was called.</div><div dir="ltr">>> I tried to google for this problem but unfortunately:<br>>> 1- I don't use <a href="https://stackoverflow.com/a/31071943/5688267" target="_blank">usb-storage</a>, it's a keyboard! (but anyway the same problem exists with any usb-based device) and all driver on my machine are  bluetooth related drive (i think!) (as you see from lsmod | grep usb)</div><div dir="ltr">>> 2- I tried to <a href="https://stackoverflow.com/a/4204608/5688267" target="_blank">rmmod usbhid</a> but I get error: ERROR: Module usbhid is builtin.</div><div dir="ltr">>> I tried to search for "usbhid" in .config file to remove it but I didn't find anything.<br><br>>> What should I do?<br>>> thanks, smalinux</div><div><br></div><div>Hello Sohaib,<br><br></div><div>Looking at the very last line of your dmesg output :<br></div><div>[ 4545.614471] hid-generic 
0003:045E:0800.000C: input,hiddev96,hidraw2: USB HID v1.11 Device 
[Microsoft Microsoft® Nano Transceiver v2.0] on 
usb-0000:00:14.0-3/input2<br><br></div><div>The reason your probe and disconnect functions are never called is because the hid-generic driver has claimed your device. This is the default behavior.<br></div><div>Since usbhid is builtin you are unable to unload it using rmmod. But you can unbind it. The steps are below:<br></div><div><br></div><div>1 - sudo modprobe <your_kernel_module></div><div>2 - unbind hid-generic                  ( from a root terminal )</div><div>3 - bind <your_kernel_module>    ( from a root terminal )<br></div><div>4 - check dmesg                         ( should show your probe has been called )<br></div><div>5 - unbind <your_kernel_module> ( from a root terminal )</div><div>6 - check dmesg                         ( should show your disconnect has been called )<br></div><div></div><div><br></div><div>Clear the log buffer with dmesg -c then run dmesg -w. <br></div><div><br></div><div>Now find your bus id. Your bus id is 3-3:1.2 from your second last dmesg output. <br>[ 4545.613190] input: Microsoft Microsoft® Nano Transceiver v2.0 System 
Control as 
/devices/pci0000:00/0000:00:14.0/usb3/3-3/3-3:1.2/0003:045E:0800.000C/input/input49<br><br></div><div>To unbind from hid-generic from a root shell/terminal:<br>echo "3-3:1.2" >  /sys/bus/usb/drivers/usbhid/unbind</div><div><br></div><div>Now to bind to your driver from a root shell:<br>echo "3-3:1.2" >  /sys/bus/usb/drivers/'my first usb driver'/bind    // you need the single quotes because of the spaces in your driver name</div><div><br></div><div>You should see dmesg telling you the probe function has been called now.</div><div><br></div><div>To unbind your driver from a root shell:</div><div>echo "3-3:1.2" >  /sys/bus/usb/drivers/'my first usb driver'/unbind    // you need the single quotes because of the spaces in your driver name</div><div><br></div><div>and now dmesg should show you the disconnect function has been called.<br></div><div><br></div><div>If you pull out your device and plug it back in usbhid will be triggered. To stop that you can from a root terminal:<br>echo '0' > /sys/bus/hid/drivers_autoprobe   <br></div><div><br></div><div>Good luck - Aruna ( If you have the kernel source why not re-compile ? Look for CONFIG_USB_HID in Make menuconfig )<br></div><div><br></div><div><br></div><div><br></div><div></div><div><br></div><div><br></div><br></div>