Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
authorDavid S. Miller <davem@davemloft.net>
Wed, 24 Dec 2008 01:56:23 +0000 (17:56 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 24 Dec 2008 01:56:23 +0000 (17:56 -0800)
Conflicts:

drivers/net/ppp_generic.c

1  2 
drivers/net/bnx2.c
drivers/net/jme.h
drivers/net/phy/mdio_bus.c
drivers/net/ppp_generic.c
drivers/net/starfire.c
net/bluetooth/rfcomm/core.c
net/socket.c

diff --combined drivers/net/bnx2.c
index 33d69ddc90a3c26797d34e3d59662f10c0e3ae1a,9e8222f9e90ee0f69416ffe985103d0f6b183df5..d4a3dac21dcfb83fdc7e6c2835705ac66433ec3c
@@@ -57,8 -57,8 +57,8 @@@
  
  #define DRV_MODULE_NAME               "bnx2"
  #define PFX DRV_MODULE_NAME   ": "
 -#define DRV_MODULE_VERSION    "1.8.1"
 -#define DRV_MODULE_RELDATE    "Oct 7, 2008"
 +#define DRV_MODULE_VERSION    "1.9.0"
 +#define DRV_MODULE_RELDATE    "Dec 16, 2008"
  
  #define RUN_AT(x) (jiffies + (x))
  
@@@ -89,7 -89,6 +89,7 @@@ typedef enum 
        BCM5709,
        BCM5709S,
        BCM5716,
 +      BCM5716S,
  } board_t;
  
  /* indexed by board_t, above */
@@@ -106,7 -105,6 +106,7 @@@ static struct 
        { "Broadcom NetXtreme II BCM5709 1000Base-T" },
        { "Broadcom NetXtreme II BCM5709 1000Base-SX" },
        { "Broadcom NetXtreme II BCM5716 1000Base-T" },
 +      { "Broadcom NetXtreme II BCM5716 1000Base-SX" },
        };
  
  static DEFINE_PCI_DEVICE_TABLE(bnx2_pci_tbl) = {
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5709S },
        { PCI_VENDOR_ID_BROADCOM, 0x163b,
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5716 },
 +      { PCI_VENDOR_ID_BROADCOM, 0x163c,
 +        PCI_ANY_ID, PCI_ANY_ID, 0, 0, BCM5716S },
        { 0, }
  };
  
@@@ -547,9 -543,9 +547,9 @@@ bnx2_free_rx_mem(struct bnx2 *bp
                for (j = 0; j < bp->rx_max_pg_ring; j++) {
                        if (rxr->rx_pg_desc_ring[j])
                                pci_free_consistent(bp->pdev, RXBD_RING_SIZE,
-                                                   rxr->rx_pg_desc_ring[i],
-                                                   rxr->rx_pg_desc_mapping[i]);
-                       rxr->rx_pg_desc_ring[i] = NULL;
+                                                   rxr->rx_pg_desc_ring[j],
+                                                   rxr->rx_pg_desc_mapping[j]);
+                       rxr->rx_pg_desc_ring[j] = NULL;
                }
                if (rxr->rx_pg_ring)
                        vfree(rxr->rx_pg_ring);
