convert some DMA_nnBIT_MASK() callers
[safe/jmp/linux-2.6] / drivers / net / dm9000.c
index 5a9083e..dd771de 100644 (file)
@@ -137,7 +137,7 @@ typedef struct board_info {
 
 static inline board_info_t *to_dm9000_board(struct net_device *dev)
 {
-       return dev->priv;
+       return netdev_priv(dev);
 }
 
 /* DM9000 network board routine ---------------------------- */
@@ -559,7 +559,7 @@ static void dm9000_show_carrier(board_info_t *db,
 static void
 dm9000_poll_work(struct work_struct *w)
 {
-       struct delayed_work *dw = container_of(w, struct delayed_work, work);
+       struct delayed_work *dw = to_delayed_work(w);
        board_info_t *db = container_of(dw, board_info_t, phy_poll);
        struct net_device *ndev = db->ndev;
 
@@ -626,7 +626,7 @@ static unsigned char dm9000_type_to_char(enum dm9000_type type)
 static void
 dm9000_hash_table(struct net_device *dev)
 {
-       board_info_t *db = (board_info_t *) dev->priv;
+       board_info_t *db = netdev_priv(dev);
        struct dev_mc_list *mcptr = dev->mc_list;
        int mc_cnt = dev->mc_count;
        int i, oft;
@@ -677,7 +677,7 @@ dm9000_hash_table(struct net_device *dev)
 static void
 dm9000_init_dm9000(struct net_device *dev)
 {
-       board_info_t *db = dev->priv;
+       board_info_t *db = netdev_priv(dev);
        unsigned int imr;
 
        dm9000_dbg(db, 1, "entering %s\n", __func__);
@@ -723,7 +723,7 @@ dm9000_init_dm9000(struct net_device *dev)
 /* Our watchdog timed out. Called by the networking layer */
 static void dm9000_timeout(struct net_device *dev)
 {
-       board_info_t *db = (board_info_t *) dev->priv;
+       board_info_t *db = netdev_priv(dev);
        u8 reg_save;
        unsigned long flags;
 
@@ -751,12 +751,12 @@ static int
 dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        unsigned long flags;
-       board_info_t *db = dev->priv;
+       board_info_t *db = netdev_priv(dev);
 
        dm9000_dbg(db, 3, "%s:\n", __func__);
 
        if (db->tx_pkt_cnt > 1)
-               return 1;
+               return NETDEV_TX_BUSY;
 
        spin_lock_irqsave(&db->lock, flags);
 
@@ -831,7 +831,7 @@ struct dm9000_rxhdr {
 static void
 dm9000_rx(struct net_device *dev)
 {
-       board_info_t *db = (board_info_t *) dev->priv;
+       board_info_t *db = netdev_priv(dev);
        struct dm9000_rxhdr rxhdr;
        struct sk_buff *skb;
        u8 rxbyte, *rdptr;
@@ -928,15 +928,17 @@ dm9000_rx(struct net_device *dev)
 static irqreturn_t dm9000_interrupt(int irq, void *dev_id)
 {
        struct net_device *dev = dev_id;
-       board_info_t *db = dev->priv;
+       board_info_t *db = netdev_priv(dev);
        int int_status;
+       unsigned long flags;
        u8 reg_save;
 
        dm9000_dbg(db, 3, "entering %s\n", __func__);
 
        /* A real interrupt coming */
 
-       spin_lock(&db->lock);
+       /* holders of db->lock must always block IRQs */
+       spin_lock_irqsave(&db->lock, flags);
 
        /* Save previous register address */
        reg_save = readb(db->io_addr);
@@ -972,7 +974,7 @@ static irqreturn_t dm9000_interrupt(int irq, void *dev_id)
        /* Restore previous register address */
        writeb(reg_save, db->io_addr);
 
-       spin_unlock(&db->lock);
+       spin_unlock_irqrestore(&db->lock, flags);
 
        return IRQ_HANDLED;
 }
@@ -996,7 +998,7 @@ static void dm9000_poll_controller(struct net_device *dev)
 static int
 dm9000_open(struct net_device *dev)
 {
-       board_info_t *db = dev->priv;
+       board_info_t *db = netdev_priv(dev);
        unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK;
 
        if (netif_msg_ifup(db))
@@ -1046,7 +1048,7 @@ static void dm9000_msleep(board_info_t *db, unsigned int ms)
 static int
 dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
 {
-       board_info_t *db = (board_info_t *) dev->priv;
+       board_info_t *db = netdev_priv(dev);
        unsigned long flags;
        unsigned int reg_save;
        int ret;
@@ -1093,7 +1095,7 @@ static void
 dm9000_phy_write(struct net_device *dev,
                 int phyaddr_unused, int reg, int value)
 {
-       board_info_t *db = (board_info_t *) dev->priv;
+       board_info_t *db = netdev_priv(dev);
        unsigned long flags;
        unsigned long reg_save;
 
@@ -1134,7 +1136,7 @@ dm9000_phy_write(struct net_device *dev,
 static void
 dm9000_shutdown(struct net_device *dev)
 {
-       board_info_t *db = dev->priv;
+       board_info_t *db = netdev_priv(dev);
 
        /* RESET device */
        dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET); /* PHY RESET */
@@ -1150,7 +1152,7 @@ dm9000_shutdown(struct net_device *dev)
 static int
 dm9000_stop(struct net_device *ndev)
 {
-       board_info_t *db = ndev->priv;
+       board_info_t *db = netdev_priv(ndev);
 
        if (netif_msg_ifdown(db))
                dev_dbg(db->dev, "shutting down %s\n", ndev->name);
@@ -1168,6 +1170,21 @@ dm9000_stop(struct net_device *ndev)
        return 0;
 }
 
+static const struct net_device_ops dm9000_netdev_ops = {
+       .ndo_open               = dm9000_open,
+       .ndo_stop               = dm9000_stop,
+       .ndo_start_xmit         = dm9000_start_xmit,
+       .ndo_tx_timeout         = dm9000_timeout,
+       .ndo_set_multicast_list = dm9000_hash_table,
+       .ndo_do_ioctl           = dm9000_ioctl,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_validate_addr      = eth_validate_addr,
+       .ndo_set_mac_address    = eth_mac_addr,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+       .ndo_poll_controller    = dm9000_poll_controller,
+#endif
+};
+
 #define res_size(_r) (((_r)->end - (_r)->start) + 1)
 
 /*
@@ -1197,7 +1214,7 @@ dm9000_probe(struct platform_device *pdev)
        dev_dbg(&pdev->dev, "dm9000_probe()\n");
 
        /* setup board info structure */
-       db = ndev->priv;
+       db = netdev_priv(ndev);
        memset(db, 0, sizeof(*db));
 
        db->dev = &pdev->dev;
@@ -1337,18 +1354,9 @@ dm9000_probe(struct platform_device *pdev)
        /* driver system function */
        ether_setup(ndev);
 
-       ndev->open               = &dm9000_open;
-       ndev->hard_start_xmit    = &dm9000_start_xmit;
-       ndev->tx_timeout         = &dm9000_timeout;
-       ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
-       ndev->stop               = &dm9000_stop;
-       ndev->set_multicast_list = &dm9000_hash_table;
-       ndev->ethtool_ops        = &dm9000_ethtool_ops;
-       ndev->do_ioctl           = &dm9000_ioctl;
-
-#ifdef CONFIG_NET_POLL_CONTROLLER
-       ndev->poll_controller    = &dm9000_poll_controller;
-#endif
+       ndev->netdev_ops        = &dm9000_netdev_ops;
+       ndev->watchdog_timeo    = msecs_to_jiffies(watchdog);
+       ndev->ethtool_ops       = &dm9000_ethtool_ops;
 
        db->msg_enable       = NETIF_MSG_LINK;
        db->mii.phy_id_mask  = 0x1f;
@@ -1385,13 +1393,11 @@ dm9000_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, ndev);
        ret = register_netdev(ndev);
 
-       if (ret == 0) {
-               DECLARE_MAC_BUF(mac);
-               printk(KERN_INFO "%s: dm9000%c at %p,%p IRQ %d MAC: %s (%s)\n",
+       if (ret == 0)
+               printk(KERN_INFO "%s: dm9000%c at %p,%p IRQ %d MAC: %pM (%s)\n",
                       ndev->name, dm9000_type_to_char(db->type),
                       db->io_addr, db->io_data, ndev->irq,
-                      print_mac(mac, ndev->dev_addr), mac_src);
-       }
+                      ndev->dev_addr, mac_src);
        return 0;
 
 out:
@@ -1410,7 +1416,7 @@ dm9000_drv_suspend(struct platform_device *dev, pm_message_t state)
        board_info_t *db;
 
        if (ndev) {
-               db = (board_info_t *) ndev->priv;
+               db = netdev_priv(ndev);
                db->in_suspend = 1;
 
                if (netif_running(ndev)) {
@@ -1425,7 +1431,7 @@ static int
 dm9000_drv_resume(struct platform_device *dev)
 {
        struct net_device *ndev = platform_get_drvdata(dev);
-       board_info_t *db = (board_info_t *) ndev->priv;
+       board_info_t *db = netdev_priv(ndev);
 
        if (ndev) {
 
@@ -1449,7 +1455,7 @@ dm9000_drv_remove(struct platform_device *pdev)
        platform_set_drvdata(pdev, NULL);
 
        unregister_netdev(ndev);
-       dm9000_release_board(pdev, (board_info_t *) ndev->priv);
+       dm9000_release_board(pdev, (board_info_t *) netdev_priv(ndev));
        free_netdev(ndev);              /* free device structure */
 
        dev_dbg(&pdev->dev, "released and freed device\n");