Skip to contentSkip to conversation

rtlwifi: Neatening

PATCH In review Joe Perches 2 participants 8 messages Jun 19, 2017 – Jun 22, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover rtlwifi: Neatening

Joe Perches (5):
rtlwifi: Use temporary ops variable to reduce code size
rtlwifi: Use temporary variable btc_ops for rtlpriv->btcoexist.btc_ops
rtlwifi: Add and use convenience macro rtl_btc
realtek: btcoexist: Make the rtl_btc_ops struct const
realtek: rtlwifi: drivers: Use the rtl_btc convenience macro

 drivers/net/wireless/realtek/rtlwifi/base.c        |  46 ++--
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c   |   4 +-
 .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.h   |   2 +-
 drivers/net/wireless/realtek/rtlwifi/core.c        | 189 ++++++++--------
 drivers/net/wireless/realtek/rtlwifi/efuse.c       |   9 +-
 drivers/net/wireless/realtek/rtlwifi/pci.c         | 242 +++++++++++----------
 drivers/net/wireless/realtek/rtlwifi/ps.c          |  83 +++----
 .../net/wireless/realtek/rtlwifi/rtl8192ee/hw.c    |   3 +-
 .../wireless/realtek/rtlwifi/rtl8723ae/hal_btc.c   |   4 +-
 .../net/wireless/realtek/rtlwifi/rtl8723ae/hw.c    |   3 +-
 .../net/wireless/realtek/rtlwifi/rtl8723be/hw.c    |   3 +-
 .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.c    |   6 +-
 .../net/wireless/realtek/rtlwifi/rtl8821ae/hw.c    |   3 +-
 drivers/net/wireless/realtek/rtlwifi/usb.c         |  40 ++--
 drivers/net/wireless/realtek/rtlwifi/wifi.h        |   9 +-
 15 files changed, 336 insertions(+), 310 deletions(-)
Signature · 1 line
2.10.0.rc2.1.g053435c
#1 lore raw

PATCH 1/5 rtlwifi: Use temporary ops variable to reduce code size

rtlpriv->cfg->ops-><fn> is used frequently in the source.

Repeated use of this multiply dereferenced table creates larger objects.

Using a temporary reduces code size as well as source code line length.

$ size -t drivers/net/wireless/realtek/rtlwifi/*.o.defconfig.new
   text	   data	    bss	    dec	    hex	filename
  12652	   3024	     24	  15700	   3d54	[...]/base.o.defconfig.new
  16700	     83	      0	  16783	   418f	[...]/core.o.defconfig.new
  10794	      0	      4	  10798	   2a2e	[...]/efuse.o.defconfig.new
  20988	      5	      0	  20993	   5201	[...]/pci.o.defconfig.new
   6182	      8	      0	   6190	   182e	[...]/ps.o.defconfig.new
   8410	      1	      4	   8415	   20df	[...]/usb.o.defconfig.new
  75726	   3121	     32	  78879	  1341f	(TOTALS)
$ size -t drivers/net/wireless/realtek/rtlwifi/*.o.defconfig.old
   text	   data	    bss	    dec	    hex	filename
  12604	   3024	     24	  15652	   3d24	[...]/base.o.defconfig.old
  16892	     83	      0	  16975	   424f	[...]/core.o.defconfig.old
  10794	      0	      4	  10798	   2a2e	[...]/efuse.o.defconfig.old
  21161	      5	      0	  21166	   52ae	[...]/pci.o.defconfig.old
   6262	      8	      0	   6270	   187e	[...]/ps.o.defconfig.old
   8435	      1	      4	   8440	   20f8	[...]/usb.o.defconfig.old
  76148	   3121	     32	  79301	  135c5	(TOTALS)

Miscellanea around modified code:

o Fix a few misindented code blocks
o Realign arguments
o Ignored 80 column checkpatch warnings

---
 drivers/net/wireless/realtek/rtlwifi/base.c  |  45 ++---
 drivers/net/wireless/realtek/rtlwifi/core.c  | 187 +++++++++++----------
 drivers/net/wireless/realtek/rtlwifi/efuse.c |   9 +-
 drivers/net/wireless/realtek/rtlwifi/pci.c   | 236 ++++++++++++++-------------
 drivers/net/wireless/realtek/rtlwifi/ps.c    |  75 +++++----
 drivers/net/wireless/realtek/rtlwifi/usb.c   |  40 +++--
 6 files changed, 313 insertions(+), 279 deletions(-)
drivers/net/wireless/realtek/rtlwifi/base.c +24 -21
index 710e5b447cff..4436addcace3 100644
@@ -498,7 +498,7 @@ EXPORT_SYMBOL_GPL(rtl_deinit_deferred_work);
 void rtl_init_rfkill(struct ieee80211_hw *hw)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
-
+	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
 	bool radio_state;
 	bool blocked;
 	u8 valid = 0;
@@ -507,7 +507,7 @@ void rtl_init_rfkill(struct ieee80211_hw *hw)
 	rtlpriv->rfkill.rfkill_state = true;
 	wiphy_rfkill_set_hw_state(hw->wiphy, 0);
 
-	radio_state = rtlpriv->cfg->ops->radio_onoff_checking(hw, &valid);
+	radio_state = ops->radio_onoff_checking(hw, &valid);
 
 	if (valid) {
 		pr_info("rtlwifi: wireless switch is %s\n",
@@ -588,8 +588,9 @@ void rtl_init_rx_config(struct ieee80211_hw *hw)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
+	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
 
-	rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RCR, (u8 *) (&mac->rx_conf));
+	ops->get_hw_reg(hw, HW_VAR_RCR, (u8 *)&mac->rx_conf);
 }
 EXPORT_SYMBOL_GPL(rtl_init_rx_config);
 
@@ -1178,13 +1179,14 @@ bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb)
 {
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
 	__le16 fc = rtl_get_fc(skb);
 
 	if (rtlpriv->dm.supp_phymode_switch &&
 	    mac->link_state < MAC80211_LINKED &&
 	    (ieee80211_is_auth(fc) || ieee80211_is_probe_req(fc))) {
-		if (rtlpriv->cfg->ops->chk_switch_dmdp)
-			rtlpriv->cfg->ops->chk_switch_dmdp(hw);
+		if (ops->chk_switch_dmdp)
+			ops->chk_switch_dmdp(hw);
 	}
 	if (ieee80211_is_auth(fc)) {
 		RT_TRACE(rtlpriv, COMP_SEND, DBG_DMESG, "MAC80211_LINKING\n");
@@ -1309,11 +1311,12 @@ EXPORT_SYMBOL_GPL(rtl_action_proc);
 static void setup_arp_tx(struct rtl_priv *rtlpriv, struct rtl_ps_ctl *ppsc)
 {
 	struct ieee80211_hw *hw = rtlpriv->hw;
+	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
 
 	rtlpriv->ra.is_special_data = true;
-	if (rtlpriv->cfg->ops->get_btc_status())
+	if (ops->get_btc_status())
 		rtlpriv->btcoexist.btc_ops->btc_special_packet_notify(
-					rtlpriv, 1);
+			rtlpriv, 1);
 	rtl_lps_leave(hw);
 	ppsc->last_delaylps_stamp_jiffies = jiffies;
 }
@@ -1571,6 +1574,7 @@ void rtl_watchdog_wq_callback(void *data)
 							    watchdog_wq);
 	struct ieee80211_hw *hw = rtlworks->hw;
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
 	bool busytraffic = false;
@@ -1683,7 +1687,7 @@ void rtl_watchdog_wq_callback(void *data)
 
 	/* <3> DM */
 	if (!rtlpriv->cfg->mod_params->disable_watchdog)
