1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-12-25 14:52:05 +02:00

Clean up the r6040 driver using checkpatch

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@9184 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
florian 2007-10-08 08:01:30 +00:00
parent f68eab92c4
commit cb792c90e6

View File

@ -13,10 +13,12 @@
Modification List
---------- ------------------------------------------------
10-07-2007 Clean up the driver using checkpatch
08-24-2006 Support at linux 2.6.10 above
03-24-2006 Support NAPI
03-21-2006 By Charies,change spin_lock_irqsave(lp->lock, flags) to
spin_lock_irqsave(&lp->lock, flags) in set_multicast_list
03-21-2006 By Charies,change spin_lock_irqsave(lp->lock, flags)
to spin_lock_irqsave(&lp->lock, flags)
in set_multicast_list
03-15-2006 Modify the set_multicast_list ,due to when re-plug the ethernet,
it will forget the previous setting
07-12-2005 Tim, modify the set_multicast_list
@ -65,11 +67,14 @@
#define ALLOC_DESC_SIZE ((TX_DCNT+RX_DCNT)*sizeof(struct r6040_descriptor)+0x10)
#define MBCR_DEFAULT 0x012A /* MAC Bus Control Register */
/* PHY settings */
#define ICPLUS_PHY_ID 0x0243
/* Debug enable or not */
#define RDC_DEBUG 0
#if RDC_DEBUG > 1
#define RDC_DBUG(msg, value) printk("%s %x\n", msg, value);
#define RDC_DBUG(msg, value) printk(KERN_ERR "%s %x\n", msg, value);
#else
#define RDC_DBUG(msg, value)
#endif
@ -92,7 +97,7 @@
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/init.h>
#include <linux/delay.h> /* for udelay() */
#include <linux/delay.h>
#include <linux/mii.h>
#include <linux/ethtool.h>
#include <linux/crc32.h>
@ -104,7 +109,7 @@
#include <asm/irq.h>
#include <asm/uaccess.h>
MODULE_AUTHOR("Sten Wang <sten.wang@rdc.com.tw>");
MODULE_AUTHOR("Sten Wang <sten.wang@rdc.com.tw>, Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>, Florian Fainelli <florian@openwrt.org>");
MODULE_LICENSE("GPL");
#ifdef CONFIG_R6040_NAPI
MODULE_DESCRIPTION("RDC R6040 NAPI PCI FastEthernet Driver");
@ -127,7 +132,7 @@ struct r6040_descriptor {
struct r6040_private {
struct net_device_stats stats;
spinlock_t lock;
spinlock_t lock; /* driver lock */
struct timer_list timer;
struct pci_dev *pdev;
@ -165,7 +170,7 @@ static struct r6040_chip_info r6040_chip_info[] __devinitdata =
{
{ "RDC R6040 Knight", R6040_PCI_CMD, R6040_IO_SIZE, 0}
};
static char *parent = NULL;
static char *parent;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)
static int NUM_MAC_TABLE = 2 ;
@ -176,7 +181,10 @@ MODULE_PARM(parent, "s");
MODULE_PARM_DESC(parent, "Parent network device name");
static int phy_table[] = { 0x1, 0x2};
static u8 adr_table[2][8] = {{0x00, 0x00, 0x60, 0x00, 0x00, 0x01}, {0x00, 0x00, 0x60, 0x00, 0x00, 0x02}};
static u8 adr_table[2][8] = {
{0x00, 0x00, 0x60, 0x00, 0x00, 0x01},
{0x00, 0x00, 0x60, 0x00, 0x00, 0x02}
};
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 10)
module_param_array(adr_table, int, &NUM_MAC_TABLE, 0644);
@ -221,9 +229,10 @@ static int __devinit r6040_init_one (struct pci_dev *pdev,
RDC_DBUG("r6040_init_one()", 0);
if (printed_version++)
printk(version);
printk(KERN_INFO version);
if ((err = pci_enable_device (pdev)))
err = pci_enable_device(pdev);
if (err)
return err;
/* this should always be supported */
@ -288,7 +297,8 @@ static int __devinit r6040_init_one (struct pci_dev *pdev,
#endif
/* Register net device. After this dev->name assign */
if ((err = register_netdev(dev))) {
err = register_netdev(dev);
if (err) {
printk(KERN_ERR DRV_NAME ": Failed to register net device\n");
goto err_out_res;
}
@ -331,14 +341,14 @@ r6040_open(struct net_device *dev)
/* Allocate Descriptor memory */
lp->desc_pool = pci_alloc_consistent(lp->pdev, ALLOC_DESC_SIZE, &lp->desc_dma);
if (!lp->desc_pool) return -ENOMEM;
if (!lp->desc_pool)
return -ENOMEM;
r6040_up(dev);
netif_start_queue(dev);
if (lp->switch_sig != 0x0243)
{
if (lp->switch_sig != ICPLUS_PHY_ID) {
/* set and active a timer process */
init_timer(&lp->timer);
lp->timer.expires = TIMER_WUT;
@ -353,8 +363,8 @@ static void
r6040_tx_timeout (struct net_device *dev)
{
struct r6040_private *lp = dev->priv;
//int ioaddr = dev->base_addr;
//struct r6040_descriptor *descptr = lp->tx_remove_ptr;
/* int ioaddr = dev->base_addr;
struct r6040_descriptor *descptr = lp->tx_remove_ptr; */
RDC_DBUG("r6040_tx_timeout()", 0);
@ -404,8 +414,11 @@ r6040_start_xmit(struct sk_buff *skb, struct net_device *dev)
/* Set TX descriptor & Transmit it */
lp->tx_free_desc--;
descptr = lp->tx_insert_ptr;
if (skb->len < 0x3c) descptr->len = 0x3c;
else descptr->len = skb->len;
if (skb->len < 0x3c)
descptr->len = 0x3c;
else
descptr->len = skb->len;
descptr->skb_ptr = skb;
descptr->buf = cpu_to_le32(pci_map_single(lp->pdev, skb->data, skb->len, PCI_DMA_TODEVICE));
descptr->status = 0x8000;
@ -457,9 +470,7 @@ r6040_interrupt(int irq, void *dev_id)
#ifdef CONFIG_R6040_NAPI
if(netif_rx_schedule_prep(dev))
{
if (netif_rx_schedule_prep(dev)) {
NAPI_status = status;
__netif_rx_schedule(dev);
}
@ -472,7 +483,8 @@ r6040_interrupt(int irq, void *dev_id)
handled = 1;
descptr = lp->tx_remove_ptr;
while (lp->tx_free_desc < TX_DCNT) {
if (descptr->status & 0x8000) break; /* Not complte */
if (descptr->status & 0x8000)
break; /* Not complte */
skb_ptr = descptr->skb_ptr;
pci_unmap_single(lp->pdev, descptr->buf, skb_ptr->len, PCI_DMA_TODEVICE);
dev_kfree_skb_irq(skb_ptr); /* Free buffer */
@ -481,7 +493,8 @@ r6040_interrupt(int irq, void *dev_id)
lp->tx_free_desc++;
}
lp->tx_remove_ptr = descptr;
if (lp->tx_free_desc) netif_wake_queue(dev);
if (lp->tx_free_desc)
netif_wake_queue(dev);
}
/* RX interrupt request */
@ -552,12 +565,13 @@ set_multicast_list(struct net_device *dev)
/* Promiscous Mode */
spin_lock_irqsave(&lp->lock, flags);
i = inw(ioaddr) & ~0x0120; /* Clear AMCP & PROM */
if (dev->flags & IFF_PROMISC)
{
if (dev->flags & IFF_PROMISC) {
i |= 0x0020;
lp->mcr0 |= 0x0020;
}
if (dev->mc_count > 4) i |= 0x0020; /* Too many multicast address */
if (dev->mc_count > 4)
i |= 0x0020; /* Too many multicast address */
outw(i, ioaddr);
spin_unlock_irqrestore(&lp->lock, flags);
@ -622,8 +636,8 @@ static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
struct r6040_private *lp = dev->priv;
RDC_DBUG("netdev_ioctl()", 0);
if (lp->switch_sig == 0x0243 && cmd == SIOCDEVPRIVATE)
{
if (lp->switch_sig == ICPLUS_PHY_ID && cmd == SIOCDEVPRIVATE) {
unsigned long *data = (unsigned long *)rq->ifr_data, args[4];
int ioaddr = dev->base_addr;
unsigned int val;
@ -701,15 +715,14 @@ static int r6040_poll(struct net_device *dev, int *budget)
lp = (struct r6040_private *)dev->priv;
unsigned long rx_work = dev->quota;
unsigned long rx;
#if 1
/* TX interrupt request */
if (NAPI_status & 0x10) {
descptr = lp->tx_remove_ptr;
while (lp->tx_free_desc < TX_DCNT) {
if (descptr->status & 0x8000) break; /* Not complte */
if (descptr->status & 0x8000)
break; /* Not complte */
skb_ptr = descptr->skb_ptr;
pci_unmap_single(lp->pdev, descptr->buf, skb_ptr->len, PCI_DMA_TODEVICE);
dev_kfree_skb_irq(skb_ptr); /* Free buffer */
@ -724,10 +737,10 @@ static int r6040_poll(struct net_device *dev, int *budget)
#if 1
/* RX interrupt request */
if (NAPI_status & 0x01) {
descptr = lp->rx_remove_ptr;
while (lp->rx_free_desc) {
if (descptr->status & 0x8000) break; /* No Rx packet */
if (descptr->status & 0x8000)
break; /* No Rx packet */
skb_ptr = descptr->skb_ptr;
descptr->skb_ptr = 0;
skb_ptr->dev = dev;
@ -741,10 +754,10 @@ static int r6040_poll(struct net_device *dev, int *budget)
lp->rx_free_desc--;
}
lp->rx_remove_ptr = descptr;
}
/* Allocate new RX buffer */
if (lp->rx_free_desc < RX_DCNT) rx_buf_alloc(lp,dev);
if (lp->rx_free_desc < RX_DCNT)
rx_buf_alloc(lp, dev);
local_irq_disable();
netif_rx_complete(dev);
@ -838,9 +851,8 @@ for (i = 0; i < RX_DCNT; i++) {
/* Buffer Size Register */
outw(MAX_BUF_SIZE, ioaddr+0x18);
if ((lp->switch_sig = phy_read(ioaddr, 0, 2)) == 0x0243) // ICPlus IP175C Signature
{
phy_write(ioaddr, 29,31, 0x175C); //Enable registers
if ((lp->switch_sig = phy_read(ioaddr, 0, 2)) == ICPLUS_PHY_ID) {
phy_write(ioaddr, 29,31, 0x175C); /* Enable registers */
lp->phy_mode = 0x8000;
} else {
/* PHY Mode Check */
@ -888,13 +900,14 @@ static void r6040_timer(unsigned long data)
/* Polling PHY Chip Status */
if (PHY_MODE == 0x3100)
phy_mode = phy_mode_chk(dev);
else phy_mode = (PHY_MODE & 0x0100) ? 0x8000:0x0;
else
phy_mode = (PHY_MODE & 0x0100) ? 0x8000:0x0;
if (phy_mode != lp->phy_mode) {
lp->phy_mode = phy_mode;
lp->mcr0 = (lp->mcr0 & 0x7fff) | phy_mode;
outw(lp->mcr0, ioaddr);
printk("<RDC> Link Change %x \n", inw(ioaddr));
printk(KERN_INFO "Link Change %x \n", inw(ioaddr));
}
/* Debug */
@ -912,15 +925,18 @@ static void rx_buf_alloc(struct r6040_private *lp,struct net_device *dev)
int ioaddr = dev->base_addr ;
RDC_DBUG("rx_buf_alloc()", 0);
descptr = lp->rx_insert_ptr;
while (lp->rx_free_desc < RX_DCNT) {
descptr->skb_ptr = dev_alloc_skb(MAX_BUF_SIZE);
if (!descptr->skb_ptr) break;
if (!descptr->skb_ptr)
break;
descptr->buf = cpu_to_le32(pci_map_single(lp->pdev, descptr->skb_ptr->tail, MAX_BUF_SIZE, PCI_DMA_FROMDEVICE));
descptr->status = 0x8000;
descptr = descptr->vndescp;
lp->rx_free_desc++;
outw(lp->mcr0 | 0x0002, ioaddr); //Trigger Rx DMA
outw(lp->mcr0 | 0x0002, ioaddr); /* Trigger Rx DMA */
}
lp->rx_insert_ptr = descptr;
}
@ -935,7 +951,8 @@ static int phy_mode_chk(struct net_device *dev)
/* PHY Link Status Check */
phy_dat = phy_read(ioaddr, lp->phy_addr, 1);
if (!(phy_dat & 0x4)) return 0x8000; /* Link Failed, full duplex */
if (!(phy_dat & 0x4))
return 0x8000; /* Link Failed, full duplex */
/* PHY Chip Auto-Negotiation Status */
phy_dat = phy_read(ioaddr, lp->phy_addr, 1);
@ -943,8 +960,10 @@ static int phy_mode_chk(struct net_device *dev)
/* Auto Negotiation Mode */
phy_dat = phy_read(ioaddr, lp->phy_addr, 5);
phy_dat &= phy_read(ioaddr, lp->phy_addr, 4);
if (phy_dat & 0x140) phy_dat = 0x8000;
else phy_dat = 0;
if (phy_dat & 0x140)
phy_dat = 0x8000;
else
phy_dat = 0;
} else {
/* Force Mode */
phy_dat = phy_read(ioaddr, lp->phy_addr, 0);
@ -984,8 +1003,9 @@ enum {
static struct pci_device_id r6040_pci_tbl[] = {
{0x17F3, 0x6040, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RDC_6040},
//{0x1106, 0x3065, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RDC_6040},
{0,} /* terminate list */
/* {PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_R6040, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RDC_6040},*/
/*{0x1106, 0x3065, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RDC_6040},*/
{0,}
};
MODULE_DEVICE_TABLE(pci, r6040_pci_tbl);
@ -1001,15 +1021,13 @@ static int __init r6040_init (void)
{
RDC_DBUG("r6040_init()", 0);
printk(version);
printk(KERN_INFO version);
printed_version = 1;
if (parent != NULL)
{
if (parent != NULL) {
struct net_device *the_parent = dev_get_by_name(parent);
if (the_parent == NULL)
{
if (the_parent == NULL) {
printk (KERN_ERR DRV_NAME ": Unknown device \"%s\" specified.\n", parent);
return -EINVAL;
}
@ -1029,13 +1047,3 @@ static void __exit r6040_cleanup (void)
module_init(r6040_init);
module_exit(r6040_cleanup);
/*
* Local variables:
* compile-command: "gcc -DMODULE -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -c r6040.c `[ -f /usr/include/linux/modversions.h ] && echo -DMODVERSIONS`"
* c-indent-level: 4
* c-basic-offset: 4
* tab-width: 4
* End:
*/