Skip to content

Commit c31a3c7

Browse files
hayesorzgregkh
authored andcommitted
r8152: split rtl8152_suspend function
[ Upstream commit 8fb280616878b81c0790a0c33acbeec59c5711f4 ] Split rtl8152_suspend() into rtl8152_system_suspend() and rtl8152_rumtime_suspend(). Signed-off-by: Hayes Wang <hayeswang@realtek.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 807cac8 commit c31a3c7

1 file changed

Lines changed: 40 additions & 17 deletions

File tree

drivers/net/usb/r8152.c

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3446,39 +3446,62 @@ static bool delay_autosuspend(struct r8152 *tp)
34463446
return false;
34473447
}
34483448

3449-
static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
3449+
static int rtl8152_rumtime_suspend(struct r8152 *tp)
34503450
{
3451-
struct r8152 *tp = usb_get_intfdata(intf);
34523451
struct net_device *netdev = tp->netdev;
34533452
int ret = 0;
34543453

3455-
mutex_lock(&tp->control);
3456-
3457-
if (PMSG_IS_AUTO(message)) {
3458-
if (netif_running(netdev) && delay_autosuspend(tp)) {
3454+
if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) {
3455+
if (delay_autosuspend(tp)) {
34593456
ret = -EBUSY;
34603457
goto out1;
34613458
}
34623459

3463-
set_bit(SELECTIVE_SUSPEND, &tp->flags);
3464-
} else {
3465-
netif_device_detach(netdev);
3460+
clear_bit(WORK_ENABLE, &tp->flags);
3461+
usb_kill_urb(tp->intr_urb);
3462+
napi_disable(&tp->napi);
3463+
rtl_stop_rx(tp);
3464+
rtl_runtime_suspend_enable(tp, true);
3465+
napi_enable(&tp->napi);
34663466
}
34673467

3468+
set_bit(SELECTIVE_SUSPEND, &tp->flags);
3469+
3470+
out1:
3471+
return ret;
3472+
}
3473+
3474+
static int rtl8152_system_suspend(struct r8152 *tp)
3475+
{
3476+
struct net_device *netdev = tp->netdev;
3477+
int ret = 0;
3478+
3479+
netif_device_detach(netdev);
3480+
34683481
if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) {
34693482
clear_bit(WORK_ENABLE, &tp->flags);
34703483
usb_kill_urb(tp->intr_urb);
34713484
napi_disable(&tp->napi);
3472-
if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) {
3473-
rtl_stop_rx(tp);
3474-
rtl_runtime_suspend_enable(tp, true);
3475-
} else {
3476-
cancel_delayed_work_sync(&tp->schedule);
3477-
tp->rtl_ops.down(tp);
3478-
}
3485+
cancel_delayed_work_sync(&tp->schedule);
3486+
tp->rtl_ops.down(tp);
34793487
napi_enable(&tp->napi);
34803488
}
3481-
out1:
3489+
3490+
return ret;
3491+
}
3492+
3493+
static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message)
3494+
{
3495+
struct r8152 *tp = usb_get_intfdata(intf);
3496+
int ret;
3497+
3498+
mutex_lock(&tp->control);
3499+
3500+
if (PMSG_IS_AUTO(message))
3501+
ret = rtl8152_rumtime_suspend(tp);
3502+
else
3503+
ret = rtl8152_system_suspend(tp);
3504+
34823505
mutex_unlock(&tp->control);
34833506

34843507
return ret;

0 commit comments

Comments
 (0)