vserver 1.9.5.x5
[linux-2.6.git] / drivers / net / sunhme.c
index 5c2917c..1b2c4b9 100644 (file)
@@ -36,9 +36,9 @@ static char version[] =
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/skbuff.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/dma.h>
 #include <asm/byteorder.h>
@@ -68,10 +68,12 @@ static char version[] =
 #include "sunhme.h"
 
 
+#define DRV_NAME "sunhme"
+
 static int macaddr[6];
 
 /* accept MAC address of the form macaddr=0x08,0x00,0x20,0x30,0x40,0x50 */
-MODULE_PARM(macaddr, "6i");
+module_param_array(macaddr, int, NULL, 0);
 MODULE_PARM_DESC(macaddr, "Happy Meal MAC address to set");
 MODULE_LICENSE("GPL");
 
@@ -201,12 +203,12 @@ MODULE_DEVICE_TABLE(pci, happymeal_pci_ids);
  */
 
 #if defined(CONFIG_SBUS) && defined(CONFIG_PCI)
-static void sbus_hme_write32(unsigned long reg, u32 val)
+static void sbus_hme_write32(void __iomem *reg, u32 val)
 {
        sbus_writel(val, reg);
 }
 
-static u32 sbus_hme_read32(unsigned long reg)
+static u32 sbus_hme_read32(void __iomem *reg)
 {
        return sbus_readl(reg);
 }
@@ -230,12 +232,12 @@ static u32 sbus_hme_read_desc32(u32 *p)
        return *p;
 }
 
-static void pci_hme_write32(unsigned long reg, u32 val)
+static void pci_hme_write32(void __iomem *reg, u32 val)
 {
        writel(val, reg);
 }
 
-static u32 pci_hme_read32(unsigned long reg)
+static u32 pci_hme_read32(void __iomem *reg)
 {
        return readl(reg);
 }
