xhci: Fix warning introduced by disabling runtime PM. 49/155649/1
authorSarah Sharp <sarah.a.sharp@linux.intel.com>
Wed, 28 Aug 2013 16:31:04 +0000 (09:31 -0700)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Mon, 16 Oct 2017 01:36:01 +0000 (10:36 +0900)
The 0day build server caught a new build warning that is triggered when
CONFIG_USB_DEFAULT_PERSIST is turned on:

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/sarah/xhci.git for-usb-next
head:   0730d52a86919300a39a2be37f6c140997dfb82f
commit: c8476fb855434c733099079063990e5bfa7ecad6 [1/3] usb: xhci: Disable runtime PM suspend for quirky controllers
config: i386-randconfig-r6-0826 (attached as .config)

All warnings:

   drivers/usb/host/xhci.c: In function 'xhci_free_dev':
>> drivers/usb/host/xhci.c:3560:17: warning: unused variable 'dev' [-Wunused-variable]
     struct device *dev = hcd->self.controller;
                    ^
   drivers/usb/host/xhci.c: In function 'xhci_alloc_dev':
>> drivers/usb/host/xhci.c:3648:17: warning: unused variable 'dev' [-Wunused-variable]
     struct device *dev = hcd->self.controller;
                    ^

vim +/dev +3560 drivers/usb/host/xhci.c

  3554   * disabled.  Free any HC data structures associated with that device.
  3555   */
  3556  void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
  3557  {
  3558          struct xhci_hcd *xhci = hcd_to_xhci(hcd);
  3559          struct xhci_virt_device *virt_dev;
> 3560          struct device *dev = hcd->self.controller;
  3561          unsigned long flags;
  3562          u32 state;
  3563          int i, ret;
  3564
  3565  #ifndef CONFIG_USB_DEFAULT_PERSIST
  3566          /*
  3567           * We called pm_runtime_get_noresume when the device was attached.
  3568           * Decrement the counter here to allow controller to runtime suspend
  3569           * if no devices remain.
  3570           */
  3571          if (xhci->quirks & XHCI_RESET_ON_RESUME)
  3572                  pm_runtime_put_noidle(dev);
  3573  #endif
  3574
...
  3641  /*
  3642   * Returns 0 if the xHC ran out of device slots, the Enable Slot command
  3643   * timed out, or allocating memory failed.  Returns 1 on success.
  3644   */
  3645  int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
  3646  {
  3647          struct xhci_hcd *xhci = hcd_to_xhci(hcd);
> 3648          struct device *dev = hcd->self.controller;
  3649          unsigned long flags;
  3650          int timeleft;
  3651          int ret;

Fix this.

Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: Shawn Nematbakhsh <shawnn@chromium.org>
[sw0312.kim: cherry-pick from mainline to remove build warning]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I16dccdaacd8736bf0b0169765bb4e46f6eb27fed

drivers/usb/host/xhci.c

index 10223f2..22b9076 100644 (file)
@@ -3503,7 +3503,6 @@ void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
 {
        struct xhci_hcd *xhci = hcd_to_xhci(hcd);
        struct xhci_virt_device *virt_dev;
-       struct device *dev = hcd->self.controller;
        unsigned long flags;
        u32 state;
        int i, ret;
@@ -3515,7 +3514,7 @@ void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
         * if no devices remain.
         */
        if (xhci->quirks & XHCI_RESET_ON_RESUME)
-               pm_runtime_put_noidle(dev);
+               pm_runtime_put_noidle(hcd->self.controller);
 #endif
 
        ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
@@ -3589,7 +3588,6 @@ static int xhci_reserve_host_control_ep_resources(struct xhci_hcd *xhci)
 int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
 {
        struct xhci_hcd *xhci = hcd_to_xhci(hcd);
-       struct device *dev = hcd->self.controller;
        unsigned long flags;
        int timeleft;
        int ret;
@@ -3649,7 +3647,7 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
         * suspend if there is a device attached.
         */
        if (xhci->quirks & XHCI_RESET_ON_RESUME)
-               pm_runtime_get_noresume(dev);
+               pm_runtime_get_noresume(hcd->self.controller);
 #endif
 
        /* Is this a LS or FS device under a HS hub? */