struct usb_ep *ep_in;
struct usb_ep *ep_out;
- /* set to 1 when we connect */
+ /* online indicates state of function_set_alt & function_unbind
+ * set to 1 when we connect
+ */
int online:1;
- /* Set to 1 when we disconnect.
+
+ /* disconnected indicates state of open & release
+ * Set to 1 when we disconnect.
* Not cleared until our file is closed.
*/
int disconnected:1;
static void acc_set_disconnected(struct acc_dev *dev)
{
- dev->online = 0;
dev->disconnected = 1;
}
printk(KERN_INFO "acc_release\n");
WARN_ON(!atomic_xchg(&_acc_dev->open_excl, 0));
- _acc_dev->disconnected = 0;
+ /* indicate that we are disconnected
+ * still could be online so don't touch online flag
+ */
+ _acc_dev->disconnected = 1;
return 0;
}
struct usb_request *req;
int i;
+ dev->online = 0; /* clear online flag */
+ wake_up(&dev->read_wq); /* unblock reads on closure */
+ wake_up(&dev->write_wq); /* likewise for writes */
+
while ((req = req_get(dev, &dev->tx_idle)))
acc_request_free(req, dev->ep_in);
for (i = 0; i < RX_REQ_MAX; i++)
}
dev->online = 1;
+ dev->disconnected = 0; /* if online then not disconnected */
/* readers may be blocked waiting for us to go online */
wake_up(&dev->read_wq);
struct usb_composite_dev *cdev = dev->cdev;
DBG(cdev, "acc_function_disable\n");
- acc_set_disconnected(dev);
+ acc_set_disconnected(dev); /* this now only sets disconnected */
+ dev->online = 0; /* so now need to clear online flag here too */
usb_ep_disable(dev->ep_in);
usb_ep_disable(dev->ep_out);