@@ -352,7 +354,7 @@ do {        (__txd)->tx_addr = cpu_to_le32(__addr); \
 
 
 /* Oh yes, the MIF BitBang is mighty fun to program.  BitBucket is more like it. */
-static void BB_PUT_BIT(struct happy_meal *hp, unsigned long tregs, int bit)
+static void BB_PUT_BIT(struct happy_meal *hp, void __iomem *tregs, int bit)
 {
        hme_write32(hp, tregs + TCVR_BBDATA, bit);
        hme_write32(hp, tregs + TCVR_BBCLOCK, 0);
@@ -360,7 +362,7 @@ static void BB_PUT_BIT(struct happy_meal *hp, unsigned long tregs, int bit)
 }
 
 #if 0
-static u32 BB_GET_BIT(struct happy_meal *hp, unsigned long tregs, int internal)
+static u32 BB_GET_BIT(struct happy_meal *hp, void __iomem *tregs, int internal)
 {
        u32 ret;
 
@@ -376,7 +378,7 @@ static u32 BB_GET_BIT(struct happy_meal *hp, unsigned long tregs, int internal)
 }
 #endif
 
-static u32 BB_GET_BIT2(struct happy_meal *hp, unsigned long tregs, int internal)
+static u32 BB_GET_BIT2(struct happy_meal *hp, void __iomem *tregs, int internal)
 {
        u32 retval;
 
@@ -395,7 +397,7 @@ static u32 BB_GET_BIT2(struct happy_meal *hp, unsigned long tregs, int internal)
 #define TCVR_FAILURE      0x80000000     /* Impossible MIF read value */
 
 static int happy_meal_bb_read(struct happy_meal *hp,
-                             unsigned long tregs, int reg)
+                             void __iomem *tregs, int reg)
 {
        u32 tmp;
        int retval = 0;
@@ -441,7 +443,7 @@ static int happy_meal_bb_read(struct happy_meal *hp,
 }
 
 static void happy_meal_bb_write(struct happy_meal *hp,
-                               unsigned long tregs, int reg,
+                               void __iomem *tregs, int reg,
                                unsigned short value)
 {
        u32 tmp;
@@ -486,7 +488,7 @@ static void happy_meal_bb_write(struct happy_meal *hp,
 #define TCVR_READ_TRIES   16
 
 static int happy_meal_tcvr_read(struct happy_meal *hp,
-                               unsigned long tregs, int reg)
+                               void __iomem *tregs, int reg)
 {
        int tries = TCVR_READ_TRIES;
        int retval;
@@ -518,7 +520,7 @@ static int happy_meal_tcvr_read(struct happy_meal *hp,
 #define TCVR_WRITE_TRIES  16
 
 static void happy_meal_tcvr_write(struct happy_meal *hp,
-                                 unsigned long tregs, int reg,
+                                 void __iomem *tregs, int reg,
                                  unsigned short value)
 {
        int tries = TCVR_WRITE_TRIES;
@@ -526,8 +528,10 @@ static void happy_meal_tcvr_write(struct happy_meal *hp,
        ASD(("happy_meal_tcvr_write: reg=0x%02x value=%04x\n", reg, value));
 
        /* Welcome to Sun Microsystems, can I take your order please? */
-       if (!(hp->happy_flags & HFLAG_FENABLE))
-               return happy_meal_bb_write(hp, tregs, reg, value);
+       if (!(hp->happy_flags & HFLAG_FENABLE)) {
+               happy_meal_bb_write(hp, tregs, reg, value);
+               return;
+       }
 
        /* Would you like fries with that? */
        hme_write32(hp, tregs + TCVR_FRAME,
@@ -575,7 +579,7 @@ static void happy_meal_tcvr_write(struct happy_meal *hp,
  * service routine, and the chip is reset, or the link is ifconfig'd down
  * and then back up, this entire process repeats itself all over again.
  */
-static int try_next_permutation(struct happy_meal *hp, unsigned long tregs)
+static int try_next_permutation(struct happy_meal *hp, void __iomem *tregs)
 {
        hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR);
 
@@ -599,7 +603,7 @@ static int try_next_permutation(struct happy_meal *hp, unsigned long tregs)
        return -1;
 }
 
-static void display_link_mode(struct happy_meal *hp, unsigned long tregs)
+static void display_link_mode(struct happy_meal *hp, void __iomem *tregs)
 {
        printk(KERN_INFO "%s: Link is up using ", hp->dev->name);
        if (hp->tcvr_type == external)
@@ -621,7 +625,7 @@ static void display_link_mode(struct happy_meal *hp, unsigned long tregs)
        }
 }
 
-static void display_forced_link_mode(struct happy_meal *hp, unsigned long tregs)
+static void display_forced_link_mode(struct happy_meal *hp, void __iomem *tregs)
 {
        printk(KERN_INFO "%s: Link has been forced up using ", hp->dev->name);
        if (hp->tcvr_type == external)
@@ -640,7 +644,7 @@ static void display_forced_link_mode(struct happy_meal *hp, unsigned long tregs)
                printk("Half Duplex.\n");
 }
 
-static int set_happy_link_modes(struct happy_meal *hp, unsigned long tregs)
+static int set_happy_link_modes(struct happy_meal *hp, void __iomem *tregs)
 {
        int full;
 
@@ -704,7 +708,7 @@ static int happy_meal_init(struct happy_meal *hp);
 
 static int is_lucent_phy(struct happy_meal *hp)
 {
-       unsigned long tregs = hp->tcvregs;
+       void __iomem *tregs = hp->tcvregs;
        unsigned short mr2, mr3;
        int ret = 0;
 
@@ -720,7 +724,7 @@ static int is_lucent_phy(struct happy_meal *hp)
 static void happy_meal_timer(unsigned long data)
 {
        struct happy_meal *hp = (struct happy_meal *) data;
-       unsigned long tregs = hp->tcvregs;
+       void __iomem *tregs = hp->tcvregs;
        int restart_timer = 0;
 
        spin_lock_irq(&hp->happy_lock);
@@ -901,7 +905,7 @@ out:
 #define RX_RESET_TRIES     32
 
 /* hp->happy_lock must be held */
-static void happy_meal_tx_reset(struct happy_meal *hp, unsigned long bregs)
+static void happy_meal_tx_reset(struct happy_meal *hp, void __iomem *bregs)
 {
        int tries = TX_RESET_TRIES;
 
@@ -921,7 +925,7 @@ static void happy_meal_tx_reset(struct happy_meal *hp, unsigned long bregs)
 }
 
 /* hp->happy_lock must be held */
-static void happy_meal_rx_reset(struct happy_meal *hp, unsigned long bregs)
+static void happy_meal_rx_reset(struct happy_meal *hp, void __iomem *bregs)
 {
        int tries = RX_RESET_TRIES;
 
@@ -943,7 +947,7 @@ static void happy_meal_rx_reset(struct happy_meal *hp, unsigned long bregs)
 #define STOP_TRIES         16
 
 /* hp->happy_lock must be held */
-static void happy_meal_stop(struct happy_meal *hp, unsigned long gregs)
+static void happy_meal_stop(struct happy_meal *hp, void __iomem *gregs)
 {
        int tries = STOP_TRIES;
 
@@ -963,7 +967,7 @@ static void happy_meal_stop(struct happy_meal *hp, unsigned long gregs)
 }
 
 /* hp->happy_lock must be held */
-static void happy_meal_get_counters(struct happy_meal *hp, unsigned long bregs)
+static void happy_meal_get_counters(struct happy_meal *hp, void __iomem *bregs)
 {
        struct net_device_stats *stats = &hp->net_stats;
 
@@ -986,7 +990,7 @@ static void happy_meal_get_counters(struct happy_meal *hp, unsigned long bregs)
 }
 
 /* hp->happy_lock must be held */
-static void happy_meal_poll_stop(struct happy_meal *hp, unsigned long tregs)
+static void happy_meal_poll_stop(struct happy_meal *hp, void __iomem *tregs)
 {
        ASD(("happy_meal_poll_stop: "));
 
@@ -1021,7 +1025,7 @@ static void happy_meal_poll_stop(struct happy_meal *hp, unsigned long tregs)
 #define TCVR_UNISOLATE_TRIES   32 /* Dis-isolation can take longer. */
 
 /* hp->happy_lock must be held */
-static int happy_meal_tcvr_reset(struct happy_meal *hp, unsigned long tregs)
+static int happy_meal_tcvr_reset(struct happy_meal *hp, void __iomem *tregs)
 {
        u32 tconfig;
        int result, tries = TCVR_RESET_TRIES;
@@ -1119,7 +1123,7 @@ static int happy_meal_tcvr_reset(struct happy_meal *hp, unsigned long tregs)
  *
  * hp->happy_lock must be held
  */
-static void happy_meal_transceiver_check(struct happy_meal *hp, unsigned long tregs)
+static void happy_meal_transceiver_check(struct happy_meal *hp, void __iomem *tregs)
 {
        unsigned long tconfig = hme_read32(hp, tregs + TCVR_CFG);
 
@@ -1314,7 +1318,7 @@ static void happy_meal_init_rings(struct happy_meal *hp)
 
 /* hp->happy_lock must be held */
 static void happy_meal_begin_auto_negotiation(struct happy_meal *hp,
-                                             unsigned long tregs,
+                                             void __iomem *tregs,
                                              struct ethtool_cmd *ep)
 {
        int timeout;
@@ -1439,11 +1443,11 @@ force_link:
 /* hp->happy_lock must be held */
 static int happy_meal_init(struct happy_meal *hp)
 {
-       unsigned long gregs        = hp->gregs;
-       unsigned long etxregs      = hp->etxregs;
-       unsigned long erxregs      = hp->erxregs;
-       unsigned long bregs        = hp->bigmacregs;
-       unsigned long tregs        = hp->tcvregs;
+       void __iomem *gregs        = hp->gregs;
+       void __iomem *etxregs      = hp->etxregs;
+       void __iomem *erxregs      = hp->erxregs;
+       void __iomem *bregs        = hp->bigmacregs;
+       void __iomem *tregs        = hp->tcvregs;
        u32 regtmp, rxcfg;
        unsigned char *e = &hp->dev->dev_addr[0];
 
@@ -1732,9 +1736,9 @@ static int happy_meal_init(struct happy_meal *hp)
 /* hp->happy_lock must be held */
 static void happy_meal_set_initial_advertisement(struct happy_meal *hp)
 {
-       unsigned long tregs     = hp->tcvregs;
-       unsigned long bregs     = hp->bigmacregs;
-       unsigned long gregs     = hp->gregs;
+       void __iomem *tregs     = hp->tcvregs;
+       void __iomem *bregs     = hp->bigmacregs;
+       void __iomem *gregs     = hp->gregs;
 
        happy_meal_stop(hp, gregs);
        hme_write32(hp, tregs + TCVR_IMASK, 0xffff);
@@ -1906,7 +1910,7 @@ static int happy_meal_is_not_so_happy(struct happy_meal *hp, u32 status)
 /* hp->happy_lock must be held */
 static void happy_meal_mif_interrupt(struct happy_meal *hp)
 {
-       unsigned long tregs = hp->tcvregs;
+       void __iomem *tregs = hp->tcvregs;
 
        printk(KERN_INFO "%s: Link status change.\n", hp->dev->name);
        hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR);
@@ -2386,7 +2390,7 @@ static struct net_device_stats *happy_meal_get_stats(struct net_device *dev)
 static void happy_meal_set_multicast(struct net_device *dev)
 {
        struct happy_meal *hp = dev->priv;
-       unsigned long bregs = hp->bigmacregs;
+       void __iomem *bregs = hp->bigmacregs;
        struct dev_mc_list *dmi = dev->mc_list;
        char *addrs;
        int i;
@@ -2920,7 +2924,8 @@ static int is_quattro_p(struct pci_dev *pdev)
        struct list_head *tmp;
        int n_hmes;
 
-       if (busdev->vendor != PCI_VENDOR_ID_DEC ||
+       if (busdev == NULL ||
+           busdev->vendor != PCI_VENDOR_ID_DEC ||
            busdev->device != PCI_DEVICE_ID_DEC_21153)
                return 0;
 
@@ -2943,12 +2948,12 @@ static int is_quattro_p(struct pci_dev *pdev)
 }
 
 /* Fetch MAC address from vital product data of PCI ROM. */
-static void find_eth_addr_in_vpd(void *rom_base, int len, int index, unsigned char *dev_addr)
+static void find_eth_addr_in_vpd(void __iomem *rom_base, int len, int index, unsigned char *dev_addr)
 {
        int this_offset;
 
        for (this_offset = 0x20; this_offset < len; this_offset++) {
-               void *p = rom_base + this_offset;
+               void __iomem *p = rom_base + this_offset;
 
                if (readb(p + 0) != 0x90 ||
                    readb(p + 1) != 0x00 ||
@@ -2975,7 +2980,7 @@ static void find_eth_addr_in_vpd(void *rom_base, int len, int index, unsigned ch
 static void get_hme_mac_nonsparc(struct pci_dev *pdev, unsigned char *dev_addr)
 {
        u32 rom_reg_orig;
-       void *p;
+       void __iomem *p;
        int index;
 
        index = 0;
@@ -3020,7 +3025,8 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev)
 #endif
        struct happy_meal *hp;
        struct net_device *dev;
-       unsigned long hpreg_base;
+       void __iomem *hpreg_base;
+       unsigned long hpreg_res;
        int i, qfe_slot = -1;
        char prom_name[64];
        int err;
@@ -3079,19 +3085,19 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev)
                qp->happy_meals[qfe_slot] = dev;
        }               
 
-       hpreg_base = pci_resource_start(pdev, 0);
+       hpreg_res = pci_resource_start(pdev, 0);
        err = -ENODEV;
        if ((pci_resource_flags(pdev, 0) & IORESOURCE_IO) != 0) {
                printk(KERN_ERR "happymeal(PCI): Cannot find proper PCI device base address.\n");
                goto err_out_clear_quattro;
        }
-       if (pci_request_regions(pdev, dev->name)) {
+       if (pci_request_regions(pdev, DRV_NAME)) {
                printk(KERN_ERR "happymeal(PCI): Cannot obtain PCI resources, "
                       "aborting.\n");
                goto err_out_clear_quattro;
        }
 
-       if ((hpreg_base = (unsigned long) ioremap(hpreg_base, 0x8000)) == 0) {
+       if ((hpreg_base = ioremap(hpreg_res, 0x8000)) == 0) {
                printk(KERN_ERR "happymeal(PCI): Unable to remap card memory.\n");
                goto err_out_free_res;
        }
@@ -3251,7 +3257,7 @@ static int __init happy_meal_pci_init(struct pci_dev *pdev)
        return 0;
 
 err_out_iounmap:
-       iounmap((void *)hp->gregs);
+       iounmap(hp->gregs);
 
 err_out_free_res:
        pci_release_regions(pdev);
@@ -3384,7 +3390,7 @@ static void __exit happy_meal_cleanup_module(void)
                                            PAGE_SIZE,
                                            hp->happy_block,
                                            hp->hblock_dvma);
-                       iounmap((void *)hp->gregs);
+                       iounmap(hp->gregs);
                        pci_release_regions(hp->happy_dev);
                }
 #endif