diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2009-09-03 11:58:09 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-09-15 12:02:35 -0700 |
commit | 1c6592f3b78640902494650efb88d8c2520c5c92 (patch) | |
tree | bcedbd1353eae39643ee50bc4fb71e6811be1768 /drivers/staging | |
parent | ffac040c05f7887896fbd5e1139e7fc59c30fa21 (diff) |
Staging: remove at76_usb wireless driver.
There is already an in-kernel driver for this hardware (since 2.6.30),
at76c50x-usb, and it supports all of the same devices. So this driver
can now be deleted.
Acked-by: Kalle Valo <kalle.valo@iki.fi>
Cc: linux-wireless <linux-wireless@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/Kconfig | 2 | ||||
-rw-r--r-- | drivers/staging/Makefile | 1 | ||||
-rw-r--r-- | drivers/staging/at76_usb/Kconfig | 8 | ||||
-rw-r--r-- | drivers/staging/at76_usb/Makefile | 1 | ||||
-rw-r--r-- | drivers/staging/at76_usb/TODO | 7 | ||||
-rw-r--r-- | drivers/staging/at76_usb/at76_usb.c | 5566 | ||||
-rw-r--r-- | drivers/staging/at76_usb/at76_usb.h | 706 |
7 files changed, 0 insertions, 6291 deletions
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index f7f9051a00e..66188a5bf44 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -57,8 +57,6 @@ source "drivers/staging/wlan-ng/Kconfig" source "drivers/staging/echo/Kconfig" -source "drivers/staging/at76_usb/Kconfig" - source "drivers/staging/poch/Kconfig" source "drivers/staging/agnx/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 3b388edd4f7..3c64d5fad65 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -11,7 +11,6 @@ obj-$(CONFIG_USB_IP_COMMON) += usbip/ obj-$(CONFIG_W35UND) += winbond/ obj-$(CONFIG_PRISM2_USB) += wlan-ng/ obj-$(CONFIG_ECHO) += echo/ -obj-$(CONFIG_USB_ATMEL) += at76_usb/ obj-$(CONFIG_POCH) += poch/ obj-$(CONFIG_AGNX) += agnx/ obj-$(CONFIG_OTUS) += otus/ diff --git a/drivers/staging/at76_usb/Kconfig b/drivers/staging/at76_usb/Kconfig deleted file mode 100644 index 8606f962162..00000000000 --- a/drivers/staging/at76_usb/Kconfig +++ /dev/null @@ -1,8 +0,0 @@ -config USB_ATMEL - tristate "Atmel at76c503/at76c505/at76c505a USB cards" - depends on WLAN_80211 && USB - default N - select FW_LOADER - ---help--- - Enable support for USB Wireless devices using Atmel at76c503, - at76c505 or at76c505a chips. diff --git a/drivers/staging/at76_usb/Makefile b/drivers/staging/at76_usb/Makefile deleted file mode 100644 index 6a47e887230..00000000000 --- a/drivers/staging/at76_usb/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-$(CONFIG_USB_ATMEL) += at76_usb.o diff --git a/drivers/staging/at76_usb/TODO b/drivers/staging/at76_usb/TODO deleted file mode 100644 index 0c7ed21c3b9..00000000000 --- a/drivers/staging/at76_usb/TODO +++ /dev/null @@ -1,7 +0,0 @@ -Fix the mac80211 port of at76_usb (the proper in-kernel wireless -stack) and get it included to the mainline. Patches available here: - -http://git.kernel.org/?p=linux/kernel/git/linville/wireless-legacy.git;a=shortlog;h=at76 - -Contact Kalle Valo <kalle.valo@iki.fi> and linux-wireless list -<linux-wireless@vger.kernel.org> for more information. diff --git a/drivers/staging/at76_usb/at76_usb.c b/drivers/staging/at76_usb/at76_usb.c deleted file mode 100644 index 4db9b976da9..00000000000 --- a/drivers/staging/at76_usb/at76_usb.c +++ /dev/null @@ -1,5566 +0,0 @@ -/* - * at76c503/at76c505 USB driver - * - * Copyright (c) 2002 - 2003 Oliver Kurth - * Copyright (c) 2004 Joerg Albert <joerg.albert@gmx.de> - * Copyright (c) 2004 Nick Jones - * Copyright (c) 2004 Balint Seeber <n0_5p4m_p13453@hotmail.com> - * Copyright (c) 2007 Guido Guenther <agx@sigxcpu.org> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This file is part of the Berlios driver for WLAN USB devices based on the - * Atmel AT76C503A/505/505A. - * - * Some iw_handler code was taken from airo.c, (C) 1999 Benjamin Reed - */ - -#include <linux/init.h> -#include <linux/kernel.h> -#include <linux/sched.h> -#include <linux/errno.h> -#include <linux/slab.h> -#include <linux/module.h> -#include <linux/spinlock.h> -#include <linux/list.h> -#include <linux/usb.h> -#include <linux/netdevice.h> -#include <linux/if_arp.h> -#include <linux/etherdevice.h> -#include <linux/ethtool.h> -#include <linux/wireless.h> -#include <net/iw_handler.h> -#include <net/ieee80211_radiotap.h> -#include <linux/firmware.h> -#include <linux/leds.h> -#include <linux/ieee80211.h> - -#include "at76_usb.h" - -/* Version information */ -#define DRIVER_NAME "at76_usb" -#define DRIVER_VERSION "0.17" -#define DRIVER_DESC "Atmel at76x USB Wireless LAN Driver" - -/* at76_debug bits */ -#define DBG_PROGRESS 0x00000001 /* authentication/accociation */ -#define DBG_BSS_TABLE 0x00000002 /* show BSS table after scans */ -#define DBG_IOCTL 0x00000004 /* ioctl calls / settings */ -#define DBG_MAC_STATE 0x00000008 /* MAC state transitions */ -#define DBG_TX_DATA 0x00000010 /* tx header */ -#define DBG_TX_DATA_CONTENT 0x00000020 /* tx content */ -#define DBG_TX_MGMT 0x00000040 /* tx management */ -#define DBG_RX_DATA 0x00000080 /* rx data header */ -#define DBG_RX_DATA_CONTENT 0x00000100 /* rx data content */ -#define DBG_RX_MGMT 0x00000200 /* rx mgmt frame headers */ -#define DBG_RX_BEACON 0x00000400 /* rx beacon */ -#define DBG_RX_CTRL 0x00000800 /* rx control */ -#define DBG_RX_MGMT_CONTENT 0x00001000 /* rx mgmt content */ -#define DBG_RX_FRAGS 0x00002000 /* rx data fragment handling */ -#define DBG_DEVSTART 0x00004000 /* fw download, device start */ -#define DBG_URB 0x00008000 /* rx urb status, ... */ -#define DBG_RX_ATMEL_HDR 0x00010000 /* Atmel-specific Rx headers */ -#define DBG_PROC_ENTRY 0x00020000 /* procedure entries/exits */ -#define DBG_PM 0x00040000 /* power management settings */ -#define DBG_BSS_MATCH 0x00080000 /* BSS match failures */ -#define DBG_PARAMS 0x00100000 /* show configured parameters */ -#define DBG_WAIT_COMPLETE 0x00200000 /* command completion */ -#define DBG_RX_FRAGS_SKB 0x00400000 /* skb header of Rx fragments */ -#define DBG_BSS_TABLE_RM 0x00800000 /* purging bss table entries */ -#define DBG_MONITOR_MODE 0x01000000 /* monitor mode */ -#define DBG_MIB 0x02000000 /* dump all MIBs on startup */ -#define DBG_MGMT_TIMER 0x04000000 /* dump mgmt_timer ops */ -#define DBG_WE_EVENTS 0x08000000 /* dump wireless events */ -#define DBG_FW 0x10000000 /* firmware download */ -#define DBG_DFU 0x20000000 /* device firmware upgrade */ - -#define DBG_DEFAULTS 0 - -/* Use our own dbg macro */ -#define at76_dbg(bits, format, arg...) \ - do { \ - if (at76_debug & (bits)) \ - printk(KERN_DEBUG DRIVER_NAME ": " format "\n" , ## arg); \ - } while (0) - -static int at76_debug = DBG_DEFAULTS; - -/* Protect against concurrent firmware loading and parsing */ -static struct mutex fw_mutex; - -static struct fwentry firmwares[] = { - [0] = {""}, - [BOARD_503_ISL3861] = {"atmel_at76c503-i3861.bin"}, - [BOARD_503_ISL3863] = {"atmel_at76c503-i3863.bin"}, - [BOARD_503] = {"atmel_at76c503-rfmd.bin"}, - [BOARD_503_ACC] = {"atmel_at76c503-rfmd-acc.bin"}, - [BOARD_505] = {"atmel_at76c505-rfmd.bin"}, - [BOARD_505_2958] = {"atmel_at76c505-rfmd2958.bin"}, - [BOARD_505A] = {"atmel_at76c505a-rfmd2958.bin"}, - [BOARD_505AMX] = {"atmel_at76c505amx-rfmd.bin"}, -}; - -#define USB_DEVICE_DATA(__ops) .driver_info = (kernel_ulong_t)(__ops) - -static struct usb_device_id dev_table[] = { - /* - * at76c503-i3861 - */ - /* Generic AT76C503/3861 device */ - {USB_DEVICE(0x03eb, 0x7603), USB_DEVICE_DATA(BOARD_503_ISL3861)}, - /* Linksys WUSB11 v2.1/v2.6 */ - {USB_DEVICE(0x066b, 0x2211), USB_DEVICE_DATA(BOARD_503_ISL3861)}, - /* Netgear MA101 rev. A */ - {USB_DEVICE(0x0864, 0x4100), USB_DEVICE_DATA(BOARD_503_ISL3861)}, - /* Tekram U300C / Allnet ALL0193 */ - {USB_DEVICE(0x0b3b, 0x1612), USB_DEVICE_DATA(BOARD_503_ISL3861)}, - /* HP HN210W J7801A */ - {USB_DEVICE(0x03f0, 0x011c), USB_DEVICE_DATA(BOARD_503_ISL3861)}, - /* Sitecom/Z-Com/Zyxel M4Y-750 */ - {USB_DEVICE(0x0cde, 0x0001), USB_DEVICE_DATA(BOARD_503_ISL3861)}, - /* Dynalink/Askey WLL013 (intersil) */ - {USB_DEVICE(0x069a, 0x0320), USB_DEVICE_DATA(BOARD_503_ISL3861)}, - /* EZ connect 11Mpbs Wireless USB Adapter SMC2662W v1 */ - {USB_DEVICE(0x0d5c, 0xa001), USB_DEVICE_DATA(BOARD_503_ISL3861)}, - /* BenQ AWL300 */ - {USB_DEVICE(0x04a5, 0x9000), USB_DEVICE_DATA(BOARD_503_ISL3861)}, - /* Addtron AWU-120, Compex WLU11 */ - {USB_DEVICE(0x05dd, 0xff31), USB_DEVICE_DATA(BOARD_503_ISL3861)}, - /* Intel AP310 AnyPoint II USB */ - {USB_DEVICE(0x8086, 0x0200), USB_DEVICE_DATA(BOARD_503_ISL3861)}, - /* Dynalink L11U */ - {USB_DEVICE(0x0d8e, 0x7100), USB_DEVICE_DATA(BOARD_503_ISL3861)}, - /* Arescom WL-210, FCC id 07J-GL2411USB */ - {USB_DEVICE(0x0d8e, 0x7110), USB_DEVICE_DATA(BOARD_503_ISL3861)}, - /* I-O DATA WN-B11/USB */ - {USB_DEVICE(0x04bb, 0x0919), USB_DEVICE_DATA(BOARD_503_ISL3861)}, - /* BT Voyager 1010 */ - {USB_DEVICE(0x069a, 0x0821), USB_DEVICE_DATA(BOARD_503_ISL3861)}, - /* - * at76c503-i3863 - */ - /* Generic AT76C503/3863 device */ - {USB_DEVICE(0x03eb, 0x7604), USB_DEVICE_DATA(BOARD_503_ISL3863)}, - /* Samsung SWL-2100U */ - {USB_DEVICE(0x055d, 0xa000), USB_DEVICE_DATA(BOARD_503_ISL3863)}, - /* - * at76c503-rfmd - */ - /* Generic AT76C503/RFMD device */ - {USB_DEVICE(0x03eb, 0x7605), USB_DEVICE_DATA(BOARD_503)}, - /* Dynalink/Askey WLL013 (rfmd) */ - {USB_DEVICE(0x069a, 0x0321), USB_DEVICE_DATA(BOARD_503)}, - /* Linksys WUSB11 v2.6 */ - {USB_DEVICE(0x077b, 0x2219), USB_DEVICE_DATA(BOARD_503)}, - /* Network Everywhere NWU11B */ - {USB_DEVICE(0x077b, 0x2227), USB_DEVICE_DATA(BOARD_503)}, - /* Netgear MA101 rev. B */ - {USB_DEVICE(0x0864, 0x4102), USB_DEVICE_DATA(BOARD_503)}, - /* D-Link DWL-120 rev. E */ - {USB_DEVICE(0x2001, 0x3200), USB_DEVICE_DATA(BOARD_503)}, - /* Actiontec 802UAT1, HWU01150-01UK */ - {USB_DEVICE(0x1668, 0x7605), USB_DEVICE_DATA(BOARD_503)}, - /* AirVast W-Buddie WN210 */ - {USB_DEVICE(0x03eb, 0x4102), USB_DEVICE_DATA(BOARD_503)}, - /* Dick Smith Electronics XH1153 802.11b USB adapter */ - {USB_DEVICE(0x1371, 0x5743), USB_DEVICE_DATA(BOARD_503)}, - /* CNet CNUSB611 */ - {USB_DEVICE(0x1371, 0x0001), USB_DEVICE_DATA(BOARD_503)}, - /* FiberLine FL-WL200U */ - {USB_DEVICE(0x1371, 0x0002), USB_DEVICE_DATA(BOARD_503)}, - /* BenQ AWL400 USB stick */ - {USB_DEVICE(0x04a5, 0x9001), USB_DEVICE_DATA(BOARD_503)}, - /* 3Com 3CRSHEW696 */ - {USB_DEVICE(0x0506, 0x0a01), USB_DEVICE_DATA(BOARD_503)}, - /* Siemens Santis ADSL WLAN USB adapter WLL 013 */ - {USB_DEVICE(0x0681, 0x001b), USB_DEVICE_DATA(BOARD_503)}, - /* Belkin F5D6050, version 2 */ - {USB_DEVICE(0x050d, 0x0050), USB_DEVICE_DATA(BOARD_503)}, - /* iBlitzz, BWU613 (not *B or *SB) */ - {USB_DEVICE(0x07b8, 0xb000), USB_DEVICE_DATA(BOARD_503)}, - /* Gigabyte GN-WLBM101 */ - {USB_DEVICE(0x1044, 0x8003), USB_DEVICE_DATA(BOARD_503)}, - /* Planex GW-US11S */ - {USB_DEVICE(0x2019, 0x3220), USB_DEVICE_DATA(BOARD_503)}, - /* Internal WLAN adapter in h5[4,5]xx series iPAQs */ - {USB_DEVICE(0x049f, 0x0032), USB_DEVICE_DATA(BOARD_503)}, - /* Corega Wireless LAN USB-11 mini */ - {USB_DEVICE(0x07aa, 0x0011), USB_DEVICE_DATA(BOARD_503)}, - /* Corega Wireless LAN USB-11 mini2 */ - {USB_DEVICE(0x07aa, 0x0018), USB_DEVICE_DATA(BOARD_503)}, - /* Uniden PCW100 */ - {USB_DEVICE(0x05dd, 0xff35), USB_DEVICE_DATA(BOARD_503)}, - /* - * at76c503-rfmd-acc - */ - /* SMC2664W */ - {USB_DEVICE(0x083a, 0x3501), USB_DEVICE_DATA(BOARD_503_ACC)}, - /* Belkin F5D6050, SMC2662W v2, SMC2662W-AR */ - {USB_DEVICE(0x0d5c, 0xa002), USB_DEVICE_DATA(BOARD_503_ACC)}, - /* - * at76c505-rfmd - */ - /* Generic AT76C505/RFMD */ - {USB_DEVICE(0x03eb, 0x7606), USB_DEVICE_DATA(BOARD_505)}, - /* - * at76c505-rfmd2958 - */ - /* Generic AT76C505/RFMD, OvisLink WL-1130USB */ - {USB_DEVICE(0x03eb, 0x7613), USB_DEVICE_DATA(BOARD_505_2958)}, - /* Fiberline FL-WL240U */ - {USB_DEVICE(0x1371, 0x0014), USB_DEVICE_DATA(BOARD_505_2958)}, - /* CNet CNUSB-611G */ - {USB_DEVICE(0x1371, 0x0013), USB_DEVICE_DATA(BOARD_505_2958)}, - /* Linksys WUSB11 v2.8 */ - {USB_DEVICE(0x1915, 0x2233), USB_DEVICE_DATA(BOARD_505_2958)}, - /* Xterasys XN-2122B, IBlitzz BWU613B/BWU613SB */ - {USB_DEVICE(0x12fd, 0x1001), USB_DEVICE_DATA(BOARD_505_2958)}, - /* Corega WLAN USB Stick 11 */ - {USB_DEVICE(0x07aa, 0x7613), USB_DEVICE_DATA(BOARD_505_2958)}, - /* Microstar MSI Box MS6978 */ - {USB_DEVICE(0x0db0, 0x1020), USB_DEVICE_DATA(BOARD_505_2958)}, - /* - * at76c505a-rfmd2958 - */ - /* Generic AT76C505A device */ - {USB_DEVICE(0x03eb, 0x7614), USB_DEVICE_DATA(BOARD_505A)}, - /* Generic AT76C505AS device */ - {USB_DEVICE(0x03eb, 0x7617), USB_DEVICE_DATA(BOARD_505A)}, - /* Siemens Gigaset USB WLAN Adapter 11 */ - {USB_DEVICE(0x1690, 0x0701), USB_DEVICE_DATA(BOARD_505A)}, - /* OQO Model 01+ Internal Wi-Fi */ - {USB_DEVICE(0x1557, 0x0002), USB_DEVICE_DATA(BOARD_505A)}, - /* - * at76c505amx-rfmd - */ - /* Generic AT76C505AMX device */ - {USB_DEVICE(0x03eb, 0x7615), USB_DEVICE_DATA(BOARD_505AMX)}, - {} -}; - -MODULE_DEVICE_TABLE(usb, dev_table); - -/* Supported rates of this hardware, bit 7 marks basic rates */ -static const u8 hw_rates[] = { 0x82, 0x84, 0x0b, 0x16 }; - -/* Frequency of each channel in MHz */ -static const long channel_frequency[] = { - 2412, 2417, 2422, 2427, 2432, 2437, 2442, - 2447, 2452, 2457, 2462, 2467, 2472, 2484 -}; - -#define NUM_CHANNELS ARRAY_SIZE(channel_frequency) - -static const char *const preambles[] = { "long", "short", "auto" }; - -static const char *const mac_states[] = { - [MAC_INIT] = "INIT", - [MAC_SCANNING] = "SCANNING", - [MAC_AUTH] = "AUTH", - [MAC_ASSOC] = "ASSOC", - [MAC_JOINING] = "JOINING", - [MAC_CONNECTED] = "CONNECTED", - [MAC_OWN_IBSS] = "OWN_IBSS" -}; - -/* Firmware download */ -/* DFU states */ -#define STATE_IDLE 0x00 -#define STATE_DETACH 0x01 -#define STATE_DFU_IDLE 0x02 -#define STATE_DFU_DOWNLOAD_SYNC 0x03 -#define STATE_DFU_DOWNLOAD_BUSY 0x04 -#define STATE_DFU_DOWNLOAD_IDLE 0x05 -#define STATE_DFU_MANIFEST_SYNC 0x06 -#define STATE_DFU_MANIFEST 0x07 -#define STATE_DFU_MANIFEST_WAIT_RESET 0x08 -#define STATE_DFU_UPLOAD_IDLE 0x09 -#define STATE_DFU_ERROR 0x0a - -/* DFU commands */ -#define DFU_DETACH 0 -#define DFU_DNLOAD 1 -#define DFU_UPLOAD 2 -#define DFU_GETSTATUS 3 -#define DFU_CLRSTATUS 4 -#define DFU_GETSTATE 5 -#define DFU_ABORT 6 - -#define FW_BLOCK_SIZE 1024 - -struct dfu_status { - unsigned char status; - unsigned char poll_timeout[3]; - unsigned char state; - unsigned char string; -} __attribute__((packed)); - -static inline int at76_is_intersil(enum board_type board) -{ - return (board == BOARD_503_ISL3861 || board == BOARD_503_ISL3863); -} - -static inline int at76_is_503rfmd(enum board_type board) -{ - return (board == BOARD_503 || board == BOARD_503_ACC); -} - -static inline int at76_is_505a(enum board_type board) -{ - return (board == BOARD_505A || board == BOARD_505AMX); -} - -/* Load a block of the first (internal) part of the firmware */ -static int at76_load_int_fw_block(struct usb_device *udev, int blockno, - void *block, int size) -{ - return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), DFU_DNLOAD, - USB_TYPE_CLASS | USB_DIR_OUT | - USB_RECIP_INTERFACE, blockno, 0, block, size, - USB_CTRL_GET_TIMEOUT); -} - -static int at76_dfu_get_status(struct usb_device *udev, - struct dfu_status *status) -{ - int ret; - - ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), DFU_GETSTATUS, - USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE, - 0, 0, status, sizeof(struct dfu_status), - USB_CTRL_GET_TIMEOUT); - return ret; -} - -static u8 at76_dfu_get_state(struct usb_device *udev, u8 *state) -{ - int ret; - - ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), DFU_GETSTATE, - USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE, - 0, 0, state, 1, USB_CTRL_GET_TIMEOUT); - return ret; -} - -/* Convert timeout from the DFU status to jiffies */ -static inline unsigned long at76_get_timeout(struct dfu_status *s) -{ - return msecs_to_jiffies((s->poll_timeout[2] << 16) - | (s->poll_timeout[1] << 8) - | (s->poll_timeout[0])); -} - -/* Load internal firmware from the buffer. If manifest_sync_timeout > 0, use - * its value in jiffies in the MANIFEST_SYNC state. */ -static int at76_usbdfu_download(struct usb_device *udev, u8 *buf, u32 size, - int manifest_sync_timeout) -{ - u8 *block; - struct dfu_status dfu_stat_buf; - int ret = 0; - int need_dfu_state = 1; - int is_done = 0; - u8 dfu_state = 0; - u32 dfu_timeout = 0; - int bsize = 0; - int blockno = 0; - - at76_dbg(DBG_DFU, "%s( %p, %u, %d)", __func__, buf, size, - manifest_sync_timeout); - - if (!size) { - dev_printk(KERN_ERR, &udev->dev, "FW buffer length invalid!\n"); - return -EINVAL; - } - - block = kmalloc(FW_BLOCK_SIZE, GFP_KERNEL); - if (!block) - return -ENOMEM; - - do { - if (need_dfu_state) { - ret = at76_dfu_get_state(udev, &dfu_state); - if (ret < 0) { - dev_printk(KERN_ERR, &udev->dev, - "cannot get DFU state: %d\n", ret); - goto exit; - } - need_dfu_state = 0; - } - - switch (dfu_state) { - case STATE_DFU_DOWNLOAD_SYNC: - at76_dbg(DBG_DFU, "STATE_DFU_DOWNLOAD_SYNC"); - ret = at76_dfu_get_status(udev, &dfu_stat_buf); - if (ret >= 0) { - dfu_state = dfu_stat_buf.state; - dfu_timeout = at76_get_timeout(&dfu_stat_buf); - need_dfu_state = 0; - } else - dev_printk(KERN_ERR, &udev->dev, - "at76_dfu_get_status returned %d\n", - ret); - break; - - case STATE_DFU_DOWNLOAD_BUSY: - at76_dbg(DBG_DFU, "STATE_DFU_DOWNLOAD_BUSY"); - need_dfu_state = 1; - - at76_dbg(DBG_DFU, "DFU: Resetting device"); - schedule_timeout_interruptible(dfu_timeout); - break; - - case STATE_DFU_DOWNLOAD_IDLE: - at76_dbg(DBG_DFU, "DOWNLOAD..."); - /* fall through */ - case STATE_DFU_IDLE: - at76_dbg(DBG_DFU, "DFU IDLE"); - - bsize = min_t(int, size, FW_BLOCK_SIZE); - memcpy(block, buf, bsize); - at76_dbg(DBG_DFU, "int fw, size left = %5d, " - "bsize = %4d, blockno = %2d", size, bsize, - blockno); - ret = - at76_load_int_fw_block(udev, blockno, block, bsize); - buf += bsize; - size -= bsize; - blockno++; - - if (ret != bsize) - dev_printk(KERN_ERR, &udev->dev, - "at76_load_int_fw_block " - "returned %d\n", ret); - need_dfu_state = 1; - break; - - case STATE_DFU_MANIFEST_SYNC: - at76_dbg(DBG_DFU, "STATE_DFU_MANIFEST_SYNC"); - - ret = at76_dfu_get_status(udev, &dfu_stat_buf); - if (ret < 0) - break; - - dfu_state = dfu_stat_buf.state; - dfu_timeout = at76_get_timeout(&dfu_stat_buf); - need_dfu_state = 0; - - /* override the timeout from the status response, - needed for AT76C505A */ - if (manifest_sync_timeout > 0) - dfu_timeout = manifest_sync_timeout; - - at76_dbg(DBG_DFU, "DFU: Waiting for manifest phase"); - schedule_timeout_interruptible(dfu_timeout); - break; - - case STATE_DFU_MANIFEST: - at76_dbg(DBG_DFU, "STATE_DFU_MANIFEST"); - is_done = 1; - break; - - case STATE_DFU_MANIFEST_WAIT_RESET: - at76_dbg(DBG_DFU, "STATE_DFU_MANIFEST_WAIT_RESET"); - is_done = 1; - break; - - case STATE_DFU_UPLOAD_IDLE: - at76_dbg(DBG_DFU, "STATE_DFU_UPLOAD_IDLE"); - break; - - case STATE_DFU_ERROR: - at76_dbg(DBG_DFU, "STATE_DFU_ERROR"); - ret = -EPIPE; - break; - - default: - at76_dbg(DBG_DFU, "DFU UNKNOWN STATE (%d)", dfu_state); - ret = -EINVAL; - break; - } - } while (!is_done && (ret >= 0)); - -exit: - kfree(block); - if (ret >= 0) - ret = 0; - - return ret; -} - -/* Report that the scan results are ready */ -static inline void at76_iwevent_scan_complete(struct net_device *netdev) -{ - union iwreq_data wrqu; - wrqu.data.length = 0; - wrqu.data.flags = 0; - wireless_send_event(netdev, SIOCGIWSCAN, &wrqu, NULL); - at76_dbg(DBG_WE_EVENTS, "%s: SIOCGIWSCAN sent", netdev->name); -} - -static inline void at76_iwevent_bss_connect(struct net_device *netdev, - u8 *bssid) -{ - union iwreq_data wrqu; - wrqu.data.length = 0; - wrqu.data.flags = 0; - memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN); - wrqu.ap_addr.sa_family = ARPHRD_ETHER; - wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL); - at76_dbg(DBG_WE_EVENTS, "%s: %s: SIOCGIWAP sent", netdev->name, - __func__); -} - -static inline void at76_iwevent_bss_disconnect(struct net_device *netdev) -{ - union iwreq_data wrqu; - wrqu.data.length = 0; - wrqu.data.flags = 0; - memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); - wrqu.ap_addr.sa_family = ARPHRD_ETHER; - wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL); - at76_dbg(DBG_WE_EVENTS, "%s: %s: SIOCGIWAP sent", netdev->name, - __func__); -} - -#define HEX2STR_BUFFERS 4 -#define HEX2STR_MAX_LEN 64 -#define BIN2HEX(x) ((x) < 10 ? '0' + (x) : (x) + 'A' - 10) - -/* Convert binary data into hex string */ -static char *hex2str(void *buf, int len) -{ - static atomic_t a = ATOMIC_INIT(0); - static char bufs[HEX2STR_BUFFERS][3 * HEX2STR_MAX_LEN + 1]; - char *ret = bufs[atomic_inc_return(&a) & (HEX2STR_BUFFERS - 1)]; - char *obuf = ret; - u8 *ibuf = buf; - - if (len > HEX2STR_MAX_LEN) - len = HEX2STR_MAX_LEN; - - if (len <= 0) { - ret[0] = '\0'; - return ret; - } - - while (len--) { - *obuf++ = BIN2HEX(*ibuf >> 4); - *obuf++ = BIN2HEX(*ibuf & 0xf); - *obuf++ = '-'; - ibuf++; - } - *(--obuf) = '\0'; - - return ret; -} - -/* LED trigger */ -static int tx_activity; -static void at76_ledtrig_tx_timerfunc(unsigned long data); -static DEFINE_TIMER(ledtrig_tx_timer, at76_ledtrig_tx_timerfunc, 0, 0); -DEFINE_LED_TRIGGER(ledtrig_tx); - -static void at76_ledtrig_tx_timerfunc(unsigned long data) -{ - static int tx_lastactivity; - - if (tx_lastactivity != tx_activity) { - tx_lastactivity = tx_activity; - led_trigger_event(ledtrig_tx, LED_FULL); - mod_timer(&ledtrig_tx_timer, jiffies + HZ / 4); - } else - led_trigger_event(ledtrig_tx, LED_OFF); -} - -static void at76_ledtrig_tx_activity(void) -{ - tx_activity++; - if (!timer_pending(&ledtrig_tx_timer)) - mod_timer(&ledtrig_tx_timer, jiffies + HZ / 4); -} - -/* Check if the given ssid is hidden */ -static inline int at76_is_hidden_ssid(u8 *ssid, int length) -{ - static const u8 zeros[32]; - - if (length == 0) - return 1; - - if (length == 1 && ssid[0] == ' ') - return 1; - - return (memcmp(ssid, zeros, length) == 0); -} - -static inline void at76_free_bss_list(struct at76_priv *priv) -{ - struct list_head *next, *ptr; - unsigned long flags; - - spin_lock_irqsave(&priv->bss_list_spinlock, flags); - - priv->curr_bss = NULL; - - list_for_each_safe(ptr, next, &priv->bss_list) { - list_del(ptr); - kfree(list_entry(ptr, struct bss_info, list)); - } - - spin_unlock_irqrestore(&priv->bss_list_spinlock, flags); -} - -static int at76_remap(struct usb_device *udev) -{ - int ret; - ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x0a, - USB_TYPE_VENDOR | USB_DIR_OUT | - USB_RECIP_INTERFACE, 0, 0, NULL, 0, - USB_CTRL_GET_TIMEOUT); - if (ret < 0) - return ret; - return 0; -} - -static int at76_get_op_mode(struct usb_device *udev) -{ - int ret; - u8 saved; - u8 *op_mode; - - op_mode = kmalloc(1, GFP_NOIO); - if (!op_mode) - return -ENOMEM; - ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x33, - USB_TYPE_VENDOR | USB_DIR_IN | - USB_RECIP_INTERFACE, 0x01, 0, op_mode, 1, - USB_CTRL_GET_TIMEOUT); - saved = *op_mode; - kfree(op_mode); - - if (ret < 0) - return ret; - else if (ret < 1) - return -EIO; - else - return saved; -} - -/* Load a block of the second ("external") part of the firmware */ -static inline int at76_load_ext_fw_block(struct usb_device *udev, int blockno, - void *block, int size) -{ - return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x0e, - USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, - 0x0802, blockno, block, size, - USB_CTRL_GET_TIMEOUT); -} - -static inline int at76_get_hw_cfg(struct usb_device *udev, - union at76_hwcfg *buf, int buf_size) -{ - return usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x33, - USB_TYPE_VENDOR | USB_DIR_IN | - USB_RECIP_INTERFACE, 0x0a02, 0, - buf, buf_size, USB_CTRL_GET_TIMEOUT); -} - -/* Intersil boards use a different "value" for GetHWConfig requests */ -static inline int at76_get_hw_cfg_intersil(struct usb_device *udev, - union at76_hwcfg *buf, int buf_size) -{ - return usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x33, - USB_TYPE_VENDOR | USB_DIR_IN | - USB_RECIP_INTERFACE, 0x0902, 0, - buf, buf_size, USB_CTRL_GET_TIMEOUT); -} - -/* Get the hardware configuration for the adapter and put it to the appropriate - * fields of 'priv' (the GetHWConfig request and interpretation of the result - * depends on the board type) */ -static int at76_get_hw_config(struct at76_priv *priv) -{ - int ret; - union at76_hwcfg *hwcfg = kmalloc(sizeof(*hwcfg), GFP_KERNEL); - - if (!hwcfg) - return -ENOMEM; - - if (at76_is_intersil(priv->board_type)) { - ret = at76_get_hw_cfg_intersil(priv->udev, hwcfg, - sizeof(hwcfg->i)); - if (ret < 0) - goto exit; - memcpy(priv->mac_addr, hwcfg->i.mac_addr, ETH_ALEN); - priv->regulatory_domain = hwcfg->i.regulatory_domain; - } else if (at76_is_503rfmd(priv->board_type)) { - ret = at76_get_hw_cfg(priv->udev, hwcfg, sizeof(hwcfg->r3)); - if (ret < 0) - goto exit; - memcpy(priv->mac_addr, hwcfg->r3.mac_addr, ETH_ALEN); - priv->regulatory_domain = hwcfg->r3.regulatory_domain; - } else { - ret = at76_get_hw_cfg(priv->udev, hwcfg, sizeof(hwcfg->r5)); - if (ret < 0) - goto exit; - memcpy(priv->mac_addr, hwcfg->r5.mac_addr, ETH_ALEN); - priv->regulatory_domain = hwcfg->r5.regulatory_domain; - } - -exit: - kfree(hwcfg); - if (ret < 0) - printk(KERN_ERR "%s: cannot get HW Config (error %d)\n", - priv->netdev->name, ret); - - return ret; -} - -static struct reg_domain const *at76_get_reg_domain(u16 code) -{ - int i; - static struct reg_domain const fd_tab[] = { - {0x10, "FCC (USA)", 0x7ff}, /* ch 1-11 */ - {0x20, "IC (Canada)", 0x7ff}, /* ch 1-11 */ - {0x30, "ETSI (most of Europe)", 0x1fff}, /* ch 1-13 */ - {0x31, "Spain", 0x600}, /* ch 10-11 */ - {0x32, "France", 0x1e00}, /* ch 10-13 */ - {0x40, "MKK (Japan)", 0x2000}, /* ch 14 */ - {0x41, "MKK1 (Japan)", 0x3fff}, /* ch 1-14 */ - {0x50, "Israel", 0x3fc}, /* ch 3-9 */ - {0x00, "<unknown>", 0xffffffff} /* ch 1-32 */ - }; - - /* Last entry is fallback for unknown domain code */ - for (i = 0; i < ARRAY_SIZE(fd_tab) - 1; i++) - if (code == fd_tab[i].code) - break; - - return &fd_tab[i]; -} - -static inline int at76_get_mib(struct usb_device *udev, u16 mib, void *buf, - int buf_size) -{ - int ret; - - ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x33, - USB_TYPE_VENDOR | USB_DIR_IN | - USB_RECIP_INTERFACE, mib << 8, 0, buf, buf_size, - USB_CTRL_GET_TIMEOUT); - if (ret >= 0 && ret != buf_size) - return -EIO; - return ret; -} - -/* Return positive number for status, negative for an error */ -static inline int at76_get_cmd_status(struct usb_device *udev, u8 cmd) -{ - u8 *stat_buf; - int ret; - - stat_buf = kmalloc(40, GFP_NOIO); - if (!stat_buf) - return -ENOMEM; - - ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x22, - USB_TYPE_VENDOR | USB_DIR_IN | - USB_RECIP_INTERFACE, cmd, 0, stat_buf, - 40, USB_CTRL_GET_TIMEOUT); - if (ret >= 0) - ret = stat_buf[5]; - kfree(stat_buf); - - return ret; -} - -static int at76_set_card_command(struct usb_device *udev, u8 cmd, void *buf, - int buf_size) -{ - int ret; - struct at76_command *cmd_buf = kmalloc(sizeof(struct at76_command) + - buf_size, GFP_KERNEL); - - if (!cmd_buf) - return -ENOMEM; - - cmd_buf->cmd = cmd; - cmd_buf->reserved = 0; - cmd_buf->size = cpu_to_le16(buf_size); - memcpy(cmd_buf->data, buf, buf_size); - - ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x0e, - USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, - 0, 0, cmd_buf, - sizeof(struct at76_command) + buf_size, - USB_CTRL_GET_TIMEOUT); - kfree(cmd_buf); - return ret; -} - -#define MAKE_CMD_STATUS_CASE(c) case (c): return #c -static const char *at76_get_cmd_status_string(u8 cmd_status) -{ - switch (cmd_status) { - MAKE_CMD_STATUS_CASE(CMD_STATUS_IDLE); - MAKE_CMD_STATUS_CASE(CMD_STATUS_COMPLETE); - MAKE_CMD_STATUS_CASE(CMD_STATUS_UNKNOWN); - MAKE_CMD_STATUS_CASE(CMD_STATUS_INVALID_PARAMETER); - MAKE_CMD_STATUS_CASE(CMD_STATUS_FUNCTION_NOT_SUPPORTED); - MAKE_CMD_STATUS_CASE(CMD_STATUS_TIME_OUT); - MAKE_CMD_STATUS_CASE(CMD_STATUS_IN_PROGRESS); - MAKE_CMD_STATUS_CASE(CMD_STATUS_HOST_FAILURE); - MAKE_CMD_STATUS_CASE(CMD_STATUS_SCAN_FAILED); - } - - return "UNKNOWN"; -} - -/* Wait until the command is completed */ -static int at76_wait_completion(struct at76_priv *priv, int cmd) -{ - int status = 0; - unsigned long timeout = jiffies + CMD_COMPLETION_TIMEOUT; - - do { - status = at76_get_cmd_status(priv->udev, cmd); - if (status < 0) { - printk(KERN_ERR "%s: at76_get_cmd_status failed: %d\n", - priv->netdev->name, status); - break; - } - - at76_dbg(DBG_WAIT_COMPLETE, - "%s: Waiting on cmd %d, status = %d (%s)", - priv->netdev->name, cmd, status, - at76_get_cmd_status_string(status)); - - if (status != CMD_STATUS_IN_PROGRESS - && status != CMD_STATUS_IDLE) - break; - - schedule_timeout_interruptible(HZ / 10); /* 100 ms */ - if (time_after(jiffies, timeout)) { - printk(KERN_ERR - "%s: completion timeout for command %d\n", - priv->netdev->name, cmd); - status = -ETIMEDOUT; - break; - } - } while (1); - - return status; -} - -static int at76_set_mib(struct at76_priv *priv, struct set_mib_buffer *buf) -{ - int ret; - - ret = at76_set_card_command(priv->udev, CMD_SET_MIB, buf, - offsetof(struct set_mib_buffer, - data) + buf->size); - if (ret < 0) - return ret; - - ret = at76_wait_completion(priv, CMD_SET_MIB); - if (ret != CMD_STATUS_COMPLETE) { - printk(KERN_INFO - "%s: set_mib: at76_wait_completion failed " - "with %d\n", priv->netdev->name, ret); - ret = -EIO; - } - - return ret; -} - -/* Return < 0 on error, == 0 if no command sent, == 1 if cmd sent */ -static int at76_set_radio(struct at76_priv *priv, int enable) -{ - int ret; - int cmd; - - if (priv->radio_on == enable) - return 0; - - cmd = enable ? CMD_RADIO_ON : CMD_RADIO_OFF; - - ret = at76_set_card_command(priv->udev, cmd, NULL, 0); - if (ret < 0) - printk(KERN_ERR "%s: at76_set_card_command(%d) failed: %d\n", - priv->netdev->name, cmd, ret); - else - ret = 1; - - priv->radio_on = enable; - return ret; -} - -/* Set current power save mode (AT76_PM_OFF/AT76_PM_ON/AT76_PM_SMART) */ -static int at76_set_pm_mode(struct at76_priv *priv) -{ - int ret = 0; - - priv->mib_buf.type = MIB_MAC_MGMT; - priv->mib_buf.size = 1; - priv->mib_buf.index = offsetof(struct mib_mac_mgmt, power_mgmt_mode); - priv->mib_buf.data.byte = priv->pm_mode; - - ret = at76_set_mib(priv, &priv->mib_buf); - if (ret < 0) - printk(KERN_ERR "%s: set_mib (pm_mode) failed: %d\n", - priv->netdev->name, ret); - - return ret; -} - -/* Set the association id for power save mode */ -static int at76_set_associd(struct at76_priv *priv, u16 id) -{ - int ret = 0; - - priv->mib_buf.type = MIB_MAC_MGMT; - priv->mib_buf.size = 2; - priv->mib_buf.index = offsetof(struct mib_mac_mgmt, station_id); - priv->mib_buf.data.word = cpu_to_le16(id); - - ret = at76_set_mib(priv, &priv->mib_buf); - if (ret < 0) - printk(KERN_ERR "%s: set_mib (associd) failed: %d\n", - priv->netdev->name, ret); - - return ret; -} - -/* Set the listen interval for power save mode */ -static int at76_set_listen_interval(struct at76_priv *priv, u16 interval) -{ - int ret = 0; - - priv->mib_buf.type = MIB_MAC; - priv->mib_buf.size = 2; - priv->mib_buf.index = offsetof(struct mib_mac, listen_interval); - priv->mib_buf.data.word = cpu_to_le16(interval); - - ret = at76_set_mib(priv, &priv->mib_buf); - if (ret < 0) - printk(KERN_ERR - "%s: set_mib (listen_interval) failed: %d\n", - priv->netdev->name, ret); - - return ret; -} - -static int at76_set_preamble(struct at76_priv *priv, u8 type) -{ - int ret = 0; - - priv->mib_buf.type = MIB_LOCAL; - priv->mib_buf.size = 1; - priv->mib_buf.index = offsetof(struct mib_local, preamble_type); - priv->mib_buf.data.byte = type; - - ret = at76_set_mib(priv, &priv->mib_buf); - if (ret < 0) - printk(KERN_ERR "%s: set_mib (preamble) failed: %d\n", - priv->netdev->name, ret); - - return ret; -} - -static int at76_set_frag(struct at76_priv *priv, u16 size) -{ - int ret = 0; - - priv->mib_buf.type = MIB_MAC; - priv->mib_buf.size = 2; - priv->mib_buf.index = offsetof(struct mib_mac, frag_threshold); - priv->mib_buf.data.word = cpu_to_le16(size); - - ret = at76_set_mib(priv, &priv->mib_buf); - if (ret < 0) - printk(KERN_ERR "%s: set_mib (frag threshold) failed: %d\n", - priv->netdev->name, ret); - - return ret; -} - -static int at76_set_rts(struct at76_priv *priv, u16 size) -{ - int ret = 0; |