Message ID | 20240118202300.1616-1-oneukum@suse.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 7626c52b6b461b44a46cea4d51b4cf749657f5a8 |
Headers | show |
Series | usb: usb_autopm_get_interface use modern helper | expand |
On Thu, Jan 18, 2024 at 09:22:55PM +0100, Oliver Neukum wrote: > PM core now gives us a primitive that does not touch > the counter in an error case. Use it. > > Signed-off-by: Oliver Neukum <oneukum@suse.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> > --- > drivers/usb/core/driver.c | 8 ++------ > 1 file changed, 2 insertions(+), 6 deletions(-) > > diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c > index e01b1913d02b..e02ba15f6e34 100644 > --- a/drivers/usb/core/driver.c > +++ b/drivers/usb/core/driver.c > @@ -1710,9 +1710,7 @@ int usb_autoresume_device(struct usb_device *udev) > { > int status; > > - status = pm_runtime_get_sync(&udev->dev); > - if (status < 0) > - pm_runtime_put_sync(&udev->dev); > + status = pm_runtime_resume_and_get(&udev->dev); > dev_vdbg(&udev->dev, "%s: cnt %d -> %d\n", > __func__, atomic_read(&udev->dev.power.usage_count), > status); > @@ -1818,9 +1816,7 @@ int usb_autopm_get_interface(struct usb_interface *intf) > { > int status; > > - status = pm_runtime_get_sync(&intf->dev); > - if (status < 0) > - pm_runtime_put_sync(&intf->dev); > + status = pm_runtime_resume_and_get(&intf->dev); > dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n", > __func__, atomic_read(&intf->dev.power.usage_count), > status); > -- > 2.43.0 > >
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index e01b1913d02b..e02ba15f6e34 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -1710,9 +1710,7 @@ int usb_autoresume_device(struct usb_device *udev) { int status; - status = pm_runtime_get_sync(&udev->dev); - if (status < 0) - pm_runtime_put_sync(&udev->dev); + status = pm_runtime_resume_and_get(&udev->dev); dev_vdbg(&udev->dev, "%s: cnt %d -> %d\n", __func__, atomic_read(&udev->dev.power.usage_count), status); @@ -1818,9 +1816,7 @@ int usb_autopm_get_interface(struct usb_interface *intf) { int status; - status = pm_runtime_get_sync(&intf->dev); - if (status < 0) - pm_runtime_put_sync(&intf->dev); + status = pm_runtime_resume_and_get(&intf->dev); dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n", __func__, atomic_read(&intf->dev.power.usage_count), status);
PM core now gives us a primitive that does not touch the counter in an error case. Use it. Signed-off-by: Oliver Neukum <oneukum@suse.com> --- drivers/usb/core/driver.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)