Am Dienstag, 16. Januar 2007 18:47 schrieb Jeremy Roberson:
> +/* 
> + *    Called when opening the input device.  This will submit the URB to
> + *    the usb system so we start getting reports 
> + */
> +static int gtco_input_open(struct input_dev *inputdev)
> +{
> +       struct gtco *device;
> +       device = inputdev->private;
> +
> +       device->urbinfo->dev = device->usbdev;
> +       if (usb_submit_urb(device->urbinfo, GFP_KERNEL)) {
> +               return -EIO;
> +       }
> +       return 0;
> +}

Now you are overdoing it the other way. You need something like

static DEFINE_MUTEX(gtco_mutex);

....

static int gtco_input_open(struct input_dev *inputdev)
{
....
        rv = 0;
        mutex_lock(&gtco_mutex);
        if (device->open_count++ == 0) {
                rv = usb_submit_urb(device->urbinfo, GFP_KERNEL);
                if (rv < 0)
                        device->open_count--;
        }
        mutex_unlock(&gtco_mutex);
        return rv;
}

static void gtco_input_close(struct input_dev *inputdev)
{
...
        mutex_lock(&gtco_mutex);
        if (--device->open_count == 0)
                usb_kill_urb(device->urbinfo);
        mutex_unlock(&gtco_mutex);
}



> +                       /* Mask out the Y tilt value used for pressure */
> +                       device->buffer[7] = (u8)((device->buffer[7]) & 0x7F);
Is this cast needed?
How about: device->buffer[7] &= 0x7f;



> +static void gtco_disconnect(struct usb_interface *interface)
> +{
> +
> +       /* Grab private device ptr */
> +       struct gtco    *device = usb_get_intfdata (interface);
> +       struct input_dev *inputdev;
> +   
> +       inputdev = device->inputdevice;
> +
> +       /* Now reverse all the registration stuff */
> +       if (device) {
> +               usb_kill_urb(device->urbinfo);
> +               input_unregister_device(inputdev);

reverse the preceeding two lines. It's a race.
As long as a device is registered, it might be opened, submitting the
URB again.

        Regards
                Oliver

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to