Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 03-11-2004, 11:30 PM   #1
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
usb skeleton driver question


where it is bold, why are they down'ing the semaphore while still holdin on to the other one? wouldnt it make more sense to switch the order of those calls and release one before trying to lock the other? or is there something i'm not seeing here.

static int skel_open (struct inode *inode, struct file *file)
    struct usb_skel *dev = NULL;
    int subminor;
    int retval = 0;


    subminor = MINOR (inode->i_rdev) - USB_SKEL_MINOR_BASE;
    if ((subminor < 0) ||
        (subminor >= MAX_DEVICES)) {
        return -ENODEV;

    /* Increment our usage count for the module.
     * This is redundant here, because "struct file_operations"
     * has an "owner" field. This line is included here soley as
     * a reference for drivers using lesser structures... ;-)

    /* lock our minor table and get our local data for this minor */
    down (&minor_table_mutex);
    dev = minor_table[subminor];
    if (dev == NULL) {
        up (&minor_table_mutex);
        return -ENODEV;

    /* lock this device */
    down (&dev->sem);

    /* unlock the minor table */
    up (&minor_table_mutex);

    /* increment our usage count for the driver */

    /* save our object in the file's private structure */
    file->private_data = dev;

    /* unlock this device */
    up (&dev->sem);

    return retval;
Old 03-12-2004, 12:19 PM   #2
Registered: Feb 2004
Location: Vienna/Austria
Distribution: Debian Unstable
Posts: 36

Rep: Reputation: 15
Hmmm... Seems for me like a preparation for preemble kernel functions... Don't know why it is eactly working this way, but, it think David Brownell was it who changed the behavier of half of the usb architecture to fit with the new needs of 2.6

Watch out your 2.6 source:

You'll see what i mean. Overall, semaphore-usage and mutexes got much more complicated in 2.6 from my view of things...

Have Fun!
Old 03-12-2004, 02:34 PM   #3
Registered: Mar 2003
Posts: 804

Original Poster
Rep: Reputation: 30
ewww im not even going to look at 2.6 until i finish 'linux device drivers'. im struggling just to make it thru as it is. thanks for the reply tho.


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
where is the skeleton directory for subdomain? koka Linux - Newbie 2 10-21-2005 05:32 PM
ati driver question and console question kholdstayr Slackware 2 07-18-2005 03:30 PM
HELP !!!!!! USB driver badboyspy Linux - Networking 1 12-03-2004 05:08 PM
slackware 10 useradd skeleton.. miguetoo Slackware 2 06-25-2004 01:50 AM
Skeleton directories for new users? jungatheart Linux - Newbie 2 04-24-2004 03:44 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:08 PM.

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