drivers/net: Use kzalloc
[safe/jmp/linux-2.6] / drivers / net / fs_enet / mac-fcc.c
index e363211..714da96 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/ptrace.h>
 #include <linux/errno.h>
 #include <linux/ioport.h>
-#include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/delay.h>
@@ -33,6 +32,8 @@
 #include <linux/fs.h>
 #include <linux/platform_device.h>
 #include <linux/phy.h>
+#include <linux/of_device.h>
+#include <linux/gfp.h>
 
 #include <asm/immap_cpm2.h>
 #include <asm/mpc8260.h>
 #include <asm/irq.h>
 #include <asm/uaccess.h>
 
-#ifdef CONFIG_PPC_CPM_NEW_BINDING
-#include <asm/of_device.h>
-#endif
-
 #include "fs_enet.h"
 
 /*************************************************/
@@ -87,7 +84,6 @@ static inline int fcc_cr_cmd(struct fs_enet_private *fep, u32 op)
 
 static int do_pd_setup(struct fs_enet_private *fep)
 {
-#ifdef CONFIG_PPC_CPM_NEW_BINDING
        struct of_device *ofdev = to_of_device(fep->dev);
        struct fs_platform_info *fpi = fep->fpi;
        int ret = -EINVAL;
@@ -125,65 +121,16 @@ out_fccp:
        iounmap(fep->fcc.fccp);
 out:
        return ret;
-#else
-       struct platform_device *pdev = to_platform_device(fep->dev);
-       struct resource *r;
-
-       /* Fill out IRQ field */
-       fep->interrupt = platform_get_irq(pdev, 0);
-       if (fep->interrupt < 0)
-               return -EINVAL;
-
-       /* Attach the memory for the FCC Parameter RAM */
-       r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fcc_pram");
-       fep->fcc.ep = ioremap(r->start, r->end - r->start + 1);
-       if (fep->fcc.ep == NULL)
-               return -EINVAL;
-
-       r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fcc_regs");
-       fep->fcc.fccp = ioremap(r->start, r->end - r->start + 1);
-       if (fep->fcc.fccp == NULL)
-               return -EINVAL;
-
-       if (fep->fpi->fcc_regs_c) {
-               fep->fcc.fcccp = (void __iomem *)fep->fpi->fcc_regs_c;
-       } else {
-               r = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-                               "fcc_regs_c");
-               fep->fcc.fcccp = ioremap(r->start,
-                               r->end - r->start + 1);
-       }
-
-       if (fep->fcc.fcccp == NULL)
-               return -EINVAL;
-
-       fep->fcc.mem = (void __iomem *)fep->fpi->mem_offset;
-       if (fep->fcc.mem == NULL)
-               return -EINVAL;
-
-       return 0;
-#endif
 }
 
 #define FCC_NAPI_RX_EVENT_MSK  (FCC_ENET_RXF | FCC_ENET_RXB)
 #define FCC_RX_EVENT           (FCC_ENET_RXF)
 #define FCC_TX_EVENT           (FCC_ENET_TXB)