-		rtlpriv->cfg->ops->dm_watchdog(hw);
+		ops->dm_watchdog(hw);
 
 	/* <4> roaming */
 	if (mac->link_state == MAC80211_LINKED &&
@@ -1709,7 +1713,7 @@ void rtl_watchdog_wq_callback(void *data)
 		}
 	}
 
-	if (rtlpriv->cfg->ops->get_btc_status())
+	if (ops->get_btc_status())
 		rtlpriv->btcoexist.btc_ops->btc_periodical(rtlpriv);
 
 	rtlpriv->link_info.bcn_rx_inperiod = 0;
@@ -1732,8 +1736,9 @@ void rtl_fwevt_wq_callback(void *data)
 		container_of_dwork_rtl(data, struct rtl_works, fwevt_wq);
 	struct ieee80211_hw *hw = rtlworks->hw;
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
 
-	rtlpriv->cfg->ops->c2h_command_handle(hw);
+	ops->c2h_command_handle(hw);
 }
 
 void rtl_c2hcmd_enqueue(struct ieee80211_hw *hw, u8 tag, u8 len, u8 *val)
@@ -1783,6 +1788,7 @@ EXPORT_SYMBOL(rtl_c2hcmd_enqueue);
 void rtl_c2hcmd_launcher(struct ieee80211_hw *hw, int exec)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
 	unsigned long flags;
 	struct rtl_c2hcmd *c2hcmd;
 	int i;
@@ -1803,9 +1809,9 @@ void rtl_c2hcmd_launcher(struct ieee80211_hw *hw, int exec)
 		if (!c2hcmd)
 			break;
 
-		if (rtlpriv->cfg->ops->c2h_content_parsing && exec)
-			rtlpriv->cfg->ops->c2h_content_parsing(hw,
-					c2hcmd->tag, c2hcmd->len, c2hcmd->val);
+		if (ops->c2h_content_parsing && exec)
+			ops->c2h_content_parsing(hw, c2hcmd->tag, c2hcmd->len,
+						 c2hcmd->val);
 
 		/* free */
 		kfree(c2hcmd->val);
@@ -1828,12 +1834,13 @@ void rtl_easy_concurrent_retrytimer_callback(unsigned long data)
 {
 	struct ieee80211_hw *hw = (struct ieee80211_hw *)data;
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
 	struct rtl_priv *buddy_priv = rtlpriv->buddy_priv;
 
 	if (buddy_priv == NULL)
 		return;
 
-	rtlpriv->cfg->ops->dualmac_easy_concurrent(hw);
+	ops->dualmac_easy_concurrent(hw);
 }
 /*********************************************************
  *
@@ -1944,7 +1951,6 @@ int rtl_send_smps_action(struct ieee80211_hw *hw,
 		struct rtl_sta_info *sta_entry =
 			(struct rtl_sta_info *) sta->drv_priv;
 		sta_entry->mimo_ps = smps;
-		/* rtlpriv->cfg->ops->update_rate_tbl(hw, sta, 0); */
 
 		info->control.rates[0].idx = 0;
 		info->band = hw->conf.chandef.chan->band;
@@ -1960,6 +1966,7 @@ EXPORT_SYMBOL(rtl_send_smps_action);
 void rtl_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 	enum io_type iotype;
 
@@ -1967,15 +1974,11 @@ void rtl_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation)
 		switch (operation) {
 		case SCAN_OPT_BACKUP:
 			iotype = IO_CMD_PAUSE_DM_BY_SCAN;
-			rtlpriv->cfg->ops->set_hw_reg(hw,
-						      HW_VAR_IO_CMD,
-						      (u8 *)&iotype);
+			ops->set_hw_reg(hw, HW_VAR_IO_CMD, (u8 *)&iotype);
 			break;
 		case SCAN_OPT_RESTORE:
 			iotype = IO_CMD_RESUME_DM_BY_SCAN;
-			rtlpriv->cfg->ops->set_hw_reg(hw,
-						      HW_VAR_IO_CMD,
-						      (u8 *)&iotype);
+			ops->set_hw_reg(hw, HW_VAR_IO_CMD, (u8 *)&iotype);
 			break;
 		default:
 			pr_err("Unknown Scan Backup operation.\n");
drivers/net/wireless/realtek/rtlwifi/core.c +98 -89

554 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/efuse.c +5 -4
index ef9acd466cca..7d5eb55031cf 100644
@@ -229,6 +229,7 @@ EXPORT_SYMBOL_GPL(read_efuse_byte);
 void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
 	struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
 	u8 *efuse_tbl;
 	u8 rtemp8[1];
@@ -365,10 +366,10 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf)
 	rtlefuse->efuse_usedbytes = efuse_utilized;
 	efuse_usage = (u8) ((efuse_utilized * 100) / efuse_len);
 	rtlefuse->efuse_usedpercentage = efuse_usage;
