Re: How to learn a device is open
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: 2009-11-25 20:15:56
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: 2009-11-25 20:15:56
Hi Oliver, On Wed, Nov 25, 2009 at 05:57:16PM +0100, Oliver Neukum wrote:
Hi, I need a way to determine whether an input device has been opened. A private flag seems wasteful. Is this an acceptable method?
Yes, I thhink it is reasonable. I really don't think that adding a wrapper for input->mutex worth it but I would not oppose adding one either.
Regards
Oliver
+static int usbtouch_resume(struct usb_interface *intf)
+{
+ struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
+ struct input_dev *input = usbtouch->input;
+ int result = 0;
+
+ mutex_lock(&input->mutex);
+ if (input->users)
+ result = usb_submit_urb(usbtouch->irq, GFP_NOIO);
+ mutex_unlock(&input->mutex);
+ return result;
+}-- Dmitry