* Tony Lindgren <t...@atomide.com> [161108 18:26]:
> * Johan Hovold <jo...@kernel.org> [161108 12:03]:
> +int musb_queue_resume_work(struct musb *musb,
> +                        int (*callback)(struct musb *musb, void *data),
> +                        void *data)
> +{
> +     struct musb_pending_work *w;
> +     unsigned long flags;
> +     int error;
> +
> +     if (WARN_ON(!callback))
> +             return -EINVAL;
> +
> +     if (pm_runtime_active(musb->controller))
> +             return callback(musb, data);
> +
> +     w = devm_kzalloc(musb->controller, sizeof(*w), GFP_ATOMIC);
> +     if (!w)
> +             return -ENOMEM;
> +
> +     w->callback = callback;
> +     w->data = data;
> +     spin_lock_irqsave(&musb->list_lock, flags);
> +     if (musb->is_runtime_suspended) {
> +             list_add_tail(&w->node, &musb->pending_list);
> +             error = 0;
> +     } else {
> +             dev_err(musb->controller, "could not add resume work %p\n",
> +                     callback);
> +             devm_kfree(musb->controller, w);
> +             error = -EINPROGRESS;
> +     }
> +     spin_unlock_irqrestore(&musb->list_lock, flags);
> +
> +     if (pm_runtime_active(musb->controller))
> +             return musb_run_resume_work(musb);
> +
> +     return error;
> +}

Hmm I think we can also leave out musb_run_resume_work() at the end,
we should not hit that case any longer.

Regards,

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to