-#define FCC_ERR_EVENT_MSK      (FCC_ENET_TXE | FCC_ENET_BSY)
+#define FCC_ERR_EVENT_MSK      (FCC_ENET_TXE)
 
 static int setup_data(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
-#ifndef CONFIG_PPC_CPM_NEW_BINDING
-       struct fs_platform_info *fpi = fep->fpi;
-
-       fpi->cp_command = (fpi->cp_page << 26) |
-                         (fpi->cp_block << 21) |
-                         (12 << 6);
-
-       fep->fcc.idx = fs_get_fcc_index(fpi->fs_no);
-       if ((unsigned int)fep->fcc.idx >= 3)    /* max 3 FCCs */
-               return -EINVAL;
-#endif
 
        if (do_pd_setup(fep) != 0)
                return -EINVAL;
@@ -271,7 +218,7 @@ static void set_multicast_finish(struct net_device *dev)
 
        /* if all multi or too many multicasts; just enable all */
        if ((dev->flags & IFF_ALLMULTI) != 0 ||
-           dev->mc_count > FCC_MAX_MULTICAST_ADDRS) {
+           netdev_mc_count(dev) > FCC_MAX_MULTICAST_ADDRS) {
 
                W32(ep, fen_gaddrh, 0xffffffff);
                W32(ep, fen_gaddrl, 0xffffffff);
@@ -284,12 +231,12 @@ static void set_multicast_finish(struct net_device *dev)
 
 static void set_multicast_list(struct net_device *dev)
 {
-       struct dev_mc_list *pmc;
+       struct netdev_hw_addr *ha;
 
        if ((dev->flags & IFF_PROMISC) == 0) {
                set_multicast_start(dev);
-               for (pmc = dev->mc_list; pmc != NULL; pmc = pmc->next)
-                       set_multicast_one(dev, pmc->dmi_addr);
+               netdev_for_each_mc_addr(ha, dev)
+                       set_multicast_one(dev, ha->addr);
                set_multicast_finish(dev);
        } else
                set_promiscuous_mode(dev);
@@ -304,9 +251,6 @@ static void restart(struct net_device *dev)
        fcc_enet_t __iomem *ep = fep->fcc.ep;
        dma_addr_t rx_bd_base_phys, tx_bd_base_phys;
        u16 paddrh, paddrm, paddrl;
-#ifndef CONFIG_PPC_CPM_NEW_BINDING
-       u16 mem_addr;
-#endif
        const unsigned char *mac;
        int i;
 
@@ -338,19 +282,10 @@ static void restart(struct net_device *dev)
         * this area.
         */
 
-#ifdef CONFIG_PPC_CPM_NEW_BINDING
        W16(ep, fen_genfcc.fcc_riptr, fpi->dpram_offset);
        W16(ep, fen_genfcc.fcc_tiptr, fpi->dpram_offset + 32);
 
        W16(ep, fen_padptr, fpi->dpram_offset + 64);
-#else
-       mem_addr = (u32) fep->fcc.mem;  /* de-fixup dpram offset */
-
-       W16(ep, fen_genfcc.fcc_riptr, (mem_addr & 0xffff));
-       W16(ep, fen_genfcc.fcc_tiptr, ((mem_addr + 32) & 0xffff));
-
-       W16(ep, fen_padptr, mem_addr + 64);
-#endif
 
        /* fill with special symbol...  */
        memset_io(fep->fcc.mem + fpi->dpram_offset + 64, 0x88, 32);
@@ -463,6 +398,9 @@ static void restart(struct net_device *dev)
        else
                C32(fccp, fcc_fpsmr, FCC_PSMR_FDE | FCC_PSMR_LPB);
 
+       /* Restore multicast and promiscuous settings */
+       set_multicast_list(dev);
+
        S32(fccp, fcc_gfmr, FCC_GFMR_ENR | FCC_GFMR_ENT);
 }
 
@@ -483,16 +421,6 @@ static void stop(struct net_device *dev)
        fs_cleanup_bds(dev);
 }
 
-static void pre_request_irq(struct net_device *dev, int irq)
-{
-       /* nothing */
-}
-
-static void post_free_irq(struct net_device *dev, int irq)
-{
-       /* nothing */
-}
-
 static void napi_clear_rx_event(struct net_device *dev)
 {
        struct fs_enet_private *fep = netdev_priv(dev);
@@ -548,8 +476,9 @@ static void clear_int_events(struct net_device *dev, u32 int_events)
 
 static void ev_error(struct net_device *dev, u32 int_events)
 {
-       printk(KERN_WARNING DRV_MODULE_NAME
-              ": %s FS_ENET ERROR(s) 0x%x\n", dev->name, int_events);
+       struct fs_enet_private *fep = netdev_priv(dev);
+
+       dev_warn(fep->dev, "FS_ENET ERROR(s) 0x%x\n", int_events);
 }
 
 static int get_regs(struct net_device *dev, void *p, int *sizep)
@@ -602,8 +531,6 @@ const struct fs_ops fs_fcc_ops = {
        .set_multicast_list     = set_multicast_list,
        .restart                = restart,
        .stop                   = stop,
-       .pre_request_irq        = pre_request_irq,
-       .post_free_irq          = post_free_irq,
        .napi_clear_rx_event    = napi_clear_rx_event,
        .napi_enable_rx         = napi_enable_rx,
        .napi_disable_rx        = napi_disable_rx,