bna: cleanup dead code and namespace issues
Subsystems (2)
RFC 1/1 bna: cleanup dead code and namespace issues
The new bna driver is full of issues that I found by running some namespace checks:
1. Lots of dead code relating to RSS and stats clearing
2. Some functions which should be local, especially ones that risk namespace collision with other code.
3. The table for interrupt control should be declared const.
The driver still is sloppy about namespace prefixes. It uses bna_, bnad_, bfa_, rxf_, __rxf and cna_ prefixes. Please convert it to have all variables and functions that are global use only one prefix.
Compile tested only.
---
Patch against net-next-2.6 tree.
drivers/net/bna/bfa_ioc.c | 8 drivers/net/bna/bfa_ioc.h | 1 drivers/net/bna/bfa_ioc_ct.c | 2 drivers/net/bna/bfa_sm.h | 2 drivers/net/bna/bna.h | 108 ---------- drivers/net/bna/bna_ctrl.c | 427 ++++--------------------------------------- drivers/net/bna/bna_hw.h | 1 drivers/net/bna/bna_txrx.c | 108 +++------- drivers/net/bna/bnad.c | 13 - drivers/net/bna/cna_fwimg.c | 2 10 files changed, 90 insertions(+), 582 deletions(-)
drivers/net/bna/bfa_ioc.c +1 -7
@@ -65,7 +65,7 @@ (!list_empty (&((__ioc)->mbox_mod.cmd_q)) || \ readl((__ioc)->ioc_regs.hfn_mbox_cmd)) -bool bfa_nw_auto_recover = true; +static bool bfa_nw_auto_recover = true;/* * forward declarations
@@ -1276,12 +1276,6 @@ bfa_nw_ioc_auto_recover(bool auto_recove bfa_nw_auto_recover = auto_recover; } -bool -bfa_nw_ioc_is_operational (struct bfa_ioc *ioc) -{ -return bfa_fsm_cmp_state (ioc, bfa_ioc_sm_op); -} -static void bfa_ioc_msgget (struct bfa_ioc *ioc,void *mbmsg) {
drivers/net/bna/bfa_ioc_ct.c +1 -1
@@ -34,7 +34,7 @@ static void bfa_ioc_ct_notify_hbfail(strstatic void bfa_ioc_ct_ownership_reset (struct bfa_ioc *ioc);static enum bfa_status bfa_ioc_ct_pll_init (void __iomem *rb,bool fcmode); -struct bfa_ioc_hwif nw_hwif_ct; +static struct bfa_ioc_hwif nw_hwif_ct;/** * Called from bfa_ioc_attach() to map asic specific calls.
drivers/net/bna/bna.h +2 -106
203 lines not on this page · raw message
drivers/net/bna/bna_ctrl.c +42 -385
678 lines not on this page · raw message
drivers/net/bna/bna_hw.h +0 -1
@@ -1282,7 +1282,6 @@ struct bna_chip_regs_offset {u32 fn_int_mask;u32 msix_idx; }; -extern const struct bna_chip_regs_offset reg_offset[];struct bna_chip_regs {void __iomem *page_addr;
drivers/net/bna/bna_txrx.c +38 -70
323 lines not on this page · raw message
drivers/net/bna/bnad.c +4 -9
@@ -28,7 +28,7 @@#include "bna.h" #include "cna.h" -DEFINE_MUTEX (bnad_fwimg_mutex); +static DEFINE_MUTEX (bnad_fwimg_mutex);/* * Module params
@@ -46,7 +46,7 @@ MODULE_PARM_DESC(bnad_ioc_auto_recover,*/ u32 bnad_rxqs_per_cq =2 ; -const u8 bnad_bcast_addr[] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }; +static const u8 bnad_bcast_addr[] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff };/* * Local MACROS
@@ -684,7 +684,7 @@ bnad_enable_mbox_irq(struct bnad *bnad)* Called with bnad->bna_lock held b'cos of * bnad->cfg_flags access. */ -void +static void bnad_disable_mbox_irq (struct bnad *bnad) {int irq =BNAD_GET_MBOX_IRQ (bnad);
@@ -953,11 +953,6 @@ bnad_cb_stats_get(struct bnad *bnad, enu jiffies + msecs_to_jiffies(BNAD_STATS_TIMER_FREQ)); } -void -bnad_cb_stats_clr (struct bnad *bnad) -{ -} -/* Resource allocation, free functions */ static void
@@ -3211,7 +3206,7 @@ bnad_pci_remove(struct pci_dev *pdev)free_netdev (netdev); } -const struct pci_device_id bnad_pci_id_table[] = { +static const struct pci_device_id bnad_pci_id_table[] = { {PCI_DEVICE (PCI_VENDOR_ID_BROCADE ,PCI_DEVICE_ID_BROCADE_CT ),
drivers/net/bna/cna_fwimg.c +1 -1
@@ -22,7 +22,7 @@ const struct firmware *bfi_fw;static u32 *bfi_image_ct_cna;static u32 bfi_image_ct_cna_size; -u32 * +static u32 *cna_read_firmware (struct pci_dev *pdev,u32 **bfi_image,u32 *bfi_image_size,char *fw_name) {
drivers/net/bna/bfa_ioc.h +0 -1
@@ -271,7 +271,6 @@ void bfa_nw_ioc_enable(struct bfa_ioc *ivoid bfa_nw_ioc_disable (struct bfa_ioc *ioc);void bfa_nw_ioc_error_isr (struct bfa_ioc *ioc); -bool bfa_nw_ioc_is_operational (struct bfa_ioc *ioc);void bfa_nw_ioc_get_attr (struct bfa_ioc *ioc,struct bfa_ioc_attr *ioc_attr); void bfa_nw_ioc_hbfail_register(struct bfa_ioc *ioc,
drivers/net/bna/bfa_sm.h +1 -1
@@ -77,7 +77,7 @@ typedef void (*bfa_fsm_t)(void *fsm, int ((_fsm)->fsm == (bfa_fsm_t)(_state))static inline int -bfa_sm_to_state (struct bfa_sm_table *smt,bfa_sm_t sm) +bfa_sm_to_state (const struct bfa_sm_table *smt,bfa_sm_t sm) {int i =0 ;
Stephen,
We are working on your suggestions. We are going through internal review of some of the cleanups that you suggested.
We will soon submit a patch towards that.
However, converting all the prefixes to the same one, or having some uniformity may take longer. BTW, the disparity in name-space is because of the fact this code is for CNA and is shared with the FCoE also.
We are working on addressing this also, by having a common module as suggested by David earlier.
Thanks
--Debashis
-----Original Message-----
From: Stephen Hemminger [mailto:[email protected]]
Sent: Tuesday, October 05, 2010 3:20 AM
To: Rasesh Mody; Debashis Dutt; David S. Miller
Cc: [email protected]
Subject: [RFC] bna: cleanup dead code and namespace issues
The new bna driver is full of issues that I found by running some namespace checks:
1. Lots of dead code relating to RSS and stats clearing
2. Some functions which should be local, especially ones that risk namespace collision with other code.
3. The table for interrupt control should be declared const.
The driver still is sloppy about namespace prefixes. It uses bna_, bnad_, bfa_, rxf_, __rxf and cna_ prefixes. Please convert it to have all variables and functions that are global use only one prefix.
Compile tested only.
---
Patch against net-next-2.6 tree.
drivers/net/bna/bfa_ioc.c | 8 drivers/net/bna/bfa_ioc.h | 1 drivers/net/bna/bfa_ioc_ct.c | 2 drivers/net/bna/bfa_sm.h | 2 drivers/net/bna/bna.h | 108 ---------- drivers/net/bna/bna_ctrl.c | 427 ++++--------------------------------------- drivers/net/bna/bna_hw.h | 1 drivers/net/bna/bna_txrx.c | 108 +++------- drivers/net/bna/bnad.c | 13 - drivers/net/bna/cna_fwimg.c | 2 10 files changed, 90 insertions(+), 582 deletions(-)
drivers/net/bna/bfa_ioc.c 2010-10-05 18:55:15.241670954 +0900 renamed from drivers/net/bna/bfa_ioc.c 2010-10-05 18:28:08.081647186 +0900 +1 -7
@@ -65,7 +65,7 @@ (!list_empty(&((__ioc)->mbox_mod.cmd_q)) || \ readl((__ioc)->ioc_regs.hfn_mbox_cmd)) -bool bfa_nw_auto_recover = true; +static bool bfa_nw_auto_recover = true; /* * forward declarations
@@ -1276,12 +1276,6 @@ bfa_nw_ioc_auto_recover(bool auto_recove bfa_nw_auto_recover = auto_recover; } -bool -bfa_nw_ioc_is_operational(struct bfa_ioc *ioc) -{ - return bfa_fsm_cmp_state(ioc, bfa_ioc_sm_op); -} - static void bfa_ioc_msgget(struct bfa_ioc *ioc, void *mbmsg) {
drivers/net/bna/bfa_ioc_ct.c 2010-10-05 18:35:37.373640864 +0900 renamed from drivers/net/bna/bfa_ioc_ct.c 2010-10-05 18:28:08.105640040 +0900 +1 -1
@@ -34,7 +34,7 @@ static void bfa_ioc_ct_notify_hbfail(str static void bfa_ioc_ct_ownership_reset(struct bfa_ioc *ioc); static enum bfa_status bfa_ioc_ct_pll_init(void __iomem *rb, bool fcmode); -struct bfa_ioc_hwif nw_hwif_ct; +static struct bfa_ioc_hwif nw_hwif_ct; /** * Called from bfa_ioc_attach() to map asic specific calls.
drivers/net/bna/bna.h 2010-10-05 19:14:12.306169796 +0900 renamed from drivers/net/bna/bna.h 2010-10-05 18:33:24.969649777 +0900 +2 -106
203 lines not on this page · raw message
drivers/net/bna/bna_ctrl.c 2010-10-05 19:17:51.037641382 +0900 renamed from drivers/net/bna/bna_ctrl.c 2010-10-05 18:28:08.125665071 +0900 +42 -385
678 lines not on this page · raw message
drivers/net/bna/bna_hw.h 2010-10-05 18:45:32.957640709 +0900 renamed from drivers/net/bna/bna_hw.h 2010-10-05 18:45:27.577646257 +0900 +0 -1
@@ -1282,7 +1282,6 @@ struct bna_chip_regs_offset { u32 fn_int_mask; u32 msix_idx; }; -extern const struct bna_chip_regs_offset reg_offset[]; struct bna_chip_regs { void __iomem *page_addr;
drivers/net/bna/bna_txrx.c 2010-10-05 19:17:57.785641486 +0900 renamed from drivers/net/bna/bna_txrx.c 2010-10-05 18:28:08.141648599 +0900 +38 -70
323 lines not on this page · raw message
drivers/net/bna/bnad.c 2010-10-05 19:11:35.125672896 +0900 renamed from drivers/net/bna/bnad.c 2010-10-05 18:28:08.157640648 +0900 +4 -9
@@ -28,7 +28,7 @@ #include "bna.h" #include "cna.h" -DEFINE_MUTEX(bnad_fwimg_mutex); +static DEFINE_MUTEX(bnad_fwimg_mutex); /* * Module params
@@ -46,7 +46,7 @@ MODULE_PARM_DESC(bnad_ioc_auto_recover, */ u32 bnad_rxqs_per_cq = 2; -const u8 bnad_bcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +static const u8 bnad_bcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; /* * Local MACROS
@@ -684,7 +684,7 @@ bnad_enable_mbox_irq(struct bnad *bnad) * Called with bnad->bna_lock held b'cos of * bnad->cfg_flags access. */ -void +static void bnad_disable_mbox_irq(struct bnad *bnad) { int irq = BNAD_GET_MBOX_IRQ(bnad);
@@ -953,11 +953,6 @@ bnad_cb_stats_get(struct bnad *bnad, enu jiffies + msecs_to_jiffies(BNAD_STATS_TIMER_FREQ)); } -void -bnad_cb_stats_clr(struct bnad *bnad) -{ -} - /* Resource allocation, free functions */ static void
@@ -3211,7 +3206,7 @@ bnad_pci_remove(struct pci_dev *pdev) free_netdev(netdev); } -const struct pci_device_id bnad_pci_id_table[] = { +static const struct pci_device_id bnad_pci_id_table[] = { { PCI_DEVICE(PCI_VENDOR_ID_BROCADE, PCI_DEVICE_ID_BROCADE_CT),
drivers/net/bna/cna_fwimg.c 2010-10-05 18:29:06.225688125 +0900 renamed from drivers/net/bna/cna_fwimg.c 2010-10-05 18:28:08.173646664 +0900 +1 -1
@@ -22,7 +22,7 @@ const struct firmware *bfi_fw; static u32 *bfi_image_ct_cna; static u32 bfi_image_ct_cna_size; -u32 * +static u32 * cna_read_firmware(struct pci_dev *pdev, u32 **bfi_image, u32 *bfi_image_size, char *fw_name) {
drivers/net/bna/bfa_ioc.h 2010-10-05 18:54:30.857688208 +0900 renamed from drivers/net/bna/bfa_ioc.h 2010-10-05 18:54:23.662672433 +0900 +0 -1
@@ -271,7 +271,6 @@ void bfa_nw_ioc_enable(struct bfa_ioc *i void bfa_nw_ioc_disable(struct bfa_ioc *ioc); void bfa_nw_ioc_error_isr(struct bfa_ioc *ioc); -bool bfa_nw_ioc_is_operational(struct bfa_ioc *ioc); void bfa_nw_ioc_get_attr(struct bfa_ioc *ioc, struct bfa_ioc_attr *ioc_attr); void bfa_nw_ioc_hbfail_register(struct bfa_ioc *ioc,
drivers/net/bna/bfa_sm.h 2010-10-05 19:12:48.897641119 +0900 renamed from drivers/net/bna/bfa_sm.h 2010-10-05 19:12:40.405663296 +0900 +1 -1
@@ -77,7 +77,7 @@ typedef void (*bfa_fsm_t)(void *fsm, int ((_fsm)->fsm == (bfa_fsm_t)(_state)) static inline int -bfa_sm_to_state(struct bfa_sm_table *smt, bfa_sm_t sm) +bfa_sm_to_state(const struct bfa_sm_table *smt, bfa_sm_t sm) { int i = 0;