-	rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_EFUSE_BYTES,
-				      (u8 *)&efuse_utilized);
-	rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_EFUSE_USAGE,
-				      &efuse_usage);
+	ops->set_hw_reg(hw, HW_VAR_EFUSE_BYTES,
+			(u8 *)&efuse_utilized);
+	ops->set_hw_reg(hw, HW_VAR_EFUSE_USAGE,
+			&efuse_usage);
 done:
 	for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++)
 		kfree(efuse_word[i]);
drivers/net/wireless/realtek/rtlwifi/pci.c +121 -115

543 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/ps.c +41 -34

213 lines not on this page · raw message

drivers/net/wireless/realtek/rtlwifi/usb.c +24 -16
index 5590d07d0918..1da29bf07318 100644
@@ -442,6 +442,7 @@ static void _rtl_usb_rx_process_agg(struct ieee80211_hw *hw,
 				    struct sk_buff *skb)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
 	u8 *rxdesc = skb->data;
 	struct ieee80211_hdr *hdr;
 	bool unicast = false;
@@ -453,7 +454,7 @@ static void _rtl_usb_rx_process_agg(struct ieee80211_hw *hw,
 	};
 
 	skb_pull(skb, RTL_RX_DESC_SIZE);
-	rtlpriv->cfg->ops->query_rx_desc(hw, &stats, &rx_status, rxdesc, skb);
+	ops->query_rx_desc(hw, &stats, &rx_status, rxdesc, skb);
 	skb_pull(skb, (stats.rx_drvinfo_size + stats.rx_bufshift));
 	hdr = (struct ieee80211_hdr *)(skb->data);
 	fc = hdr->frame_control;
@@ -470,7 +471,7 @@ static void _rtl_usb_rx_process_agg(struct ieee80211_hw *hw,
 		}
 
 		if (ieee80211_is_data(fc)) {
-			rtlpriv->cfg->ops->led_control(hw, LED_CTL_RX);
+			ops->led_control(hw, LED_CTL_RX);
 
 			if (unicast)
 				rtlpriv->link_info.num_rx_inperiod++;
@@ -484,6 +485,7 @@ static void _rtl_usb_rx_process_noagg(struct ieee80211_hw *hw,
 				      struct sk_buff *skb)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
 	u8 *rxdesc = skb->data;
 	struct ieee80211_hdr *hdr;
 	bool unicast = false;
@@ -495,7 +497,7 @@ static void _rtl_usb_rx_process_noagg(struct ieee80211_hw *hw,
 	};
 
 	skb_pull(skb, RTL_RX_DESC_SIZE);
-	rtlpriv->cfg->ops->query_rx_desc(hw, &stats, &rx_status, rxdesc, skb);
+	ops->query_rx_desc(hw, &stats, &rx_status, rxdesc, skb);
 	skb_pull(skb, (stats.rx_drvinfo_size + stats.rx_bufshift));
 	hdr = (struct ieee80211_hdr *)(skb->data);
 	fc = hdr->frame_control;
@@ -512,7 +514,7 @@ static void _rtl_usb_rx_process_noagg(struct ieee80211_hw *hw,
 		}
 
 		if (ieee80211_is_data(fc)) {
-			rtlpriv->cfg->ops->led_control(hw, LED_CTL_RX);
+			ops->led_control(hw, LED_CTL_RX);
 
 			if (unicast)
 				rtlpriv->link_info.num_rx_inperiod++;
@@ -755,10 +757,11 @@ static int rtl_usb_start(struct ieee80211_hw *hw)
 {
 	int err;
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 	struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
 
-	err = rtlpriv->cfg->ops->hw_init(hw);
+	err = ops->hw_init(hw);
 	if (!err) {
 		rtl_init_rx_config(hw);
 
@@ -816,6 +819,7 @@ static void rtl_usb_deinit(struct ieee80211_hw *hw)
 static void rtl_usb_stop(struct ieee80211_hw *hw)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 	struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
 	struct urb *urb;
@@ -842,7 +846,7 @@ static void rtl_usb_stop(struct ieee80211_hw *hw)
 		usb_free_urb(urb);
 	}
 
-	rtlpriv->cfg->ops->hw_disable(hw);
+	ops->hw_disable(hw);
 }
 
 static void _rtl_submit_tx_urb(struct ieee80211_hw *hw, struct urb *_urb)
@@ -952,6 +956,7 @@ static void _rtl_usb_tx_preprocess(struct ieee80211_hw *hw,
 				   u16 hw_queue)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
 	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
 	struct rtl_tx_desc *pdesc = NULL;
@@ -991,14 +996,14 @@ static void _rtl_usb_tx_preprocess(struct ieee80211_hw *hw,
 		seq_number += 1;
 		seq_number <<= 4;
 	}
-	rtlpriv->cfg->ops->fill_tx_desc(hw, hdr, (u8 *)pdesc, NULL, info, sta, skb,
-					hw_queue, &tcb_desc);
+	ops->fill_tx_desc(hw, hdr, (u8 *)pdesc, NULL, info, sta, skb,
+			  hw_queue, &tcb_desc);
 	if (!ieee80211_has_morefrags(hdr->frame_control)) {
 		if (qc)
 			mac->tids[tid].seq_number = seq_number;
 	}
 	if (ieee80211_is_data(fc))
-		rtlpriv->cfg->ops->led_control(hw, LED_CTL_TX);
+		ops->led_control(hw, LED_CTL_TX);
 }
 
 static int rtl_usb_tx(struct ieee80211_hw *hw,
@@ -1037,8 +1042,9 @@ static void rtl_fill_h2c_cmd_work_callback(struct work_struct *work)
 	    container_of(work, struct rtl_works, fill_h2c_cmd);
 	struct ieee80211_hw *hw = rtlworks->hw;
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
 
-	rtlpriv->cfg->ops->fill_h2c_cmd(hw, H2C_RA_MASK, 5, rtlpriv->rate_mask);
+	ops->fill_h2c_cmd(hw, H2C_RA_MASK, 5, rtlpriv->rate_mask);
 }
 
 static const struct rtl_intf_ops rtl_usb_ops = {
@@ -1055,6 +1061,7 @@ int rtl_usb_probe(struct usb_interface *intf,
 	int err;
 	struct ieee80211_hw *hw = NULL;
 	struct rtl_priv *rtlpriv = NULL;
+	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
 	struct usb_device	*udev;
 	struct rtl_usb_priv *usb_priv;
 
@@ -1094,9 +1101,9 @@ int rtl_usb_probe(struct usb_interface *intf,
 	rtlpriv->intf_ops = &rtl_usb_ops;
 	/* Init IO handler */
 	_rtl_usb_io_handler_init(&udev->dev, hw);
-	rtlpriv->cfg->ops->read_chip_version(hw);
+	ops->read_chip_version(hw);
 	/*like read eeprom and so on */
-	rtlpriv->cfg->ops->read_eeprom_info(hw);
+	ops->read_eeprom_info(hw);
 	err = _rtl_usb_init(hw);
 	if (err)
 		goto error_out;
@@ -1107,11 +1114,11 @@ int rtl_usb_probe(struct usb_interface *intf,
 		pr_err("Can't allocate sw for mac80211\n");
 		goto error_out;
 	}
-	if (rtlpriv->cfg->ops->init_sw_vars(hw)) {
+	if (ops->init_sw_vars(hw)) {
 		pr_err("Can't init_sw_vars\n");
 		goto error_out;
 	}
-	rtlpriv->cfg->ops->init_sw_leds(hw);
+	ops->init_sw_leds(hw);
 
 	err = ieee80211_register_hw(hw);
 	if (err) {
@@ -1137,6 +1144,7 @@ void rtl_usb_disconnect(struct usb_interface *intf)
 {
 	struct ieee80211_hw *hw = usb_get_intfdata(intf);
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
+	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
 	struct rtl_mac *rtlmac = rtl_mac(rtl_priv(hw));
 	struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
 
@@ -1158,8 +1166,8 @@ void rtl_usb_disconnect(struct usb_interface *intf)
 	rtl_usb_deinit(hw);
 	rtl_deinit_core(hw);
 	kfree(rtlpriv->usb_data);
-	rtlpriv->cfg->ops->deinit_sw_leds(hw);
-	rtlpriv->cfg->ops->deinit_sw_vars(hw);
+	ops->deinit_sw_leds(hw);
+	ops->deinit_sw_vars(hw);
 	_rtl_usb_io_handler_release(hw);
 	usb_put_dev(rtlusb->udev);
 	usb_set_intfdata(intf, NULL);
Signature · 1 line
2.10.0.rc2.1.g053435c
#2 lore raw

PATCH 2/5 rtlwifi: Use temporary variable btc_ops for rtlpriv->btcoexist.btc_ops

In reply to Joe Perches

Reduce the code line length a little.

---
 drivers/net/wireless/realtek/rtlwifi/base.c |  7 ++++---
 drivers/net/wireless/realtek/rtlwifi/core.c | 10 ++++++----
 drivers/net/wireless/realtek/rtlwifi/pci.c  |  8 +++++---
 drivers/net/wireless/realtek/rtlwifi/ps.c   | 16 ++++++++++------
 4 files changed, 25 insertions(+), 16 deletions(-)
drivers/net/wireless/realtek/rtlwifi/base.c +4 -3
index 4436addcace3..cc4b50e1b7e5 100644
@@ -1312,11 +1312,11 @@ static void setup_arp_tx(struct rtl_priv *rtlpriv, struct rtl_ps_ctl *ppsc)
 {
 	struct ieee80211_hw *hw = rtlpriv->hw;
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
+	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 
 	rtlpriv->ra.is_special_data = true;
 	if (ops->get_btc_status())
-		rtlpriv->btcoexist.btc_ops->btc_special_packet_notify(
-			rtlpriv, 1);
+		btc_ops->btc_special_packet_notify(rtlpriv, 1);
 	rtl_lps_leave(hw);
 	ppsc->last_delaylps_stamp_jiffies = jiffies;
 }
@@ -1575,6 +1575,7 @@ void rtl_watchdog_wq_callback(void *data)
 	struct ieee80211_hw *hw = rtlworks->hw;
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
+	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
 	bool busytraffic = false;
@@ -1714,7 +1715,7 @@ void rtl_watchdog_wq_callback(void *data)
 	}
 
 	if (ops->get_btc_status())
-		rtlpriv->btcoexist.btc_ops->btc_periodical(rtlpriv);
+		btc_ops->btc_periodical(rtlpriv);
 
 	rtlpriv->link_info.bcn_rx_inperiod = 0;
 }
drivers/net/wireless/realtek/rtlwifi/core.c +6 -4
index 63f5c0cd6935..e08febc2d0d6 100644
@@ -1046,6 +1046,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
+	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 	struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
@@ -1193,8 +1194,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
 				      true : false;
 
 		if (ops->get_btc_status())
-			rtlpriv->btcoexist.btc_ops->btc_mediastatus_notify(
-				rtlpriv, mstatus);
+			btc_ops->btc_mediastatus_notify(rtlpriv, mstatus);
 	}
 
 	if (changed & BSS_CHANGED_ERP_CTS_PROT) {
@@ -1428,6 +1428,7 @@ static void rtl_op_sw_scan_start(struct ieee80211_hw *hw,
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
+	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
 
 	RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "\n");
@@ -1438,7 +1439,7 @@ static void rtl_op_sw_scan_start(struct ieee80211_hw *hw,
 	}
 
 	if (ops->get_btc_status())
-		rtlpriv->btcoexist.btc_ops->btc_scan_notify(rtlpriv, 1);
+		btc_ops->btc_scan_notify(rtlpriv, 1);
 
 	if (rtlpriv->dm.supp_phymode_switch) {
 		if (ops->chk_switch_dmdp)
@@ -1464,6 +1465,7 @@ static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw,
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
+	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
 
 	RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "\n");
@@ -1491,7 +1493,7 @@ static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw,
 
 	ops->scan_operation_backup(hw, SCAN_OPT_RESTORE);
 	if (ops->get_btc_status())
-		rtlpriv->btcoexist.btc_ops->btc_scan_notify(rtlpriv, 0);
+		btc_ops->btc_scan_notify(rtlpriv, 0);
 }
 
 static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
drivers/net/wireless/realtek/rtlwifi/pci.c +5 -3
index 81c36978df8a..f129c4c76c05 100644
@@ -1814,6 +1814,7 @@ static int rtl_pci_start(struct ieee80211_hw *hw)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
+	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
@@ -1826,8 +1827,8 @@ static int rtl_pci_start(struct ieee80211_hw *hw)
 	rtlpci->driver_is_goingto_unload = false;
 	if (ops->get_btc_status &&
 	    ops->get_btc_status()) {
-		rtlpriv->btcoexist.btc_ops->btc_init_variables(rtlpriv);
-		rtlpriv->btcoexist.btc_ops->btc_init_hal_vars(rtlpriv);
+		btc_ops->btc_init_variables(rtlpriv);
+		btc_ops->btc_init_hal_vars(rtlpriv);
 	}
 	err = ops->hw_init(hw);
 	if (err) {
@@ -1858,6 +1859,7 @@ static void rtl_pci_stop(struct ieee80211_hw *hw)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
+	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
@@ -1865,7 +1867,7 @@ static void rtl_pci_stop(struct ieee80211_hw *hw)
 	u8 RFInProgressTimeOut = 0;
 
 	if (ops->get_btc_status())
-		rtlpriv->btcoexist.btc_ops->btc_halt_notify();
+		btc_ops->btc_halt_notify();
 
 	/*
 	 *should be before disable interrupt&adapter
drivers/net/wireless/realtek/rtlwifi/ps.c +10 -6
index 5a51e56c5f47..3cd8a387c845 100644
@@ -210,6 +210,7 @@ void rtl_ips_nic_off_wq_callback(void *data)
 	struct ieee80211_hw *hw = rtlworks->hw;
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
+	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
@@ -261,8 +262,8 @@ void rtl_ips_nic_off_wq_callback(void *data)
 
 			/* call before RF off */
 			if (ops->get_btc_status())
-				rtlpriv->btcoexist.btc_ops->btc_ips_notify(rtlpriv,
-									   ppsc->inactive_pwrstate);
+				btc_ops->btc_ips_notify(rtlpriv,
+							ppsc->inactive_pwrstate);
 
 			/*rtl_pci_reset_trx_ring(hw); */
 			_rtl_ps_inactive_ps(hw);
@@ -289,6 +290,7 @@ void rtl_ips_nic_on(struct ieee80211_hw *hw)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
+	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
 	enum rf_pwrstate rtstate;
 
@@ -307,8 +309,8 @@ void rtl_ips_nic_on(struct ieee80211_hw *hw)
 			_rtl_ps_inactive_ps(hw);
 			/* call after RF on */
 			if (ops->get_btc_status())
-				rtlpriv->btcoexist.btc_ops->btc_ips_notify(rtlpriv,
-									   ppsc->inactive_pwrstate);
+				btc_ops->btc_ips_notify(rtlpriv,
+							ppsc->inactive_pwrstate);
 		}
 	}
 	spin_unlock(&rtlpriv->locks.ips_lock);
@@ -352,6 +354,7 @@ void rtl_lps_set_psmode(struct ieee80211_hw *hw, u8 rt_psmode)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
+	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
 	bool enter_fwlps;
@@ -392,14 +395,15 @@ void rtl_lps_set_psmode(struct ieee80211_hw *hw, u8 rt_psmode)
 				rtl_p2p_ps_cmd(hw , P2P_PS_ENABLE);
 
 			if (ops->get_btc_status())
-				rtlpriv->btcoexist.btc_ops->btc_lps_notify(rtlpriv, rt_psmode);
+				btc_ops->btc_lps_notify(rtlpriv, rt_psmode);
 		} else {
 			if (rtl_get_fwlps_doze(hw)) {
 				RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
 					 "FW LPS enter ps_mode:%x\n",
 					 ppsc->fwctrl_psmode);
 				if (ops->get_btc_status())
-					rtlpriv->btcoexist.btc_ops->btc_lps_notify(rtlpriv, rt_psmode);
+					btc_ops->btc_lps_notify(rtlpriv,
+								rt_psmode);
 				enter_fwlps = true;
 				ppsc->pwr_mode = ppsc->fwctrl_psmode;
 				ppsc->smart_ps = 2;
Signature · 1 line
2.10.0.rc2.1.g053435c
#3 lore raw

PATCH 3/5 rtlwifi: Add and use convenience macro rtl_btc

In reply to Joe Perches

bluetooth coexistence functions always check get_btc_status before accessing the function. Centralize this via a convenience macro to neaten the source code a little.

---
 drivers/net/wireless/realtek/rtlwifi/base.c |  8 ++------
 drivers/net/wireless/realtek/rtlwifi/core.c | 12 +++---------
 drivers/net/wireless/realtek/rtlwifi/pci.c  |  4 +---
 drivers/net/wireless/realtek/rtlwifi/ps.c   | 24 ++++++++++--------------
 drivers/net/wireless/realtek/rtlwifi/wifi.h |  7 +++++++
 5 files changed, 23 insertions(+), 32 deletions(-)
drivers/net/wireless/realtek/rtlwifi/base.c +2 -6
index cc4b50e1b7e5..997dd692e6bb 100644
@@ -1312,11 +1312,9 @@ static void setup_arp_tx(struct rtl_priv *rtlpriv, struct rtl_ps_ctl *ppsc)
 {
 	struct ieee80211_hw *hw = rtlpriv->hw;
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
-	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 
 	rtlpriv->ra.is_special_data = true;
-	if (ops->get_btc_status())
-		btc_ops->btc_special_packet_notify(rtlpriv, 1);
+	rtl_btc(rtlpriv, ops, btc_special_packet_notify(rtlpriv, 1));
 	rtl_lps_leave(hw);
 	ppsc->last_delaylps_stamp_jiffies = jiffies;
 }
@@ -1575,7 +1573,6 @@ void rtl_watchdog_wq_callback(void *data)
 	struct ieee80211_hw *hw = rtlworks->hw;
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
-	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
 	bool busytraffic = false;
@@ -1714,8 +1711,7 @@ void rtl_watchdog_wq_callback(void *data)
 		}
 	}
 
-	if (ops->get_btc_status())
-		btc_ops->btc_periodical(rtlpriv);
+	rtl_btc(rtlpriv, ops, btc_periodical(rtlpriv));
 
 	rtlpriv->link_info.bcn_rx_inperiod = 0;
 }
drivers/net/wireless/realtek/rtlwifi/core.c +3 -9
index e08febc2d0d6..8d3eddeeffea 100644
@@ -1046,7 +1046,6 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
-	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 	struct rtl_hal *rtlhal = rtl_hal(rtlpriv);
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
@@ -1193,8 +1192,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw *hw,
 		ppsc->report_linked = (mstatus == RT_MEDIA_CONNECT) ?
 				      true : false;
 
-		if (ops->get_btc_status())
-			btc_ops->btc_mediastatus_notify(rtlpriv, mstatus);
+		rtl_btc(rtlpriv, ops, btc_mediastatus_notify(rtlpriv, mstatus));
 	}
 
 	if (changed & BSS_CHANGED_ERP_CTS_PROT) {
@@ -1428,7 +1426,6 @@ static void rtl_op_sw_scan_start(struct ieee80211_hw *hw,
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
-	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
 
 	RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "\n");
@@ -1438,8 +1435,7 @@ static void rtl_op_sw_scan_start(struct ieee80211_hw *hw,
 		return;
 	}
 
-	if (ops->get_btc_status())
-		btc_ops->btc_scan_notify(rtlpriv, 1);
+	rtl_btc(rtlpriv, ops, btc_scan_notify(rtlpriv, 1));
 
 	if (rtlpriv->dm.supp_phymode_switch) {
 		if (ops->chk_switch_dmdp)
@@ -1465,7 +1461,6 @@ static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw,
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
-	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
 
 	RT_TRACE(rtlpriv, COMP_MAC80211, DBG_LOUD, "\n");
@@ -1492,8 +1487,7 @@ static void rtl_op_sw_scan_complete(struct ieee80211_hw *hw,
 	}
 
 	ops->scan_operation_backup(hw, SCAN_OPT_RESTORE);
-	if (ops->get_btc_status())
-		btc_ops->btc_scan_notify(rtlpriv, 0);
+	rtl_btc(rtlpriv, ops, btc_scan_notify(rtlpriv, 0));
 }
 
 static int rtl_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
drivers/net/wireless/realtek/rtlwifi/pci.c +1 -3
index f129c4c76c05..fa93401acdab 100644
@@ -1859,15 +1859,13 @@ static void rtl_pci_stop(struct ieee80211_hw *hw)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
-	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 	unsigned long flags;
 	u8 RFInProgressTimeOut = 0;
 
-	if (ops->get_btc_status())
-		btc_ops->btc_halt_notify();
+	rtl_btc(rtlpriv, ops, btc_halt_notify());
 
 	/*
 	 *should be before disable interrupt&adapter
drivers/net/wireless/realtek/rtlwifi/ps.c +10 -14
index 3cd8a387c845..8babc4a70ac2 100644
@@ -210,7 +210,6 @@ void rtl_ips_nic_off_wq_callback(void *data)
 	struct ieee80211_hw *hw = rtlworks->hw;
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
-	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
@@ -261,9 +260,9 @@ void rtl_ips_nic_off_wq_callback(void *data)
 			ppsc->in_powersavemode = true;
 
 			/* call before RF off */
-			if (ops->get_btc_status())
-				btc_ops->btc_ips_notify(rtlpriv,
-							ppsc->inactive_pwrstate);
+			rtl_btc(rtlpriv, ops,
+				btc_ips_notify(rtlpriv,
+					       ppsc->inactive_pwrstate));
 
 			/*rtl_pci_reset_trx_ring(hw); */
 			_rtl_ps_inactive_ps(hw);
@@ -290,7 +289,6 @@ void rtl_ips_nic_on(struct ieee80211_hw *hw)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
-	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
 	enum rf_pwrstate rtstate;
 
@@ -308,9 +306,9 @@ void rtl_ips_nic_on(struct ieee80211_hw *hw)
 			ppsc->in_powersavemode = false;
 			_rtl_ps_inactive_ps(hw);
 			/* call after RF on */
-			if (ops->get_btc_status())
-				btc_ops->btc_ips_notify(rtlpriv,
-							ppsc->inactive_pwrstate);
+			rtl_btc(rtlpriv, ops,
+				btc_ips_notify(rtlpriv,
+					       ppsc->inactive_pwrstate));
 		}
 	}
 	spin_unlock(&rtlpriv->locks.ips_lock);
