LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-14-2010, 09:07 PM   #1
beetleskin
LQ Newbie
 
Registered: Dec 2010
Posts: 4

Rep: Reputation: 0
driver development: usbhid is blocking custom device driver


Hej!

I'm developing a custom usb device driver (Stereovision HMD). Unfortunately the Linux usbhid driver (resp. the correlating kernel module) kind of catches the device as soon as it is connected to dhe usb host controller. Thus my own driver (identifying via vendorID and productID) is blocked. I searched the internet for a way to prevent usbhid from catching the device and found a couple of solutions, but nothing worked so far, as I just didn't find the files proposed by that solutions (blacklisting vendorid and productid in some files, e.g. usbhid.conf...). I can't figure out a up-to-date solution.

I'm running Ubuntu, 2.6.32-25 Kernel.

I just can't imagine why the standard Linux driver for HID (usbhid) is associated to that device when there is a driver loaded (my driver kernel module), which provides the correct IDs!? Anyway, is there a solution for that problem? A kind of priority list? Can I override/overload usbhid? Or do I have to use blacklists? Best solution would be within my driver code, as I want to port my driver to other systems whithout hacking some kernel properties everytime...

every hint would be appreciated!

best regards

ps: my nasty workaround is a shell script that unloads the usbhid module, waits 20 seconds for me to plug the usb device and reloads the usbhid module. works. kind of
 
Old 12-15-2010, 07:09 PM   #2
stevexyz
LQ Newbie
 
Registered: Apr 2008
Location: Hampshire, UK
Distribution: None
Posts: 27

Rep: Reputation: 16
Can you unbind the USB device from usbhid?

cat xxx > /sys/bus/usb/drivers/usbhid/unbind

Where xxx is its USB ID (this will be a symlink in that directory)

Cheers, Steve
 
Old 12-16-2010, 10:12 AM   #3
beetleskin
LQ Newbie
 
Registered: Dec 2010
Posts: 4

Original Poster
Rep: Reputation: 0
I tried the unbind but got a <permission denied>, even as sudoer :/
I wont get more permissions at this computer...

Any other ideas?
 
Old 12-16-2010, 10:34 AM   #4
stevexyz
LQ Newbie
 
Registered: Apr 2008
Location: Hampshire, UK
Distribution: None
Posts: 27

Rep: Reputation: 16
cat xxx > /sys/bus/usb/drivers/usbhid/unbind

Sorry, the cat should be an echo

Steve
 
Old 12-16-2010, 11:00 AM   #5
beetleskin
LQ Newbie
 
Registered: Dec 2010
Posts: 4

Original Poster
Rep: Reputation: 0
hej, tried it with echo:
echo 4-3.1\:1.0 > /sys/bus/usb/drivers/usbhid/unbind

but output is the same, permission denied, with sudo as well.

4-3.1:1.0 should be the correct id. I obtained it with plugging/unplugging the device and searched for changes in /sys/bus/usb/drivers/usbhid/. Is there a nicer way of getting that id? via lsusb, usb-device or via the device-file?

edit:
funny thing: running the script:
#!/bin/bash
modprobe -r usbhid z800_a
modprobe z800_a
modprobe usbhid

, where z800_a is my driver, will load the correct driver for the device even when plugging/unplugging the device. so the sequence in which modules are loaded somehow affect their priority concerning probing devices...?!

Last edited by beetleskin; 12-16-2010 at 12:03 PM.
 
Old 12-16-2010, 03:57 PM   #6
stevexyz
LQ Newbie
 
Registered: Apr 2008
Location: Hampshire, UK
Distribution: None
Posts: 27

Rep: Reputation: 16
When the USB device is bound to the usbhid driver, it should appear as a symlink in the usbhid sysfs directory. For example, my /sys/bus/usb/drivers/usbhid directory looks like this:

2-3:1.0 bind module new_id remove_id uevent unbind

In this case 2-3:1.0 is my mouse.

As root I can echo 2-3:1.0 > unbind and I lose my mouse. The 2-3:1.0 symlink disappears as it's no longer bound to the hid driver. Then I can echo 2-3:1.0 > bind and I get it back again.

I have an FTDI USB serial device which I communicate with using libusb, not through the usb-serial FTDI driver. I have to unbind this one device from the usb-serial driver in exactly the same way.

Cheers, Steve
 
Old 12-20-2010, 07:03 AM   #7
beetleskin
LQ Newbie
 
Registered: Dec 2010
Posts: 4

Original Poster
Rep: Reputation: 0
hej,

yep, it does appear in the usbhid directory. But allt he same even as root I'm somehow not allowed to unbind it this way. but anyway, this is not the solution I'm looking forward, as I want the device to be bound to the correct driver automatically, at startup and without running a script every time...

thanks anyway
 
Old 06-13-2012, 02:44 AM   #8
noamraph
LQ Newbie
 
Registered: Jun 2012
Posts: 4

Rep: Reputation: Disabled
I think that I encountered the same problem, and the solution was to add an entry to the hid_ignore_list array in drivers/hid/hid-core.c

See http://permalink.gmane.org/gmane.lin....general/65613
 
Old 09-26-2013, 08:41 AM   #9
TwoD
LQ Newbie
 
Registered: Sep 2013
Posts: 1

Rep: Reputation: Disabled
Sorry for reviving an old thread, but I think the reason you're not able to unbind the device is that only the echo is being run as root when using sudo.
Switch to an actual root prompt (sudo -s) first and echoing the device id to the bind/unbind interface should work.
 
Old 11-19-2013, 09:04 AM   #10
mateo23
LQ Newbie
 
Registered: Nov 2013
Posts: 4

Rep: Reputation: Disabled
Quote:
Originally Posted by TwoD View Post
Sorry for reviving an old thread, but I think the reason you're not able to unbind the device is that only the echo is being run as root when using sudo.
Switch to an actual root prompt (sudo -s) first and echoing the device id to the bind/unbind interface should work.
Yes, that does the trick.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Best IDE for C/C++ and Device driver development djai Linux - Software 5 07-27-2010 06:39 PM
New USB Device Driver Development njain6127 LinuxQuestions.org Member Intro 0 09-03-2009 07:32 PM
PCI Device Driver development and deployment amit1947 Linux - Hardware 1 05-27-2009 06:54 PM
Custom kernel device driver isalmbio Linux - Kernel 0 06-30-2007 10:50 AM
Linux Device Driver Development aslv Linux - Certification 0 09-27-2004 08:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration