Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [patch V2 34/36] net: rtlwifi: Remove void* casts related to delayed work
Date: Tue, 29 Sep 2020 22:25:43 +0200	[thread overview]
Message-ID: <20200929203502.866542017@linutronix.de> (raw)
In-Reply-To: 20200929202509.673358734@linutronix.de

From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

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>
---
 drivers/net/wireless/realtek/rtlwifi/base.c |   39 +++++++++++++---------------
 drivers/net/wireless/realtek/rtlwifi/base.h |    3 --
 drivers/net/wireless/realtek/rtlwifi/ps.c   |   19 ++++++-------
 drivers/net/wireless/realtek/rtlwifi/ps.h   |    6 ++--
 drivers/net/wireless/realtek/rtlwifi/wifi.h |    3 --
 5 files changed, 31 insertions(+), 39 deletions(-)

--- a/drivers/net/wireless/realtek/rtlwifi/base.c
+++ b/drivers/net/wireless/realtek/rtlwifi/base.c
@@ -436,6 +436,10 @@ static void _rtl_init_mac80211(struct ie
 	}
 }
 
+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)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
@@ -454,17 +458,14 @@ static void _rtl_init_deferred_work(stru
 	}
 
 	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,
-			  (void *)rtl_ips_nic_off_wq_callback);
-	INIT_DELAYED_WORK(&rtlpriv->works.ps_work,
-			  (void *)rtl_swlps_wq_callback);
+			  rtl_ips_nic_off_wq_callback);
+	INIT_DELAYED_WORK(&rtlpriv->works.ps_work, rtl_swlps_wq_callback);
 	INIT_DELAYED_WORK(&rtlpriv->works.ps_rfon_wq,
-			  (void *)rtl_swlps_rfon_wq_callback);
-	INIT_DELAYED_WORK(&rtlpriv->works.fwevt_wq,
-			  (void *)rtl_fwevt_wq_callback);
-	INIT_DELAYED_WORK(&rtlpriv->works.c2hcmd_wq,
-			  (void *)rtl_c2hcmd_wq_callback);
+			  rtl_swlps_rfon_wq_callback);
+	INIT_DELAYED_WORK(&rtlpriv->works.fwevt_wq, rtl_fwevt_wq_callback);
+	INIT_DELAYED_WORK(&rtlpriv->works.c2hcmd_wq, rtl_c2hcmd_wq_callback);
 }
 
 void rtl_deinit_deferred_work(struct ieee80211_hw *hw, bool ips_wq)
@@ -2042,11 +2043,10 @@ void rtl_collect_scan_list(struct ieee80
 }
 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,
-							    watchdog_wq);
+	struct rtl_works *rtlworks = container_of(work, struct rtl_works,
+						  watchdog_wq.work);
 	struct ieee80211_hw *hw = rtlworks->hw;
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
@@ -2239,10 +2239,10 @@ void rtl_watch_dog_timer_callback(struct
 		  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 =
-		container_of_dwork_rtl(data, struct rtl_works, fwevt_wq);
+	struct rtl_works *rtlworks = container_of(work, struct rtl_works,
+						  fwevt_wq.work);
 	struct ieee80211_hw *hw = rtlworks->hw;
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 
@@ -2368,11 +2368,10 @@ void rtl_c2hcmd_launcher(struct ieee8021
 	}
 }
 
-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,
-							    c2hcmd_wq);
+	struct rtl_works *rtlworks = container_of(work, struct rtl_works,
+						  c2hcmd_wq.work);
 	struct ieee80211_hw *hw = rtlworks->hw;
 
 	rtl_c2hcmd_launcher(hw, 1);