@@ -354,7 +352,6 @@ void rtl_lps_set_psmode(struct ieee80211_hw *hw, u8 rt_psmode)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
-	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
 	bool enter_fwlps;
@@ -394,16 +391,15 @@ void rtl_lps_set_psmode(struct ieee80211_hw *hw, u8 rt_psmode)
 			if (ppsc->p2p_ps_info.opp_ps)
 				rtl_p2p_ps_cmd(hw , P2P_PS_ENABLE);
 
-			if (ops->get_btc_status())
-				btc_ops->btc_lps_notify(rtlpriv, rt_psmode);
+			rtl_btc(rtlpriv, ops,
+				btc_lps_notify(rtlpriv, rt_psmode));
 		} else {
 			if (rtl_get_fwlps_doze(hw)) {
 				RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
 					 "FW LPS enter ps_mode:%x\n",
 					 ppsc->fwctrl_psmode);
-				if (ops->get_btc_status())
-					btc_ops->btc_lps_notify(rtlpriv,
-								rt_psmode);
+				rtl_btc(rtlpriv, ops,
+					btc_lps_notify(rtlpriv, rt_psmode));
 				enter_fwlps = true;
 				ppsc->pwr_mode = ppsc->fwctrl_psmode;
 				ppsc->smart_ps = 2;
drivers/net/wireless/realtek/rtlwifi/wifi.h +7 -0
index c0d2601bc55f..9a916188a703 100644
@@ -2552,6 +2552,13 @@ struct rtl_btc_ops {
 					  u8 pkt_type);
 };
 
