Re: [PATCH v10 2/4] usb: add apis for offload usage tracking
From: Guan-Yu Lin
Date: Thu Apr 03 2025 - 03:35:01 EST
On Tue, Apr 1, 2025 at 10:24 PM Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On Tue, Apr 01, 2025 at 06:22:40AM +0000, Guan-Yu Lin wrote:
> > +
> > + /*
> > + * offload_usage could only be modified when the device is active, since
> > + * it will alter the suspend flow of the device.
> > + */
> > + ret = pm_runtime_resume_and_get(&udev->dev);
> > +
> > + if (ret < 0)
> > + return ret;
> > +
> > + refcount_inc(&udev->offload_usage);
> > + pm_runtime_put_sync(&udev->dev);
>
> The USB subsystem has wrappers: usb_autoresume_device() and
> usb_autosuspend_device(). You should use them instead of calling the
> runtime PM routines directly.
>
> The same advice applies to usb_offload_put().
>
> Alan Stern
Thanks for the suggestion, I'll include the change in the next version.