staging: rtl8712u: Fix suspend and resume callbacks
authorKai-Heng Feng <kai.heng.feng@canonical.com>
Sun, 13 Jan 2019 11:02:54 +0000 (19:02 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 15 Jan 2019 15:11:50 +0000 (16:11 +0100)
When system resume and the rtl8712u dongle didn't lose its power, it
doesn't work quite right:
[  146.844241] r8712u 2-3:1.0 wlp0s4f1u3: Unable to resume
...
[  154.029573] r8712u 2-3:1.0 wlp0s4f1u3: In r8711_wx_set_scan: bDriverStopped=1

The !netif_running() check in PM callbacks aren't correct because
rtl8712u doesn't support runtime suspend, so the when the PM ops get
called, it's system suspend or system resume, hence we want to "stop
everthing" or "resume everything".

The NULL check on pnetdev is also redundant, the only place pnetdev can
become NULL is the disconnect callback, which is mutually exclusive to
PM callbacks.

This can make rtl8712u starts working after system resume.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8712/usb_intf.c

index 9cf2a798cfcaddae09c7734be287944aab201415..005010de9997ba0c68da4aad5c9bdbd0a843a0f2 100644 (file)
@@ -196,10 +196,6 @@ static int r871x_suspend(struct usb_interface *pusb_intf, pm_message_t state)
        struct _adapter *padapter = netdev_priv(pnetdev);
 
        netdev_info(pnetdev, "Suspending...\n");
-       if (!pnetdev || !netif_running(pnetdev)) {
-               netdev_info(pnetdev, "Unable to suspend\n");
-               return 0;
-       }
        padapter->bSuspended = true;
        rtl871x_intf_stop(padapter);
        if (pnetdev->netdev_ops->ndo_stop)
@@ -221,10 +217,6 @@ static int r871x_resume(struct usb_interface *pusb_intf)
        struct _adapter *padapter = netdev_priv(pnetdev);
 
        netdev_info(pnetdev,  "Resuming...\n");
-       if (!pnetdev || !netif_running(pnetdev)) {
-               netdev_info(pnetdev, "Unable to resume\n");
-               return 0;
-       }
        netif_device_attach(pnetdev);
        if (pnetdev->netdev_ops->ndo_open)
                pnetdev->netdev_ops->ndo_open(pnetdev);