ath6kl: create ath6kl_core.ko
v2 cover ath6kl: create ath6kl_core.ko
Here's the patchset to fix the allyesconfig build breakage. The fix is to create a separate module ath6kl_core.ko which both ath6kl_sdio.ko and ath6kl_usb.ko use.
v2:
o fix ath6kl_dbg() to use va_format correctly (thanks to joe)
o improved commit log in patch 4
---
Kalle Valo (6):
ath6kl: rename vif init and cleanup functions
ath6kl: unify cfg80211 init/cleanup functions
ath6kl: create core.c
ath6kl: get rid of AR_DBG_LVL_CHECK()
ath6kl: convert ath6kl_dbg() and ath6kl_dbg_dump() into functions
ath6kl: create ath6kl_core.ko
drivers/net/wireless/ath/ath6kl/Makefile | 35 +-- drivers/net/wireless/ath/ath6kl/cfg80211.c | 207 ++++++++------------ drivers/net/wireless/ath/ath6kl/cfg80211.h | 12 + drivers/net/wireless/ath/ath6kl/common.h | 3 drivers/net/wireless/ath/ath6kl/core.c | 297 ++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath6kl/core.h | 10 + drivers/net/wireless/ath/ath6kl/debug.c | 68 +++++- drivers/net/wireless/ath/ath6kl/debug.h | 27 --- drivers/net/wireless/ath/ath6kl/hif.c | 10 + drivers/net/wireless/ath/ath6kl/init.c | 211 +------------------- drivers/net/wireless/ath/ath6kl/sdio.c | 4 drivers/net/wireless/ath/ath6kl/usb.c | 8 - drivers/net/wireless/ath/ath6kl/wmi.c | 3 13 files changed, 484 insertions(+), 411 deletions(-) create mode 100644 drivers/net/wireless/ath/ath6kl/core.c
PATCH v2 1/6 ath6kl: rename vif init and cleanup functions
ath6kl_cfg80211_vif_init/cleanup() follow more closely the style used elsewhere in ath6kl.
--- drivers/net/wireless/ath/ath6kl/cfg80211.c | 9 ++++----- drivers/net/wireless/ath/ath6kl/cfg80211.h | 2 ++ drivers/net/wireless/ath/ath6kl/core.h | 1 - drivers/net/wireless/ath/ath6kl/init.c | 5 +++-- 4 files changed, 9 insertions(+), 8 deletions(-)
drivers/net/wireless/ath/ath6kl/cfg80211.c +4 -5
@@ -1403,7 +1403,7 @@ static int ath6kl_cfg80211_del_iface(struct wiphy *wiphy,ath6kl_cleanup_vif (vif,test_bit (WMI_READY , &ar->flag)); -ath6kl_deinit_if_data (vif); +ath6kl_cfg80211_vif_cleanup (vif);return 0 ; }
@@ -2742,7 +2742,7 @@ int ath6kl_register_ieee80211_hw(struct ath6kl *ar)return 0 ; } -static int ath6kl_init_if_data (struct ath6kl_vif *vif) +static int ath6kl_cfg80211_vif_init (struct ath6kl_vif *vif) { vif->aggr_cntxt =aggr_init (vif->ndev);if (!vif->aggr_cntxt) {
@@ -2761,7 +2761,7 @@ static int ath6kl_init_if_data(struct ath6kl_vif *vif)return 0 ; } -void ath6kl_deinit_if_data (struct ath6kl_vif *vif) +void ath6kl_cfg80211_vif_cleanup (struct ath6kl_vif *vif) {struct ath6kl *ar = vif->ar;
@@ -2808,8 +2808,7 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name,ath6kl_init_control_info (vif); -/* TODO: Pass interface specific pointer instead of ar */ -if (ath6kl_init_if_data (vif)) +if (ath6kl_cfg80211_vif_init (vif)) goto err;if (register_netdevice (ndev))
drivers/net/wireless/ath/ath6kl/cfg80211.h +2 -0
@@ -53,6 +53,8 @@ int ath6kl_cfg80211_suspend(struct ath6kl *ar,int ath6kl_cfg80211_resume (struct ath6kl *ar); +void ath6kl_cfg80211_vif_cleanup (struct ath6kl_vif *vif); +void ath6kl_cfg80211_stop (struct ath6kl_vif *vif);void ath6kl_cfg80211_stop_all (struct ath6kl *ar);
drivers/net/wireless/ath/ath6kl/core.h +0 -1
@@ -723,7 +723,6 @@ void ath6kl_wakeup_event(void *dev);void ath6kl_reset_device (struct ath6kl *ar,u32 target_type,bool wait_fot_compltn,bool cold_reset);void ath6kl_init_control_info (struct ath6kl_vif *vif); -void ath6kl_deinit_if_data (struct ath6kl_vif *vif);void ath6kl_core_free (struct ath6kl *ar);struct ath6kl_vif *ath6kl_vif_first (struct ath6kl *ar);void ath6kl_cleanup_vif (struct ath6kl_vif *vif,bool wmi_ready);
drivers/net/wireless/ath/ath6kl/init.c +3 -2
@@ -1695,7 +1695,7 @@ err_rxbuf_cleanup:ath6kl_htc_flush_rx_buf (ar->htc_target);ath6kl_cleanup_amsdu_rxbufs (ar);rtnl_lock (); -ath6kl_deinit_if_data (netdev_priv (ndev)); +ath6kl_cfg80211_vif_cleanup (netdev_priv (ndev));rtnl_unlock ();wiphy_unregister (ar->wiphy); err_debug_init:
@@ -1716,6 +1716,7 @@ err_wq:return ret; } +/* FIXME: move this to cfg80211.c and rename to ath6kl_cfg80211_vif_stop() */ void ath6kl_cleanup_vif (struct ath6kl_vif *vif,bool wmi_ready) {static u8 bcast_mac[] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff };
@@ -1761,7 +1762,7 @@ void ath6kl_stop_txrx(struct ath6kl *ar)spin_unlock_bh (&ar->list_lock);ath6kl_cleanup_vif (vif,test_bit (WMI_READY , &ar->flag));rtnl_lock (); -ath6kl_deinit_if_data (vif); +ath6kl_cfg80211_vif_cleanup (vif);rtnl_unlock ();spin_lock_bh (&ar->list_lock); }
PATCH v2 2/6 ath6kl: unify cfg80211 init/cleanup functions
In reply to Kalle ValoGroup them together and change the naming to follow the common style in ath6kl. No functional changes.
--- drivers/net/wireless/ath/ath6kl/cfg80211.c | 109 +++++++++++++++------------- drivers/net/wireless/ath/ath6kl/cfg80211.h | 6 +- drivers/net/wireless/ath/ath6kl/init.c | 4 + 3 files changed, 62 insertions(+), 57 deletions(-)
drivers/net/wireless/ath/ath6kl/cfg80211.c +57 -52
@@ -2691,57 +2691,6 @@ struct ath6kl *ath6kl_core_alloc(struct device *dev)return ar; } -int ath6kl_register_ieee80211_hw (struct ath6kl *ar) -{ -struct wiphy *wiphy = ar->wiphy; -int ret; - - wiphy->mgmt_stypes = ath6kl_mgmt_stypes; - - wiphy->max_remain_on_channel_duration =5000 ; - -/* set device pointer for wiphy */ -set_wiphy_dev (wiphy, ar->dev); - - wiphy->interface_modes =BIT (NL80211_IFTYPE_STATION ) | -BIT (NL80211_IFTYPE_ADHOC ) | -BIT (NL80211_IFTYPE_AP ); -if (ar->p2p) { - wiphy->interface_modes |=BIT (NL80211_IFTYPE_P2P_GO ) | -BIT (NL80211_IFTYPE_P2P_CLIENT ); - } - -/* max num of ssids that can be probed during scanning */ - wiphy->max_scan_ssids =MAX_PROBED_SSID_INDEX ; - wiphy->max_scan_ie_len =1000 ;/* FIX: what is correct limit? */ - wiphy->bands[IEEE80211_BAND_2GHZ ] = &ath6kl_band_2ghz; - wiphy->bands[IEEE80211_BAND_5GHZ ] = &ath6kl_band_5ghz; - wiphy->signal_type =CFG80211_SIGNAL_TYPE_MBM ; - - wiphy->cipher_suites = cipher_suites; - wiphy->n_cipher_suites =ARRAY_SIZE (cipher_suites); - - wiphy->wowlan.flags =WIPHY_WOWLAN_MAGIC_PKT | -WIPHY_WOWLAN_DISCONNECT | -WIPHY_WOWLAN_GTK_REKEY_FAILURE | -WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | -WIPHY_WOWLAN_EAP_IDENTITY_REQ | -WIPHY_WOWLAN_4WAY_HANDSHAKE ; - wiphy->wowlan.n_patterns =WOW_MAX_FILTERS_PER_LIST ; - wiphy->wowlan.pattern_min_len =1 ; - wiphy->wowlan.pattern_max_len =WOW_PATTERN_SIZE ; - - wiphy->max_sched_scan_ssids =10 ; - - ret =wiphy_register (wiphy); -if (ret <0 ) { -ath6kl_err ("couldn't register wiphy device\n" ); -return ret; - } - -return 0 ; -} -static int ath6kl_cfg80211_vif_init (struct ath6kl_vif *vif) { vif->aggr_cntxt =aggr_init (vif->ndev);
@@ -2835,8 +2784,64 @@ err:return NULL ; } -void ath6kl_deinit_ieee80211_hw (struct ath6kl *ar) +int ath6kl_cfg80211_init (struct ath6kl *ar) +{ +struct wiphy *wiphy = ar->wiphy; +int ret; + + wiphy->mgmt_stypes = ath6kl_mgmt_stypes; + + wiphy->max_remain_on_channel_duration =5000 ; + +/* set device pointer for wiphy */ +set_wiphy_dev (wiphy, ar->dev); + + wiphy->interface_modes =BIT (NL80211_IFTYPE_STATION ) | +BIT (NL80211_IFTYPE_ADHOC ) | +BIT (NL80211_IFTYPE_AP ); +if (ar->p2p) { + wiphy->interface_modes |=BIT (NL80211_IFTYPE_P2P_GO ) | +BIT (NL80211_IFTYPE_P2P_CLIENT ); + } + +/* max num of ssids that can be probed during scanning */ + wiphy->max_scan_ssids =MAX_PROBED_SSID_INDEX ; + wiphy->max_scan_ie_len =1000 ;/* FIX: what is correct limit? */ + wiphy->bands[IEEE80211_BAND_2GHZ ] = &ath6kl_band_2ghz; + wiphy->bands[IEEE80211_BAND_5GHZ ] = &ath6kl_band_5ghz; + wiphy->signal_type =CFG80211_SIGNAL_TYPE_MBM ; + + wiphy->cipher_suites = cipher_suites; + wiphy->n_cipher_suites =ARRAY_SIZE (cipher_suites); + + wiphy->wowlan.flags =WIPHY_WOWLAN_MAGIC_PKT | +WIPHY_WOWLAN_DISCONNECT | +WIPHY_WOWLAN_GTK_REKEY_FAILURE | +WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | +WIPHY_WOWLAN_EAP_IDENTITY_REQ | +WIPHY_WOWLAN_4WAY_HANDSHAKE ; + wiphy->wowlan.n_patterns =WOW_MAX_FILTERS_PER_LIST ; + wiphy->wowlan.pattern_min_len =1 ; + wiphy->wowlan.pattern_max_len =WOW_PATTERN_SIZE ; + + wiphy->max_sched_scan_ssids =10 ; + + ret =wiphy_register (wiphy); +if (ret <0 ) { +ath6kl_err ("couldn't register wiphy device\n" ); +return ret; + } + +return 0 ; +} + +void ath6kl_cfg80211_cleanup (struct ath6kl *ar) {wiphy_unregister (ar->wiphy); + +/* +* FIXME: should be removed as we remove wiphy in +* ath6kl_core_free(). Most likely this causes a use after free. +*/ wiphy_free (ar->wiphy); }
drivers/net/wireless/ath/ath6kl/cfg80211.h +3 -3
@@ -27,10 +27,7 @@ enum ath6kl_cfg_suspend_mode {struct net_device *ath6kl_interface_add (struct ath6kl *ar,char *name,enum nl80211_iftype type,u8 fw_vif_idx,u8 nw_type); -int ath6kl_register_ieee80211_hw (struct ath6kl *ar);struct ath6kl *ath6kl_core_alloc (struct device *dev); -void ath6kl_deinit_ieee80211_hw (struct ath6kl *ar); -void ath6kl_cfg80211_scan_complete_event (struct ath6kl_vif *vif,bool aborted); void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel,
@@ -58,4 +55,7 @@ void ath6kl_cfg80211_vif_cleanup(struct ath6kl_vif *vif);void ath6kl_cfg80211_stop (struct ath6kl_vif *vif);void ath6kl_cfg80211_stop_all (struct ath6kl *ar); +int ath6kl_cfg80211_init (struct ath6kl *ar); +void ath6kl_cfg80211_cleanup (struct ath6kl *ar); +#endif /* ATH6KL_CFG80211_H */
drivers/net/wireless/ath/ath6kl/init.c +2 -2
@@ -600,7 +600,7 @@ void ath6kl_core_cleanup(struct ath6kl *ar)kfree (ar->fw);kfree (ar->fw_patch); -ath6kl_deinit_ieee80211_hw (ar); +ath6kl_cfg80211_cleanup (ar); }/* firmware upload */
@@ -1608,7 +1608,7 @@ int ath6kl_core_init(struct ath6kl *ar)ath6kl_dbg (ATH6KL_DBG_TRC ,"%s: got wmi @ 0x%p.\n" , __func__, ar->wmi); - ret =ath6kl_register_ieee80211_hw (ar); + ret =ath6kl_cfg80211_init (ar);if (ret) goto err_node_cleanup;
PATCH v2 3/6 ath6kl: create core.c
In reply to Kalle ValoCurrently core functions are spread between various files, group all the functions into file and rename the functions to follow the style used elsewhere in the driver. This will make it easier to a separate core module.
Also fix a bug where wiphy is freed too early.
--- drivers/net/wireless/ath/ath6kl/Makefile | 2 drivers/net/wireless/ath/ath6kl/cfg80211.c | 94 ++------- drivers/net/wireless/ath/ath6kl/cfg80211.h | 4 drivers/net/wireless/ath/ath6kl/common.h | 3 drivers/net/wireless/ath/ath6kl/core.c | 288 ++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath6kl/core.h | 9 + drivers/net/wireless/ath/ath6kl/init.c | 205 -------------------- drivers/net/wireless/ath/ath6kl/sdio.c | 4 drivers/net/wireless/ath/ath6kl/usb.c | 8 - 9 files changed, 333 insertions(+), 284 deletions(-) create mode 100644 drivers/net/wireless/ath/ath6kl/core.c
drivers/net/wireless/ath/ath6kl/Makefile +2 -0
@@ -31,6 +31,7 @@ ath6kl_sdio-y += init.o ath6kl_sdio-y += main.o ath6kl_sdio-y += txrx.o ath6kl_sdio-y += wmi.o +ath6kl_sdio-y += core.o ath6kl_sdio-y += sdio.o ath6kl_sdio-$(CONFIG_NL80211_TESTMODE) += testmode.o
@@ -44,6 +45,7 @@ ath6kl_usb-y += init.o ath6kl_usb-y += main.o ath6kl_usb-y += txrx.o ath6kl_usb-y += wmi.o +ath6kl_usb-y += core.o ath6kl_usb-y += usb.o ath6kl_usb-$(CONFIG_NL80211_TESTMODE) += testmode.o
drivers/net/wireless/ath/ath6kl/cfg80211.c +24 -70
112 lines not on this page · raw message
drivers/net/wireless/ath/ath6kl/cfg80211.h +3 -1
@@ -27,7 +27,6 @@ enum ath6kl_cfg_suspend_mode {struct net_device *ath6kl_interface_add (struct ath6kl *ar,char *name,enum nl80211_iftype type,u8 fw_vif_idx,u8 nw_type); -struct ath6kl *ath6kl_core_alloc (struct device *dev);void ath6kl_cfg80211_scan_complete_event (struct ath6kl_vif *vif,bool aborted); void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel,
@@ -58,4 +57,7 @@ void ath6kl_cfg80211_stop_all(struct ath6kl *ar);int ath6kl_cfg80211_init (struct ath6kl *ar);void ath6kl_cfg80211_cleanup (struct ath6kl *ar); +struct ath6kl *ath6kl_cfg80211_create (void ); +void ath6kl_cfg80211_destroy (struct ath6kl *ar); +#endif /* ATH6KL_CFG80211_H */
drivers/net/wireless/ath/ath6kl/common.h +0 -3
@@ -79,8 +79,5 @@ struct ath6kl;enum htc_credit_dist_reason ;struct ath6kl_htc_credit_info ; -struct ath6kl *ath6kl_core_alloc (struct device *sdev); -int ath6kl_core_init (struct ath6kl *ar); -void ath6kl_core_cleanup (struct ath6kl *ar);struct sk_buff *ath6kl_buf_alloc (int size);#endif /* COMMON_H */
drivers/net/wireless/ath/ath6kl/core.c new file +288 -0
288 lines not on this page · raw message
drivers/net/wireless/ath/ath6kl/core.h +8 -1
@@ -723,11 +723,18 @@ void ath6kl_wakeup_event(void *dev);void ath6kl_reset_device (struct ath6kl *ar,u32 target_type,bool wait_fot_compltn,bool cold_reset);void ath6kl_init_control_info (struct ath6kl_vif *vif); -void ath6kl_core_free (struct ath6kl *ar);struct ath6kl_vif *ath6kl_vif_first (struct ath6kl *ar);void ath6kl_cleanup_vif (struct ath6kl_vif *vif,bool wmi_ready);int ath6kl_init_hw_start (struct ath6kl *ar);int ath6kl_init_hw_stop (struct ath6kl *ar); +int ath6kl_init_fetch_firmwares (struct ath6kl *ar); +int ath6kl_init_hw_params (struct ath6kl *ar); +void ath6kl_check_wow_status (struct ath6kl *ar); +struct ath6kl *ath6kl_core_create (struct device *dev); +int ath6kl_core_init (struct ath6kl *ar); +void ath6kl_core_cleanup (struct ath6kl *ar); +void ath6kl_core_destroy (struct ath6kl *ar); +#endif /* CORE_H */
drivers/net/wireless/ath/ath6kl/init.c +2 -203
238 lines not on this page · raw message
drivers/net/wireless/ath/ath6kl/sdio.c +2 -2
@@ -1263,7 +1263,7 @@ static int ath6kl_sdio_probe(struct sdio_func *func,for (count =0 ; count <BUS_REQUEST_MAX_NUM ; count++)ath6kl_sdio_free_bus_req (ar_sdio, &ar_sdio->bus_req[count]); - ar =ath6kl_core_alloc (&ar_sdio->func->dev); + ar =ath6kl_core_create (&ar_sdio->func->dev);if (!ar) {ath6kl_err ("Failed to alloc ath6kl core\n" ); ret = -ENOMEM ;
@@ -1293,7 +1293,7 @@ static int ath6kl_sdio_probe(struct sdio_func *func,return ret; err_core_alloc: -ath6kl_core_free (ar_sdio->ar); +ath6kl_core_destroy (ar_sdio->ar); err_dma:kfree (ar_sdio->dma_buffer); err_hif:
drivers/net/wireless/ath/ath6kl/usb.c +4 -4
@@ -352,7 +352,7 @@ static int ath6kl_usb_probe(struct usb_interface *interface, goto err_usb_put; } - ar =ath6kl_core_alloc (&ar_usb->udev->dev); + ar =ath6kl_core_create (&ar_usb->udev->dev);if (ar ==NULL ) {ath6kl_err ("Failed to alloc ath6kl core\n" ); ret = -ENOMEM ;
@@ -370,13 +370,13 @@ static int ath6kl_usb_probe(struct usb_interface *interface, ret =ath6kl_core_init (ar);if (ret) {ath6kl_err ("Failed to init ath6kl core: %d\n" , ret); - goto err_core_free; + goto err_core_destroy; }return ret; -err_core_free: -ath6kl_core_free (ar); +err_core_destroy: +ath6kl_core_destroy (ar); err_usb_destroy:ath6kl_usb_destroy (ar_usb); err_usb_put:
PATCH v2 4/6 ath6kl: get rid of AR_DBG_LVL_CHECK()
In reply to Kalle ValoWe don't need it as debug calls already have a log level and compiler should be smart enough to optimise away the code when ath6kl debug code is not enabled. Also it makes it easier to abstract core code to ath6kl_core.ko.
In ath6kl_dump_registers() I had to change the debug level from ANY to IRQ as I removed the AR_DBG_LVL_CHECK() check before calling the function.
--- drivers/net/wireless/ath/ath6kl/debug.c | 35 ++++++++++++++----------------- drivers/net/wireless/ath/ath6kl/debug.h | 2 -- drivers/net/wireless/ath/ath6kl/hif.c | 5 ++-- drivers/net/wireless/ath/ath6kl/wmi.c | 3 --- 4 files changed, 18 insertions(+), 27 deletions(-)
drivers/net/wireless/ath/ath6kl/debug.c +16 -19
@@ -82,31 +82,31 @@ void ath6kl_dump_registers(struct ath6kl_device *dev, struct ath6kl_irq_enable_reg *irq_enable_reg) { -ath6kl_dbg (ATH6KL_DBG_ANY , ("<------- Register Table -------->\n" )); +ath6kl_dbg (ATH6KL_DBG_IRQ , ("<------- Register Table -------->\n" ));if (irq_proc_reg !=NULL ) { -ath6kl_dbg (ATH6KL_DBG_ANY , +ath6kl_dbg (ATH6KL_DBG_IRQ ,"Host Int status: 0x%x\n" , irq_proc_reg->host_int_status); -ath6kl_dbg (ATH6KL_DBG_ANY , +ath6kl_dbg (ATH6KL_DBG_IRQ ,"CPU Int status: 0x%x\n" , irq_proc_reg->cpu_int_status); -ath6kl_dbg (ATH6KL_DBG_ANY , +ath6kl_dbg (ATH6KL_DBG_IRQ ,"Error Int status: 0x%x\n" , irq_proc_reg->error_int_status); -ath6kl_dbg (ATH6KL_DBG_ANY , +ath6kl_dbg (ATH6KL_DBG_IRQ ,"Counter Int status: 0x%x\n" , irq_proc_reg->counter_int_status); -ath6kl_dbg (ATH6KL_DBG_ANY , +ath6kl_dbg (ATH6KL_DBG_IRQ ,"Mbox Frame: 0x%x\n" , irq_proc_reg->mbox_frame); -ath6kl_dbg (ATH6KL_DBG_ANY , +ath6kl_dbg (ATH6KL_DBG_IRQ ,"Rx Lookahead Valid: 0x%x\n" , irq_proc_reg->rx_lkahd_valid); -ath6kl_dbg (ATH6KL_DBG_ANY , +ath6kl_dbg (ATH6KL_DBG_IRQ ,"Rx Lookahead 0: 0x%x\n" , irq_proc_reg->rx_lkahd[0 ]); -ath6kl_dbg (ATH6KL_DBG_ANY , +ath6kl_dbg (ATH6KL_DBG_IRQ ,"Rx Lookahead 1: 0x%x\n" , irq_proc_reg->rx_lkahd[1 ]);
@@ -115,16 +115,16 @@ void ath6kl_dump_registers(struct ath6kl_device *dev,* If the target supports GMBOX hardware, dump some * additional state. */ -ath6kl_dbg (ATH6KL_DBG_ANY , +ath6kl_dbg (ATH6KL_DBG_IRQ ,"GMBOX Host Int status 2: 0x%x\n" , irq_proc_reg->host_int_status2); -ath6kl_dbg (ATH6KL_DBG_ANY , +ath6kl_dbg (ATH6KL_DBG_IRQ ,"GMBOX RX Avail: 0x%x\n" , irq_proc_reg->gmbox_rx_avail); -ath6kl_dbg (ATH6KL_DBG_ANY , +ath6kl_dbg (ATH6KL_DBG_IRQ ,"GMBOX lookahead alias 0: 0x%x\n" , irq_proc_reg->rx_gmbox_lkahd_alias[0 ]); -ath6kl_dbg (ATH6KL_DBG_ANY , +ath6kl_dbg (ATH6KL_DBG_IRQ ,"GMBOX lookahead alias 1: 0x%x\n" , irq_proc_reg->rx_gmbox_lkahd_alias[1 ]); }
@@ -132,13 +132,13 @@ void ath6kl_dump_registers(struct ath6kl_device *dev, }if (irq_enable_reg !=NULL ) { -ath6kl_dbg (ATH6KL_DBG_ANY , +ath6kl_dbg (ATH6KL_DBG_IRQ ,"Int status Enable: 0x%x\n" , irq_enable_reg->int_status_en); -ath6kl_dbg (ATH6KL_DBG_ANY ,"Counter Int status Enable: 0x%x\n" , +ath6kl_dbg (ATH6KL_DBG_IRQ ,"Counter Int status Enable: 0x%x\n" , irq_enable_reg->cntr_int_status_en); } -ath6kl_dbg (ATH6KL_DBG_ANY ,"<------------------------------->\n" ); +ath6kl_dbg (ATH6KL_DBG_IRQ ,"<------------------------------->\n" ); }static void dump_cred_dist (struct htc_endpoint_credit_dist *ep_dist)
@@ -175,9 +175,6 @@ void dump_cred_dist_stats(struct htc_target *target) {struct htc_endpoint_credit_dist *ep_list; -if (!AR_DBG_LVL_CHECK (ATH6KL_DBG_CREDIT )) -return ; -list_for_each_entry (ep_list, &target->cred_dist_list, list)dump_cred_dist (ep_list);
drivers/net/wireless/ath/ath6kl/debug.h +0 -2
@@ -56,8 +56,6 @@ int ath6kl_printk(const char *level, const char *fmt, ...);#define ath6kl_warn (fmt, ...) \ ath6kl_printk(KERN_WARNING, fmt, ##__VA_ARGS__) -#define AR_DBG_LVL_CHECK (mask) (debug_mask & mask) -enum ath6kl_war {ATH6KL_WAR_INVALID_RATE , };
drivers/net/wireless/ath/ath6kl/hif.c +2 -3
@@ -429,9 +429,8 @@ static int proc_pending_irqs(struct ath6kl_device *dev, bool *done)if (status) goto out; -if (AR_DBG_LVL_CHECK (ATH6KL_DBG_IRQ )) -ath6kl_dump_registers (dev, &dev->irq_proc_reg, - &dev->irq_en_reg); +ath6kl_dump_registers (dev, &dev->irq_proc_reg, + &dev->irq_en_reg);/* Update only those registers that are enabled */ host_int_status = dev->irq_proc_reg.host_int_status &
drivers/net/wireless/ath/ath6kl/wmi.c +0 -3
@@ -419,9 +419,6 @@ static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len)ath6kl_dbg (ATH6KL_DBG_WMI ,"comp: %d %d %d\n" , evt->num_msg, evt->msg_len, evt->msg_type); -if (!AR_DBG_LVL_CHECK (ATH6KL_DBG_WMI )) -return 0 ; -for (index =0 ; index < evt->num_msg; index++) { size =sizeof (struct wmi_tx_complete_event ) + (index *sizeof (struct tx_complete_msg_v1 ));
RE: [PATCH v2 4/6] ath6kl: get rid of AR_DBG_LVL_CHECK()
Quoted 4 lines
We don't need it as debug calls already have a log level and compiler should be smart enough to optimise away the code when ath6kl debug code is not enabled.
Have you checked?
I think you are assuming that because the called function collapses, the call will be removed allowing the loop to be removed.
I suspect this is only true if the function is inlined. IIRC the normal linkage rules mean that only static functions are candidates for inlining.
David
Re: [PATCH v2 4/6] ath6kl: get rid of AR_DBG_LVL_CHECK()
Quoted 6 lines · David Laight
Quoted 4 lines
We don't need it as debug calls already have a log level and compiler should be smart enough to optimise away the code when ath6kl debug code is not enabled.
Have you checked?
No, I just assumed so.
Quoted 4 lines
I think you are assuming that because the called function collapses, the call will be removed allowing the loop to be removed. I suspect this is only true if the function is inlined. IIRC the normal linkage rules mean that only static functions are candidates for inlining.
I think you are right.
But while I investigated more I noticed that ath6kl_dump_registers() will be an empty static inline whenever CONFIG_ATH6KL_DEBUG is disabled and that will make sure that the whole function is not included. So whenever ath6kl debug code is enabled there is a small performance hit, but it's so small that IMHO we don't need to worry about it.
And for optimal performance CONFIG_ATH6KL_DEBUG should be disabled anyway.
What do you think?
Kalle
PATCH v2 5/6 ath6kl: convert ath6kl_dbg() and ath6kl_dbg_dump() into functions
In reply to Kalle ValoThat way it's possible to not export debug_mask outside the upcoming ath6kl_core.ko and that makes it easier to ath6kl_core.ko in the following patch.
--- drivers/net/wireless/ath/ath6kl/debug.c | 30 ++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath6kl/debug.h | 25 ++++--------------------- 2 files changed, 34 insertions(+), 21 deletions(-)
drivers/net/wireless/ath/ath6kl/debug.c +30 -0
@@ -57,6 +57,36 @@ int ath6kl_printk(const char *level, const char *fmt, ...)#ifdef CONFIG_ATH6KL_DEBUG +void ath6kl_dbg (enum ATH6K_DEBUG_MASK mask,const char *fmt, ...) +{ +struct va_format vaf; +va_list args; + +if (!(debug_mask & mask)) +return ; + +va_start (args, fmt); + + vaf.fmt = fmt; + vaf.va = &args; + +ath6kl_printk (KERN_DEBUG ,"%pV" , &vaf); + +va_end (args); +} + +void ath6kl_dbg_dump (enum ATH6K_DEBUG_MASK mask, +const char *msg,const char *prefix, +const void *buf,size_t len) +{ +if (debug_mask & mask) { +if (msg) +ath6kl_dbg (mask,"%s\n" , msg); + +print_hex_dump_bytes (prefix,DUMP_PREFIX_OFFSET , buf, len); + } +} +#define REG_OUTPUT_LEN_PER_LINE 25#define REGTYPE_STR_LEN 100
drivers/net/wireless/ath/ath6kl/debug.h +4 -21
@@ -61,28 +61,11 @@ enum ath6kl_war { };#ifdef CONFIG_ATH6KL_DEBUG -#define ath6kl_dbg (mask, fmt, ...) \ - ({ \ - int rtn; \ - if (debug_mask & mask) \ - rtn = ath6kl_printk(KERN_DEBUG, fmt, ##__VA_ARGS__); \ - else \ - rtn = 0; \ - \ - rtn; \ - }) -static inline void ath6kl_dbg_dump (enum ATH6K_DEBUG_MASK mask, -const char *msg,const char *prefix, -const void *buf,size_t len) -{ -if (debug_mask & mask) { -if (msg) -ath6kl_dbg (mask,"%s\n" , msg); - -print_hex_dump_bytes (prefix,DUMP_PREFIX_OFFSET , buf, len); - } -} +void ath6kl_dbg (enum ATH6K_DEBUG_MASK mask,const char *fmt, ...); +void ath6kl_dbg_dump (enum ATH6K_DEBUG_MASK mask, +const char *msg,const char *prefix, +const void *buf,size_t len); void ath6kl_dump_registers(struct ath6kl_device *dev, struct ath6kl_irq_proc_registers *irq_proc_reg,
Re: [PATCH v2 5/6] ath6kl: convert ath6kl_dbg() and ath6kl_dbg_dump() into functions
On Thu, 2012-01-05 at 15:28 +0200, Kalle Valo wrote:
Hey Kalle.
drivers/net/wireless/ath/ath6kl/debug.c
Quoted 1 line
drivers/net/wireless/ath/ath6kl/debug.c +0
-0
[]
Quoted 1 line
+void
ath6kl_dbg(enum ATH6K_DEBUG_MASK mask, const char *fmt, ...)
[]
drivers/net/wireless/ath/ath6kl/debug.c int ath6kl_printk(const char *level, const char *fmt, ...) · line 73
Quoted 1 line
drivers/net/wireless/ath/ath6kl/debug.c +1
-0+ath6kl_printk (KERN_DEBUG ,"%pV" , &vaf);
[
drivers/net/wireless/ath/ath6kl/debug.h
Quoted 1 line
drivers/net/wireless/ath/ath6kl/debug.h +0
-0
[]
Quoted 1 line
+void
ath6kl_dbg(enum ATH6K_DEBUG_MASK mask, const char *fmt, ...);
You need to add
__printf(2, 3)
to the prototype.
If it's not there, the printf formats and arguments aren't verified. %pV could do the wrong/bad things.
Re: [PATCH v2 5/6] ath6kl: convert ath6kl_dbg() and ath6kl_dbg_dump() into functions
Hi Joe,
Quoted 12 lines · Joe Perches
drivers/net/wireless/ath/ath6kl/debug.c
Quoted 1 line · Kalle Valo
drivers/net/wireless/ath/ath6kl/debug.c +0
-0[]
Quoted 1 line
+void
ath6kl_dbg(enum ATH6K_DEBUG_MASK mask, const char *fmt, ...)[]
drivers/net/wireless/ath/ath6kl/debug.c int ath6kl_printk(const char *level, const char *fmt, ...) · line 73
Quoted 1 line
drivers/net/wireless/ath/ath6kl/debug.c +1
-0+ath6kl_printk (KERN_DEBUG ,"%pV" , &vaf);[
drivers/net/wireless/ath/ath6kl/debug.h
Quoted 1 line
drivers/net/wireless/ath/ath6kl/debug.h +0
-0[]
Quoted 1 line
+void
ath6kl_dbg(enum ATH6K_DEBUG_MASK mask, const char *fmt, ...);
Quoted 8 lines
You need to add
__printf(2, 3)to the prototype.
If it's not there, the printf formats and arguments aren't verified. %pV could do the wrong/bad things.
Nice, I'll add that to v3. Thanks again.
Kalle
PATCH v2 6/6 ath6kl: create ath6kl_core.ko
In reply to Kalle ValoNow ath6kl is ready for splitting core code to ath6kl_core.ko module. This also makes it possible to link both sdio and usb code to kernel at the same time, which earlier failed miserably.
--- drivers/net/wireless/ath/ath6kl/Makefile | 37 +++++++++++----------------- drivers/net/wireless/ath/ath6kl/cfg80211.c | 3 ++ drivers/net/wireless/ath/ath6kl/core.c | 9 +++++++ drivers/net/wireless/ath/ath6kl/debug.c | 3 ++ drivers/net/wireless/ath/ath6kl/hif.c | 5 ++++ drivers/net/wireless/ath/ath6kl/init.c | 3 ++ 6 files changed, 37 insertions(+), 23 deletions(-)
drivers/net/wireless/ath/ath6kl/Makefile +14 -23
@@ -21,32 +21,23 @@ # Author(s): ="Atheros" #------------------------------------------------------------------------------ -obj-$(CONFIG_ATH6KL_SDIO) := ath6kl_sdio.o -ath6kl_sdio-y += debug.o -ath6kl_sdio-y += hif.o -ath6kl_sdio-y += htc.o -ath6kl_sdio-y += bmi.o -ath6kl_sdio-y += cfg80211.o -ath6kl_sdio-y += init.o -ath6kl_sdio-y += main.o -ath6kl_sdio-y += txrx.o -ath6kl_sdio-y += wmi.o -ath6kl_sdio-y += core.o +obj-$(CONFIG_ATH6KL) += ath6kl_core.o +ath6kl_core-y += debug.o +ath6kl_core-y += hif.o +ath6kl_core-y += htc.o +ath6kl_core-y += bmi.o +ath6kl_core-y += cfg80211.o +ath6kl_core-y += init.o +ath6kl_core-y += main.o +ath6kl_core-y += txrx.o +ath6kl_core-y += wmi.o +ath6kl_core-y += core.o +ath6kl_core-$(CONFIG_NL80211_TESTMODE) += testmode.o + +obj-$(CONFIG_ATH6KL_SDIO) += ath6kl_sdio.o ath6kl_sdio-y += sdio.o -ath6kl_sdio-$(CONFIG_NL80211_TESTMODE) += testmode.o obj-$(CONFIG_ATH6KL_USB) += ath6kl_usb.o -ath6kl_usb-y += debug.o -ath6kl_usb-y += hif.o -ath6kl_usb-y += htc.o -ath6kl_usb-y += bmi.o -ath6kl_usb-y += cfg80211.o -ath6kl_usb-y += init.o -ath6kl_usb-y += main.o -ath6kl_usb-y += txrx.o -ath6kl_usb-y += wmi.o -ath6kl_usb-y += core.o ath6kl_usb-y += usb.o -ath6kl_usb-$(CONFIG_NL80211_TESTMODE) += testmode.o ccflags-y += -D__CHECK_ENDIAN__
drivers/net/wireless/ath/ath6kl/cfg80211.c +3 -0
@@ -15,6 +15,7 @@*/ #include <linux/moduleparam.h> +#include <linux/export.h> #include "core.h" #include "cfg80211.h"
@@ -1907,6 +1908,7 @@ int ath6kl_cfg80211_suspend(struct ath6kl *ar,return 0 ; } +EXPORT_SYMBOL (ath6kl_cfg80211_suspend);int ath6kl_cfg80211_resume (struct ath6kl *ar) {
@@ -1958,6 +1960,7 @@ int ath6kl_cfg80211_resume(struct ath6kl *ar)return 0 ; } +EXPORT_SYMBOL (ath6kl_cfg80211_resume);#ifdef CONFIG_PM
drivers/net/wireless/ath/ath6kl/core.c +9 -0
@@ -16,7 +16,9 @@#include "core.h" +#include <linux/module.h> #include <linux/moduleparam.h> +#include <linux/export.h> #include "debug.h" #include "hif-ops.h"
@@ -198,6 +200,7 @@ err_wq:return ret; } +EXPORT_SYMBOL (ath6kl_core_init);struct ath6kl *ath6kl_core_create (struct device *dev) {
@@ -254,6 +257,7 @@ struct ath6kl *ath6kl_core_create(struct device *dev)return ar; } +EXPORT_SYMBOL (ath6kl_core_create);void ath6kl_core_cleanup (struct ath6kl *ar) {
@@ -280,9 +284,14 @@ void ath6kl_core_cleanup(struct ath6kl *ar)ath6kl_cfg80211_cleanup (ar);ath6kl_cfg80211_destroy (ar); } +EXPORT_SYMBOL (ath6kl_core_cleanup);void ath6kl_core_destroy (struct ath6kl *ar) {ath6kl_cfg80211_destroy (ar); } +EXPORT_SYMBOL (ath6kl_core_destroy); +MODULE_AUTHOR ("Qualcomm Atheros" ); +MODULE_DESCRIPTION ("Core module for AR600x SDIO and USB devices." ); +MODULE_LICENSE ("Dual BSD/GPL" );
drivers/net/wireless/ath/ath6kl/debug.c +3 -0
@@ -54,6 +54,7 @@ int ath6kl_printk(const char *level, const char *fmt, ...)return rtn; } +EXPORT_SYMBOL (ath6kl_printk);#ifdef CONFIG_ATH6KL_DEBUG
@@ -74,6 +75,7 @@ void ath6kl_dbg(enum ATH6K_DEBUG_MASK mask, const char *fmt, ...)va_end (args); } +EXPORT_SYMBOL (ath6kl_dbg); void ath6kl_dbg_dump(enum ATH6K_DEBUG_MASK mask, const char *msg, const char *prefix,
@@ -86,6 +88,7 @@ void ath6kl_dbg_dump(enum ATH6K_DEBUG_MASK mask,print_hex_dump_bytes (prefix,DUMP_PREFIX_OFFSET , buf, len); } } +EXPORT_SYMBOL (ath6kl_dbg_dump);#define REG_OUTPUT_LEN_PER_LINE 25#define REGTYPE_STR_LEN 100
drivers/net/wireless/ath/ath6kl/hif.c +5 -0
@@ -15,6 +15,8 @@*/ #include "hif.h" +#include <linux/export.h> +#include "core.h" #include "target.h" #include "hif-ops.h"
@@ -59,6 +61,8 @@ int ath6kl_hif_rw_comp_handler(void *context, int status)return 0 ; } +EXPORT_SYMBOL (ath6kl_hif_rw_comp_handler); +#define REG_DUMP_COUNT_AR6003 60#define REGISTER_DUMP_LEN_MAX 60
@@ -560,6 +564,7 @@ int ath6kl_hif_intr_bh_handler(struct ath6kl *ar)return status; } +EXPORT_SYMBOL (ath6kl_hif_intr_bh_handler);static int ath6kl_hif_enable_intrs (struct ath6kl_device *dev) {
drivers/net/wireless/ath/ath6kl/init.c +3 -0
@@ -17,8 +17,10 @@#include <linux/moduleparam.h> #include <linux/errno.h> +#include <linux/export.h> #include <linux/of.h> #include <linux/mmc/sdio_func.h> +#include "core.h" #include "cfg80211.h" #include "target.h"
@@ -1596,3 +1598,4 @@ void ath6kl_stop_txrx(struct ath6kl *ar)clear_bit (WLAN_ENABLED , &ar->flag); } +EXPORT_SYMBOL (ath6kl_stop_txrx);