Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bc63eb9c authored by Akinobu Mita's avatar Akinobu Mita Committed by Jeff Garzik
Browse files

net: use bitrev8



Use bitrev8 for bmac, mace, macmace, macsonic, and skfp drivers.

[akpm@osdl.org: use the API, not the array]
Cc: Jeff Garzik <jgarzik@pobox.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mirko Lindner <mlindner@syskonnect.de>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 079ca7da
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2546,6 +2546,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:
+4 −16
Original line number Diff line number Diff line
@@ -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_rxbuf;
	+ (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 *skb, volatile struct dbdma_cmd *cp)
		     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_device *dev, unsigned char *ea)
		{
			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 macio_dev *mdev, const struct of_device_i

	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);
+2 −14
Original line number Diff line number Diff line
@@ -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 net_device *dev, void *addr);
 */
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 macio_dev *mdev, const struct of_device_i

	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);
+3 −15
Original line number Diff line number Diff line
@@ -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 irq, void *dev_id);
static 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) {
+1 −5
Original line number Diff line number Diff line
@@ -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)
Loading