ext [EMAIL PROTECTED] wrote:

> +
> +/*
> + * We need to lock the device before resetting, but we may already have the
> + * lock. So we try to lock the device, if it fails (returns < 0) then we
> + * cannot proceed. If it returned 1 then we acquired the lock here and need
> + * to release the lock. If it returned 0 then we already have the lock and
> + * we leave it to the piece that acquired the lock to release it.
> + */
> +static
> +void usb_dev_reset_delayed_task(struct work_struct *ws)
> +{
> +     struct usb_dev_reset_ctx *reset_ctx =
> +             container_of(ws, struct usb_dev_reset_ctx, ws);
> +     struct usb_device *usb_dev = reset_ctx->usb_dev;
> +     struct device *dev = &usb_dev->dev;
> +     int had_to_lock;
> +     int result = 0;
> +
> +     if (usb_dev == NULL) {
> +             WARN_ON(1);
> +             goto release;
> +     }
> +     had_to_lock = usb_lock_device_for_reset(usb_dev, NULL);
> +     if (had_to_lock < 0) {
> +             if (had_to_lock != -ENODEV)     // ignore dissapearance
Comment with "//" above ...
> +                     dev_err(dev, "Cannot lock device for reset: %d\n",
> +                             had_to_lock);
> +     } else {
> +             result = usb_reset_device(usb_dev);
> +             if (result < 0 && result != -ENODEV)
> +                     dev_err(dev, "Unable to reset device: %d\n", result);
> +             if (had_to_lock)
> +                     usb_unlock_device(usb_dev);
> +     }
> +     usb_dev->delayed_reset = 0;
> +     usb_put_dev(usb_dev);
> +release:
> +     kfree(reset_ctx);
> +     module_put(THIS_MODULE);
> +}
> +
> +

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
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