--- a/drivers/net/wireless/realtek/rtlwifi/base.h
+++ b/drivers/net/wireless/realtek/rtlwifi/base.h
@@ -108,9 +108,6 @@ int rtl_rx_agg_start(struct ieee80211_hw
 int rtl_rx_agg_stop(struct ieee80211_hw *hw,
 		    struct ieee80211_sta *sta, u16 tid);
 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_enqueue(struct ieee80211_hw *hw, struct sk_buff *skb);
 
--- a/drivers/net/wireless/realtek/rtlwifi/ps.c
+++ b/drivers/net/wireless/realtek/rtlwifi/ps.c
@@ -179,10 +179,10 @@ static void _rtl_ps_inactive_ps(struct i
 	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 =
-	    container_of_dwork_rtl(data, struct rtl_works, ips_nic_off_wq);
+	struct rtl_works *rtlworks = container_of(work, struct rtl_works,
+						  ips_nic_off_wq.work);
 	struct ieee80211_hw *hw = rtlworks->hw;
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
@@ -562,10 +562,10 @@ void rtl_swlps_rf_awake(struct ieee80211
 	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 =
-	    container_of_dwork_rtl(data, struct rtl_works, ps_rfon_wq);
+	struct rtl_works *rtlworks = container_of(work, struct rtl_works,
+						  ps_rfon_wq.work);
 	struct ieee80211_hw *hw = rtlworks->hw;
 
 	rtl_swlps_rf_awake(hw);
@@ -675,11 +675,10 @@ void rtl_lps_leave(struct ieee80211_hw *
 }
 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,
-				     ps_work);
+	struct rtl_works *rtlworks = container_of(work, struct rtl_works,
+						  ps_work.work);
 	struct ieee80211_hw *hw = rtlworks->hw;
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	bool ps = false;
--- a/drivers/net/wireless/realtek/rtlwifi/ps.h
+++ b/drivers/net/wireless/realtek/rtlwifi/ps.h
@@ -10,15 +10,15 @@ bool rtl_ps_enable_nic(struct ieee80211_
 bool rtl_ps_disable_nic(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_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_leave(struct ieee80211_hw *hw);
 
 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_wq_callback(void *data);
-void rtl_swlps_rfon_wq_callback(void *data);
+void rtl_swlps_wq_callback(struct work_struct *work);
+void rtl_swlps_rfon_wq_callback(struct work_struct *work);
 void rtl_swlps_rf_awake(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);
--- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
@@ -2936,9 +2936,6 @@ enum bt_radio_shared {
 #define	RT_SET_PS_LEVEL(ppsc, _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)	\
 		(_os).octet = (u8 *)(_octet);		\
 		(_os).length = (_len);



  parent reply	other threads:[~2020-09-29 20:25 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-29 20:25 [Intel-wired-lan] [patch V2 00/36] net: in_interrupt() cleanup and fixes Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 01/36] net: enic: Cure the enic api locking trainwreck Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 02/36] net: caif: Remove unused caif SPI driver Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 03/36] net: Add netif_rx_any_context() Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 04/36] net: caif: Use netif_rx_any_context() Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 05/36] net: atheros: Remove WARN_ON(in_interrupt()) Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 06/36] net: cxgb3: Cleanup in_interrupt() usage Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 07/36] net: cxbg4: Remove pointless in_interrupt() check Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 08/36] net: e100: Remove in_interrupt() usage and pointless GFP_ATOMIC allocation Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 09/36] net: fec_mpc52xx: Replace in_interrupt() usage Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 10/36] net: intel: Remove in_interrupt() warnings Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 11/36] net: ionic: Replace in_interrupt() usage Thomas Gleixner
2020-09-29 23:06   ` Shannon Nelson
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 12/36] net: ionic: Remove WARN_ON(in_interrupt()) Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 13/36] net: mdiobus: Remove WARN_ON_ONCE(in_interrupt()) Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 14/36] net: natsemi: Replace in_interrupt() usage Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 15/36] net: sfc: " Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 16/36] net: sfc: Use GFP_KERNEL in efx_ef10_try_update_nic_stats() Thomas Gleixner
2020-09-30  8:00   ` Martin Habets
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 17/36] net: sunbmac: Replace in_interrupt() usage Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 18/36] net: sun3lance: Remove redundant checks in interrupt handler Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 19/36] net: vxge: Remove in_interrupt() conditionals Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 20/36] net: zd1211rw: Remove ZD_ASSERT(in_interrupt()) Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 21/36] net: usb: kaweth: Replace kaweth_control() with usb_control_msg() Thomas Gleixner
2020-09-30  6:22   ` Greg Kroah-Hartman
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 22/36] net: usb: kaweth: Remove last user of kaweth_control() Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 23/36] net: usb: net1080: Remove in_interrupt() comment Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 24/36] net: wan/lmc: Remove lmc_trace() Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 25/36] net: brcmfmac: Replace in_interrupt() Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 26/36] net: brcmfmac: Convey execution context via argument to brcmf_netif_rx() Thomas Gleixner
2020-09-29 22:03   ` Arend Van Spriel
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 27/36] net: brcmfmac: Convey allocation mode as argument Thomas Gleixner
2020-09-29 22:07   ` Arend Van Spriel
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 28/36] net: ipw2x00, iwlegacy, iwlwifi: Remove in_interrupt() from debug macros Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 29/36] net: iwlwifi: Remove in_interrupt() from tracing macro Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 30/36] net: hostap: Remove in_interrupt() usage Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 31/36] net: mwifiex: Use netif_rx_any_context() Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 32/36] net: libertas libertas_tf: Remove in_interrupt() from debug macro Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 33/36] net: libertas: Use netif_rx_any_context() Thomas Gleixner
2020-09-29 21:53   ` James Cameron
2020-09-29 20:25 ` Thomas Gleixner [this message]
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 35/36] net: rtlwifi: Remove in_interrupt() from debug macro Thomas Gleixner
2020-09-29 20:25 ` [Intel-wired-lan] [patch V2 36/36] net: rtlwifi: Replace in_interrupt() for context detection Thomas Gleixner
2020-09-29 21:22 ` [Intel-wired-lan] [patch V2 00/36] net: in_interrupt() cleanup and fixes David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200929203502.866542017@linutronix.de \
    --to=tglx@linutronix.de \
    --cc=intel-wired-lan@osuosl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox