Merge branch 'upstream' of master.kernel.org:/pub/scm/linux/kernel/git/linville/wirel...
authorJeff Garzik <jeff@garzik.org>
Fri, 9 Feb 2007 21:12:09 +0000 (16:12 -0500)
committerJeff Garzik <jeff@garzik.org>
Fri, 9 Feb 2007 21:12:09 +0000 (16:12 -0500)
1  2 
drivers/net/wireless/bcm43xx/bcm43xx.h
drivers/net/wireless/bcm43xx/bcm43xx_main.c
drivers/net/wireless/zd1211rw/zd_usb.c
net/core/net-sysfs.c

index 3a064def162e70d7e37547b1e3c97a9b6bc74b33,4168b1a807ef4a4b4902f4cb7327b114142fddf9..0e790efae683cfdbe2e17e204ad7667af56871ed
  #define BCM43xx_UCODEFLAG_UNKPACTRL   0x0040
  #define BCM43xx_UCODEFLAG_JAPAN               0x0080
  
 +/* Hardware Radio Enable masks */
 +#define BCM43xx_MMIO_RADIO_HWENABLED_HI_MASK (1 << 16)
 +#define BCM43xx_MMIO_RADIO_HWENABLED_LO_MASK (1 << 4)
 +
  /* Generic-Interrupt reasons. */
  #define BCM43xx_IRQ_READY             (1 << 0)
  #define BCM43xx_IRQ_BEACON            (1 << 1)
@@@ -762,8 -758,7 +762,8 @@@ struct bcm43xx_private 
            bad_frames_preempt:1,       /* Use "Bad Frames Preemption" (default off) */
            reg124_set_0x4:1,           /* Some variable to keep track of IRQ stuff. */
            short_preamble:1,           /* TRUE, if short preamble is enabled. */
 -          firmware_norelease:1;       /* Do not release the firmware. Used on suspend. */
 +          firmware_norelease:1,       /* Do not release the firmware. Used on suspend. */
 +          radio_hw_enable:1;          /* TRUE if radio is hardware enabled */
  
        struct bcm43xx_stats stats;
  
         * This is currently always BCM43xx_BUSTYPE_PCI
         */
        u8 bustype;
+       u64 dma_mask;
  
        u16 board_vendor;
        u16 board_type;
index 23aaf1ed8541d925bf1d453a43536b7766fc843d,63fc16f6e58425d8f3f53dc2f1598df0cd52057c..2e400aacc436e2a72d10ab2f18a7875a15e0bfa5
@@@ -95,13 -95,9 +95,9 @@@ static int modparam_noleds
  module_param_named(noleds, modparam_noleds, int, 0444);
  MODULE_PARM_DESC(noleds, "Turn off all LED activity");
  
- #ifdef CONFIG_BCM43XX_DEBUG
  static char modparam_fwpostfix[64];
  module_param_string(fwpostfix, modparam_fwpostfix, 64, 0444);