@@@ -1656,7 -1652,7 +1656,7 @@@ bnx2_setup_serdes_phy(struct bnx2 *bp, 
                 * exchanging base pages plus 3 next pages and
                 * normally completes in about 120 msec.
                 */
 -              bp->current_interval = SERDES_AN_TIMEOUT;
 +              bp->current_interval = BNX2_SERDES_AN_TIMEOUT;
                bp->serdes_an_pending = 1;
                mod_timer(&bp->timer, jiffies + bp->current_interval);
        } else {
@@@ -2278,7 -2274,7 +2278,7 @@@ bnx2_fw_sync(struct bnx2 *bp, u32 msg_d
                return 0;
  
        /* wait for an acknowledgement. */
 -      for (i = 0; i < (FW_ACK_TIME_OUT_MS / 10); i++) {
 +      for (i = 0; i < (BNX2_FW_ACK_TIME_OUT_MS / 10); i++) {
                msleep(10);
  
                val = bnx2_shmem_rd(bp, BNX2_FW_MB);
@@@ -3004,6 -3000,7 +3004,6 @@@ bnx2_rx_int(struct bnx2 *bp, struct bnx
  #endif
                        netif_receive_skb(skb);
  
 -              bp->dev->last_rx = jiffies;
                rx_pkt++;
  
  next_rx:
@@@ -3043,6 -3040,7 +3043,6 @@@ bnx2_msi(int irq, void *dev_instance
  {
        struct bnx2_napi *bnapi = dev_instance;
        struct bnx2 *bp = bnapi->bp;
 -      struct net_device *dev = bp->dev;
  
        prefetch(bnapi->status_blk.msi);
        REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
        if (unlikely(atomic_read(&bp->intr_sem) != 0))
                return IRQ_HANDLED;
  
 -      netif_rx_schedule(dev, &bnapi->napi);
 +      netif_rx_schedule(&bnapi->napi);
  
        return IRQ_HANDLED;
  }
@@@ -3063,6 -3061,7 +3063,6 @@@ bnx2_msi_1shot(int irq, void *dev_insta
  {
        struct bnx2_napi *bnapi = dev_instance;
        struct bnx2 *bp = bnapi->bp;
 -      struct net_device *dev = bp->dev;
  
        prefetch(bnapi->status_blk.msi);
  
        if (unlikely(atomic_read(&bp->intr_sem) != 0))
                return IRQ_HANDLED;
  
 -      netif_rx_schedule(dev, &bnapi->napi);
 +      netif_rx_schedule(&bnapi->napi);
  
        return IRQ_HANDLED;
  }
@@@ -3080,6 -3079,7 +3080,6 @@@ bnx2_interrupt(int irq, void *dev_insta
  {
        struct bnx2_napi *bnapi = dev_instance;
        struct bnx2 *bp = bnapi->bp;
 -      struct net_device *dev = bp->dev;
        struct status_block *sblk = bnapi->status_blk.msi;
  
        /* When using INTx, it is possible for the interrupt to arrive
        if (unlikely(atomic_read(&bp->intr_sem) != 0))
                return IRQ_HANDLED;
  
 -      if (netif_rx_schedule_prep(dev, &bnapi->napi)) {
 +      if (netif_rx_schedule_prep(&bnapi->napi)) {
                bnapi->last_status_idx = sblk->status_idx;
 -              __netif_rx_schedule(dev, &bnapi->napi);
 +              __netif_rx_schedule(&bnapi->napi);
        }
  
        return IRQ_HANDLED;
@@@ -3218,7 -3218,7 +3218,7 @@@ static int bnx2_poll_msix(struct napi_s
                rmb();
                if (likely(!bnx2_has_fast_work(bnapi))) {
  
 -                      netif_rx_complete(bp->dev, napi);
 +                      netif_rx_complete(napi);
                        REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD, bnapi->int_num |
                               BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID |
                               bnapi->last_status_idx);
@@@ -3251,7 -3251,7 +3251,7 @@@ static int bnx2_poll(struct napi_struc
  
                rmb();
                if (likely(!bnx2_has_work(bnapi))) {
 -                      netif_rx_complete(bp->dev, napi);
 +                      netif_rx_complete(napi);
                        if (likely(bp->flags & BNX2_FLAG_USING_MSI_OR_MSIX)) {
                                REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
                                       BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID |
@@@ -4493,7 -4493,7 +4493,7 @@@ bnx2_reset_chip(struct bnx2 *bp, u32 re
  static int
  bnx2_init_chip(struct bnx2 *bp)
  {
 -      u32 val;
 +      u32 val, mtu;
        int rc, i;
  
        /* Make sure the interrupt is not active. */
        REG_WR(bp, BNX2_EMAC_BACKOFF_SEED, val);
  
        /* Program the MTU.  Also include 4 bytes for CRC32. */
 -      val = bp->dev->mtu + ETH_HLEN + 4;
 +      mtu = bp->dev->mtu;
 +      val = mtu + ETH_HLEN + ETH_FCS_LEN;
        if (val > (MAX_ETHERNET_PACKET_SIZE + 4))
                val |= BNX2_EMAC_RX_MTU_SIZE_JUMBO_ENA;
        REG_WR(bp, BNX2_EMAC_RX_MTU_SIZE, val);
  
 +      if (mtu < 1500)
 +              mtu = 1500;
 +
 +      bnx2_reg_wr_ind(bp, BNX2_RBUF_CONFIG, BNX2_RBUF_CONFIG_VAL(mtu));
 +      bnx2_reg_wr_ind(bp, BNX2_RBUF_CONFIG2, BNX2_RBUF_CONFIG2_VAL(mtu));
 +      bnx2_reg_wr_ind(bp, BNX2_RBUF_CONFIG3, BNX2_RBUF_CONFIG3_VAL(mtu));
 +
        for (i = 0; i < BNX2_MAX_MSIX_VEC; i++)
                bp->bnx2_napi[i].last_status_idx = 0;
  
@@@ -5727,7 -5719,7 +5727,7 @@@ bnx2_5708_serdes_timer(struct bnx2 *bp
                bnx2_read_phy(bp, bp->mii_bmcr, &bmcr);
                if (bmcr & BMCR_ANENABLE) {
                        bnx2_enable_forced_2g5(bp);
 -                      bp->current_interval = SERDES_FORCED_TIMEOUT;
 +                      bp->current_interval = BNX2_SERDES_FORCED_TIMEOUT;
                } else {
                        bnx2_disable_forced_2g5(bp);
                        bp->serdes_an_pending = 2;
@@@ -5824,8 -5816,6 +5824,8 @@@ bnx2_enable_msix(struct bnx2 *bp, int m
  {
        int i, rc;
        struct msix_entry msix_ent[BNX2_MAX_MSIX_VEC];
 +      struct net_device *dev = bp->dev;
 +      const int len = sizeof(bp->irq_tbl[0].name);
  
        bnx2_setup_msix_tbl(bp);
        REG_WR(bp, BNX2_PCI_MSIX_CONTROL, BNX2_MAX_MSIX_HW_VEC - 1);
                msix_ent[i].entry = i;
                msix_ent[i].vector = 0;
  
 -              strcpy(bp->irq_tbl[i].name, bp->dev->name);
 +              snprintf(bp->irq_tbl[i].name, len, "%s-%d", dev->name, i);
                bp->irq_tbl[i].handler = bnx2_msi_1shot;
        }
  
@@@ -6183,7 -6173,7 +6183,7 @@@ bnx2_get_stats(struct net_device *dev
  {
        struct bnx2 *bp = netdev_priv(dev);
        struct statistics_block *stats_blk = bp->stats_blk;
 -      struct net_device_stats *net_stats = &bp->net_stats;
 +      struct net_device_stats *net_stats = &dev->stats;
  
        if (bp->stats_blk == NULL) {
                return net_stats;
@@@ -6550,7 -6540,7 +6550,7 @@@ bnx2_nway_reset(struct net_device *dev
  
                spin_lock_bh(&bp->phy_lock);
  
 -              bp->current_interval = SERDES_AN_TIMEOUT;
 +              bp->current_interval = BNX2_SERDES_AN_TIMEOUT;
                bp->serdes_an_pending = 1;
                mod_timer(&bp->timer, jiffies + bp->current_interval);
        }
@@@ -7625,8 -7615,7 +7625,8 @@@ bnx2_init_board(struct pci_dev *pdev, s
  
        if ((CHIP_ID(bp) == CHIP_ID_5708_A0) ||
            (CHIP_ID(bp) == CHIP_ID_5708_B0) ||
 -          (CHIP_ID(bp) == CHIP_ID_5708_B1)) {
 +          (CHIP_ID(bp) == CHIP_ID_5708_B1) ||
 +          !(REG_RD(bp, BNX2_PCI_CONFIG_3) & BNX2_PCI_CONFIG_3_VAUX_PRESET)) {
                bp->flags |= BNX2_FLAG_NO_WOL;
                bp->wol = 0;
        }
@@@ -7735,25 -7724,6 +7735,25 @@@ bnx2_init_napi(struct bnx2 *bp
        }
  }
  
 +static const struct net_device_ops bnx2_netdev_ops = {
 +      .ndo_open               = bnx2_open,
 +      .ndo_start_xmit         = bnx2_start_xmit,
 +      .ndo_stop               = bnx2_close,
 +      .ndo_get_stats          = bnx2_get_stats,
 +      .ndo_set_rx_mode        = bnx2_set_rx_mode,
 +      .ndo_do_ioctl           = bnx2_ioctl,
 +      .ndo_validate_addr      = eth_validate_addr,
 +      .ndo_set_mac_address    = bnx2_change_mac_addr,
 +      .ndo_change_mtu         = bnx2_change_mtu,
 +      .ndo_tx_timeout         = bnx2_tx_timeout,
 +#ifdef BCM_VLAN
 +      .ndo_vlan_rx_register   = bnx2_vlan_rx_register,
 +#endif
 +#if defined(HAVE_POLL_CONTROLLER) || defined(CONFIG_NET_POLL_CONTROLLER)
 +      .ndo_poll_controller    = poll_bnx2,
 +#endif
 +};
 +
  static int __devinit
  bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
  {
        struct bnx2 *bp;
        int rc;
        char str[40];
 -      DECLARE_MAC_BUF(mac);
  
        if (version_printed++ == 0)
                printk(KERN_INFO "%s", version);
                return rc;
        }
  
 -      dev->open = bnx2_open;
 -      dev->hard_start_xmit = bnx2_start_xmit;
 -      dev->stop = bnx2_close;
 -      dev->get_stats = bnx2_get_stats;
 -      dev->set_rx_mode = bnx2_set_rx_mode;
 -      dev->do_ioctl = bnx2_ioctl;
 -      dev->set_mac_address = bnx2_change_mac_addr;
 -      dev->change_mtu = bnx2_change_mtu;
 -      dev->tx_timeout = bnx2_tx_timeout;
 +      dev->netdev_ops = &bnx2_netdev_ops;
        dev->watchdog_timeo = TX_TIMEOUT;
 -#ifdef BCM_VLAN
 -      dev->vlan_rx_register = bnx2_vlan_rx_register;
 -#endif
        dev->ethtool_ops = &bnx2_ethtool_ops;
  
        bp = netdev_priv(dev);
        bnx2_init_napi(bp);
  
 -#if defined(HAVE_POLL_CONTROLLER) || defined(CONFIG_NET_POLL_CONTROLLER)
 -      dev->poll_controller = poll_bnx2;
 -#endif
 -
        pci_set_drvdata(pdev, dev);
  
        memcpy(dev->dev_addr, bp->mac_addr, 6);
        }
  
        printk(KERN_INFO "%s: %s (%c%d) %s found at mem %lx, "
 -              "IRQ %d, node addr %s\n",
 +              "IRQ %d, node addr %pM\n",
                dev->name,
                board_info[ent->driver_data].name,
                ((CHIP_ID(bp) & 0xf000) >> 12) + 'A',
                ((CHIP_ID(bp) & 0x0ff0) >> 4),
                bnx2_bus_string(bp, str),
                dev->base_addr,
 -              bp->pdev->irq, print_mac(mac, dev->dev_addr));
 +              bp->pdev->irq, dev->dev_addr);
  
        return 0;
  }
diff --combined drivers/net/jme.h
index 2d6f30e638fca290dc599e009f80df8be826c90a,3f5d91543246c88936d8fc086abf37c2cd3f6686..5154411b5e6b0821054cdefef093947bf99a8333
@@@ -22,7 -22,7 +22,7 @@@
   */
  
  #ifndef __JME_H_INCLUDED__
- #define __JME_H_INCLUDEE__
+ #define __JME_H_INCLUDED__
  
  #define DRV_NAME      "jme"
  #define DRV_VERSION   "1.0.3"
@@@ -398,15 -398,15 +398,15 @@@ struct jme_ring 
  #define JME_NAPI_WEIGHT(w) int w
  #define JME_NAPI_WEIGHT_VAL(w) w
  #define JME_NAPI_WEIGHT_SET(w, r)
 -#define JME_RX_COMPLETE(dev, napis) netif_rx_complete(dev, napis)
 +#define JME_RX_COMPLETE(dev, napis) netif_rx_complete(napis)
  #define JME_NAPI_ENABLE(priv) napi_enable(&priv->napi);
  #define JME_NAPI_DISABLE(priv) \
        if (!napi_disable_pending(&priv->napi)) \
                napi_disable(&priv->napi);
  #define JME_RX_SCHEDULE_PREP(priv) \
 -      netif_rx_schedule_prep(priv->dev, &priv->napi)
 +      netif_rx_schedule_prep(&priv->napi)
  #define JME_RX_SCHEDULE(priv) \
 -      __netif_rx_schedule(priv->dev, &priv->napi);
 +      __netif_rx_schedule(&priv->napi);
  
  /*
   * Jmac Adapter Private data
@@@ -815,30 -815,16 +815,30 @@@ static inline u32 smi_phy_addr(int x
   * Global Host Control
   */
  enum jme_ghc_bit_mask {
 -      GHC_SWRST       = 0x40000000,
 -      GHC_DPX         = 0x00000040,
 -      GHC_SPEED       = 0x00000030,
 -      GHC_LINK_POLL   = 0x00000001,
 +      GHC_SWRST               = 0x40000000,
 +      GHC_DPX                 = 0x00000040,
 +      GHC_SPEED               = 0x00000030,
 +      GHC_LINK_POLL           = 0x00000001,
  };
  
  enum jme_ghc_speed_val {
 -      GHC_SPEED_10M   = 0x00000010,
 -      GHC_SPEED_100M  = 0x00000020,
 -      GHC_SPEED_1000M = 0x00000030,
 +      GHC_SPEED_10M           = 0x00000010,
 +      GHC_SPEED_100M          = 0x00000020,
 +      GHC_SPEED_1000M         = 0x00000030,
 +};
 +
 +enum jme_ghc_to_clk {
 +      GHC_TO_CLK_OFF          = 0x00000000,
 +      GHC_TO_CLK_GPHY         = 0x00400000,
 +      GHC_TO_CLK_PCIE         = 0x00800000,
 +      GHC_TO_CLK_INVALID      = 0x00C00000,
 +};
 +
 +enum jme_ghc_txmac_clk {
 +      GHC_TXMAC_CLK_OFF       = 0x00000000,
 +      GHC_TXMAC_CLK_GPHY      = 0x00100000,
 +      GHC_TXMAC_CLK_PCIE      = 0x00200000,
 +      GHC_TXMAC_CLK_INVALID   = 0x00300000,
  };
  
  /*
index 8755d8cd41661a4251b75366a19f01c2cfc98b38,289fc267edf30eb5094d24f416ca644c9494d401..7a333601fbe88cf39adf9c2cfc07867f96f6708a
@@@ -97,7 -97,7 +97,7 @@@ int mdiobus_register(struct mii_bus *bu
        bus->dev.parent = bus->parent;
        bus->dev.class = &mdio_bus_class;
        bus->dev.groups = NULL;
 -      memcpy(bus->dev.bus_id, bus->id, MII_BUS_ID_SIZE);
 +      dev_set_name(&bus->dev, bus->id);
  
        err = device_register(&bus->dev);
        if (err) {
                return -EINVAL;
        }
  
-       bus->state = MDIOBUS_REGISTERED;
        mutex_init(&bus->mdio_lock);
  
        if (bus->reset)
                }
        }
  
+       if (!err)
+               bus->state = MDIOBUS_REGISTERED;
        pr_info("%s: probed\n", bus->name);
  
        return err;
@@@ -191,7 -192,7 +192,7 @@@ struct phy_device *mdiobus_scan(struct 
  
        phydev->dev.parent = bus->parent;
        phydev->dev.bus = &mdio_bus_type;
 -      snprintf(phydev->dev.bus_id, BUS_ID_SIZE, PHY_ID_FMT, bus->id, addr);
 +      dev_set_name(&phydev->dev, PHY_ID_FMT, bus->id, addr);
  
        phydev->bus = bus;
  
@@@ -284,12 -285,9 +285,12 @@@ static int mdio_bus_suspend(struct devi
  {
        int ret = 0;
        struct device_driver *drv = dev->driver;
 +      struct phy_driver *phydrv = to_phy_driver(drv);
 +      struct phy_device *phydev = to_phy_device(dev);
  
 -      if (drv && drv->suspend)
 -              ret = drv->suspend(dev, state);
 +      if ((!device_may_wakeup(phydev->dev.parent)) &&
 +              (phydrv && phydrv->suspend))
 +                      ret = phydrv->suspend(phydev);
  
        return ret;
  }
@@@ -298,12 -296,9 +299,12 @@@ static int mdio_bus_resume(struct devic
  {
        int ret = 0;
        struct device_driver *drv = dev->driver;
 +      struct phy_driver *phydrv = to_phy_driver(drv);
 +      struct phy_device *phydev = to_phy_device(dev);
  
 -      if (drv && drv->resume)
 -              ret = drv->resume(dev);
 +      if ((!device_may_wakeup(phydev->dev.parent)) &&
 +              (phydrv && phydrv->resume))
 +              ret = phydrv->resume(phydev);
  
        return ret;
  }
index c832d600d1e8829b72faddd095dfa513e03d03e0,714a23035de1980a968c19a835712d587c007c17..06b448285eb5d0783c104383c12b0e4add6309ea
@@@ -27,7 -27,6 +27,7 @@@
  #include <linux/kmod.h>
  #include <linux/init.h>
  #include <linux/list.h>
 +#include <linux/idr.h>
  #include <linux/netdevice.h>
  #include <linux/poll.h>
  #include <linux/ppp_defs.h>
@@@ -117,6 -116,7 +117,7 @@@ struct ppp 
        unsigned long   last_xmit;      /* jiffies when last pkt sent 9c */
        unsigned long   last_recv;      /* jiffies when last pkt rcvd a0 */
        struct net_device *dev;         /* network interface device a4 */
+       int             closing;        /* is device closing down? a8 */
  #ifdef CONFIG_PPP_MULTILINK
        int             nxchan;         /* next channel to send something on */
        u32             nxseq;          /* next sequence number to send */
@@@ -172,14 -172,36 +173,14 @@@ struct channel 
   * channel.downl.
   */
  
 -/*
 - * A cardmap represents a mapping from unsigned integers to pointers,
 - * and provides a fast "find lowest unused number" operation.
 - * It uses a broad (32-way) tree with a bitmap at each level.
 - * It is designed to be space-efficient for small numbers of entries
 - * and time-efficient for large numbers of entries.
 - */
 -#define CARDMAP_ORDER 5
 -#define CARDMAP_WIDTH (1U << CARDMAP_ORDER)
 -#define CARDMAP_MASK  (CARDMAP_WIDTH - 1)
 -
 -struct cardmap {
 -      int shift;
 -      unsigned long inuse;
 -      struct cardmap *parent;
 -      void *ptr[CARDMAP_WIDTH];
 -};
 -static void *cardmap_get(struct cardmap *map, unsigned int nr);
 -static int cardmap_set(struct cardmap **map, unsigned int nr, void *ptr);
 -static unsigned int cardmap_find_first_free(struct cardmap *map);
 -static void cardmap_destroy(struct cardmap **map);
 -
  /*
   * all_ppp_mutex protects the all_ppp_units mapping.
   * It also ensures that finding a ppp unit in the all_ppp_units map
   * and updating its file.refcnt field is atomic.
   */
  static DEFINE_MUTEX(all_ppp_mutex);
 -static struct cardmap *all_ppp_units;
  static atomic_t ppp_unit_count = ATOMIC_INIT(0);
 +static DEFINE_IDR(ppp_units_idr);
  
  /*
   * all_channels_lock protects all_channels and last_channel_index,
@@@ -248,9 -270,6 +249,9 @@@ static struct channel *ppp_find_channel
  static int ppp_connect_channel(struct channel *pch, int unit);
  static int ppp_disconnect_channel(struct channel *pch);
  static void ppp_destroy_channel(struct channel *pch);
 +static int unit_get(struct idr *p, void *ptr);
 +static void unit_put(struct idr *p, int n);
 +static void *unit_find(struct idr *p, int n);
  
  static struct class *ppp_class;
  
@@@ -868,7 -887,7 +869,7 @@@ out_chrdev
  static int
  ppp_start_xmit(struct sk_buff *skb, struct net_device *dev)
  {
 -      struct ppp *ppp = (struct ppp *) dev->priv;
 +      struct ppp *ppp = netdev_priv(dev);
        int npi, proto;
        unsigned char *pp;
  
  static int
  ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
  {
 -      struct ppp *ppp = dev->priv;
 +      struct ppp *ppp = netdev_priv(dev);
        int err = -EFAULT;
        void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
        struct ppp_stats stats;
        return err;
  }
  
 +static const struct net_device_ops ppp_netdev_ops = {
 +      .ndo_start_xmit = ppp_start_xmit,
 +      .ndo_do_ioctl   = ppp_net_ioctl,
 +};
 +
  static void ppp_setup(struct net_device *dev)
  {
 +      dev->netdev_ops = &ppp_netdev_ops;
        dev->hard_header_len = PPP_HDRLEN;
        dev->mtu = PPP_MTU;
        dev->addr_len = 0;
@@@ -983,7 -996,7 +984,7 @@@ ppp_xmit_process(struct ppp *ppp
        struct sk_buff *skb;
  
        ppp_xmit_lock(ppp);
-       if (ppp->dev) {
+       if (!ppp->closing) {
                ppp_push(ppp);
                while (!ppp->xmit_pending
                       && (skb = skb_dequeue(&ppp->file.xq)))
@@@ -1451,8 -1464,7 +1452,7 @@@ static inline voi
  ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
  {
        ppp_recv_lock(ppp);
-       /* ppp->dev == 0 means interface is closing down */
-       if (ppp->dev)
+       if (!ppp->closing)
                ppp_receive_frame(ppp, skb, pch);
        else
                kfree_skb(skb);
@@@ -1672,6 -1684,7 +1672,6 @@@ ppp_receive_nonmp_frame(struct ppp *ppp
                        skb->protocol = htons(npindex_to_ethertype[npi]);
                        skb_reset_mac_header(skb);
                        netif_rx(skb);
 -                      ppp->dev->last_rx = jiffies;
                }
        }
        return;
@@@ -2401,12 -2414,13 +2401,12 @@@ ppp_create_interface(int unit, int *ret
        int ret = -ENOMEM;
        int i;
  
 -      ppp = kzalloc(sizeof(struct ppp), GFP_KERNEL);
 -      if (!ppp)
 -              goto out;
 -      dev = alloc_netdev(0, "", ppp_setup);
 +      dev = alloc_netdev(sizeof(struct ppp), "", ppp_setup);
        if (!dev)
                goto out1;
  
 +      ppp = netdev_priv(dev);
 +      ppp->dev = dev;
        ppp->mru = PPP_MRU;
        init_ppp_file(&ppp->file, INTERFACE);
        ppp->file.hdrlen = PPP_HDRLEN - 2;      /* don't count proto bytes */
        ppp->minseq = -1;
        skb_queue_head_init(&ppp->mrq);
  #endif /* CONFIG_PPP_MULTILINK */
 -      ppp->dev = dev;
 -      dev->priv = ppp;
 -
 -      dev->hard_start_xmit = ppp_start_xmit;
 -      dev->do_ioctl = ppp_net_ioctl;
  
        ret = -EEXIST;
        mutex_lock(&all_ppp_mutex);
 -      if (unit < 0)
 -              unit = cardmap_find_first_free(all_ppp_units);
 -      else if (cardmap_get(all_ppp_units, unit) != NULL)
 -              goto out2;      /* unit already exists */
 +
 +      if (unit < 0) {
 +              unit = unit_get(&ppp_units_idr, ppp);
 +              if (unit < 0) {
 +                      *retp = unit;
 +                      goto out2;
 +              }
 +      } else {
 +              if (unit_find(&ppp_units_idr, unit))
 +                      goto out2; /* unit already exists */
 +              else {
 +                      /* darn, someone is cheating us? */
 +                      *retp = -EINVAL;
 +                      goto out2;
 +              }
 +      }
  
        /* Initialize the new ppp unit */
        ppp->file.index = unit;
  
        ret = register_netdev(dev);
        if (ret != 0) {
 +              unit_put(&ppp_units_idr, unit);
                printk(KERN_ERR "PPP: couldn't register device %s (%d)\n",
                       dev->name, ret);
                goto out2;
        }
  
        atomic_inc(&ppp_unit_count);
 -      ret = cardmap_set(&all_ppp_units, unit, ppp);
 -      if (ret != 0)
 -              goto out3;
 -
        mutex_unlock(&all_ppp_mutex);
 +
        *retp = 0;
        return ppp;
  
 -out3:
 -      atomic_dec(&ppp_unit_count);
 -      unregister_netdev(dev);
  out2:
        mutex_unlock(&all_ppp_mutex);
        free_netdev(dev);
  out1:
 -      kfree(ppp);
 -out:
        *retp = ret;
        return NULL;
  }
@@@ -2484,19 -2498,17 +2484,17 @@@ init_ppp_file(struct ppp_file *pf, int 
   */
  static void ppp_shutdown_interface(struct ppp *ppp)
  {
-       struct net_device *dev;
        mutex_lock(&all_ppp_mutex);
-       ppp_lock(ppp);
-       dev = ppp->dev;
-       ppp->dev = NULL;
-       ppp_unlock(ppp);
        /* This will call dev_close() for us. */
-       if (dev) {
-               unregister_netdev(dev);
-               free_netdev(dev);
-       }
+       ppp_lock(ppp);
+       if (!ppp->closing) {
+               ppp->closing = 1;
+               ppp_unlock(ppp);
+               unregister_netdev(ppp->dev);
+       } else
+               ppp_unlock(ppp);
 -      cardmap_set(&all_ppp_units, ppp->file.index, NULL);
 +      unit_put(&ppp_units_idr, ppp->file.index);
        ppp->file.dead = 1;
        ppp->owner = NULL;
        wake_up_interruptible(&ppp->file.rwait);
@@@ -2540,7 -2552,7 +2538,7 @@@ static void ppp_destroy_interface(struc
        if (ppp->xmit_pending)
                kfree_skb(ppp->xmit_pending);
  
-       kfree(ppp);
+       free_netdev(ppp->dev);
  }
  
  /*
  static struct ppp *
  ppp_find_unit(int unit)
  {
 -      return cardmap_get(all_ppp_units, unit);
 +      return unit_find(&ppp_units_idr, unit);
  }
  
  /*
@@@ -2602,7 -2614,7 +2600,7 @@@ ppp_connect_channel(struct channel *pch
        if (pch->file.hdrlen > ppp->file.hdrlen)
                ppp->file.hdrlen = pch->file.hdrlen;
        hdrlen = pch->file.hdrlen + 2;  /* for protocol bytes */
-       if (ppp->dev && hdrlen > ppp->dev->hard_header_len)
+       if (hdrlen > ppp->dev->hard_header_len)
                ppp->dev->hard_header_len = hdrlen;
        list_add_tail(&pch->clist, &ppp->channels);
        ++ppp->n_channels;
@@@ -2668,45 -2680,123 +2666,45 @@@ static void __exit ppp_cleanup(void
        /* should never happen */
        if (atomic_read(&ppp_unit_count) || atomic_read(&channel_count))
                printk(KERN_ERR "PPP: removing module but units remain!\n");
 -      cardmap_destroy(&all_ppp_units);
        unregister_chrdev(PPP_MAJOR, "ppp");
        device_destroy(ppp_class, MKDEV(PPP_MAJOR, 0));
        class_destroy(ppp_class);
 +      idr_destroy(&ppp_units_idr);
  }
  
  /*
 - * Cardmap implementation.
 + * Units handling. Caller must protect concurrent access
 + * by holding all_ppp_mutex
   */
 -static void *cardmap_get(struct cardmap *map, unsigned int nr)
 +
 +/* get new free unit number and associate pointer with it */
 +static int unit_get(struct idr *p, void *ptr)
  {
 -      struct cardmap *p;
 -      int i;
 +      int unit, err;
  
 -      for (p = map; p != NULL; ) {
 -              if ((i = nr >> p->shift) >= CARDMAP_WIDTH)
 -                      return NULL;
 -              if (p->shift == 0)
 -                      return p->ptr[i];
 -              nr &= ~(CARDMAP_MASK << p->shift);
 -              p = p->ptr[i];
 +again:
 +      if (idr_pre_get(p, GFP_KERNEL) == 0) {
 +              printk(KERN_ERR "Out of memory expanding drawable idr\n");
 +              return -ENOMEM;
        }
 -      return NULL;
 -}
  
 -static int cardmap_set(struct cardmap **pmap, unsigned int nr, void *ptr)
 -{
 -      struct cardmap *p;
 -      int i;
 +      err = idr_get_new_above(p, ptr, 0, &unit);
 +      if (err == -EAGAIN)
 +              goto again;
  
 -      p = *pmap;
 -      if (p == NULL || (nr >> p->shift) >= CARDMAP_WIDTH) {
 -              do {
 -                      /* need a new top level */
 -                      struct cardmap *np = kzalloc(sizeof(*np), GFP_KERNEL);
 -                      if (!np)
 -                              goto enomem;
 -                      np->ptr[0] = p;
 -                      if (p != NULL) {
 -                              np->shift = p->shift + CARDMAP_ORDER;
 -                              p->parent = np;
 -                      } else
 -                              np->shift = 0;
 -                      p = np;
 -              } while ((nr >> p->shift) >= CARDMAP_WIDTH);
 -              *pmap = p;
 -      }
 -      while (p->shift > 0) {
 -              i = (nr >> p->shift) & CARDMAP_MASK;
 -              if (p->ptr[i] == NULL) {
 -                      struct cardmap *np = kzalloc(sizeof(*np), GFP_KERNEL);
 -                      if (!np)
 -                              goto enomem;
 -                      np->shift = p->shift - CARDMAP_ORDER;
 -                      np->parent = p;
 -                      p->ptr[i] = np;
 -              }
 -              if (ptr == NULL)
 -                      clear_bit(i, &p->inuse);
 -              p = p->ptr[i];
 -      }
 -      i = nr & CARDMAP_MASK;
 -      p->ptr[i] = ptr;
 -      if (ptr != NULL)
 -              set_bit(i, &p->inuse);
 -      else
 -              clear_bit(i, &p->inuse);
 -      return 0;
 - enomem:
 -      return -ENOMEM;
 +      return unit;
  }
  
 -static unsigned int cardmap_find_first_free(struct cardmap *map)
 +/* put unit number back to a pool */
 +static void unit_put(struct idr *p, int n)
  {
 -      struct cardmap *p;
 -      unsigned int nr = 0;
 -      int i;
 -
 -      if ((p = map) == NULL)
 -              return 0;
 -      for (;;) {
 -              i = find_first_zero_bit(&p->inuse, CARDMAP_WIDTH);
 -              if (i >= CARDMAP_WIDTH) {
 -                      if (p->parent == NULL)
 -                              return CARDMAP_WIDTH << p->shift;
 -                      p = p->parent;
 -                      i = (nr >> p->shift) & CARDMAP_MASK;
 -                      set_bit(i, &p->inuse);
 -                      continue;
 -              }
 -              nr = (nr & (~CARDMAP_MASK << p->shift)) | (i << p->shift);
 -              if (p->shift == 0 || p->ptr[i] == NULL)
 -                      return nr;
 -              p = p->ptr[i];
 -      }
 +      idr_remove(p, n);
  }
  
 -static void cardmap_destroy(struct cardmap **pmap)
 +/* get pointer associated with the number */
 +static void *unit_find(struct idr *p, int n)
  {
 -      struct cardmap *p, *np;
 -      int i;
 -
 -      for (p = *pmap; p != NULL; p = np) {
 -              if (p->shift != 0) {
 -                      for (i = 0; i < CARDMAP_WIDTH; ++i)
 -                              if (p->ptr[i] != NULL)
 -                                      break;
 -                      if (i < CARDMAP_WIDTH) {
 -                              np = p->ptr[i];
 -                              p->ptr[i] = NULL;
 -                              continue;
 -                      }
 -              }
 -              np = p->parent;
 -              kfree(p);
 -      }
 -      *pmap = NULL;
 +      return idr_find(p, n);
  }
  
  /* Module/initialization stuff */
diff --combined drivers/net/starfire.c
index d5b9dd842c619e9fbeef4a73f590cabbd3129ac2,5a40f2d78beb1a9114478ac9e0385556c29d30bf..1902f4fabde140018ed840bcb501cf6e3bb43ae9
@@@ -653,6 -653,7 +653,6 @@@ static int __devinit starfire_init_one(
        void __iomem *base;
        int drv_flags, io_size;
        int boguscnt;
 -      DECLARE_MAC_BUF(mac);
  
  /* when built into the kernel, we only print version if device is found */
  #ifndef MODULE
        if (register_netdev(dev))
                goto err_out_cleardev;
  
 -      printk(KERN_INFO "%s: %s at %p, %s, IRQ %d.\n",
 +      printk(KERN_INFO "%s: %s at %p, %pM, IRQ %d.\n",
               dev->name, netdrv_tbl[chip_idx].name, base,
 -             print_mac(mac, dev->dev_addr), irq);
 +             dev->dev_addr, irq);
  
        if (drv_flags & CanHaveMII) {
                int phy, phy_idx = 0;
@@@ -1290,8 -1291,8 +1290,8 @@@ static irqreturn_t intr_handler(int irq
                if (intr_status & (IntrRxDone | IntrRxEmpty)) {
                        u32 enable;
  
 -                      if (likely(netif_rx_schedule_prep(dev, &np->napi))) {
 -                              __netif_rx_schedule(dev, &np->napi);
 +                      if (likely(netif_rx_schedule_prep(&np->napi))) {
 +                              __netif_rx_schedule(&np->napi);
                                enable = readl(ioaddr + IntrEnable);
                                enable &= ~(IntrRxDone | IntrRxEmpty);
                                writel(enable, ioaddr + IntrEnable);
@@@ -1451,8 -1452,12 +1451,8 @@@ static int __netdev_rx(struct net_devic
  #ifndef final_version                 /* Remove after testing. */
                /* You will want this info for the initial debug. */
                if (debug > 5) {
 -                      printk(KERN_DEBUG "  Rx data " MAC_FMT " " MAC_FMT
 -                             " %2.2x%2.2x.\n",
 -                             skb->data[0], skb->data[1], skb->data[2],
 -                             skb->data[3], skb->data[4], skb->data[5],
 -                             skb->data[6], skb->data[7], skb->data[8],
 -                             skb->data[9], skb->data[10], skb->data[11],
 +                      printk(KERN_DEBUG "  Rx data %pM %pM %2.2x%2.2x.\n",
 +                             skb->data, skb->data + 6,
                               skb->data[12], skb->data[13]);
                }
  #endif
                } else
  #endif /* VLAN_SUPPORT */
                        netif_receive_skb(skb);
 -              dev->last_rx = jiffies;
                np->stats.rx_packets++;
  
        next_rx:
                desc->status = 0;
                np->rx_done = (np->rx_done + 1) % DONE_Q_SIZE;
        }
+       if (*quota == 0) {      /* out of rx quota */
+               retcode = 1;
+               goto out;
+       }
        writew(np->rx_done, np->base + CompletionQConsumerIdx);
  
   out:
@@@ -1530,7 -1541,7 +1535,7 @@@ static int netdev_poll(struct napi_stru
                intr_status = readl(ioaddr + IntrStatus);
        } while (intr_status & (IntrRxDone | IntrRxEmpty));
  
 -      netif_rx_complete(dev, napi);
 +      netif_rx_complete(napi);
        intr_status = readl(ioaddr + IntrEnable);
        intr_status |= IntrRxDone | IntrRxEmpty;
        writel(intr_status, ioaddr + IntrEnable);
index 37c640d1c3fd9d103a86f0445d40d0b220a833a2,ce68e046d963840e4a3822972ed33f2a30a86244..acd84fd524b856c25cf1f7c40560c3a6726d7236
  #include <net/bluetooth/l2cap.h>
  #include <net/bluetooth/rfcomm.h>
  
 -#ifndef CONFIG_BT_RFCOMM_DEBUG
 -#undef  BT_DBG
 -#define BT_DBG(D...)
 -#endif
 -
  #define VERSION "1.10"
  
  static int disable_cfc = 0;
@@@ -1781,8 -1786,6 +1781,6 @@@ static inline void rfcomm_accept_connec
        if (err < 0)
                return;
  
-       __module_get(nsock->ops->owner);
        /* Set our callbacks */
        nsock->sk->sk_data_ready   = rfcomm_l2data_ready;
        nsock->sk->sk_state_change = rfcomm_l2state_change;
diff --combined net/socket.c
index e9d65ea2687e86539431d64426a2430b8badbccc,76ba80aeac1a86217ae77edc0e239084840f90d6..43021f9463f3c70f14a597d972256bac3267b9a4
@@@ -69,6 -69,7 +69,6 @@@
  #include <linux/proc_fs.h>
  #include <linux/seq_file.h>
  #include <linux/mutex.h>
 -#include <linux/thread_info.h>
  #include <linux/wanrouter.h>
  #include <linux/if_bridge.h>
  #include <linux/if_frad.h>
@@@ -2306,6 -2307,7 +2306,7 @@@ int kernel_accept(struct socket *sock, 
        }
  
        (*newsock)->ops = sock->ops;
+       __module_get((*newsock)->ops->owner);
  
  done:
        return err;