Commit 6c4a70c5 authored by Francois Romieu's avatar Francois Romieu

r8169: move task enable boolean to bitfield.

Simpler, more consistent, with negligible cost in non-critical paths.
Signed-off-by: default avatarFrancois Romieu <romieu@fr.zoreil.com>
Suggested-by: default avatarMichał Mirosław <mirqus@gmail.com>
Cc: Hayes Wang <hayeswang@realtek.com>
parent 98ddf986
...@@ -668,6 +668,7 @@ struct rtl8169_counters { ...@@ -668,6 +668,7 @@ struct rtl8169_counters {
}; };
enum rtl_flag { enum rtl_flag {
RTL_FLAG_TASK_ENABLED,
RTL_FLAG_TASK_SLOW_PENDING, RTL_FLAG_TASK_SLOW_PENDING,
RTL_FLAG_TASK_RESET_PENDING, RTL_FLAG_TASK_RESET_PENDING,
RTL_FLAG_TASK_PHY_PENDING, RTL_FLAG_TASK_PHY_PENDING,
...@@ -725,7 +726,6 @@ struct rtl8169_private { ...@@ -725,7 +726,6 @@ struct rtl8169_private {
DECLARE_BITMAP(flags, RTL_FLAG_MAX); DECLARE_BITMAP(flags, RTL_FLAG_MAX);
struct mutex mutex; struct mutex mutex;
struct work_struct work; struct work_struct work;
bool enabled;
} wk; } wk;
unsigned features; unsigned features;
...@@ -4352,7 +4352,7 @@ static int rtl8169_open(struct net_device *dev) ...@@ -4352,7 +4352,7 @@ static int rtl8169_open(struct net_device *dev)
rtl_lock_work(tp); rtl_lock_work(tp);
tp->wk.enabled = true; set_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags);
napi_enable(&tp->napi); napi_enable(&tp->napi);
...@@ -5879,7 +5879,8 @@ static void rtl_task(struct work_struct *work) ...@@ -5879,7 +5879,8 @@ static void rtl_task(struct work_struct *work)
rtl_lock_work(tp); rtl_lock_work(tp);
if (!netif_running(dev) || !tp->wk.enabled) if (!netif_running(dev) ||
!test_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags))
goto out_unlock; goto out_unlock;
for (i = 0; i < ARRAY_SIZE(rtl_work); i++) { for (i = 0; i < ARRAY_SIZE(rtl_work); i++) {
...@@ -5977,7 +5978,7 @@ static int rtl8169_close(struct net_device *dev) ...@@ -5977,7 +5978,7 @@ static int rtl8169_close(struct net_device *dev)
rtl8169_update_counters(dev); rtl8169_update_counters(dev);
rtl_lock_work(tp); rtl_lock_work(tp);
tp->wk.enabled = false; clear_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags);
rtl8169_down(dev); rtl8169_down(dev);
rtl_unlock_work(tp); rtl_unlock_work(tp);
...@@ -6076,7 +6077,7 @@ static void rtl8169_net_suspend(struct net_device *dev) ...@@ -6076,7 +6077,7 @@ static void rtl8169_net_suspend(struct net_device *dev)
rtl_lock_work(tp); rtl_lock_work(tp);
napi_disable(&tp->napi); napi_disable(&tp->napi);
tp->wk.enabled = false; clear_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags);
rtl_unlock_work(tp); rtl_unlock_work(tp);
rtl_pll_power_down(tp); rtl_pll_power_down(tp);
...@@ -6102,7 +6103,7 @@ static void __rtl8169_resume(struct net_device *dev) ...@@ -6102,7 +6103,7 @@ static void __rtl8169_resume(struct net_device *dev)
rtl_pll_power_up(tp); rtl_pll_power_up(tp);
tp->wk.enabled = true; set_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags);
rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING); rtl_schedule_task(tp, RTL_FLAG_TASK_RESET_PENDING);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment