net: rtlwifi: Remove void* casts related to delayed work

INIT_DELAYED_WORK() takes two arguments: A pointer to the delayed work and
a function reference for the callback.

The rtl code casts all function references to (void *) because the
callbacks in use are not matching the required function signature. That's
error prone and bad pratice.

Some of the callback functions are also global, but only used in a single
file.

Clean the mess up by:

  - Adding the proper arguments to the callback functions and using them in
    the container_of() constructs correctly which removes the hideous
    container_of_dwork_rtl() macro as well.

  - Removing the type cast at the initializers

  - Making the unnecessary global functions static

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Sebastian Andrzej Siewior 2020-09-29 22:25:43 +02:00 коммит произвёл David S. Miller
Родитель 021b58ef51
Коммит a3b7b227f1
5 изменённых файлов: 31 добавлений и 39 удалений

Просмотреть файл

@ -436,6 +436,10 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw)
} }
} }
static void rtl_watchdog_wq_callback(struct work_struct *work);
static void rtl_fwevt_wq_callback(struct work_struct *work);
static void rtl_c2hcmd_wq_callback(struct work_struct *work);
static void _rtl_init_deferred_work(struct ieee80211_hw *hw) static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
{ {
struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_priv *rtlpriv = rtl_priv(hw);
@ -454,17 +458,14 @@ static void _rtl_init_deferred_work(struct ieee80211_hw *hw)
} }
INIT_DELAYED_WORK(&rtlpriv->works.watchdog_wq, INIT_DELAYED_WORK(&rtlpriv->works.watchdog_wq,
(void *)rtl_watchdog_wq_callback); rtl_watchdog_wq_callback);
INIT_DELAYED_WORK(&rtlpriv->works.ips_nic_off_wq, INIT_DELAYED_WORK(&rtlpriv->works.ips_nic_off_wq,
(void *)rtl_ips_nic_off_wq_callback); rtl_ips_nic_off_wq_callback);
INIT_DELAYED_WORK(&rtlpriv->works.ps_work, INIT_DELAYED_WORK(&rtlpriv->works.ps_work, rtl_swlps_wq_callback);
(void *)rtl_swlps_wq_callback);
INIT_DELAYED_WORK(&rtlpriv->works.ps_rfon_wq, INIT_DELAYED_WORK(&rtlpriv->works.ps_rfon_wq,
(void *)rtl_swlps_rfon_wq_callback); rtl_swlps_rfon_wq_callback);
INIT_DELAYED_WORK(&rtlpriv->works.fwevt_wq, INIT_DELAYED_WORK(&rtlpriv->works.fwevt_wq, rtl_fwevt_wq_callback);
(void *)rtl_fwevt_wq_callback); INIT_DELAYED_WORK(&rtlpriv->works.c2hcmd_wq, rtl_c2hcmd_wq_callback);
INIT_DELAYED_WORK(&rtlpriv->works.c2hcmd_wq,
(void *)rtl_c2hcmd_wq_callback);
} }
void rtl_deinit_deferred_work(struct ieee80211_hw *hw, bool ips_wq) void rtl_deinit_deferred_work(struct ieee80211_hw *hw, bool ips_wq)
@ -2042,11 +2043,10 @@ label_err:
} }
EXPORT_SYMBOL(rtl_collect_scan_list); EXPORT_SYMBOL(rtl_collect_scan_list);
void rtl_watchdog_wq_callback(void *data) static void rtl_watchdog_wq_callback(struct work_struct *work)
{ {
struct rtl_works *rtlworks = container_of_dwork_rtl(data, struct rtl_works *rtlworks = container_of(work, struct rtl_works,
struct rtl_works, watchdog_wq.work);
watchdog_wq);
struct ieee80211_hw *hw = rtlworks->hw; struct ieee80211_hw *hw = rtlworks->hw;
struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
@ -2239,10 +2239,10 @@ void rtl_watch_dog_timer_callback(struct timer_list *t)
jiffies + MSECS(RTL_WATCH_DOG_TIME)); jiffies + MSECS(RTL_WATCH_DOG_TIME));
} }
void rtl_fwevt_wq_callback(void *data) static void rtl_fwevt_wq_callback(struct work_struct *work)
{ {
struct rtl_works *rtlworks = struct rtl_works *rtlworks = container_of(work, struct rtl_works,
container_of_dwork_rtl(data, struct rtl_works, fwevt_wq); fwevt_wq.work);
struct ieee80211_hw *hw = rtlworks->hw; struct ieee80211_hw *hw = rtlworks->hw;
struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_priv *rtlpriv = rtl_priv(hw);
@ -2368,11 +2368,10 @@ void rtl_c2hcmd_launcher(struct ieee80211_hw *hw, int exec)
} }
} }
void rtl_c2hcmd_wq_callback(void *data) static void rtl_c2hcmd_wq_callback(struct work_struct *work)
{ {
struct rtl_works *rtlworks = container_of_dwork_rtl(data, struct rtl_works *rtlworks = container_of(work, struct rtl_works,
struct rtl_works, c2hcmd_wq.work);
c2hcmd_wq);
struct ieee80211_hw *hw = rtlworks->hw; struct ieee80211_hw *hw = rtlworks->hw;
rtl_c2hcmd_launcher(hw, 1); rtl_c2hcmd_launcher(hw, 1);

Просмотреть файл

@ -108,9 +108,6 @@ int rtl_rx_agg_start(struct ieee80211_hw *hw,
int rtl_rx_agg_stop(struct ieee80211_hw *hw, int rtl_rx_agg_stop(struct ieee80211_hw *hw,
struct ieee80211_sta *sta, u16 tid); struct ieee80211_sta *sta, u16 tid);
void rtl_rx_ampdu_apply(struct rtl_priv *rtlpriv); void rtl_rx_ampdu_apply(struct rtl_priv *rtlpriv);
void rtl_watchdog_wq_callback(void *data);
void rtl_fwevt_wq_callback(void *data);
void rtl_c2hcmd_wq_callback(void *data);
void rtl_c2hcmd_launcher(struct ieee80211_hw *hw, int exec); void rtl_c2hcmd_launcher(struct ieee80211_hw *hw, int exec);
void rtl_c2hcmd_enqueue(struct ieee80211_hw *hw, struct sk_buff *skb); void rtl_c2hcmd_enqueue(struct ieee80211_hw *hw, struct sk_buff *skb);

Просмотреть файл

@ -179,10 +179,10 @@ static void _rtl_ps_inactive_ps(struct ieee80211_hw *hw)
ppsc->swrf_processing = false; ppsc->swrf_processing = false;
} }
void rtl_ips_nic_off_wq_callback(void *data) void rtl_ips_nic_off_wq_callback(struct work_struct *work)
{ {
struct rtl_works *rtlworks = struct rtl_works *rtlworks = container_of(work, struct rtl_works,
container_of_dwork_rtl(data, struct rtl_works, ips_nic_off_wq); ips_nic_off_wq.work);
struct ieee80211_hw *hw = rtlworks->hw; struct ieee80211_hw *hw = rtlworks->hw;
struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
@ -562,10 +562,10 @@ void rtl_swlps_rf_awake(struct ieee80211_hw *hw)
mutex_unlock(&rtlpriv->locks.lps_mutex); mutex_unlock(&rtlpriv->locks.lps_mutex);
} }
void rtl_swlps_rfon_wq_callback(void *data) void rtl_swlps_rfon_wq_callback(struct work_struct *work)
{ {
struct rtl_works *rtlworks = struct rtl_works *rtlworks = container_of(work, struct rtl_works,
container_of_dwork_rtl(data, struct rtl_works, ps_rfon_wq); ps_rfon_wq.work);
struct ieee80211_hw *hw = rtlworks->hw; struct ieee80211_hw *hw = rtlworks->hw;
rtl_swlps_rf_awake(hw); rtl_swlps_rf_awake(hw);
@ -675,11 +675,10 @@ void rtl_lps_leave(struct ieee80211_hw *hw)
} }
EXPORT_SYMBOL_GPL(rtl_lps_leave); EXPORT_SYMBOL_GPL(rtl_lps_leave);
void rtl_swlps_wq_callback(void *data) void rtl_swlps_wq_callback(struct work_struct *work)
{ {
struct rtl_works *rtlworks = container_of_dwork_rtl(data, struct rtl_works *rtlworks = container_of(work, struct rtl_works,
struct rtl_works, ps_work.work);
ps_work);
struct ieee80211_hw *hw = rtlworks->hw; struct ieee80211_hw *hw = rtlworks->hw;
struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_priv *rtlpriv = rtl_priv(hw);
bool ps = false; bool ps = false;

Просмотреть файл

@ -10,15 +10,15 @@ bool rtl_ps_enable_nic(struct ieee80211_hw *hw);
bool rtl_ps_disable_nic(struct ieee80211_hw *hw); bool rtl_ps_disable_nic(struct ieee80211_hw *hw);
void rtl_ips_nic_off(struct ieee80211_hw *hw); void rtl_ips_nic_off(struct ieee80211_hw *hw);
void rtl_ips_nic_on(struct ieee80211_hw *hw); void rtl_ips_nic_on(struct ieee80211_hw *hw);
void rtl_ips_nic_off_wq_callback(void *data); void rtl_ips_nic_off_wq_callback(struct work_struct *work);
void rtl_lps_enter(struct ieee80211_hw *hw); void rtl_lps_enter(struct ieee80211_hw *hw);
void rtl_lps_leave(struct ieee80211_hw *hw); void rtl_lps_leave(struct ieee80211_hw *hw);
void rtl_lps_set_psmode(struct ieee80211_hw *hw, u8 rt_psmode); void rtl_lps_set_psmode(struct ieee80211_hw *hw, u8 rt_psmode);
void rtl_swlps_beacon(struct ieee80211_hw *hw, void *data, unsigned int len); void rtl_swlps_beacon(struct ieee80211_hw *hw, void *data, unsigned int len);
void rtl_swlps_wq_callback(void *data); void rtl_swlps_wq_callback(struct work_struct *work);
void rtl_swlps_rfon_wq_callback(void *data); void rtl_swlps_rfon_wq_callback(struct work_struct *work);
void rtl_swlps_rf_awake(struct ieee80211_hw *hw); void rtl_swlps_rf_awake(struct ieee80211_hw *hw);
void rtl_swlps_rf_sleep(struct ieee80211_hw *hw); void rtl_swlps_rf_sleep(struct ieee80211_hw *hw);
void rtl_p2p_ps_cmd(struct ieee80211_hw *hw , u8 p2p_ps_state); void rtl_p2p_ps_cmd(struct ieee80211_hw *hw , u8 p2p_ps_state);

Просмотреть файл

@ -2936,9 +2936,6 @@ enum bt_radio_shared {
#define RT_SET_PS_LEVEL(ppsc, _ps_flg) \ #define RT_SET_PS_LEVEL(ppsc, _ps_flg) \
(ppsc->cur_ps_level |= _ps_flg) (ppsc->cur_ps_level |= _ps_flg)
#define container_of_dwork_rtl(x, y, z) \
container_of(to_delayed_work(x), y, z)
#define FILL_OCTET_STRING(_os, _octet, _len) \ #define FILL_OCTET_STRING(_os, _octet, _len) \
(_os).octet = (u8 *)(_octet); \ (_os).octet = (u8 *)(_octet); \
(_os).length = (_len); (_os).length = (_len);