+/* Convenience macro for accessing rtl_btc_ops() functions */
+#define rtl_btc(rtlpriv, ops, func)					\
+do {									\
+	if ((ops)->get_btc_status())					\
+		(rtlpriv)->btcoexist.btc_ops->func;			\
+} while (0)
+
 struct proxim {
 	bool proxim_on;
 
Signature · 1 line
2.10.0.rc2.1.g053435c
#4 lore raw

PATCH 4/5 realtek: btcoexist: Make the rtl_btc_ops struct const

In reply to Joe Perches

Avoid allowing a write into what should be const.

---
 drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c | 4 ++--
 drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h | 2 +-
 drivers/net/wireless/realtek/rtlwifi/pci.c               | 2 +-
 drivers/net/wireless/realtek/rtlwifi/wifi.h              | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.c +2 -2
index 3ab0cfe26513..19a95b69255d 100644
@@ -29,7 +29,7 @@
 #include "rtl_btc.h"
 #include "halbt_precomp.h"
 
-static struct rtl_btc_ops rtl_btc_operation = {
+static const struct rtl_btc_ops rtl_btc_operation = {
 	.btc_init_variables = rtl_btc_init_variables,
 	.btc_init_hal_vars = rtl_btc_init_hal_vars,
 	.btc_init_hw_config = rtl_btc_init_hw_config,
@@ -161,7 +161,7 @@ void rtl_btc_special_packet_notify(struct rtl_priv *rtlpriv, u8 pkt_type)
 	return exhalbtc_special_packet_notify(&gl_bt_coexist, pkt_type);
 }
 
-struct rtl_btc_ops *rtl_btc_get_ops_pointer(void)
+const struct rtl_btc_ops *rtl_btc_get_ops_pointer(void)
 {
 	return &rtl_btc_operation;
 }
drivers/net/wireless/realtek/rtlwifi/btcoexist/rtl_btc.h +1 -1
index fff5117e1c4e..83c5bb2d6ad8 100644
@@ -44,7 +44,7 @@ bool rtl_btc_is_disable_edca_turbo(struct rtl_priv *rtlpriv);
 bool rtl_btc_is_bt_disabled(struct rtl_priv *rtlpriv);
 void rtl_btc_special_packet_notify(struct rtl_priv *rtlpriv, u8 pkt_type);
 
-struct rtl_btc_ops *rtl_btc_get_ops_pointer(void);
+const struct rtl_btc_ops *rtl_btc_get_ops_pointer(void);
 
 u8 rtl_get_hwpg_bt_exist(struct rtl_priv *rtlpriv);
 u8 rtl_get_hwpg_bt_type(struct rtl_priv *rtlpriv);
drivers/net/wireless/realtek/rtlwifi/pci.c +1 -1
index fa93401acdab..8000894c4212 100644
@@ -1814,7 +1814,7 @@ static int rtl_pci_start(struct ieee80211_hw *hw)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_hal_ops *ops = rtlpriv->cfg->ops;
-	struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
+	const struct rtl_btc_ops *btc_ops = rtlpriv->btcoexist.btc_ops;
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
 	struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
drivers/net/wireless/realtek/rtlwifi/wifi.h +1 -1
index 9a916188a703..d03f0ca92530 100644
@@ -2475,7 +2475,7 @@ struct rtl_btc_info {
 };
 
 struct bt_coexist_info {
-	struct rtl_btc_ops *btc_ops;
+	const struct rtl_btc_ops *btc_ops;
 	struct rtl_btc_info btc_info;
 	/* EEPROM BT info. */
 	u8 eeprom_bt_coexist;
Signature · 1 line
2.10.0.rc2.1.g053435c
#5 lore raw

PATCH 5/5 realtek: rtlwifi: drivers: Use the rtl_btc convenience macro

In reply to Joe Perches

Convert the uses of the btcoexist.<funcs> to the rtl_btc macro to save a few lines of code.

---
 drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c      | 3 +--
 drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hal_btc.c | 4 +---
 drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c      | 3 +--
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c      | 3 +--
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c      | 6 ++----
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c      | 3 +--
 6 files changed, 7 insertions(+), 15 deletions(-)
drivers/net/wireless/realtek/rtlwifi/rtl8192ee/hw.c +1 -2
index 11d97fa0e921..9fc3e79e5a43 100644
@@ -2572,8 +2572,7 @@ void rtl92ee_bt_hw_init(struct ieee80211_hw *hw)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 
-	if (rtlpriv->cfg->ops->get_btc_status())
-		rtlpriv->btcoexist.btc_ops->btc_init_hw_config(rtlpriv);
+	rtl_btc(rtlpriv, rtlpriv->cfg->ops, btc_init_hw_config(rtlpriv));
 }
 
 void rtl92ee_suspend(struct ieee80211_hw *hw)
drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hal_btc.c +1 -3
index ec9bcf32f0ab..8621ea8f6644 100644
@@ -1767,9 +1767,7 @@ void rtl_8723e_c2h_command_handle(struct ieee80211_hw *hw)
 
 		rtl8723e_dm_bt_parse_bt_info(hw, ptmp_buf, c2h_event.cmd_len);
 
-		if (rtlpriv->cfg->ops->get_btc_status())
-			rtlpriv->btcoexist.btc_ops->btc_periodical(rtlpriv);
-
+		rtl_btc(rtlpriv, rtlpriv->cfg->ops, btc_periodical(rtlpriv));
 		break;
 	default:
 		break;
drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c +1 -2
index 5ac7b815648a..3b6d140bb863 100644
@@ -2419,8 +2419,7 @@ void rtl8723e_bt_hw_init(struct ieee80211_hw *hw)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 
-	if (rtlpriv->cfg->ops->get_btc_status())
-		rtlpriv->btcoexist.btc_ops->btc_init_hw_config(rtlpriv);
+	rtl_btc(rtlpriv, rtlpriv->cfg->ops, btc_init_hw_config(rtlpriv));
 }
 
 void rtl8723e_suspend(struct ieee80211_hw *hw)
drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c +1 -2
index a79f936bb394..bddc4f56832d 100644
@@ -2719,8 +2719,7 @@ void rtl8723be_bt_hw_init(struct ieee80211_hw *hw)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 
-	if (rtlpriv->cfg->ops->get_btc_status())
-		rtlpriv->btcoexist.btc_ops->btc_init_hw_config(rtlpriv);
+	rtl_btc(rtlpriv, rtlpriv->cfg->ops, btc_init_hw_config(rtlpriv));
 
 }
 
drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c +2 -4
index 73350103b736..a7a537716a8e 100644
@@ -1879,10 +1879,8 @@ void rtl8821ae_c2h_content_parsing(struct ieee80211_hw *hw,
 	case C2H_8812_BT_INFO:
 		RT_TRACE(rtlpriv, COMP_FW, DBG_LOUD,
 			 "[C2H], C2H_8812_BT_INFO!!\n");
-		if (rtlpriv->cfg->ops->get_btc_status())
-			rtlpriv->btcoexist.btc_ops->btc_btinfo_notify(rtlpriv,
-								      tmp_buf,
-								      c2h_cmd_len);
+		rtl_btc(rtlpriv, rtlpriv->cfg->ops,
+			btc_btinfo_notify(rtlpriv, tmp_buf, c2h_cmd_len));
 		break;
 	default:
 		break;
drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c +1 -2
index 2bc6bace069c..f76c64570d16 100644
@@ -4012,8 +4012,7 @@ void rtl8821ae_bt_hw_init(struct ieee80211_hw *hw)
 {
 	struct rtl_priv *rtlpriv = rtl_priv(hw);
 
-	if (rtlpriv->cfg->ops->get_btc_status())
-		rtlpriv->btcoexist.btc_ops->btc_init_hw_config(rtlpriv);
+	rtl_btc(rtlpriv, rtlpriv->cfg->ops, btc_init_hw_config(rtlpriv));
 }
 
 void rtl8821ae_suspend(struct ieee80211_hw *hw)
Signature · 1 line
2.10.0.rc2.1.g053435c
#6 lore raw
In reply to Joe Perches
Quoted 7 lines · Joe Perches

Joe Perches (5):
rtlwifi: Use temporary ops variable to reduce code size
rtlwifi: Use temporary variable btc_ops for rtlpriv->btcoexist.btc_ops
rtlwifi: Add and use convenience macro rtl_btc
realtek: btcoexist: Make the rtl_btc_ops struct const
realtek: rtlwifi: drivers: Use the rtl_btc convenience macro

Quoted 17 lines
  drivers/net/wireless/realtek/rtlwifi/base.c        |  46 ++--
  .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.c   |   4 +-
  .../wireless/realtek/rtlwifi/btcoexist/rtl_btc.h   |   2 +-
  drivers/net/wireless/realtek/rtlwifi/core.c        | 189 ++++++++--------
  drivers/net/wireless/realtek/rtlwifi/efuse.c       |   9 +-
  drivers/net/wireless/realtek/rtlwifi/pci.c         | 242 +++++++++++----------
  drivers/net/wireless/realtek/rtlwifi/ps.c          |  83 +++----
  .../net/wireless/realtek/rtlwifi/rtl8192ee/hw.c    |   3 +-
  .../wireless/realtek/rtlwifi/rtl8723ae/hal_btc.c   |   4 +-
  .../net/wireless/realtek/rtlwifi/rtl8723ae/hw.c    |   3 +-
  .../net/wireless/realtek/rtlwifi/rtl8723be/hw.c    |   3 +-
  .../net/wireless/realtek/rtlwifi/rtl8821ae/fw.c    |   6 +-
  .../net/wireless/realtek/rtlwifi/rtl8821ae/hw.c    |   3 +-
  drivers/net/wireless/realtek/rtlwifi/usb.c         |  40 ++--
  drivers/net/wireless/realtek/rtlwifi/wifi.h        |   9 +-
  15 files changed, 336 insertions(+), 310 deletions(-)

Joe,

In general, I approve of your patches. Unfortunately, they will conflict with a number of changes that I am currently making. If you would like, I can merge your patches, fix the conflicts, and submit a version 2 for you.

Larry

#7 lore raw
Quoted 1 line · Larry Finger

On 06/19/2017 03:18 PM, Joe Perches wrote:

[]

Quoted 3 lines

In general, I approve of your patches. Unfortunately, they will conflict with a number of changes that I am currently making. If you would like, I can merge your patches, fix the conflicts, and submit a version 2 for you.

Sure, thanks.