- MODULE_PARM_DESC(fwpostfix, "Postfix for .fw files. Useful for debugging.");
- #else
- # define modparam_fwpostfix  ""
- #endif /* CONFIG_BCM43XX_DEBUG*/
+ MODULE_PARM_DESC(fwpostfix, "Postfix for .fw files. Useful for using multiple firmware image versions.");
  
  
  /* If you want to debug with just a single device, enable this,
@@@ -2441,9 -2437,6 +2437,9 @@@ static int bcm43xx_chip_init(struct bcm
        if (err)
                goto err_gpio_cleanup;
        bcm43xx_radio_turn_on(bcm);
 +      bcm->radio_hw_enable = bcm43xx_is_hw_radio_enabled(bcm);
 +      dprintk(KERN_INFO PFX "Radio %s by hardware\n",
 +              (bcm->radio_hw_enable == 0) ? "disabled" : "enabled");
  
        bcm43xx_write16(bcm, 0x03E6, 0x0000);
        err = bcm43xx_phy_init(bcm);
@@@ -2983,8 -2976,10 +2979,10 @@@ static int bcm43xx_chipset_attach(struc
        err = bcm43xx_pctl_set_crystal(bcm, 1);
        if (err)
                goto out;
-       bcm43xx_pci_read_config16(bcm, PCI_STATUS, &pci_status);
-       bcm43xx_pci_write_config16(bcm, PCI_STATUS, pci_status & ~PCI_STATUS_SIG_TARGET_ABORT);
+       err = bcm43xx_pci_read_config16(bcm, PCI_STATUS, &pci_status);
+       if (err)
+               goto out;
+       err = bcm43xx_pci_write_config16(bcm, PCI_STATUS, pci_status & ~PCI_STATUS_SIG_TARGET_ABORT);
  
  out:
        return err;
@@@ -3177,25 -3172,10 +3175,25 @@@ static void bcm43xx_periodic_every30sec
  }
  
  static void bcm43xx_periodic_every15sec(struct bcm43xx_private *bcm)
 +{
 +      bcm43xx_phy_xmitpower(bcm); //FIXME: unless scanning?
 +      //TODO for APHY (temperature?)
 +}
 +
 +static void bcm43xx_periodic_every1sec(struct bcm43xx_private *bcm)
  {
        struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
        struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
 +      int radio_hw_enable;
  
 +      /* check if radio hardware enabled status changed */
 +      radio_hw_enable = bcm43xx_is_hw_radio_enabled(bcm);
 +      if (unlikely(bcm->radio_hw_enable != radio_hw_enable)) {
 +              bcm->radio_hw_enable = radio_hw_enable;
 +              dprintk(KERN_INFO PFX "Radio hardware status changed to %s\n",
 +                     (radio_hw_enable == 0) ? "disabled" : "enabled");
 +              bcm43xx_leds_update(bcm, 0);
 +      }
        if (phy->type == BCM43xx_PHYTYPE_G) {
                //TODO: update_aci_moving_average
                if (radio->aci_enable && radio->aci_wlan_automatic) {
                        //TODO: implement rev1 workaround
                }
        }
 -      bcm43xx_phy_xmitpower(bcm); //FIXME: unless scanning?
 -      //TODO for APHY (temperature?)
  }
  
  static void do_periodic_work(struct bcm43xx_private *bcm)
  {
 -      if (bcm->periodic_state % 8 == 0)
 +      if (bcm->periodic_state % 120 == 0)
                bcm43xx_periodic_every120sec(bcm);
 -      if (bcm->periodic_state % 4 == 0)
 +      if (bcm->periodic_state % 60 == 0)
                bcm43xx_periodic_every60sec(bcm);
 -      if (bcm->periodic_state % 2 == 0)
 +      if (bcm->periodic_state % 30 == 0)
                bcm43xx_periodic_every30sec(bcm);
 -      bcm43xx_periodic_every15sec(bcm);
 +      if (bcm->periodic_state % 15 == 0)
 +              bcm43xx_periodic_every15sec(bcm);
 +      bcm43xx_periodic_every1sec(bcm);
  
 -      schedule_delayed_work(&bcm->periodic_work, HZ * 15);
 +      schedule_delayed_work(&bcm->periodic_work, HZ);
  }
  
  static void bcm43xx_periodic_work_handler(struct work_struct *work)
        unsigned long orig_trans_start = 0;
  
        mutex_lock(&bcm->mutex);
 -      if (unlikely(bcm->periodic_state % 4 == 0)) {
 +      if (unlikely(bcm->periodic_state % 60 == 0)) {
                /* Periodic work will take a long time, so we want it to
                 * be preemtible.
                 */
  
        do_periodic_work(bcm);
  
 -      if (unlikely(bcm->periodic_state % 4 == 0)) {
 +      if (unlikely(bcm->periodic_state % 60 == 0)) {
                spin_lock_irqsave(&bcm->irq_lock, flags);
                tasklet_enable(&bcm->isr_tasklet);
                bcm43xx_interrupt_enable(bcm, savedirqs);
@@@ -3796,12 -3776,18 +3794,18 @@@ static int bcm43xx_attach_board(struct 
        }
        net_dev->base_addr = (unsigned long)bcm->mmio_addr;
  
-       bcm43xx_pci_read_config16(bcm, PCI_SUBSYSTEM_VENDOR_ID,
+       err = bcm43xx_pci_read_config16(bcm, PCI_SUBSYSTEM_VENDOR_ID,
                                  &bcm->board_vendor);
-       bcm43xx_pci_read_config16(bcm, PCI_SUBSYSTEM_ID,
+       if (err)
+               goto err_iounmap;
+       err = bcm43xx_pci_read_config16(bcm, PCI_SUBSYSTEM_ID,
                                  &bcm->board_type);
-       bcm43xx_pci_read_config16(bcm, PCI_REVISION_ID,
+       if (err)
+               goto err_iounmap;
+       err = bcm43xx_pci_read_config16(bcm, PCI_REVISION_ID,
                                  &bcm->board_revision);
+       if (err)
+               goto err_iounmap;
  
        err = bcm43xx_chipset_attach(bcm);
        if (err)
@@@ -3892,6 -3878,7 +3896,7 @@@ err_pci_release
        pci_release_regions(pci_dev);
  err_pci_disable:
        pci_disable_device(pci_dev);
+       printk(KERN_ERR PFX "Unable to attach board\n");
        goto out;
  }
  
index 75ef55624d7fd2cf15820e79127beff3e6e393dd,a3217a8d37c42ccf9c9c61f8df2bd78f0c70c62e..aac8a1c5ba08fb94e7919fc4e6b930e4b55ea595
@@@ -58,10 -58,6 +58,10 @@@ static struct usb_device_id usb_ids[] 
        { USB_DEVICE(0x079b, 0x0062), .driver_info = DEVICE_ZD1211B },
        { USB_DEVICE(0x1582, 0x6003), .driver_info = DEVICE_ZD1211B },
        { USB_DEVICE(0x050d, 0x705c), .driver_info = DEVICE_ZD1211B },
 +      { USB_DEVICE(0x083a, 0x4505), .driver_info = DEVICE_ZD1211B },
 +      { USB_DEVICE(0x0471, 0x1236), .driver_info = DEVICE_ZD1211B },
 +      { USB_DEVICE(0x13b1, 0x0024), .driver_info = DEVICE_ZD1211B },
 +      { USB_DEVICE(0x0586, 0x340f), .driver_info = DEVICE_ZD1211B },
        /* "Driverless" devices that need ejecting */
        { USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER },
        {}
@@@ -77,6 -73,96 +77,6 @@@ MODULE_DEVICE_TABLE(usb, usb_ids)
  #define FW_ZD1211_PREFIX      "zd1211/zd1211_"
  #define FW_ZD1211B_PREFIX     "zd1211/zd1211b_"
  
 -/* register address handling */
 -
 -#ifdef DEBUG
 -static int check_addr(struct zd_usb *usb, zd_addr_t addr)
 -{
 -      u32 base = ZD_ADDR_BASE(addr);
 -      u32 offset = ZD_OFFSET(addr);
 -
 -      if ((u32)addr & ADDR_ZERO_MASK)
 -              goto invalid_address;
 -      switch (base) {
 -      case USB_BASE:
 -              break;
 -      case CR_BASE:
 -              if (offset > CR_MAX_OFFSET) {
 -                      dev_dbg(zd_usb_dev(usb),
 -                              "CR offset %#010x larger than"
 -                              " CR_MAX_OFFSET %#10x\n",
 -                              offset, CR_MAX_OFFSET);
 -                      goto invalid_address;
 -              }
 -              if (offset & 1) {
 -                      dev_dbg(zd_usb_dev(usb),
 -                              "CR offset %#010x is not a multiple of 2\n",
 -                              offset);
 -                      goto invalid_address;
 -              }
 -              break;
 -      case E2P_BASE:
 -              if (offset > E2P_MAX_OFFSET) {
 -                      dev_dbg(zd_usb_dev(usb),
 -                              "E2P offset %#010x larger than"
 -                              " E2P_MAX_OFFSET %#010x\n",
 -                              offset, E2P_MAX_OFFSET);
 -                      goto invalid_address;
 -              }
 -              break;
 -      case FW_BASE:
 -              if (!usb->fw_base_offset) {
 -                      dev_dbg(zd_usb_dev(usb),
 -                             "ERROR: fw base offset has not been set\n");
 -                      return -EAGAIN;
 -              }
 -              if (offset > FW_MAX_OFFSET) {
 -                      dev_dbg(zd_usb_dev(usb),
 -                              "FW offset %#10x is larger than"
 -                              " FW_MAX_OFFSET %#010x\n",
 -                              offset, FW_MAX_OFFSET);
 -                      goto invalid_address;
 -              }
 -              break;
 -      default:
 -              dev_dbg(zd_usb_dev(usb),
 -                      "address has unsupported base %#010x\n", addr);
 -              goto invalid_address;
 -      }
 -
 -      return 0;
 -invalid_address:
 -      dev_dbg(zd_usb_dev(usb),
 -              "ERROR: invalid address: %#010x\n", addr);
 -      return -EINVAL;
 -}
 -#endif /* DEBUG */
 -
 -static u16 usb_addr(struct zd_usb *usb, zd_addr_t addr)
 -{
 -      u32 base;
 -      u16 offset;
 -
 -      base = ZD_ADDR_BASE(addr);
 -      offset = ZD_OFFSET(addr);
 -
 -      ZD_ASSERT(check_addr(usb, addr) == 0);
 -
 -      switch (base) {
 -      case CR_BASE:
 -              offset += CR_BASE_OFFSET;
 -              break;
 -      case E2P_BASE:
 -              offset += E2P_BASE_OFFSET;
 -              break;
 -      case FW_BASE:
 -              offset += usb->fw_base_offset;
 -              break;
 -      }
 -
 -      return offset;
 -}
 -
  /* USB device initialization */
  
  static int request_fw_file(
@@@ -209,13 -295,14 +209,13 @@@ static int handle_version_mismatch(stru
        if (r)
                goto error;
  
 -      r = upload_code(udev, ur_fw->data, ur_fw->size, FW_START_OFFSET,
 -              REBOOT);
 +      r = upload_code(udev, ur_fw->data, ur_fw->size, FW_START, REBOOT);
        if (r)
                goto error;
  
 -      offset = ((EEPROM_REGS_OFFSET + EEPROM_REGS_SIZE) * sizeof(u16));
 +      offset = (E2P_BOOT_CODE_OFFSET * sizeof(u16));
        r = upload_code(udev, ub_fw->data + offset, ub_fw->size - offset,
 -              E2P_BASE_OFFSET + EEPROM_REGS_SIZE, REBOOT);
 +              E2P_START + E2P_BOOT_CODE_OFFSET, REBOOT);
  
        /* At this point, the vendor driver downloads the whole firmware
         * image, hacks around with version IDs, and uploads it again,
@@@ -244,7 -331,7 +244,7 @@@ static int upload_firmware(struct usb_d
        if (r)
                goto error;
  
 -      fw_bcdDevice = get_word(ub_fw->data, EEPROM_REGS_OFFSET);
 +      fw_bcdDevice = get_word(ub_fw->data, E2P_DATA_OFFSET);
  
        if (fw_bcdDevice != bcdDevice) {
                dev_info(&udev->dev,
        if (r)
                goto error;
  
 -      r = upload_code(udev, uph_fw->data, uph_fw->size, FW_START_OFFSET,
 -                      REBOOT);
 +      r = upload_code(udev, uph_fw->data, uph_fw->size, FW_START, REBOOT);
        if (r) {
                dev_err(&udev->dev,
                        "Could not upload firmware code uph. Error number %d\n",
@@@ -313,6 -401,12 +313,12 @@@ out
  
  static inline void handle_retry_failed_int(struct urb *urb)
  {
+       struct zd_usb *usb = urb->context;
+       struct zd_mac *mac = zd_usb_to_mac(usb);
+       struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac);
+       ieee->stats.tx_errors++;
+       ieee->ieee_stats.tx_retry_limit_exceeded++;
        dev_dbg_f(urb_dev(urb), "retry failed interrupt\n");
  }
  
@@@ -487,6 -581,9 +493,9 @@@ static void handle_rx_packet(struct zd_
  
        if (length < sizeof(struct rx_length_info)) {
                /* It's not a complete packet anyhow. */
+               struct ieee80211_device *ieee = zd_mac_to_ieee80211(mac);
+               ieee->stats.rx_errors++;
+               ieee->stats.rx_length_errors++;
                return;
        }
        length_info = (struct rx_length_info *)
@@@ -770,7 -867,7 +779,7 @@@ static inline void init_usb_interrupt(s
        spin_lock_init(&intr->lock);
        intr->interval = int_urb_interval(zd_usb_to_usbdev(usb));
        init_completion(&intr->read_regs.completion);
 -      intr->read_regs.cr_int_addr = cpu_to_le16(usb_addr(usb, CR_INTERRUPT));
 +      intr->read_regs.cr_int_addr = cpu_to_le16((u16)CR_INTERRUPT);
  }
  
  static inline void init_usb_rx(struct zd_usb *usb)
@@@ -802,6 -899,22 +811,6 @@@ void zd_usb_init(struct zd_usb *usb, st
        init_usb_rx(usb);
  }
  
 -int zd_usb_init_hw(struct zd_usb *usb)
 -{
 -      int r;
 -      struct zd_chip *chip = zd_usb_to_chip(usb);
 -
 -      ZD_ASSERT(mutex_is_locked(&chip->mutex));
 -      r = zd_ioread16_locked(chip, &usb->fw_base_offset,
 -                      USB_REG((u16)FW_BASE_ADDR_OFFSET));
 -      if (r)
 -              return r;
 -      dev_dbg_f(zd_usb_dev(usb), "fw_base_offset: %#06hx\n",
 -               usb->fw_base_offset);
 -
 -      return 0;
 -}
 -
  void zd_usb_clear(struct zd_usb *usb)
  {
        usb_set_intfdata(usb->intf, NULL);
@@@ -923,6 -1036,8 +932,8 @@@ static int probe(struct usb_interface *
                goto error;
        }
  
+       usb_reset_device(interface_to_usbdev(intf));
        netdev = zd_netdev_alloc(intf);
        if (netdev == NULL) {
                r = -ENOMEM;
@@@ -1024,6 -1139,7 +1035,7 @@@ static int __init usb_init(void
  
        r = usb_register(&driver);
        if (r) {
+               destroy_workqueue(zd_workqueue);
                printk(KERN_ERR "%s usb_register() failed. Error number %d\n",
                       driver.name, r);
                return r;
@@@ -1149,7 -1265,7 +1161,7 @@@ int zd_usb_ioread16v(struct zd_usb *usb
                return -ENOMEM;
        req->id = cpu_to_le16(USB_REQ_READ_REGS);
        for (i = 0; i < count; i++)
 -              req->addr[i] = cpu_to_le16(usb_addr(usb, addresses[i]));
 +              req->addr[i] = cpu_to_le16((u16)addresses[i]);
  
        udev = zd_usb_to_usbdev(usb);
        prepare_read_regs_int(usb);
@@@ -1214,7 -1330,7 +1226,7 @@@ int zd_usb_iowrite16v(struct zd_usb *us
        req->id = cpu_to_le16(USB_REQ_WRITE_REGS);
        for (i = 0; i < count; i++) {
                struct reg_data *rw  = &req->reg_writes[i];
 -              rw->addr = cpu_to_le16(usb_addr(usb, ioreqs[i].addr));
 +              rw->addr = cpu_to_le16((u16)ioreqs[i].addr);
                rw->value = cpu_to_le16(ioreqs[i].value);
        }
  
diff --combined net/core/net-sysfs.c
index 44db095a8f7e9f4e404f616c4837edc019408060,44e69a21c32aed5f03b6029bca3af15b105a926b..cd59ac6200926bc6239e9242af3ab737ac40c353
@@@ -18,6 -18,9 +18,6 @@@
  #include <linux/wireless.h>
  #include <net/iw_handler.h>
  
 -#define to_class_dev(obj) container_of(obj,struct class_device,kobj)
 -#define to_net_dev(class) container_of(class, struct net_device, class_dev)
 -
  static const char fmt_hex[] = "%#x\n";
  static const char fmt_long_hex[] = "%#lx\n";
  static const char fmt_dec[] = "%d\n";
@@@ -29,11 -32,10 +29,11 @@@ static inline int dev_isalive(const str
  }
  
  /* use same locking rules as GIF* ioctl's */
 -static ssize_t netdev_show(const struct class_device *cd, char *buf,
 +static ssize_t netdev_show(const struct device *dev,
 +                         struct device_attribute *attr, char *buf,
                           ssize_t (*format)(const struct net_device *, char *))
  {
 -      struct net_device *net = to_net_dev(cd);
 +      struct net_device *net = to_net_dev(dev);
        ssize_t ret = -EINVAL;
  
        read_lock(&dev_base_lock);
@@@ -50,15 -52,14 +50,15 @@@ static ssize_t format_##field(const str
  {                                                                     \
        return sprintf(buf, format_string, net->field);                 \
  }                                                                     \
 -static ssize_t show_##field(struct class_device *cd, char *buf)               \
 +static ssize_t show_##field(struct device *dev,                               \
 +                          struct device_attribute *attr, char *buf)   \
  {                                                                     \
 -      return netdev_show(cd, buf, format_##field);                    \
 +      return netdev_show(dev, attr, buf, format_##field);             \
  }
  
  
  /* use same locking and permission rules as SIF* ioctl's */
 -static ssize_t netdev_store(struct class_device *dev,
 +static ssize_t netdev_store(struct device *dev, struct device_attribute *attr,
                            const char *buf, size_t len,
                            int (*set)(struct net_device *, unsigned long))
  {
@@@ -103,8 -104,7 +103,8 @@@ static ssize_t format_addr(char *buf, c
        return cp - buf;
  }
  
 -static ssize_t show_address(struct class_device *dev, char *buf)
 +static ssize_t show_address(struct device *dev, struct device_attribute *attr,
 +                          char *buf)
  {
        struct net_device *net = to_net_dev(dev);
        ssize_t ret = -EINVAL;
        return ret;
  }
  
 -static ssize_t show_broadcast(struct class_device *dev, char *buf)
 +static ssize_t show_broadcast(struct device *dev,
 +                          struct device_attribute *attr, char *buf)
  {
        struct net_device *net = to_net_dev(dev);
        if (dev_isalive(net))
        return -EINVAL;
  }
  
 -static ssize_t show_carrier(struct class_device *dev, char *buf)
 +static ssize_t show_carrier(struct device *dev,
 +                          struct device_attribute *attr, char *buf)
  {
        struct net_device *netdev = to_net_dev(dev);
        if (netif_running(netdev)) {
        return -EINVAL;
  }
  
 -static ssize_t show_dormant(struct class_device *dev, char *buf)
 +static ssize_t show_dormant(struct device *dev,
 +                          struct device_attribute *attr, char *buf)
  {
        struct net_device *netdev = to_net_dev(dev);
  
@@@ -156,8 -153,7 +156,8 @@@ static const char *operstates[] = 
        "up"
  };
  
 -static ssize_t show_operstate(struct class_device *dev, char *buf)
 +static ssize_t show_operstate(struct device *dev,
 +                            struct device_attribute *attr, char *buf)
  {
        const struct net_device *netdev = to_net_dev(dev);
        unsigned char operstate;
@@@ -182,10 -178,9 +182,10 @@@ static int change_mtu(struct net_devic
        return dev_set_mtu(net, (int) new_mtu);
  }
  
 -static ssize_t store_mtu(struct class_device *dev, const char *buf, size_t len)
 +static ssize_t store_mtu(struct device *dev, struct device_attribute *attr,
 +                       const char *buf, size_t len)
  {
 -      return netdev_store(dev, buf, len, change_mtu);
 +      return netdev_store(dev, attr, buf, len, change_mtu);
  }
  
  NETDEVICE_SHOW(flags, fmt_hex);
@@@ -195,10 -190,9 +195,10 @@@ static int change_flags(struct net_devi
        return dev_change_flags(net, (unsigned) new_flags);
  }
  
 -static ssize_t store_flags(struct class_device *dev, const char *buf, size_t len)
 +static ssize_t store_flags(struct device *dev, struct device_attribute *attr,
 +                         const char *buf, size_t len)
  {
 -      return netdev_store(dev, buf, len, change_flags);
 +      return netdev_store(dev, attr, buf, len, change_flags);
  }
  
  NETDEVICE_SHOW(tx_queue_len, fmt_ulong);
@@@ -209,11 -203,9 +209,11 @@@ static int change_tx_queue_len(struct n
        return 0;
  }
  
 -static ssize_t store_tx_queue_len(struct class_device *dev, const char *buf, size_t len)
 +static ssize_t store_tx_queue_len(struct device *dev,
 +                                struct device_attribute *attr,
 +                                const char *buf, size_t len)
  {
 -      return netdev_store(dev, buf, len, change_tx_queue_len);
 +      return netdev_store(dev, attr, buf, len, change_tx_queue_len);
  }
  
  NETDEVICE_SHOW(weight, fmt_dec);
@@@ -224,13 -216,12 +224,13 @@@ static int change_weight(struct net_dev
        return 0;
  }
  
 -static ssize_t store_weight(struct class_device *dev, const char *buf, size_t len)
 +static ssize_t store_weight(struct device *dev, struct device_attribute *attr,
 +                          const char *buf, size_t len)
  {
 -      return netdev_store(dev, buf, len, change_weight);
 +      return netdev_store(dev, attr, buf, len, change_weight);
  }
  
 -static struct class_device_attribute net_class_attributes[] = {
 +static struct device_attribute net_class_attributes[] = {
        __ATTR(addr_len, S_IRUGO, show_addr_len, NULL),
        __ATTR(iflink, S_IRUGO, show_iflink, NULL),
        __ATTR(ifindex, S_IRUGO, show_ifindex, NULL),
  };
  
  /* Show a given an attribute in the statistics group */
 -static ssize_t netstat_show(const struct class_device *cd, char *buf, 
 +static ssize_t netstat_show(const struct device *d,
 +                          struct device_attribute *attr, char *buf,
                            unsigned long offset)
  {
 -      struct net_device *dev = to_net_dev(cd);
 +      struct net_device *dev = to_net_dev(d);
        struct net_device_stats *stats;
        ssize_t ret = -EINVAL;
  
  
  /* generate a read-only statistics attribute */
  #define NETSTAT_ENTRY(name)                                           \
 -static ssize_t show_##name(struct class_device *cd, char *buf)                \
 +static ssize_t show_##name(struct device *d,                          \
 +                         struct device_attribute *attr, char *buf)    \
  {                                                                     \
 -      return netstat_show(cd, buf,                                    \
 +      return netstat_show(d, attr, buf,                               \
                            offsetof(struct net_device_stats, name));   \
  }                                                                     \
 -static CLASS_DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
 +static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
  
  NETSTAT_ENTRY(rx_packets);
  NETSTAT_ENTRY(tx_packets);
@@@ -308,29 -297,29 +308,29 @@@ NETSTAT_ENTRY(rx_compressed)
  NETSTAT_ENTRY(tx_compressed);
  
  static struct attribute *netstat_attrs[] = {
 -      &class_device_attr_rx_packets.attr,
 -      &class_device_attr_tx_packets.attr,
 -      &class_device_attr_rx_bytes.attr,
 -      &class_device_attr_tx_bytes.attr,
 -      &class_device_attr_rx_errors.attr,
 -      &class_device_attr_tx_errors.attr,
 -      &class_device_attr_rx_dropped.attr,
 -      &class_device_attr_tx_dropped.attr,
 -      &class_device_attr_multicast.attr,
 -      &class_device_attr_collisions.attr,
 -      &class_device_attr_rx_length_errors.attr,
 -      &class_device_attr_rx_over_errors.attr,
 -      &class_device_attr_rx_crc_errors.attr,
 -      &class_device_attr_rx_frame_errors.attr,
 -      &class_device_attr_rx_fifo_errors.attr,
 -      &class_device_attr_rx_missed_errors.attr,
 -      &class_device_attr_tx_aborted_errors.attr,
 -      &class_device_attr_tx_carrier_errors.attr,
 -      &class_device_attr_tx_fifo_errors.attr,
 -      &class_device_attr_tx_heartbeat_errors.attr,
 -      &class_device_attr_tx_window_errors.attr,
 -      &class_device_attr_rx_compressed.attr,
 -      &class_device_attr_tx_compressed.attr,
 +      &dev_attr_rx_packets.attr,
 +      &dev_attr_tx_packets.attr,
 +      &dev_attr_rx_bytes.attr,
 +      &dev_attr_tx_bytes.attr,
 +      &dev_attr_rx_errors.attr,
 +      &dev_attr_tx_errors.attr,
 +      &dev_attr_rx_dropped.attr,
 +      &dev_attr_tx_dropped.attr,
 +      &dev_attr_multicast.attr,
 +      &dev_attr_collisions.attr,
 +      &dev_attr_rx_length_errors.attr,
 +      &dev_attr_rx_over_errors.attr,
 +      &dev_attr_rx_crc_errors.attr,
 +      &dev_attr_rx_frame_errors.attr,
 +      &dev_attr_rx_fifo_errors.attr,
 +      &dev_attr_rx_missed_errors.attr,
 +      &dev_attr_tx_aborted_errors.attr,
 +      &dev_attr_tx_carrier_errors.attr,
 +      &dev_attr_tx_fifo_errors.attr,
 +      &dev_attr_tx_heartbeat_errors.attr,
 +      &dev_attr_tx_window_errors.attr,
 +      &dev_attr_rx_compressed.attr,
 +      &dev_attr_tx_compressed.attr,
        NULL
  };
  
@@@ -340,13 -329,13 +340,13 @@@ static struct attribute_group netstat_g
        .attrs  = netstat_attrs,
  };
  
- #ifdef WIRELESS_EXT
+ #ifdef CONFIG_WIRELESS_EXT
  /* helper function that does all the locking etc for wireless stats */
 -static ssize_t wireless_show(struct class_device *cd, char *buf,
 +static ssize_t wireless_show(struct device *d, char *buf,
                             ssize_t (*format)(const struct iw_statistics *,
                                               char *))
  {
 -      struct net_device *dev = to_net_dev(cd);
 +      struct net_device *dev = to_net_dev(d);
        const struct iw_statistics *iw = NULL;
        ssize_t ret = -EINVAL;
        
@@@ -369,12 -358,11 +369,12 @@@ static ssize_t format_iw_##name(const s
  {                                                                     \
        return sprintf(buf, format_string, iw->field);                  \
  }                                                                     \
 -static ssize_t show_iw_##name(struct class_device *cd, char *buf)     \
 +static ssize_t show_iw_##name(struct device *d,                               \
 +                            struct device_attribute *attr, char *buf) \
  {                                                                     \
 -      return wireless_show(cd, buf, format_iw_##name);                \
 +      return wireless_show(d, buf, format_iw_##name);                 \
  }                                                                     \
 -static CLASS_DEVICE_ATTR(name, S_IRUGO, show_iw_##name, NULL)
 +static DEVICE_ATTR(name, S_IRUGO, show_iw_##name, NULL)
  
  WIRELESS_SHOW(status, status, fmt_hex);
  WIRELESS_SHOW(link, qual.qual, fmt_dec);
@@@ -388,16 -376,16 +388,16 @@@ WIRELESS_SHOW(retries, discard.retries
  WIRELESS_SHOW(beacon, miss.beacon, fmt_dec);
  
  static struct attribute *wireless_attrs[] = {
 -      &class_device_attr_status.attr,
 -      &class_device_attr_link.attr,
 -      &class_device_attr_level.attr,
 -      &class_device_attr_noise.attr,
 -      &class_device_attr_nwid.attr,
 -      &class_device_attr_crypt.attr,
 -      &class_device_attr_fragment.attr,
 -      &class_device_attr_retries.attr,
 -      &class_device_attr_misc.attr,
 -      &class_device_attr_beacon.attr,
 +      &dev_attr_status.attr,
 +      &dev_attr_link.attr,
 +      &dev_attr_level.attr,
 +      &dev_attr_noise.attr,
 +      &dev_attr_nwid.attr,
 +      &dev_attr_crypt.attr,
 +      &dev_attr_fragment.attr,
 +      &dev_attr_retries.attr,
 +      &dev_attr_misc.attr,
 +      &dev_attr_beacon.attr,
        NULL
  };
  
@@@ -408,10 -396,10 +408,10 @@@ static struct attribute_group wireless_
  #endif
  
  #ifdef CONFIG_HOTPLUG
 -static int netdev_uevent(struct class_device *cd, char **envp,
 +static int netdev_uevent(struct device *d, char **envp,
                         int num_envp, char *buf, int size)
  {
 -      struct net_device *dev = to_net_dev(cd);
 +      struct net_device *dev = to_net_dev(d);
        int i = 0;
        int n;
  
  
  /*
   *    netdev_release -- destroy and free a dead device. 
 - *    Called when last reference to class_device kobject is gone.
 + *    Called when last reference to device kobject is gone.
   */
 -static void netdev_release(struct class_device *cd)
 +static void netdev_release(struct device *d)
  {
 -      struct net_device *dev 
 -              = container_of(cd, struct net_device, class_dev);
 +      struct net_device *dev = to_net_dev(d);
  
        BUG_ON(dev->reg_state != NETREG_RELEASED);
  
  
  static struct class net_class = {
        .name = "net",
 -      .release = netdev_release,
 -      .class_dev_attrs = net_class_attributes,
 +      .dev_release = netdev_release,
 +      .dev_attrs = net_class_attributes,
  #ifdef CONFIG_HOTPLUG
 -      .uevent = netdev_uevent,
 +      .dev_uevent = netdev_uevent,
  #endif
  };
  
  void netdev_unregister_sysfs(struct net_device * net)
  {
 -      class_device_del(&(net->class_dev));
 +      device_del(&(net->dev));
  }
  
  /* Create sysfs entries for network device. */
  int netdev_register_sysfs(struct net_device *net)
  {
 -      struct class_device *class_dev = &(net->class_dev);
 +      struct device *dev = &(net->dev);
        struct attribute_group **groups = net->sysfs_groups;
  
 -      class_device_initialize(class_dev);
 -      class_dev->class = &net_class;
 -      class_dev->class_data = net;
 -      class_dev->groups = groups;
 +      device_initialize(dev);
 +      dev->class = &net_class;
 +      dev->platform_data = net;
 +      dev->groups = groups;
  
        BUILD_BUG_ON(BUS_ID_SIZE < IFNAMSIZ);
 -      strlcpy(class_dev->class_id, net->name, BUS_ID_SIZE);
 +      strlcpy(dev->bus_id, net->name, BUS_ID_SIZE);
  
        if (net->get_stats)
                *groups++ = &netstat_group;
  
- #ifdef WIRELESS_EXT
+ #ifdef CONFIG_WIRELESS_EXT
        if (net->wireless_handlers && net->wireless_handlers->get_wireless_stats)
                *groups++ = &wireless_group;
  #endif
  
 -      return class_device_add(class_dev);
 +      return device_add(dev);
  }
  
  int netdev_sysfs_init(void)