net: use bitrev8
Subsystems (3)
PATCH 4/6 net: use bitrev8
Use bitrev8 for bmac, mace, macmace, macsonic, and skfp drivers.
drivers/net/Kconfig | 1 drivers/net/bmac.c | 20 ++-------- drivers/net/mace.c | 16 +------- drivers/net/macmace.c | 18 +-------- drivers/net/macsonic.c | 6 --- drivers/net/skfp/can.c | 83 --------------------------------------------- drivers/net/skfp/drvfbi.c | 21 ++++------- drivers/net/skfp/fplustm.c | 4 +- drivers/net/skfp/smt.c | 7 +-- 9 files changed, 25 insertions(+), 151 deletions(-)
drivers/net/bmac.c +4 -16
@@ -18,6 +18,7 @@#include <linux/init.h> #include <linux/spinlock.h> #include <linux/crc32.h> +#include <linux/bitrev.h> #include <asm/prom.h> #include <asm/dbdma.h> #include <asm/io.h>
@@ -140,7 +141,6 @@ static unsigned char *bmac_emergency_rxb + (N_RX_RING + N_TX_RING + 4) * sizeof(struct dbdma_cmd) \ + sizeof(struct sk_buff_head)) -static unsigned char bitrev (unsigned char b);static int bmac_open (struct net_device *dev);static int bmac_close (struct net_device *dev);static int bmac_transmit_packet (struct sk_buff *skb,struct net_device *dev);
@@ -586,18 +586,6 @@ bmac_construct_rxbuff(struct sk_buff *sk virt_to_bus(addr), 0); } -/* Bit-reverse one byte of an ethernet hardware address. */ -static unsigned char -bitrev (unsigned char b) -{ -int d =0 , i; - -for (i =0 ; i <8 ; ++i, b >>=1 ) - d = (d <<1 ) | (b &1 ); -return d; -} - -static void bmac_init_tx_ring (struct bmac_data *bp) {
@@ -1224,8 +1212,8 @@ bmac_get_station_address(struct net_devi {reset_and_select_srom (dev); data =read_srom (dev, i + EnetAddressOffset/2 , SROMAddressBits); - ea[2 *i] =bitrev (data &0x0ff ); - ea[2 *i+1 ] =bitrev ((data >>8 ) &0x0ff ); + ea[2 *i] =bitrev8 (data &0x0ff ); + ea[2 *i+1 ] =bitrev8 ((data >>8 ) &0x0ff ); } }
@@ -1315,7 +1303,7 @@ static int __devinit bmac_probe(struct m rev = addr[0 ] ==0 && addr[1 ] ==0xA0 ;for (j =0 ; j <6 ; ++j) - dev->dev_addr[j] = rev?bitrev (addr[j]): addr[j]; + dev->dev_addr[j] = rev ?bitrev8 (addr[j]): addr[j];/* Enable chip without interrupts for now */ bmac_enable_and_reset_chip (dev);
drivers/net/mace.c +2 -14
@@ -15,6 +15,7 @@#include <linux/init.h> #include <linux/crc32.h> #include <linux/spinlock.h> +#include <linux/bitrev.h> #include <asm/prom.h> #include <asm/dbdma.h> #include <asm/io.h>
@@ -74,7 +75,6 @@ struct mace_data {#define PRIV_BYTES (sizeof(struct mace_data) \ + (N_RX_RING + NCMDS_TX * N_TX_RING + 3) * sizeof(struct dbdma_cmd)) -static int bitrev (int );static int mace_open (struct net_device *dev);static int mace_close (struct net_device *dev);static int mace_xmit_start (struct sk_buff *skb,struct net_device *dev);
@@ -96,18 +96,6 @@ static void __mace_set_address(struct ne*/ static unsigned char *dummy_buf; -/* Bit-reverse one byte of an ethernet hardware address. */ -static inline int -bitrev (int b) -{ -int d =0 , i; - -for (i =0 ; i <8 ; ++i, b >>=1 ) - d = (d <<1 ) | (b &1 ); -return d; -} - -static int __devinit mace_probe (struct macio_dev *mdev,const struct of_device_id *match) {struct device_node *mace =macio_get_of_node (mdev);
@@ -173,7 +161,7 @@ static int __devinit mace_probe(struct m rev = addr[0 ] ==0 && addr[1 ] ==0xA0 ;for (j =0 ; j <6 ; ++j) { - dev->dev_addr[j] = rev?bitrev (addr[j]): addr[j]; + dev->dev_addr[j] = rev ?bitrev8 (addr[j]): addr[j]; } mp->chipid = (in_8 (&mp->mace->chipid_hi) <<8 ) |in_8 (&mp->mace->chipid_lo);
drivers/net/macmace.c +3 -15
@@ -22,6 +22,7 @@#include <linux/delay.h> #include <linux/string.h> #include <linux/crc32.h> +#include <linux/bitrev.h> #include <asm/io.h> #include <asm/pgtable.h> #include <asm/irq.h>
@@ -81,19 +82,6 @@ static irqreturn_t mace_interrupt(int irstatic irqreturn_t mace_dma_intr (int irq,void *dev_id);static void mace_tx_timeout (struct net_device *dev); -/* Bit-reverse one byte of an ethernet hardware address. */ - -static int bitrev (int b) -{ -int d =0 , i; - -for (i =0 ; i <8 ; ++i, b >>=1 ) { - d = (d <<1 ) | (b &1 ); - } - -return d; -} -/* * Load a receive DMA channel with a base address and ring length */
@@ -219,12 +207,12 @@ struct net_device *mace_probe(int unit) addr = (void *)MACE_PROM ;for (j =0 ; j <6 ; ++j) { -u8 v=bitrev (addr[j<<4 ]); +u8 v =bitrev8 (addr[j<<4 ]); checksum ^= v; dev->dev_addr[j] = v; }for (; j <8 ; ++j) { - checksum ^=bitrev (addr[j<<4 ]); + checksum ^=bitrev8 (addr[j<<4 ]); }if (checksum !=0xFF ) {
drivers/net/macsonic.c +1 -5
@@ -121,16 +121,12 @@ enum macsonic_type {* For reversing the PROM address */ -static unsigned char nibbletab[] = {0 ,8 ,4 ,12 ,2 ,10 ,6 ,14 , -1 ,9 ,5 ,13 ,3 ,11 ,7 ,15 }; -static inline void bit_reverse_addr (unsigned char addr[6 ]) {int i;for (i =0 ; i <6 ; i++) - addr[i] = ((nibbletab[addr[i] &0xf ] <<4 ) | - nibbletab[(addr[i] >>4 ) &0xf ]); + addr[i] =bitrev8 (addr[i]); }int __init macsonic_init (struct net_device * dev)
drivers/net/skfp/can.c deleted +0 -83
83 lines not on this page · raw message
drivers/net/skfp/drvfbi.c +9 -12
@@ -23,6 +23,7 @@#include "h/smc.h" #include "h/supern_2.h" #include "h/skfbiinc.h" +#include <linux/bitrev.h> #ifndef lintstatic const char ID_sccs[] ="@(#)drvfbi.c 1.63 99/02/11 (C) SK " ;
@@ -445,16 +446,14 @@ void read_address(struct s_smc *smc, u_cchar PmdType ;int i ; -extern const u_char canonical[256 ] ; -#if (defined(ISA ) || defined(MCA ))for (i =0 ; i <4 ;i++) {/* read mac address from board */ smc->hw.fddi_phys_addr.a[i] = - canonical[(inpw (PR_A (i+SA_MAC ))&0xff )] ; + byte_rev_table[(inpw (PR_A (i+SA_MAC ))&0xff )] ; }for (i =4 ; i <6 ; i++) { smc->hw.fddi_phys_addr.a[i] = - canonical[(inpw (PR_A (i+SA_MAC +PRA_OFF ))&0xff )] ; + byte_rev_table[(inpw (PR_A (i+SA_MAC +PRA_OFF ))&0xff )] ; }#endif #ifdef EISA
@@ -464,17 +463,17 @@ void read_address(struct s_smc *smc, u_c*/ for (i =0 ; i <4 ;i++) {/* read mac address from board */ smc->hw.fddi_phys_addr.a[i] = - canonical[inp (PR_A (i+SA_MAC ))] ; + byte_rev_table[inp (PR_A (i+SA_MAC ))] ; }for (i =4 ; i <6 ; i++) { smc->hw.fddi_phys_addr.a[i] = - canonical[inp (PR_A (i+SA_MAC +PRA_OFF ))] ; + byte_rev_table[inp (PR_A (i+SA_MAC +PRA_OFF ))] ; }#endif #ifdef PCI for (i =0 ; i <6 ; i++) {/* read mac address from board */ smc->hw.fddi_phys_addr.a[i] = - canonical[inp (ADDR (B2_MAC_0 +i))] ; + byte_rev_table[inp (ADDR (B2_MAC_0 +i))] ; }#endif #ifndef PCI
@@ -493,7 +492,7 @@ void read_address(struct s_smc *smc, u_cif (mac_addr) {for (i =0 ; i <6 ;i++) { smc->hw.fddi_canon_addr.a[i] = mac_addr[i] ; - smc->hw.fddi_home_addr.a[i] = canonical[mac_addr[i]] ; + smc->hw.fddi_home_addr.a[i] = byte_rev_table[mac_addr[i]] ; }return ; }
@@ -501,7 +500,7 @@ void read_address(struct s_smc *smc, u_cfor (i =0 ; i <6 ;i++) { smc->hw.fddi_canon_addr.a[i] = - canonical[smc->hw.fddi_phys_addr.a[i]] ; + byte_rev_table[smc->hw.fddi_phys_addr.a[i]] ; } }
@@ -1269,10 +1268,8 @@ void driver_get_bia(struct s_smc *smc, s {int i ; -extern const u_char canonical[256 ] ; -for (i =0 ; i <6 ; i++) { - bia_addr->a[i] = canonical[smc->hw.fddi_phys_addr.a[i]] ; + bia_addr->a[i] = byte_rev_table[smc->hw.fddi_phys_addr.a[i]] ; } }
drivers/net/skfp/fplustm.c +2 -2
@@ -22,7 +22,7 @@#include "h/fddi.h" #include "h/smc.h" #include "h/supern_2.h" -#include "can.c" +#include <linux/bitrev.h> #ifndef lintstatic const char ID_sccs[] ="@(#)fplustm.c 1.32 99/02/23 (C) SK " ;
@@ -1073,7 +1073,7 @@ static struct s_fpmc* mac_get_mc_table(sif (can) { p = own->a ;for (i =0 ; i <6 ; i++, p++) - *p = canonical[*p] ; + *p = byte_rev_table[*p] ; } slot =NULL ;for (i =0 , tb = smc->hw.fp.mc.table ; i <FPMAX_MULTICAST ; i++, tb++){
drivers/net/skfp/smt.c +3 -4
@@ -18,6 +18,7 @@#include "h/fddi.h" #include "h/smc.h" #include "h/smt_p.h" +#include <linux/bitrev.h> #define KERNEL #include "h/smtstate.h"
@@ -26,8 +27,6 @@static const char ID_sccs[] ="@(#)smt.c 2.43 98/11/23 (C) SK " ;#endif -extern const u_char canonical[256 ] ; -/* * FC in SMbuf */
@@ -180,7 +179,7 @@ void smt_agent_init(struct s_smc *smc)driver_get_bia (smc,&smc->mib.fddiSMTStationId.sid_node) ;for (i =0 ; i <6 ; i ++) { smc->mib.fddiSMTStationId.sid_node.a[i] = - canonical[smc->mib.fddiSMTStationId.sid_node.a[i]] ; + byte_rev_table[smc->mib.fddiSMTStationId.sid_node.a[i]] ; } smc->mib.fddiSMTManufacturerData[0 ] = smc->mib.fddiSMTStationId.sid_node.a[0 ] ;
@@ -2050,7 +2049,7 @@ static void hwm_conv_can(struct s_smc *sSK_UNUSED (smc) ;for (i = len; i ; i--, data++) { - *data = canonical[*(u_char *)data] ; + *data = byte_rev_table[*(u_char *)data] ; } }#endif
drivers/net/Kconfig +1 -0
@@ -2500,6 +2500,7 @@ config DEFXX config SKFP tristate "SysKonnect FDDI PCI support" depends on FDDI && PCI + select BITREVERSE ---help--- Say Y here if you have a SysKonnect FDDI PCI adapter. The following adapters are supported by this driver:
Quoted 8 lines · On Thu, 19 Oct 2006 01:46:47 +0900 Akinobu Mita <[email protected]> wrote:
Use bitrev8 for bmac, mace, macmace, macsonic, and skfp drivers.
Cc Jeff Garzik <[email protected]>Cc Paul Mackerras <[email protected]>Cc Mirko Lindner <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Signed-off-by Akinobu Mita <[email protected]>
Quoted 9 lines
drivers/net/Kconfig | 1 drivers/net/bmac.c | 20 ++-------- drivers/net/mace.c | 16 +------- drivers/net/macmace.c | 18 +-------- drivers/net/macsonic.c | 6 --- drivers/net/skfp/can.c | 83 --------------------------------------------- drivers/net/skfp/drvfbi.c | 21 ++++------- drivers/net/skfp/fplustm.c | 4 +- drivers/net/skfp/smt.c | 7 +--
A bunch of drivers.
drivers/net/Kconfig config DEFXX · line 2506
Quoted 11 lines
===================================================================
drivers/net/Kconfig +1
-0@@ -2500,6 +2500,7 @@ config DEFXX config SKFP tristate "SysKonnect FDDI PCI support" depends on FDDI && PCI + select BITREVERSE ---help--- Say Y here if you have a SysKonnect FDDI PCI adapter. The following adapters are supported by this driver:
But only one of them selects the library.
The patchset adds a large number of `select' statements. afaict everything _seems_ to work OK with that (as long as all the needed selects are there).
But select is problematic and I do wonder whether it'd be simpler to just link the thing into vmlinux.
Oh well, we'll see how it goes.
Quoted 15 lines · Andrew Morton
A bunch of drivers.
drivers/net/Kconfig config DEFXX · line 2506
Quoted 11 lines
===================================================================
drivers/net/Kconfig +1
-0@@ -2500,6 +2500,7 @@ config DEFXX config SKFP tristate "SysKonnect FDDI PCI support" depends on FDDI && PCI + select BITREVERSE ---help--- Say Y here if you have a SysKonnect FDDI PCI adapter. The following adapters are supported by this driver:But only one of them selects the library.
Other drivers already select CRC32 and CRC32 selects BITREVERSE.
Quoted 2 lines
But select is problematic and I do wonder whether it'd be simpler to just link the thing into vmlinux.
OK. I'll try.
Quoted 5 lines · Andrew Morton
Quoted 2 lines · On Thu, 19 Oct 2006 01:46:47 +0900 Akinobu Mita <[email protected]> wrote:
Use bitrev8 for bmac, mace, macmace, macsonic, and skfp drivers.
[]
Quoted 12 lines
drivers/net/Kconfig config DEFXX · line 2506
Quoted 11 lines
===================================================================
drivers/net/Kconfig +1
-0@@ -2500,6 +2500,7 @@ config DEFXX config SKFP tristate "SysKonnect FDDI PCI support" depends on FDDI && PCI + select BITREVERSE ---help--- Say Y here if you have a SysKonnect FDDI PCI adapter. The following adapters are supported by this driver:
[]
Quoted 2 lines
But select is problematic and I do wonder whether it'd be simpler to just link the thing into vmlinux.
Why it's problematic? Maintenance costs of various missing selects? I don't want extra stuff in kernel (vmlinux) if it's not used.
/mjt