Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965685AbXBTAXK (ORCPT ); Mon, 19 Feb 2007 19:23:10 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750930AbXBTAUB (ORCPT ); Mon, 19 Feb 2007 19:20:01 -0500 Received: from mailout.stusta.mhn.de ([141.84.69.5]:36086 "EHLO mailhub.stusta.mhn.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965588AbXBTAH2 (ORCPT ); Mon, 19 Feb 2007 19:07:28 -0500 Date: Tue, 20 Feb 2007 01:07:27 +0100 From: Adrian Bunk To: Andrew Morton , Sriram Chidambaram , jgarzik@pobox.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [-mm patch] drivers/net/vioc/: possible cleanups Message-ID: <20070220000727.GU13958@stusta.de> References: <20070215051408.a7fb7d81.akpm@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070215051408.a7fb7d81.akpm@linux-foundation.org> User-Agent: Mutt/1.5.13 (2006-08-11) Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 17577 Lines: 582 On Thu, Feb 15, 2007 at 05:14:08AM -0800, Andrew Morton wrote: >... > Changes since 2.6.20-rc6-mm3: >... > +Fabric7-VIOC-driver.patch >... > netdev stuff >... This patch contains the following possible cleanups: - remove dead #ifdef EXPORT_SYMTAB code - no "inline" functions in C files - gcc knows best whether or not to inline static functions - move the vioc_ethtool_ops prototype to a header file - make needlessly global code static - #if 0 unused code - vioc_irq.c: remove the unused vioc_driver_lock Signed-off-by: Adrian Bunk --- drivers/net/vioc/f7/sppapi.h | 2 - drivers/net/vioc/khash.h | 10 ----- drivers/net/vioc/spp.c | 60 +++++++++++++++++++----------- drivers/net/vioc/vioc_api.c | 5 ++ drivers/net/vioc/vioc_api.h | 3 + drivers/net/vioc/vioc_driver.c | 3 - drivers/net/vioc/vioc_ethtool.c | 2 - drivers/net/vioc/vioc_irq.c | 9 +--- drivers/net/vioc/vioc_provision.c | 16 +++++--- drivers/net/vioc/vioc_receive.c | 2 - drivers/net/vioc/vioc_spp.c | 6 +-- drivers/net/vioc/vioc_transmit.c | 40 +++++++++++--------- 12 files changed, 85 insertions(+), 73 deletions(-) --- linux-2.6.20-mm1/drivers/net/vioc/vioc_driver.c.old 2007-02-18 01:14:31.000000000 +0100 +++ linux-2.6.20-mm1/drivers/net/vioc/vioc_driver.c 2007-02-18 01:14:35.000000000 +0100 @@ -868,6 +868,3 @@ module_init(vioc_module_init); module_exit(vioc_module_exit); -#ifdef EXPORT_SYMTAB -EXPORT_SYMBOL(vioc_viocdev); -#endif /* EXPORT_SYMTAB */ --- linux-2.6.20-mm1/drivers/net/vioc/khash.h.old 2007-02-18 01:16:28.000000000 +0100 +++ linux-2.6.20-mm1/drivers/net/vioc/khash.h 2007-02-18 01:25:29.000000000 +0100 @@ -52,14 +52,4 @@ }; -struct shash_t *hashT_create(u32, size_t, size_t, u32(*)(unsigned char *, unsigned long), int(*)(void *, void *), unsigned int); -int hashT_delete(struct shash_t * , void *); -struct hash_elem_t *hashT_lookup(struct shash_t * , void *); -struct hash_elem_t *hashT_add(struct shash_t *, void *); -void hashT_destroy(struct shash_t *); -/* Accesors */ -void **hashT_getkeys(struct shash_t *); -size_t hashT_tablesize(struct shash_t *); -size_t hashT_size(struct shash_t *); - #endif --- linux-2.6.20-mm1/drivers/net/vioc/f7/sppapi.h.old 2007-02-18 01:26:44.000000000 +0100 +++ linux-2.6.20-mm1/drivers/net/vioc/f7/sppapi.h 2007-02-18 01:26:57.000000000 +0100 @@ -234,7 +234,5 @@ extern void spp_msg_unregister(u32 key_facility); -extern int read_spp_regbank32(int vioc, int bank, char *buffer); - #endif /* _SPPAPI_H_ */ --- linux-2.6.20-mm1/drivers/net/vioc/spp.c.old 2007-02-18 01:19:34.000000000 +0100 +++ linux-2.6.20-mm1/drivers/net/vioc/spp.c 2007-02-18 01:27:13.000000000 +0100 @@ -50,6 +50,15 @@ c -= a; c -= b; c ^= (b >> 15); \ } +static struct hash_elem_t *hashT_add(struct shash_t *htable, void *key); +static struct shash_t *hashT_create(u32 sizehint, size_t keybuf_size, + size_t databuf_size, + u32(*hfunc) (unsigned char *, + unsigned long), + int (*cfunc) (void *, void *), + unsigned int flags); +static void hashT_destroy(struct shash_t *htable); +static struct hash_elem_t *hashT_lookup(struct shash_t *htable, void *key); struct shash_t { /* Common fields for all hash tables types */ @@ -65,7 +74,9 @@ }; struct hash_ops { +#if 0 int (*delete) (struct shash_t *, void *); +#endif /* 0 */ struct hash_elem_t *(*lookup) (struct shash_t *, void *); void (*destroy) (struct shash_t *); struct hash_elem_t *(*add) (struct shash_t *, void *); @@ -143,6 +154,7 @@ return ((htable->hash_fn(key, len)) & (htable->tsize - 1)); } +#if 0 /* Data associated to this key MUST be freed by the caller */ static int ch_delete(struct shash_t *htable, void *key) { @@ -181,6 +193,7 @@ return -1; } +#endif /* 0 */ static void ch_destroy(struct shash_t *htable) { @@ -232,16 +245,21 @@ } /* Accesors ******************************************************************/ -inline size_t hashT_tablesize(struct shash_t * htable) + +#if 0 + +size_t hashT_tablesize(struct shash_t * htable) { return htable->tsize; } -inline size_t hashT_size(struct shash_t * htable) +size_t hashT_size(struct shash_t * htable) { return htable->nelems; } +#endif /* 0 */ + static struct hash_elem_t *ch_lookup(struct shash_t *htable, void *key) { u32 idx; @@ -330,15 +348,17 @@ return 1; } -struct hash_ops ch_ops = { +static struct hash_ops ch_ops = { +#if 0 .delete = ch_delete, +#endif /* 0 */ .lookup = ch_lookup, .destroy = ch_destroy, .getkeys = ch_getkeys, .add = ch_add }; -struct facility fTable[FACILITY_CNT]; +static struct facility fTable[FACILITY_CNT]; int spp_init(void) { @@ -511,7 +531,7 @@ spin_unlock(&elem->lock); } - +#if 0 int read_spp_regbank32(int vioc_idx, int bank, char *buffer) { struct vioc_device *viocdev = vioc_viocdev(vioc_idx); @@ -531,14 +551,14 @@ return i; } +#endif /* 0 */ -struct shash_t *hashT_create(u32 sizehint, - size_t keybuf_size, - size_t databuf_size, - u32(*hfunc) (unsigned char *, - unsigned long), - int (*cfunc) (void *, void *), - unsigned int flags) +static struct shash_t *hashT_create(u32 sizehint, size_t keybuf_size, + size_t databuf_size, + u32(*hfunc) (unsigned char *, + unsigned long), + int (*cfunc) (void *, void *), + unsigned int flags) { struct shash_t *htable; u32 size = 0; /* Table size */ @@ -591,36 +611,34 @@ return htable; } +#if 0 int hashT_delete(struct shash_t *htable, void *key) { return htable->h_ops->delete(htable, key); } +#endif /* 0 */ -struct hash_elem_t *hashT_add(struct shash_t *htable, void *key) +static struct hash_elem_t *hashT_add(struct shash_t *htable, void *key) { return htable->h_ops->add(htable, key); } -struct hash_elem_t *hashT_lookup(struct shash_t *htable, void *key) +static struct hash_elem_t *hashT_lookup(struct shash_t *htable, void *key) { return htable->h_ops->lookup(htable, key); } -void hashT_destroy(struct shash_t *htable) +static void hashT_destroy(struct shash_t *htable) { - htable->h_ops->destroy(htable); vfree(htable); } +#if 0 void **hashT_getkeys(struct shash_t *htable) { return htable->h_ops->getkeys(htable); } +#endif /* 0 */ -#ifdef EXPORT_SYMTAB -EXPORT_SYMBOL(spp_msg_register); -EXPORT_SYMBOL(spp_msg_unregister); -EXPORT_SYMBOL(read_spp_regbank32); -#endif --- linux-2.6.20-mm1/drivers/net/vioc/vioc_spp.c.old 2007-02-18 01:22:54.000000000 +0100 +++ linux-2.6.20-mm1/drivers/net/vioc/vioc_spp.c 2007-02-18 01:34:50.000000000 +0100 @@ -84,12 +84,12 @@ static DECLARE_MUTEX(vnic_prov_sem); -static inline void vnic_prov_get_sema(void) +static void vnic_prov_get_sema(void) { down(&vnic_prov_sem); } -static inline void vnic_prov_put_sema(void) +static void vnic_prov_put_sema(void) { up(&vnic_prov_sem); } @@ -290,7 +290,7 @@ vioc_reg_wr(1, viocdev->ba.virt, SPP_HB_SENSOR_REG); } -void vioc_reset_rq_to_bmc(int vioc_id, u32 command) +static void vioc_reset_rq_to_bmc(int vioc_id, u32 command) { struct vioc_device *viocdev = vioc_viocdev(0); --- linux-2.6.20-mm1/drivers/net/vioc/vioc_transmit.c.old 2007-02-18 01:23:30.000000000 +0100 +++ linux-2.6.20-mm1/drivers/net/vioc/vioc_transmit.c 2007-02-18 12:28:58.000000000 +0100 @@ -73,49 +73,52 @@ #define TXQ0 0 #define NOT_SET -1 -static inline u32 vnic_rd_txd_ctl(struct txq *txq) +static u32 vnic_rd_txd_ctl(struct txq *txq) { return readl(txq->va_of_vreg_veng_txd_ctl); } -static inline void vnic_ring_tx_bell(struct txq *txq) +static void vnic_ring_tx_bell(struct txq *txq) { writel(txq->shadow_VREG_VENG_TXD_CTL | VREG_VENG_TXD_CTL_QRING_MASK, txq->va_of_vreg_veng_txd_ctl); txq->bells++; } -static inline void vnic_reset_tx_ring_err(struct txq *txq) +static void vnic_reset_tx_ring_err(struct txq *txq) { writel(txq->shadow_VREG_VENG_TXD_CTL | (VREG_VENG_TXD_CTL_QENABLE_MASK | VREG_VENG_TXD_CTL_CLEARMASK), txq->va_of_vreg_veng_txd_ctl); } -static inline void vnic_enable_tx_ring(struct txq *txq) +static void vnic_enable_tx_ring(struct txq *txq) { txq->shadow_VREG_VENG_TXD_CTL = VREG_VENG_TXD_CTL_QENABLE_MASK; writel(txq->shadow_VREG_VENG_TXD_CTL, txq->va_of_vreg_veng_txd_ctl); } -static inline void vnic_disable_tx_ring(struct txq *txq) +static void vnic_disable_tx_ring(struct txq *txq) { txq->shadow_VREG_VENG_TXD_CTL = 0; writel(0, txq->va_of_vreg_veng_txd_ctl); } -static inline void vnic_pause_tx_ring(struct txq *txq) +#if 0 + +static void vnic_pause_tx_ring(struct txq *txq) { txq->shadow_VREG_VENG_TXD_CTL |= VREG_VENG_TXD_CTL_QPAUSE_MASK; writel(txq->shadow_VREG_VENG_TXD_CTL, txq->va_of_vreg_veng_txd_ctl); } -static inline void vnic_resume_tx_ring(struct txq *txq) +static void vnic_resume_tx_ring(struct txq *txq) { txq->shadow_VREG_VENG_TXD_CTL &= ~VREG_VENG_TXD_CTL_QPAUSE_MASK; writel(txq->shadow_VREG_VENG_TXD_CTL, txq->va_of_vreg_veng_txd_ctl); } +#endif /* 0 */ /* TxQ must be locked */ static void vnic_reset_txq(struct vnic_device *vnicdev, struct txq *txq) @@ -395,8 +398,9 @@ viocdev->vioc_stats.tx_tasklets++; // read_unlock(&viocdev->lock); } -void vnic_enqueue_tx_pkt(struct vnic_device *vnicdev, struct txq *txq, - struct sk_buff *skb, struct vioc_prov *prov) + +static void vnic_enqueue_tx_pkt(struct vnic_device *vnicdev, struct txq *txq, + struct sk_buff *skb, struct vioc_prov *prov) { int idx, sop_idx, eop_idx, f; struct tx_pktBufDesc_Phys_w *txd; @@ -512,8 +516,9 @@ } -void vnic_enqueue_tx_buffers(struct vnic_device *vnicdev, struct txq *txq, - struct sk_buff *skb, struct vioc_prov *prov) +static void vnic_enqueue_tx_buffers(struct vnic_device *vnicdev, + struct txq *txq, struct sk_buff *skb, + struct vioc_prov *prov) { int len; int idx; @@ -586,7 +591,7 @@ txq->next_to_use = idx; } -static inline void init_f7_header(struct sk_buff *skb) +static void init_f7_header(struct sk_buff *skb) { struct vioc_f7pf_w *f7p; unsigned char tag; @@ -675,7 +680,7 @@ * not hold - add a tx_enabled flag to the vnic struct protected * by txq->lock. Or just read-lock the VIOC. */ -int vnic_start_xmit(struct sk_buff *skb, struct net_device *netdev) +static int vnic_start_xmit(struct sk_buff *skb, struct net_device *netdev) { struct vnic_device *vnicdev = netdev->priv; struct txq *txq = &vnicdev->txq; @@ -734,8 +739,9 @@ * saddr=NULL means use device source address * daddr=NULL means leave destination address (eg unresolved arp) */ -int vnic_eth_header(struct sk_buff *skb, struct net_device *dev, - unsigned short type, void *daddr, void *saddr, unsigned len) +static int vnic_eth_header(struct sk_buff *skb, struct net_device *dev, + unsigned short type, void *daddr, void *saddr, + unsigned len) { struct ethhdr *eth = (struct ethhdr *)skb_push(skb, ETH_HLEN); @@ -952,6 +958,7 @@ vnicdev->txq.vbuf = NULL; } +#if 0 void vioc_reset_if_tx(struct net_device *netdev) { struct vnic_device *vnicdev = netdev->priv; @@ -959,8 +966,7 @@ vnic_reset_txq(vnicdev, txq); } - -extern struct ethtool_ops vioc_ethtool_ops; +#endif /* 0 */ /** * vnic_uninit - Device Termination Routine --- linux-2.6.20-mm1/drivers/net/vioc/vioc_api.h.old 2007-02-18 01:28:17.000000000 +0100 +++ linux-2.6.20-mm1/drivers/net/vioc/vioc_api.h 2007-02-18 01:56:08.000000000 +0100 @@ -30,11 +30,12 @@ #include #include "vioc_vnic.h" +extern struct ethtool_ops vioc_ethtool_ops; + extern int vioc_vnic_resources_set(int vioc_id, u32 vnic_id); extern void vioc_sw_reset(int vioc_id); extern u32 vioc_rrd(int vioc_id, int module_id, int vnic_id, int reg_addr); extern int vioc_rwr(int vioc_id, int module_id, int vnic_id, int reg_addr, u32 value); -extern int vioc_set_vnic_mac(int vioc_id, u32 vnic_id, u8 * p); extern int vioc_get_vnic_mac(int vioc_id, u32 vnic_id, u8 * p); extern int vioc_set_txq(int vioc_id, u32 vnic_id, u32 txq_id, dma_addr_t base, u32 num_elements); --- linux-2.6.20-mm1/drivers/net/vioc/vioc_api.c.old 2007-02-18 01:27:41.000000000 +0100 +++ linux-2.6.20-mm1/drivers/net/vioc/vioc_api.c 2007-02-18 01:28:59.000000000 +0100 @@ -46,7 +46,8 @@ #include "vioc_vnic.h" #include "vioc_api.h" -int vioc_set_rx_intr_param(int viocdev_idx, int rx_intr_id, u32 timeout, u32 cntout) +static int vioc_set_rx_intr_param(int viocdev_idx, int rx_intr_id, + u32 timeout, u32 cntout) { int ret = 0; struct vioc_device *viocdev; @@ -83,6 +84,7 @@ return 0; } +#if 0 int vioc_set_vnic_mac(int viocdev_idx, u32 vnic_id, u8 * p) { struct vioc_device *viocdev = vioc_viocdev(viocdev_idx); @@ -101,6 +103,7 @@ return 0; } +#endif /* 0 */ int vioc_set_txq(int viocdev_idx, u32 vnic_id, u32 txq_id, dma_addr_t base, u32 num_elements) --- linux-2.6.20-mm1/drivers/net/vioc/vioc_ethtool.c.old 2007-02-18 01:29:21.000000000 +0100 +++ linux-2.6.20-mm1/drivers/net/vioc/vioc_ethtool.c 2007-02-18 01:29:36.000000000 +0100 @@ -155,7 +155,7 @@ return 0; } -int vioc_trace; +static int vioc_trace; static u32 vnic_get_msglevel(struct net_device *netdev) { --- linux-2.6.20-mm1/drivers/net/vioc/vioc_irq.c.old 2007-02-18 01:29:59.000000000 +0100 +++ linux-2.6.20-mm1/drivers/net/vioc/vioc_irq.c 2007-02-18 12:56:33.000000000 +0100 @@ -55,9 +55,6 @@ #define VIOC_INTERRUPTS_CNT 19 /* 16 Rx + 1 Tx + 1 BMC + 1 Error */ #define VIOC_INTERRUPTS_CNT_PIN_IRQ 4 /* 2 Rx + 1 Tx + 1 BMC */ -#define VIOC_SLVAR(x) x spinlock_t vioc_driver_lock = SPIN_LOCK_UNLOCKED -#define VIOC_CLI spin_lock_irq(&vioc_driver_lock) -#define VIOC_STI spin_unlock_irq(&vioc_driver_lock) #define IRQRETURN return IRQ_HANDLED #define TX_IRQ_IDX 16 #define BMC_IRQ_IDX 17 @@ -92,9 +89,7 @@ }; /* GLOBAL VIOC Interrupt table/structure */ -struct viocdev_intreq vioc_interrupts[VIOC_MAX_VIOCS]; - -VIOC_SLVAR(); +static struct viocdev_intreq vioc_interrupts[VIOC_MAX_VIOCS]; static irqreturn_t taskq_handler(int i, void *p) { @@ -227,7 +222,7 @@ return 0; } -int get_pci_pin_irq(struct pci_dev *dev_in, int func) +static int get_pci_pin_irq(struct pci_dev *dev_in, int func) { struct pci_dev *dev = NULL; unsigned int slot, fn, devfn; --- linux-2.6.20-mm1/drivers/net/vioc/vioc_provision.c.old 2007-02-18 01:32:09.000000000 +0100 +++ linux-2.6.20-mm1/drivers/net/vioc/vioc_provision.c 2007-02-18 12:55:56.000000000 +0100 @@ -75,7 +75,7 @@ */ -struct vnic_prov_def vnic_set_0 = { +static struct vnic_prov_def vnic_set_0 = { .rxd_ring[0].buf_size = RXDQ_SMALL_ALLOC_BUFSIZE, .rxd_ring[0].entries = RXDQ_SMALL_ENTRIES, .rxd_ring[0].id = 0, @@ -92,7 +92,7 @@ 0,.rxc_intr_id = 0 }; -struct vnic_prov_def vnic_set_1 = { +static struct vnic_prov_def vnic_set_1 = { .rxd_ring[0].buf_size = RXDQ_SMALL_ALLOC_BUFSIZE, .rxd_ring[0].entries = RXDQ_SMALL_ENTRIES, .rxd_ring[0].id = 4, @@ -109,7 +109,7 @@ 1,.rxc_intr_id = 1 }; -struct vnic_prov_def vnic_set_2 = { +static struct vnic_prov_def vnic_set_2 = { .rxd_ring[0].buf_size = RXDQ_SMALL_ALLOC_BUFSIZE, .rxd_ring[0].entries = RXDQ_SMALL_ENTRIES, .rxd_ring[0].id = 8, @@ -126,7 +126,7 @@ 2,.rxc_intr_id = 2 }; -struct vnic_prov_def vnic_set_3 = { +static struct vnic_prov_def vnic_set_3 = { .rxd_ring[0].buf_size = RXDQ_SMALL_ALLOC_BUFSIZE, .rxd_ring[0].entries = RXDQ_SMALL_ENTRIES, .rxd_ring[0].id = 12, @@ -143,6 +143,7 @@ 3,.rxc_intr_id = 3 }; +#if 0 struct vnic_prov_def vnic_set_sim = { .rxd_ring[0].buf_size = RXDQ_STD_ALLOC_BUFSIZE, .rxd_ring[0].entries = 256, @@ -158,8 +159,9 @@ .rxd_ring[2].state = 1, .tx_entries = 256,.rxc_entries = 256 * 3,.rxc_id = 0,.rxc_intr_id = 0 }; +#endif /* 0 */ -struct vnic_prov_def *vnic_prov_pmm_pin_irq[VIOC_MAX_VNICS] = { +static struct vnic_prov_def *vnic_prov_pmm_pin_irq[VIOC_MAX_VNICS] = { &vnic_set_0, &vnic_set_1, &vnic_set_0, @@ -178,7 +180,7 @@ &vnic_set_1 }; -struct vnic_prov_def *vnic_prov_pmm_msi_x[VIOC_MAX_VNICS] = { +static struct vnic_prov_def *vnic_prov_pmm_msi_x[VIOC_MAX_VNICS] = { &vnic_set_0, &vnic_set_1, &vnic_set_2, @@ -197,6 +199,7 @@ &vnic_set_3 }; +#if 0 struct vnic_prov_def *vnic_prov_sim[VIOC_MAX_VNICS] = { &vnic_set_sim, &vnic_set_sim, @@ -215,6 +218,7 @@ &vnic_set_sim, &vnic_set_sim }; +#endif /* 0 */ struct vnic_prov_def **vioc_prov_get(int num_rx_irq) { --- linux-2.6.20-mm1/drivers/net/vioc/vioc_receive.c.old 2007-02-18 01:34:23.000000000 +0100 +++ linux-2.6.20-mm1/drivers/net/vioc/vioc_receive.c 2007-02-18 01:34:30.000000000 +0100 @@ -58,7 +58,7 @@ * one RxSet, no locking is needed on RxDQs or RxCQs. * Return true if we got a packet, false if the queue is empty. */ -int vioc_rx_pkt(struct vioc_device *viocdev, struct rxc *rxc, u32 sw_idx) +static int vioc_rx_pkt(struct vioc_device *viocdev, struct rxc *rxc, u32 sw_idx) { u32 rx_status; u32 vnic_id; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/