LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-22-2010, 06:22 AM   #1
greplinux
Member
 
Registered: Jun 2007
Posts: 118

Rep: Reputation: 17
struct driver_info


Hi,

while going through the usb drivers chapter in 'Linux device drivers' book, I came through the code which we use to match device to a driver. A structure 'driver_info' was described as well. It is not well documented about the usage of this structure. Can you guys let me know its usage with an example?

Thanks,
 
Old 07-22-2010, 09:34 PM   #2
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Ubuntu 10.10, Slackware 64-current
Posts: 2,124

Rep: Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778
I am not familiar with this part of the book, but I think I have a pretty good guess as to what you are asking and will try to answer.

Each (registered or certified) USB device vendor has a "vendor ID" and each device that they manufacture has a "Device ID". These ID's are part of the data that is communicated during device enumeration. In addition, information regarding the end points, types of transfers supported, protocols, etc, will also be discovered. The structure most likely maps some or all of this information into a table that is indexed by the device and vendor ID numbers. By knowing the device and vendor ID, you can also record if there are any "quirks" associated with the device and program around them. Unfortunately, many manufacturer's don't fully comply with the standards and as long as it works with Window's they don't care. This means that in order to be supported in Linux, a work around for these non-compliance issues may be required.
 
1 members found this post helpful.
Old 07-23-2010, 03:07 AM   #3
greplinux
Member
 
Registered: Jun 2007
Posts: 118

Original Poster
Rep: Reputation: 17
Hi Noway2,

Thanks a lot. But still some doubts about the 'quirks' part. Can you give me an example to get a hold on that.

Thanks again,
 
Old 07-23-2010, 06:09 AM   #4
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Ubuntu 10.10, Slackware 64-current
Posts: 2,124

Rep: Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778Reputation: 778
Yes, I can. A few years back, as part of a larger project we developed a USB host controller using the NXP-1161A OTG controller that was developed on a TI DSP. We borrowed from the 1161A drivers that we were found for the Linux kernel (http://www.beyondlogic.org/usb/otghost.htm for reference). The purpose of the application was to be able to read UBS memory sticks and data log our application to them. In addition to borrowing from Linux, we read the specs on the SCSI command set, bulk-only-transport protocols, FAT-32 specification, etc. In other words we followed the standards.

Towards the end, we were testing with several different brands of USB sticks and USB external HDDs (which have the same command set). This by the way is an example of where the structure could come into play, if for example the device supports both the SCSI and ATAPI command sets on different endpoints. Anyway, we discovered a couple of the devices would enumerate, but would not mount as a disk.

It turns out that as part of the FAT decode you need to do several computations involving things like the number of sectors in order to be able to get the information needed to access the disk. After several days of head scratching, we came across an article (I think it may have been on LVR.com) that said that many vendors erroneously represent (I think it is the sector count) as being off by 1. When we adjusted this count per the article, the device worked perfectly. We still had a device that was an old 16Mb stick that I got at CompUSA that was made by Poinchips that would not work with our system and would only work with Windows.

So, in this case, we needed to hard code a work around into the software that it try this fix. We could use the vendor and device IDs as flags indicating that we needed to adjust the count. In our case it was simple to try the adjusted count if we received an error, but in a case like Windows or Linux where you have to support thousands of different devices, a table of the corrections could be immensely helpful.
 
Old 07-23-2010, 07:00 AM   #5
greplinux
Member
 
Registered: Jun 2007
Posts: 118

Original Poster
Rep: Reputation: 17
Hi Noway2,

Thank you very much. Even though, I didnt get it completely, you reply, certainly started to make sense about the structure. Will work more on this.

Thank you verrrrrrrrrry much.

I feel really happy , when I see people taking great pains to solve others problem. I appreciate your reply very much.

Thanks,
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] Question about Kernel pid_namespace - struct pid and struct upid sreeharsha.t Linux - Kernel 4 03-19-2010 05:41 AM
Typecast struct sockaddr in struct sockaddr_in sudhansu Linux - Kernel 1 02-17-2009 11:33 AM
GCC compile problem:struct A have a member variable which is just a struct type name? leon.zcom Programming 3 04-18-2008 05:40 PM
g++ and wrong struct member addresses / struct size misreporting sonajiso Linux - General 5 05-22-2004 11:16 PM
switch statement converting struct char to struct int oceaneyes2 Programming 2 12-10-2003 05:30 PM


All times are GMT -5. The time now is 05:30 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration