The error#
I was having trouble with a USB joystick adapter
(an EMS Playstation controller adapter, to be specific). When
I plugged it in, it wouldn't work and checking dmesg
showed the same error getting generated over and over again (at least
once per second):
$ dmesg
...
[81700.968873] usbhid 6-1:1.0: can't add hid device: -71
[81700.968885] usbhid: probe of 6-1:1.0 failed with error -71
[81700.968986] usb usb6-port1: disabled by hub (EMI?), re-enabling...
[81700.968991] usb 6-1: USB disconnect, device number 53
[81701.208025] usb 6-1: new low-speed USB device number 54 using uhci_hcd
[81701.384866] usb 6-1: string descriptor 0 read error: -32
...
The wrong fix#
I decided the sensible thing to do was to reload the driver:
$ sudo modprobe -r usbhid # Bad idea, don't run this
An aside on kernel modules#
Drivers in Linux are called kernel modules and are managed by
the modprobe
command whose -r
or
--remove
option unloads a module. The lsmod
command
lists the currently loaded modules. The actual modules are the .ko
files stored under /lib/modules/$(uname
-r)/kernel/
.
When compiling a kernel, most features that can be compiled as modules can also be compiled into the kernel. That means that just because a system supports a feature doesn't mean that feature is loaded as a module. But the kernels that come with most distributions tend to have everything as separate modules to best support as many different hardware configurations as possible.
The usbhid
kernel module#
USB joysticks are handled by the usbhid
module which handles all
USB human interface devices including joysticks, mice,
keyboards… See the reason for the title of this blog post now?
After running that command, my computer's mouse and keyboard stopped
working because I had just unloaded the driver for them.
Fixing my mistake#
The right thing to do would have been to run a command that included reloading the driver:
$ sudo modprobe -r usbhid; sudo modprobe usbhid
I was about to ssh
in from another computer when I remembered a
simpler workaround: unplugging the joystick adapter and plugging it back
in. Then my keyboard and mouse worked again because whenever a device is
plugged in, udev loads the appropriate kernel modules for it, in
this case, reloading the usbhid
module.
A happy ending#
The good news is, the joystick adapter worked, so unloading and
reloading usbhid
was the right fix.
Comments
Have something to add? Post a comment by sending an email to comments@aweirdimagination.net. You may use Markdown for formatting.
There are no comments yet.