From 494a43bb188c10b9b21375bbfe2691e41e3cb145 Mon Sep 17 00:00:00 2001 From: Alan Olsen Date: Mon, 26 Apr 2010 10:50:19 -0700 Subject: [PATCH 001/523] Moorestown "Post Beta" nand driver. Contains the fixes for nand corruption with the watchdog driver. New features compares to MRST NAND driver Post Alpah2 2.0: 1. Enable CDMA feature of NAND controller How to use this driver: The same with before. That is, to enable this driver, you can set CONFIG_MRST_NAND=y CONFIG_MRST_NAND_HW=y Signed-off-by: Gao Yunpeng Signed-off-by: Alan Olsen --- drivers/block/Kconfig | 2 + drivers/block/Makefile | 2 + drivers/block/spectra/Kconfig | 27 + drivers/block/spectra/Makefile | 7 + drivers/block/spectra/README | 29 + drivers/block/spectra/ffsdefs.h | 58 + drivers/block/spectra/ffsport.c | 847 ++++ drivers/block/spectra/ffsport.h | 84 + drivers/block/spectra/flash.c | 4731 +++++++++++++++++++++++ drivers/block/spectra/flash.h | 198 + drivers/block/spectra/lld.c | 258 ++ drivers/block/spectra/lld.h | 111 + drivers/block/spectra/lld_cdma.c | 910 +++++ drivers/block/spectra/lld_cdma.h | 123 + drivers/block/spectra/lld_emu.c | 780 ++++ drivers/block/spectra/lld_emu.h | 51 + drivers/block/spectra/lld_nand.c | 2601 +++++++++++++ drivers/block/spectra/lld_nand.h | 131 + drivers/block/spectra/nand_regs.h | 619 +++ drivers/block/spectra/spectraswconfig.h | 81 + 20 files changed, 11650 insertions(+) create mode 100644 drivers/block/spectra/Kconfig create mode 100644 drivers/block/spectra/Makefile create mode 100644 drivers/block/spectra/README create mode 100644 drivers/block/spectra/ffsdefs.h create mode 100644 drivers/block/spectra/ffsport.c create mode 100644 drivers/block/spectra/ffsport.h create mode 100644 drivers/block/spectra/flash.c create mode 100644 drivers/block/spectra/flash.h create mode 100644 drivers/block/spectra/lld.c create mode 100644 drivers/block/spectra/lld.h create mode 100644 drivers/block/spectra/lld_cdma.c create mode 100644 drivers/block/spectra/lld_cdma.h create mode 100644 drivers/block/spectra/lld_emu.c create mode 100644 drivers/block/spectra/lld_emu.h create mode 100644 drivers/block/spectra/lld_nand.c create mode 100644 drivers/block/spectra/lld_nand.h create mode 100644 drivers/block/spectra/nand_regs.h create mode 100644 drivers/block/spectra/spectraswconfig.h diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 77bfce52e9ca..d62b95d2ab00 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -488,4 +488,6 @@ config BLK_DEV_HD If unsure, say N. +source "drivers/block/spectra/Kconfig" + endif # BLK_DEV diff --git a/drivers/block/Makefile b/drivers/block/Makefile index aff5ac925c34..568ba651cb5e 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -38,4 +38,6 @@ obj-$(CONFIG_BLK_DEV_HD) += hd.o obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o obj-$(CONFIG_BLK_DEV_DRBD) += drbd/ +obj-$(CONFIG_MRST_NAND) += spectra/ + swim_mod-objs := swim.o swim_asm.o diff --git a/drivers/block/spectra/Kconfig b/drivers/block/spectra/Kconfig new file mode 100644 index 000000000000..fbece109f6c6 --- /dev/null +++ b/drivers/block/spectra/Kconfig @@ -0,0 +1,27 @@ + +menuconfig MRST_NAND + tristate "Moorestown NAND Flash controller" + depends on BLOCK + default n + ---help--- + Enable the driver for the NAND Flash controller in Intel Moorestown + Platform + +choice + prompt "Compile for" + depends on MRST_NAND + default MRST_NAND_HW + +config MRST_NAND_HW + bool "Actual hardware mode" + help + Driver communicates with the actual hardware's register interface. + in DMA mode. + +config MRST_NAND_EMU + bool "RAM emulator testing" + help + Driver emulates Flash on a RAM buffer and / or disk file. Useful to test the behavior of FTL layer. + +endchoice + diff --git a/drivers/block/spectra/Makefile b/drivers/block/spectra/Makefile new file mode 100644 index 000000000000..261891c23577 --- /dev/null +++ b/drivers/block/spectra/Makefile @@ -0,0 +1,7 @@ +# +# Makefile of Intel Moorestown NAND controller driver +# + +obj-$(CONFIG_MRST_NAND) += spectra.o +spectra-objs := ffsport.o flash.o lld.o lld_emu.o lld_nand.o lld_cdma.o + diff --git a/drivers/block/spectra/README b/drivers/block/spectra/README new file mode 100644 index 000000000000..ecba559b899c --- /dev/null +++ b/drivers/block/spectra/README @@ -0,0 +1,29 @@ +This is a driver for NAND controller of Intel Moorestown platform. + +This driver is a standalone linux block device driver, it acts as if it's a normal hard disk. +It includes three layer: + block layer interface - file ffsport.c + Flash Translation Layer (FTL) - file flash.c (implement the NAND flash Translation Layer, includs address mapping, garbage collection, wear-leveling and so on) + Low level layer - file lld_nand.c/lld_cdma.c/lld_emu.c (which implements actual controller hardware registers access) + +This driver can be build as modules or build-in. + +Dependency: +This driver has dependency on IA Firmware of Intel Moorestown platform. +It need the IA Firmware to create the block table for the first time. +And to validate this driver code without IA Firmware, you can change the +macro AUTO_FORMAT_FLASH from 0 to 1 in file spectraswconfig.h. Thus the +driver will erase the whole nand flash and create a new block table. + +TODO: + - Enable Command DMA feature support + - lower the memory footprint + - Remove most of the unnecessary global variables + - Change all the upcase variable / functions name to lowercase + - Some other misc bugs + +Please send patches to: + Greg Kroah-Hartman + +And Cc to: Gao Yunpeng + diff --git a/drivers/block/spectra/ffsdefs.h b/drivers/block/spectra/ffsdefs.h new file mode 100644 index 000000000000..a9e9cd233d2a --- /dev/null +++ b/drivers/block/spectra/ffsdefs.h @@ -0,0 +1,58 @@ +/* + * NAND Flash Controller Device Driver + * Copyright (c) 2009, Intel Corporation and its suppliers. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef _FFSDEFS_ +#define _FFSDEFS_ + +#define CLEAR 0 /*use this to clear a field instead of "fail"*/ +#define SET 1 /*use this to set a field instead of "pass"*/ +#define FAIL 1 /*failed flag*/ +#define PASS 0 /*success flag*/ +#define ERR -1 /*error flag*/ + +#define ERASE_CMD 10 +#define WRITE_MAIN_CMD 11 +#define READ_MAIN_CMD 12 +#define WRITE_SPARE_CMD 13 +#define READ_SPARE_CMD 14 +#define WRITE_MAIN_SPARE_CMD 15 +#define READ_MAIN_SPARE_CMD 16 +#define MEMCOPY_CMD 17 +#define DUMMY_CMD 99 + +#define EVENT_PASS 0x00 +#define EVENT_CORRECTABLE_DATA_ERROR_FIXED 0x01 +#define EVENT_UNCORRECTABLE_DATA_ERROR 0x02 +#define EVENT_TIME_OUT 0x03 +#define EVENT_PROGRAM_FAILURE 0x04 +#define EVENT_ERASE_FAILURE 0x05 +#define EVENT_MEMCOPY_FAILURE 0x06 +#define EVENT_FAIL 0x07 + +#define EVENT_NONE 0x22 +#define EVENT_DMA_CMD_COMP 0x77 +#define EVENT_ECC_TRANSACTION_DONE 0x88 +#define EVENT_DMA_CMD_FAIL 0x99 + +#define CMD_PASS 0 +#define CMD_FAIL 1 +#define CMD_ABORT 2 +#define CMD_NOT_DONE 3 + +#endif /* _FFSDEFS_ */ diff --git a/drivers/block/spectra/ffsport.c b/drivers/block/spectra/ffsport.c new file mode 100644 index 000000000000..0b3d49d2f8a5 --- /dev/null +++ b/drivers/block/spectra/ffsport.c @@ -0,0 +1,847 @@ +/* + * NAND Flash Controller Device Driver + * Copyright (c) 2009, Intel Corporation and its suppliers. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "ffsport.h" +#include "flash.h" +#include +#include +#include +#include +#include +#include +#include +#include + +/**** Helper functions used for Div, Remainder operation on u64 ****/ + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: GLOB_Calc_Used_Bits +* Inputs: Power of 2 number +* Outputs: Number of Used Bits +* 0, if the argument is 0 +* Description: Calculate the number of bits used by a given power of 2 number +* Number can be upto 32 bit +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int GLOB_Calc_Used_Bits(u32 n) +{ + int tot_bits = 0; + + if (n >= 1 << 16) { + n >>= 16; + tot_bits += 16; + } + + if (n >= 1 << 8) { + n >>= 8; + tot_bits += 8; + } + + if (n >= 1 << 4) { + n >>= 4; + tot_bits += 4; + } + + if (n >= 1 << 2) { + n >>= 2; + tot_bits += 2; + } + + if (n >= 1 << 1) + tot_bits += 1; + + return ((n == 0) ? (0) : tot_bits); +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: GLOB_u64_Div +* Inputs: Number of u64 +* A power of 2 number as Division +* Outputs: Quotient of the Divisor operation +* Description: It divides the address by divisor by using bit shift operation +* (essentially without explicitely using "/"). +* Divisor is a power of 2 number and Divided is of u64 +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u64 GLOB_u64_Div(u64 addr, u32 divisor) +{ + return (u64)(addr >> GLOB_Calc_Used_Bits(divisor)); +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: GLOB_u64_Remainder +* Inputs: Number of u64 +* Divisor Type (1 -PageAddress, 2- BlockAddress) +* Outputs: Remainder of the Division operation +* Description: It calculates the remainder of a number (of u64) by +* divisor(power of 2 number ) by using bit shifting and multiply +* operation(essentially without explicitely using "/"). +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u64 GLOB_u64_Remainder(u64 addr, u32 divisor_type) +{ + u64 result = 0; + + if (divisor_type == 1) { /* Remainder -- Page */ + result = (addr >> DeviceInfo.nBitsInPageDataSize); + result = result * DeviceInfo.wPageDataSize; + } else if (divisor_type == 2) { /* Remainder -- Block */ + result = (addr >> DeviceInfo.nBitsInBlockDataSize); + result = result * DeviceInfo.wBlockDataSize; + } + + result = addr - result; + + return result; +} + +#define NUM_DEVICES 1 +#define PARTITIONS 8 + +#define GLOB_SBD_NAME "nd" +#define GLOB_SBD_IRQ_NUM (29) +#define GLOB_VERSION "driver version 20091110" + +#define GLOB_SBD_IOCTL_GC (0x7701) +#define GLOB_SBD_IOCTL_WL (0x7702) +#define GLOB_SBD_IOCTL_FORMAT (0x7703) +#define GLOB_SBD_IOCTL_ERASE_FLASH (0x7704) +#define GLOB_SBD_IOCTL_FLUSH_CACHE (0x7705) +#define GLOB_SBD_IOCTL_COPY_BLK_TABLE (0x7706) +#define GLOB_SBD_IOCTL_COPY_WEAR_LEVELING_TABLE (0x7707) +#define GLOB_SBD_IOCTL_GET_NAND_INFO (0x7708) +#define GLOB_SBD_IOCTL_WRITE_DATA (0x7709) +#define GLOB_SBD_IOCTL_READ_DATA (0x770A) + +static u32 reserved_mb_for_os_image = 0; + +int nand_debug_level; +module_param(nand_debug_level, int, 0644); +MODULE_PARM_DESC(nand_debug_level, "debug level value: 1-3"); + +MODULE_LICENSE("GPL"); + +struct spectra_nand_dev { + struct pci_dev *dev; + u64 size; + u16 users; + spinlock_t qlock; + void __iomem *ioaddr; /* Mapped address */ + struct request_queue *queue; + struct task_struct *thread; + struct gendisk *gd; + u8 *tmp_buf; +}; + + +static int GLOB_SBD_majornum; + +static char *GLOB_version = GLOB_VERSION; + +static struct spectra_nand_dev nand_device[NUM_DEVICES]; + +static struct mutex spectra_lock; + +static int res_blks_os = 1; + +struct spectra_indentfy_dev_tag IdentifyDeviceData; + +static int force_flush_cache(void) +{ + nand_dbg_print(NAND_DBG_DEBUG, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (ERR == GLOB_FTL_Flush_Cache()) { + printk(KERN_ERR "Fail to Flush FTL Cache!\n"); + return -EFAULT; + } +#if CMD_DMA + if (glob_ftl_execute_cmds()) + return -EIO; + else + return 0; +#endif + return 0; +} + +struct ioctl_rw_page_info { + u8 *data; + unsigned int page; +}; + +static int ioctl_read_page_data(unsigned long arg) +{ + u8 *buf; + struct ioctl_rw_page_info info; + int result = PASS; + + if (copy_from_user(&info, (void __user *)arg, sizeof(info))) + return -EFAULT; + + buf = kmalloc(IdentifyDeviceData.PageDataSize, GFP_ATOMIC); + if (!buf) { + printk(KERN_ERR "ioctl_read_page_data: " + "failed to allocate memory\n"); + return -ENOMEM; + } + + mutex_lock(&spectra_lock); + result = GLOB_FTL_Page_Read(buf, + (u64)info.page * IdentifyDeviceData.PageDataSize); + mutex_unlock(&spectra_lock); + + if (copy_to_user((void __user *)info.data, buf, + IdentifyDeviceData.PageDataSize)) { + printk(KERN_ERR "ioctl_read_page_data: " + "failed to copy user data\n"); + kfree(buf); + return -EFAULT; + } + + kfree(buf); + return result; +} + +static int ioctl_write_page_data(unsigned long arg) +{ + u8 *buf; + struct ioctl_rw_page_info info; + int result = PASS; + + if (copy_from_user(&info, (void __user *)arg, sizeof(info))) + return -EFAULT; + + buf = kmalloc(IdentifyDeviceData.PageDataSize, GFP_ATOMIC); + if (!buf) { + printk(KERN_ERR "ioctl_write_page_data: " + "failed to allocate memory\n"); + return -ENOMEM; + } + + if (copy_from_user(buf, (void __user *)info.data, + IdentifyDeviceData.PageDataSize)) { + printk(KERN_ERR "ioctl_write_page_data: " + "failed to copy user data\n"); + kfree(buf); + return -EFAULT; + } + + mutex_lock(&spectra_lock); + result = GLOB_FTL_Page_Write(buf, + (u64)info.page * IdentifyDeviceData.PageDataSize); + mutex_unlock(&spectra_lock); + + kfree(buf); + return result; +} + +/* Return how many blocks should be reserved for bad block replacement */ +static int get_res_blk_num_bad_blk(void) +{ + return IdentifyDeviceData.wDataBlockNum / 10; +} + +/* Return how many blocks should be reserved for OS image */ +static int get_res_blk_num_os(void) +{ + u32 res_blks, blk_size; + + blk_size = IdentifyDeviceData.PageDataSize * + IdentifyDeviceData.PagesPerBlock; + + res_blks = (reserved_mb_for_os_image * 1024 * 1024) / blk_size; + + if ((res_blks < 1) || (res_blks >= IdentifyDeviceData.wDataBlockNum)) + res_blks = 1; /* Reserved 1 block for block table */ + + return res_blks; +} + +static void SBD_prepare_flush(struct request_queue *q, struct request *rq) +{ + rq->cmd_type = REQ_TYPE_LINUX_BLOCK; + /* rq->timeout = 5 * HZ; */ + rq->cmd[0] = REQ_LB_OP_FLUSH; +} + +/* Transfer a full request. */ +static int do_transfer(struct spectra_nand_dev *tr, struct request *req) +{ + u64 start_addr, addr; + u32 logical_start_sect, hd_start_sect; + u32 nsect, hd_sects; + u32 rsect, tsect = 0; + char *buf; + u32 ratio = IdentifyDeviceData.PageDataSize >> 9; + + start_addr = (u64)(blk_rq_pos(req)) << 9; + /* Add a big enough offset to prevent the OS Image from + * being accessed or damaged by file system */ + start_addr += IdentifyDeviceData.PageDataSize * + IdentifyDeviceData.PagesPerBlock * + res_blks_os; + + if (req->cmd_type == REQ_TYPE_LINUX_BLOCK && + req->cmd[0] == REQ_LB_OP_FLUSH) { + if (force_flush_cache()) /* Fail to flush cache */ + return -EIO; + else + return 0; + } + + if (!blk_fs_request(req)) + return -EIO; + + if (blk_rq_pos(req) + blk_rq_cur_sectors(req) > get_capacity(tr->gd)) { + printk(KERN_ERR "Spectra error: request over the NAND " + "capacity!sector %d, current_nr_sectors %d, " + "while capacity is %d\n", + (int)blk_rq_pos(req), + blk_rq_cur_sectors(req), + (int)get_capacity(tr->gd)); + return -EIO; + } + + logical_start_sect = start_addr >> 9; + hd_start_sect = logical_start_sect / ratio; + rsect = logical_start_sect - hd_start_sect * ratio; + + addr = (u64)hd_start_sect * ratio * 512; + buf = req->buffer; + nsect = blk_rq_cur_sectors(req); + + if (rsect) + tsect = (ratio - rsect) < nsect ? (ratio - rsect) : nsect; + + switch (rq_data_dir(req)) { + case READ: + /* Read the first NAND page */ + if (rsect) { + if (GLOB_FTL_Page_Read(tr->tmp_buf, addr)) { + printk(KERN_ERR "Error in %s, Line %d\n", + __FILE__, __LINE__); + return -EIO; + } + memcpy(buf, tr->tmp_buf + (rsect << 9), tsect << 9); + addr += IdentifyDeviceData.PageDataSize; + buf += tsect << 9; + nsect -= tsect; + } + + /* Read the other NAND pages */ + for (hd_sects = nsect / ratio; hd_sects > 0; hd_sects--) { + if (GLOB_FTL_Page_Read(buf, addr)) { + printk(KERN_ERR "Error in %s, Line %d\n", + __FILE__, __LINE__); + return -EIO; + } + addr += IdentifyDeviceData.PageDataSize; + buf += IdentifyDeviceData.PageDataSize; + } + + /* Read the last NAND pages */ + if (nsect % ratio) { + if (GLOB_FTL_Page_Read(tr->tmp_buf, addr)) { + printk(KERN_ERR "Error in %s, Line %d\n", + __FILE__, __LINE__); + return -EIO; + } + memcpy(buf, tr->tmp_buf, (nsect % ratio) << 9); + } +#if CMD_DMA + if (glob_ftl_execute_cmds()) + return -EIO; + else + return 0; +#endif + return 0; + + case WRITE: + /* Write the first NAND page */ + if (rsect) { + if (GLOB_FTL_Page_Read(tr->tmp_buf, addr)) { + printk(KERN_ERR "Error in %s, Line %d\n", + __FILE__, __LINE__); + return -EIO; + } + memcpy(tr->tmp_buf + (rsect << 9), buf, tsect << 9); + if (GLOB_FTL_Page_Write(tr->tmp_buf, addr)) { + printk(KERN_ERR "Error in %s, Line %d\n", + __FILE__, __LINE__); + return -EIO; + } + addr += IdentifyDeviceData.PageDataSize; + buf += tsect << 9; + nsect -= tsect; + } + + /* Write the other NAND pages */ + for (hd_sects = nsect / ratio; hd_sects > 0; hd_sects--) { + if (GLOB_FTL_Page_Write(buf, addr)) { + printk(KERN_ERR "Error in %s, Line %d\n", + __FILE__, __LINE__); + return -EIO; + } + addr += IdentifyDeviceData.PageDataSize; + buf += IdentifyDeviceData.PageDataSize; + } + + /* Write the last NAND pages */ + if (nsect % ratio) { + if (GLOB_FTL_Page_Read(tr->tmp_buf, addr)) { + printk(KERN_ERR "Error in %s, Line %d\n", + __FILE__, __LINE__); + return -EIO; + } + memcpy(tr->tmp_buf, buf, (nsect % ratio) << 9); + if (GLOB_FTL_Page_Write(tr->tmp_buf, addr)) { + printk(KERN_ERR "Error in %s, Line %d\n", + __FILE__, __LINE__); + return -EIO; + } + } +#if CMD_DMA + if (glob_ftl_execute_cmds()) + return -EIO; + else + return 0; +#endif + return 0; + + default: + printk(KERN_NOTICE "Unknown request %u\n", rq_data_dir(req)); + return -EIO; + } +} + +/* This function is copied from drivers/mtd/mtd_blkdevs.c */ +static int spectra_trans_thread(void *arg) +{ + struct spectra_nand_dev *tr = arg; + struct request_queue *rq = tr->queue; + struct request *req = NULL; + + /* we might get involved when memory gets low, so use PF_MEMALLOC */ + current->flags |= PF_MEMALLOC; + + spin_lock_irq(rq->queue_lock); + while (!kthread_should_stop()) { + int res; + + if (!req) { + req = blk_fetch_request(rq); + if (!req) { + set_current_state(TASK_INTERRUPTIBLE); + spin_unlock_irq(rq->queue_lock); + schedule(); + spin_lock_irq(rq->queue_lock); + continue; + } + } + + spin_unlock_irq(rq->queue_lock); + + mutex_lock(&spectra_lock); + res = do_transfer(tr, req); + mutex_unlock(&spectra_lock); + + spin_lock_irq(rq->queue_lock); + + if (!__blk_end_request_cur(req, res)) + req = NULL; + } + + if (req) + __blk_end_request_all(req, -EIO); + + spin_unlock_irq(rq->queue_lock); + + return 0; +} + + +/* Request function that "handles clustering". */ +static void GLOB_SBD_request(struct request_queue *rq) +{ + struct spectra_nand_dev *pdev = rq->queuedata; + wake_up_process(pdev->thread); +} + +static int GLOB_SBD_open(struct block_device *bdev, fmode_t mode) + +{ + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + return 0; +} + +static int GLOB_SBD_release(struct gendisk *disk, fmode_t mode) +{ + int ret; + + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + mutex_lock(&spectra_lock); + ret = force_flush_cache(); + mutex_unlock(&spectra_lock); + + return 0; +} + +static int GLOB_SBD_getgeo(struct block_device *bdev, struct hd_geometry *geo) +{ + geo->heads = 4; + geo->sectors = 16; + geo->cylinders = get_capacity(bdev->bd_disk) / (4 * 16); + + nand_dbg_print(NAND_DBG_DEBUG, + "heads: %d, sectors: %d, cylinders: %d\n", + geo->heads, geo->sectors, geo->cylinders); + + return 0; +} + +int GLOB_SBD_ioctl(struct block_device *bdev, fmode_t mode, + unsigned int cmd, unsigned long arg) +{ + int ret; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + switch (cmd) { + case GLOB_SBD_IOCTL_GC: + nand_dbg_print(NAND_DBG_DEBUG, + "Spectra IOCTL: Garbage Collection " + "being performed\n"); + if (PASS != GLOB_FTL_Garbage_Collection()) + return -EFAULT; + return 0; + + case GLOB_SBD_IOCTL_WL: + nand_dbg_print(NAND_DBG_DEBUG, + "Spectra IOCTL: Static Wear Leveling " + "being performed\n"); + if (PASS != GLOB_FTL_Wear_Leveling()) + return -EFAULT; + return 0; + + case GLOB_SBD_IOCTL_FORMAT: + nand_dbg_print(NAND_DBG_DEBUG, "Spectra IOCTL: Flash format " + "being performed\n"); + if (PASS != GLOB_FTL_Flash_Format()) + return -EFAULT; + return 0; + + case GLOB_SBD_IOCTL_FLUSH_CACHE: + nand_dbg_print(NAND_DBG_DEBUG, "Spectra IOCTL: Cache flush " + "being performed\n"); + mutex_lock(&spectra_lock); + ret = force_flush_cache(); + mutex_unlock(&spectra_lock); + return ret; + + case GLOB_SBD_IOCTL_COPY_BLK_TABLE: + nand_dbg_print(NAND_DBG_DEBUG, "Spectra IOCTL: " + "Copy block table\n"); + if (copy_to_user((void __user *)arg, + get_blk_table_start_addr(), + get_blk_table_len())) + return -EFAULT; + return 0; + + case GLOB_SBD_IOCTL_COPY_WEAR_LEVELING_TABLE: + nand_dbg_print(NAND_DBG_DEBUG, "Spectra IOCTL: " + "Copy wear leveling table\n"); + if (copy_to_user((void __user *)arg, + get_wear_leveling_table_start_addr(), + get_wear_leveling_table_len())) + return -EFAULT; + return 0; + + case GLOB_SBD_IOCTL_GET_NAND_INFO: + nand_dbg_print(NAND_DBG_DEBUG, "Spectra IOCTL: " + "Get NAND info\n"); + if (copy_to_user((void __user *)arg, &IdentifyDeviceData, + sizeof(IdentifyDeviceData))) + return -EFAULT; + return 0; + + case GLOB_SBD_IOCTL_WRITE_DATA: + nand_dbg_print(NAND_DBG_DEBUG, "Spectra IOCTL: " + "Write one page data\n"); + return ioctl_write_page_data(arg); + + case GLOB_SBD_IOCTL_READ_DATA: + nand_dbg_print(NAND_DBG_DEBUG, "Spectra IOCTL: " + "Read one page data\n"); + return ioctl_read_page_data(arg); + } + + return -ENOTTY; +} + +static struct block_device_operations GLOB_SBD_ops = { + .owner = THIS_MODULE, + .open = GLOB_SBD_open, + .release = GLOB_SBD_release, + .locked_ioctl = GLOB_SBD_ioctl, + .getgeo = GLOB_SBD_getgeo, +}; + +static int SBD_setup_device(struct spectra_nand_dev *dev, int which) +{ + int res_blks; + u32 sects; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + memset(dev, 0, sizeof(struct spectra_nand_dev)); + + nand_dbg_print(NAND_DBG_WARN, "Reserved %d blocks " + "for OS image, %d blocks for bad block replacement.\n", + get_res_blk_num_os(), + get_res_blk_num_bad_blk()); + + res_blks = get_res_blk_num_bad_blk() + get_res_blk_num_os(); + + dev->size = (u64)IdentifyDeviceData.PageDataSize * + IdentifyDeviceData.PagesPerBlock * + (IdentifyDeviceData.wDataBlockNum - res_blks); + + res_blks_os = get_res_blk_num_os(); + + spin_lock_init(&dev->qlock); + + dev->tmp_buf = kmalloc(IdentifyDeviceData.PageDataSize, GFP_ATOMIC); + if (!dev->tmp_buf) { + printk(KERN_ERR "Failed to kmalloc memory in %s Line %d, exit.\n", + __FILE__, __LINE__); + goto out_vfree; + } + + dev->queue = blk_init_queue(GLOB_SBD_request, &dev->qlock); + if (dev->queue == NULL) { + printk(KERN_ERR + "Spectra: Request queue could not be initialized." + " Aborting\n "); + goto out_vfree; + } + dev->queue->queuedata = dev; + + /* As Linux block layer doens't support >4KB hardware sector, */ + /* Here we force report 512 byte hardware sector size to Kernel */ + blk_queue_logical_block_size(dev->queue, 512); + + blk_queue_ordered(dev->queue, QUEUE_ORDERED_DRAIN_FLUSH, + SBD_prepare_flush); + + dev->thread = kthread_run(spectra_trans_thread, dev, "nand_thd"); + if (IS_ERR(dev->thread)) { + blk_cleanup_queue(dev->queue); + unregister_blkdev(GLOB_SBD_majornum, GLOB_SBD_NAME); + return PTR_ERR(dev->thread); + } + + dev->gd = alloc_disk(PARTITIONS); + if (!dev->gd) { + printk(KERN_ERR + "Spectra: Could not allocate disk. Aborting \n "); + goto out_vfree; + } + dev->gd->major = GLOB_SBD_majornum; + dev->gd->first_minor = which * PARTITIONS; + dev->gd->fops = &GLOB_SBD_ops; + dev->gd->queue = dev->queue; + dev->gd->private_data = dev; + snprintf(dev->gd->disk_name, 32, "%s%c", GLOB_SBD_NAME, which + 'a'); + + sects = dev->size >> 9; + nand_dbg_print(NAND_DBG_WARN, "Capacity sects: %d\n", sects); + set_capacity(dev->gd, sects); + + add_disk(dev->gd); + + return 0; +out_vfree: + return -ENOMEM; +} + +/* +static ssize_t show_nand_block_num(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%d\n", + (int)IdentifyDeviceData.wDataBlockNum); +} + +static ssize_t show_nand_pages_per_block(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%d\n", + (int)IdentifyDeviceData.PagesPerBlock); +} + +static ssize_t show_nand_page_size(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return snprintf(buf, PAGE_SIZE, "%d\n", + (int)IdentifyDeviceData.PageDataSize); +} + +static DEVICE_ATTR(nand_block_num, 0444, show_nand_block_num, NULL); +static DEVICE_ATTR(nand_pages_per_block, 0444, show_nand_pages_per_block, NULL); +static DEVICE_ATTR(nand_page_size, 0444, show_nand_page_size, NULL); + +static void create_sysfs_entry(struct device *dev) +{ + if (device_create_file(dev, &dev_attr_nand_block_num)) + printk(KERN_ERR "Spectra: " + "failed to create sysfs entry nand_block_num.\n"); + if (device_create_file(dev, &dev_attr_nand_pages_per_block)) + printk(KERN_ERR "Spectra: " + "failed to create sysfs entry nand_pages_per_block.\n"); + if (device_create_file(dev, &dev_attr_nand_page_size)) + printk(KERN_ERR "Spectra: " + "failed to create sysfs entry nand_page_size.\n"); +} +*/ + +static int GLOB_SBD_init(void) +{ + int i; + + /* Set debug output level (0~3) here. 3 is most verbose */ + nand_debug_level = 0; + + printk(KERN_ALERT "Spectra: %s\n", GLOB_version); + + mutex_init(&spectra_lock); + + GLOB_SBD_majornum = register_blkdev(0, GLOB_SBD_NAME); + if (GLOB_SBD_majornum <= 0) { + printk(KERN_ERR "Unable to get the major %d for Spectra", + GLOB_SBD_majornum); + return -EBUSY; + } + + if (PASS != GLOB_FTL_Flash_Init()) { + printk(KERN_ERR "Spectra: Unable to Initialize Flash Device. " + "Aborting\n"); + goto out_flash_register; + } + + /* create_sysfs_entry(&dev->dev); */ + + if (PASS != GLOB_FTL_IdentifyDevice(&IdentifyDeviceData)) { + printk(KERN_ERR "Spectra: Unable to Read Flash Device. " + "Aborting\n"); + goto out_flash_register; + } else { + nand_dbg_print(NAND_DBG_WARN, "In GLOB_SBD_init: " + "Num blocks=%d, pagesperblock=%d, " + "pagedatasize=%d, ECCBytesPerSector=%d\n", + (int)IdentifyDeviceData.NumBlocks, + (int)IdentifyDeviceData.PagesPerBlock, + (int)IdentifyDeviceData.PageDataSize, + (int)IdentifyDeviceData.wECCBytesPerSector); + } + + printk(KERN_ALERT "Spectra: searching block table, please wait ...\n"); + if (GLOB_FTL_Init() != PASS) { + printk(KERN_ERR "Spectra: Unable to Initialize FTL Layer. " + "Aborting\n"); + goto out_ftl_flash_register; + } + printk(KERN_ALERT "Spectra: block table has been found.\n"); + + for (i = 0; i < NUM_DEVICES; i++) + if (SBD_setup_device(&nand_device[i], i) == -ENOMEM) + goto out_ftl_flash_register; + + nand_dbg_print(NAND_DBG_DEBUG, + "Spectra: module loaded with major number %d\n", + GLOB_SBD_majornum); + + return 0; + +out_ftl_flash_register: + GLOB_FTL_Cache_Release(); +out_flash_register: + GLOB_FTL_Flash_Release(); + unregister_blkdev(GLOB_SBD_majornum, GLOB_SBD_NAME); + printk(KERN_ERR "Spectra: Module load failed.\n"); + + return -ENOMEM; +} + +static void __exit GLOB_SBD_exit(void) +{ + int i; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + for (i = 0; i < NUM_DEVICES; i++) { + struct spectra_nand_dev *dev = &nand_device[i]; + if (dev->gd) { + del_gendisk(dev->gd); + put_disk(dev->gd); + } + if (dev->queue) + blk_cleanup_queue(dev->queue); + kfree(dev->tmp_buf); + } + + unregister_blkdev(GLOB_SBD_majornum, GLOB_SBD_NAME); + + mutex_lock(&spectra_lock); + force_flush_cache(); + mutex_unlock(&spectra_lock); + + GLOB_FTL_Cache_Release(); + + GLOB_FTL_Flash_Release(); + + nand_dbg_print(NAND_DBG_DEBUG, + "Spectra FTL module (major number %d) unloaded.\n", + GLOB_SBD_majornum); +} + +static int __init setup_reserve_space_for_os_image(char *cmdline) +{ + unsigned long value; + int error; + + printk(KERN_ALERT "Spectra - cmdline: %s\n", cmdline); + if (!cmdline) + return -EINVAL; + + error = strict_strtoul((const char *)cmdline, 10, &value); + if (error) + return -EINVAL; + + reserved_mb_for_os_image = value; + + return 0; +} + +early_param("res_nand", setup_reserve_space_for_os_image); + +module_init(GLOB_SBD_init); +module_exit(GLOB_SBD_exit); diff --git a/drivers/block/spectra/ffsport.h b/drivers/block/spectra/ffsport.h new file mode 100644 index 000000000000..6c5d90c53430 --- /dev/null +++ b/drivers/block/spectra/ffsport.h @@ -0,0 +1,84 @@ +/* + * NAND Flash Controller Device Driver + * Copyright (c) 2009, Intel Corporation and its suppliers. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef _FFSPORT_ +#define _FFSPORT_ + +#include "ffsdefs.h" + +#if defined __GNUC__ +#define PACKED +#define PACKED_GNU __attribute__ ((packed)) +#define UNALIGNED +#endif + +#include +#include /* for strcpy(), stricmp(), etc */ +#include /* for kmalloc(), kfree() */ +#include +#include +#include +#include + +#include /* printk() */ +#include /* everything... */ +#include /* error codes */ +#include /* size_t */ +#include +#include +#include +#include +#include "flash.h" + +#define VERBOSE 1 + +#define NAND_DBG_WARN 1 +#define NAND_DBG_DEBUG 2 +#define NAND_DBG_TRACE 3 + +extern int nand_debug_level; + +#ifdef VERBOSE +#define nand_dbg_print(level, args...) \ + do { \ + if (level <= nand_debug_level) \ + printk(KERN_ALERT args); \ + } while (0) +#else +#define nand_dbg_print(level, args...) +#endif + +#ifdef SUPPORT_BIG_ENDIAN +#define INVERTUINT16(w) ((u16)(((u16)(w)) << 8) | \ + (u16)((u16)(w) >> 8)) + +#define INVERTUINT32(dw) (((u32)(dw) << 24) | \ + (((u32)(dw) << 8) & 0x00ff0000) | \ + (((u32)(dw) >> 8) & 0x0000ff00) | \ + ((u32)(dw) >> 24)) +#else +#define INVERTUINT16(w) w +#define INVERTUINT32(dw) dw +#endif + +extern int GLOB_Calc_Used_Bits(u32 n); +extern u64 GLOB_u64_Div(u64 addr, u32 divisor); +extern u64 GLOB_u64_Remainder(u64 addr, u32 divisor_type); + +#endif /* _FFSPORT_ */ diff --git a/drivers/block/spectra/flash.c b/drivers/block/spectra/flash.c new file mode 100644 index 000000000000..134aa5166a8d --- /dev/null +++ b/drivers/block/spectra/flash.c @@ -0,0 +1,4731 @@ +/* + * NAND Flash Controller Device Driver + * Copyright (c) 2009, Intel Corporation and its suppliers. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include +#include + +#include "flash.h" +#include "ffsdefs.h" +#include "lld.h" +#include "lld_nand.h" +#if CMD_DMA +#include "lld_cdma.h" +#endif + +#define BLK_FROM_ADDR(addr) ((u32)(addr >> DeviceInfo.nBitsInBlockDataSize)) +#define PAGE_FROM_ADDR(addr, Block) ((u16)((addr - (u64)Block * \ + DeviceInfo.wBlockDataSize) >> DeviceInfo.nBitsInPageDataSize)) + +#define IS_SPARE_BLOCK(blk) (BAD_BLOCK != (pbt[blk] &\ + BAD_BLOCK) && SPARE_BLOCK == (pbt[blk] & SPARE_BLOCK)) + +#define IS_DATA_BLOCK(blk) (0 == (pbt[blk] & BAD_BLOCK)) + +#define IS_DISCARDED_BLOCK(blk) (BAD_BLOCK != (pbt[blk] &\ + BAD_BLOCK) && DISCARD_BLOCK == (pbt[blk] & DISCARD_BLOCK)) + +#define IS_BAD_BLOCK(blk) (BAD_BLOCK == (pbt[blk] & BAD_BLOCK)) + +#if DEBUG_BNDRY +void debug_boundary_lineno_error(int chnl, int limit, int no, + int lineno, char *filename) +{ + if (chnl >= limit) + printk(KERN_ERR "Boundary Check Fail value %d >= limit %d, " + "at %s:%d. Other info:%d. Aborting...\n", + chnl, limit, filename, lineno, no); +} +/* static int globalmemsize; */ +#endif + +static u16 FTL_Cache_If_Hit(u64 dwPageAddr); +static int FTL_Cache_Read(u64 dwPageAddr); +static void FTL_Cache_Read_Page(u8 *pData, u64 dwPageAddr, + u16 cache_blk); +static void FTL_Cache_Write_Page(u8 *pData, u64 dwPageAddr, + u8 cache_blk, u16 flag); +static int FTL_Cache_Write(void); +static int FTL_Cache_Write_Back(u8 *pData, u64 blk_addr); +static void FTL_Calculate_LRU(void); +static u32 FTL_Get_Block_Index(u32 wBlockNum); + +static int FTL_Search_Block_Table_IN_Block(u32 BT_Block, + u8 BT_Tag, u16 *Page); +static int FTL_Read_Block_Table(void); +static int FTL_Write_Block_Table(int wForce); +static int FTL_Write_Block_Table_Data(void); +static int FTL_Check_Block_Table(int wOldTable); +static int FTL_Static_Wear_Leveling(void); +static u32 FTL_Replace_Block_Table(void); +static int FTL_Write_IN_Progress_Block_Table_Page(void); + +static u32 FTL_Get_Page_Num(u64 length); +static u64 FTL_Get_Physical_Block_Addr(u64 blk_addr); + +static u32 FTL_Replace_OneBlock(u32 wBlockNum, + u32 wReplaceNum); +static u32 FTL_Replace_LWBlock(u32 wBlockNum, + int *pGarbageCollect); +static u32 FTL_Replace_MWBlock(void); +static int FTL_Replace_Block(u64 blk_addr); +static int FTL_Adjust_Relative_Erase_Count(u32 Index_of_MAX); + +static int FTL_Flash_Error_Handle(u8 *pData, u64 old_page_addr, u64 blk_addr); + +struct device_info_tag DeviceInfo; +struct flash_cache_tag Cache; +static struct spectra_l2_cache_info cache_l2; + +static u8 *cache_l2_page_buf; +static u8 *cache_l2_blk_buf; + +u8 *g_pBlockTable; +u8 *g_pWearCounter; +u16 *g_pReadCounter; +u32 *g_pBTBlocks; +static u16 g_wBlockTableOffset; +static u32 g_wBlockTableIndex; +static u8 g_cBlockTableStatus; + +static u8 *g_pTempBuf; +static u8 *flag_check_blk_table; +static u8 *tmp_buf_search_bt_in_block; +static u8 *spare_buf_search_bt_in_block; +static u8 *spare_buf_bt_search_bt_in_block; +static u8 *tmp_buf1_read_blk_table; +static u8 *tmp_buf2_read_blk_table; +static u8 *flags_static_wear_leveling; +static u8 *tmp_buf_write_blk_table_data; +static u8 *tmp_buf_read_disturbance; + +u8 *buf_read_page_main_spare; +u8 *buf_write_page_main_spare; +u8 *buf_read_page_spare; +u8 *buf_get_bad_block; + +#if (RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE && CMD_DMA) +struct flash_cache_delta_list_tag int_cache[MAX_CHANS + MAX_DESCS]; +struct flash_cache_tag cache_start_copy; +#endif + +int g_wNumFreeBlocks; +u8 g_SBDCmdIndex; + +static u8 *g_pIPF; +static u8 bt_flag = FIRST_BT_ID; +static u8 bt_block_changed; + +static u16 cache_block_to_write; +static u8 last_erased = FIRST_BT_ID; + +static u8 GC_Called; +static u8 BT_GC_Called; + +#if CMD_DMA +#define COPY_BACK_BUF_NUM 10 + +static u8 ftl_cmd_cnt; /* Init value is 0 */ +u8 *g_pBTDelta; +u8 *g_pBTDelta_Free; +u8 *g_pBTStartingCopy; +u8 *g_pWearCounterCopy; +u16 *g_pReadCounterCopy; +u8 *g_pBlockTableCopies; +u8 *g_pNextBlockTable; +static u8 *cp_back_buf_copies[COPY_BACK_BUF_NUM]; +static int cp_back_buf_idx; + +static u8 *g_temp_buf; + +#pragma pack(push, 1) +#pragma pack(1) +struct BTableChangesDelta { + u8 ftl_cmd_cnt; + u8 ValidFields; + u16 g_wBlockTableOffset; + u32 g_wBlockTableIndex; + u32 BT_Index; + u32 BT_Entry_Value; + u32 WC_Index; + u8 WC_Entry_Value; + u32 RC_Index; + u16 RC_Entry_Value; +}; + +#pragma pack(pop) + +struct BTableChangesDelta *p_BTableChangesDelta; +#endif + + +#define MARK_BLOCK_AS_BAD(blocknode) (blocknode |= BAD_BLOCK) +#define MARK_BLK_AS_DISCARD(blk) (blk = (blk & ~SPARE_BLOCK) | DISCARD_BLOCK) + +#define FTL_Get_LBAPBA_Table_Mem_Size_Bytes() (DeviceInfo.wDataBlockNum *\ + sizeof(u32)) +#define FTL_Get_WearCounter_Table_Mem_Size_Bytes() (DeviceInfo.wDataBlockNum *\ + sizeof(u8)) +#define FTL_Get_ReadCounter_Table_Mem_Size_Bytes() (DeviceInfo.wDataBlockNum *\ + sizeof(u16)) +#if SUPPORT_LARGE_BLOCKNUM +#define FTL_Get_LBAPBA_Table_Flash_Size_Bytes() (DeviceInfo.wDataBlockNum *\ + sizeof(u8) * 3) +#else +#define FTL_Get_LBAPBA_Table_Flash_Size_Bytes() (DeviceInfo.wDataBlockNum *\ + sizeof(u16)) +#endif +#define FTL_Get_WearCounter_Table_Flash_Size_Bytes \ + FTL_Get_WearCounter_Table_Mem_Size_Bytes +#define FTL_Get_ReadCounter_Table_Flash_Size_Bytes \ + FTL_Get_ReadCounter_Table_Mem_Size_Bytes + +static u32 FTL_Get_Block_Table_Flash_Size_Bytes(void) +{ + u32 byte_num; + + if (DeviceInfo.MLCDevice) { + byte_num = FTL_Get_LBAPBA_Table_Flash_Size_Bytes() + + DeviceInfo.wDataBlockNum * sizeof(u8) + + DeviceInfo.wDataBlockNum * sizeof(u16); + } else { + byte_num = FTL_Get_LBAPBA_Table_Flash_Size_Bytes() + + DeviceInfo.wDataBlockNum * sizeof(u8); + } + + byte_num += 4 * sizeof(u8); + + return byte_num; +} + +static u16 FTL_Get_Block_Table_Flash_Size_Pages(void) +{ + return (u16)FTL_Get_Page_Num(FTL_Get_Block_Table_Flash_Size_Bytes()); +} + +static int FTL_Copy_Block_Table_To_Flash(u8 *flashBuf, u32 sizeToTx, + u32 sizeTxed) +{ + u32 wBytesCopied, blk_tbl_size, wBytes; + u32 *pbt = (u32 *)g_pBlockTable; + + blk_tbl_size = FTL_Get_LBAPBA_Table_Flash_Size_Bytes(); + for (wBytes = 0; + (wBytes < sizeToTx) && ((wBytes + sizeTxed) < blk_tbl_size); + wBytes++) { +#if SUPPORT_LARGE_BLOCKNUM + flashBuf[wBytes] = (u8)(pbt[(wBytes + sizeTxed) / 3] + >> (((wBytes + sizeTxed) % 3) ? + ((((wBytes + sizeTxed) % 3) == 2) ? 0 : 8) : 16)) & 0xFF; +#else + flashBuf[wBytes] = (u8)(pbt[(wBytes + sizeTxed) / 2] + >> (((wBytes + sizeTxed) % 2) ? 0 : 8)) & 0xFF; +#endif + } + + sizeTxed = (sizeTxed > blk_tbl_size) ? (sizeTxed - blk_tbl_size) : 0; + blk_tbl_size = FTL_Get_WearCounter_Table_Flash_Size_Bytes(); + wBytesCopied = wBytes; + wBytes = ((blk_tbl_size - sizeTxed) > (sizeToTx - wBytesCopied)) ? + (sizeToTx - wBytesCopied) : (blk_tbl_size - sizeTxed); + memcpy(flashBuf + wBytesCopied, g_pWearCounter + sizeTxed, wBytes); + + sizeTxed = (sizeTxed > blk_tbl_size) ? (sizeTxed - blk_tbl_size) : 0; + + if (DeviceInfo.MLCDevice) { + blk_tbl_size = FTL_Get_ReadCounter_Table_Flash_Size_Bytes(); + wBytesCopied += wBytes; + for (wBytes = 0; ((wBytes + wBytesCopied) < sizeToTx) && + ((wBytes + sizeTxed) < blk_tbl_size); wBytes++) + flashBuf[wBytes + wBytesCopied] = + (g_pReadCounter[(wBytes + sizeTxed) / 2] >> + (((wBytes + sizeTxed) % 2) ? 0 : 8)) & 0xFF; + } + + return wBytesCopied + wBytes; +} + +static int FTL_Copy_Block_Table_From_Flash(u8 *flashBuf, + u32 sizeToTx, u32 sizeTxed) +{ + u32 wBytesCopied, blk_tbl_size, wBytes; + u32 *pbt = (u32 *)g_pBlockTable; + + blk_tbl_size = FTL_Get_LBAPBA_Table_Flash_Size_Bytes(); + for (wBytes = 0; (wBytes < sizeToTx) && + ((wBytes + sizeTxed) < blk_tbl_size); wBytes++) { +#if SUPPORT_LARGE_BLOCKNUM + if (!((wBytes + sizeTxed) % 3)) + pbt[(wBytes + sizeTxed) / 3] = 0; + pbt[(wBytes + sizeTxed) / 3] |= + (flashBuf[wBytes] << (((wBytes + sizeTxed) % 3) ? + ((((wBytes + sizeTxed) % 3) == 2) ? 0 : 8) : 16)); +#else + if (!((wBytes + sizeTxed) % 2)) + pbt[(wBytes + sizeTxed) / 2] = 0; + pbt[(wBytes + sizeTxed) / 2] |= + (flashBuf[wBytes] << (((wBytes + sizeTxed) % 2) ? + 0 : 8)); +#endif + } + + sizeTxed = (sizeTxed > blk_tbl_size) ? (sizeTxed - blk_tbl_size) : 0; + blk_tbl_size = FTL_Get_WearCounter_Table_Flash_Size_Bytes(); + wBytesCopied = wBytes; + wBytes = ((blk_tbl_size - sizeTxed) > (sizeToTx - wBytesCopied)) ? + (sizeToTx - wBytesCopied) : (blk_tbl_size - sizeTxed); + memcpy(g_pWearCounter + sizeTxed, flashBuf + wBytesCopied, wBytes); + sizeTxed = (sizeTxed > blk_tbl_size) ? (sizeTxed - blk_tbl_size) : 0; + + if (DeviceInfo.MLCDevice) { + wBytesCopied += wBytes; + blk_tbl_size = FTL_Get_ReadCounter_Table_Flash_Size_Bytes(); + for (wBytes = 0; ((wBytes + wBytesCopied) < sizeToTx) && + ((wBytes + sizeTxed) < blk_tbl_size); wBytes++) { + if (((wBytes + sizeTxed) % 2)) + g_pReadCounter[(wBytes + sizeTxed) / 2] = 0; + g_pReadCounter[(wBytes + sizeTxed) / 2] |= + (flashBuf[wBytes] << + (((wBytes + sizeTxed) % 2) ? 0 : 8)); + } + } + + return wBytesCopied+wBytes; +} + +static int FTL_Insert_Block_Table_Signature(u8 *buf, u8 tag) +{ + int i; + + for (i = 0; i < BTSIG_BYTES; i++) + buf[BTSIG_OFFSET + i] = + ((tag + (i * BTSIG_DELTA) - FIRST_BT_ID) % + (1 + LAST_BT_ID-FIRST_BT_ID)) + FIRST_BT_ID; + + return PASS; +} + +static int FTL_Extract_Block_Table_Tag(u8 *buf, u8 **tagarray) +{ + static u8 tag[BTSIG_BYTES >> 1]; + int i, j, k, tagi, tagtemp, status; + + *tagarray = (u8 *)tag; + tagi = 0; + + for (i = 0; i < (BTSIG_BYTES - 1); i++) { + for (j = i + 1; (j < BTSIG_BYTES) && + (tagi < (BTSIG_BYTES >> 1)); j++) { + tagtemp = buf[BTSIG_OFFSET + j] - + buf[BTSIG_OFFSET + i]; + if (tagtemp && !(tagtemp % BTSIG_DELTA)) { + tagtemp = (buf[BTSIG_OFFSET + i] + + (1 + LAST_BT_ID - FIRST_BT_ID) - + (i * BTSIG_DELTA)) % + (1 + LAST_BT_ID - FIRST_BT_ID); + status = FAIL; + for (k = 0; k < tagi; k++) { + if (tagtemp == tag[k]) + status = PASS; + } + + if (status == FAIL) { + tag[tagi++] = tagtemp; + i = (j == (i + 1)) ? i + 1 : i; + j = (j == (i + 1)) ? i + 1 : i; + } + } + } + } + + return tagi; +} + + +static int FTL_Execute_SPL_Recovery(void) +{ + u32 j, block, blks; + u32 *pbt = (u32 *)g_pBlockTable; + int ret; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + blks = DeviceInfo.wSpectraEndBlock - DeviceInfo.wSpectraStartBlock; + for (j = 0; j <= blks; j++) { + block = (pbt[j]); + if (((block & BAD_BLOCK) != BAD_BLOCK) && + ((block & SPARE_BLOCK) == SPARE_BLOCK)) { + ret = GLOB_LLD_Erase_Block(block & ~BAD_BLOCK); + if (FAIL == ret) { + nand_dbg_print(NAND_DBG_WARN, + "NAND Program fail in %s, Line %d, " + "Function: %s, new Bad Block %d " + "generated!\n", + __FILE__, __LINE__, __func__, + (int)(block & ~BAD_BLOCK)); + MARK_BLOCK_AS_BAD(pbt[j]); + } + } + } + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: GLOB_FTL_IdentifyDevice +* Inputs: pointer to identify data structure +* Outputs: PASS / FAIL +* Description: the identify data structure is filled in with +* information for the block driver. +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int GLOB_FTL_IdentifyDevice(struct spectra_indentfy_dev_tag *dev_data) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + dev_data->NumBlocks = DeviceInfo.wTotalBlocks; + dev_data->PagesPerBlock = DeviceInfo.wPagesPerBlock; + dev_data->PageDataSize = DeviceInfo.wPageDataSize; + dev_data->wECCBytesPerSector = DeviceInfo.wECCBytesPerSector; + dev_data->wDataBlockNum = DeviceInfo.wDataBlockNum; + + return PASS; +} + +/* ..... */ +static int allocate_memory(void) +{ + u32 block_table_size, page_size, block_size, mem_size; + u32 total_bytes = 0; + int i; +#if CMD_DMA + int j; +#endif + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + page_size = DeviceInfo.wPageSize; + block_size = DeviceInfo.wPagesPerBlock * DeviceInfo.wPageDataSize; + + block_table_size = DeviceInfo.wDataBlockNum * + (sizeof(u32) + sizeof(u8) + sizeof(u16)); + block_table_size += (DeviceInfo.wPageDataSize - + (block_table_size % DeviceInfo.wPageDataSize)) % + DeviceInfo.wPageDataSize; + + /* Malloc memory for block tables */ + g_pBlockTable = kmalloc(block_table_size, GFP_ATOMIC); + if (!g_pBlockTable) + goto block_table_fail; + memset(g_pBlockTable, 0, block_table_size); + total_bytes += block_table_size; + + g_pWearCounter = (u8 *)(g_pBlockTable + + DeviceInfo.wDataBlockNum * sizeof(u32)); + + if (DeviceInfo.MLCDevice) + g_pReadCounter = (u16 *)(g_pBlockTable + + DeviceInfo.wDataBlockNum * + (sizeof(u32) + sizeof(u8))); + + /* Malloc memory and init for cache items */ + for (i = 0; i < CACHE_ITEM_NUM; i++) { + Cache.array[i].address = NAND_CACHE_INIT_ADDR; + Cache.array[i].use_cnt = 0; + Cache.array[i].changed = CLEAR; + Cache.array[i].buf = kmalloc(Cache.cache_item_size, + GFP_ATOMIC); + if (!Cache.array[i].buf) + goto cache_item_fail; + memset(Cache.array[i].buf, 0, Cache.cache_item_size); + total_bytes += Cache.cache_item_size; + } + + /* Malloc memory for IPF */ + g_pIPF = kmalloc(page_size, GFP_ATOMIC); + if (!g_pIPF) + goto ipf_fail; + memset(g_pIPF, 0, page_size); + total_bytes += page_size; + + /* Malloc memory for data merging during Level2 Cache flush */ + cache_l2_page_buf = kmalloc(page_size, GFP_ATOMIC); + if (!cache_l2_page_buf) + goto cache_l2_page_buf_fail; + memset(cache_l2_page_buf, 0xff, page_size); + total_bytes += page_size; + + cache_l2_blk_buf = kmalloc(block_size, GFP_ATOMIC); + if (!cache_l2_blk_buf) + goto cache_l2_blk_buf_fail; + memset(cache_l2_blk_buf, 0xff, block_size); + total_bytes += block_size; + + /* Malloc memory for temp buffer */ + g_pTempBuf = kmalloc(Cache.cache_item_size, GFP_ATOMIC); + if (!g_pTempBuf) + goto Temp_buf_fail; + memset(g_pTempBuf, 0, Cache.cache_item_size); + total_bytes += Cache.cache_item_size; + + /* Malloc memory for block table blocks */ + mem_size = (1 + LAST_BT_ID - FIRST_BT_ID) * sizeof(u32); + g_pBTBlocks = kmalloc(mem_size, GFP_ATOMIC); + if (!g_pBTBlocks) + goto bt_blocks_fail; + memset(g_pBTBlocks, 0xff, mem_size); + total_bytes += mem_size; + + /* Malloc memory for function FTL_Check_Block_Table */ + flag_check_blk_table = kmalloc(DeviceInfo.wDataBlockNum, GFP_ATOMIC); + if (!flag_check_blk_table) + goto flag_check_blk_table_fail; + total_bytes += DeviceInfo.wDataBlockNum; + + /* Malloc memory for function FTL_Search_Block_Table_IN_Block */ + tmp_buf_search_bt_in_block = kmalloc(page_size, GFP_ATOMIC); + if (!tmp_buf_search_bt_in_block) + goto tmp_buf_search_bt_in_block_fail; + memset(tmp_buf_search_bt_in_block, 0xff, page_size); + total_bytes += page_size; + + mem_size = DeviceInfo.wPageSize - DeviceInfo.wPageDataSize; + spare_buf_search_bt_in_block = kmalloc(mem_size, GFP_ATOMIC); + if (!spare_buf_search_bt_in_block) + goto spare_buf_search_bt_in_block_fail; + memset(spare_buf_search_bt_in_block, 0xff, mem_size); + total_bytes += mem_size; + + spare_buf_bt_search_bt_in_block = kmalloc(mem_size, GFP_ATOMIC); + if (!spare_buf_bt_search_bt_in_block) + goto spare_buf_bt_search_bt_in_block_fail; + memset(spare_buf_bt_search_bt_in_block, 0xff, mem_size); + total_bytes += mem_size; + + /* Malloc memory for function FTL_Read_Block_Table */ + tmp_buf1_read_blk_table = kmalloc(page_size, GFP_ATOMIC); + if (!tmp_buf1_read_blk_table) + goto tmp_buf1_read_blk_table_fail; + memset(tmp_buf1_read_blk_table, 0xff, page_size); + total_bytes += page_size; + + tmp_buf2_read_blk_table = kmalloc(page_size, GFP_ATOMIC); + if (!tmp_buf2_read_blk_table) + goto tmp_buf2_read_blk_table_fail; + memset(tmp_buf2_read_blk_table, 0xff, page_size); + total_bytes += page_size; + + /* Malloc memory for function FTL_Static_Wear_Leveling */ + flags_static_wear_leveling = kmalloc(DeviceInfo.wDataBlockNum, + GFP_ATOMIC); + if (!flags_static_wear_leveling) + goto flags_static_wear_leveling_fail; + total_bytes += DeviceInfo.wDataBlockNum; + + /* Malloc memory for function FTL_Write_Block_Table_Data */ + if (FTL_Get_Block_Table_Flash_Size_Pages() > 3) + mem_size = FTL_Get_Block_Table_Flash_Size_Bytes() - + 2 * DeviceInfo.wPageSize; + else + mem_size = DeviceInfo.wPageSize; + tmp_buf_write_blk_table_data = kmalloc(mem_size, GFP_ATOMIC); + if (!tmp_buf_write_blk_table_data) + goto tmp_buf_write_blk_table_data_fail; + memset(tmp_buf_write_blk_table_data, 0xff, mem_size); + total_bytes += mem_size; + + /* Malloc memory for function FTL_Read_Disturbance */ + tmp_buf_read_disturbance = kmalloc(block_size, GFP_ATOMIC); + if (!tmp_buf_read_disturbance) + goto tmp_buf_read_disturbance_fail; + memset(tmp_buf_read_disturbance, 0xff, block_size); + total_bytes += block_size; + + /* Alloc mem for function NAND_Read_Page_Main_Spare of lld_nand.c */ + buf_read_page_main_spare = kmalloc(DeviceInfo.wPageSize, GFP_ATOMIC); + if (!buf_read_page_main_spare) + goto buf_read_page_main_spare_fail; + total_bytes += DeviceInfo.wPageSize; + + /* Alloc mem for function NAND_Write_Page_Main_Spare of lld_nand.c */ + buf_write_page_main_spare = kmalloc(DeviceInfo.wPageSize, GFP_ATOMIC); + if (!buf_write_page_main_spare) + goto buf_write_page_main_spare_fail; + total_bytes += DeviceInfo.wPageSize; + + /* Alloc mem for function NAND_Read_Page_Spare of lld_nand.c */ + buf_read_page_spare = kmalloc(DeviceInfo.wPageSpareSize, GFP_ATOMIC); + if (!buf_read_page_spare) + goto buf_read_page_spare_fail; + memset(buf_read_page_spare, 0xff, DeviceInfo.wPageSpareSize); + total_bytes += DeviceInfo.wPageSpareSize; + + /* Alloc mem for function NAND_Get_Bad_Block of lld_nand.c */ + buf_get_bad_block = kmalloc(DeviceInfo.wPageSpareSize, GFP_ATOMIC); + if (!buf_get_bad_block) + goto buf_get_bad_block_fail; + memset(buf_get_bad_block, 0xff, DeviceInfo.wPageSpareSize); + total_bytes += DeviceInfo.wPageSpareSize; + +#if CMD_DMA + g_temp_buf = kmalloc(block_size, GFP_ATOMIC); + if (!g_temp_buf) + goto temp_buf_fail; + memset(g_temp_buf, 0xff, block_size); + total_bytes += block_size; + + /* Malloc memory for copy of block table used in CDMA mode */ + g_pBTStartingCopy = kmalloc(block_table_size, GFP_ATOMIC); + if (!g_pBTStartingCopy) + goto bt_starting_copy; + memset(g_pBTStartingCopy, 0, block_table_size); + total_bytes += block_table_size; + + g_pWearCounterCopy = (u8 *)(g_pBTStartingCopy + + DeviceInfo.wDataBlockNum * sizeof(u32)); + + if (DeviceInfo.MLCDevice) + g_pReadCounterCopy = (u16 *)(g_pBTStartingCopy + + DeviceInfo.wDataBlockNum * + (sizeof(u32) + sizeof(u8))); + + /* Malloc memory for block table copies */ + mem_size = 5 * DeviceInfo.wDataBlockNum * sizeof(u32) + + 5 * DeviceInfo.wDataBlockNum * sizeof(u8); + if (DeviceInfo.MLCDevice) + mem_size += 5 * DeviceInfo.wDataBlockNum * sizeof(u16); + g_pBlockTableCopies = kmalloc(mem_size, GFP_ATOMIC); + if (!g_pBlockTableCopies) + goto blk_table_copies_fail; + memset(g_pBlockTableCopies, 0, mem_size); + total_bytes += mem_size; + g_pNextBlockTable = g_pBlockTableCopies; + + /* Malloc memory for Block Table Delta */ + mem_size = MAX_DESCS * sizeof(struct BTableChangesDelta); + g_pBTDelta = kmalloc(mem_size, GFP_ATOMIC); + if (!g_pBTDelta) + goto bt_delta_fail; + memset(g_pBTDelta, 0, mem_size); + total_bytes += mem_size; + g_pBTDelta_Free = g_pBTDelta; + + /* Malloc memory for Copy Back Buffers */ + for (j = 0; j < COPY_BACK_BUF_NUM; j++) { + cp_back_buf_copies[j] = kmalloc(block_size, GFP_ATOMIC); + if (!cp_back_buf_copies[j]) + goto cp_back_buf_copies_fail; + memset(cp_back_buf_copies[j], 0, block_size); + total_bytes += block_size; + } + cp_back_buf_idx = 0; + + /* Malloc memory for pending commands list */ + mem_size = sizeof(struct pending_cmd) * MAX_DESCS; + info.pcmds = kzalloc(mem_size, GFP_KERNEL); + if (!info.pcmds) + goto pending_cmds_buf_fail; + total_bytes += mem_size; + + /* Malloc memory for CDMA descripter table */ + mem_size = sizeof(struct cdma_descriptor) * MAX_DESCS; + info.cdma_desc_buf = kzalloc(mem_size, GFP_KERNEL); + if (!info.cdma_desc_buf) + goto cdma_desc_buf_fail; + total_bytes += mem_size; + + /* Malloc memory for Memcpy descripter table */ + mem_size = sizeof(struct memcpy_descriptor) * MAX_DESCS; + info.memcp_desc_buf = kzalloc(mem_size, GFP_KERNEL); + if (!info.memcp_desc_buf) + goto memcp_desc_buf_fail; + total_bytes += mem_size; +#endif + + nand_dbg_print(NAND_DBG_WARN, + "Total memory allocated in FTL layer: %d\n", total_bytes); + + return PASS; + +#if CMD_DMA +memcp_desc_buf_fail: + kfree(info.cdma_desc_buf); +cdma_desc_buf_fail: + kfree(info.pcmds); +pending_cmds_buf_fail: +cp_back_buf_copies_fail: + j--; + for (; j >= 0; j--) + kfree(cp_back_buf_copies[j]); + kfree(g_pBTDelta); +bt_delta_fail: + kfree(g_pBlockTableCopies); +blk_table_copies_fail: + kfree(g_pBTStartingCopy); +bt_starting_copy: + kfree(g_temp_buf); +temp_buf_fail: + kfree(buf_get_bad_block); +#endif + +buf_get_bad_block_fail: + kfree(buf_read_page_spare); +buf_read_page_spare_fail: + kfree(buf_write_page_main_spare); +buf_write_page_main_spare_fail: + kfree(buf_read_page_main_spare); +buf_read_page_main_spare_fail: + kfree(tmp_buf_read_disturbance); +tmp_buf_read_disturbance_fail: + kfree(tmp_buf_write_blk_table_data); +tmp_buf_write_blk_table_data_fail: + kfree(flags_static_wear_leveling); +flags_static_wear_leveling_fail: + kfree(tmp_buf2_read_blk_table); +tmp_buf2_read_blk_table_fail: + kfree(tmp_buf1_read_blk_table); +tmp_buf1_read_blk_table_fail: + kfree(spare_buf_bt_search_bt_in_block); +spare_buf_bt_search_bt_in_block_fail: + kfree(spare_buf_search_bt_in_block); +spare_buf_search_bt_in_block_fail: + kfree(tmp_buf_search_bt_in_block); +tmp_buf_search_bt_in_block_fail: + kfree(flag_check_blk_table); +flag_check_blk_table_fail: + kfree(g_pBTBlocks); +bt_blocks_fail: + kfree(g_pTempBuf); +Temp_buf_fail: + kfree(cache_l2_blk_buf); +cache_l2_blk_buf_fail: + kfree(cache_l2_page_buf); +cache_l2_page_buf_fail: + kfree(g_pIPF); +ipf_fail: +cache_item_fail: + i--; + for (; i >= 0; i--) + kfree(Cache.array[i].buf); + kfree(g_pBlockTable); +block_table_fail: + printk(KERN_ERR "Failed to kmalloc memory in %s Line %d.\n", + __FILE__, __LINE__); + + return -ENOMEM; +} + +/* .... */ +static int free_memory(void) +{ + int i; + +#if CMD_DMA + kfree(info.memcp_desc_buf); + kfree(info.cdma_desc_buf); + kfree(info.pcmds); + for (i = COPY_BACK_BUF_NUM - 1; i >= 0; i--) + kfree(cp_back_buf_copies[i]); + kfree(g_pBTDelta); + kfree(g_pBlockTableCopies); + kfree(g_pBTStartingCopy); + kfree(g_temp_buf); + kfree(buf_get_bad_block); +#endif + kfree(buf_read_page_spare); + kfree(buf_write_page_main_spare); + kfree(buf_read_page_main_spare); + kfree(tmp_buf_read_disturbance); + kfree(tmp_buf_write_blk_table_data); + kfree(flags_static_wear_leveling); + kfree(tmp_buf2_read_blk_table); + kfree(tmp_buf1_read_blk_table); + kfree(spare_buf_bt_search_bt_in_block); + kfree(spare_buf_search_bt_in_block); + kfree(tmp_buf_search_bt_in_block); + kfree(flag_check_blk_table); + kfree(g_pBTBlocks); + kfree(g_pTempBuf); + kfree(g_pIPF); + for (i = CACHE_ITEM_NUM - 1; i >= 0; i--) + kfree(Cache.array[i].buf); + kfree(g_pBlockTable); + + return 0; +} + +static void dump_cache_l2_table(void) +{ + struct list_head *p; + struct spectra_l2_cache_list *pnd; + int n, i; + + n = 0; + list_for_each(p, &cache_l2.table.list) { + pnd = list_entry(p, struct spectra_l2_cache_list, list); + nand_dbg_print(NAND_DBG_WARN, "dump_cache_l2_table node: %d, logical_blk_num: %d\n", n, pnd->logical_blk_num); +/* + for (i = 0; i < DeviceInfo.wPagesPerBlock; i++) { + if (pnd->pages_array[i] != MAX_U32_VALUE) + nand_dbg_print(NAND_DBG_WARN, " pages_array[%d]: 0x%x\n", i, pnd->pages_array[i]); + } +*/ + n++; + } +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: GLOB_FTL_Init +* Inputs: none +* Outputs: PASS=0 / FAIL=1 +* Description: allocates the memory for cache array, +* important data structures +* clears the cache array +* reads the block table from flash into array +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int GLOB_FTL_Init(void) +{ + int i; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + Cache.pages_per_item = 1; + Cache.cache_item_size = 1 * DeviceInfo.wPageDataSize; + + if (allocate_memory() != PASS) + return FAIL; + +#if CMD_DMA +#if RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE + memcpy((void *)&cache_start_copy, (void *)&Cache, + sizeof(struct flash_cache_tag)); + memset((void *)&int_cache, -1, + sizeof(struct flash_cache_delta_list_tag) * + (MAX_CHANS + MAX_DESCS)); +#endif + ftl_cmd_cnt = 0; +#endif + + if (FTL_Read_Block_Table() != PASS) + return FAIL; + + /* Init the Level2 Cache data structure */ + for (i = 0; i < BLK_NUM_FOR_L2_CACHE; i++) + cache_l2.blk_array[i] = MAX_U32_VALUE; + cache_l2.cur_blk_idx = 0; + cache_l2.cur_page_num = 0; + INIT_LIST_HEAD(&cache_l2.table.list); + cache_l2.table.logical_blk_num = MAX_U32_VALUE; + + dump_cache_l2_table(); + + return 0; +} + + +#if CMD_DMA +#if 0 +static void save_blk_table_changes(u16 idx) +{ + u8 ftl_cmd; + u32 *pbt = (u32 *)g_pBTStartingCopy; + +#if RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE + u16 id; + u8 cache_blks; + + id = idx - MAX_CHANS; + if (int_cache[id].item != -1) { + cache_blks = int_cache[id].item; + cache_start_copy.array[cache_blks].address = + int_cache[id].cache.address; + cache_start_copy.array[cache_blks].changed = + int_cache[id].cache.changed; + } +#endif + + ftl_cmd = p_BTableChangesDelta->ftl_cmd_cnt; + + while (ftl_cmd <= PendingCMD[idx].Tag) { + if (p_BTableChangesDelta->ValidFields == 0x01) { + g_wBlockTableOffset = + p_BTableChangesDelta->g_wBlockTableOffset; + } else if (p_BTableChangesDelta->ValidFields == 0x0C) { + pbt[p_BTableChangesDelta->BT_Index] = + p_BTableChangesDelta->BT_Entry_Value; + debug_boundary_error((( + p_BTableChangesDelta->BT_Index)), + DeviceInfo.wDataBlockNum, 0); + } else if (p_BTableChangesDelta->ValidFields == 0x03) { + g_wBlockTableOffset = + p_BTableChangesDelta->g_wBlockTableOffset; + g_wBlockTableIndex = + p_BTableChangesDelta->g_wBlockTableIndex; + } else if (p_BTableChangesDelta->ValidFields == 0x30) { + g_pWearCounterCopy[p_BTableChangesDelta->WC_Index] = + p_BTableChangesDelta->WC_Entry_Value; + } else if ((DeviceInfo.MLCDevice) && + (p_BTableChangesDelta->ValidFields == 0xC0)) { + g_pReadCounterCopy[p_BTableChangesDelta->RC_Index] = + p_BTableChangesDelta->RC_Entry_Value; + nand_dbg_print(NAND_DBG_DEBUG, + "In event status setting read counter " + "GLOB_ftl_cmd_cnt %u Count %u Index %u\n", + ftl_cmd, + p_BTableChangesDelta->RC_Entry_Value, + (unsigned int)p_BTableChangesDelta->RC_Index); + } else { + nand_dbg_print(NAND_DBG_DEBUG, + "This should never occur \n"); + } + p_BTableChangesDelta += 1; + ftl_cmd = p_BTableChangesDelta->ftl_cmd_cnt; + } +} + +static void discard_cmds(u16 n) +{ + u32 *pbt = (u32 *)g_pBTStartingCopy; + u8 ftl_cmd; + unsigned long k; +#if RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE + u8 cache_blks; + u16 id; +#endif + + if ((PendingCMD[n].CMD == WRITE_MAIN_CMD) || + (PendingCMD[n].CMD == WRITE_MAIN_SPARE_CMD)) { + for (k = 0; k < DeviceInfo.wDataBlockNum; k++) { + if (PendingCMD[n].Block == (pbt[k] & (~BAD_BLOCK))) + MARK_BLK_AS_DISCARD(pbt[k]); + } + } + + ftl_cmd = p_BTableChangesDelta->ftl_cmd_cnt; + while (ftl_cmd <= PendingCMD[n].Tag) { + p_BTableChangesDelta += 1; + ftl_cmd = p_BTableChangesDelta->ftl_cmd_cnt; + } + +#if RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE + id = n - MAX_CHANS; + + if (int_cache[id].item != -1) { + cache_blks = int_cache[id].item; + if (PendingCMD[n].CMD == MEMCOPY_CMD) { + if ((cache_start_copy.array[cache_blks].buf <= + PendingCMD[n].DataDestAddr) && + ((cache_start_copy.array[cache_blks].buf + + Cache.cache_item_size) > + PendingCMD[n].DataDestAddr)) { + cache_start_copy.array[cache_blks].address = + NAND_CACHE_INIT_ADDR; + cache_start_copy.array[cache_blks].use_cnt = + 0; + cache_start_copy.array[cache_blks].changed = + CLEAR; + } + } else { + cache_start_copy.array[cache_blks].address = + int_cache[id].cache.address; + cache_start_copy.array[cache_blks].changed = + int_cache[id].cache.changed; + } + } +#endif +} + +static void process_cmd_pass(int *first_failed_cmd, u16 idx) +{ + if (0 == *first_failed_cmd) + save_blk_table_changes(idx); + else + discard_cmds(idx); +} + +static void process_cmd_fail_abort(int *first_failed_cmd, + u16 idx, int event) +{ + u32 *pbt = (u32 *)g_pBTStartingCopy; + u8 ftl_cmd; + unsigned long i; + int erase_fail, program_fail; +#if RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE + u8 cache_blks; + u16 id; +#endif + + if (0 == *first_failed_cmd) + *first_failed_cmd = PendingCMD[idx].SBDCmdIndex; + + nand_dbg_print(NAND_DBG_DEBUG, "Uncorrectable error has occured " + "while executing %u Command %u accesing Block %u\n", + (unsigned int)p_BTableChangesDelta->ftl_cmd_cnt, + PendingCMD[idx].CMD, + (unsigned int)PendingCMD[idx].Block); + + ftl_cmd = p_BTableChangesDelta->ftl_cmd_cnt; + while (ftl_cmd <= PendingCMD[idx].Tag) { + p_BTableChangesDelta += 1; + ftl_cmd = p_BTableChangesDelta->ftl_cmd_cnt; + } + +#if RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE + id = idx - MAX_CHANS; + + if (int_cache[id].item != -1) { + cache_blks = int_cache[id].item; + if ((PendingCMD[idx].CMD == WRITE_MAIN_CMD)) { + cache_start_copy.array[cache_blks].address = + int_cache[id].cache.address; + cache_start_copy.array[cache_blks].changed = SET; + } else if ((PendingCMD[idx].CMD == READ_MAIN_CMD)) { + cache_start_copy.array[cache_blks].address = + NAND_CACHE_INIT_ADDR; + cache_start_copy.array[cache_blks].use_cnt = 0; + cache_start_copy.array[cache_blks].changed = + CLEAR; + } else if (PendingCMD[idx].CMD == ERASE_CMD) { + /* ? */ + } else if (PendingCMD[idx].CMD == MEMCOPY_CMD) { + /* ? */ + } + } +#endif + + erase_fail = (event == EVENT_ERASE_FAILURE) && + (PendingCMD[idx].CMD == ERASE_CMD); + + program_fail = (event == EVENT_PROGRAM_FAILURE) && + ((PendingCMD[idx].CMD == WRITE_MAIN_CMD) || + (PendingCMD[idx].CMD == WRITE_MAIN_SPARE_CMD)); + + if (erase_fail || program_fail) { + for (i = 0; i < DeviceInfo.wDataBlockNum; i++) { + if (PendingCMD[idx].Block == + (pbt[i] & (~BAD_BLOCK))) + MARK_BLOCK_AS_BAD(pbt[i]); + } + } +} + +static void process_cmd(int *first_failed_cmd, u16 idx, int event) +{ + u8 ftl_cmd; + int cmd_match = 0; + + if (p_BTableChangesDelta->ftl_cmd_cnt == PendingCMD[idx].Tag) + cmd_match = 1; + + if (PendingCMD[idx].Status == CMD_PASS) { + process_cmd_pass(first_failed_cmd, idx); + } else if ((PendingCMD[idx].Status == CMD_FAIL) || + (PendingCMD[idx].Status == CMD_ABORT)) { + process_cmd_fail_abort(first_failed_cmd, idx, event); + } else if ((PendingCMD[idx].Status == CMD_NOT_DONE) && + PendingCMD[idx].Tag) { + nand_dbg_print(NAND_DBG_DEBUG, + " Command no. %hu is not executed\n", + (unsigned int)PendingCMD[idx].Tag); + ftl_cmd = p_BTableChangesDelta->ftl_cmd_cnt; + while (ftl_cmd <= PendingCMD[idx].Tag) { + p_BTableChangesDelta += 1; + ftl_cmd = p_BTableChangesDelta->ftl_cmd_cnt; + } + } +} +#endif + +static void process_cmd(int *first_failed_cmd, u16 idx, int event) +{ + printk(KERN_ERR "temporary workaround function. " + "Should not be called! \n"); +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: GLOB_FTL_Event_Status +* Inputs: none +* Outputs: Event Code +* Description: It is called by SBD after hardware interrupt signalling +* completion of commands chain +* It does following things +* get event status from LLD +* analyze command chain status +* determine last command executed +* analyze results +* rebuild the block table in case of uncorrectable error +* return event code +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int GLOB_FTL_Event_Status(int *first_failed_cmd) +{ + int event_code = PASS; + u16 i_P; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + *first_failed_cmd = 0; + + event_code = GLOB_LLD_Event_Status(); + + switch (event_code) { + case EVENT_PASS: + nand_dbg_print(NAND_DBG_DEBUG, "Handling EVENT_PASS\n"); + break; + case EVENT_UNCORRECTABLE_DATA_ERROR: + nand_dbg_print(NAND_DBG_DEBUG, "Handling Uncorrectable ECC!\n"); + break; + case EVENT_PROGRAM_FAILURE: + case EVENT_ERASE_FAILURE: + nand_dbg_print(NAND_DBG_WARN, "Handling Ugly case. " + "Event code: 0x%x\n", event_code); + p_BTableChangesDelta = + (struct BTableChangesDelta *)g_pBTDelta; + for (i_P = MAX_CHANS; i_P < (ftl_cmd_cnt + MAX_CHANS); + i_P++) + process_cmd(first_failed_cmd, i_P, event_code); + memcpy(g_pBlockTable, g_pBTStartingCopy, + DeviceInfo.wDataBlockNum * sizeof(u32)); + memcpy(g_pWearCounter, g_pWearCounterCopy, + DeviceInfo.wDataBlockNum * sizeof(u8)); + if (DeviceInfo.MLCDevice) + memcpy(g_pReadCounter, g_pReadCounterCopy, + DeviceInfo.wDataBlockNum * sizeof(u16)); + +#if RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE + memcpy((void *)&Cache, (void *)&cache_start_copy, + sizeof(struct flash_cache_tag)); + memset((void *)&int_cache, -1, + sizeof(struct flash_cache_delta_list_tag) * + (MAX_DESCS + MAX_CHANS)); +#endif + break; + default: + nand_dbg_print(NAND_DBG_WARN, + "Handling unexpected event code - 0x%x\n", + event_code); + event_code = ERR; + break; + } + + memcpy(g_pBTStartingCopy, g_pBlockTable, + DeviceInfo.wDataBlockNum * sizeof(u32)); + memcpy(g_pWearCounterCopy, g_pWearCounter, + DeviceInfo.wDataBlockNum * sizeof(u8)); + if (DeviceInfo.MLCDevice) + memcpy(g_pReadCounterCopy, g_pReadCounter, + DeviceInfo.wDataBlockNum * sizeof(u16)); + + g_pBTDelta_Free = g_pBTDelta; + ftl_cmd_cnt = 0; + g_pNextBlockTable = g_pBlockTableCopies; + cp_back_buf_idx = 0; + +#if RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE + memcpy((void *)&cache_start_copy, (void *)&Cache, + sizeof(struct flash_cache_tag)); + memset((void *)&int_cache, -1, + sizeof(struct flash_cache_delta_list_tag) * + (MAX_DESCS + MAX_CHANS)); +#endif + + return event_code; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: glob_ftl_execute_cmds +* Inputs: none +* Outputs: none +* Description: pass thru to LLD +***************************************************************/ +u16 glob_ftl_execute_cmds(void) +{ + nand_dbg_print(NAND_DBG_TRACE, + "glob_ftl_execute_cmds: ftl_cmd_cnt %u\n", + (unsigned int)ftl_cmd_cnt); + g_SBDCmdIndex = 0; + return glob_lld_execute_cmds(); +} + +#endif + +#if !CMD_DMA +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: GLOB_FTL_Read Immediate +* Inputs: pointer to data +* address of data +* Outputs: PASS / FAIL +* Description: Reads one page of data into RAM directly from flash without +* using or disturbing cache.It is assumed this function is called +* with CMD-DMA disabled. +*****************************************************************/ +int GLOB_FTL_Read_Immediate(u8 *read_data, u64 addr) +{ + int wResult = FAIL; + u32 Block; + u16 Page; + u32 phy_blk; + u32 *pbt = (u32 *)g_pBlockTable; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + Block = BLK_FROM_ADDR(addr); + Page = PAGE_FROM_ADDR(addr, Block); + + if (!IS_SPARE_BLOCK(Block)) + return FAIL; + + phy_blk = pbt[Block]; + wResult = GLOB_LLD_Read_Page_Main(read_data, phy_blk, Page, 1); + + if (DeviceInfo.MLCDevice) { + g_pReadCounter[phy_blk - DeviceInfo.wSpectraStartBlock]++; + if (g_pReadCounter[phy_blk - DeviceInfo.wSpectraStartBlock] + >= MAX_READ_COUNTER) + FTL_Read_Disturbance(phy_blk); + if (g_cBlockTableStatus != IN_PROGRESS_BLOCK_TABLE) { + g_cBlockTableStatus = IN_PROGRESS_BLOCK_TABLE; + FTL_Write_IN_Progress_Block_Table_Page(); + } + } + + return wResult; +} +#endif + +#ifdef SUPPORT_BIG_ENDIAN +/********************************************************************* +* Function: FTL_Invert_Block_Table +* Inputs: none +* Outputs: none +* Description: Re-format the block table in ram based on BIG_ENDIAN and +* LARGE_BLOCKNUM if necessary +**********************************************************************/ +static void FTL_Invert_Block_Table(void) +{ + u32 i; + u32 *pbt = (u32 *)g_pBlockTable; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + +#ifdef SUPPORT_LARGE_BLOCKNUM + for (i = 0; i < DeviceInfo.wDataBlockNum; i++) { + pbt[i] = INVERTUINT32(pbt[i]); + g_pWearCounter[i] = INVERTUINT32(g_pWearCounter[i]); + } +#else + for (i = 0; i < DeviceInfo.wDataBlockNum; i++) { + pbt[i] = INVERTUINT16(pbt[i]); + g_pWearCounter[i] = INVERTUINT16(g_pWearCounter[i]); + } +#endif +} +#endif + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: GLOB_FTL_Flash_Init +* Inputs: none +* Outputs: PASS=0 / FAIL=0x01 (based on read ID) +* Description: The flash controller is initialized +* The flash device is reset +* Perform a flash READ ID command to confirm that a +* valid device is attached and active. +* The DeviceInfo structure gets filled in +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int GLOB_FTL_Flash_Init(void) +{ + int status = FAIL; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + g_SBDCmdIndex = 0; + + GLOB_LLD_Flash_Init(); + + status = GLOB_LLD_Read_Device_ID(); + + return status; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Inputs: none +* Outputs: PASS=0 / FAIL=0x01 (based on read ID) +* Description: The flash controller is released +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int GLOB_FTL_Flash_Release(void) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + return GLOB_LLD_Flash_Release(); +} + + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: GLOB_FTL_Cache_Release +* Inputs: none +* Outputs: none +* Description: release all allocated memory in GLOB_FTL_Init +* (allocated in GLOB_FTL_Init) +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +void GLOB_FTL_Cache_Release(void) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + free_memory(); +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Cache_If_Hit +* Inputs: Page Address +* Outputs: Block number/UNHIT BLOCK +* Description: Determines if the addressed page is in cache +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static u16 FTL_Cache_If_Hit(u64 page_addr) +{ + u16 item; + u64 addr; + int i; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + item = UNHIT_CACHE_ITEM; + for (i = 0; i < CACHE_ITEM_NUM; i++) { + addr = Cache.array[i].address; + if ((page_addr >= addr) && + (page_addr < (addr + Cache.cache_item_size))) { + item = i; + break; + } + } + + return item; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Calculate_LRU +* Inputs: None +* Outputs: None +* Description: Calculate the least recently block in a cache and record its +* index in LRU field. +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static void FTL_Calculate_LRU(void) +{ + u16 i, bCurrentLRU, bTempCount; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + bCurrentLRU = 0; + bTempCount = MAX_WORD_VALUE; + + for (i = 0; i < CACHE_ITEM_NUM; i++) { + if (Cache.array[i].use_cnt < bTempCount) { + bCurrentLRU = i; + bTempCount = Cache.array[i].use_cnt; + } + } + + Cache.LRU = bCurrentLRU; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Cache_Read_Page +* Inputs: pointer to read buffer, logical address and cache item number +* Outputs: None +* Description: Read the page from the cached block addressed by blocknumber +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static void FTL_Cache_Read_Page(u8 *data_buf, u64 logic_addr, u16 cache_item) +{ + u8 *start_addr; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + start_addr = Cache.array[cache_item].buf; + start_addr += (u32)(((logic_addr - Cache.array[cache_item].address) >> + DeviceInfo.nBitsInPageDataSize) * DeviceInfo.wPageDataSize); + +#if CMD_DMA + GLOB_LLD_MemCopy_CMD(data_buf, start_addr, + DeviceInfo.wPageDataSize, 0); + ftl_cmd_cnt++; +#else + memcpy(data_buf, start_addr, DeviceInfo.wPageDataSize); +#endif + + if (Cache.array[cache_item].use_cnt < MAX_WORD_VALUE) + Cache.array[cache_item].use_cnt++; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Cache_Read_All +* Inputs: pointer to read buffer,block address +* Outputs: PASS=0 / FAIL =1 +* Description: It reads pages in cache +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static int FTL_Cache_Read_All(u8 *pData, u64 phy_addr) +{ + int wResult = PASS; + u32 Block; + u32 lba; + u16 Page; + u16 PageCount; + u32 *pbt = (u32 *)g_pBlockTable; + u32 i; + + Block = BLK_FROM_ADDR(phy_addr); + Page = PAGE_FROM_ADDR(phy_addr, Block); + PageCount = Cache.pages_per_item; + + nand_dbg_print(NAND_DBG_DEBUG, + "%s, Line %d, Function: %s, Block: 0x%x\n", + __FILE__, __LINE__, __func__, Block); + + lba = 0xffffffff; + for (i = 0; i < DeviceInfo.wDataBlockNum; i++) { + if ((pbt[i] & (~BAD_BLOCK)) == Block) { + lba = i; + if (IS_SPARE_BLOCK(i) || IS_BAD_BLOCK(i) || + IS_DISCARDED_BLOCK(i)) { + /* Add by yunpeng -2008.12.3 */ +#if CMD_DMA + GLOB_LLD_MemCopy_CMD(pData, g_temp_buf, + PageCount * DeviceInfo.wPageDataSize, 0); + ftl_cmd_cnt++; +#else + memset(pData, 0xFF, + PageCount * DeviceInfo.wPageDataSize); +#endif + return wResult; + } else { + continue; /* break ?? */ + } + } + } + + if (0xffffffff == lba) + printk(KERN_ERR "FTL_Cache_Read_All: Block is not found in BT\n"); + +#if CMD_DMA + wResult = GLOB_LLD_Read_Page_Main_cdma(pData, Block, Page, + PageCount, LLD_CMD_FLAG_MODE_CDMA); + if (DeviceInfo.MLCDevice) { + g_pReadCounter[Block - DeviceInfo.wSpectraStartBlock]++; + nand_dbg_print(NAND_DBG_DEBUG, + "Read Counter modified in ftl_cmd_cnt %u" + " Block %u Counter%u\n", + ftl_cmd_cnt, (unsigned int)Block, + g_pReadCounter[Block - + DeviceInfo.wSpectraStartBlock]); + + p_BTableChangesDelta = + (struct BTableChangesDelta *)g_pBTDelta_Free; + g_pBTDelta_Free += sizeof(struct BTableChangesDelta); + p_BTableChangesDelta->ftl_cmd_cnt = ftl_cmd_cnt; + p_BTableChangesDelta->RC_Index = + Block - DeviceInfo.wSpectraStartBlock; + p_BTableChangesDelta->RC_Entry_Value = + g_pReadCounter[Block - DeviceInfo.wSpectraStartBlock]; + p_BTableChangesDelta->ValidFields = 0xC0; + + ftl_cmd_cnt++; + + if (g_pReadCounter[Block - DeviceInfo.wSpectraStartBlock] >= + MAX_READ_COUNTER) + FTL_Read_Disturbance(Block); + if (g_cBlockTableStatus != IN_PROGRESS_BLOCK_TABLE) { + g_cBlockTableStatus = IN_PROGRESS_BLOCK_TABLE; + FTL_Write_IN_Progress_Block_Table_Page(); + } + } else { + ftl_cmd_cnt++; + } +#else + wResult = GLOB_LLD_Read_Page_Main(pData, Block, Page, PageCount); + if (wResult == FAIL) + return wResult; + + if (DeviceInfo.MLCDevice) { + g_pReadCounter[Block - DeviceInfo.wSpectraStartBlock]++; + if (g_pReadCounter[Block - DeviceInfo.wSpectraStartBlock] >= + MAX_READ_COUNTER) + FTL_Read_Disturbance(Block); + if (g_cBlockTableStatus != IN_PROGRESS_BLOCK_TABLE) { + g_cBlockTableStatus = IN_PROGRESS_BLOCK_TABLE; + FTL_Write_IN_Progress_Block_Table_Page(); + } + } +#endif + return wResult; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Cache_Write_All +* Inputs: pointer to cache in sys memory +* address of free block in flash +* Outputs: PASS=0 / FAIL=1 +* Description: writes all the pages of the block in cache to flash +* +* NOTE:need to make sure this works ok when cache is limited +* to a partial block. This is where copy-back would be +* activated. This would require knowing which pages in the +* cached block are clean/dirty.Right now we only know if +* the whole block is clean/dirty. +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static int FTL_Cache_Write_All(u8 *pData, u64 blk_addr) +{ + u16 wResult = PASS; + u32 Block; + u16 Page; + u16 PageCount; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + nand_dbg_print(NAND_DBG_DEBUG, "This block %d going to be written " + "on %d\n", cache_block_to_write, + (u32)(blk_addr >> DeviceInfo.nBitsInBlockDataSize)); + + Block = BLK_FROM_ADDR(blk_addr); + Page = PAGE_FROM_ADDR(blk_addr, Block); + PageCount = Cache.pages_per_item; + +#if CMD_DMA + if (FAIL == GLOB_LLD_Write_Page_Main_cdma(pData, + Block, Page, PageCount)) { + nand_dbg_print(NAND_DBG_WARN, + "NAND Program fail in %s, Line %d, " + "Function: %s, new Bad Block %d generated! " + "Need Bad Block replacing.\n", + __FILE__, __LINE__, __func__, Block); + wResult = FAIL; + } + ftl_cmd_cnt++; +#else + if (FAIL == GLOB_LLD_Write_Page_Main(pData, Block, Page, PageCount)) { + nand_dbg_print(NAND_DBG_WARN, "NAND Program fail in %s," + " Line %d, Function %s, new Bad Block %d generated!" + "Need Bad Block replacing.\n", + __FILE__, __LINE__, __func__, Block); + wResult = FAIL; + } +#endif + return wResult; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Cache_Update_Block +* Inputs: pointer to buffer,page address,block address +* Outputs: PASS=0 / FAIL=1 +* Description: It updates the cache +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static int FTL_Cache_Update_Block(u8 *pData, + u64 old_page_addr, u64 blk_addr) +{ + int i, j; + u8 *buf = pData; + int wResult = PASS; + int wFoundInCache; + u64 page_addr; + u64 addr; + u64 old_blk_addr; + u16 page_offset; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + old_blk_addr = (u64)(old_page_addr >> + DeviceInfo.nBitsInBlockDataSize) * DeviceInfo.wBlockDataSize; + page_offset = (u16)(GLOB_u64_Remainder(old_page_addr, 2) >> + DeviceInfo.nBitsInPageDataSize); + + for (i = 0; i < DeviceInfo.wPagesPerBlock; i += Cache.pages_per_item) { + page_addr = old_blk_addr + i * DeviceInfo.wPageDataSize; + if (i != page_offset) { + wFoundInCache = FAIL; + for (j = 0; j < CACHE_ITEM_NUM; j++) { + addr = Cache.array[j].address; + addr = FTL_Get_Physical_Block_Addr(addr) + + GLOB_u64_Remainder(addr, 2); + if ((addr >= page_addr) && addr < + (page_addr + Cache.cache_item_size)) { + wFoundInCache = PASS; + buf = Cache.array[j].buf; + Cache.array[j].changed = SET; +#if CMD_DMA +#if RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE + int_cache[ftl_cmd_cnt].item = j; + int_cache[ftl_cmd_cnt].cache.address = + Cache.array[j].address; + int_cache[ftl_cmd_cnt].cache.changed = + Cache.array[j].changed; +#endif +#endif + break; + } + } + if (FAIL == wFoundInCache) { + if (ERR == FTL_Cache_Read_All(g_pTempBuf, + page_addr)) { + wResult = FAIL; + break; + } + buf = g_pTempBuf; + } + } else { + buf = pData; + } + + if (FAIL == FTL_Cache_Write_All(buf, + blk_addr + (page_addr - old_blk_addr))) { + wResult = FAIL; + break; + } + } + + return wResult; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Copy_Block +* Inputs: source block address +* Destination block address +* Outputs: PASS=0 / FAIL=1 +* Description: used only for static wear leveling to move the block +* containing static data to new blocks(more worn) +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int FTL_Copy_Block(u64 old_blk_addr, u64 blk_addr) +{ + int i, r1, r2, wResult = PASS; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + for (i = 0; i < DeviceInfo.wPagesPerBlock; i += Cache.pages_per_item) { + r1 = FTL_Cache_Read_All(g_pTempBuf, old_blk_addr + + i * DeviceInfo.wPageDataSize); + r2 = FTL_Cache_Write_All(g_pTempBuf, blk_addr + + i * DeviceInfo.wPageDataSize); + if ((ERR == r1) || (FAIL == r2)) { + wResult = FAIL; + break; + } + } + + return wResult; +} + +/* Search the block table to find out the least wear block and then return it */ +static u32 find_least_worn_blk_for_l2_cache(void) +{ + int i; + u32 *pbt = (u32 *)g_pBlockTable; + u8 least_wear_cnt = MAX_BYTE_VALUE; + u32 least_wear_blk_idx = MAX_U32_VALUE; + u32 phy_idx; + + for (i = 0; i < DeviceInfo.wDataBlockNum; i++) { + if (IS_SPARE_BLOCK(i)) { + phy_idx = (u32)((~BAD_BLOCK) & pbt[i]); + if (phy_idx > DeviceInfo.wSpectraEndBlock) + printk(KERN_ERR "find_least_worn_blk_for_l2_cache: " + "Too big phy block num (%d)\n", phy_idx); + if (g_pWearCounter[phy_idx -DeviceInfo.wSpectraStartBlock] < least_wear_cnt) { + least_wear_cnt = g_pWearCounter[phy_idx - DeviceInfo.wSpectraStartBlock]; + least_wear_blk_idx = i; + } + } + } + + nand_dbg_print(NAND_DBG_WARN, + "find_least_worn_blk_for_l2_cache: " + "find block %d with least worn counter (%d)\n", + least_wear_blk_idx, least_wear_cnt); + + return least_wear_blk_idx; +} + + + +/* Get blocks for Level2 Cache */ +static int get_l2_cache_blks(void) +{ + int n; + u32 blk; + u32 *pbt = (u32 *)g_pBlockTable; + + for (n = 0; n < BLK_NUM_FOR_L2_CACHE; n++) { + blk = find_least_worn_blk_for_l2_cache(); + if (blk > DeviceInfo.wDataBlockNum) { + nand_dbg_print(NAND_DBG_WARN, + "find_least_worn_blk_for_l2_cache: " + "No enough free NAND blocks (n: %d) for L2 Cache!\n", n); + return FAIL; + } + /* Tag the free block as discard in block table */ + pbt[blk] = (pbt[blk] & (~BAD_BLOCK)) | DISCARD_BLOCK; + /* Add the free block to the L2 Cache block array */ + cache_l2.blk_array[n] = pbt[blk] & (~BAD_BLOCK); + } + + return PASS; +} + +static int erase_l2_cache_blocks(void) +{ + int i, ret = PASS; + u32 pblk, lblk; + u64 addr; + u32 *pbt = (u32 *)g_pBlockTable; + + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + for (i = 0; i < BLK_NUM_FOR_L2_CACHE; i++) { + pblk = cache_l2.blk_array[i]; + + /* If the L2 cache block is invalid, then just skip it */ + if (MAX_U32_VALUE == pblk) + continue; + + BUG_ON(pblk > DeviceInfo.wSpectraEndBlock); + + addr = (u64)pblk << DeviceInfo.nBitsInBlockDataSize; + if (PASS == GLOB_FTL_Block_Erase(addr)) { + /* Get logical block number of the erased block */ + lblk = FTL_Get_Block_Index(pblk); + BUG_ON(BAD_BLOCK == lblk); + /* Tag it as free in the block table */ + pbt[lblk] &= (u32)(~DISCARD_BLOCK); + pbt[lblk] |= (u32)(SPARE_BLOCK); + } else { + MARK_BLOCK_AS_BAD(pbt[lblk]); + ret = ERR; + } + } + + return ret; +} + +/* + * Merge the valid data page in the L2 cache blocks into NAND. +*/ +static int flush_l2_cache(void) +{ + struct list_head *p; + struct spectra_l2_cache_list *pnd, *tmp_pnd; + u32 *pbt = (u32 *)g_pBlockTable; + u32 phy_blk, l2_blk; + u64 addr; + u16 l2_page; + int i, ret = PASS; + + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (list_empty(&cache_l2.table.list)) /* No data to flush */ + return ret; + + //dump_cache_l2_table(); + + if (IN_PROGRESS_BLOCK_TABLE != g_cBlockTableStatus) { + g_cBlockTableStatus = IN_PROGRESS_BLOCK_TABLE; + FTL_Write_IN_Progress_Block_Table_Page(); + } + + list_for_each(p, &cache_l2.table.list) { + pnd = list_entry(p, struct spectra_l2_cache_list, list); + if (IS_SPARE_BLOCK(pnd->logical_blk_num) || + IS_BAD_BLOCK(pnd->logical_blk_num) || + IS_DISCARDED_BLOCK(pnd->logical_blk_num)) { + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d\n", __FILE__, __LINE__); + memset(cache_l2_blk_buf, 0xff, DeviceInfo.wPagesPerBlock * DeviceInfo.wPageDataSize); + } else { + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d\n", __FILE__, __LINE__); + phy_blk = pbt[pnd->logical_blk_num] & (~BAD_BLOCK); + ret = GLOB_LLD_Read_Page_Main(cache_l2_blk_buf, + phy_blk, 0, DeviceInfo.wPagesPerBlock); + if (ret == FAIL) { + printk(KERN_ERR "Read NAND page fail in %s, Line %d\n", __FILE__, __LINE__); + } + } + + for (i = 0; i < DeviceInfo.wPagesPerBlock; i++) { + if (pnd->pages_array[i] != MAX_U32_VALUE) { + l2_blk = cache_l2.blk_array[(pnd->pages_array[i] >> 16) & 0xffff]; + l2_page = pnd->pages_array[i] & 0xffff; + ret = GLOB_LLD_Read_Page_Main(cache_l2_page_buf, l2_blk, l2_page, 1); + if (ret == FAIL) { + printk(KERN_ERR "Read NAND page fail in %s, Line %d\n", __FILE__, __LINE__); + } + memcpy(cache_l2_blk_buf + i * DeviceInfo.wPageDataSize, cache_l2_page_buf, DeviceInfo.wPageDataSize); + } + } + + /* Find a free block and tag the original block as discarded */ + addr = (u64)pnd->logical_blk_num << DeviceInfo.nBitsInBlockDataSize; + ret = FTL_Replace_Block(addr); + if (ret == FAIL) { + printk(KERN_ERR "FTL_Replace_Block fail in %s, Line %d\n", __FILE__, __LINE__); + } + + /* Write back the updated data into NAND */ + phy_blk = pbt[pnd->logical_blk_num] & (~BAD_BLOCK); + if (FAIL == GLOB_LLD_Write_Page_Main(cache_l2_blk_buf, phy_blk, 0, DeviceInfo.wPagesPerBlock)) { + nand_dbg_print(NAND_DBG_WARN, + "Program NAND block %d fail in %s, Line %d\n", + phy_blk, __FILE__, __LINE__); + /* This may not be really a bad block. So just tag it as discarded. */ + /* Then it has a chance to be erased when garbage collection. */ + /* If it is really bad, then the erase will fail and it will be marked */ + /* as bad then. Otherwise it will be marked as free and can be used again */ + MARK_BLK_AS_DISCARD(pbt[pnd->logical_blk_num]); + /* Find another free block and write it again */ + FTL_Replace_Block(addr); + phy_blk = pbt[pnd->logical_blk_num] & (~BAD_BLOCK); + if (FAIL == GLOB_LLD_Write_Page_Main(cache_l2_blk_buf, phy_blk, 0, DeviceInfo.wPagesPerBlock)) { + printk(KERN_ERR "Failed to write back block %d when flush L2 cache." + "Some data will be lost!\n", phy_blk); + MARK_BLOCK_AS_BAD(pbt[pnd->logical_blk_num]); + } + } else { + /* tag the new free block as used block */ + pbt[pnd->logical_blk_num] &= (~SPARE_BLOCK); + } + } + + /* Destroy the L2 Cache table and free the memory of all nodes */ + list_for_each_entry_safe(pnd, tmp_pnd, &cache_l2.table.list, list) { + list_del(&pnd->list); + kfree(pnd); + } + + /* Erase discard L2 cache blocks */ + if (erase_l2_cache_blocks() != PASS) + nand_dbg_print(NAND_DBG_WARN, + " Erase L2 cache blocks error in %s, Line %d\n", + __FILE__, __LINE__); + + /* Init the Level2 Cache data structure */ + for (i = 0; i < BLK_NUM_FOR_L2_CACHE; i++) + cache_l2.blk_array[i] = MAX_U32_VALUE; + cache_l2.cur_blk_idx = 0; + cache_l2.cur_page_num = 0; + INIT_LIST_HEAD(&cache_l2.table.list); + cache_l2.table.logical_blk_num = MAX_U32_VALUE; + + return ret; +} + +/* + * Write back a changed victim cache item to the Level2 Cache + * and update the L2 Cache table to map the change. + * If the L2 Cache is full, then start to do the L2 Cache flush. +*/ +static int write_back_to_l2_cache(u8 *buf, u64 logical_addr) +{ + u32 logical_blk_num; + u16 logical_page_num; + struct list_head *p; + struct spectra_l2_cache_list *pnd, *pnd_new; + u32 node_size; + int i, found; + + nand_dbg_print(NAND_DBG_DEBUG, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + /* + * If Level2 Cache table is empty, then it means either: + * 1. This is the first time that the function called after FTL_init + * or + * 2. The Level2 Cache has just been flushed + * + * So, 'steal' some free blocks from NAND for L2 Cache using + * by just mask them as discard in the block table + */ + if (list_empty(&cache_l2.table.list)) { + BUG_ON(cache_l2.cur_blk_idx != 0); + BUG_ON(cache_l2.cur_page_num!= 0); + BUG_ON(cache_l2.table.logical_blk_num != MAX_U32_VALUE); + if (FAIL == get_l2_cache_blks()) { + GLOB_FTL_Garbage_Collection(); + if (FAIL == get_l2_cache_blks()) { + printk(KERN_ALERT "Fail to get L2 cache blks!\n"); + return FAIL; + } + } + } + + logical_blk_num = BLK_FROM_ADDR(logical_addr); + logical_page_num = PAGE_FROM_ADDR(logical_addr, logical_blk_num); + BUG_ON(logical_blk_num == MAX_U32_VALUE); + + /* Write the cache item data into the current position of L2 Cache */ +#if CMD_DMA + /* + * TODO + */ +#else + if (FAIL == GLOB_LLD_Write_Page_Main(buf, + cache_l2.blk_array[cache_l2.cur_blk_idx], + cache_l2.cur_page_num, 1)) { + nand_dbg_print(NAND_DBG_WARN, "NAND Program fail in " + "%s, Line %d, new Bad Block %d generated!\n", + __FILE__, __LINE__, + cache_l2.blk_array[cache_l2.cur_blk_idx]); + + /* TODO: tag the current block as bad and try again */ + + return FAIL; + } +#endif + + /* + * Update the L2 Cache table. + * + * First seaching in the table to see whether the logical block + * has been mapped. If not, then kmalloc a new node for the + * logical block, fill data, and then insert it to the list. + * Otherwise, just update the mapped node directly. + */ + found = 0; + list_for_each(p, &cache_l2.table.list) { + pnd = list_entry(p, struct spectra_l2_cache_list, list); + if (pnd->logical_blk_num == logical_blk_num) { + pnd->pages_array[logical_page_num] = + (cache_l2.cur_blk_idx << 16) | + cache_l2.cur_page_num; + found = 1; + break; + } + } + if (!found) { /* Create new node for the logical block here */ + + /* The logical pages to physical pages map array is + * located at the end of struct spectra_l2_cache_list. + */ + node_size = sizeof(struct spectra_l2_cache_list) + + sizeof(u32) * DeviceInfo.wPagesPerBlock; + pnd_new = kmalloc(node_size, GFP_ATOMIC); + if (!pnd_new) { + printk(KERN_ERR "Failed to kmalloc in %s Line %d\n", + __FILE__, __LINE__); + /* + * TODO: Need to flush all the L2 cache into NAND ASAP + * since no memory available here + */ + } + pnd_new->logical_blk_num = logical_blk_num; + for (i = 0; i < DeviceInfo.wPagesPerBlock; i++) + pnd_new->pages_array[i] = MAX_U32_VALUE; + pnd_new->pages_array[logical_page_num] = + (cache_l2.cur_blk_idx << 16) | cache_l2.cur_page_num; + list_add(&pnd_new->list, &cache_l2.table.list); + } + + /* Increasing the current position pointer of the L2 Cache */ + cache_l2.cur_page_num++; + if (cache_l2.cur_page_num >= DeviceInfo.wPagesPerBlock) { + cache_l2.cur_blk_idx++; + if (cache_l2.cur_blk_idx >= BLK_NUM_FOR_L2_CACHE) { + /* The L2 Cache is full. Need to flush it now */ + nand_dbg_print(NAND_DBG_WARN, + "L2 Cache is full, will start to flush it\n"); + flush_l2_cache(); + } else { + cache_l2.cur_page_num = 0; + } + } + + return PASS; +} + +/* + * Seach in the Level2 Cache table to find the cache item. + * If find, read the data from the NAND page of L2 Cache, + * Otherwise, return FAIL. + */ +static int search_l2_cache(u8 *buf, u64 logical_addr) +{ + u32 logical_blk_num; + u16 logical_page_num; + struct list_head *p; + struct spectra_l2_cache_list *pnd; + u32 tmp = MAX_U32_VALUE; + u32 phy_blk; + u16 phy_page; + int ret = FAIL; + + logical_blk_num = BLK_FROM_ADDR(logical_addr); + logical_page_num = PAGE_FROM_ADDR(logical_addr, logical_blk_num); + + list_for_each(p, &cache_l2.table.list) { + pnd = list_entry(p, struct spectra_l2_cache_list, list); + if (pnd->logical_blk_num == logical_blk_num) { + tmp = pnd->pages_array[logical_page_num]; + break; + } + } + + if (tmp != MAX_U32_VALUE) { /* Found valid map */ + phy_blk = cache_l2.blk_array[(tmp >> 16) & 0xFFFF]; + phy_page = tmp & 0xFFFF; +#if CMD_DMA + /* TODO */ +#else + ret = GLOB_LLD_Read_Page_Main(buf, phy_blk, phy_page, 1); +#endif + } + + return ret; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Cache_Write_Back +* Inputs: pointer to data cached in sys memory +* address of free block in flash +* Outputs: PASS=0 / FAIL=1 +* Description: writes all the pages of Cache Block to flash +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static int FTL_Cache_Write_Back(u8 *pData, u64 blk_addr) +{ + int i, j, iErase; + u64 old_page_addr, addr, phy_addr; + u32 *pbt = (u32 *)g_pBlockTable; + u32 lba; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + old_page_addr = FTL_Get_Physical_Block_Addr(blk_addr) + + GLOB_u64_Remainder(blk_addr, 2); + + iErase = (FAIL == FTL_Replace_Block(blk_addr)) ? PASS : FAIL; + + pbt[BLK_FROM_ADDR(blk_addr)] &= (~SPARE_BLOCK); + +#if CMD_DMA + p_BTableChangesDelta = (struct BTableChangesDelta *)g_pBTDelta_Free; + g_pBTDelta_Free += sizeof(struct BTableChangesDelta); + + p_BTableChangesDelta->ftl_cmd_cnt = ftl_cmd_cnt; + p_BTableChangesDelta->BT_Index = (u32)(blk_addr >> + DeviceInfo.nBitsInBlockDataSize); + p_BTableChangesDelta->BT_Entry_Value = + pbt[(u32)(blk_addr >> DeviceInfo.nBitsInBlockDataSize)]; + p_BTableChangesDelta->ValidFields = 0x0C; +#endif + + if (IN_PROGRESS_BLOCK_TABLE != g_cBlockTableStatus) { + g_cBlockTableStatus = IN_PROGRESS_BLOCK_TABLE; + FTL_Write_IN_Progress_Block_Table_Page(); + } + + for (i = 0; i < RETRY_TIMES; i++) { + if (PASS == iErase) { + phy_addr = FTL_Get_Physical_Block_Addr(blk_addr); + if (FAIL == GLOB_FTL_Block_Erase(phy_addr)) { + lba = BLK_FROM_ADDR(blk_addr); + MARK_BLOCK_AS_BAD(pbt[lba]); + i = RETRY_TIMES; + break; + } + } + + for (j = 0; j < CACHE_ITEM_NUM; j++) { + addr = Cache.array[j].address; + if ((addr <= blk_addr) && + ((addr + Cache.cache_item_size) > blk_addr)) + cache_block_to_write = j; + } + + phy_addr = FTL_Get_Physical_Block_Addr(blk_addr); + if (PASS == FTL_Cache_Update_Block(pData, + old_page_addr, phy_addr)) { + cache_block_to_write = UNHIT_CACHE_ITEM; + break; + } else { + iErase = PASS; + } + } + + if (i >= RETRY_TIMES) { + if (ERR == FTL_Flash_Error_Handle(pData, + old_page_addr, blk_addr)) + return ERR; + else + return FAIL; + } + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Cache_Write_Page +* Inputs: Pointer to buffer, page address, cache block number +* Outputs: PASS=0 / FAIL=1 +* Description: It writes the data in Cache Block +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static void FTL_Cache_Write_Page(u8 *pData, u64 page_addr, + u8 cache_blk, u16 flag) +{ + u8 *pDest; + u64 addr; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + addr = Cache.array[cache_blk].address; + pDest = Cache.array[cache_blk].buf; + + pDest += (unsigned long)(page_addr - addr); + Cache.array[cache_blk].changed = SET; +#if CMD_DMA +#if RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE + int_cache[ftl_cmd_cnt].item = cache_blk; + int_cache[ftl_cmd_cnt].cache.address = + Cache.array[cache_blk].address; + int_cache[ftl_cmd_cnt].cache.changed = + Cache.array[cache_blk].changed; +#endif + GLOB_LLD_MemCopy_CMD(pDest, pData, DeviceInfo.wPageDataSize, flag); + ftl_cmd_cnt++; +#else + memcpy(pDest, pData, DeviceInfo.wPageDataSize); +#endif + if (Cache.array[cache_blk].use_cnt < MAX_WORD_VALUE) + Cache.array[cache_blk].use_cnt++; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Cache_Write +* Inputs: none +* Outputs: PASS=0 / FAIL=1 +* Description: It writes least frequently used Cache block to flash if it +* has been changed +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static int FTL_Cache_Write(void) +{ + int i, bResult = PASS; + u16 bNO, least_count = 0xFFFF; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + FTL_Calculate_LRU(); + + bNO = Cache.LRU; + nand_dbg_print(NAND_DBG_DEBUG, "FTL_Cache_Write: " + "Least used cache block is %d\n", bNO); + + if (Cache.array[bNO].changed != SET) + return bResult; + + nand_dbg_print(NAND_DBG_DEBUG, "FTL_Cache_Write: Cache" + " Block %d containing logical block %d is dirty\n", + bNO, + (u32)(Cache.array[bNO].address >> + DeviceInfo.nBitsInBlockDataSize)); +#if CMD_DMA +#if RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE + int_cache[ftl_cmd_cnt].item = bNO; + int_cache[ftl_cmd_cnt].cache.address = + Cache.array[bNO].address; + int_cache[ftl_cmd_cnt].cache.changed = CLEAR; +#endif +#endif + bResult = write_back_to_l2_cache(Cache.array[bNO].buf, + Cache.array[bNO].address); + if (bResult != ERR) + Cache.array[bNO].changed = CLEAR; + + least_count = Cache.array[bNO].use_cnt; + + for (i = 0; i < CACHE_ITEM_NUM; i++) { + if (i == bNO) + continue; + if (Cache.array[i].use_cnt > 0) + Cache.array[i].use_cnt -= least_count; + } + + return bResult; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Cache_Read +* Inputs: Page address +* Outputs: PASS=0 / FAIL=1 +* Description: It reads the block from device in Cache Block +* Set the LRU count to 1 +* Mark the Cache Block as clean +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static int FTL_Cache_Read(u64 logical_addr) +{ + u64 item_addr, phy_addr; + u16 num; + int ret; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + num = Cache.LRU; /* The LRU cache item will be overwritten */ + + item_addr = (u64)GLOB_u64_Div(logical_addr, Cache.cache_item_size) * + Cache.cache_item_size; + Cache.array[num].address = item_addr; + Cache.array[num].use_cnt = 1; + Cache.array[num].changed = CLEAR; + +#if CMD_DMA +#if RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE + int_cache[ftl_cmd_cnt].item = num; + int_cache[ftl_cmd_cnt].cache.address = + Cache.array[num].address; + int_cache[ftl_cmd_cnt].cache.changed = + Cache.array[num].changed; +#endif +#endif + /* + * Search in L2 Cache. If hit, fill data into L1 Cache item buffer, + * Otherwise, read it from NAND + */ + ret = search_l2_cache(Cache.array[num].buf, logical_addr); + if (PASS == ret) /* Hit in L2 Cache */ + return ret; + + /* Compute the physical start address of NAND device according to */ + /* the logical start address of the cache item (LRU cache item) */ + phy_addr = FTL_Get_Physical_Block_Addr(item_addr) + + GLOB_u64_Remainder(item_addr, 2); + + return FTL_Cache_Read_All(Cache.array[num].buf, phy_addr); +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Check_Block_Table +* Inputs: ? +* Outputs: PASS=0 / FAIL=1 +* Description: It checks the correctness of each block table entry +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static int FTL_Check_Block_Table(int wOldTable) +{ + u32 i; + int wResult = PASS; + u32 blk_idx; + u32 *pbt = (u32 *)g_pBlockTable; + u8 *pFlag = flag_check_blk_table; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (NULL != pFlag) { + memset(pFlag, FAIL, DeviceInfo.wDataBlockNum); + for (i = 0; i < DeviceInfo.wDataBlockNum; i++) { + blk_idx = (u32)(pbt[i] & (~BAD_BLOCK)); + + /* + * 20081006/KBV - Changed to pFlag[i] reference + * to avoid buffer overflow + */ + + /* + * 2008-10-20 Yunpeng Note: This change avoid + * buffer overflow, but changed function of + * the code, so it should be re-write later + */ + if ((blk_idx > DeviceInfo.wSpectraEndBlock) || + PASS == pFlag[i]) { + wResult = FAIL; + break; + } else { + pFlag[i] = PASS; + } + } + } + + return wResult; +} + + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Write_Block_Table +* Inputs: flasg +* Outputs: 0=Block Table was updated. No write done. 1=Block write needs to +* happen. -1 Error +* Description: It writes the block table +* Block table always mapped to LBA 0 which inturn mapped +* to any physical block +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static int FTL_Write_Block_Table(int wForce) +{ + u32 *pbt = (u32 *)g_pBlockTable; + int wSuccess = PASS; + u32 wTempBlockTableIndex; + u16 bt_pages, new_bt_offset; + u8 blockchangeoccured = 0; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + bt_pages = FTL_Get_Block_Table_Flash_Size_Pages(); + + if (IN_PROGRESS_BLOCK_TABLE != g_cBlockTableStatus) + return 0; + + if (PASS == wForce) { + g_wBlockTableOffset = + (u16)(DeviceInfo.wPagesPerBlock - bt_pages); +#if CMD_DMA + p_BTableChangesDelta = + (struct BTableChangesDelta *)g_pBTDelta_Free; + g_pBTDelta_Free += sizeof(struct BTableChangesDelta); + + p_BTableChangesDelta->ftl_cmd_cnt = ftl_cmd_cnt; + p_BTableChangesDelta->g_wBlockTableOffset = + g_wBlockTableOffset; + p_BTableChangesDelta->ValidFields = 0x01; +#endif + } + + nand_dbg_print(NAND_DBG_DEBUG, + "Inside FTL_Write_Block_Table: block %d Page:%d\n", + g_wBlockTableIndex, g_wBlockTableOffset); + + do { + new_bt_offset = g_wBlockTableOffset + bt_pages + 1; + if ((0 == (new_bt_offset % DeviceInfo.wPagesPerBlock)) || + (new_bt_offset > DeviceInfo.wPagesPerBlock) || + (FAIL == wSuccess)) { + wTempBlockTableIndex = FTL_Replace_Block_Table(); + if (BAD_BLOCK == wTempBlockTableIndex) + return ERR; + if (!blockchangeoccured) { + bt_block_changed = 1; + blockchangeoccured = 1; + } + + g_wBlockTableIndex = wTempBlockTableIndex; + g_wBlockTableOffset = 0; + pbt[BLOCK_TABLE_INDEX] = g_wBlockTableIndex; +#if CMD_DMA + p_BTableChangesDelta = + (struct BTableChangesDelta *)g_pBTDelta_Free; + g_pBTDelta_Free += sizeof(struct BTableChangesDelta); + + p_BTableChangesDelta->ftl_cmd_cnt = + ftl_cmd_cnt; + p_BTableChangesDelta->g_wBlockTableOffset = + g_wBlockTableOffset; + p_BTableChangesDelta->g_wBlockTableIndex = + g_wBlockTableIndex; + p_BTableChangesDelta->ValidFields = 0x03; + + p_BTableChangesDelta = + (struct BTableChangesDelta *)g_pBTDelta_Free; + g_pBTDelta_Free += + sizeof(struct BTableChangesDelta); + + p_BTableChangesDelta->ftl_cmd_cnt = + ftl_cmd_cnt; + p_BTableChangesDelta->BT_Index = + BLOCK_TABLE_INDEX; + p_BTableChangesDelta->BT_Entry_Value = + pbt[BLOCK_TABLE_INDEX]; + p_BTableChangesDelta->ValidFields = 0x0C; +#endif + } + + wSuccess = FTL_Write_Block_Table_Data(); + if (FAIL == wSuccess) + MARK_BLOCK_AS_BAD(pbt[BLOCK_TABLE_INDEX]); + } while (FAIL == wSuccess); + + g_cBlockTableStatus = CURRENT_BLOCK_TABLE; + + return 1; +} + +/****************************************************************** +* Function: GLOB_FTL_Flash_Format +* Inputs: none +* Outputs: PASS +* Description: The block table stores bad block info, including MDF+ +* blocks gone bad over the ages. Therefore, if we have a +* block table in place, then use it to scan for bad blocks +* If not, then scan for MDF. +* Now, a block table will only be found if spectra was already +* being used. For a fresh flash, we'll go thru scanning for +* MDF. If spectra was being used, then there is a chance that +* the MDF has been corrupted. Spectra avoids writing to the +* first 2 bytes of the spare area to all pages in a block. This +* covers all known flash devices. However, since flash +* manufacturers have no standard of where the MDF is stored, +* this cannot guarantee that the MDF is protected for future +* devices too. The initial scanning for the block table assures +* this. It is ok even if the block table is outdated, as all +* we're looking for are bad block markers. +* Use this when mounting a file system or starting a +* new flash. +* +*********************************************************************/ +static int FTL_Format_Flash(u8 valid_block_table) +{ + u32 i, j; + u32 *pbt = (u32 *)g_pBlockTable; + u32 tempNode; + int ret; + +#if CMD_DMA + u32 *pbtStartingCopy = (u32 *)g_pBTStartingCopy; + if (ftl_cmd_cnt) + return FAIL; +#endif + + if (FAIL == FTL_Check_Block_Table(FAIL)) + valid_block_table = 0; + + if (valid_block_table) { + u8 switched = 1; + u32 block, k; + + k = DeviceInfo.wSpectraStartBlock; + while (switched && (k < DeviceInfo.wSpectraEndBlock)) { + switched = 0; + k++; + for (j = DeviceInfo.wSpectraStartBlock, i = 0; + j <= DeviceInfo.wSpectraEndBlock; + j++, i++) { + block = (pbt[i] & ~BAD_BLOCK) - + DeviceInfo.wSpectraStartBlock; + if (block != i) { + switched = 1; + tempNode = pbt[i]; + pbt[i] = pbt[block]; + pbt[block] = tempNode; + } + } + } + if ((k == DeviceInfo.wSpectraEndBlock) && switched) + valid_block_table = 0; + } + + if (!valid_block_table) { + memset(g_pBlockTable, 0, + DeviceInfo.wDataBlockNum * sizeof(u32)); + memset(g_pWearCounter, 0, + DeviceInfo.wDataBlockNum * sizeof(u8)); + if (DeviceInfo.MLCDevice) + memset(g_pReadCounter, 0, + DeviceInfo.wDataBlockNum * sizeof(u16)); +#if CMD_DMA + memset(g_pBTStartingCopy, 0, + DeviceInfo.wDataBlockNum * sizeof(u32)); + memset(g_pWearCounterCopy, 0, + DeviceInfo.wDataBlockNum * sizeof(u8)); + if (DeviceInfo.MLCDevice) + memset(g_pReadCounterCopy, 0, + DeviceInfo.wDataBlockNum * sizeof(u16)); +#endif + for (j = DeviceInfo.wSpectraStartBlock, i = 0; + j <= DeviceInfo.wSpectraEndBlock; + j++, i++) { + if (GLOB_LLD_Get_Bad_Block((u32)j)) + pbt[i] = (u32)(BAD_BLOCK | j); + } + } + + nand_dbg_print(NAND_DBG_WARN, "Erasing all blocks in the NAND\n"); + + for (j = DeviceInfo.wSpectraStartBlock, i = 0; + j <= DeviceInfo.wSpectraEndBlock; + j++, i++) { + if ((pbt[i] & BAD_BLOCK) != BAD_BLOCK) { + ret = GLOB_LLD_Erase_Block(j); + if (FAIL == ret) { + pbt[i] = (u32)(j); + MARK_BLOCK_AS_BAD(pbt[i]); + nand_dbg_print(NAND_DBG_WARN, + "NAND Program fail in %s, Line %d, " + "Function: %s, new Bad Block %d generated!\n", + __FILE__, __LINE__, __func__, (int)j); + } else { + pbt[i] = (u32)(SPARE_BLOCK | j); + } + } +#if CMD_DMA + pbtStartingCopy[i] = pbt[i]; +#endif + } + + g_wBlockTableOffset = 0; + for (i = 0; (i <= (DeviceInfo.wSpectraEndBlock - + DeviceInfo.wSpectraStartBlock)) + && ((pbt[i] & BAD_BLOCK) == BAD_BLOCK); i++) + ; + if (i > (DeviceInfo.wSpectraEndBlock - DeviceInfo.wSpectraStartBlock)) { + printk(KERN_ERR "All blocks bad!\n"); + return FAIL; + } else { + g_wBlockTableIndex = pbt[i] & ~BAD_BLOCK; + if (i != BLOCK_TABLE_INDEX) { + tempNode = pbt[i]; + pbt[i] = pbt[BLOCK_TABLE_INDEX]; + pbt[BLOCK_TABLE_INDEX] = tempNode; + } + } + pbt[BLOCK_TABLE_INDEX] &= (~SPARE_BLOCK); + +#if CMD_DMA + pbtStartingCopy[BLOCK_TABLE_INDEX] &= (~SPARE_BLOCK); +#endif + + g_cBlockTableStatus = IN_PROGRESS_BLOCK_TABLE; + memset(g_pBTBlocks, 0xFF, + (1 + LAST_BT_ID - FIRST_BT_ID) * sizeof(u32)); + g_pBTBlocks[FIRST_BT_ID-FIRST_BT_ID] = g_wBlockTableIndex; + FTL_Write_Block_Table(FAIL); + + for (i = 0; i < CACHE_ITEM_NUM; i++) { + Cache.array[i].address = NAND_CACHE_INIT_ADDR; + Cache.array[i].use_cnt = 0; + Cache.array[i].changed = CLEAR; + } + +#if (RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE && CMD_DMA) + memcpy((void *)&cache_start_copy, (void *)&Cache, + sizeof(struct flash_cache_tag)); +#endif + return PASS; +} + +static int force_format_nand(void) +{ + u32 i; + + /* Force erase the whole unprotected physical partiton of NAND */ + printk(KERN_ALERT "Start to force erase whole NAND device ...\n"); + printk(KERN_ALERT "From phyical block %d to %d\n", + DeviceInfo.wSpectraStartBlock, DeviceInfo.wSpectraEndBlock); + for (i = DeviceInfo.wSpectraStartBlock; i <= DeviceInfo.wSpectraEndBlock; i++) { + if (GLOB_LLD_Erase_Block(i)) + printk(KERN_ERR "Failed to force erase NAND block %d\n", i); + } + printk(KERN_ALERT "Force Erase ends. Please reboot the system ...\n"); + while(1); + + return PASS; +} + +int GLOB_FTL_Flash_Format(void) +{ + //return FTL_Format_Flash(1); + return force_format_nand(); + +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Search_Block_Table_IN_Block +* Inputs: Block Number +* Pointer to page +* Outputs: PASS / FAIL +* Page contatining the block table +* Description: It searches the block table in the block +* passed as an argument. +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static int FTL_Search_Block_Table_IN_Block(u32 BT_Block, + u8 BT_Tag, u16 *Page) +{ + u16 i, j, k; + u16 Result = PASS; + u16 Last_IPF = 0; + u8 BT_Found = 0; + u8 *tagarray; + u8 *tempbuf = tmp_buf_search_bt_in_block; + u8 *pSpareBuf = spare_buf_search_bt_in_block; + u8 *pSpareBufBTLastPage = spare_buf_bt_search_bt_in_block; + u8 bt_flag_last_page = 0xFF; + u8 search_in_previous_pages = 0; + u16 bt_pages; + + nand_dbg_print(NAND_DBG_DEBUG, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + nand_dbg_print(NAND_DBG_DEBUG, + "Searching block table in %u block\n", + (unsigned int)BT_Block); + + bt_pages = FTL_Get_Block_Table_Flash_Size_Pages(); + + for (i = bt_pages; i < DeviceInfo.wPagesPerBlock; + i += (bt_pages + 1)) { + nand_dbg_print(NAND_DBG_DEBUG, + "Searching last IPF: %d\n", i); + Result = GLOB_LLD_Read_Page_Main_Polling(tempbuf, + BT_Block, i, 1); + + if (0 == memcmp(tempbuf, g_pIPF, DeviceInfo.wPageDataSize)) { + if ((i + bt_pages + 1) < DeviceInfo.wPagesPerBlock) { + continue; + } else { + search_in_previous_pages = 1; + Last_IPF = i; + } + } + + if (!search_in_previous_pages) { + if (i != bt_pages) { + i -= (bt_pages + 1); + Last_IPF = i; + } + } + + if (0 == Last_IPF) + break; + + if (!search_in_previous_pages) { + i = i + 1; + nand_dbg_print(NAND_DBG_DEBUG, + "Reading the spare area of Block %u Page %u", + (unsigned int)BT_Block, i); + Result = GLOB_LLD_Read_Page_Spare(pSpareBuf, + BT_Block, i, 1); + nand_dbg_print(NAND_DBG_DEBUG, + "Reading the spare area of Block %u Page %u", + (unsigned int)BT_Block, i + bt_pages - 1); + Result = GLOB_LLD_Read_Page_Spare(pSpareBufBTLastPage, + BT_Block, i + bt_pages - 1, 1); + + k = 0; + j = FTL_Extract_Block_Table_Tag(pSpareBuf, &tagarray); + if (j) { + for (; k < j; k++) { + if (tagarray[k] == BT_Tag) + break; + } + } + + if (k < j) + bt_flag = tagarray[k]; + else + Result = FAIL; + + if (Result == PASS) { + k = 0; + j = FTL_Extract_Block_Table_Tag( + pSpareBufBTLastPage, &tagarray); + if (j) { + for (; k < j; k++) { + if (tagarray[k] == BT_Tag) + break; + } + } + + if (k < j) + bt_flag_last_page = tagarray[k]; + else + Result = FAIL; + + if (Result == PASS) { + if (bt_flag == bt_flag_last_page) { + nand_dbg_print(NAND_DBG_DEBUG, + "Block table is found" + " in page after IPF " + "at block %d " + "page %d\n", + (int)BT_Block, i); + BT_Found = 1; + *Page = i; + g_cBlockTableStatus = + CURRENT_BLOCK_TABLE; + break; + } else { + Result = FAIL; + } + } + } + } + + if (search_in_previous_pages) + i = i - bt_pages; + else + i = i - (bt_pages + 1); + + Result = PASS; + + nand_dbg_print(NAND_DBG_DEBUG, + "Reading the spare area of Block %d Page %d", + (int)BT_Block, i); + + Result = GLOB_LLD_Read_Page_Spare(pSpareBuf, BT_Block, i, 1); + nand_dbg_print(NAND_DBG_DEBUG, + "Reading the spare area of Block %u Page %u", + (unsigned int)BT_Block, i + bt_pages - 1); + + Result = GLOB_LLD_Read_Page_Spare(pSpareBufBTLastPage, + BT_Block, i + bt_pages - 1, 1); + + k = 0; + j = FTL_Extract_Block_Table_Tag(pSpareBuf, &tagarray); + if (j) { + for (; k < j; k++) { + if (tagarray[k] == BT_Tag) + break; + } + } + + if (k < j) + bt_flag = tagarray[k]; + else + Result = FAIL; + + if (Result == PASS) { + k = 0; + j = FTL_Extract_Block_Table_Tag(pSpareBufBTLastPage, + &tagarray); + if (j) { + for (; k < j; k++) { + if (tagarray[k] == BT_Tag) + break; + } + } + + if (k < j) { + bt_flag_last_page = tagarray[k]; + } else { + Result = FAIL; + break; + } + + if (Result == PASS) { + if (bt_flag == bt_flag_last_page) { + nand_dbg_print(NAND_DBG_DEBUG, + "Block table is found " + "in page prior to IPF " + "at block %u page %d\n", + (unsigned int)BT_Block, i); + BT_Found = 1; + *Page = i; + g_cBlockTableStatus = + IN_PROGRESS_BLOCK_TABLE; + break; + } else { + Result = FAIL; + break; + } + } + } + } + + if (Result == FAIL) { + if ((Last_IPF > bt_pages) && (i < Last_IPF) && (!BT_Found)) { + BT_Found = 1; + *Page = i - (bt_pages + 1); + } + if ((Last_IPF == bt_pages) && (i < Last_IPF) && (!BT_Found)) + goto func_return; + } + + if (Last_IPF == 0) { + i = 0; + Result = PASS; + nand_dbg_print(NAND_DBG_DEBUG, "Reading the spare area of " + "Block %u Page %u", (unsigned int)BT_Block, i); + + Result = GLOB_LLD_Read_Page_Spare(pSpareBuf, BT_Block, i, 1); + nand_dbg_print(NAND_DBG_DEBUG, + "Reading the spare area of Block %u Page %u", + (unsigned int)BT_Block, i + bt_pages - 1); + Result = GLOB_LLD_Read_Page_Spare(pSpareBufBTLastPage, + BT_Block, i + bt_pages - 1, 1); + + k = 0; + j = FTL_Extract_Block_Table_Tag(pSpareBuf, &tagarray); + if (j) { + for (; k < j; k++) { + if (tagarray[k] == BT_Tag) + break; + } + } + + if (k < j) + bt_flag = tagarray[k]; + else + Result = FAIL; + + if (Result == PASS) { + k = 0; + j = FTL_Extract_Block_Table_Tag(pSpareBufBTLastPage, + &tagarray); + if (j) { + for (; k < j; k++) { + if (tagarray[k] == BT_Tag) + break; + } + } + + if (k < j) + bt_flag_last_page = tagarray[k]; + else + Result = FAIL; + + if (Result == PASS) { + if (bt_flag == bt_flag_last_page) { + nand_dbg_print(NAND_DBG_DEBUG, + "Block table is found " + "in page after IPF at " + "block %u page %u\n", + (unsigned int)BT_Block, + (unsigned int)i); + BT_Found = 1; + *Page = i; + g_cBlockTableStatus = + CURRENT_BLOCK_TABLE; + goto func_return; + } else { + Result = FAIL; + } + } + } + + if (Result == FAIL) + goto func_return; + } +func_return: + return Result; +} + +u8 *get_blk_table_start_addr(void) +{ + return g_pBlockTable; +} + +unsigned long get_blk_table_len(void) +{ + return DeviceInfo.wDataBlockNum * sizeof(u32); +} + +u8 *get_wear_leveling_table_start_addr(void) +{ + return g_pWearCounter; +} + +unsigned long get_wear_leveling_table_len(void) +{ + return DeviceInfo.wDataBlockNum * sizeof(u8); +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Read_Block_Table +* Inputs: none +* Outputs: PASS / FAIL +* Description: read the flash spare area and find a block containing the +* most recent block table(having largest block_table_counter). +* Find the last written Block table in this block. +* Check the correctness of Block Table +* If CDMA is enabled, this function is called in +* polling mode. +* We don't need to store changes in Block table in this +* function as it is called only at initialization +* +* Note: Currently this function is called at initialization +* before any read/erase/write command issued to flash so, +* there is no need to wait for CDMA list to complete as of now +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static int FTL_Read_Block_Table(void) +{ + u16 i = 0; + int k, j; + u8 *tempBuf, *tagarray; + int wResult = FAIL; + int status = FAIL; + u8 block_table_found = 0; + int search_result; + u32 Block; + u16 Page = 0; + u16 PageCount; + u16 bt_pages; + int wBytesCopied = 0, tempvar; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + tempBuf = tmp_buf1_read_blk_table; + bt_pages = FTL_Get_Block_Table_Flash_Size_Pages(); + + for (j = DeviceInfo.wSpectraStartBlock; + j <= (int)DeviceInfo.wSpectraEndBlock; + j++) { + status = GLOB_LLD_Read_Page_Spare(tempBuf, j, 0, 1); + k = 0; + i = FTL_Extract_Block_Table_Tag(tempBuf, &tagarray); + if (i) { + status = GLOB_LLD_Read_Page_Main_Polling(tempBuf, + j, 0, 1); + for (; k < i; k++) { + if (tagarray[k] == tempBuf[3]) + break; + } + } + + if (k < i) + k = tagarray[k]; + else + continue; + + nand_dbg_print(NAND_DBG_DEBUG, + "Block table is contained in Block %d %d\n", + (unsigned int)j, (unsigned int)k); + + if (g_pBTBlocks[k-FIRST_BT_ID] == BTBLOCK_INVAL) { + g_pBTBlocks[k-FIRST_BT_ID] = j; + block_table_found = 1; + } else { + printk(KERN_ERR "FTL_Read_Block_Table -" + "This should never happens. " + "Two block table have same counter %u!\n", k); + } + } + + if (block_table_found) { + if (g_pBTBlocks[FIRST_BT_ID - FIRST_BT_ID] != BTBLOCK_INVAL && + g_pBTBlocks[LAST_BT_ID - FIRST_BT_ID] != BTBLOCK_INVAL) { + j = LAST_BT_ID; + while ((j > FIRST_BT_ID) && + (g_pBTBlocks[j - FIRST_BT_ID] != BTBLOCK_INVAL)) + j--; + if (j == FIRST_BT_ID) { + j = LAST_BT_ID; + last_erased = LAST_BT_ID; + } else { + last_erased = (u8)j + 1; + while ((j > FIRST_BT_ID) && (BTBLOCK_INVAL == + g_pBTBlocks[j - FIRST_BT_ID])) + j--; + } + } else { + j = FIRST_BT_ID; + while (g_pBTBlocks[j - FIRST_BT_ID] == BTBLOCK_INVAL) + j++; + last_erased = (u8)j; + while ((j < LAST_BT_ID) && (BTBLOCK_INVAL != + g_pBTBlocks[j - FIRST_BT_ID])) + j++; + if (g_pBTBlocks[j-FIRST_BT_ID] == BTBLOCK_INVAL) + j--; + } + + if (last_erased > j) + j += (1 + LAST_BT_ID - FIRST_BT_ID); + + for (; (j >= last_erased) && (FAIL == wResult); j--) { + i = (j - FIRST_BT_ID) % + (1 + LAST_BT_ID - FIRST_BT_ID); + search_result = + FTL_Search_Block_Table_IN_Block(g_pBTBlocks[i], + i + FIRST_BT_ID, &Page); + if (g_cBlockTableStatus == IN_PROGRESS_BLOCK_TABLE) + block_table_found = 0; + + while ((search_result == PASS) && (FAIL == wResult)) { + nand_dbg_print(NAND_DBG_DEBUG, + "FTL_Read_Block_Table:" + "Block: %u Page: %u " + "contains block table\n", + (unsigned int)g_pBTBlocks[i], + (unsigned int)Page); + + tempBuf = tmp_buf2_read_blk_table; + + for (k = 0; k < bt_pages; k++) { + Block = g_pBTBlocks[i]; + PageCount = 1; + + status = + GLOB_LLD_Read_Page_Main_Polling( + tempBuf, Block, Page, PageCount); + + tempvar = k ? 0 : 4; + + wBytesCopied += + FTL_Copy_Block_Table_From_Flash( + tempBuf + tempvar, + DeviceInfo.wPageDataSize - tempvar, + wBytesCopied); + + Page++; + } + + wResult = FTL_Check_Block_Table(FAIL); + if (FAIL == wResult) { + block_table_found = 0; + if (Page > bt_pages) + Page -= ((bt_pages<<1) + 1); + else + search_result = FAIL; + } + } + } + } + + if (PASS == wResult) { + if (!block_table_found) + FTL_Execute_SPL_Recovery(); + + if (g_cBlockTableStatus == IN_PROGRESS_BLOCK_TABLE) + g_wBlockTableOffset = (u16)Page + 1; + else + g_wBlockTableOffset = (u16)Page - bt_pages; + + g_wBlockTableIndex = (u32)g_pBTBlocks[i]; + +#if CMD_DMA + if (DeviceInfo.MLCDevice) + memcpy(g_pBTStartingCopy, g_pBlockTable, + DeviceInfo.wDataBlockNum * sizeof(u32) + + DeviceInfo.wDataBlockNum * sizeof(u8) + + DeviceInfo.wDataBlockNum * sizeof(u16)); + else + memcpy(g_pBTStartingCopy, g_pBlockTable, + DeviceInfo.wDataBlockNum * sizeof(u32) + + DeviceInfo.wDataBlockNum * sizeof(u8)); +#endif + } + + if (FAIL == wResult) + printk(KERN_ERR "Yunpeng - " + "Can not find valid spectra block table!\n"); + +#if AUTO_FORMAT_FLASH + if (FAIL == wResult) { + nand_dbg_print(NAND_DBG_DEBUG, "doing auto-format\n"); + wResult = FTL_Format_Flash(0); + } +#endif + + return wResult; +} + + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Flash_Error_Handle +* Inputs: Pointer to data +* Page address +* Block address +* Outputs: PASS=0 / FAIL=1 +* Description: It handles any error occured during Spectra operation +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static int FTL_Flash_Error_Handle(u8 *pData, u64 old_page_addr, + u64 blk_addr) +{ + u32 i; + int j; + u32 tmp_node, blk_node = BLK_FROM_ADDR(blk_addr); + u64 phy_addr; + int wErase = FAIL; + int wResult = FAIL; + u32 *pbt = (u32 *)g_pBlockTable; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (ERR == GLOB_FTL_Garbage_Collection()) + return ERR; + + do { + for (i = DeviceInfo.wSpectraEndBlock - + DeviceInfo.wSpectraStartBlock; + i > 0; i--) { + if (IS_SPARE_BLOCK(i)) { + tmp_node = (u32)(BAD_BLOCK | + pbt[blk_node]); + pbt[blk_node] = (u32)(pbt[i] & + (~SPARE_BLOCK)); + pbt[i] = tmp_node; +#if CMD_DMA + p_BTableChangesDelta = + (struct BTableChangesDelta *) + g_pBTDelta_Free; + g_pBTDelta_Free += + sizeof(struct BTableChangesDelta); + + p_BTableChangesDelta->ftl_cmd_cnt = + ftl_cmd_cnt; + p_BTableChangesDelta->BT_Index = + blk_node; + p_BTableChangesDelta->BT_Entry_Value = + pbt[blk_node]; + p_BTableChangesDelta->ValidFields = 0x0C; + + p_BTableChangesDelta = + (struct BTableChangesDelta *) + g_pBTDelta_Free; + g_pBTDelta_Free += + sizeof(struct BTableChangesDelta); + + p_BTableChangesDelta->ftl_cmd_cnt = + ftl_cmd_cnt; + p_BTableChangesDelta->BT_Index = i; + p_BTableChangesDelta->BT_Entry_Value = pbt[i]; + p_BTableChangesDelta->ValidFields = 0x0C; +#endif + wResult = PASS; + break; + } + } + + if (FAIL == wResult) { + if (FAIL == GLOB_FTL_Garbage_Collection()) + break; + else + continue; + } + + if (IN_PROGRESS_BLOCK_TABLE != g_cBlockTableStatus) { + g_cBlockTableStatus = IN_PROGRESS_BLOCK_TABLE; + FTL_Write_IN_Progress_Block_Table_Page(); + } + + phy_addr = FTL_Get_Physical_Block_Addr(blk_addr); + + for (j = 0; j < RETRY_TIMES; j++) { + if (PASS == wErase) { + if (FAIL == GLOB_FTL_Block_Erase(phy_addr)) { + MARK_BLOCK_AS_BAD(pbt[blk_node]); + break; + } + } + if (PASS == FTL_Cache_Update_Block(pData, + old_page_addr, + phy_addr)) { + wResult = PASS; + break; + } else { + wResult = FAIL; + wErase = PASS; + } + } + } while (FAIL == wResult); + + FTL_Write_Block_Table(FAIL); + + return wResult; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Get_Page_Num +* Inputs: Size in bytes +* Outputs: Size in pages +* Description: It calculates the pages required for the length passed +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static u32 FTL_Get_Page_Num(u64 length) +{ + return (u32)((length >> DeviceInfo.nBitsInPageDataSize) + + (GLOB_u64_Remainder(length , 1) > 0 ? 1 : 0)); +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Get_Physical_Block_Addr +* Inputs: Block Address (byte format) +* Outputs: Physical address of the block. +* Description: It translates LBA to PBA by returning address stored +* at the LBA location in the block table +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static u64 FTL_Get_Physical_Block_Addr(u64 logical_addr) +{ + u32 *pbt; + u64 physical_addr; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + pbt = (u32 *)g_pBlockTable; + physical_addr = (u64) DeviceInfo.wBlockDataSize * + (pbt[BLK_FROM_ADDR(logical_addr)] & (~BAD_BLOCK)); + + return physical_addr; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Get_Block_Index +* Inputs: Physical Block no. +* Outputs: Logical block no. /BAD_BLOCK +* Description: It returns the logical block no. for the PBA passed +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static u32 FTL_Get_Block_Index(u32 wBlockNum) +{ + u32 *pbt = (u32 *)g_pBlockTable; + u32 i; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + for (i = 0; i < DeviceInfo.wDataBlockNum; i++) + if (wBlockNum == (pbt[i] & (~BAD_BLOCK))) + return i; + + return BAD_BLOCK; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: GLOB_FTL_Wear_Leveling +* Inputs: none +* Outputs: PASS=0 +* Description: This is static wear leveling (done by explicit call) +* do complete static wear leveling +* do complete garbage collection +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int GLOB_FTL_Wear_Leveling(void) +{ + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + FTL_Static_Wear_Leveling(); + GLOB_FTL_Garbage_Collection(); + + return PASS; +} + +static void find_least_most_worn(u8 *chg, + u32 *least_idx, u8 *least_cnt, + u32 *most_idx, u8 *most_cnt) +{ + u32 *pbt = (u32 *)g_pBlockTable; + u32 idx; + u8 cnt; + int i; + + for (i = BLOCK_TABLE_INDEX + 1; i < DeviceInfo.wDataBlockNum; i++) { + if (IS_BAD_BLOCK(i) || PASS == chg[i]) + continue; + + idx = (u32) ((~BAD_BLOCK) & pbt[i]); + cnt = g_pWearCounter[idx - DeviceInfo.wSpectraStartBlock]; + + if (IS_SPARE_BLOCK(i)) { + if (cnt > *most_cnt) { + *most_cnt = cnt; + *most_idx = idx; + } + } + + if (IS_DATA_BLOCK(i)) { + if (cnt < *least_cnt) { + *least_cnt = cnt; + *least_idx = idx; + } + } + + if (PASS == chg[*most_idx] || PASS == chg[*least_idx]) { + debug_boundary_error(*most_idx, + DeviceInfo.wDataBlockNum, 0); + debug_boundary_error(*least_idx, + DeviceInfo.wDataBlockNum, 0); + continue; + } + } +} + +static int move_blks_for_wear_leveling(u8 *chg, + u32 *least_idx, u32 *rep_blk_num, int *result) +{ + u32 *pbt = (u32 *)g_pBlockTable; + u32 rep_blk; + int j, ret_cp_blk, ret_erase; + int ret = PASS; + + chg[*least_idx] = PASS; + debug_boundary_error(*least_idx, DeviceInfo.wDataBlockNum, 0); + + rep_blk = FTL_Replace_MWBlock(); + if (rep_blk != BAD_BLOCK) { + nand_dbg_print(NAND_DBG_DEBUG, + "More than two spare blocks exist so do it\n"); + nand_dbg_print(NAND_DBG_DEBUG, "Block Replaced is %d\n", + rep_blk); + + chg[rep_blk] = PASS; + + if (IN_PROGRESS_BLOCK_TABLE != g_cBlockTableStatus) { + g_cBlockTableStatus = IN_PROGRESS_BLOCK_TABLE; + FTL_Write_IN_Progress_Block_Table_Page(); + } + + for (j = 0; j < RETRY_TIMES; j++) { + ret_cp_blk = FTL_Copy_Block((u64)(*least_idx) * + DeviceInfo.wBlockDataSize, + (u64)rep_blk * DeviceInfo.wBlockDataSize); + if (FAIL == ret_cp_blk) { + ret_erase = GLOB_FTL_Block_Erase((u64)rep_blk + * DeviceInfo.wBlockDataSize); + if (FAIL == ret_erase) + MARK_BLOCK_AS_BAD(pbt[rep_blk]); + } else { + nand_dbg_print(NAND_DBG_DEBUG, + "FTL_Copy_Block == OK\n"); + break; + } + } + + if (j < RETRY_TIMES) { + u32 tmp; + u32 old_idx = FTL_Get_Block_Index(*least_idx); + u32 rep_idx = FTL_Get_Block_Index(rep_blk); + tmp = (u32)(DISCARD_BLOCK | pbt[old_idx]); + pbt[old_idx] = (u32)((~SPARE_BLOCK) & + pbt[rep_idx]); + pbt[rep_idx] = tmp; +#if CMD_DMA + p_BTableChangesDelta = (struct BTableChangesDelta *) + g_pBTDelta_Free; + g_pBTDelta_Free += sizeof(struct BTableChangesDelta); + p_BTableChangesDelta->ftl_cmd_cnt = + ftl_cmd_cnt; + p_BTableChangesDelta->BT_Index = old_idx; + p_BTableChangesDelta->BT_Entry_Value = pbt[old_idx]; + p_BTableChangesDelta->ValidFields = 0x0C; + + p_BTableChangesDelta = (struct BTableChangesDelta *) + g_pBTDelta_Free; + g_pBTDelta_Free += sizeof(struct BTableChangesDelta); + + p_BTableChangesDelta->ftl_cmd_cnt = + ftl_cmd_cnt; + p_BTableChangesDelta->BT_Index = rep_idx; + p_BTableChangesDelta->BT_Entry_Value = pbt[rep_idx]; + p_BTableChangesDelta->ValidFields = 0x0C; +#endif + } else { + pbt[FTL_Get_Block_Index(rep_blk)] |= BAD_BLOCK; +#if CMD_DMA + p_BTableChangesDelta = (struct BTableChangesDelta *) + g_pBTDelta_Free; + g_pBTDelta_Free += sizeof(struct BTableChangesDelta); + + p_BTableChangesDelta->ftl_cmd_cnt = + ftl_cmd_cnt; + p_BTableChangesDelta->BT_Index = + FTL_Get_Block_Index(rep_blk); + p_BTableChangesDelta->BT_Entry_Value = + pbt[FTL_Get_Block_Index(rep_blk)]; + p_BTableChangesDelta->ValidFields = 0x0C; +#endif + *result = FAIL; + ret = FAIL; + } + + if (((*rep_blk_num)++) > WEAR_LEVELING_BLOCK_NUM) + ret = FAIL; + } else { + printk(KERN_ERR "Less than 3 spare blocks exist so quit\n"); + ret = FAIL; + } + + return ret; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Static_Wear_Leveling +* Inputs: none +* Outputs: PASS=0 / FAIL=1 +* Description: This is static wear leveling (done by explicit call) +* search for most&least used +* if difference < GATE: +* update the block table with exhange +* mark block table in flash as IN_PROGRESS +* copy flash block +* the caller should handle GC clean up after calling this function +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int FTL_Static_Wear_Leveling(void) +{ + u8 most_worn_cnt; + u8 least_worn_cnt; + u32 most_worn_idx; + u32 least_worn_idx; + int result = PASS; + int go_on = PASS; + u32 replaced_blks = 0; + u8 *chang_flag = flags_static_wear_leveling; + + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (!chang_flag) + return FAIL; + + memset(chang_flag, FAIL, DeviceInfo.wDataBlockNum); + while (go_on == PASS) { + nand_dbg_print(NAND_DBG_DEBUG, + "starting static wear leveling\n"); + most_worn_cnt = 0; + least_worn_cnt = 0xFF; + least_worn_idx = BLOCK_TABLE_INDEX; + most_worn_idx = BLOCK_TABLE_INDEX; + + find_least_most_worn(chang_flag, &least_worn_idx, + &least_worn_cnt, &most_worn_idx, &most_worn_cnt); + + nand_dbg_print(NAND_DBG_DEBUG, + "Used and least worn is block %u, whos count is %u\n", + (unsigned int)least_worn_idx, + (unsigned int)least_worn_cnt); + + nand_dbg_print(NAND_DBG_DEBUG, + "Free and most worn is block %u, whos count is %u\n", + (unsigned int)most_worn_idx, + (unsigned int)most_worn_cnt); + + if ((most_worn_cnt > least_worn_cnt) && + (most_worn_cnt - least_worn_cnt > WEAR_LEVELING_GATE)) + go_on = move_blks_for_wear_leveling(chang_flag, + &least_worn_idx, &replaced_blks, &result); + else + go_on = FAIL; + } + + return result; +} + +#if CMD_DMA +static int do_garbage_collection(u32 discard_cnt) +{ + u32 *pbt = (u32 *)g_pBlockTable; + u32 pba; + u8 bt_block_erased = 0; + int i, cnt, ret = FAIL; + u64 addr; + + i = 0; + while ((i < DeviceInfo.wDataBlockNum) && (discard_cnt > 0) && + ((ftl_cmd_cnt + 28) < 256)) { + if (((pbt[i] & BAD_BLOCK) != BAD_BLOCK) && + (pbt[i] & DISCARD_BLOCK)) { + if (IN_PROGRESS_BLOCK_TABLE != g_cBlockTableStatus) { + g_cBlockTableStatus = IN_PROGRESS_BLOCK_TABLE; + FTL_Write_IN_Progress_Block_Table_Page(); + } + + addr = FTL_Get_Physical_Block_Addr((u64)i * + DeviceInfo.wBlockDataSize); + pba = BLK_FROM_ADDR(addr); + + for (cnt = FIRST_BT_ID; cnt <= LAST_BT_ID; cnt++) { + if (pba == g_pBTBlocks[cnt - FIRST_BT_ID]) { + nand_dbg_print(NAND_DBG_DEBUG, + "GC will erase BT block %u\n", + (unsigned int)pba); + discard_cnt--; + i++; + bt_block_erased = 1; + break; + } + } + + if (bt_block_erased) { + bt_block_erased = 0; + continue; + } + + addr = FTL_Get_Physical_Block_Addr((u64)i * + DeviceInfo.wBlockDataSize); + + if (PASS == GLOB_FTL_Block_Erase(addr)) { + pbt[i] &= (u32)(~DISCARD_BLOCK); + pbt[i] |= (u32)(SPARE_BLOCK); + p_BTableChangesDelta = + (struct BTableChangesDelta *) + g_pBTDelta_Free; + g_pBTDelta_Free += + sizeof(struct BTableChangesDelta); + p_BTableChangesDelta->ftl_cmd_cnt = + ftl_cmd_cnt - 1; + p_BTableChangesDelta->BT_Index = i; + p_BTableChangesDelta->BT_Entry_Value = pbt[i]; + p_BTableChangesDelta->ValidFields = 0x0C; + discard_cnt--; + ret = PASS; + } else { + MARK_BLOCK_AS_BAD(pbt[i]); + } + } + + i++; + } + + return ret; +} + +#else +static int do_garbage_collection(u32 discard_cnt) +{ + u32 *pbt = (u32 *)g_pBlockTable; + u32 pba; + u8 bt_block_erased = 0; + int i, cnt, ret = FAIL; + u64 addr; + + i = 0; + while ((i < DeviceInfo.wDataBlockNum) && (discard_cnt > 0)) { + if (((pbt[i] & BAD_BLOCK) != BAD_BLOCK) && + (pbt[i] & DISCARD_BLOCK)) { + if (IN_PROGRESS_BLOCK_TABLE != g_cBlockTableStatus) { + g_cBlockTableStatus = IN_PROGRESS_BLOCK_TABLE; + FTL_Write_IN_Progress_Block_Table_Page(); + } + + addr = FTL_Get_Physical_Block_Addr((u64)i * + DeviceInfo.wBlockDataSize); + pba = BLK_FROM_ADDR(addr); + + for (cnt = FIRST_BT_ID; cnt <= LAST_BT_ID; cnt++) { + if (pba == g_pBTBlocks[cnt - FIRST_BT_ID]) { + nand_dbg_print(NAND_DBG_DEBUG, + "GC will erase BT block %d\n", + pba); + discard_cnt--; + i++; + bt_block_erased = 1; + break; + } + } + + if (bt_block_erased) { + bt_block_erased = 0; + continue; + } + + /* If the discard block is L2 cache block, then just skip it */ + for (cnt = 0; cnt < BLK_NUM_FOR_L2_CACHE; cnt++) { + if (cache_l2.blk_array[cnt] == pba) { + nand_dbg_print(NAND_DBG_DEBUG, + "GC will erase L2 cache blk %d\n", + pba); + break; + } + } + if (cnt < BLK_NUM_FOR_L2_CACHE) { /* Skip it */ + discard_cnt--; + i++; + continue; + } + + addr = FTL_Get_Physical_Block_Addr((u64)i * + DeviceInfo.wBlockDataSize); + + if (PASS == GLOB_FTL_Block_Erase(addr)) { + pbt[i] &= (u32)(~DISCARD_BLOCK); + pbt[i] |= (u32)(SPARE_BLOCK); + discard_cnt--; + ret = PASS; + } else { + MARK_BLOCK_AS_BAD(pbt[i]); + } + } + + i++; + } + + return ret; +} +#endif + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: GLOB_FTL_Garbage_Collection +* Inputs: none +* Outputs: PASS / FAIL (returns the number of un-erased blocks +* Description: search the block table for all discarded blocks to erase +* for each discarded block: +* set the flash block to IN_PROGRESS +* erase the block +* update the block table +* write the block table to flash +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int GLOB_FTL_Garbage_Collection(void) +{ + u32 i; + u32 wDiscard = 0; + int wResult = FAIL; + u32 *pbt = (u32 *)g_pBlockTable; + + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (GC_Called) { + printk(KERN_ALERT "GLOB_FTL_Garbage_Collection() " + "has been re-entered! Exit.\n"); + return PASS; + } + + GC_Called = 1; + + GLOB_FTL_BT_Garbage_Collection(); + + for (i = 0; i < DeviceInfo.wDataBlockNum; i++) { + if (IS_DISCARDED_BLOCK(i)) + wDiscard++; + } + + if (wDiscard <= 0) { + GC_Called = 0; + return wResult; + } + + nand_dbg_print(NAND_DBG_DEBUG, + "Found %d discarded blocks\n", wDiscard); + + FTL_Write_Block_Table(FAIL); + + wResult = do_garbage_collection(wDiscard); + + FTL_Write_Block_Table(FAIL); + + GC_Called = 0; + + return wResult; +} + + +#if CMD_DMA +static int do_bt_garbage_collection(void) +{ + u32 pba, lba; + u32 *pbt = (u32 *)g_pBlockTable; + u32 *pBTBlocksNode = (u32 *)g_pBTBlocks; + u64 addr; + int i, ret = FAIL; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (BT_GC_Called) + return PASS; + + BT_GC_Called = 1; + + for (i = last_erased; (i <= LAST_BT_ID) && + (g_pBTBlocks[((i + 2) % (1 + LAST_BT_ID - FIRST_BT_ID)) + + FIRST_BT_ID - FIRST_BT_ID] != BTBLOCK_INVAL) && + ((ftl_cmd_cnt + 28)) < 256; i++) { + pba = pBTBlocksNode[i - FIRST_BT_ID]; + lba = FTL_Get_Block_Index(pba); + nand_dbg_print(NAND_DBG_DEBUG, + "do_bt_garbage_collection: pba %d, lba %d\n", + pba, lba); + nand_dbg_print(NAND_DBG_DEBUG, + "Block Table Entry: %d", pbt[lba]); + + if (((pbt[lba] & BAD_BLOCK) != BAD_BLOCK) && + (pbt[lba] & DISCARD_BLOCK)) { + nand_dbg_print(NAND_DBG_DEBUG, + "do_bt_garbage_collection_cdma: " + "Erasing Block tables present in block %d\n", + pba); + addr = FTL_Get_Physical_Block_Addr((u64)lba * + DeviceInfo.wBlockDataSize); + if (PASS == GLOB_FTL_Block_Erase(addr)) { + pbt[lba] &= (u32)(~DISCARD_BLOCK); + pbt[lba] |= (u32)(SPARE_BLOCK); + + p_BTableChangesDelta = + (struct BTableChangesDelta *) + g_pBTDelta_Free; + g_pBTDelta_Free += + sizeof(struct BTableChangesDelta); + + p_BTableChangesDelta->ftl_cmd_cnt = + ftl_cmd_cnt - 1; + p_BTableChangesDelta->BT_Index = lba; + p_BTableChangesDelta->BT_Entry_Value = + pbt[lba]; + + p_BTableChangesDelta->ValidFields = 0x0C; + + ret = PASS; + pBTBlocksNode[last_erased - FIRST_BT_ID] = + BTBLOCK_INVAL; + nand_dbg_print(NAND_DBG_DEBUG, + "resetting bt entry at index %d " + "value %d\n", i, + pBTBlocksNode[i - FIRST_BT_ID]); + if (last_erased == LAST_BT_ID) + last_erased = FIRST_BT_ID; + else + last_erased++; + } else { + MARK_BLOCK_AS_BAD(pbt[lba]); + } + } + } + + BT_GC_Called = 0; + + return ret; +} + +#else +static int do_bt_garbage_collection(void) +{ + u32 pba, lba; + u32 *pbt = (u32 *)g_pBlockTable; + u32 *pBTBlocksNode = (u32 *)g_pBTBlocks; + u64 addr; + int i, ret = FAIL; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (BT_GC_Called) + return PASS; + + BT_GC_Called = 1; + + for (i = last_erased; (i <= LAST_BT_ID) && + (g_pBTBlocks[((i + 2) % (1 + LAST_BT_ID - FIRST_BT_ID)) + + FIRST_BT_ID - FIRST_BT_ID] != BTBLOCK_INVAL); i++) { + pba = pBTBlocksNode[i - FIRST_BT_ID]; + lba = FTL_Get_Block_Index(pba); + nand_dbg_print(NAND_DBG_DEBUG, + "do_bt_garbage_collection_cdma: pba %d, lba %d\n", + pba, lba); + nand_dbg_print(NAND_DBG_DEBUG, + "Block Table Entry: %d", pbt[lba]); + + if (((pbt[lba] & BAD_BLOCK) != BAD_BLOCK) && + (pbt[lba] & DISCARD_BLOCK)) { + nand_dbg_print(NAND_DBG_DEBUG, + "do_bt_garbage_collection: " + "Erasing Block tables present in block %d\n", + pba); + addr = FTL_Get_Physical_Block_Addr((u64)lba * + DeviceInfo.wBlockDataSize); + if (PASS == GLOB_FTL_Block_Erase(addr)) { + pbt[lba] &= (u32)(~DISCARD_BLOCK); + pbt[lba] |= (u32)(SPARE_BLOCK); + ret = PASS; + pBTBlocksNode[last_erased - FIRST_BT_ID] = + BTBLOCK_INVAL; + nand_dbg_print(NAND_DBG_DEBUG, + "resetting bt entry at index %d " + "value %d\n", i, + pBTBlocksNode[i - FIRST_BT_ID]); + if (last_erased == LAST_BT_ID) + last_erased = FIRST_BT_ID; + else + last_erased++; + } else { + MARK_BLOCK_AS_BAD(pbt[lba]); + } + } + } + + BT_GC_Called = 0; + + return ret; +} + +#endif + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: GLOB_FTL_BT_Garbage_Collection +* Inputs: none +* Outputs: PASS / FAIL (returns the number of un-erased blocks +* Description: Erases discarded blocks containing Block table +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int GLOB_FTL_BT_Garbage_Collection(void) +{ + return do_bt_garbage_collection(); +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Replace_OneBlock +* Inputs: Block number 1 +* Block number 2 +* Outputs: Replaced Block Number +* Description: Interchange block table entries at wBlockNum and wReplaceNum +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static u32 FTL_Replace_OneBlock(u32 blk, u32 rep_blk) +{ + u32 tmp_blk; + u32 replace_node = BAD_BLOCK; + u32 *pbt = (u32 *)g_pBlockTable; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (rep_blk != BAD_BLOCK) { + if (IS_BAD_BLOCK(blk)) + tmp_blk = pbt[blk]; + else + tmp_blk = DISCARD_BLOCK | (~SPARE_BLOCK & pbt[blk]); + + replace_node = (u32) ((~SPARE_BLOCK) & pbt[rep_blk]); + pbt[blk] = replace_node; + pbt[rep_blk] = tmp_blk; + +#if CMD_DMA + p_BTableChangesDelta = + (struct BTableChangesDelta *)g_pBTDelta_Free; + g_pBTDelta_Free += sizeof(struct BTableChangesDelta); + + p_BTableChangesDelta->ftl_cmd_cnt = ftl_cmd_cnt; + p_BTableChangesDelta->BT_Index = blk; + p_BTableChangesDelta->BT_Entry_Value = pbt[blk]; + + p_BTableChangesDelta->ValidFields = 0x0C; + + p_BTableChangesDelta = + (struct BTableChangesDelta *)g_pBTDelta_Free; + g_pBTDelta_Free += sizeof(struct BTableChangesDelta); + + p_BTableChangesDelta->ftl_cmd_cnt = ftl_cmd_cnt; + p_BTableChangesDelta->BT_Index = rep_blk; + p_BTableChangesDelta->BT_Entry_Value = pbt[rep_blk]; + p_BTableChangesDelta->ValidFields = 0x0C; +#endif + } + + return replace_node; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Write_Block_Table_Data +* Inputs: Block table size in pages +* Outputs: PASS=0 / FAIL=1 +* Description: Write block table data in flash +* If first page and last page +* Write data+BT flag +* else +* Write data +* BT flag is a counter. Its value is incremented for block table +* write in a new Block +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static int FTL_Write_Block_Table_Data(void) +{ + u64 dwBlockTableAddr, pTempAddr; + u32 Block; + u16 Page, PageCount; + u8 *tempBuf = tmp_buf_write_blk_table_data; + int wBytesCopied; + u16 bt_pages; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + dwBlockTableAddr = + (u64)((u64)g_wBlockTableIndex * DeviceInfo.wBlockDataSize + + (u64)g_wBlockTableOffset * DeviceInfo.wPageDataSize); + pTempAddr = dwBlockTableAddr; + + bt_pages = FTL_Get_Block_Table_Flash_Size_Pages(); + + nand_dbg_print(NAND_DBG_DEBUG, "FTL_Write_Block_Table_Data: " + "page= %d BlockTableIndex= %d " + "BlockTableOffset=%d\n", bt_pages, + g_wBlockTableIndex, g_wBlockTableOffset); + + Block = BLK_FROM_ADDR(pTempAddr); + Page = PAGE_FROM_ADDR(pTempAddr, Block); + PageCount = 1; + + if (bt_block_changed) { + if (bt_flag == LAST_BT_ID) { + bt_flag = FIRST_BT_ID; + g_pBTBlocks[bt_flag - FIRST_BT_ID] = Block; + } else if (bt_flag < LAST_BT_ID) { + bt_flag++; + g_pBTBlocks[bt_flag - FIRST_BT_ID] = Block; + } + + if ((bt_flag > (LAST_BT_ID-4)) && + g_pBTBlocks[FIRST_BT_ID - FIRST_BT_ID] != + BTBLOCK_INVAL) { + bt_block_changed = 0; + GLOB_FTL_BT_Garbage_Collection(); + } + + bt_block_changed = 0; + nand_dbg_print(NAND_DBG_DEBUG, + "Block Table Counter is %u Block %u\n", + bt_flag, (unsigned int)Block); + } + + memset(tempBuf, 0, 3); + tempBuf[3] = bt_flag; + wBytesCopied = FTL_Copy_Block_Table_To_Flash(tempBuf + 4, + DeviceInfo.wPageDataSize - 4, 0); + memset(&tempBuf[wBytesCopied + 4], 0xff, + DeviceInfo.wPageSize - (wBytesCopied + 4)); + FTL_Insert_Block_Table_Signature(&tempBuf[DeviceInfo.wPageDataSize], + bt_flag); + +#if CMD_DMA + memcpy(g_pNextBlockTable, tempBuf, + DeviceInfo.wPageSize * sizeof(u8)); + nand_dbg_print(NAND_DBG_DEBUG, "Writing First Page of Block Table " + "Block %u Page %u\n", (unsigned int)Block, Page); + if (FAIL == GLOB_LLD_Write_Page_Main_Spare_cdma(g_pNextBlockTable, + Block, Page, 1, + LLD_CMD_FLAG_MODE_CDMA | LLD_CMD_FLAG_ORDER_BEFORE_REST)) { + nand_dbg_print(NAND_DBG_WARN, "NAND Program fail in " + "%s, Line %d, Function: %s, " + "new Bad Block %d generated!\n", + __FILE__, __LINE__, __func__, Block); + goto func_return; + } + + ftl_cmd_cnt++; + g_pNextBlockTable += ((DeviceInfo.wPageSize * sizeof(u8))); +#else + if (FAIL == GLOB_LLD_Write_Page_Main_Spare(tempBuf, Block, Page, 1)) { + nand_dbg_print(NAND_DBG_WARN, + "NAND Program fail in %s, Line %d, Function: %s, " + "new Bad Block %d generated!\n", + __FILE__, __LINE__, __func__, Block); + goto func_return; + } +#endif + + if (bt_pages > 1) { + PageCount = bt_pages - 1; + if (PageCount > 1) { + wBytesCopied += FTL_Copy_Block_Table_To_Flash(tempBuf, + DeviceInfo.wPageDataSize * (PageCount - 1), + wBytesCopied); + +#if CMD_DMA + memcpy(g_pNextBlockTable, tempBuf, + (PageCount - 1) * DeviceInfo.wPageDataSize); + if (FAIL == GLOB_LLD_Write_Page_Main_cdma( + g_pNextBlockTable, Block, Page + 1, + PageCount - 1)) { + nand_dbg_print(NAND_DBG_WARN, + "NAND Program fail in %s, Line %d, " + "Function: %s, " + "new Bad Block %d generated!\n", + __FILE__, __LINE__, __func__, + (int)Block); + goto func_return; + } + + ftl_cmd_cnt++; + g_pNextBlockTable += (PageCount - 1) * + DeviceInfo.wPageDataSize * sizeof(u8); +#else + if (FAIL == GLOB_LLD_Write_Page_Main(tempBuf, + Block, Page + 1, PageCount - 1)) { + nand_dbg_print(NAND_DBG_WARN, + "NAND Program fail in %s, Line %d, " + "Function: %s, " + "new Bad Block %d generated!\n", + __FILE__, __LINE__, __func__, + (int)Block); + goto func_return; + } +#endif + } + + wBytesCopied = FTL_Copy_Block_Table_To_Flash(tempBuf, + DeviceInfo.wPageDataSize, wBytesCopied); + memset(&tempBuf[wBytesCopied], 0xff, + DeviceInfo.wPageSize-wBytesCopied); + FTL_Insert_Block_Table_Signature( + &tempBuf[DeviceInfo.wPageDataSize], bt_flag); +#if CMD_DMA + memcpy(g_pNextBlockTable, tempBuf, + DeviceInfo.wPageSize * sizeof(u8)); + nand_dbg_print(NAND_DBG_DEBUG, + "Writing the last Page of Block Table " + "Block %u Page %u\n", + (unsigned int)Block, Page + bt_pages - 1); + if (FAIL == GLOB_LLD_Write_Page_Main_Spare_cdma( + g_pNextBlockTable, Block, Page + bt_pages - 1, 1, + LLD_CMD_FLAG_MODE_CDMA | + LLD_CMD_FLAG_ORDER_BEFORE_REST)) { + nand_dbg_print(NAND_DBG_WARN, + "NAND Program fail in %s, Line %d, " + "Function: %s, new Bad Block %d generated!\n", + __FILE__, __LINE__, __func__, Block); + goto func_return; + } + ftl_cmd_cnt++; +#else + if (FAIL == GLOB_LLD_Write_Page_Main_Spare(tempBuf, + Block, Page+bt_pages - 1, 1)) { + nand_dbg_print(NAND_DBG_WARN, + "NAND Program fail in %s, Line %d, " + "Function: %s, " + "new Bad Block %d generated!\n", + __FILE__, __LINE__, __func__, Block); + goto func_return; + } +#endif + } + + nand_dbg_print(NAND_DBG_DEBUG, "FTL_Write_Block_Table_Data: done\n"); + +func_return: + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Replace_Block_Table +* Inputs: None +* Outputs: PASS=0 / FAIL=1 +* Description: Get a new block to write block table +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static u32 FTL_Replace_Block_Table(void) +{ + u32 blk; + int gc; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + blk = FTL_Replace_LWBlock(BLOCK_TABLE_INDEX, &gc); + + if ((BAD_BLOCK == blk) && (PASS == gc)) { + GLOB_FTL_Garbage_Collection(); + blk = FTL_Replace_LWBlock(BLOCK_TABLE_INDEX, &gc); + } + if (BAD_BLOCK == blk) + printk(KERN_ERR "%s, %s: There is no spare block. " + "It should never happen\n", + __FILE__, __func__); + + nand_dbg_print(NAND_DBG_DEBUG, "New Block table Block is %d\n", blk); + + return blk; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Replace_LWBlock +* Inputs: Block number +* Pointer to Garbage Collect flag +* Outputs: +* Description: Determine the least weared block by traversing +* block table +* Set Garbage collection to be called if number of spare +* block is less than Free Block Gate count +* Change Block table entry to map least worn block for current +* operation +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static u32 FTL_Replace_LWBlock(u32 wBlockNum, int *pGarbageCollect) +{ + u32 i; + u32 *pbt = (u32 *)g_pBlockTable; + u8 wLeastWornCounter = 0xFF; + u32 wLeastWornIndex = BAD_BLOCK; + u32 wSpareBlockNum = 0; + u32 wDiscardBlockNum = 0; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (IS_SPARE_BLOCK(wBlockNum)) { + *pGarbageCollect = FAIL; + pbt[wBlockNum] = (u32)(pbt[wBlockNum] & (~SPARE_BLOCK)); +#if CMD_DMA + p_BTableChangesDelta = + (struct BTableChangesDelta *)g_pBTDelta_Free; + g_pBTDelta_Free += sizeof(struct BTableChangesDelta); + p_BTableChangesDelta->ftl_cmd_cnt = + ftl_cmd_cnt; + p_BTableChangesDelta->BT_Index = (u32)(wBlockNum); + p_BTableChangesDelta->BT_Entry_Value = pbt[wBlockNum]; + p_BTableChangesDelta->ValidFields = 0x0C; +#endif + return pbt[wBlockNum]; + } + + for (i = 0; i < DeviceInfo.wDataBlockNum; i++) { + if (IS_DISCARDED_BLOCK(i)) + wDiscardBlockNum++; + + if (IS_SPARE_BLOCK(i)) { + u32 wPhysicalIndex = (u32)((~BAD_BLOCK) & pbt[i]); + if (wPhysicalIndex > DeviceInfo.wSpectraEndBlock) + printk(KERN_ERR "FTL_Replace_LWBlock: " + "This should never occur!\n"); + if (g_pWearCounter[wPhysicalIndex - + DeviceInfo.wSpectraStartBlock] < + wLeastWornCounter) { + wLeastWornCounter = + g_pWearCounter[wPhysicalIndex - + DeviceInfo.wSpectraStartBlock]; + wLeastWornIndex = i; + } + wSpareBlockNum++; + } + } + + nand_dbg_print(NAND_DBG_WARN, + "FTL_Replace_LWBlock: Least Worn Counter %d\n", + (int)wLeastWornCounter); + + if ((wDiscardBlockNum >= NUM_FREE_BLOCKS_GATE) || + (wSpareBlockNum <= NUM_FREE_BLOCKS_GATE)) + *pGarbageCollect = PASS; + else + *pGarbageCollect = FAIL; + + nand_dbg_print(NAND_DBG_DEBUG, + "FTL_Replace_LWBlock: Discarded Blocks %u Spare" + " Blocks %u\n", + (unsigned int)wDiscardBlockNum, + (unsigned int)wSpareBlockNum); + + return FTL_Replace_OneBlock(wBlockNum, wLeastWornIndex); +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Replace_MWBlock +* Inputs: None +* Outputs: most worn spare block no./BAD_BLOCK +* Description: It finds most worn spare block. +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static u32 FTL_Replace_MWBlock(void) +{ + u32 i; + u32 *pbt = (u32 *)g_pBlockTable; + u8 wMostWornCounter = 0; + u32 wMostWornIndex = BAD_BLOCK; + u32 wSpareBlockNum = 0; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + for (i = 0; i < DeviceInfo.wDataBlockNum; i++) { + if (IS_SPARE_BLOCK(i)) { + u32 wPhysicalIndex = (u32)((~SPARE_BLOCK) & pbt[i]); + if (g_pWearCounter[wPhysicalIndex - + DeviceInfo.wSpectraStartBlock] > + wMostWornCounter) { + wMostWornCounter = + g_pWearCounter[wPhysicalIndex - + DeviceInfo.wSpectraStartBlock]; + wMostWornIndex = wPhysicalIndex; + } + wSpareBlockNum++; + } + } + + if (wSpareBlockNum <= 2) + return BAD_BLOCK; + + return wMostWornIndex; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Replace_Block +* Inputs: Block Address +* Outputs: PASS=0 / FAIL=1 +* Description: If block specified by blk_addr parameter is not free, +* replace it with the least worn block. +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static int FTL_Replace_Block(u64 blk_addr) +{ + u32 current_blk = BLK_FROM_ADDR(blk_addr); + u32 *pbt = (u32 *)g_pBlockTable; + int wResult = PASS; + int GarbageCollect = FAIL; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (IS_SPARE_BLOCK(current_blk)) { + pbt[current_blk] = (~SPARE_BLOCK) & pbt[current_blk]; +#if CMD_DMA + p_BTableChangesDelta = + (struct BTableChangesDelta *)g_pBTDelta_Free; + g_pBTDelta_Free += sizeof(struct BTableChangesDelta); + p_BTableChangesDelta->ftl_cmd_cnt = + ftl_cmd_cnt; + p_BTableChangesDelta->BT_Index = current_blk; + p_BTableChangesDelta->BT_Entry_Value = pbt[current_blk]; + p_BTableChangesDelta->ValidFields = 0x0C ; +#endif + return wResult; + } + + FTL_Replace_LWBlock(current_blk, &GarbageCollect); + + if (PASS == GarbageCollect) + wResult = GLOB_FTL_Garbage_Collection(); + + return wResult; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: GLOB_FTL_Is_BadBlock +* Inputs: block number to test +* Outputs: PASS (block is BAD) / FAIL (block is not bad) +* Description: test if this block number is flagged as bad +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int GLOB_FTL_Is_BadBlock(u32 wBlockNum) +{ + u32 *pbt = (u32 *)g_pBlockTable; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (wBlockNum >= DeviceInfo.wSpectraStartBlock + && BAD_BLOCK == (pbt[wBlockNum] & BAD_BLOCK)) + return PASS; + else + return FAIL; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: GLOB_FTL_Flush_Cache +* Inputs: none +* Outputs: PASS=0 / FAIL=1 +* Description: flush all the cache blocks to flash +* if a cache block is not dirty, don't do anything with it +* else, write the block and update the block table +* Note: This function should be called at shutdown/power down. +* to write important data into device +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int GLOB_FTL_Flush_Cache(void) +{ + int i, ret; + + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + for (i = 0; i < CACHE_ITEM_NUM; i++) { + if (SET == Cache.array[i].changed) { +#if CMD_DMA +#if RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE + int_cache[ftl_cmd_cnt].item = i; + int_cache[ftl_cmd_cnt].cache.address = + Cache.array[i].address; + int_cache[ftl_cmd_cnt].cache.changed = CLEAR; +#endif +#endif + ret = write_back_to_l2_cache(Cache.array[i].buf, Cache.array[i].address); + if (PASS == ret) { + Cache.array[i].changed = CLEAR; + } else { + printk(KERN_ALERT "Failed when write back to L2 cache!\n"); + /* TODO - How to handle this? */ + } + } + } + + flush_l2_cache(); + + return FTL_Write_Block_Table(FAIL); +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: GLOB_FTL_Page_Read +* Inputs: pointer to data +* logical address of data (u64 is LBA * Bytes/Page) +* Outputs: PASS=0 / FAIL=1 +* Description: reads a page of data into RAM from the cache +* if the data is not already in cache, read from flash to cache +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int GLOB_FTL_Page_Read(u8 *data, u64 logical_addr) +{ + u16 cache_item; + int res = PASS; + + nand_dbg_print(NAND_DBG_DEBUG, "GLOB_FTL_Page_Read - " + "page_addr: %llu\n", logical_addr); + + cache_item = FTL_Cache_If_Hit(logical_addr); + + if (UNHIT_CACHE_ITEM == cache_item) { + nand_dbg_print(NAND_DBG_DEBUG, + "GLOB_FTL_Page_Read: Cache not hit\n"); + res = FTL_Cache_Write(); + if (ERR == FTL_Cache_Read(logical_addr)) + res = ERR; + cache_item = Cache.LRU; + } + + FTL_Cache_Read_Page(data, logical_addr, cache_item); + + return res; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: GLOB_FTL_Page_Write +* Inputs: pointer to data +* address of data (ADDRESSTYPE is LBA * Bytes/Page) +* Outputs: PASS=0 / FAIL=1 +* Description: writes a page of data from RAM to the cache +* if the data is not already in cache, write back the +* least recently used block and read the addressed block +* from flash to cache +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int GLOB_FTL_Page_Write(u8 *pData, u64 dwPageAddr) +{ + u16 cache_blk; + u32 *pbt = (u32 *)g_pBlockTable; + int wResult = PASS; + + nand_dbg_print(NAND_DBG_TRACE, "GLOB_FTL_Page_Write - " + "dwPageAddr: %llu\n", dwPageAddr); + + cache_blk = FTL_Cache_If_Hit(dwPageAddr); + + if (UNHIT_CACHE_ITEM == cache_blk) { + wResult = FTL_Cache_Write(); + if (IS_BAD_BLOCK(BLK_FROM_ADDR(dwPageAddr))) { + wResult = FTL_Replace_Block(dwPageAddr); + pbt[BLK_FROM_ADDR(dwPageAddr)] |= SPARE_BLOCK; + if (wResult == FAIL) + return FAIL; + } + if (ERR == FTL_Cache_Read(dwPageAddr)) + wResult = ERR; + cache_blk = Cache.LRU; + FTL_Cache_Write_Page(pData, dwPageAddr, cache_blk, 0); + } else { +#if CMD_DMA + FTL_Cache_Write_Page(pData, dwPageAddr, cache_blk, + LLD_CMD_FLAG_ORDER_BEFORE_REST); +#else + FTL_Cache_Write_Page(pData, dwPageAddr, cache_blk, 0); +#endif + } + + return wResult; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: GLOB_FTL_Block_Erase +* Inputs: address of block to erase (now in byte format, should change to +* block format) +* Outputs: PASS=0 / FAIL=1 +* Description: erases the specified block +* increments the erase count +* If erase count reaches its upper limit,call function to +* do the ajustment as per the relative erase count values +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int GLOB_FTL_Block_Erase(u64 blk_addr) +{ + int status; + u32 BlkIdx; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + BlkIdx = (u32)(blk_addr >> DeviceInfo.nBitsInBlockDataSize); + + if (BlkIdx < DeviceInfo.wSpectraStartBlock) { + printk(KERN_ERR "GLOB_FTL_Block_Erase: " + "This should never occur\n"); + return FAIL; + } + +#if CMD_DMA + status = GLOB_LLD_Erase_Block_cdma(BlkIdx, LLD_CMD_FLAG_MODE_CDMA); + if (status == FAIL) + nand_dbg_print(NAND_DBG_WARN, + "NAND Program fail in %s, Line %d, " + "Function: %s, new Bad Block %d generated!\n", + __FILE__, __LINE__, __func__, BlkIdx); +#else + status = GLOB_LLD_Erase_Block(BlkIdx); + if (status == FAIL) { + nand_dbg_print(NAND_DBG_WARN, + "NAND Program fail in %s, Line %d, " + "Function: %s, new Bad Block %d generated!\n", + __FILE__, __LINE__, __func__, BlkIdx); + return status; + } +#endif + + if (DeviceInfo.MLCDevice) { + g_pReadCounter[BlkIdx - DeviceInfo.wSpectraStartBlock] = 0; + if (g_cBlockTableStatus != IN_PROGRESS_BLOCK_TABLE) { + g_cBlockTableStatus = IN_PROGRESS_BLOCK_TABLE; + FTL_Write_IN_Progress_Block_Table_Page(); + } + } + + g_pWearCounter[BlkIdx - DeviceInfo.wSpectraStartBlock]++; + +#if CMD_DMA + p_BTableChangesDelta = + (struct BTableChangesDelta *)g_pBTDelta_Free; + g_pBTDelta_Free += sizeof(struct BTableChangesDelta); + p_BTableChangesDelta->ftl_cmd_cnt = ftl_cmd_cnt; + p_BTableChangesDelta->WC_Index = + BlkIdx - DeviceInfo.wSpectraStartBlock; + p_BTableChangesDelta->WC_Entry_Value = + g_pWearCounter[BlkIdx - DeviceInfo.wSpectraStartBlock]; + p_BTableChangesDelta->ValidFields = 0x30; + + if (DeviceInfo.MLCDevice) { + p_BTableChangesDelta = + (struct BTableChangesDelta *)g_pBTDelta_Free; + g_pBTDelta_Free += sizeof(struct BTableChangesDelta); + p_BTableChangesDelta->ftl_cmd_cnt = + ftl_cmd_cnt; + p_BTableChangesDelta->RC_Index = + BlkIdx - DeviceInfo.wSpectraStartBlock; + p_BTableChangesDelta->RC_Entry_Value = + g_pReadCounter[BlkIdx - + DeviceInfo.wSpectraStartBlock]; + p_BTableChangesDelta->ValidFields = 0xC0; + } + + ftl_cmd_cnt++; +#endif + + if (g_pWearCounter[BlkIdx - DeviceInfo.wSpectraStartBlock] == 0xFE) + FTL_Adjust_Relative_Erase_Count(BlkIdx); + + return status; +} + + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Adjust_Relative_Erase_Count +* Inputs: index to block that was just incremented and is at the max +* Outputs: PASS=0 / FAIL=1 +* Description: If any erase counts at MAX, adjusts erase count of every +* block by substracting least worn +* counter from counter value of every entry in wear table +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +static int FTL_Adjust_Relative_Erase_Count(u32 Index_of_MAX) +{ + u8 wLeastWornCounter = MAX_BYTE_VALUE; + u8 wWearCounter; + u32 i, wWearIndex; + u32 *pbt = (u32 *)g_pBlockTable; + int wResult = PASS; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + for (i = 0; i < DeviceInfo.wDataBlockNum; i++) { + if (IS_BAD_BLOCK(i)) + continue; + wWearIndex = (u32)(pbt[i] & (~BAD_BLOCK)); + + if ((wWearIndex - DeviceInfo.wSpectraStartBlock) < 0) + printk(KERN_ERR "FTL_Adjust_Relative_Erase_Count:" + "This should never occur\n"); + wWearCounter = g_pWearCounter[wWearIndex - + DeviceInfo.wSpectraStartBlock]; + if (wWearCounter < wLeastWornCounter) + wLeastWornCounter = wWearCounter; + } + + if (wLeastWornCounter == 0) { + nand_dbg_print(NAND_DBG_WARN, + "Adjusting Wear Levelling Counters: Special Case\n"); + g_pWearCounter[Index_of_MAX - + DeviceInfo.wSpectraStartBlock]--; +#if CMD_DMA + p_BTableChangesDelta = + (struct BTableChangesDelta *)g_pBTDelta_Free; + g_pBTDelta_Free += sizeof(struct BTableChangesDelta); + p_BTableChangesDelta->ftl_cmd_cnt = ftl_cmd_cnt; + p_BTableChangesDelta->WC_Index = + Index_of_MAX - DeviceInfo.wSpectraStartBlock; + p_BTableChangesDelta->WC_Entry_Value = + g_pWearCounter[Index_of_MAX - + DeviceInfo.wSpectraStartBlock]; + p_BTableChangesDelta->ValidFields = 0x30; +#endif + FTL_Static_Wear_Leveling(); + } else { + for (i = 0; i < DeviceInfo.wDataBlockNum; i++) + if (!IS_BAD_BLOCK(i)) { + wWearIndex = (u32)(pbt[i] & (~BAD_BLOCK)); + g_pWearCounter[wWearIndex - + DeviceInfo.wSpectraStartBlock] = + (u8)(g_pWearCounter + [wWearIndex - + DeviceInfo.wSpectraStartBlock] - + wLeastWornCounter); +#if CMD_DMA + p_BTableChangesDelta = + (struct BTableChangesDelta *)g_pBTDelta_Free; + g_pBTDelta_Free += + sizeof(struct BTableChangesDelta); + + p_BTableChangesDelta->ftl_cmd_cnt = + ftl_cmd_cnt; + p_BTableChangesDelta->WC_Index = wWearIndex - + DeviceInfo.wSpectraStartBlock; + p_BTableChangesDelta->WC_Entry_Value = + g_pWearCounter[wWearIndex - + DeviceInfo.wSpectraStartBlock]; + p_BTableChangesDelta->ValidFields = 0x30; +#endif + } + } + + return wResult; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Write_IN_Progress_Block_Table_Page +* Inputs: None +* Outputs: None +* Description: It writes in-progress flag page to the page next to +* block table +***********************************************************************/ +static int FTL_Write_IN_Progress_Block_Table_Page(void) +{ + int wResult = PASS; + u16 bt_pages; + u16 dwIPFPageAddr; +#if CMD_DMA +#else + u32 *pbt = (u32 *)g_pBlockTable; + u32 wTempBlockTableIndex; +#endif + + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + bt_pages = FTL_Get_Block_Table_Flash_Size_Pages(); + + dwIPFPageAddr = g_wBlockTableOffset + bt_pages; + + nand_dbg_print(NAND_DBG_DEBUG, "Writing IPF at " + "Block %d Page %d\n", + g_wBlockTableIndex, dwIPFPageAddr); + +#if CMD_DMA + wResult = GLOB_LLD_Write_Page_Main_Spare_cdma(g_pIPF, + g_wBlockTableIndex, dwIPFPageAddr, 1, + LLD_CMD_FLAG_MODE_CDMA | LLD_CMD_FLAG_ORDER_BEFORE_REST); + if (wResult == FAIL) { + nand_dbg_print(NAND_DBG_WARN, + "NAND Program fail in %s, Line %d, " + "Function: %s, new Bad Block %d generated!\n", + __FILE__, __LINE__, __func__, + g_wBlockTableIndex); + } + g_wBlockTableOffset = dwIPFPageAddr + 1; + p_BTableChangesDelta = (struct BTableChangesDelta *)g_pBTDelta_Free; + g_pBTDelta_Free += sizeof(struct BTableChangesDelta); + p_BTableChangesDelta->ftl_cmd_cnt = ftl_cmd_cnt; + p_BTableChangesDelta->g_wBlockTableOffset = g_wBlockTableOffset; + p_BTableChangesDelta->ValidFields = 0x01; + ftl_cmd_cnt++; +#else + wResult = GLOB_LLD_Write_Page_Main_Spare(g_pIPF, + g_wBlockTableIndex, dwIPFPageAddr, 1); + if (wResult == FAIL) { + nand_dbg_print(NAND_DBG_WARN, + "NAND Program fail in %s, Line %d, " + "Function: %s, new Bad Block %d generated!\n", + __FILE__, __LINE__, __func__, + (int)g_wBlockTableIndex); + MARK_BLOCK_AS_BAD(pbt[BLOCK_TABLE_INDEX]); + wTempBlockTableIndex = FTL_Replace_Block_Table(); + bt_block_changed = 1; + if (BAD_BLOCK == wTempBlockTableIndex) + return ERR; + g_wBlockTableIndex = wTempBlockTableIndex; + g_wBlockTableOffset = 0; + /* Block table tag is '00'. Means it's used one */ + pbt[BLOCK_TABLE_INDEX] = g_wBlockTableIndex; + return FAIL; + } + g_wBlockTableOffset = dwIPFPageAddr + 1; +#endif + return wResult; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: FTL_Read_Disturbance +* Inputs: block address +* Outputs: PASS=0 / FAIL=1 +* Description: used to handle read disturbance. Data in block that +* reaches its read limit is moved to new block +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int FTL_Read_Disturbance(u32 blk_addr) +{ + int wResult = FAIL; + u32 *pbt = (u32 *) g_pBlockTable; + u32 dwOldBlockAddr = blk_addr; + u32 wBlockNum; + u32 i; + u32 wLeastReadCounter = 0xFFFF; + u32 wLeastReadIndex = BAD_BLOCK; + u32 wSpareBlockNum = 0; + u32 wTempNode; + u32 wReplacedNode; + u8 *g_pTempBuf; + + nand_dbg_print(NAND_DBG_DEBUG, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + +#if CMD_DMA + g_pTempBuf = cp_back_buf_copies[cp_back_buf_idx]; + cp_back_buf_idx++; + if (cp_back_buf_idx > COPY_BACK_BUF_NUM) { + printk(KERN_ERR "cp_back_buf_copies overflow! Exit." + "Maybe too many pending commands in your CDMA chain.\n"); + return FAIL; + } +#else + g_pTempBuf = tmp_buf_read_disturbance; +#endif + + wBlockNum = FTL_Get_Block_Index(blk_addr); + + do { + /* This is a bug.Here 'i' should be logical block number + * and start from 1 (0 is reserved for block table). + * Have fixed it. - Yunpeng 2008. 12. 19 + */ + for (i = 1; i < DeviceInfo.wDataBlockNum; i++) { + if (IS_SPARE_BLOCK(i)) { + u32 wPhysicalIndex = + (u32)((~SPARE_BLOCK) & pbt[i]); + if (g_pReadCounter[wPhysicalIndex - + DeviceInfo.wSpectraStartBlock] < + wLeastReadCounter) { + wLeastReadCounter = + g_pReadCounter[wPhysicalIndex - + DeviceInfo.wSpectraStartBlock]; + wLeastReadIndex = i; + } + wSpareBlockNum++; + } + } + + if (wSpareBlockNum <= NUM_FREE_BLOCKS_GATE) { + wResult = GLOB_FTL_Garbage_Collection(); + if (PASS == wResult) + continue; + else + break; + } else { + wTempNode = (u32)(DISCARD_BLOCK | pbt[wBlockNum]); + wReplacedNode = (u32)((~SPARE_BLOCK) & + pbt[wLeastReadIndex]); +#if CMD_DMA + pbt[wBlockNum] = wReplacedNode; + pbt[wLeastReadIndex] = wTempNode; + p_BTableChangesDelta = + (struct BTableChangesDelta *)g_pBTDelta_Free; + g_pBTDelta_Free += sizeof(struct BTableChangesDelta); + + p_BTableChangesDelta->ftl_cmd_cnt = + ftl_cmd_cnt; + p_BTableChangesDelta->BT_Index = wBlockNum; + p_BTableChangesDelta->BT_Entry_Value = pbt[wBlockNum]; + p_BTableChangesDelta->ValidFields = 0x0C; + + p_BTableChangesDelta = + (struct BTableChangesDelta *)g_pBTDelta_Free; + g_pBTDelta_Free += sizeof(struct BTableChangesDelta); + + p_BTableChangesDelta->ftl_cmd_cnt = + ftl_cmd_cnt; + p_BTableChangesDelta->BT_Index = wLeastReadIndex; + p_BTableChangesDelta->BT_Entry_Value = + pbt[wLeastReadIndex]; + p_BTableChangesDelta->ValidFields = 0x0C; + + wResult = GLOB_LLD_Read_Page_Main_cdma(g_pTempBuf, + dwOldBlockAddr, 0, DeviceInfo.wPagesPerBlock, + LLD_CMD_FLAG_MODE_CDMA); + if (wResult == FAIL) + return wResult; + + ftl_cmd_cnt++; + + if (wResult != FAIL) { + if (FAIL == GLOB_LLD_Write_Page_Main_cdma( + g_pTempBuf, pbt[wBlockNum], 0, + DeviceInfo.wPagesPerBlock)) { + nand_dbg_print(NAND_DBG_WARN, + "NAND Program fail in " + "%s, Line %d, Function: %s, " + "new Bad Block %d " + "generated!\n", + __FILE__, __LINE__, __func__, + (int)pbt[wBlockNum]); + wResult = FAIL; + MARK_BLOCK_AS_BAD(pbt[wBlockNum]); + } + ftl_cmd_cnt++; + } +#else + wResult = GLOB_LLD_Read_Page_Main(g_pTempBuf, + dwOldBlockAddr, 0, DeviceInfo.wPagesPerBlock); + if (wResult == FAIL) + return wResult; + + if (wResult != FAIL) { + /* This is a bug. At this time, pbt[wBlockNum] + is still the physical address of + discard block, and should not be write. + Have fixed it as below. + -- Yunpeng 2008.12.19 + */ + wResult = GLOB_LLD_Write_Page_Main(g_pTempBuf, + wReplacedNode, 0, + DeviceInfo.wPagesPerBlock); + if (wResult == FAIL) { + nand_dbg_print(NAND_DBG_WARN, + "NAND Program fail in " + "%s, Line %d, Function: %s, " + "new Bad Block %d " + "generated!\n", + __FILE__, __LINE__, __func__, + (int)wReplacedNode); + MARK_BLOCK_AS_BAD(wReplacedNode); + } else { + pbt[wBlockNum] = wReplacedNode; + pbt[wLeastReadIndex] = wTempNode; + } + } + + if ((wResult == PASS) && (g_cBlockTableStatus != + IN_PROGRESS_BLOCK_TABLE)) { + g_cBlockTableStatus = IN_PROGRESS_BLOCK_TABLE; + FTL_Write_IN_Progress_Block_Table_Page(); + } +#endif + } + } while (wResult != PASS) + ; + +#if CMD_DMA + /* ... */ +#endif + + return wResult; +} + diff --git a/drivers/block/spectra/flash.h b/drivers/block/spectra/flash.h new file mode 100644 index 000000000000..5ed05805cf65 --- /dev/null +++ b/drivers/block/spectra/flash.h @@ -0,0 +1,198 @@ +/* + * NAND Flash Controller Device Driver + * Copyright (c) 2009, Intel Corporation and its suppliers. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef _FLASH_INTERFACE_ +#define _FLASH_INTERFACE_ + +#include "ffsport.h" +#include "spectraswconfig.h" + +#define MAX_BYTE_VALUE 0xFF +#define MAX_WORD_VALUE 0xFFFF +#define MAX_U32_VALUE 0xFFFFFFFF + +#define MAX_BLOCKNODE_VALUE 0xFFFFFF +#define DISCARD_BLOCK 0x800000 +#define SPARE_BLOCK 0x400000 +#define BAD_BLOCK 0xC00000 + +#define UNHIT_CACHE_ITEM 0xFFFF + +#define NAND_CACHE_INIT_ADDR 0xffffffffffffffffULL + +#define IN_PROGRESS_BLOCK_TABLE 0x00 +#define CURRENT_BLOCK_TABLE 0x01 + +#define BTSIG_OFFSET (0) +#define BTSIG_BYTES (5) +#define BTSIG_DELTA (3) + +#define MAX_READ_COUNTER 0x2710 + +#define FIRST_BT_ID (1) +#define LAST_BT_ID (254) +#define BTBLOCK_INVAL (u32)(0xFFFFFFFF) + +struct device_info_tag { + u16 wDeviceMaker; + u16 wDeviceID; + u32 wDeviceType; + u32 wSpectraStartBlock; + u32 wSpectraEndBlock; + u32 wTotalBlocks; + u16 wPagesPerBlock; + u16 wPageSize; + u16 wPageDataSize; + u16 wPageSpareSize; + u16 wNumPageSpareFlag; + u16 wECCBytesPerSector; + u32 wBlockSize; + u32 wBlockDataSize; + u32 wDataBlockNum; + u8 bPlaneNum; + u16 wDeviceMainAreaSize; + u16 wDeviceSpareAreaSize; + u16 wDevicesConnected; + u16 wDeviceWidth; + u16 wHWRevision; + u16 wHWFeatures; + + u16 wONFIDevFeatures; + u16 wONFIOptCommands; + u16 wONFITimingMode; + u16 wONFIPgmCacheTimingMode; + + u16 MLCDevice; + u16 wSpareSkipBytes; + + u8 nBitsInPageNumber; + u8 nBitsInPageDataSize; + u8 nBitsInBlockDataSize; +}; + +extern struct device_info_tag DeviceInfo; + +/* Cache item format */ +struct flash_cache_item_tag { + u64 address; + u16 use_cnt; + u16 changed; + u8 *buf; +}; + +struct flash_cache_tag { + u32 cache_item_size; /* Size in bytes of each cache item */ + u16 pages_per_item; /* How many NAND pages in each cache item */ + u16 LRU; /* No. of the least recently used cache item */ + struct flash_cache_item_tag array[CACHE_ITEM_NUM]; +}; + +/* + *Data structure for each list node of the managment table + * used for the Level 2 Cache. Each node maps one logical NAND block. + */ +struct spectra_l2_cache_list { + struct list_head list; + u32 logical_blk_num; /* Logical block number */ + u32 pages_array[]; /* Page map array of this logical block. + * Array index is the logical block number, + * and for every item of this arry: + * high 16 bit is index of the L2 cache block num, + * low 16 bit is the phy page num + * of the above L2 cache block. + * This array will be kmalloc during run time. + */ +}; + +struct spectra_l2_cache_info { + u32 blk_array[BLK_NUM_FOR_L2_CACHE]; + u16 cur_blk_idx; /* idx to the phy block number of current using */ + u16 cur_page_num; /* pages number of current using */ + struct spectra_l2_cache_list table; /* First node of the table */ +}; + +#define RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE 1 + +#if RESTORE_CACHE_ON_CDMA_CHAIN_FAILURE +struct flash_cache_mod_item_tag { + u64 address; + u8 changed; +}; + +struct flash_cache_delta_list_tag { + u8 item; /* used cache item */ + struct flash_cache_mod_item_tag cache; +}; +#endif + +extern struct flash_cache_tag Cache; + +extern u8 *buf_read_page_main_spare; +extern u8 *buf_write_page_main_spare; +extern u8 *buf_read_page_spare; +extern u8 *buf_get_bad_block; +extern u8 *cdma_desc_buf; +extern u8 *memcp_desc_buf; + +/* struture used for IndentfyDevice function */ +struct spectra_indentfy_dev_tag { + u32 NumBlocks; + u16 PagesPerBlock; + u16 PageDataSize; + u16 wECCBytesPerSector; + u32 wDataBlockNum; +}; + +int GLOB_FTL_Flash_Init(void); +int GLOB_FTL_Flash_Release(void); +/*void GLOB_FTL_Erase_Flash(void);*/ +int GLOB_FTL_Block_Erase(u64 block_addr); +int GLOB_FTL_Is_BadBlock(u32 block_num); +int GLOB_FTL_IdentifyDevice(struct spectra_indentfy_dev_tag *dev_data); +int GLOB_FTL_Event_Status(int *); +u16 glob_ftl_execute_cmds(void); + +/*int FTL_Read_Disturbance(ADDRESSTYPE dwBlockAddr);*/ +int FTL_Read_Disturbance(u32 dwBlockAddr); + +/*Flash r/w based on cache*/ +int GLOB_FTL_Page_Read(u8 *read_data, u64 page_addr); +int GLOB_FTL_Page_Write(u8 *write_data, u64 page_addr); +int GLOB_FTL_Wear_Leveling(void); +int GLOB_FTL_Flash_Format(void); +int GLOB_FTL_Init(void); +int GLOB_FTL_Flush_Cache(void); +int GLOB_FTL_Garbage_Collection(void); +int GLOB_FTL_BT_Garbage_Collection(void); +void GLOB_FTL_Cache_Release(void); +u8 *get_blk_table_start_addr(void); +u8 *get_wear_leveling_table_start_addr(void); +unsigned long get_blk_table_len(void); +unsigned long get_wear_leveling_table_len(void); + +#if DEBUG_BNDRY +void debug_boundary_lineno_error(int chnl, int limit, int no, int lineno, + char *filename); +#define debug_boundary_error(chnl, limit, no) debug_boundary_lineno_error(chnl,\ + limit, no, __LINE__, __FILE__) +#else +#define debug_boundary_error(chnl, limit, no) ; +#endif + +#endif /*_FLASH_INTERFACE_*/ diff --git a/drivers/block/spectra/lld.c b/drivers/block/spectra/lld.c new file mode 100644 index 000000000000..3f411af4405e --- /dev/null +++ b/drivers/block/spectra/lld.c @@ -0,0 +1,258 @@ +/* + * NAND Flash Controller Device Driver + * Copyright (c) 2009, Intel Corporation and its suppliers. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "spectraswconfig.h" +#include "ffsport.h" +#include "ffsdefs.h" +#include "lld.h" +#include "lld_nand.h" + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +#if FLASH_EMU /* vector all the LLD calls to the LLD_EMU code */ +#include "lld_emu.h" +#include "lld_cdma.h" + +/* common functions: */ +u16 GLOB_LLD_Flash_Reset(void) +{ + return emu_Flash_Reset(); +} + +u16 GLOB_LLD_Read_Device_ID(void) +{ + return emu_Read_Device_ID(); +} + +int GLOB_LLD_Flash_Release(void) +{ + return emu_Flash_Release(); +} + +u16 GLOB_LLD_Flash_Init(void) +{ + return emu_Flash_Init(); +} + +u16 GLOB_LLD_Erase_Block(u32 block_add) +{ + return emu_Erase_Block(block_add); +} + +u16 GLOB_LLD_Write_Page_Main(u8 *write_data, u32 block, u16 Page, + u16 PageCount) +{ + return emu_Write_Page_Main(write_data, block, Page, PageCount); +} + +u16 GLOB_LLD_Read_Page_Main(u8 *read_data, u32 block, u16 Page, + u16 PageCount) +{ + return emu_Read_Page_Main(read_data, block, Page, PageCount); +} + +u16 GLOB_LLD_Read_Page_Main_Polling(u8 *read_data, + u32 block, u16 page, u16 page_count) +{ + return emu_Read_Page_Main(read_data, block, page, page_count); +} + +u16 GLOB_LLD_Write_Page_Main_Spare(u8 *write_data, u32 block, + u16 Page, u16 PageCount) +{ + return emu_Write_Page_Main_Spare(write_data, block, Page, PageCount); +} + +u16 GLOB_LLD_Read_Page_Main_Spare(u8 *read_data, u32 block, + u16 Page, u16 PageCount) +{ + return emu_Read_Page_Main_Spare(read_data, block, Page, PageCount); +} + +u16 GLOB_LLD_Write_Page_Spare(u8 *write_data, u32 block, u16 Page, + u16 PageCount) +{ + return emu_Write_Page_Spare(write_data, block, Page, PageCount); +} + +u16 GLOB_LLD_Read_Page_Spare(u8 *read_data, u32 block, u16 Page, + u16 PageCount) +{ + return emu_Read_Page_Spare(read_data, block, Page, PageCount); +} + +u16 GLOB_LLD_Get_Bad_Block(u32 block) +{ + return emu_Get_Bad_Block(block); +} + +#endif /* FLASH_EMU */ + + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +#if FLASH_NAND /* vector all the LLD calls to the NAND controller code */ +#include "lld_nand.h" +#include "lld_cdma.h" +#include "flash.h" + +/* common functions for LLD_NAND */ +void GLOB_LLD_ECC_Control(int enable) +{ + NAND_ECC_Ctrl(enable); +} + +/* common functions for LLD_NAND */ +u16 GLOB_LLD_Flash_Reset(void) +{ + return NAND_Flash_Reset(); +} + +u16 GLOB_LLD_Read_Device_ID(void) +{ + return NAND_Read_Device_ID(); +} + +u16 GLOB_LLD_UnlockArrayAll(void) +{ + return NAND_UnlockArrayAll(); +} + +u16 GLOB_LLD_Flash_Init(void) +{ + return NAND_Flash_Init(); +} + +int GLOB_LLD_Flash_Release(void) +{ + return nand_release(); +} + +u16 GLOB_LLD_Erase_Block(u32 block_add) +{ + return NAND_Erase_Block(block_add); +} + + +u16 GLOB_LLD_Write_Page_Main(u8 *write_data, u32 block, u16 Page, + u16 PageCount) +{ + return NAND_Write_Page_Main(write_data, block, Page, PageCount); +} + +u16 GLOB_LLD_Read_Page_Main(u8 *read_data, u32 block, u16 page, + u16 page_count) +{ + if (page_count == 1) /* Using polling to improve read speed */ + return NAND_Read_Page_Main_Polling(read_data, block, page, 1); + else + return NAND_Read_Page_Main(read_data, block, page, page_count); +} + +u16 GLOB_LLD_Read_Page_Main_Polling(u8 *read_data, + u32 block, u16 page, u16 page_count) +{ + return NAND_Read_Page_Main_Polling(read_data, + block, page, page_count); +} + +u16 GLOB_LLD_Write_Page_Main_Spare(u8 *write_data, u32 block, + u16 Page, u16 PageCount) +{ + return NAND_Write_Page_Main_Spare(write_data, block, Page, PageCount); +} + +u16 GLOB_LLD_Write_Page_Spare(u8 *write_data, u32 block, u16 Page, + u16 PageCount) +{ + return NAND_Write_Page_Spare(write_data, block, Page, PageCount); +} + +u16 GLOB_LLD_Read_Page_Main_Spare(u8 *read_data, u32 block, + u16 page, u16 page_count) +{ + return NAND_Read_Page_Main_Spare(read_data, block, page, page_count); +} + +u16 GLOB_LLD_Read_Page_Spare(u8 *read_data, u32 block, u16 Page, + u16 PageCount) +{ + return NAND_Read_Page_Spare(read_data, block, Page, PageCount); +} + +u16 GLOB_LLD_Get_Bad_Block(u32 block) +{ + return NAND_Get_Bad_Block(block); +} + +u16 GLOB_LLD_Event_Status(void) +{ + return CDMA_Event_Status(); +} + +u16 glob_lld_execute_cmds(void) +{ + return CDMA_Execute_CMDs(); +} + +u16 GLOB_LLD_MemCopy_CMD(u8 *dest, u8 *src, + u32 ByteCount, u16 flag) +{ + /* Replace the hardware memcopy with software memcpy function */ + if (CDMA_Execute_CMDs()) + return FAIL; + memcpy(dest, src, ByteCount); + return PASS; + + /* return CDMA_MemCopy_CMD(dest, src, ByteCount, flag); */ +} + +u16 GLOB_LLD_Erase_Block_cdma(u32 block, u16 flags) +{ + return CDMA_Data_CMD(ERASE_CMD, 0, block, 0, 0, flags); +} + +u16 GLOB_LLD_Write_Page_Main_cdma(u8 *data, u32 block, u16 page, u16 count) +{ + return CDMA_Data_CMD(WRITE_MAIN_CMD, data, block, page, count, 0); +} + +u16 GLOB_LLD_Read_Page_Main_cdma(u8 *data, u32 block, u16 page, + u16 count, u16 flags) +{ + return CDMA_Data_CMD(READ_MAIN_CMD, data, block, page, count, flags); +} + +u16 GLOB_LLD_Write_Page_Main_Spare_cdma(u8 *data, u32 block, u16 page, + u16 count, u16 flags) +{ + return CDMA_Data_CMD(WRITE_MAIN_SPARE_CMD, + data, block, page, count, flags); +} + +u16 GLOB_LLD_Read_Page_Main_Spare_cdma(u8 *data, + u32 block, u16 page, u16 count) +{ + return CDMA_Data_CMD(READ_MAIN_SPARE_CMD, data, block, page, count, + LLD_CMD_FLAG_MODE_CDMA); +} + +#endif /* FLASH_NAND */ + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ + +/* end of LLD.c */ diff --git a/drivers/block/spectra/lld.h b/drivers/block/spectra/lld.h new file mode 100644 index 000000000000..d3738e0e1fea --- /dev/null +++ b/drivers/block/spectra/lld.h @@ -0,0 +1,111 @@ +/* + * NAND Flash Controller Device Driver + * Copyright (c) 2009, Intel Corporation and its suppliers. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + + + +#ifndef _LLD_ +#define _LLD_ + +#include "ffsport.h" +#include "spectraswconfig.h" +#include "flash.h" + +#define GOOD_BLOCK 0 +#define DEFECTIVE_BLOCK 1 +#define READ_ERROR 2 + +#define CLK_X 5 +#define CLK_MULTI 4 + +/* Typedefs */ + +/* prototypes: API for LLD */ +/* Currently, Write_Page_Main + * MemCopy + * Read_Page_Main_Spare + * do not have flag because they were not implemented prior to this + * They are not being added to keep changes to a minimum for now. + * Currently, they are not required (only reqd for Wr_P_M_S.) + * Later on, these NEED to be changed. + */ + +extern void GLOB_LLD_ECC_Control(int enable); + +extern u16 GLOB_LLD_Flash_Reset(void); + +extern u16 GLOB_LLD_Read_Device_ID(void); + +extern u16 GLOB_LLD_UnlockArrayAll(void); + +extern u16 GLOB_LLD_Flash_Init(void); + +extern int GLOB_LLD_Flash_Release(void); + +extern u16 GLOB_LLD_Erase_Block(u32 block_add); + +extern u16 GLOB_LLD_Write_Page_Main(u8 *write_data, + u32 block, u16 Page, u16 PageCount); + +extern u16 GLOB_LLD_Read_Page_Main(u8 *read_data, + u32 block, u16 page, u16 page_count); + +extern u16 GLOB_LLD_Read_Page_Main_Polling(u8 *read_data, + u32 block, u16 page, u16 page_count); + +extern u16 GLOB_LLD_Write_Page_Main_Spare(u8 *write_data, + u32 block, u16 Page, u16 PageCount); + +extern u16 GLOB_LLD_Write_Page_Spare(u8 *write_data, + u32 block, u16 Page, u16 PageCount); + +extern u16 GLOB_LLD_Read_Page_Main_Spare(u8 *read_data, + u32 block, u16 page, u16 page_count); + +extern u16 GLOB_LLD_Read_Page_Spare(u8 *read_data, + u32 block, u16 Page, u16 PageCount); + +extern u16 GLOB_LLD_Get_Bad_Block(u32 block); + +extern u16 GLOB_LLD_Event_Status(void); + +extern u16 GLOB_LLD_MemCopy_CMD(u8 *dest, u8 *src, u32 ByteCount, u16 flag); + +extern u16 glob_lld_execute_cmds(void); + +extern u16 GLOB_LLD_Erase_Block_cdma(u32 block, u16 flags); + +extern u16 GLOB_LLD_Write_Page_Main_cdma(u8 *data, + u32 block, u16 page, u16 count); + +extern u16 GLOB_LLD_Read_Page_Main_cdma(u8 *data, + u32 block, u16 page, u16 count, u16 flags); + +extern u16 GLOB_LLD_Write_Page_Main_Spare_cdma(u8 *data, + u32 block, u16 page, u16 count, u16 flags); + +extern u16 GLOB_LLD_Read_Page_Main_Spare_cdma(u8 *data, + u32 block, u16 page, u16 count); + +#define LLD_CMD_FLAG_ORDER_BEFORE_REST (0x1) +#define LLD_CMD_FLAG_MODE_CDMA (0x8) + + +#endif /*_LLD_ */ + + diff --git a/drivers/block/spectra/lld_cdma.c b/drivers/block/spectra/lld_cdma.c new file mode 100644 index 000000000000..c6e76103d43c --- /dev/null +++ b/drivers/block/spectra/lld_cdma.c @@ -0,0 +1,910 @@ +/* + * NAND Flash Controller Device Driver + * Copyright (c) 2009, Intel Corporation and its suppliers. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include +#include + +#include "spectraswconfig.h" +#include "lld.h" +#include "lld_nand.h" +#include "lld_cdma.h" +#include "lld_emu.h" +#include "flash.h" +#include "nand_regs.h" + +#define MAX_PENDING_CMDS 4 +#define MODE_02 (0x2 << 26) + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: CDMA_Data_Cmd +* Inputs: cmd code (aligned for hw) +* data: pointer to source or destination +* block: block address +* page: page address +* num: num pages to transfer +* Outputs: PASS +* Description: This function takes the parameters and puts them +* into the "pending commands" array. +* It does not parse or validate the parameters. +* The array index is same as the tag. +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 CDMA_Data_CMD(u8 cmd, u8 *data, u32 block, u16 page, u16 num, u16 flags) +{ + u8 bank; + + nand_dbg_print(NAND_DBG_DEBUG, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (0 == cmd) + nand_dbg_print(NAND_DBG_DEBUG, + "%s, Line %d, Illegal cmd (0)\n", __FILE__, __LINE__); + + /* If a command of another bank comes, then first execute */ + /* pending commands of the current bank, then set the new */ + /* bank as current bank */ + bank = block / (DeviceInfo.wTotalBlocks / totalUsedBanks); + if (bank != info.flash_bank) { + nand_dbg_print(NAND_DBG_WARN, + "Will access new bank. old bank: %d, new bank: %d\n", + info.flash_bank, bank); + if (CDMA_Execute_CMDs()) { + printk(KERN_ERR "CDMA_Execute_CMDs fail!\n"); + return FAIL; + } + info.flash_bank = bank; + } + + info.pcmds[info.pcmds_num].CMD = cmd; + info.pcmds[info.pcmds_num].DataAddr = data; + info.pcmds[info.pcmds_num].Block = block; + info.pcmds[info.pcmds_num].Page = page; + info.pcmds[info.pcmds_num].PageCount = num; + info.pcmds[info.pcmds_num].DataDestAddr = 0; + info.pcmds[info.pcmds_num].DataSrcAddr = 0; + info.pcmds[info.pcmds_num].MemCopyByteCnt = 0; + info.pcmds[info.pcmds_num].Flags = flags; + info.pcmds[info.pcmds_num].Status = 0xB0B; + + switch (cmd) { + case WRITE_MAIN_SPARE_CMD: + Conv_Main_Spare_Data_Log2Phy_Format(data, num); + break; + case WRITE_SPARE_CMD: + Conv_Spare_Data_Log2Phy_Format(data); + break; + default: + break; + } + + info.pcmds_num++; + + if (info.pcmds_num >= MAX_PENDING_CMDS) { + if (CDMA_Execute_CMDs()) { + printk(KERN_ERR "CDMA_Execute_CMDs fail!\n"); + return FAIL; + } + } + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: CDMA_MemCopy_CMD +* Inputs: dest: pointer to destination +* src: pointer to source +* count: num bytes to transfer +* Outputs: PASS +* Description: This function takes the parameters and puts them +* into the "pending commands" array. +* It does not parse or validate the parameters. +* The array index is same as the tag. +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 CDMA_MemCopy_CMD(u8 *dest, u8 *src, u32 byte_cnt, u16 flags) +{ + nand_dbg_print(NAND_DBG_DEBUG, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + info.pcmds[info.pcmds_num].CMD = MEMCOPY_CMD; + info.pcmds[info.pcmds_num].DataAddr = 0; + info.pcmds[info.pcmds_num].Block = 0; + info.pcmds[info.pcmds_num].Page = 0; + info.pcmds[info.pcmds_num].PageCount = 0; + info.pcmds[info.pcmds_num].DataDestAddr = dest; + info.pcmds[info.pcmds_num].DataSrcAddr = src; + info.pcmds[info.pcmds_num].MemCopyByteCnt = byte_cnt; + info.pcmds[info.pcmds_num].Flags = flags; + info.pcmds[info.pcmds_num].Status = 0xB0B; + + info.pcmds_num++; + + if (info.pcmds_num >= MAX_PENDING_CMDS) { + if (CDMA_Execute_CMDs()) { + printk(KERN_ERR "CDMA_Execute_CMDs fail!\n"); + return FAIL; + } + } + + return PASS; +} + +#if 0 +/* Prints the PendingCMDs array */ +void print_pending_cmds(void) +{ + u16 i; + + nand_dbg_print(NAND_DBG_DEBUG, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + for (i = 0; i < info.pcmds_num; i++) { + nand_dbg_print(NAND_DBG_DEBUG, "\ni: %d\n", i); + switch (info.pcmds[i].CMD) { + case ERASE_CMD: + nand_dbg_print(NAND_DBG_DEBUG, + "Erase Command (0x%x)\n", + info.pcmds[i].CMD); + break; + case WRITE_MAIN_CMD: + nand_dbg_print(NAND_DBG_DEBUG, + "Write Main Command (0x%x)\n", + info.pcmds[i].CMD); + break; + case WRITE_MAIN_SPARE_CMD: + nand_dbg_print(NAND_DBG_DEBUG, + "Write Main Spare Command (0x%x)\n", + info.pcmds[i].CMD); + break; + case READ_MAIN_SPARE_CMD: + nand_dbg_print(NAND_DBG_DEBUG, + "Read Main Spare Command (0x%x)\n", + info.pcmds[i].CMD); + break; + case READ_MAIN_CMD: + nand_dbg_print(NAND_DBG_DEBUG, + "Read Main Command (0x%x)\n", + info.pcmds[i].CMD); + break; + case MEMCOPY_CMD: + nand_dbg_print(NAND_DBG_DEBUG, + "Memcopy Command (0x%x)\n", + info.pcmds[i].CMD); + break; + case DUMMY_CMD: + nand_dbg_print(NAND_DBG_DEBUG, + "Dummy Command (0x%x)\n", + info.pcmds[i].CMD); + break; + default: + nand_dbg_print(NAND_DBG_DEBUG, + "Illegal Command (0x%x)\n", + info.pcmds[i].CMD); + break; + } + + nand_dbg_print(NAND_DBG_DEBUG, "DataAddr: 0x%x\n", + (u32)info.pcmds[i].DataAddr); + nand_dbg_print(NAND_DBG_DEBUG, "Block: %d\n", + info.pcmds[i].Block); + nand_dbg_print(NAND_DBG_DEBUG, "Page: %d\n", + info.pcmds[i].Page); + nand_dbg_print(NAND_DBG_DEBUG, "PageCount: %d\n", + info.pcmds[i].PageCount); + nand_dbg_print(NAND_DBG_DEBUG, "DataDestAddr: 0x%x\n", + (u32)info.pcmds[i].DataDestAddr); + nand_dbg_print(NAND_DBG_DEBUG, "DataSrcAddr: 0x%x\n", + (u32)info.pcmds[i].DataSrcAddr); + nand_dbg_print(NAND_DBG_DEBUG, "MemCopyByteCnt: %d\n", + info.pcmds[i].MemCopyByteCnt); + nand_dbg_print(NAND_DBG_DEBUG, "Flags: 0x%x\n", + info.pcmds[i].Flags); + nand_dbg_print(NAND_DBG_DEBUG, "Status: 0x%x\n", + info.pcmds[i].Status); + } +} + +/* Print the CDMA descriptors */ +void print_cdma_descriptors(void) +{ + struct cdma_descriptor *pc; + int i; + + pc = (struct cdma_descriptor *)info.cdma_desc_buf; + + nand_dbg_print(NAND_DBG_DEBUG, "\nWill dump cdma descriptors:\n"); + + for (i = 0; i < info.cdma_num; i++) { + nand_dbg_print(NAND_DBG_DEBUG, "\ni: %d\n", i); + nand_dbg_print(NAND_DBG_DEBUG, + "NxtPointerHi: 0x%x, NxtPointerLo: 0x%x\n", + pc[i].NxtPointerHi, pc[i].NxtPointerLo); + nand_dbg_print(NAND_DBG_DEBUG, + "FlashPointerHi: 0x%x, FlashPointerLo: 0x%x\n", + pc[i].FlashPointerHi, pc[i].FlashPointerLo); + nand_dbg_print(NAND_DBG_DEBUG, "CommandType: 0x%x\n", + pc[i].CommandType); + nand_dbg_print(NAND_DBG_DEBUG, + "MemAddrHi: 0x%x, MemAddrLo: 0x%x\n", + pc[i].MemAddrHi, pc[i].MemAddrLo); + nand_dbg_print(NAND_DBG_DEBUG, "CommandFlags: 0x%x\n", + pc[i].CommandFlags); + nand_dbg_print(NAND_DBG_DEBUG, "Channel: %d, Status: 0x%x\n", + pc[i].Channel, pc[i].Status); + nand_dbg_print(NAND_DBG_DEBUG, + "MemCopyPointerHi: 0x%x, MemCopyPointerLo: 0x%x\n", + pc[i].MemCopyPointerHi, pc[i].MemCopyPointerLo); + nand_dbg_print(NAND_DBG_DEBUG, + "Reserved12: 0x%x, Reserved13: 0x%x, " + "Reserved14: 0x%x, pcmd: %d\n", + pc[i].Reserved12, pc[i].Reserved13, + pc[i].Reserved14, pc[i].pcmd); + } +} + +/* Print the Memory copy descriptors */ +static void print_memcp_descriptors(void) +{ + struct memcpy_descriptor *pm; + int i; + + pm = (struct memcpy_descriptor *)info.memcp_desc_buf; + + nand_dbg_print(NAND_DBG_DEBUG, "\nWill dump mem_cpy descriptors:\n"); + + for (i = 0; i < info.cdma_num; i++) { + nand_dbg_print(NAND_DBG_DEBUG, "\ni: %d\n", i); + nand_dbg_print(NAND_DBG_DEBUG, + "NxtPointerHi: 0x%x, NxtPointerLo: 0x%x\n", + pm[i].NxtPointerHi, pm[i].NxtPointerLo); + nand_dbg_print(NAND_DBG_DEBUG, + "SrcAddrHi: 0x%x, SrcAddrLo: 0x%x\n", + pm[i].SrcAddrHi, pm[i].SrcAddrLo); + nand_dbg_print(NAND_DBG_DEBUG, + "DestAddrHi: 0x%x, DestAddrLo: 0x%x\n", + pm[i].DestAddrHi, pm[i].DestAddrLo); + nand_dbg_print(NAND_DBG_DEBUG, "XferSize: %d\n", + pm[i].XferSize); + nand_dbg_print(NAND_DBG_DEBUG, "MemCopyFlags: 0x%x\n", + pm[i].MemCopyFlags); + nand_dbg_print(NAND_DBG_DEBUG, "MemCopyStatus: %d\n", + pm[i].MemCopyStatus); + nand_dbg_print(NAND_DBG_DEBUG, "reserved9: 0x%x\n", + pm[i].reserved9); + nand_dbg_print(NAND_DBG_DEBUG, "reserved10: 0x%x\n", + pm[i].reserved10); + nand_dbg_print(NAND_DBG_DEBUG, "reserved11: 0x%x\n", + pm[i].reserved11); + nand_dbg_print(NAND_DBG_DEBUG, "reserved12: 0x%x\n", + pm[i].reserved12); + nand_dbg_print(NAND_DBG_DEBUG, "reserved13: 0x%x\n", + pm[i].reserved13); + nand_dbg_print(NAND_DBG_DEBUG, "reserved14: 0x%x\n", + pm[i].reserved14); + nand_dbg_print(NAND_DBG_DEBUG, "reserved15: 0x%x\n", + pm[i].reserved15); + } +} +#endif + +/* Reset cdma_descriptor chain to 0 */ +static void reset_cdma_desc(int i) +{ + struct cdma_descriptor *ptr; + + BUG_ON(i >= MAX_DESCS); + + ptr = (struct cdma_descriptor *)info.cdma_desc_buf; + + ptr[i].NxtPointerHi = 0; + ptr[i].NxtPointerLo = 0; + ptr[i].FlashPointerHi = 0; + ptr[i].FlashPointerLo = 0; + ptr[i].CommandType = 0; + ptr[i].MemAddrHi = 0; + ptr[i].MemAddrLo = 0; + ptr[i].CommandFlags = 0; + ptr[i].Channel = 0; + ptr[i].Status = 0; + ptr[i].MemCopyPointerHi = 0; + ptr[i].MemCopyPointerLo = 0; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: CDMA_UpdateEventStatus +* Inputs: none +* Outputs: none +* Description: This function update the event status of all the channels +* when an error condition is reported. +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +void CDMA_UpdateEventStatus(void) +{ + int i, j, active_chan; + struct cdma_descriptor *ptr; + + nand_dbg_print(NAND_DBG_DEBUG, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + ptr = (struct cdma_descriptor *)info.cdma_desc_buf; + + for (j = 0; j < info.cdma_num; j++) { + /* Check for the descriptor with failure */ + if ((ptr[j].Status & CMD_DMA_DESC_FAIL)) + break; + + } + + /* All the previous cmd's status for this channel must be good */ + for (i = 0; i < j; i++) { + if (ptr[i].pcmd != 0xff) + info.pcmds[ptr[i].pcmd].Status = CMD_PASS; + } + + /* Abort the channel with type 0 reset command. It resets the */ + /* selected channel after the descriptor completes the flash */ + /* operation and status has been updated for the descriptor. */ + /* Memory Copy and Sync associated with this descriptor will */ + /* not be executed */ + active_chan = ioread32(FlashReg + CHNL_ACTIVE); + if ((active_chan & (1 << info.flash_bank)) == (1 << info.flash_bank)) { + iowrite32(MODE_02 | (0 << 4), FlashMem); /* Type 0 reset */ + iowrite32((0xF << 4) | info.flash_bank, FlashMem + 0x10); + } else { /* Should not reached here */ + printk(KERN_ERR "Error! Used bank is not set in" + " reg CHNL_ACTIVE\n"); + } +} + +static void cdma_trans(u16 chan) +{ + u32 addr; + + addr = info.cdma_desc; + + iowrite32(MODE_10 | (chan << 24), FlashMem); + iowrite32((1 << 7) | chan, FlashMem + 0x10); + + iowrite32(MODE_10 | (chan << 24) | ((0x0FFFF & (addr >> 16)) << 8), + FlashMem); + iowrite32((1 << 7) | (1 << 4) | 0, FlashMem + 0x10); + + iowrite32(MODE_10 | (chan << 24) | ((0x0FFFF & addr) << 8), FlashMem); + iowrite32((1 << 7) | (1 << 5) | 0, FlashMem + 0x10); + + iowrite32(MODE_10 | (chan << 24), FlashMem); + iowrite32((1 << 7) | (1 << 5) | (1 << 4) | 0, FlashMem + 0x10); +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: CDMA_Execute_CMDs (for use with CMD_DMA) +* Inputs: tag_count: the number of pending cmds to do +* Outputs: PASS/FAIL +* Description: Build the SDMA chain(s) by making one CMD-DMA descriptor +* for each pending command, start the CDMA engine, and return. +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 CDMA_Execute_CMDs(void) +{ + int i, ret; + u64 flash_add; + u32 ptr; + dma_addr_t map_addr, next_ptr; + u16 status = PASS; + u16 tmp_c; + struct cdma_descriptor *pc; + struct memcpy_descriptor *pm; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + /* No pending cmds to execute, just exit */ + if (0 == info.pcmds_num) { + nand_dbg_print(NAND_DBG_TRACE, + "No pending cmds to execute. Just exit.\n"); + return PASS; + } + + for (i = 0; i < MAX_DESCS; i++) + reset_cdma_desc(i); + + pc = (struct cdma_descriptor *)info.cdma_desc_buf; + pm = (struct memcpy_descriptor *)info.memcp_desc_buf; + + info.cdma_desc = virt_to_bus(info.cdma_desc_buf); + info.memcp_desc = virt_to_bus(info.memcp_desc_buf); + next_ptr = info.cdma_desc; + info.cdma_num = 0; + + for (i = 0; i < info.pcmds_num; i++) { + if (info.pcmds[i].Block >= DeviceInfo.wTotalBlocks) { + info.pcmds[i].Status = CMD_NOT_DONE; + continue; + } + + next_ptr += sizeof(struct cdma_descriptor); + pc[info.cdma_num].NxtPointerHi = next_ptr >> 16; + pc[info.cdma_num].NxtPointerLo = next_ptr & 0xffff; + + /* Use the Block offset within a bank */ + tmp_c = info.pcmds[i].Block / + (DeviceInfo.wTotalBlocks / totalUsedBanks); + flash_add = (u64)(info.pcmds[i].Block - tmp_c * + (DeviceInfo.wTotalBlocks / totalUsedBanks)) * + DeviceInfo.wBlockDataSize + + (u64)(info.pcmds[i].Page) * + DeviceInfo.wPageDataSize; + + ptr = MODE_10 | (info.flash_bank << 24) | + (u32)GLOB_u64_Div(flash_add, + DeviceInfo.wPageDataSize); + pc[info.cdma_num].FlashPointerHi = ptr >> 16; + pc[info.cdma_num].FlashPointerLo = ptr & 0xffff; + + if ((info.pcmds[i].CMD == WRITE_MAIN_SPARE_CMD) || + (info.pcmds[i].CMD == READ_MAIN_SPARE_CMD)) { + /* Descriptor to set Main+Spare Access Mode */ + pc[info.cdma_num].CommandType = 0x43; + pc[info.cdma_num].CommandFlags = + (0 << 10) | (1 << 9) | (0 << 8) | 0x40; + pc[info.cdma_num].MemAddrHi = 0; + pc[info.cdma_num].MemAddrLo = 0; + pc[info.cdma_num].Channel = 0; + pc[info.cdma_num].Status = 0; + pc[info.cdma_num].pcmd = i; + + info.cdma_num++; + BUG_ON(info.cdma_num >= MAX_DESCS); + + reset_cdma_desc(info.cdma_num); + next_ptr += sizeof(struct cdma_descriptor); + pc[info.cdma_num].NxtPointerHi = next_ptr >> 16; + pc[info.cdma_num].NxtPointerLo = next_ptr & 0xffff; + pc[info.cdma_num].FlashPointerHi = ptr >> 16; + pc[info.cdma_num].FlashPointerLo = ptr & 0xffff; + } + + switch (info.pcmds[i].CMD) { + case ERASE_CMD: + pc[info.cdma_num].CommandType = 1; + pc[info.cdma_num].CommandFlags = + (0 << 10) | (1 << 9) | (0 << 8) | 0x40; + pc[info.cdma_num].MemAddrHi = 0; + pc[info.cdma_num].MemAddrLo = 0; + break; + + case WRITE_MAIN_CMD: + pc[info.cdma_num].CommandType = + 0x2100 | info.pcmds[i].PageCount; + pc[info.cdma_num].CommandFlags = + (0 << 10) | (1 << 9) | (0 << 8) | 0x40; + map_addr = virt_to_bus(info.pcmds[i].DataAddr); + pc[info.cdma_num].MemAddrHi = map_addr >> 16; + pc[info.cdma_num].MemAddrLo = map_addr & 0xffff; + break; + + case READ_MAIN_CMD: + pc[info.cdma_num].CommandType = + 0x2000 | info.pcmds[i].PageCount; + pc[info.cdma_num].CommandFlags = + (0 << 10) | (1 << 9) | (0 << 8) | 0x40; + map_addr = virt_to_bus(info.pcmds[i].DataAddr); + pc[info.cdma_num].MemAddrHi = map_addr >> 16; + pc[info.cdma_num].MemAddrLo = map_addr & 0xffff; + break; + + case WRITE_MAIN_SPARE_CMD: + pc[info.cdma_num].CommandType = + 0x2100 | info.pcmds[i].PageCount; + pc[info.cdma_num].CommandFlags = + (0 << 10) | (1 << 9) | (0 << 8) | 0x40; + map_addr = virt_to_bus(info.pcmds[i].DataAddr); + pc[info.cdma_num].MemAddrHi = map_addr >> 16; + pc[info.cdma_num].MemAddrLo = map_addr & 0xffff; + break; + + case READ_MAIN_SPARE_CMD: + pc[info.cdma_num].CommandType = + 0x2000 | info.pcmds[i].PageCount; + pc[info.cdma_num].CommandFlags = + (0 << 10) | (1 << 9) | (0 << 8) | 0x40; + map_addr = virt_to_bus(info.pcmds[i].DataAddr); + pc[info.cdma_num].MemAddrHi = map_addr >> 16; + pc[info.cdma_num].MemAddrLo = map_addr & 0xffff; + break; + + case MEMCOPY_CMD: + pc[info.cdma_num].CommandType = 0xFFFF; /* NOP cmd */ + /* Set bit 11 to let the CDMA engine continue to */ + /* execute only after it has finished processing */ + /* the memcopy descriptor. */ + /* Also set bit 10 and bit 9 to 1 */ + pc[info.cdma_num].CommandFlags = 0x0E40; + map_addr = info.memcp_desc + info.cdma_num * + sizeof(struct memcpy_descriptor); + pc[info.cdma_num].MemCopyPointerHi = map_addr >> 16; + pc[info.cdma_num].MemCopyPointerLo = map_addr & 0xffff; + + pm[info.cdma_num].NxtPointerHi = 0; + pm[info.cdma_num].NxtPointerLo = 0; + + map_addr = virt_to_bus(info.pcmds[i].DataSrcAddr); + pm[info.cdma_num].SrcAddrHi = map_addr >> 16; + pm[info.cdma_num].SrcAddrLo = map_addr & 0xffff; + map_addr = virt_to_bus(info.pcmds[i].DataDestAddr); + pm[info.cdma_num].DestAddrHi = map_addr >> 16; + pm[info.cdma_num].DestAddrLo = map_addr & 0xffff; + + pm[info.cdma_num].XferSize = + info.pcmds[i].MemCopyByteCnt; + pm[info.cdma_num].MemCopyFlags = + (0 << 15 | 0 << 14 | 27 << 8 | 0x40); + pm[info.cdma_num].MemCopyStatus = 0; + break; + + case DUMMY_CMD: + default: + pc[info.cdma_num].CommandType = 0XFFFF; + pc[info.cdma_num].CommandFlags = + (0 << 10) | (1 << 9) | (0 << 8) | 0x40; + pc[info.cdma_num].MemAddrHi = 0; + pc[info.cdma_num].MemAddrLo = 0; + break; + } + + pc[info.cdma_num].Channel = 0; + pc[info.cdma_num].Status = 0; + pc[info.cdma_num].pcmd = i; + + info.cdma_num++; + BUG_ON(info.cdma_num >= MAX_DESCS); + + if ((info.pcmds[i].CMD == WRITE_MAIN_SPARE_CMD) || + (info.pcmds[i].CMD == READ_MAIN_SPARE_CMD)) { + /* Descriptor to set back Main Area Access Mode */ + reset_cdma_desc(info.cdma_num); + next_ptr += sizeof(struct cdma_descriptor); + pc[info.cdma_num].NxtPointerHi = next_ptr >> 16; + pc[info.cdma_num].NxtPointerLo = next_ptr & 0xffff; + + pc[info.cdma_num].FlashPointerHi = ptr >> 16; + pc[info.cdma_num].FlashPointerLo = ptr & 0xffff; + + pc[info.cdma_num].CommandType = 0x42; + pc[info.cdma_num].CommandFlags = + (0 << 10) | (1 << 9) | (0 << 8) | 0x40; + pc[info.cdma_num].MemAddrHi = 0; + pc[info.cdma_num].MemAddrLo = 0; + + pc[info.cdma_num].Channel = 0; + pc[info.cdma_num].Status = 0; + pc[info.cdma_num].pcmd = i; + + info.cdma_num++; + BUG_ON(info.cdma_num >= MAX_DESCS); + } + } + + /* Add a dummy descriptor at end of the CDMA chain */ + reset_cdma_desc(info.cdma_num); + ptr = MODE_10 | (info.flash_bank << 24); + pc[info.cdma_num].FlashPointerHi = ptr >> 16; + pc[info.cdma_num].FlashPointerLo = ptr & 0xffff; + pc[info.cdma_num].CommandType = 0xFFFF; /* NOP command */ + /* Set Command Flags for the last CDMA descriptor: */ + /* set Continue bit (bit 9) to 0 and Interrupt bit (bit 8) to 1 */ + pc[info.cdma_num].CommandFlags = + (0 << 10) | (0 << 9) | (1 << 8) | 0x40; + pc[info.cdma_num].pcmd = 0xff; /* Set it to an illegal value */ + info.cdma_num++; + BUG_ON(info.cdma_num >= MAX_DESCS); + + iowrite32(1, FlashReg + GLOBAL_INT_ENABLE); /* Enable Interrupt */ + + iowrite32(1, FlashReg + DMA_ENABLE); + /* Wait for DMA to be enabled before issuing the next command */ + while (!(ioread32(FlashReg + DMA_ENABLE) & DMA_ENABLE__FLAG)) + ; + cdma_trans(info.flash_bank); + + ret = wait_for_completion_timeout(&info.complete, 50 * HZ); + if (!ret) + printk(KERN_ERR "Wait for completion timeout " + "in %s, Line %d\n", __FILE__, __LINE__); + status = info.ret; + + info.pcmds_num = 0; /* Clear the pending cmds number to 0 */ + + return status; +} + +int is_cdma_interrupt(void) +{ + u32 ints_b0, ints_b1, ints_b2, ints_b3, ints_cdma; + u32 int_en_mask; + u32 cdma_int_en_mask; + + nand_dbg_print(NAND_DBG_DEBUG, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + /* Set the global Enable masks for only those interrupts + * that are supported */ + cdma_int_en_mask = (DMA_INTR__DESC_COMP_CHANNEL0 | + DMA_INTR__DESC_COMP_CHANNEL1 | + DMA_INTR__DESC_COMP_CHANNEL2 | + DMA_INTR__DESC_COMP_CHANNEL3 | + DMA_INTR__MEMCOPY_DESC_COMP); + + int_en_mask = (INTR_STATUS0__ECC_ERR | + INTR_STATUS0__PROGRAM_FAIL | + INTR_STATUS0__ERASE_FAIL); + + ints_b0 = ioread32(FlashReg + INTR_STATUS0) & int_en_mask; + ints_b1 = ioread32(FlashReg + INTR_STATUS1) & int_en_mask; + ints_b2 = ioread32(FlashReg + INTR_STATUS2) & int_en_mask; + ints_b3 = ioread32(FlashReg + INTR_STATUS3) & int_en_mask; + ints_cdma = ioread32(FlashReg + DMA_INTR) & cdma_int_en_mask; + + nand_dbg_print(NAND_DBG_WARN, "ints_bank0 to ints_bank3: " + "0x%x, 0x%x, 0x%x, 0x%x, ints_cdma: 0x%x\n", + ints_b0, ints_b1, ints_b2, ints_b3, ints_cdma); + + if (ints_b0 || ints_b1 || ints_b2 || ints_b3 || ints_cdma) { + return 1; + } else { + iowrite32(ints_b0, FlashReg + INTR_STATUS0); + iowrite32(ints_b1, FlashReg + INTR_STATUS1); + iowrite32(ints_b2, FlashReg + INTR_STATUS2); + iowrite32(ints_b3, FlashReg + INTR_STATUS3); + nand_dbg_print(NAND_DBG_DEBUG, + "Not a NAND controller interrupt! Ignore it.\n"); + return 0; + } +} + +static void update_event_status(void) +{ + int i; + struct cdma_descriptor *ptr; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + ptr = (struct cdma_descriptor *)info.cdma_desc_buf; + + for (i = 0; i < info.cdma_num; i++) { + if (ptr[i].pcmd != 0xff) + info.pcmds[ptr[i].pcmd].Status = CMD_PASS; + if ((ptr[i].CommandType == 0x41) || + (ptr[i].CommandType == 0x42) || + (ptr[i].CommandType == 0x43)) + continue; + + switch (info.pcmds[ptr[i].pcmd].CMD) { + case READ_MAIN_SPARE_CMD: + Conv_Main_Spare_Data_Phy2Log_Format( + info.pcmds[ptr[i].pcmd].DataAddr, + info.pcmds[ptr[i].pcmd].PageCount); + break; + case READ_SPARE_CMD: + Conv_Spare_Data_Phy2Log_Format( + info.pcmds[ptr[i].pcmd].DataAddr); + break; + } + } +} + +static u16 do_ecc_for_desc(u32 ch, u8 *buf, u16 page) +{ + u16 event = EVENT_NONE; + u16 err_byte; + u16 err_page = 0; + u8 err_sector; + u8 err_device; + u16 ecc_correction_info; + u16 err_address; + u32 eccSectorSize; + u8 *err_pos; + + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + eccSectorSize = ECC_SECTOR_SIZE * (DeviceInfo.wDevicesConnected); + + do { + if (0 == ch) + err_page = ioread32(FlashReg + ERR_PAGE_ADDR0); + else if (1 == ch) + err_page = ioread32(FlashReg + ERR_PAGE_ADDR1); + else if (2 == ch) + err_page = ioread32(FlashReg + ERR_PAGE_ADDR2); + else if (3 == ch) + err_page = ioread32(FlashReg + ERR_PAGE_ADDR3); + + err_address = ioread32(FlashReg + ECC_ERROR_ADDRESS); + err_byte = err_address & ECC_ERROR_ADDRESS__OFFSET; + err_sector = ((err_address & + ECC_ERROR_ADDRESS__SECTOR_NR) >> 12); + + ecc_correction_info = ioread32(FlashReg + ERR_CORRECTION_INFO); + err_device = ((ecc_correction_info & + ERR_CORRECTION_INFO__DEVICE_NR) >> 8); + + if (ecc_correction_info & ERR_CORRECTION_INFO__ERROR_TYPE) { + event = EVENT_UNCORRECTABLE_DATA_ERROR; + } else { + event = EVENT_CORRECTABLE_DATA_ERROR_FIXED; + if (err_byte < ECC_SECTOR_SIZE) { + err_pos = buf + + (err_page - page) * + DeviceInfo.wPageDataSize + + err_sector * eccSectorSize + + err_byte * + DeviceInfo.wDevicesConnected + + err_device; + *err_pos ^= ecc_correction_info & + ERR_CORRECTION_INFO__BYTEMASK; + } + } + } while (!(ecc_correction_info & ERR_CORRECTION_INFO__LAST_ERR_INFO)); + + return event; +} + +static u16 process_ecc_int(u32 c, u16 *p_desc_num) +{ + struct cdma_descriptor *ptr; + u16 j; + int event = EVENT_PASS; + + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (c != info.flash_bank) + printk(KERN_ERR "Error!info.flash_bank is %d, while c is %d\n", + info.flash_bank, c); + + ptr = (struct cdma_descriptor *)info.cdma_desc_buf; + + for (j = 0; j < info.cdma_num; j++) + if ((ptr[j].Status & CMD_DMA_DESC_COMP) != CMD_DMA_DESC_COMP) + break; + + *p_desc_num = j; /* Pass the descripter number found here */ + + if (j >= info.cdma_num) { + printk(KERN_ERR "Can not find the correct descriptor number " + "when ecc interrupt triggered!" + "info.cdma_num: %d, j: %d\n", info.cdma_num, j); + return EVENT_UNCORRECTABLE_DATA_ERROR; + } + + event = do_ecc_for_desc(c, info.pcmds[ptr[j].pcmd].DataAddr, + info.pcmds[ptr[j].pcmd].Page); + + if (EVENT_UNCORRECTABLE_DATA_ERROR == event) { + printk(KERN_ERR "Uncorrectable ECC error!" + "info.cdma_num: %d, j: %d, " + "pending cmd CMD: 0x%x, " + "Block: 0x%x, Page: 0x%x, PageCount: 0x%x\n", + info.cdma_num, j, + info.pcmds[ptr[j].pcmd].CMD, + info.pcmds[ptr[j].pcmd].Block, + info.pcmds[ptr[j].pcmd].Page, + info.pcmds[ptr[j].pcmd].PageCount); + + if (ptr[j].pcmd != 0xff) + info.pcmds[ptr[j].pcmd].Status = CMD_FAIL; + CDMA_UpdateEventStatus(); + } + + return event; +} + +static void process_prog_erase_fail_int(u16 desc_num) +{ + struct cdma_descriptor *ptr; + + nand_dbg_print(NAND_DBG_DEBUG, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + ptr = (struct cdma_descriptor *)info.cdma_desc_buf; + + if (ptr[desc_num].pcmd != 0xFF) + info.pcmds[ptr[desc_num].pcmd].Status = CMD_FAIL; + + CDMA_UpdateEventStatus(); +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: CDMA_Event_Status (for use with CMD_DMA) +* Inputs: none +* Outputs: Event_Status code +* Description: This function is called after an interrupt has happened +* It reads the HW status register and ...tbd +* It returns the appropriate event status +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 CDMA_Event_Status(void) +{ + u32 ints_addr[4] = {INTR_STATUS0, INTR_STATUS1, + INTR_STATUS2, INTR_STATUS3}; + u32 dma_intr_bit[4] = {DMA_INTR__DESC_COMP_CHANNEL0, + DMA_INTR__DESC_COMP_CHANNEL1, + DMA_INTR__DESC_COMP_CHANNEL2, + DMA_INTR__DESC_COMP_CHANNEL3}; + u32 cdma_int_status, int_status; + u32 ecc_enable = 0; + u16 event = EVENT_PASS; + u16 cur_desc = 0; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + ecc_enable = ioread32(FlashReg + ECC_ENABLE); + + while (1) { + int_status = ioread32(FlashReg + ints_addr[info.flash_bank]); + if (ecc_enable && (int_status & INTR_STATUS0__ECC_ERR)) { + event = process_ecc_int(info.flash_bank, &cur_desc); + iowrite32(INTR_STATUS0__ECC_ERR, + FlashReg + ints_addr[info.flash_bank]); + if (EVENT_UNCORRECTABLE_DATA_ERROR == event) { + nand_dbg_print(NAND_DBG_WARN, + "ints_bank0 to ints_bank3: " + "0x%x, 0x%x, 0x%x, 0x%x, " + "ints_cdma: 0x%x\n", + ioread32(FlashReg + INTR_STATUS0), + ioread32(FlashReg + INTR_STATUS1), + ioread32(FlashReg + INTR_STATUS2), + ioread32(FlashReg + INTR_STATUS3), + ioread32(FlashReg + DMA_INTR)); + break; + } + } else if (int_status & INTR_STATUS0__PROGRAM_FAIL) { + printk(KERN_ERR "NAND program fail interrupt!\n"); + process_prog_erase_fail_int(cur_desc); + event = EVENT_PROGRAM_FAILURE; + break; + } else if (int_status & INTR_STATUS0__ERASE_FAIL) { + printk(KERN_ERR "NAND erase fail interrupt!\n"); + process_prog_erase_fail_int(cur_desc); + event = EVENT_ERASE_FAILURE; + break; + } else { + cdma_int_status = ioread32(FlashReg + DMA_INTR); + if (cdma_int_status & dma_intr_bit[info.flash_bank]) { + iowrite32(dma_intr_bit[info.flash_bank], + FlashReg + DMA_INTR); + update_event_status(); + event = EVENT_PASS; + break; + } + } + } + + int_status = ioread32(FlashReg + ints_addr[info.flash_bank]); + iowrite32(int_status, FlashReg + ints_addr[info.flash_bank]); + cdma_int_status = ioread32(FlashReg + DMA_INTR); + iowrite32(cdma_int_status, FlashReg + DMA_INTR); + + iowrite32(0, FlashReg + DMA_ENABLE); + while ((ioread32(FlashReg + DMA_ENABLE) & DMA_ENABLE__FLAG)) + ; + + return event; +} + + + diff --git a/drivers/block/spectra/lld_cdma.h b/drivers/block/spectra/lld_cdma.h new file mode 100644 index 000000000000..854ea066f0c4 --- /dev/null +++ b/drivers/block/spectra/lld_cdma.h @@ -0,0 +1,123 @@ +/* + * NAND Flash Controller Device Driver + * Copyright (c) 2009, Intel Corporation and its suppliers. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +/* header for LLD_CDMA.c module */ + +#ifndef _LLD_CDMA_ +#define _LLD_CDMA_ + +#include "flash.h" + +#define DEBUG_SYNC 1 + +/*/////////// CDMA specific MACRO definition */ +#define MAX_DESCS (255) +#define MAX_CHANS (4) +#define MAX_SYNC_POINTS (16) +#define MAX_DESC_PER_CHAN (MAX_DESCS * 3 + MAX_SYNC_POINTS + 2) + +#define CHANNEL_SYNC_MASK (0x000F) +#define CHANNEL_DMA_MASK (0x00F0) +#define CHANNEL_ID_MASK (0x0300) +#define CHANNEL_CONT_MASK (0x4000) +#define CHANNEL_INTR_MASK (0x8000) + +#define CHANNEL_SYNC_OFFSET (0) +#define CHANNEL_DMA_OFFSET (4) +#define CHANNEL_ID_OFFSET (8) +#define CHANNEL_CONT_OFFSET (14) +#define CHANNEL_INTR_OFFSET (15) + +u16 CDMA_Data_CMD(u8 cmd, u8 *data, u32 block, u16 page, u16 num, u16 flags); +u16 CDMA_MemCopy_CMD(u8 *dest, u8 *src, u32 byte_cnt, u16 flags); +u16 CDMA_Execute_CMDs(void); +void print_pending_cmds(void); +void print_cdma_descriptors(void); + +extern u8 g_SBDCmdIndex; +extern struct mrst_nand_info info; + + +/*/////////// prototypes: APIs for LLD_CDMA */ +int is_cdma_interrupt(void); +u16 CDMA_Event_Status(void); + +/* CMD-DMA Descriptor Struct. These are defined by the CMD_DMA HW */ +struct cdma_descriptor { + u32 NxtPointerHi; + u32 NxtPointerLo; + u32 FlashPointerHi; + u32 FlashPointerLo; + u32 CommandType; + u32 MemAddrHi; + u32 MemAddrLo; + u32 CommandFlags; + u32 Channel; + u32 Status; + u32 MemCopyPointerHi; + u32 MemCopyPointerLo; + u32 Reserved12; + u32 Reserved13; + u32 Reserved14; + u32 pcmd; /* pending cmd num related to this descriptor */ +}; + +/* This struct holds one MemCopy descriptor as defined by the HW */ +struct memcpy_descriptor { + u32 NxtPointerHi; + u32 NxtPointerLo; + u32 SrcAddrHi; + u32 SrcAddrLo; + u32 DestAddrHi; + u32 DestAddrLo; + u32 XferSize; + u32 MemCopyFlags; + u32 MemCopyStatus; + u32 reserved9; + u32 reserved10; + u32 reserved11; + u32 reserved12; + u32 reserved13; + u32 reserved14; + u32 reserved15; +}; + +/* Pending CMD table entries (includes MemCopy parameters */ +struct pending_cmd { + u8 CMD; + u8 *DataAddr; + u32 Block; + u16 Page; + u16 PageCount; + u8 *DataDestAddr; + u8 *DataSrcAddr; + u32 MemCopyByteCnt; + u16 Flags; + u16 Status; +}; + +#if DEBUG_SYNC +extern u32 debug_sync_cnt; +#endif + +/* Definitions for CMD DMA descriptor chain fields */ +#define CMD_DMA_DESC_COMP 0x8000 +#define CMD_DMA_DESC_FAIL 0x4000 + +#endif /*_LLD_CDMA_*/ diff --git a/drivers/block/spectra/lld_emu.c b/drivers/block/spectra/lld_emu.c new file mode 100644 index 000000000000..60eb0f6fdba4 --- /dev/null +++ b/drivers/block/spectra/lld_emu.c @@ -0,0 +1,780 @@ +/* + * NAND Flash Controller Device Driver + * Copyright (c) 2009, Intel Corporation and its suppliers. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include +#include +#include "flash.h" +#include "ffsdefs.h" +#include "lld_emu.h" +#include "lld.h" +#if CMD_DMA +#include "lld_cdma.h" +#endif + +#define GLOB_LLD_PAGES 64 +#define GLOB_LLD_PAGE_SIZE (512+16) +#define GLOB_LLD_PAGE_DATA_SIZE 512 +#define GLOB_LLD_BLOCKS 2048 + +#if (CMD_DMA && FLASH_EMU) +#include "lld_cdma.h" +u32 totalUsedBanks; +u32 valid_banks[MAX_CHANS]; +#endif + +#if FLASH_EMU /* This is for entire module */ + +static u8 *flash_memory[GLOB_LLD_BLOCKS * GLOB_LLD_PAGES]; + +/* Read nand emu file and then fill it's content to flash_memory */ +int emu_load_file_to_mem(void) +{ + mm_segment_t fs; + struct file *nef_filp = NULL; + struct inode *inode = NULL; + loff_t nef_size = 0; + loff_t tmp_file_offset, file_offset; + ssize_t nread; + int i, rc = -EINVAL; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + fs = get_fs(); + set_fs(get_ds()); + + nef_filp = filp_open("/root/nand_emu_file", O_RDWR | O_LARGEFILE, 0); + if (IS_ERR(nef_filp)) { + printk(KERN_ERR "filp_open error: " + "Unable to open nand emu file!\n"); + return PTR_ERR(nef_filp); + } + + if (nef_filp->f_path.dentry) { + inode = nef_filp->f_path.dentry->d_inode; + } else { + printk(KERN_ERR "Can not get valid inode!\n"); + goto out; + } + + nef_size = i_size_read(inode->i_mapping->host); + if (nef_size <= 0) { + printk(KERN_ERR "Invalid nand emu file size: " + "0x%llx\n", nef_size); + goto out; + } else { + nand_dbg_print(NAND_DBG_DEBUG, "nand emu file size: %lld\n", + nef_size); + } + + file_offset = 0; + for (i = 0; i < GLOB_LLD_BLOCKS * GLOB_LLD_PAGES; i++) { + tmp_file_offset = file_offset; + nread = vfs_read(nef_filp, + (char __user *)flash_memory[i], + GLOB_LLD_PAGE_SIZE, &tmp_file_offset); + if (nread < GLOB_LLD_PAGE_SIZE) { + printk(KERN_ERR "%s, Line %d - " + "nand emu file partial read: " + "%d bytes\n", __FILE__, __LINE__, (int)nread); + goto out; + } + file_offset += GLOB_LLD_PAGE_SIZE; + } + rc = 0; + +out: + filp_close(nef_filp, current->files); + set_fs(fs); + return rc; +} + +/* Write contents of flash_memory to nand emu file */ +int emu_write_mem_to_file(void) +{ + mm_segment_t fs; + struct file *nef_filp = NULL; + struct inode *inode = NULL; + loff_t nef_size = 0; + loff_t tmp_file_offset, file_offset; + ssize_t nwritten; + int i, rc = -EINVAL; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + fs = get_fs(); + set_fs(get_ds()); + + nef_filp = filp_open("/root/nand_emu_file", O_RDWR | O_LARGEFILE, 0); + if (IS_ERR(nef_filp)) { + printk(KERN_ERR "filp_open error: " + "Unable to open nand emu file!\n"); + return PTR_ERR(nef_filp); + } + + if (nef_filp->f_path.dentry) { + inode = nef_filp->f_path.dentry->d_inode; + } else { + printk(KERN_ERR "Invalid " "nef_filp->f_path.dentry value!\n"); + goto out; + } + + nef_size = i_size_read(inode->i_mapping->host); + if (nef_size <= 0) { + printk(KERN_ERR "Invalid " + "nand emu file size: 0x%llx\n", nef_size); + goto out; + } else { + nand_dbg_print(NAND_DBG_DEBUG, "nand emu file size: " + "%lld\n", nef_size); + } + + file_offset = 0; + for (i = 0; i < GLOB_LLD_BLOCKS * GLOB_LLD_PAGES; i++) { + tmp_file_offset = file_offset; + nwritten = vfs_write(nef_filp, + (char __user *)flash_memory[i], + GLOB_LLD_PAGE_SIZE, &tmp_file_offset); + if (nwritten < GLOB_LLD_PAGE_SIZE) { + printk(KERN_ERR "%s, Line %d - " + "nand emu file partial write: " + "%d bytes\n", __FILE__, __LINE__, (int)nwritten); + goto out; + } + file_offset += GLOB_LLD_PAGE_SIZE; + } + rc = 0; + +out: + filp_close(nef_filp, current->files); + set_fs(fs); + return rc; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: emu_Flash_Init +* Inputs: none +* Outputs: PASS=0 (notice 0=ok here) +* Description: Creates & initializes the flash RAM array. +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 emu_Flash_Init(void) +{ + int i; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + flash_memory[0] = (u8 *)vmalloc(GLOB_LLD_PAGE_SIZE * + GLOB_LLD_BLOCKS * + GLOB_LLD_PAGES * + sizeof(u8)); + if (!flash_memory[0]) { + printk(KERN_ERR "Fail to allocate memory " + "for nand emulator!\n"); + return ERR; + } + + memset((char *)(flash_memory[0]), 0xFF, + GLOB_LLD_PAGE_SIZE * GLOB_LLD_BLOCKS * GLOB_LLD_PAGES * + sizeof(u8)); + + for (i = 1; i < GLOB_LLD_BLOCKS * GLOB_LLD_PAGES; i++) + flash_memory[i] = flash_memory[i - 1] + GLOB_LLD_PAGE_SIZE; + + emu_load_file_to_mem(); /* Load nand emu file to mem */ + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: emu_Flash_Release +* Inputs: none +* Outputs: PASS=0 (notice 0=ok here) +* Description: Releases the flash. +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int emu_Flash_Release(void) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + emu_write_mem_to_file(); /* Write back mem to nand emu file */ + + vfree(flash_memory[0]); + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: emu_Read_Device_ID +* Inputs: none +* Outputs: PASS=1 FAIL=0 +* Description: Reads the info from the controller registers. +* Sets up DeviceInfo structure with device parameters +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ + +u16 emu_Read_Device_ID(void) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + DeviceInfo.wDeviceMaker = 0; + DeviceInfo.wDeviceType = 8; + DeviceInfo.wSpectraStartBlock = 36; + DeviceInfo.wSpectraEndBlock = GLOB_LLD_BLOCKS - 1; + DeviceInfo.wTotalBlocks = GLOB_LLD_BLOCKS; + DeviceInfo.wPagesPerBlock = GLOB_LLD_PAGES; + DeviceInfo.wPageSize = GLOB_LLD_PAGE_SIZE; + DeviceInfo.wPageDataSize = GLOB_LLD_PAGE_DATA_SIZE; + DeviceInfo.wPageSpareSize = GLOB_LLD_PAGE_SIZE - + GLOB_LLD_PAGE_DATA_SIZE; + DeviceInfo.wBlockSize = DeviceInfo.wPageSize * GLOB_LLD_PAGES; + DeviceInfo.wBlockDataSize = DeviceInfo.wPageDataSize * GLOB_LLD_PAGES; + DeviceInfo.wDataBlockNum = (u32) (DeviceInfo.wSpectraEndBlock - + DeviceInfo.wSpectraStartBlock + + 1); + DeviceInfo.MLCDevice = 1; /* Emulate MLC device */ + DeviceInfo.nBitsInPageNumber = + (u8)GLOB_Calc_Used_Bits(DeviceInfo.wPagesPerBlock); + DeviceInfo.nBitsInPageDataSize = + (u8)GLOB_Calc_Used_Bits(DeviceInfo.wPageDataSize); + DeviceInfo.nBitsInBlockDataSize = + (u8)GLOB_Calc_Used_Bits(DeviceInfo.wBlockDataSize); + +#if CMD_DMA + totalUsedBanks = 4; + valid_banks[0] = 1; + valid_banks[1] = 1; + valid_banks[2] = 1; + valid_banks[3] = 1; +#endif + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: emu_Flash_Reset +* Inputs: none +* Outputs: PASS=0 (notice 0=ok here) +* Description: Reset the flash +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 emu_Flash_Reset(void) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: emu_Erase_Block +* Inputs: Address +* Outputs: PASS=0 (notice 0=ok here) +* Description: Erase a block +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 emu_Erase_Block(u32 block_add) +{ + int i; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (block_add >= DeviceInfo.wTotalBlocks) { + printk(KERN_ERR "emu_Erase_Block error! " + "Too big block address: %d\n", block_add); + return FAIL; + } + + nand_dbg_print(NAND_DBG_DEBUG, "Erasing block %d\n", + (int)block_add); + + for (i = block_add * GLOB_LLD_PAGES; + i < ((block_add + 1) * GLOB_LLD_PAGES); i++) { + if (flash_memory[i]) { + memset((u8 *)(flash_memory[i]), 0xFF, + DeviceInfo.wPageSize * sizeof(u8)); + } + } + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: emu_Write_Page_Main +* Inputs: Write buffer address pointer +* Block number +* Page number +* Number of pages to process +* Outputs: PASS=0 (notice 0=ok here) +* Description: Write the data in the buffer to main area of flash +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 emu_Write_Page_Main(u8 *write_data, u32 Block, + u16 Page, u16 PageCount) +{ + int i; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (Block >= DeviceInfo.wTotalBlocks) + return FAIL; + + if (Page + PageCount > DeviceInfo.wPagesPerBlock) + return FAIL; + + nand_dbg_print(NAND_DBG_DEBUG, "emu_Write_Page_Main: " + "lba %u Page %u PageCount %u\n", + (unsigned int)Block, + (unsigned int)Page, (unsigned int)PageCount); + + for (i = 0; i < PageCount; i++) { + if (NULL == flash_memory[Block * GLOB_LLD_PAGES + Page]) { + printk(KERN_ERR "Run out of memory\n"); + return FAIL; + } + memcpy((u8 *) (flash_memory[Block * GLOB_LLD_PAGES + Page]), + write_data, DeviceInfo.wPageDataSize); + write_data += DeviceInfo.wPageDataSize; + Page++; + } + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: emu_Read_Page_Main +* Inputs: Read buffer address pointer +* Block number +* Page number +* Number of pages to process +* Outputs: PASS=0 (notice 0=ok here) +* Description: Read the data from the flash main area to the buffer +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 emu_Read_Page_Main(u8 *read_data, u32 Block, + u16 Page, u16 PageCount) +{ + int i; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (Block >= DeviceInfo.wTotalBlocks) + return FAIL; + + if (Page + PageCount > DeviceInfo.wPagesPerBlock) + return FAIL; + + nand_dbg_print(NAND_DBG_DEBUG, "emu_Read_Page_Main: " + "lba %u Page %u PageCount %u\n", + (unsigned int)Block, + (unsigned int)Page, (unsigned int)PageCount); + + for (i = 0; i < PageCount; i++) { + if (NULL == flash_memory[Block * GLOB_LLD_PAGES + Page]) { + memset(read_data, 0xFF, DeviceInfo.wPageDataSize); + } else { + memcpy(read_data, + (u8 *) (flash_memory[Block * GLOB_LLD_PAGES + + Page]), + DeviceInfo.wPageDataSize); + } + read_data += DeviceInfo.wPageDataSize; + Page++; + } + + return PASS; +} + +#ifndef ELDORA +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: emu_Read_Page_Main_Spare +* Inputs: Write Buffer +* Address +* Buffer size +* Outputs: PASS=0 (notice 0=ok here) +* Description: Read from flash main+spare area +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 emu_Read_Page_Main_Spare(u8 *read_data, u32 Block, + u16 Page, u16 PageCount) +{ + int i; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (Block >= DeviceInfo.wTotalBlocks) { + printk(KERN_ERR "Read Page Main+Spare " + "Error: Block Address too big\n"); + return FAIL; + } + + if (Page + PageCount > DeviceInfo.wPagesPerBlock) { + printk(KERN_ERR "Read Page Main+Spare " + "Error: Page number too big\n"); + return FAIL; + } + + nand_dbg_print(NAND_DBG_DEBUG, "Read Page Main + Spare - " + "No. of pages %u block %u start page %u\n", + (unsigned int)PageCount, + (unsigned int)Block, (unsigned int)Page); + + for (i = 0; i < PageCount; i++) { + if (NULL == flash_memory[Block * GLOB_LLD_PAGES + Page]) { + memset(read_data, 0xFF, DeviceInfo.wPageSize); + } else { + memcpy(read_data, (u8 *) (flash_memory[Block * + GLOB_LLD_PAGES + + Page]), + DeviceInfo.wPageSize); + } + + read_data += DeviceInfo.wPageSize; + Page++; + } + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: emu_Write_Page_Main_Spare +* Inputs: Write buffer +* address +* buffer length +* Outputs: PASS=0 (notice 0=ok here) +* Description: Write the buffer to main+spare area of flash +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 emu_Write_Page_Main_Spare(u8 *write_data, u32 Block, + u16 Page, u16 page_count) +{ + u16 i; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (Block >= DeviceInfo.wTotalBlocks) { + printk(KERN_ERR "Write Page Main + Spare " + "Error: Block Address too big\n"); + return FAIL; + } + + if (Page + page_count > DeviceInfo.wPagesPerBlock) { + printk(KERN_ERR "Write Page Main + Spare " + "Error: Page number too big\n"); + return FAIL; + } + + nand_dbg_print(NAND_DBG_DEBUG, "Write Page Main+Spare - " + "No. of pages %u block %u start page %u\n", + (unsigned int)page_count, + (unsigned int)Block, (unsigned int)Page); + + for (i = 0; i < page_count; i++) { + if (NULL == flash_memory[Block * GLOB_LLD_PAGES + Page]) { + printk(KERN_ERR "Run out of memory!\n"); + return FAIL; + } + memcpy((u8 *) (flash_memory[Block * GLOB_LLD_PAGES + Page]), + write_data, DeviceInfo.wPageSize); + write_data += DeviceInfo.wPageSize; + Page++; + } + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: emu_Write_Page_Spare +* Inputs: Write buffer +* Address +* buffer size +* Outputs: PASS=0 (notice 0=ok here) +* Description: Write the buffer in the spare area +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 emu_Write_Page_Spare(u8 *write_data, u32 Block, + u16 Page, u16 PageCount) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (Block >= DeviceInfo.wTotalBlocks) { + printk(KERN_ERR "Read Page Spare Error: " + "Block Address too big\n"); + return FAIL; + } + + if (Page + PageCount > DeviceInfo.wPagesPerBlock) { + printk(KERN_ERR "Read Page Spare Error: " + "Page number too big\n"); + return FAIL; + } + + nand_dbg_print(NAND_DBG_DEBUG, "Write Page Spare- " + "block %u page %u\n", + (unsigned int)Block, (unsigned int)Page); + + if (NULL == flash_memory[Block * GLOB_LLD_PAGES + Page]) { + printk(KERN_ERR "Run out of memory!\n"); + return FAIL; + } + + memcpy((u8 *) (flash_memory[Block * GLOB_LLD_PAGES + Page] + + DeviceInfo.wPageDataSize), write_data, + (DeviceInfo.wPageSize - DeviceInfo.wPageDataSize)); + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: emu_Read_Page_Spare +* Inputs: Write Buffer +* Address +* Buffer size +* Outputs: PASS=0 (notice 0=ok here) +* Description: Read data from the spare area +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 emu_Read_Page_Spare(u8 *write_data, u32 Block, + u16 Page, u16 PageCount) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (Block >= DeviceInfo.wTotalBlocks) { + printk(KERN_ERR "Read Page Spare " + "Error: Block Address too big\n"); + return FAIL; + } + + if (Page + PageCount > DeviceInfo.wPagesPerBlock) { + printk(KERN_ERR "Read Page Spare " + "Error: Page number too big\n"); + return FAIL; + } + + nand_dbg_print(NAND_DBG_DEBUG, "Read Page Spare- " + "block %u page %u\n", + (unsigned int)Block, (unsigned int)Page); + + if (NULL == flash_memory[Block * GLOB_LLD_PAGES + Page]) { + memset(write_data, 0xFF, + (DeviceInfo.wPageSize - DeviceInfo.wPageDataSize)); + } else { + memcpy(write_data, + (u8 *) (flash_memory[Block * GLOB_LLD_PAGES + Page] + + DeviceInfo.wPageDataSize), + (DeviceInfo.wPageSize - DeviceInfo.wPageDataSize)); + } + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: emu_Enable_Disable_Interrupts +* Inputs: enable or disable +* Outputs: none +* Description: NOP +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +void emu_Enable_Disable_Interrupts(u16 INT_ENABLE) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); +} + +u16 emu_Get_Bad_Block(u32 block) +{ + return 0; +} + +#if CMD_DMA +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Support for CDMA functions +************************************ +* emu_CDMA_Flash_Init +* CDMA_process_data command (use LLD_CDMA) +* CDMA_MemCopy_CMD (use LLD_CDMA) +* emu_CDMA_execute all commands +* emu_CDMA_Event_Status +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 emu_CDMA_Flash_Init(void) +{ + u16 i; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + for (i = 0; i < MAX_DESCS + MAX_CHANS; i++) { + PendingCMD[i].CMD = 0; + PendingCMD[i].Tag = 0; + PendingCMD[i].DataAddr = 0; + PendingCMD[i].Block = 0; + PendingCMD[i].Page = 0; + PendingCMD[i].PageCount = 0; + PendingCMD[i].DataDestAddr = 0; + PendingCMD[i].DataSrcAddr = 0; + PendingCMD[i].MemCopyByteCnt = 0; + PendingCMD[i].ChanSync[0] = 0; + PendingCMD[i].ChanSync[1] = 0; + PendingCMD[i].ChanSync[2] = 0; + PendingCMD[i].ChanSync[3] = 0; + PendingCMD[i].ChanSync[4] = 0; + PendingCMD[i].Status = 3; + } + + return PASS; +} + +static void emu_isr(int irq, void *dev_id) +{ + /* TODO: ... */ +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: CDMA_Execute_CMDs +* Inputs: tag_count: the number of pending cmds to do +* Outputs: PASS/FAIL +* Description: execute each command in the pending CMD array +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 emu_CDMA_Execute_CMDs(u16 tag_count) +{ + u16 i, j; + u8 CMD; /* cmd parameter */ + u8 *data; + u32 block; + u16 page; + u16 count; + u16 status = PASS; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + nand_dbg_print(NAND_DBG_TRACE, "At start of Execute CMDs: " + "Tag Count %u\n", tag_count); + + for (i = 0; i < totalUsedBanks; i++) { + PendingCMD[i].CMD = DUMMY_CMD; + PendingCMD[i].Tag = 0xFF; + PendingCMD[i].Block = + (DeviceInfo.wTotalBlocks / totalUsedBanks) * i; + + for (j = 0; j <= MAX_CHANS; j++) + PendingCMD[i].ChanSync[j] = 0; + } + + CDMA_Execute_CMDs(tag_count); + + print_pending_cmds(tag_count); + +#if DEBUG_SYNC + } + debug_sync_cnt++; +#endif + + for (i = MAX_CHANS; + i < tag_count + MAX_CHANS; i++) { + CMD = PendingCMD[i].CMD; + data = PendingCMD[i].DataAddr; + block = PendingCMD[i].Block; + page = PendingCMD[i].Page; + count = PendingCMD[i].PageCount; + + switch (CMD) { + case ERASE_CMD: + emu_Erase_Block(block); + PendingCMD[i].Status = PASS; + break; + case WRITE_MAIN_CMD: + emu_Write_Page_Main(data, block, page, count); + PendingCMD[i].Status = PASS; + break; + case WRITE_MAIN_SPARE_CMD: + emu_Write_Page_Main_Spare(data, block, page, count); + PendingCMD[i].Status = PASS; + break; + case READ_MAIN_CMD: + emu_Read_Page_Main(data, block, page, count); + PendingCMD[i].Status = PASS; + break; + case MEMCOPY_CMD: + memcpy(PendingCMD[i].DataDestAddr, + PendingCMD[i].DataSrcAddr, + PendingCMD[i].MemCopyByteCnt); + case DUMMY_CMD: + PendingCMD[i].Status = PASS; + break; + default: + PendingCMD[i].Status = FAIL; + break; + } + } + + /* + * Temperory adding code to reset PendingCMD array for basic testing. + * It should be done at the end of event status function. + */ + for (i = tag_count + MAX_CHANS; i < MAX_DESCS; i++) { + PendingCMD[i].CMD = 0; + PendingCMD[i].Tag = 0; + PendingCMD[i].DataAddr = 0; + PendingCMD[i].Block = 0; + PendingCMD[i].Page = 0; + PendingCMD[i].PageCount = 0; + PendingCMD[i].DataDestAddr = 0; + PendingCMD[i].DataSrcAddr = 0; + PendingCMD[i].MemCopyByteCnt = 0; + PendingCMD[i].ChanSync[0] = 0; + PendingCMD[i].ChanSync[1] = 0; + PendingCMD[i].ChanSync[2] = 0; + PendingCMD[i].ChanSync[3] = 0; + PendingCMD[i].ChanSync[4] = 0; + PendingCMD[i].Status = CMD_NOT_DONE; + } + + nand_dbg_print(NAND_DBG_TRACE, "At end of Execute CMDs.\n"); + + emu_isr(0, 0); /* This is a null isr now. Need fill it in future */ + + return status; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: emu_Event_Status +* Inputs: none +* Outputs: Event_Status code +* Description: This function can also be used to force errors +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 emu_CDMA_Event_Status(void) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + return EVENT_PASS; +} + +#endif /* CMD_DMA */ +#endif /* !ELDORA */ +#endif /* FLASH_EMU */ diff --git a/drivers/block/spectra/lld_emu.h b/drivers/block/spectra/lld_emu.h new file mode 100644 index 000000000000..63f84c38d3c1 --- /dev/null +++ b/drivers/block/spectra/lld_emu.h @@ -0,0 +1,51 @@ +/* + * NAND Flash Controller Device Driver + * Copyright (c) 2009, Intel Corporation and its suppliers. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef _LLD_EMU_ +#define _LLD_EMU_ + +#include "ffsport.h" +#include "ffsdefs.h" + +/* prototypes: emulator API functions */ +extern u16 emu_Flash_Reset(void); +extern u16 emu_Flash_Init(void); +extern int emu_Flash_Release(void); +extern u16 emu_Read_Device_ID(void); +extern u16 emu_Erase_Block(u32 block_addr); +extern u16 emu_Write_Page_Main(u8 *write_data, u32 Block, + u16 Page, u16 PageCount); +extern u16 emu_Read_Page_Main(u8 *read_data, u32 Block, u16 Page, + u16 PageCount); +extern u16 emu_Event_Status(void); +extern void emu_Enable_Disable_Interrupts(u16 INT_ENABLE); +extern u16 emu_Write_Page_Main_Spare(u8 *write_data, u32 Block, + u16 Page, u16 PageCount); +extern u16 emu_Write_Page_Spare(u8 *write_data, u32 Block, + u16 Page, u16 PageCount); +extern u16 emu_Read_Page_Main_Spare(u8 *read_data, u32 Block, + u16 Page, u16 PageCount); +extern u16 emu_Read_Page_Spare(u8 *read_data, u32 Block, u16 Page, + u16 PageCount); +extern u16 emu_Get_Bad_Block(u32 block); + +u16 emu_CDMA_Flash_Init(void); +u16 emu_CDMA_Execute_CMDs(u16 tag_count); +u16 emu_CDMA_Event_Status(void); +#endif /*_LLD_EMU_*/ diff --git a/drivers/block/spectra/lld_nand.c b/drivers/block/spectra/lld_nand.c new file mode 100644 index 000000000000..8c279b8a6a67 --- /dev/null +++ b/drivers/block/spectra/lld_nand.c @@ -0,0 +1,2601 @@ +/* + * NAND Flash Controller Device Driver + * Copyright (c) 2009, Intel Corporation and its suppliers. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "lld.h" +#include "lld_nand.h" +#include "lld_cdma.h" + +#include "spectraswconfig.h" +#include "flash.h" +#include "ffsdefs.h" + +#include +#include +#include +#include + +#include "nand_regs.h" + +#define SPECTRA_NAND_NAME "nd" + +#define CEIL_DIV(X, Y) (((X)%(Y)) ? ((X)/(Y)+1) : ((X)/(Y))) +#define MAX_PAGES_PER_RW 128 + +#define INT_IDLE_STATE 0 +#define INT_READ_PAGE_MAIN 0x01 +#define INT_WRITE_PAGE_MAIN 0x02 +#define INT_PIPELINE_READ_AHEAD 0x04 +#define INT_PIPELINE_WRITE_AHEAD 0x08 +#define INT_MULTI_PLANE_READ 0x10 +#define INT_MULTI_PLANE_WRITE 0x11 + +static u32 enable_ecc; + +struct mrst_nand_info info; + +int totalUsedBanks; +u32 GLOB_valid_banks[LLD_MAX_FLASH_BANKS]; + +void __iomem *FlashReg; +void __iomem *FlashMem; + +u16 conf_parameters[] = { + 0x0000, + 0x0000, + 0x01F4, + 0x01F4, + 0x01F4, + 0x01F4, + 0x0000, + 0x0000, + 0x0001, + 0x0000, + 0x0000, + 0x0000, + 0x0000, + 0x0040, + 0x0001, + 0x000A, + 0x000A, + 0x000A, + 0x0000, + 0x0000, + 0x0005, + 0x0012, + 0x000C +}; + +u16 NAND_Get_Bad_Block(u32 block) +{ + u32 status = PASS; + u32 flag_bytes = 0; + u32 skip_bytes = DeviceInfo.wSpareSkipBytes; + u32 page, i; + u8 *pReadSpareBuf = buf_get_bad_block; + + if (enable_ecc) + flag_bytes = DeviceInfo.wNumPageSpareFlag; + + for (page = 0; page < 2; page++) { + status = NAND_Read_Page_Spare(pReadSpareBuf, block, page, 1); + if (status != PASS) + return READ_ERROR; + for (i = flag_bytes; i < (flag_bytes + skip_bytes); i++) + if (pReadSpareBuf[i] != 0xff) + return DEFECTIVE_BLOCK; + } + + for (page = 1; page < 3; page++) { + status = NAND_Read_Page_Spare(pReadSpareBuf, block, + DeviceInfo.wPagesPerBlock - page , 1); + if (status != PASS) + return READ_ERROR; + for (i = flag_bytes; i < (flag_bytes + skip_bytes); i++) + if (pReadSpareBuf[i] != 0xff) + return DEFECTIVE_BLOCK; + } + + return GOOD_BLOCK; +} + + +u16 NAND_Flash_Reset(void) +{ + u32 i; + u32 intr_status_rst_comp[4] = {INTR_STATUS0__RST_COMP, + INTR_STATUS1__RST_COMP, + INTR_STATUS2__RST_COMP, + INTR_STATUS3__RST_COMP}; + u32 intr_status_time_out[4] = {INTR_STATUS0__TIME_OUT, + INTR_STATUS1__TIME_OUT, + INTR_STATUS2__TIME_OUT, + INTR_STATUS3__TIME_OUT}; + u32 intr_status[4] = {INTR_STATUS0, INTR_STATUS1, + INTR_STATUS2, INTR_STATUS3}; + u32 device_reset_banks[4] = {DEVICE_RESET__BANK0, + DEVICE_RESET__BANK1, + DEVICE_RESET__BANK2, + DEVICE_RESET__BANK3}; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + for (i = 0 ; i < LLD_MAX_FLASH_BANKS; i++) + iowrite32(intr_status_rst_comp[i] | intr_status_time_out[i], + FlashReg + intr_status[i]); + + for (i = 0 ; i < LLD_MAX_FLASH_BANKS; i++) { + iowrite32(device_reset_banks[i], FlashReg + DEVICE_RESET); + while (!(ioread32(FlashReg + intr_status[i]) & + (intr_status_rst_comp[i] | intr_status_time_out[i]))) + ; + if (ioread32(FlashReg + intr_status[i]) & + intr_status_time_out[i]) + nand_dbg_print(NAND_DBG_WARN, + "NAND Reset operation timed out on bank %d\n", i); + } + + for (i = 0; i < LLD_MAX_FLASH_BANKS; i++) + iowrite32(intr_status_rst_comp[i] | intr_status_time_out[i], + FlashReg + intr_status[i]); + + return PASS; +} + +static void NAND_ONFi_Timing_Mode(u16 mode) +{ + u16 Trea[6] = {40, 30, 25, 20, 20, 16}; + u16 Trp[6] = {50, 25, 17, 15, 12, 10}; + u16 Treh[6] = {30, 15, 15, 10, 10, 7}; + u16 Trc[6] = {100, 50, 35, 30, 25, 20}; + u16 Trhoh[6] = {0, 15, 15, 15, 15, 15}; + u16 Trloh[6] = {0, 0, 0, 0, 5, 5}; + u16 Tcea[6] = {100, 45, 30, 25, 25, 25}; + u16 Tadl[6] = {200, 100, 100, 100, 70, 70}; + u16 Trhw[6] = {200, 100, 100, 100, 100, 100}; + u16 Trhz[6] = {200, 100, 100, 100, 100, 100}; + u16 Twhr[6] = {120, 80, 80, 60, 60, 60}; + u16 Tcs[6] = {70, 35, 25, 25, 20, 15}; + + u16 TclsRising = 1; + u16 data_invalid_rhoh, data_invalid_rloh, data_invalid; + u16 dv_window = 0; + u16 en_lo, en_hi; + u16 acc_clks; + u16 addr_2_data, re_2_we, re_2_re, we_2_re, cs_cnt; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + en_lo = CEIL_DIV(Trp[mode], CLK_X); + en_hi = CEIL_DIV(Treh[mode], CLK_X); + +#if ONFI_BLOOM_TIME + if ((en_hi * CLK_X) < (Treh[mode] + 2)) + en_hi++; +#endif + + if ((en_lo + en_hi) * CLK_X < Trc[mode]) + en_lo += CEIL_DIV((Trc[mode] - (en_lo + en_hi) * CLK_X), CLK_X); + + if ((en_lo + en_hi) < CLK_MULTI) + en_lo += CLK_MULTI - en_lo - en_hi; + + while (dv_window < 8) { + data_invalid_rhoh = en_lo * CLK_X + Trhoh[mode]; + + data_invalid_rloh = (en_lo + en_hi) * CLK_X + Trloh[mode]; + + data_invalid = + data_invalid_rhoh < + data_invalid_rloh ? data_invalid_rhoh : data_invalid_rloh; + + dv_window = data_invalid - Trea[mode]; + + if (dv_window < 8) + en_lo++; + } + + acc_clks = CEIL_DIV(Trea[mode], CLK_X); + + while (((acc_clks * CLK_X) - Trea[mode]) < 3) + acc_clks++; + + if ((data_invalid - acc_clks * CLK_X) < 2) + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d: Warning!\n", + __FILE__, __LINE__); + + addr_2_data = CEIL_DIV(Tadl[mode], CLK_X); + re_2_we = CEIL_DIV(Trhw[mode], CLK_X); + re_2_re = CEIL_DIV(Trhz[mode], CLK_X); + we_2_re = CEIL_DIV(Twhr[mode], CLK_X); + cs_cnt = CEIL_DIV((Tcs[mode] - Trp[mode]), CLK_X); + if (!TclsRising) + cs_cnt = CEIL_DIV(Tcs[mode], CLK_X); + if (cs_cnt == 0) + cs_cnt = 1; + + if (Tcea[mode]) { + while (((cs_cnt * CLK_X) + Trea[mode]) < Tcea[mode]) + cs_cnt++; + } + +#if MODE5_WORKAROUND + if (mode == 5) + acc_clks = 5; +#endif + + /* Sighting 3462430: Temporary hack for MT29F128G08CJABAWP:B */ + if ((ioread32(FlashReg + MANUFACTURER_ID) == 0) && + (ioread32(FlashReg + DEVICE_ID) == 0x88)) + acc_clks = 6; + + iowrite32(acc_clks, FlashReg + ACC_CLKS); + iowrite32(re_2_we, FlashReg + RE_2_WE); + iowrite32(re_2_re, FlashReg + RE_2_RE); + iowrite32(we_2_re, FlashReg + WE_2_RE); + iowrite32(addr_2_data, FlashReg + ADDR_2_DATA); + iowrite32(en_lo, FlashReg + RDWR_EN_LO_CNT); + iowrite32(en_hi, FlashReg + RDWR_EN_HI_CNT); + iowrite32(cs_cnt, FlashReg + CS_SETUP_CNT); +} + +static void index_addr(u32 address, u32 data) +{ + iowrite32(address, FlashMem); + iowrite32(data, FlashMem + 0x10); +} + +static void index_addr_read_data(u32 address, u32 *pdata) +{ + iowrite32(address, FlashMem); + *pdata = ioread32(FlashMem + 0x10); +} + +static void set_ecc_config(void) +{ +#if SUPPORT_8BITECC + if ((ioread32(FlashReg + DEVICE_MAIN_AREA_SIZE) < 4096) || + (ioread32(FlashReg + DEVICE_SPARE_AREA_SIZE) <= 128)) + iowrite32(8, FlashReg + ECC_CORRECTION); +#endif + + if ((ioread32(FlashReg + ECC_CORRECTION) & ECC_CORRECTION__VALUE) + == 1) { + DeviceInfo.wECCBytesPerSector = 4; + DeviceInfo.wECCBytesPerSector *= DeviceInfo.wDevicesConnected; + DeviceInfo.wNumPageSpareFlag = + DeviceInfo.wPageSpareSize - + DeviceInfo.wPageDataSize / + (ECC_SECTOR_SIZE * DeviceInfo.wDevicesConnected) * + DeviceInfo.wECCBytesPerSector + - DeviceInfo.wSpareSkipBytes; + } else { + DeviceInfo.wECCBytesPerSector = + (ioread32(FlashReg + ECC_CORRECTION) & + ECC_CORRECTION__VALUE) * 13 / 8; + if ((DeviceInfo.wECCBytesPerSector) % 2 == 0) + DeviceInfo.wECCBytesPerSector += 2; + else + DeviceInfo.wECCBytesPerSector += 1; + + DeviceInfo.wECCBytesPerSector *= DeviceInfo.wDevicesConnected; + DeviceInfo.wNumPageSpareFlag = DeviceInfo.wPageSpareSize - + DeviceInfo.wPageDataSize / + (ECC_SECTOR_SIZE * DeviceInfo.wDevicesConnected) * + DeviceInfo.wECCBytesPerSector + - DeviceInfo.wSpareSkipBytes; + } +} + +static u16 get_onfi_nand_para(void) +{ + int i; + u16 blks_lun_l, blks_lun_h, n_of_luns; + u32 blockperlun, id; + + iowrite32(DEVICE_RESET__BANK0, FlashReg + DEVICE_RESET); + + while (!((ioread32(FlashReg + INTR_STATUS0) & + INTR_STATUS0__RST_COMP) | + (ioread32(FlashReg + INTR_STATUS0) & + INTR_STATUS0__TIME_OUT))) + ; + + if (ioread32(FlashReg + INTR_STATUS0) & INTR_STATUS0__RST_COMP) { + iowrite32(DEVICE_RESET__BANK1, FlashReg + DEVICE_RESET); + while (!((ioread32(FlashReg + INTR_STATUS1) & + INTR_STATUS1__RST_COMP) | + (ioread32(FlashReg + INTR_STATUS1) & + INTR_STATUS1__TIME_OUT))) + ; + + if (ioread32(FlashReg + INTR_STATUS1) & + INTR_STATUS1__RST_COMP) { + iowrite32(DEVICE_RESET__BANK2, + FlashReg + DEVICE_RESET); + while (!((ioread32(FlashReg + INTR_STATUS2) & + INTR_STATUS2__RST_COMP) | + (ioread32(FlashReg + INTR_STATUS2) & + INTR_STATUS2__TIME_OUT))) + ; + + if (ioread32(FlashReg + INTR_STATUS2) & + INTR_STATUS2__RST_COMP) { + iowrite32(DEVICE_RESET__BANK3, + FlashReg + DEVICE_RESET); + while (!((ioread32(FlashReg + INTR_STATUS3) & + INTR_STATUS3__RST_COMP) | + (ioread32(FlashReg + INTR_STATUS3) & + INTR_STATUS3__TIME_OUT))) + ; + } else { + printk(KERN_ERR "Getting a time out for bank 2!\n"); + } + } else { + printk(KERN_ERR "Getting a time out for bank 1!\n"); + } + } + + iowrite32(INTR_STATUS0__TIME_OUT, FlashReg + INTR_STATUS0); + iowrite32(INTR_STATUS1__TIME_OUT, FlashReg + INTR_STATUS1); + iowrite32(INTR_STATUS2__TIME_OUT, FlashReg + INTR_STATUS2); + iowrite32(INTR_STATUS3__TIME_OUT, FlashReg + INTR_STATUS3); + + DeviceInfo.wONFIDevFeatures = + ioread32(FlashReg + ONFI_DEVICE_FEATURES); + DeviceInfo.wONFIOptCommands = + ioread32(FlashReg + ONFI_OPTIONAL_COMMANDS); + DeviceInfo.wONFITimingMode = + ioread32(FlashReg + ONFI_TIMING_MODE); + DeviceInfo.wONFIPgmCacheTimingMode = + ioread32(FlashReg + ONFI_PGM_CACHE_TIMING_MODE); + + n_of_luns = ioread32(FlashReg + ONFI_DEVICE_NO_OF_LUNS) & + ONFI_DEVICE_NO_OF_LUNS__NO_OF_LUNS; + blks_lun_l = ioread32(FlashReg + ONFI_DEVICE_NO_OF_BLOCKS_PER_LUN_L); + blks_lun_h = ioread32(FlashReg + ONFI_DEVICE_NO_OF_BLOCKS_PER_LUN_U); + + blockperlun = (blks_lun_h << 16) | blks_lun_l; + + DeviceInfo.wTotalBlocks = n_of_luns * blockperlun; + + if (!(ioread32(FlashReg + ONFI_TIMING_MODE) & + ONFI_TIMING_MODE__VALUE)) + return FAIL; + + for (i = 5; i > 0; i--) { + if (ioread32(FlashReg + ONFI_TIMING_MODE) & (0x01 << i)) + break; + } + + NAND_ONFi_Timing_Mode(i); + + index_addr(MODE_11 | 0, 0x90); + index_addr(MODE_11 | 1, 0); + + for (i = 0; i < 3; i++) + index_addr_read_data(MODE_11 | 2, &id); + + nand_dbg_print(NAND_DBG_DEBUG, "3rd ID: 0x%x\n", id); + + DeviceInfo.MLCDevice = id & 0x0C; + + /* By now, all the ONFI devices we know support the page cache */ + /* rw feature. So here we enable the pipeline_rw_ahead feature */ + /* iowrite32(1, FlashReg + CACHE_WRITE_ENABLE); */ + /* iowrite32(1, FlashReg + CACHE_READ_ENABLE); */ + + return PASS; +} + +static void get_samsung_nand_para(void) +{ + u8 no_of_planes; + u32 blk_size; + u64 plane_size, capacity; + u32 id_bytes[5]; + int i; + + index_addr((u32)(MODE_11 | 0), 0x90); + index_addr((u32)(MODE_11 | 1), 0); + for (i = 0; i < 5; i++) + index_addr_read_data((u32)(MODE_11 | 2), &id_bytes[i]); + + nand_dbg_print(NAND_DBG_DEBUG, + "ID bytes: 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", + id_bytes[0], id_bytes[1], id_bytes[2], + id_bytes[3], id_bytes[4]); + + if ((id_bytes[1] & 0xff) == 0xd3) { /* Samsung K9WAG08U1A */ + /* Set timing register values according to datasheet */ + iowrite32(5, FlashReg + ACC_CLKS); + iowrite32(20, FlashReg + RE_2_WE); + iowrite32(12, FlashReg + WE_2_RE); + iowrite32(14, FlashReg + ADDR_2_DATA); + iowrite32(3, FlashReg + RDWR_EN_LO_CNT); + iowrite32(2, FlashReg + RDWR_EN_HI_CNT); + iowrite32(2, FlashReg + CS_SETUP_CNT); + } + + no_of_planes = 1 << ((id_bytes[4] & 0x0c) >> 2); + plane_size = (u64)64 << ((id_bytes[4] & 0x70) >> 4); + blk_size = 64 << ((ioread32(FlashReg + DEVICE_PARAM_1) & 0x30) >> 4); + capacity = (u64)128 * plane_size * no_of_planes; + + DeviceInfo.wTotalBlocks = (u32)GLOB_u64_Div(capacity, blk_size); +} + +static void get_toshiba_nand_para(void) +{ + void __iomem *scratch_reg; + u32 tmp; + + /* Workaround to fix a controller bug which reports a wrong */ + /* spare area size for some kind of Toshiba NAND device */ + if ((ioread32(FlashReg + DEVICE_MAIN_AREA_SIZE) == 4096) && + (ioread32(FlashReg + DEVICE_SPARE_AREA_SIZE) == 64)) { + iowrite32(216, FlashReg + DEVICE_SPARE_AREA_SIZE); + tmp = ioread32(FlashReg + DEVICES_CONNECTED) * + ioread32(FlashReg + DEVICE_SPARE_AREA_SIZE); + iowrite32(tmp, FlashReg + LOGICAL_PAGE_SPARE_SIZE); +#if SUPPORT_15BITECC + iowrite32(15, FlashReg + ECC_CORRECTION); +#elif SUPPORT_8BITECC + iowrite32(8, FlashReg + ECC_CORRECTION); +#endif + } + + /* As Toshiba NAND can not provide it's block number, */ + /* so here we need user to provide the correct block */ + /* number in a scratch register before the Linux NAND */ + /* driver is loaded. If no valid value found in the scratch */ + /* register, then we use default block number value */ + scratch_reg = ioremap_nocache(SCRATCH_REG_ADDR, SCRATCH_REG_SIZE); + if (!scratch_reg) { + printk(KERN_ERR "Spectra: ioremap failed in %s, Line %d", + __FILE__, __LINE__); + DeviceInfo.wTotalBlocks = GLOB_HWCTL_DEFAULT_BLKS; + } else { + nand_dbg_print(NAND_DBG_WARN, + "Spectra: ioremap reg address: 0x%p\n", scratch_reg); + DeviceInfo.wTotalBlocks = 1 << ioread8(scratch_reg); + if (DeviceInfo.wTotalBlocks < 512) + DeviceInfo.wTotalBlocks = GLOB_HWCTL_DEFAULT_BLKS; + iounmap(scratch_reg); + } +} + +static void get_hynix_nand_para(void) +{ + void __iomem *scratch_reg; + u32 main_size, spare_size; + + switch (DeviceInfo.wDeviceID) { + case 0xD5: /* Hynix H27UAG8T2A, H27UBG8U5A or H27UCG8VFA */ + case 0xD7: /* Hynix H27UDG8VEM, H27UCG8UDM or H27UCG8V5A */ + iowrite32(128, FlashReg + PAGES_PER_BLOCK); + iowrite32(4096, FlashReg + DEVICE_MAIN_AREA_SIZE); + iowrite32(224, FlashReg + DEVICE_SPARE_AREA_SIZE); + main_size = 4096 * ioread32(FlashReg + DEVICES_CONNECTED); + spare_size = 224 * ioread32(FlashReg + DEVICES_CONNECTED); + iowrite32(main_size, FlashReg + LOGICAL_PAGE_DATA_SIZE); + iowrite32(spare_size, FlashReg + LOGICAL_PAGE_SPARE_SIZE); + iowrite32(0, FlashReg + DEVICE_WIDTH); +#if SUPPORT_15BITECC + iowrite32(15, FlashReg + ECC_CORRECTION); +#elif SUPPORT_8BITECC + iowrite32(8, FlashReg + ECC_CORRECTION); +#endif + DeviceInfo.MLCDevice = 1; + break; + default: + nand_dbg_print(NAND_DBG_WARN, + "Spectra: Unknown Hynix NAND (Device ID: 0x%x)." + "Will use default parameter values instead.\n", + DeviceInfo.wDeviceID); + } + + scratch_reg = ioremap_nocache(SCRATCH_REG_ADDR, SCRATCH_REG_SIZE); + if (!scratch_reg) { + printk(KERN_ERR "Spectra: ioremap failed in %s, Line %d", + __FILE__, __LINE__); + DeviceInfo.wTotalBlocks = GLOB_HWCTL_DEFAULT_BLKS; + } else { + nand_dbg_print(NAND_DBG_WARN, + "Spectra: ioremap reg address: 0x%p\n", scratch_reg); + DeviceInfo.wTotalBlocks = 1 << ioread8(scratch_reg); + if (DeviceInfo.wTotalBlocks < 512) + DeviceInfo.wTotalBlocks = GLOB_HWCTL_DEFAULT_BLKS; + iounmap(scratch_reg); + } +} + +static void find_valid_banks(void) +{ + u32 id[LLD_MAX_FLASH_BANKS]; + int i; + + totalUsedBanks = 0; + for (i = 0; i < LLD_MAX_FLASH_BANKS; i++) { + index_addr((u32)(MODE_11 | (i << 24) | 0), 0x90); + index_addr((u32)(MODE_11 | (i << 24) | 1), 0); + index_addr_read_data((u32)(MODE_11 | (i << 24) | 2), &id[i]); + + nand_dbg_print(NAND_DBG_DEBUG, + "Return 1st ID for bank[%d]: %x\n", i, id[i]); + + if (i == 0) { + if (id[i] & 0x0ff) + GLOB_valid_banks[i] = 1; + } else { + if ((id[i] & 0x0ff) == (id[0] & 0x0ff)) + GLOB_valid_banks[i] = 1; + } + + totalUsedBanks += GLOB_valid_banks[i]; + } + + nand_dbg_print(NAND_DBG_DEBUG, + "totalUsedBanks: %d\n", totalUsedBanks); +} + +static void detect_partition_feature(void) +{ + if (ioread32(FlashReg + FEATURES) & FEATURES__PARTITION) { + if ((ioread32(FlashReg + PERM_SRC_ID_1) & + PERM_SRC_ID_1__SRCID) == SPECTRA_PARTITION_ID) { + DeviceInfo.wSpectraStartBlock = + ((ioread32(FlashReg + MIN_MAX_BANK_1) & + MIN_MAX_BANK_1__MIN_VALUE) * + DeviceInfo.wTotalBlocks) + + + (ioread32(FlashReg + MIN_BLK_ADDR_1) & + MIN_BLK_ADDR_1__VALUE); + + DeviceInfo.wSpectraEndBlock = + (((ioread32(FlashReg + MIN_MAX_BANK_1) & + MIN_MAX_BANK_1__MAX_VALUE) >> 2) * + DeviceInfo.wTotalBlocks) + + + (ioread32(FlashReg + MAX_BLK_ADDR_1) & + MAX_BLK_ADDR_1__VALUE); + + DeviceInfo.wTotalBlocks *= totalUsedBanks; + + if (DeviceInfo.wSpectraEndBlock >= + DeviceInfo.wTotalBlocks) { + DeviceInfo.wSpectraEndBlock = + DeviceInfo.wTotalBlocks - 1; + } + + DeviceInfo.wDataBlockNum = + DeviceInfo.wSpectraEndBlock - + DeviceInfo.wSpectraStartBlock + 1; + } else { + DeviceInfo.wTotalBlocks *= totalUsedBanks; + DeviceInfo.wSpectraStartBlock = SPECTRA_START_BLOCK; + DeviceInfo.wSpectraEndBlock = + DeviceInfo.wTotalBlocks - 1; + DeviceInfo.wDataBlockNum = + DeviceInfo.wSpectraEndBlock - + DeviceInfo.wSpectraStartBlock + 1; + } + } else { + DeviceInfo.wTotalBlocks *= totalUsedBanks; + DeviceInfo.wSpectraStartBlock = SPECTRA_START_BLOCK; + DeviceInfo.wSpectraEndBlock = DeviceInfo.wTotalBlocks - 1; + DeviceInfo.wDataBlockNum = + DeviceInfo.wSpectraEndBlock - + DeviceInfo.wSpectraStartBlock + 1; + } +} + +static void dump_device_info(void) +{ + nand_dbg_print(NAND_DBG_DEBUG, "DeviceInfo:\n"); + nand_dbg_print(NAND_DBG_DEBUG, "DeviceMaker: 0x%x\n", + DeviceInfo.wDeviceMaker); + nand_dbg_print(NAND_DBG_DEBUG, "DeviceID: 0x%x\n", + DeviceInfo.wDeviceID); + nand_dbg_print(NAND_DBG_DEBUG, "DeviceType: 0x%x\n", + DeviceInfo.wDeviceType); + nand_dbg_print(NAND_DBG_DEBUG, "SpectraStartBlock: %d\n", + DeviceInfo.wSpectraStartBlock); + nand_dbg_print(NAND_DBG_DEBUG, "SpectraEndBlock: %d\n", + DeviceInfo.wSpectraEndBlock); + nand_dbg_print(NAND_DBG_DEBUG, "TotalBlocks: %d\n", + DeviceInfo.wTotalBlocks); + nand_dbg_print(NAND_DBG_DEBUG, "PagesPerBlock: %d\n", + DeviceInfo.wPagesPerBlock); + nand_dbg_print(NAND_DBG_DEBUG, "PageSize: %d\n", + DeviceInfo.wPageSize); + nand_dbg_print(NAND_DBG_DEBUG, "PageDataSize: %d\n", + DeviceInfo.wPageDataSize); + nand_dbg_print(NAND_DBG_DEBUG, "PageSpareSize: %d\n", + DeviceInfo.wPageSpareSize); + nand_dbg_print(NAND_DBG_DEBUG, "NumPageSpareFlag: %d\n", + DeviceInfo.wNumPageSpareFlag); + nand_dbg_print(NAND_DBG_DEBUG, "ECCBytesPerSector: %d\n", + DeviceInfo.wECCBytesPerSector); + nand_dbg_print(NAND_DBG_DEBUG, "BlockSize: %d\n", + DeviceInfo.wBlockSize); + nand_dbg_print(NAND_DBG_DEBUG, "BlockDataSize: %d\n", + DeviceInfo.wBlockDataSize); + nand_dbg_print(NAND_DBG_DEBUG, "DataBlockNum: %d\n", + DeviceInfo.wDataBlockNum); + nand_dbg_print(NAND_DBG_DEBUG, "PlaneNum: %d\n", + DeviceInfo.bPlaneNum); + nand_dbg_print(NAND_DBG_DEBUG, "DeviceMainAreaSize: %d\n", + DeviceInfo.wDeviceMainAreaSize); + nand_dbg_print(NAND_DBG_DEBUG, "DeviceSpareAreaSize: %d\n", + DeviceInfo.wDeviceSpareAreaSize); + nand_dbg_print(NAND_DBG_DEBUG, "DevicesConnected: %d\n", + DeviceInfo.wDevicesConnected); + nand_dbg_print(NAND_DBG_DEBUG, "DeviceWidth: %d\n", + DeviceInfo.wDeviceWidth); + nand_dbg_print(NAND_DBG_DEBUG, "HWRevision: 0x%x\n", + DeviceInfo.wHWRevision); + nand_dbg_print(NAND_DBG_DEBUG, "HWFeatures: 0x%x\n", + DeviceInfo.wHWFeatures); + nand_dbg_print(NAND_DBG_DEBUG, "ONFIDevFeatures: 0x%x\n", + DeviceInfo.wONFIDevFeatures); + nand_dbg_print(NAND_DBG_DEBUG, "ONFIOptCommands: 0x%x\n", + DeviceInfo.wONFIOptCommands); + nand_dbg_print(NAND_DBG_DEBUG, "ONFITimingMode: 0x%x\n", + DeviceInfo.wONFITimingMode); + nand_dbg_print(NAND_DBG_DEBUG, "ONFIPgmCacheTimingMode: 0x%x\n", + DeviceInfo.wONFIPgmCacheTimingMode); + nand_dbg_print(NAND_DBG_DEBUG, "MLCDevice: %s\n", + DeviceInfo.MLCDevice ? "Yes" : "No"); + nand_dbg_print(NAND_DBG_DEBUG, "SpareSkipBytes: %d\n", + DeviceInfo.wSpareSkipBytes); + nand_dbg_print(NAND_DBG_DEBUG, "BitsInPageNumber: %d\n", + DeviceInfo.nBitsInPageNumber); + nand_dbg_print(NAND_DBG_DEBUG, "BitsInPageDataSize: %d\n", + DeviceInfo.nBitsInPageDataSize); + nand_dbg_print(NAND_DBG_DEBUG, "BitsInBlockDataSize: %d\n", + DeviceInfo.nBitsInBlockDataSize); +} + +u16 NAND_Read_Device_ID(void) +{ + u16 status = PASS; + u8 no_of_planes; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + iowrite32(0x02, FlashReg + SPARE_AREA_SKIP_BYTES); + iowrite32(0xffff, FlashReg + SPARE_AREA_MARKER); + DeviceInfo.wDeviceMaker = ioread32(FlashReg + MANUFACTURER_ID); + DeviceInfo.wDeviceID = ioread32(FlashReg + DEVICE_ID); + DeviceInfo.MLCDevice = ioread32(FlashReg + DEVICE_PARAM_0) & 0x0c; + + if (ioread32(FlashReg + ONFI_DEVICE_NO_OF_LUNS) & + ONFI_DEVICE_NO_OF_LUNS__ONFI_DEVICE) { /* ONFI 1.0 NAND */ + if (FAIL == get_onfi_nand_para()) + return FAIL; + } else if (DeviceInfo.wDeviceMaker == 0xEC) { /* Samsung NAND */ + get_samsung_nand_para(); + } else if (DeviceInfo.wDeviceMaker == 0x98) { /* Toshiba NAND */ + get_toshiba_nand_para(); + } else if (DeviceInfo.wDeviceMaker == 0xAD) { /* Hynix NAND */ + get_hynix_nand_para(); + } else { + DeviceInfo.wTotalBlocks = GLOB_HWCTL_DEFAULT_BLKS; + } + + nand_dbg_print(NAND_DBG_DEBUG, "Dump timing register values:" + "acc_clks: %d, re_2_we: %d, we_2_re: %d," + "addr_2_data: %d, rdwr_en_lo_cnt: %d, " + "rdwr_en_hi_cnt: %d, cs_setup_cnt: %d\n", + ioread32(FlashReg + ACC_CLKS), + ioread32(FlashReg + RE_2_WE), + ioread32(FlashReg + WE_2_RE), + ioread32(FlashReg + ADDR_2_DATA), + ioread32(FlashReg + RDWR_EN_LO_CNT), + ioread32(FlashReg + RDWR_EN_HI_CNT), + ioread32(FlashReg + CS_SETUP_CNT)); + + DeviceInfo.wHWRevision = ioread32(FlashReg + REVISION); + DeviceInfo.wHWFeatures = ioread32(FlashReg + FEATURES); + + DeviceInfo.wDeviceMainAreaSize = + ioread32(FlashReg + DEVICE_MAIN_AREA_SIZE); + DeviceInfo.wDeviceSpareAreaSize = + ioread32(FlashReg + DEVICE_SPARE_AREA_SIZE); + + DeviceInfo.wPageDataSize = + ioread32(FlashReg + LOGICAL_PAGE_DATA_SIZE); + + /* Note: When using the Micon 4K NAND device, the controller will report + * Page Spare Size as 216 bytes. But Micron's Spec say it's 218 bytes. + * And if force set it to 218 bytes, the controller can not work + * correctly. So just let it be. But keep in mind that this bug may + * cause + * other problems in future. - Yunpeng 2008-10-10 + */ + DeviceInfo.wPageSpareSize = + ioread32(FlashReg + LOGICAL_PAGE_SPARE_SIZE); + + DeviceInfo.wPagesPerBlock = ioread32(FlashReg + PAGES_PER_BLOCK); + + DeviceInfo.wPageSize = + DeviceInfo.wPageDataSize + DeviceInfo.wPageSpareSize; + DeviceInfo.wBlockSize = + DeviceInfo.wPageSize * DeviceInfo.wPagesPerBlock; + DeviceInfo.wBlockDataSize = + DeviceInfo.wPagesPerBlock * DeviceInfo.wPageDataSize; + + DeviceInfo.wDeviceWidth = ioread32(FlashReg + DEVICE_WIDTH); + DeviceInfo.wDeviceType = + ((ioread32(FlashReg + DEVICE_WIDTH) > 0) ? 16 : 8); + + DeviceInfo.wDevicesConnected = ioread32(FlashReg + DEVICES_CONNECTED); + + DeviceInfo.wSpareSkipBytes = + ioread32(FlashReg + SPARE_AREA_SKIP_BYTES) * + DeviceInfo.wDevicesConnected; + + DeviceInfo.nBitsInPageNumber = + (u8)GLOB_Calc_Used_Bits(DeviceInfo.wPagesPerBlock); + DeviceInfo.nBitsInPageDataSize = + (u8)GLOB_Calc_Used_Bits(DeviceInfo.wPageDataSize); + DeviceInfo.nBitsInBlockDataSize = + (u8)GLOB_Calc_Used_Bits(DeviceInfo.wBlockDataSize); + + set_ecc_config(); + + no_of_planes = ioread32(FlashReg + NUMBER_OF_PLANES) & + NUMBER_OF_PLANES__VALUE; + + switch (no_of_planes) { + case 0: + case 1: + case 3: + case 7: + DeviceInfo.bPlaneNum = no_of_planes + 1; + break; + default: + status = FAIL; + break; + } + + find_valid_banks(); + + detect_partition_feature(); + + dump_device_info(); + + return status; +} + +u16 NAND_UnlockArrayAll(void) +{ + u64 start_addr, end_addr; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + start_addr = 0; + end_addr = ((u64)DeviceInfo.wBlockSize * + (DeviceInfo.wTotalBlocks - 1)) >> + DeviceInfo.nBitsInPageDataSize; + + index_addr((u32)(MODE_10 | (u32)start_addr), 0x10); + index_addr((u32)(MODE_10 | (u32)end_addr), 0x11); + + return PASS; +} + +void NAND_LLD_Enable_Disable_Interrupts(u16 INT_ENABLE) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (INT_ENABLE) + iowrite32(1, FlashReg + GLOBAL_INT_ENABLE); + else + iowrite32(0, FlashReg + GLOBAL_INT_ENABLE); +} + +u16 NAND_Erase_Block(u32 block) +{ + u16 status = PASS; + u64 flash_add; + u16 flash_bank; + u32 intr_status = 0; + u32 intr_status_addresses[4] = {INTR_STATUS0, + INTR_STATUS1, INTR_STATUS2, INTR_STATUS3}; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + flash_add = (u64)(block % (DeviceInfo.wTotalBlocks / totalUsedBanks)) + * DeviceInfo.wBlockDataSize; + + flash_bank = block / (DeviceInfo.wTotalBlocks / totalUsedBanks); + + if (block >= DeviceInfo.wTotalBlocks) + status = FAIL; + + if (status == PASS) { + intr_status = intr_status_addresses[flash_bank]; + + iowrite32(INTR_STATUS0__ERASE_COMP | INTR_STATUS0__ERASE_FAIL, + FlashReg + intr_status); + + index_addr((u32)(MODE_10 | (flash_bank << 24) | + (flash_add >> DeviceInfo.nBitsInPageDataSize)), 1); + + while (!(ioread32(FlashReg + intr_status) & + (INTR_STATUS0__ERASE_COMP | INTR_STATUS0__ERASE_FAIL))) + ; + + if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__ERASE_FAIL) + status = FAIL; + + iowrite32(INTR_STATUS0__ERASE_COMP | INTR_STATUS0__ERASE_FAIL, + FlashReg + intr_status); + } + + return status; +} + +static u32 Boundary_Check_Block_Page(u32 block, u16 page, + u16 page_count) +{ + u32 status = PASS; + + if (block >= DeviceInfo.wTotalBlocks) + status = FAIL; + + if (page + page_count > DeviceInfo.wPagesPerBlock) + status = FAIL; + + return status; +} + +u16 NAND_Read_Page_Spare(u8 *read_data, u32 block, u16 page, + u16 page_count) +{ + u32 status = PASS; + u32 i; + u64 flash_add; + u32 PageSpareSize = DeviceInfo.wPageSpareSize; + u32 spareFlagBytes = DeviceInfo.wNumPageSpareFlag; + u32 flash_bank; + u32 intr_status = 0; + u32 intr_status_addresses[4] = {INTR_STATUS0, + INTR_STATUS1, INTR_STATUS2, INTR_STATUS3}; + u8 *page_spare = buf_read_page_spare; + + if (block >= DeviceInfo.wTotalBlocks) { + printk(KERN_ERR "block too big: %d\n", (int)block); + status = FAIL; + } + + if (page >= DeviceInfo.wPagesPerBlock) { + printk(KERN_ERR "page too big: %d\n", page); + status = FAIL; + } + + if (page_count > 1) { + printk(KERN_ERR "page count too big: %d\n", page_count); + status = FAIL; + } + + flash_add = (u64)(block % (DeviceInfo.wTotalBlocks / totalUsedBanks)) + * DeviceInfo.wBlockDataSize + + (u64)page * DeviceInfo.wPageDataSize; + + flash_bank = block / (DeviceInfo.wTotalBlocks / totalUsedBanks); + + if (status == PASS) { + intr_status = intr_status_addresses[flash_bank]; + iowrite32(ioread32(FlashReg + intr_status), + FlashReg + intr_status); + + index_addr((u32)(MODE_10 | (flash_bank << 24) | + (flash_add >> DeviceInfo.nBitsInPageDataSize)), + 0x41); + index_addr((u32)(MODE_10 | (flash_bank << 24) | + (flash_add >> DeviceInfo.nBitsInPageDataSize)), + 0x2000 | page_count); + while (!(ioread32(FlashReg + intr_status) & + INTR_STATUS0__LOAD_COMP)) + ; + + iowrite32((u32)(MODE_01 | (flash_bank << 24) | + (flash_add >> DeviceInfo.nBitsInPageDataSize)), + FlashMem); + + for (i = 0; i < (PageSpareSize / 4); i++) + *((u32 *)page_spare + i) = + ioread32(FlashMem + 0x10); + + if (enable_ecc) { + for (i = 0; i < spareFlagBytes; i++) + read_data[i] = + page_spare[PageSpareSize - + spareFlagBytes + i]; + for (i = 0; i < (PageSpareSize - spareFlagBytes); i++) + read_data[spareFlagBytes + i] = + page_spare[i]; + } else { + for (i = 0; i < PageSpareSize; i++) + read_data[i] = page_spare[i]; + } + + index_addr((u32)(MODE_10 | (flash_bank << 24) | + (flash_add >> DeviceInfo.nBitsInPageDataSize)), 0x42); + } + + return status; +} + +/* No use function. Should be removed later */ +u16 NAND_Write_Page_Spare(u8 *write_data, u32 block, u16 page, + u16 page_count) +{ + printk(KERN_ERR + "Error! This function (NAND_Write_Page_Spare) should never" + " be called!\n"); + return ERR; +} + +/* op value: 0 - DDMA read; 1 - DDMA write */ +static void ddma_trans(u8 *data, u64 flash_add, + u32 flash_bank, int op, u32 numPages) +{ + u32 data_addr; + + /* Map virtual address to bus address for DDMA */ + data_addr = virt_to_bus(data); + + index_addr((u32)(MODE_10 | (flash_bank << 24) | + (flash_add >> DeviceInfo.nBitsInPageDataSize)), + (u16)(2 << 12) | (op << 8) | numPages); + + index_addr((u32)(MODE_10 | (flash_bank << 24) | + ((u16)(0x0FFFF & (data_addr >> 16)) << 8)), + (u16)(2 << 12) | (2 << 8) | 0); + + index_addr((u32)(MODE_10 | (flash_bank << 24) | + ((u16)(0x0FFFF & data_addr) << 8)), + (u16)(2 << 12) | (3 << 8) | 0); + + index_addr((u32)(MODE_10 | (flash_bank << 24) | + (1 << 16) | (0x40 << 8)), + (u16)(2 << 12) | (4 << 8) | 0); +} + +/* If data in buf are all 0xff, then return 1; otherwise return 0 */ +static int check_all_1(u8 *buf) +{ + int i, j, cnt; + + for (i = 0; i < DeviceInfo.wPageDataSize; i++) { + if (buf[i] != 0xff) { + cnt = 0; + nand_dbg_print(NAND_DBG_WARN, + "the first non-0xff data byte is: %d\n", i); + for (j = i; j < DeviceInfo.wPageDataSize; j++) { + nand_dbg_print(NAND_DBG_WARN, "0x%x ", buf[j]); + cnt++; + if (cnt > 8) + break; + } + nand_dbg_print(NAND_DBG_WARN, "\n"); + return 0; + } + } + + return 1; +} + +static int do_ecc_new(unsigned long bank, u8 *buf, + u32 block, u16 page) +{ + int status = PASS; + u16 err_page = 0; + u16 err_byte; + u8 err_sect; + u8 err_dev; + u16 err_fix_info; + u16 err_addr; + u32 ecc_sect_size; + u8 *err_pos; + u32 err_page_addr[4] = {ERR_PAGE_ADDR0, + ERR_PAGE_ADDR1, ERR_PAGE_ADDR2, ERR_PAGE_ADDR3}; + + ecc_sect_size = ECC_SECTOR_SIZE * (DeviceInfo.wDevicesConnected); + + do { + err_page = ioread32(FlashReg + err_page_addr[bank]); + err_addr = ioread32(FlashReg + ECC_ERROR_ADDRESS); + err_byte = err_addr & ECC_ERROR_ADDRESS__OFFSET; + err_sect = ((err_addr & ECC_ERROR_ADDRESS__SECTOR_NR) >> 12); + err_fix_info = ioread32(FlashReg + ERR_CORRECTION_INFO); + err_dev = ((err_fix_info & ERR_CORRECTION_INFO__DEVICE_NR) + >> 8); + if (err_fix_info & ERR_CORRECTION_INFO__ERROR_TYPE) { + nand_dbg_print(NAND_DBG_WARN, + "%s, Line %d Uncorrectable ECC error " + "when read block %d page %d." + "PTN_INTR register: 0x%x " + "err_page: %d, err_sect: %d, err_byte: %d, " + "err_dev: %d, ecc_sect_size: %d, " + "err_fix_info: 0x%x\n", + __FILE__, __LINE__, block, page, + ioread32(FlashReg + PTN_INTR), + err_page, err_sect, err_byte, err_dev, + ecc_sect_size, (u32)err_fix_info); + + if (check_all_1(buf)) + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d" + "All 0xff!\n", + __FILE__, __LINE__); + else + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d" + "Not all 0xff!\n", + __FILE__, __LINE__); + status = FAIL; + } else { + nand_dbg_print(NAND_DBG_WARN, + "%s, Line %d Found ECC error " + "when read block %d page %d." + "err_page: %d, err_sect: %d, err_byte: %d, " + "err_dev: %d, ecc_sect_size: %d, " + "err_fix_info: 0x%x\n", + __FILE__, __LINE__, block, page, + err_page, err_sect, err_byte, err_dev, + ecc_sect_size, (u32)err_fix_info); + if (err_byte < ECC_SECTOR_SIZE) { + err_pos = buf + + (err_page - page) * + DeviceInfo.wPageDataSize + + err_sect * ecc_sect_size + + err_byte * + DeviceInfo.wDevicesConnected + + err_dev; + + *err_pos ^= err_fix_info & + ERR_CORRECTION_INFO__BYTEMASK; + } + } + } while (!(err_fix_info & ERR_CORRECTION_INFO__LAST_ERR_INFO)); + + return status; +} + +u16 NAND_Read_Page_Main_Polling(u8 *read_data, + u32 block, u16 page, u16 page_count) +{ + u32 status = PASS; + u64 flash_add; + u32 intr_status = 0; + u32 flash_bank; + u32 intr_status_addresses[4] = {INTR_STATUS0, + INTR_STATUS1, INTR_STATUS2, INTR_STATUS3}; + u8 *read_data_l; + + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + status = Boundary_Check_Block_Page(block, page, page_count); + if (status != PASS) + return status; + + flash_add = (u64)(block % (DeviceInfo.wTotalBlocks / totalUsedBanks)) + * DeviceInfo.wBlockDataSize + + (u64)page * DeviceInfo.wPageDataSize; + flash_bank = block / (DeviceInfo.wTotalBlocks / totalUsedBanks); + + iowrite32(0, FlashReg + TRANSFER_SPARE_REG); + + intr_status = intr_status_addresses[flash_bank]; + iowrite32(ioread32(FlashReg + intr_status), FlashReg + intr_status); + + if (page_count > 1) { + read_data_l = read_data; + while (page_count > MAX_PAGES_PER_RW) { + if (ioread32(FlashReg + MULTIPLANE_OPERATION)) + status = NAND_Multiplane_Read(read_data_l, + block, page, MAX_PAGES_PER_RW); + else + status = NAND_Pipeline_Read_Ahead_Polling( + read_data_l, block, page, + MAX_PAGES_PER_RW); + + if (status == FAIL) + return status; + + read_data_l += DeviceInfo.wPageDataSize * + MAX_PAGES_PER_RW; + page_count -= MAX_PAGES_PER_RW; + page += MAX_PAGES_PER_RW; + } + if (ioread32(FlashReg + MULTIPLANE_OPERATION)) + status = NAND_Multiplane_Read(read_data_l, + block, page, page_count); + else + status = NAND_Pipeline_Read_Ahead_Polling( + read_data_l, block, page, page_count); + + return status; + } + + iowrite32(1, FlashReg + DMA_ENABLE); + while (!(ioread32(FlashReg + DMA_ENABLE) & DMA_ENABLE__FLAG)) + ; + + iowrite32(0, FlashReg + TRANSFER_SPARE_REG); + iowrite32(ioread32(FlashReg + intr_status), FlashReg + intr_status); + + ddma_trans(read_data, flash_add, flash_bank, 0, 1); + + if (enable_ecc) { + while (!(ioread32(FlashReg + intr_status) & + (INTR_STATUS0__ECC_TRANSACTION_DONE | + INTR_STATUS0__ECC_ERR))) + ; + + if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__ECC_ERR) { + iowrite32(INTR_STATUS0__ECC_ERR, + FlashReg + intr_status); + status = do_ecc_new(flash_bank, read_data, + block, page); + } + + if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__ECC_TRANSACTION_DONE & + INTR_STATUS0__ECC_ERR) + iowrite32(INTR_STATUS0__ECC_TRANSACTION_DONE | + INTR_STATUS0__ECC_ERR, + FlashReg + intr_status); + else if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__ECC_TRANSACTION_DONE) + iowrite32(INTR_STATUS0__ECC_TRANSACTION_DONE, + FlashReg + intr_status); + else if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__ECC_ERR) + iowrite32(INTR_STATUS0__ECC_ERR, + FlashReg + intr_status); + } else { + while (!(ioread32(FlashReg + intr_status) & + INTR_STATUS0__DMA_CMD_COMP)) + ; + iowrite32(INTR_STATUS0__DMA_CMD_COMP, FlashReg + intr_status); + } + + iowrite32(ioread32(FlashReg + intr_status), FlashReg + intr_status); + + iowrite32(0, FlashReg + DMA_ENABLE); + while ((ioread32(FlashReg + DMA_ENABLE) & DMA_ENABLE__FLAG)) + ; + + return status; +} + +u16 NAND_Pipeline_Read_Ahead_Polling(u8 *read_data, + u32 block, u16 page, u16 page_count) +{ + u32 status = PASS; + u32 NumPages = page_count; + u64 flash_add; + u32 flash_bank; + u32 intr_status = 0; + u32 intr_status_addresses[4] = {INTR_STATUS0, + INTR_STATUS1, INTR_STATUS2, INTR_STATUS3}; + u32 ecc_done_OR_dma_comp; + + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + status = Boundary_Check_Block_Page(block, page, page_count); + + if (page_count < 2) + status = FAIL; + + flash_add = (u64)(block % (DeviceInfo.wTotalBlocks / totalUsedBanks)) + *DeviceInfo.wBlockDataSize + + (u64)page * DeviceInfo.wPageDataSize; + + flash_bank = block / (DeviceInfo.wTotalBlocks / totalUsedBanks); + + if (status == PASS) { + intr_status = intr_status_addresses[flash_bank]; + iowrite32(ioread32(FlashReg + intr_status), + FlashReg + intr_status); + + iowrite32(1, FlashReg + DMA_ENABLE); + while (!(ioread32(FlashReg + DMA_ENABLE) & DMA_ENABLE__FLAG)) + ; + + iowrite32(0, FlashReg + TRANSFER_SPARE_REG); + + index_addr((u32)(MODE_10 | (flash_bank << 24) | + (flash_add >> DeviceInfo.nBitsInPageDataSize)), 0x42); + ddma_trans(read_data, flash_add, flash_bank, 0, NumPages); + + ecc_done_OR_dma_comp = 0; + while (1) { + if (enable_ecc) { + while (!ioread32(FlashReg + intr_status)) + ; + + if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__ECC_ERR) { + iowrite32(INTR_STATUS0__ECC_ERR, + FlashReg + intr_status); + status = do_ecc_new(flash_bank, + read_data, block, page); + } else if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__DMA_CMD_COMP) { + iowrite32(INTR_STATUS0__DMA_CMD_COMP, + FlashReg + intr_status); + + if (1 == ecc_done_OR_dma_comp) + break; + + ecc_done_OR_dma_comp = 1; + } else if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__ECC_TRANSACTION_DONE) { + iowrite32( + INTR_STATUS0__ECC_TRANSACTION_DONE, + FlashReg + intr_status); + + if (1 == ecc_done_OR_dma_comp) + break; + + ecc_done_OR_dma_comp = 1; + } + } else { + while (!(ioread32(FlashReg + intr_status) & + INTR_STATUS0__DMA_CMD_COMP)) + ; + + iowrite32(INTR_STATUS0__DMA_CMD_COMP, + FlashReg + intr_status); + break; + } + + iowrite32((~INTR_STATUS0__ECC_ERR) & + (~INTR_STATUS0__ECC_TRANSACTION_DONE) & + (~INTR_STATUS0__DMA_CMD_COMP), + FlashReg + intr_status); + + } + + iowrite32(ioread32(FlashReg + intr_status), + FlashReg + intr_status); + + iowrite32(0, FlashReg + DMA_ENABLE); + + while ((ioread32(FlashReg + DMA_ENABLE) & DMA_ENABLE__FLAG)) + ; + } + return status; +} + +u16 NAND_Read_Page_Main(u8 *read_data, u32 block, u16 page, + u16 page_count) +{ + u32 status = PASS; + u64 flash_add; + u32 intr_status = 0; + u32 flash_bank; + u32 intr_status_addresses[4] = {INTR_STATUS0, + INTR_STATUS1, INTR_STATUS2, INTR_STATUS3}; + int ret; + u8 *read_data_l; + + nand_dbg_print(NAND_DBG_DEBUG, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + status = Boundary_Check_Block_Page(block, page, page_count); + if (status != PASS) + return status; + + flash_add = (u64)(block % (DeviceInfo.wTotalBlocks / totalUsedBanks)) + * DeviceInfo.wBlockDataSize + + (u64)page * DeviceInfo.wPageDataSize; + flash_bank = block / (DeviceInfo.wTotalBlocks / totalUsedBanks); + + iowrite32(0, FlashReg + TRANSFER_SPARE_REG); + + intr_status = intr_status_addresses[flash_bank]; + iowrite32(ioread32(FlashReg + intr_status), FlashReg + intr_status); + + if (page_count > 1) { + read_data_l = read_data; + while (page_count > MAX_PAGES_PER_RW) { + if (ioread32(FlashReg + MULTIPLANE_OPERATION)) + status = NAND_Multiplane_Read(read_data_l, + block, page, MAX_PAGES_PER_RW); + else + status = NAND_Pipeline_Read_Ahead( + read_data_l, block, page, + MAX_PAGES_PER_RW); + + if (status == FAIL) + return status; + + read_data_l += DeviceInfo.wPageDataSize * + MAX_PAGES_PER_RW; + page_count -= MAX_PAGES_PER_RW; + page += MAX_PAGES_PER_RW; + } + if (ioread32(FlashReg + MULTIPLANE_OPERATION)) + status = NAND_Multiplane_Read(read_data_l, + block, page, page_count); + else + status = NAND_Pipeline_Read_Ahead( + read_data_l, block, page, page_count); + + return status; + } + + iowrite32(1, FlashReg + DMA_ENABLE); + while (!(ioread32(FlashReg + DMA_ENABLE) & DMA_ENABLE__FLAG)) + ; + + iowrite32(0, FlashReg + TRANSFER_SPARE_REG); + iowrite32(ioread32(FlashReg + intr_status), FlashReg + intr_status); + + /* Fill the mrst_nand_info structure */ + info.state = INT_READ_PAGE_MAIN; + info.read_data = read_data; + info.flash_bank = flash_bank; + info.block = block; + info.page = page; + info.ret = PASS; + + ddma_trans(read_data, flash_add, flash_bank, 0, 1); + + iowrite32(1, FlashReg + GLOBAL_INT_ENABLE); /* Enable Interrupt */ + + ret = wait_for_completion_timeout(&info.complete, 10 * HZ); + if (!ret) { + printk(KERN_ERR "Wait for completion timeout " + "in %s, Line %d\n", __FILE__, __LINE__); + status = ERR; + } else { + status = info.ret; + } + + iowrite32(ioread32(FlashReg + intr_status), FlashReg + intr_status); + + iowrite32(0, FlashReg + DMA_ENABLE); + while ((ioread32(FlashReg + DMA_ENABLE) & DMA_ENABLE__FLAG)) + ; + + return status; +} + +void Conv_Spare_Data_Log2Phy_Format(u8 *data) +{ + int i; + const u32 spareFlagBytes = DeviceInfo.wNumPageSpareFlag; + const u32 PageSpareSize = DeviceInfo.wPageSpareSize; + + if (enable_ecc) { + for (i = spareFlagBytes - 1; i >= 0; i++) + data[PageSpareSize - spareFlagBytes + i] = data[i]; + } +} + +void Conv_Spare_Data_Phy2Log_Format(u8 *data) +{ + int i; + const u32 spareFlagBytes = DeviceInfo.wNumPageSpareFlag; + const u32 PageSpareSize = DeviceInfo.wPageSpareSize; + + if (enable_ecc) { + for (i = 0; i < spareFlagBytes; i++) + data[i] = data[PageSpareSize - spareFlagBytes + i]; + } +} + + +void Conv_Main_Spare_Data_Log2Phy_Format(u8 *data, u16 page_count) +{ + const u32 PageSize = DeviceInfo.wPageSize; + const u32 PageDataSize = DeviceInfo.wPageDataSize; + const u32 eccBytes = DeviceInfo.wECCBytesPerSector; + const u32 spareSkipBytes = DeviceInfo.wSpareSkipBytes; + const u32 spareFlagBytes = DeviceInfo.wNumPageSpareFlag; + u32 eccSectorSize; + u32 page_offset; + int i, j; + + eccSectorSize = ECC_SECTOR_SIZE * (DeviceInfo.wDevicesConnected); + if (enable_ecc) { + while (page_count > 0) { + page_offset = (page_count - 1) * PageSize; + j = (DeviceInfo.wPageDataSize / eccSectorSize); + for (i = spareFlagBytes - 1; i >= 0; i--) + data[page_offset + + (eccSectorSize + eccBytes) * j + i] = + data[page_offset + PageDataSize + i]; + for (j--; j >= 1; j--) { + for (i = eccSectorSize - 1; i >= 0; i--) + data[page_offset + + (eccSectorSize + eccBytes) * j + i] = + data[page_offset + + eccSectorSize * j + i]; + } + for (i = (PageSize - spareSkipBytes) - 1; + i >= PageDataSize; i--) + data[page_offset + i + spareSkipBytes] = + data[page_offset + i]; + page_count--; + } + } +} + +void Conv_Main_Spare_Data_Phy2Log_Format(u8 *data, u16 page_count) +{ + const u32 PageSize = DeviceInfo.wPageSize; + const u32 PageDataSize = DeviceInfo.wPageDataSize; + const u32 eccBytes = DeviceInfo.wECCBytesPerSector; + const u32 spareSkipBytes = DeviceInfo.wSpareSkipBytes; + const u32 spareFlagBytes = DeviceInfo.wNumPageSpareFlag; + u32 eccSectorSize; + u32 page_offset; + int i, j; + + eccSectorSize = ECC_SECTOR_SIZE * (DeviceInfo.wDevicesConnected); + if (enable_ecc) { + while (page_count > 0) { + page_offset = (page_count - 1) * PageSize; + for (i = PageDataSize; + i < PageSize - spareSkipBytes; + i++) + data[page_offset + i] = + data[page_offset + i + + spareSkipBytes]; + for (j = 1; + j < DeviceInfo.wPageDataSize / eccSectorSize; + j++) { + for (i = 0; i < eccSectorSize; i++) + data[page_offset + + eccSectorSize * j + i] = + data[page_offset + + (eccSectorSize + eccBytes) * j + + i]; + } + for (i = 0; i < spareFlagBytes; i++) + data[page_offset + PageDataSize + i] = + data[page_offset + + (eccSectorSize + eccBytes) * j + i]; + page_count--; + } + } +} + +/* Un-tested function */ +u16 NAND_Multiplane_Read(u8 *read_data, u32 block, u16 page, + u16 page_count) +{ + u32 status = PASS; + u32 NumPages = page_count; + u64 flash_add; + u32 flash_bank; + u32 intr_status = 0; + u32 intr_status_addresses[4] = {INTR_STATUS0, + INTR_STATUS1, INTR_STATUS2, INTR_STATUS3}; + u32 ecc_done_OR_dma_comp; + + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + status = Boundary_Check_Block_Page(block, page, page_count); + + flash_add = (u64)(block % (DeviceInfo.wTotalBlocks / totalUsedBanks)) + * DeviceInfo.wBlockDataSize + + (u64)page * DeviceInfo.wPageDataSize; + + flash_bank = block / (DeviceInfo.wTotalBlocks / totalUsedBanks); + + if (status == PASS) { + intr_status = intr_status_addresses[flash_bank]; + iowrite32(ioread32(FlashReg + intr_status), + FlashReg + intr_status); + + iowrite32(0, FlashReg + TRANSFER_SPARE_REG); + iowrite32(0x01, FlashReg + MULTIPLANE_OPERATION); + + iowrite32(1, FlashReg + DMA_ENABLE); + while (!(ioread32(FlashReg + DMA_ENABLE) & DMA_ENABLE__FLAG)) + ; + index_addr((u32)(MODE_10 | (flash_bank << 24) | + (flash_add >> DeviceInfo.nBitsInPageDataSize)), 0x42); + ddma_trans(read_data, flash_add, flash_bank, 0, NumPages); + + ecc_done_OR_dma_comp = 0; + while (1) { + if (enable_ecc) { + while (!ioread32(FlashReg + intr_status)) + ; + + if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__ECC_ERR) { + iowrite32(INTR_STATUS0__ECC_ERR, + FlashReg + intr_status); + status = do_ecc_new(flash_bank, + read_data, block, page); + } else if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__DMA_CMD_COMP) { + iowrite32(INTR_STATUS0__DMA_CMD_COMP, + FlashReg + intr_status); + + if (1 == ecc_done_OR_dma_comp) + break; + + ecc_done_OR_dma_comp = 1; + } else if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__ECC_TRANSACTION_DONE) { + iowrite32( + INTR_STATUS0__ECC_TRANSACTION_DONE, + FlashReg + intr_status); + + if (1 == ecc_done_OR_dma_comp) + break; + + ecc_done_OR_dma_comp = 1; + } + } else { + while (!(ioread32(FlashReg + intr_status) & + INTR_STATUS0__DMA_CMD_COMP)) + ; + iowrite32(INTR_STATUS0__DMA_CMD_COMP, + FlashReg + intr_status); + break; + } + + iowrite32((~INTR_STATUS0__ECC_ERR) & + (~INTR_STATUS0__ECC_TRANSACTION_DONE) & + (~INTR_STATUS0__DMA_CMD_COMP), + FlashReg + intr_status); + + } + + iowrite32(ioread32(FlashReg + intr_status), + FlashReg + intr_status); + + iowrite32(0, FlashReg + DMA_ENABLE); + + while ((ioread32(FlashReg + DMA_ENABLE) & DMA_ENABLE__FLAG)) + ; + + iowrite32(0, FlashReg + MULTIPLANE_OPERATION); + } + + return status; +} + +u16 NAND_Pipeline_Read_Ahead(u8 *read_data, u32 block, + u16 page, u16 page_count) +{ + u32 status = PASS; + u32 NumPages = page_count; + u64 flash_add; + u32 flash_bank; + u32 intr_status = 0; + u32 intr_status_addresses[4] = {INTR_STATUS0, + INTR_STATUS1, INTR_STATUS2, INTR_STATUS3}; + int ret; + + nand_dbg_print(NAND_DBG_DEBUG, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + status = Boundary_Check_Block_Page(block, page, page_count); + + if (page_count < 2) + status = FAIL; + + if (status != PASS) + return status; + + flash_add = (u64)(block % (DeviceInfo.wTotalBlocks / totalUsedBanks)) + *DeviceInfo.wBlockDataSize + + (u64)page * DeviceInfo.wPageDataSize; + + flash_bank = block / (DeviceInfo.wTotalBlocks / totalUsedBanks); + + intr_status = intr_status_addresses[flash_bank]; + iowrite32(ioread32(FlashReg + intr_status), FlashReg + intr_status); + + iowrite32(1, FlashReg + DMA_ENABLE); + while (!(ioread32(FlashReg + DMA_ENABLE) & DMA_ENABLE__FLAG)) + ; + + iowrite32(0, FlashReg + TRANSFER_SPARE_REG); + + /* Fill the mrst_nand_info structure */ + info.state = INT_PIPELINE_READ_AHEAD; + info.read_data = read_data; + info.flash_bank = flash_bank; + info.block = block; + info.page = page; + info.ret = PASS; + + index_addr((u32)(MODE_10 | (flash_bank << 24) | + (flash_add >> DeviceInfo.nBitsInPageDataSize)), 0x42); + + ddma_trans(read_data, flash_add, flash_bank, 0, NumPages); + + iowrite32(1, FlashReg + GLOBAL_INT_ENABLE); /* Enable Interrupt */ + + ret = wait_for_completion_timeout(&info.complete, 10 * HZ); + if (!ret) { + printk(KERN_ERR "Wait for completion timeout " + "in %s, Line %d\n", __FILE__, __LINE__); + status = ERR; + } else { + status = info.ret; + } + + iowrite32(ioread32(FlashReg + intr_status), FlashReg + intr_status); + + iowrite32(0, FlashReg + DMA_ENABLE); + + while ((ioread32(FlashReg + DMA_ENABLE) & DMA_ENABLE__FLAG)) + ; + + return status; +} + + +u16 NAND_Write_Page_Main(u8 *write_data, u32 block, u16 page, + u16 page_count) +{ + u32 status = PASS; + u64 flash_add; + u32 intr_status = 0; + u32 flash_bank; + u32 intr_status_addresses[4] = {INTR_STATUS0, + INTR_STATUS1, INTR_STATUS2, INTR_STATUS3}; + int ret; + u8 *write_data_l; + + nand_dbg_print(NAND_DBG_DEBUG, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + status = Boundary_Check_Block_Page(block, page, page_count); + if (status != PASS) + return status; + + flash_add = (u64)(block % (DeviceInfo.wTotalBlocks / totalUsedBanks)) + * DeviceInfo.wBlockDataSize + + (u64)page * DeviceInfo.wPageDataSize; + + flash_bank = block / (DeviceInfo.wTotalBlocks / totalUsedBanks); + + intr_status = intr_status_addresses[flash_bank]; + + iowrite32(0, FlashReg + TRANSFER_SPARE_REG); + + iowrite32(INTR_STATUS0__PROGRAM_COMP | + INTR_STATUS0__PROGRAM_FAIL, FlashReg + intr_status); + + if (page_count > 1) { + write_data_l = write_data; + while (page_count > MAX_PAGES_PER_RW) { + if (ioread32(FlashReg + MULTIPLANE_OPERATION)) + status = NAND_Multiplane_Write(write_data_l, + block, page, MAX_PAGES_PER_RW); + else + status = NAND_Pipeline_Write_Ahead( + write_data_l, block, page, + MAX_PAGES_PER_RW); + if (status == FAIL) + return status; + + write_data_l += DeviceInfo.wPageDataSize * + MAX_PAGES_PER_RW; + page_count -= MAX_PAGES_PER_RW; + page += MAX_PAGES_PER_RW; + } + if (ioread32(FlashReg + MULTIPLANE_OPERATION)) + status = NAND_Multiplane_Write(write_data_l, + block, page, page_count); + else + status = NAND_Pipeline_Write_Ahead(write_data_l, + block, page, page_count); + + return status; + } + + iowrite32(1, FlashReg + DMA_ENABLE); + while (!(ioread32(FlashReg + DMA_ENABLE) & DMA_ENABLE__FLAG)) + ; + + iowrite32(0, FlashReg + TRANSFER_SPARE_REG); + + iowrite32(ioread32(FlashReg + intr_status), FlashReg + intr_status); + + /* Fill the mrst_nand_info structure */ + info.state = INT_WRITE_PAGE_MAIN; + info.write_data = write_data; + info.flash_bank = flash_bank; + info.block = block; + info.page = page; + info.ret = PASS; + + ddma_trans(write_data, flash_add, flash_bank, 1, 1); + + iowrite32(1, FlashReg + GLOBAL_INT_ENABLE); /* Enable interrupt */ + + ret = wait_for_completion_timeout(&info.complete, 10 * HZ); + if (!ret) { + printk(KERN_ERR "Wait for completion timeout " + "in %s, Line %d\n", __FILE__, __LINE__); + status = ERR; + } else { + status = info.ret; + } + + iowrite32(ioread32(FlashReg + intr_status), FlashReg + intr_status); + + iowrite32(0, FlashReg + DMA_ENABLE); + while (ioread32(FlashReg + DMA_ENABLE) & DMA_ENABLE__FLAG) + ; + + return status; +} + +void NAND_ECC_Ctrl(int enable) +{ + if (enable) { + nand_dbg_print(NAND_DBG_WARN, + "Will enable ECC in %s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + iowrite32(1, FlashReg + ECC_ENABLE); + enable_ecc = 1; + } else { + nand_dbg_print(NAND_DBG_WARN, + "Will disable ECC in %s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + iowrite32(0, FlashReg + ECC_ENABLE); + enable_ecc = 0; + } +} + +u16 NAND_Write_Page_Main_Spare(u8 *write_data, u32 block, + u16 page, u16 page_count) +{ + u32 status = PASS; + u32 i, j, page_num = 0; + u32 PageSize = DeviceInfo.wPageSize; + u32 PageDataSize = DeviceInfo.wPageDataSize; + u32 eccBytes = DeviceInfo.wECCBytesPerSector; + u32 spareFlagBytes = DeviceInfo.wNumPageSpareFlag; + u32 spareSkipBytes = DeviceInfo.wSpareSkipBytes; + u64 flash_add; + u32 eccSectorSize; + u32 flash_bank; + u32 intr_status = 0; + u32 intr_status_addresses[4] = {INTR_STATUS0, + INTR_STATUS1, INTR_STATUS2, INTR_STATUS3}; + u8 *page_main_spare = buf_write_page_main_spare; + + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + eccSectorSize = ECC_SECTOR_SIZE * (DeviceInfo.wDevicesConnected); + + status = Boundary_Check_Block_Page(block, page, page_count); + + flash_bank = block / (DeviceInfo.wTotalBlocks / totalUsedBanks); + + if (status == PASS) { + intr_status = intr_status_addresses[flash_bank]; + + iowrite32(1, FlashReg + TRANSFER_SPARE_REG); + + while ((status != FAIL) && (page_count > 0)) { + flash_add = (u64)(block % + (DeviceInfo.wTotalBlocks / totalUsedBanks)) * + DeviceInfo.wBlockDataSize + + (u64)page * DeviceInfo.wPageDataSize; + + iowrite32(ioread32(FlashReg + intr_status), + FlashReg + intr_status); + + iowrite32((u32)(MODE_01 | (flash_bank << 24) | + (flash_add >> + DeviceInfo.nBitsInPageDataSize)), + FlashMem); + + if (enable_ecc) { + for (j = 0; + j < + DeviceInfo.wPageDataSize / eccSectorSize; + j++) { + for (i = 0; i < eccSectorSize; i++) + page_main_spare[(eccSectorSize + + eccBytes) * j + + i] = + write_data[eccSectorSize * + j + i]; + + for (i = 0; i < eccBytes; i++) + page_main_spare[(eccSectorSize + + eccBytes) * j + + eccSectorSize + + i] = + write_data[PageDataSize + + spareFlagBytes + + eccBytes * j + + i]; + } + + for (i = 0; i < spareFlagBytes; i++) + page_main_spare[(eccSectorSize + + eccBytes) * j + i] = + write_data[PageDataSize + i]; + + for (i = PageSize - 1; i >= PageDataSize + + spareSkipBytes; i--) + page_main_spare[i] = page_main_spare[i - + spareSkipBytes]; + + for (i = PageDataSize; i < PageDataSize + + spareSkipBytes; i++) + page_main_spare[i] = 0xff; + + for (i = 0; i < PageSize / 4; i++) + iowrite32( + *((u32 *)page_main_spare + i), + FlashMem + 0x10); + } else { + + for (i = 0; i < PageSize / 4; i++) + iowrite32(*((u32 *)write_data + i), + FlashMem + 0x10); + } + + while (!(ioread32(FlashReg + intr_status) & + (INTR_STATUS0__PROGRAM_COMP | + INTR_STATUS0__PROGRAM_FAIL))) + ; + + if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__PROGRAM_FAIL) + status = FAIL; + + iowrite32(ioread32(FlashReg + intr_status), + FlashReg + intr_status); + + page_num++; + page_count--; + write_data += PageSize; + } + + iowrite32(0, FlashReg + TRANSFER_SPARE_REG); + } + + return status; +} + +u16 NAND_Read_Page_Main_Spare(u8 *read_data, u32 block, u16 page, + u16 page_count) +{ + u32 status = PASS; + u32 i, j; + u64 flash_add = 0; + u32 PageSize = DeviceInfo.wPageSize; + u32 PageDataSize = DeviceInfo.wPageDataSize; + u32 PageSpareSize = DeviceInfo.wPageSpareSize; + u32 eccBytes = DeviceInfo.wECCBytesPerSector; + u32 spareFlagBytes = DeviceInfo.wNumPageSpareFlag; + u32 spareSkipBytes = DeviceInfo.wSpareSkipBytes; + u32 eccSectorSize; + u32 flash_bank; + u32 intr_status = 0; + u8 *read_data_l = read_data; + u32 intr_status_addresses[4] = {INTR_STATUS0, + INTR_STATUS1, INTR_STATUS2, INTR_STATUS3}; + u8 *page_main_spare = buf_read_page_main_spare; + + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + eccSectorSize = ECC_SECTOR_SIZE * (DeviceInfo.wDevicesConnected); + + status = Boundary_Check_Block_Page(block, page, page_count); + + flash_bank = block / (DeviceInfo.wTotalBlocks / totalUsedBanks); + + if (status == PASS) { + intr_status = intr_status_addresses[flash_bank]; + + iowrite32(1, FlashReg + TRANSFER_SPARE_REG); + + iowrite32(ioread32(FlashReg + intr_status), + FlashReg + intr_status); + + while ((status != FAIL) && (page_count > 0)) { + flash_add = (u64)(block % + (DeviceInfo.wTotalBlocks / totalUsedBanks)) + * DeviceInfo.wBlockDataSize + + (u64)page * DeviceInfo.wPageDataSize; + + index_addr((u32)(MODE_10 | (flash_bank << 24) | + (flash_add >> DeviceInfo.nBitsInPageDataSize)), + 0x43); + index_addr((u32)(MODE_10 | (flash_bank << 24) | + (flash_add >> DeviceInfo.nBitsInPageDataSize)), + 0x2000 | page_count); + + while (!(ioread32(FlashReg + intr_status) & + INTR_STATUS0__LOAD_COMP)) + ; + + iowrite32((u32)(MODE_01 | (flash_bank << 24) | + (flash_add >> + DeviceInfo.nBitsInPageDataSize)), + FlashMem); + + for (i = 0; i < PageSize / 4; i++) + *(((u32 *)page_main_spare) + i) = + ioread32(FlashMem + 0x10); + + if (enable_ecc) { + for (i = PageDataSize; i < PageSize - + spareSkipBytes; i++) + page_main_spare[i] = page_main_spare[i + + spareSkipBytes]; + + for (j = 0; + j < DeviceInfo.wPageDataSize / eccSectorSize; + j++) { + + for (i = 0; i < eccSectorSize; i++) + read_data_l[eccSectorSize * j + + i] = + page_main_spare[ + (eccSectorSize + + eccBytes) * j + i]; + + for (i = 0; i < eccBytes; i++) + read_data_l[PageDataSize + + spareFlagBytes + + eccBytes * j + i] = + page_main_spare[ + (eccSectorSize + + eccBytes) * j + + eccSectorSize + i]; + } + + for (i = 0; i < spareFlagBytes; i++) + read_data_l[PageDataSize + i] = + page_main_spare[(eccSectorSize + + eccBytes) * j + i]; + } else { + for (i = 0; i < (PageDataSize + PageSpareSize); + i++) + read_data_l[i] = page_main_spare[i]; + + } + + if (enable_ecc) { + while (!(ioread32(FlashReg + intr_status) & + (INTR_STATUS0__ECC_TRANSACTION_DONE | + INTR_STATUS0__ECC_ERR))) + ; + + if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__ECC_ERR) { + iowrite32(INTR_STATUS0__ECC_ERR, + FlashReg + intr_status); + status = do_ecc_new(flash_bank, + read_data, block, page); + } + + if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__ECC_TRANSACTION_DONE & + INTR_STATUS0__ECC_ERR) { + iowrite32(INTR_STATUS0__ECC_ERR | + INTR_STATUS0__ECC_TRANSACTION_DONE, + FlashReg + intr_status); + } else if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__ECC_TRANSACTION_DONE) { + iowrite32( + INTR_STATUS0__ECC_TRANSACTION_DONE, + FlashReg + intr_status); + } else if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__ECC_ERR) { + iowrite32(INTR_STATUS0__ECC_ERR, + FlashReg + intr_status); + } + } + + page++; + page_count--; + read_data_l += PageSize; + } + } + + iowrite32(0, FlashReg + TRANSFER_SPARE_REG); + + index_addr((u32)(MODE_10 | (flash_bank << 24) | + (flash_add >> DeviceInfo.nBitsInPageDataSize)), 0x42); + + return status; +} + +u16 NAND_Pipeline_Write_Ahead(u8 *write_data, u32 block, + u16 page, u16 page_count) +{ + u16 status = PASS; + u32 NumPages = page_count; + u64 flash_add; + u32 flash_bank; + u32 intr_status = 0; + u32 intr_status_addresses[4] = {INTR_STATUS0, + INTR_STATUS1, INTR_STATUS2, INTR_STATUS3}; + int ret; + + nand_dbg_print(NAND_DBG_DEBUG, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + status = Boundary_Check_Block_Page(block, page, page_count); + + if (page_count < 2) + status = FAIL; + + if (status != PASS) + return status; + + flash_add = (u64)(block % (DeviceInfo.wTotalBlocks / totalUsedBanks)) + * DeviceInfo.wBlockDataSize + + (u64)page * DeviceInfo.wPageDataSize; + + flash_bank = block / (DeviceInfo.wTotalBlocks / totalUsedBanks); + + intr_status = intr_status_addresses[flash_bank]; + iowrite32(ioread32(FlashReg + intr_status), FlashReg + intr_status); + + iowrite32(1, FlashReg + DMA_ENABLE); + while (!(ioread32(FlashReg + DMA_ENABLE) & DMA_ENABLE__FLAG)) + ; + + iowrite32(0, FlashReg + TRANSFER_SPARE_REG); + + /* Fill the mrst_nand_info structure */ + info.state = INT_PIPELINE_WRITE_AHEAD; + info.write_data = write_data; + info.flash_bank = flash_bank; + info.block = block; + info.page = page; + info.ret = PASS; + + index_addr((u32)(MODE_10 | (flash_bank << 24) | + (flash_add >> DeviceInfo.nBitsInPageDataSize)), 0x42); + + ddma_trans(write_data, flash_add, flash_bank, 1, NumPages); + + iowrite32(1, FlashReg + GLOBAL_INT_ENABLE); /* Enable interrupt */ + + ret = wait_for_completion_timeout(&info.complete, 10 * HZ); + if (!ret) { + printk(KERN_ERR "Wait for completion timeout " + "in %s, Line %d\n", __FILE__, __LINE__); + status = ERR; + } else { + status = info.ret; + } + + iowrite32(ioread32(FlashReg + intr_status), FlashReg + intr_status); + + iowrite32(0, FlashReg + DMA_ENABLE); + while ((ioread32(FlashReg + DMA_ENABLE) & DMA_ENABLE__FLAG)) + ; + + return status; +} + +/* Un-tested function */ +u16 NAND_Multiplane_Write(u8 *write_data, u32 block, u16 page, + u16 page_count) +{ + u16 status = PASS; + u32 NumPages = page_count; + u64 flash_add; + u32 flash_bank; + u32 intr_status = 0; + u32 intr_status_addresses[4] = {INTR_STATUS0, + INTR_STATUS1, INTR_STATUS2, INTR_STATUS3}; + u16 status2 = PASS; + u32 t; + + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + status = Boundary_Check_Block_Page(block, page, page_count); + if (status != PASS) + return status; + + flash_add = (u64)(block % (DeviceInfo.wTotalBlocks / totalUsedBanks)) + * DeviceInfo.wBlockDataSize + + (u64)page * DeviceInfo.wPageDataSize; + + flash_bank = block / (DeviceInfo.wTotalBlocks / totalUsedBanks); + + intr_status = intr_status_addresses[flash_bank]; + iowrite32(ioread32(FlashReg + intr_status), FlashReg + intr_status); + + iowrite32(0, FlashReg + TRANSFER_SPARE_REG); + iowrite32(0x01, FlashReg + MULTIPLANE_OPERATION); + + iowrite32(1, FlashReg + DMA_ENABLE); + while (!(ioread32(FlashReg + DMA_ENABLE) & DMA_ENABLE__FLAG)) + ; + + iowrite32(0, FlashReg + TRANSFER_SPARE_REG); + + index_addr((u32)(MODE_10 | (flash_bank << 24) | + (flash_add >> DeviceInfo.nBitsInPageDataSize)), 0x42); + + ddma_trans(write_data, flash_add, flash_bank, 1, NumPages); + + while (1) { + while (!ioread32(FlashReg + intr_status)) + ; + + if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__DMA_CMD_COMP) { + iowrite32(INTR_STATUS0__DMA_CMD_COMP, + FlashReg + intr_status); + status = PASS; + if (status2 == FAIL) + status = FAIL; + break; + } else if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__PROGRAM_FAIL) { + status2 = FAIL; + status = FAIL; + t = ioread32(FlashReg + intr_status) & + INTR_STATUS0__PROGRAM_FAIL; + iowrite32(t, FlashReg + intr_status); + } else { + iowrite32((~INTR_STATUS0__PROGRAM_FAIL) & + (~INTR_STATUS0__DMA_CMD_COMP), + FlashReg + intr_status); + } + } + + iowrite32(ioread32(FlashReg + intr_status), FlashReg + intr_status); + + iowrite32(0, FlashReg + DMA_ENABLE); + + while ((ioread32(FlashReg + DMA_ENABLE) & DMA_ENABLE__FLAG)) + ; + + iowrite32(0, FlashReg + MULTIPLANE_OPERATION); + + return status; +} + + +#if CMD_DMA +static irqreturn_t cdma_isr(int irq, void *dev_id) +{ + struct mrst_nand_info *dev = dev_id; + int first_failed_cmd; + + nand_dbg_print(NAND_DBG_DEBUG, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (!is_cdma_interrupt()) + return IRQ_NONE; + + /* Disable controller interrupts */ + iowrite32(0, FlashReg + GLOBAL_INT_ENABLE); + GLOB_FTL_Event_Status(&first_failed_cmd); + complete(&dev->complete); + + return IRQ_HANDLED; +} +#else +static void handle_nand_int_read(struct mrst_nand_info *dev) +{ + u32 intr_status_addresses[4] = {INTR_STATUS0, + INTR_STATUS1, INTR_STATUS2, INTR_STATUS3}; + u32 intr_status; + u32 ecc_done_OR_dma_comp = 0; + + nand_dbg_print(NAND_DBG_DEBUG, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + dev->ret = PASS; + intr_status = intr_status_addresses[dev->flash_bank]; + + while (1) { + if (enable_ecc) { + if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__ECC_ERR) { + iowrite32(INTR_STATUS0__ECC_ERR, + FlashReg + intr_status); + dev->ret = do_ecc_new(dev->flash_bank, + dev->read_data, + dev->block, dev->page); + } else if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__DMA_CMD_COMP) { + iowrite32(INTR_STATUS0__DMA_CMD_COMP, + FlashReg + intr_status); + if (1 == ecc_done_OR_dma_comp) + break; + ecc_done_OR_dma_comp = 1; + } else if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__ECC_TRANSACTION_DONE) { + iowrite32(INTR_STATUS0__ECC_TRANSACTION_DONE, + FlashReg + intr_status); + if (1 == ecc_done_OR_dma_comp) + break; + ecc_done_OR_dma_comp = 1; + } + } else { + if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__DMA_CMD_COMP) { + iowrite32(INTR_STATUS0__DMA_CMD_COMP, + FlashReg + intr_status); + break; + } else { + printk(KERN_ERR "Illegal INTS " + "(offset addr 0x%x) value: 0x%x\n", + intr_status, + ioread32(FlashReg + intr_status)); + } + } + + iowrite32((~INTR_STATUS0__ECC_ERR) & + (~INTR_STATUS0__ECC_TRANSACTION_DONE) & + (~INTR_STATUS0__DMA_CMD_COMP), + FlashReg + intr_status); + } +} + +static void handle_nand_int_write(struct mrst_nand_info *dev) +{ + u32 intr_status; + u32 intr[4] = {INTR_STATUS0, INTR_STATUS1, + INTR_STATUS2, INTR_STATUS3}; + int status = PASS; + + nand_dbg_print(NAND_DBG_DEBUG, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + dev->ret = PASS; + intr_status = intr[dev->flash_bank]; + + while (1) { + while (!ioread32(FlashReg + intr_status)) + ; + + if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__DMA_CMD_COMP) { + iowrite32(INTR_STATUS0__DMA_CMD_COMP, + FlashReg + intr_status); + if (FAIL == status) + dev->ret = FAIL; + break; + } else if (ioread32(FlashReg + intr_status) & + INTR_STATUS0__PROGRAM_FAIL) { + status = FAIL; + iowrite32(INTR_STATUS0__PROGRAM_FAIL, + FlashReg + intr_status); + } else { + iowrite32((~INTR_STATUS0__PROGRAM_FAIL) & + (~INTR_STATUS0__DMA_CMD_COMP), + FlashReg + intr_status); + } + } +} + +static irqreturn_t ddma_isr(int irq, void *dev_id) +{ + struct mrst_nand_info *dev = dev_id; + u32 int_mask, ints0, ints1, ints2, ints3, ints_offset; + u32 intr[4] = {INTR_STATUS0, INTR_STATUS1, + INTR_STATUS2, INTR_STATUS3}; + + int_mask = INTR_STATUS0__DMA_CMD_COMP | + INTR_STATUS0__ECC_TRANSACTION_DONE | + INTR_STATUS0__ECC_ERR | + INTR_STATUS0__PROGRAM_FAIL | + INTR_STATUS0__ERASE_FAIL; + + ints0 = ioread32(FlashReg + INTR_STATUS0); + ints1 = ioread32(FlashReg + INTR_STATUS1); + ints2 = ioread32(FlashReg + INTR_STATUS2); + ints3 = ioread32(FlashReg + INTR_STATUS3); + + ints_offset = intr[dev->flash_bank]; + + nand_dbg_print(NAND_DBG_DEBUG, + "INTR0: 0x%x, INTR1: 0x%x, INTR2: 0x%x, INTR3: 0x%x, " + "DMA_INTR: 0x%x, " + "dev->state: 0x%x, dev->flash_bank: %d\n", + ints0, ints1, ints2, ints3, + ioread32(FlashReg + DMA_INTR), + dev->state, dev->flash_bank); + + if (!(ioread32(FlashReg + ints_offset) & int_mask)) { + iowrite32(ints0, FlashReg + INTR_STATUS0); + iowrite32(ints1, FlashReg + INTR_STATUS1); + iowrite32(ints2, FlashReg + INTR_STATUS2); + iowrite32(ints3, FlashReg + INTR_STATUS3); + nand_dbg_print(NAND_DBG_WARN, + "ddma_isr: Invalid interrupt for NAND controller. " + "Ignore it\n"); + return IRQ_NONE; + } + + switch (dev->state) { + case INT_READ_PAGE_MAIN: + case INT_PIPELINE_READ_AHEAD: + /* Disable controller interrupts */ + iowrite32(0, FlashReg + GLOBAL_INT_ENABLE); + handle_nand_int_read(dev); + break; + case INT_WRITE_PAGE_MAIN: + case INT_PIPELINE_WRITE_AHEAD: + iowrite32(0, FlashReg + GLOBAL_INT_ENABLE); + handle_nand_int_write(dev); + break; + default: + printk(KERN_ERR "ddma_isr - Illegal state: 0x%x\n", + dev->state); + return IRQ_NONE; + } + + dev->state = INT_IDLE_STATE; + complete(&dev->complete); + return IRQ_HANDLED; +} +#endif + +static const struct pci_device_id nand_pci_ids[] = { + { + .vendor = 0x8086, + .device = 0x0809, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + }, + { /* end: all zeroes */ } +}; + +static int nand_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) +{ + int ret = -ENODEV; + unsigned long csr_base; + unsigned long csr_len; + struct mrst_nand_info *pndev = &info; + + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + ret = pci_enable_device(dev); + if (ret) { + printk(KERN_ERR "Spectra: pci_enable_device failed.\n"); + return ret; + } + + pci_set_master(dev); + pndev->dev = dev; + + csr_base = pci_resource_start(dev, 0); + if (!csr_base) { + printk(KERN_ERR "Spectra: pci_resource_start failed!\n"); + return -ENODEV; + } + + csr_len = pci_resource_len(dev, 0); + if (!csr_len) { + printk(KERN_ERR "Spectra: pci_resource_len failed!\n"); + return -ENODEV; + } + + ret = pci_request_regions(dev, SPECTRA_NAND_NAME); + if (ret) { + printk(KERN_ERR "Spectra: Unable to request " + "memory region\n"); + goto failed_req_csr; + } + + pndev->ioaddr = ioremap_nocache(csr_base, csr_len); + if (!pndev->ioaddr) { + printk(KERN_ERR "Spectra: Unable to remap memory region\n"); + ret = -ENOMEM; + goto failed_remap_csr; + } + nand_dbg_print(NAND_DBG_DEBUG, "Spectra: CSR 0x%08lx -> 0x%p (0x%lx)\n", + csr_base, pndev->ioaddr, csr_len); + + init_completion(&pndev->complete); + nand_dbg_print(NAND_DBG_DEBUG, "Spectra: IRQ %d\n", dev->irq); + +#if CMD_DMA + if (request_irq(dev->irq, cdma_isr, IRQF_SHARED, + SPECTRA_NAND_NAME, &info)) { + printk(KERN_ERR "Spectra: Unable to allocate IRQ\n"); + ret = -ENODEV; + iounmap(pndev->ioaddr); + goto failed_remap_csr; + } +#else + if (request_irq(dev->irq, ddma_isr, IRQF_SHARED, + SPECTRA_NAND_NAME, &info)) { + printk(KERN_ERR "Spectra: Unable to allocate IRQ\n"); + ret = -ENODEV; + iounmap(pndev->ioaddr); + goto failed_remap_csr; + } +#endif + + pci_set_drvdata(dev, pndev); + + return 0; + +failed_remap_csr: + pci_release_regions(dev); +failed_req_csr: + + return ret; +} + +static void nand_pci_remove(struct pci_dev *dev) +{ + struct mrst_nand_info *pndev = pci_get_drvdata(dev); + + nand_dbg_print(NAND_DBG_WARN, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + +#if CMD_DMA + free_irq(dev->irq, pndev); +#endif + iounmap(pndev->ioaddr); + pci_release_regions(dev); + pci_disable_device(dev); +} + +MODULE_DEVICE_TABLE(pci, nand_pci_ids); + +static struct pci_driver nand_pci_driver = { + .name = SPECTRA_NAND_NAME, + .id_table = nand_pci_ids, + .probe = nand_pci_probe, + .remove = nand_pci_remove, +}; + +int NAND_Flash_Init(void) +{ + int retval; + u32 int_mask; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + FlashReg = ioremap_nocache(GLOB_HWCTL_REG_BASE, + GLOB_HWCTL_REG_SIZE); + if (!FlashReg) { + printk(KERN_ERR "Spectra: ioremap_nocache failed!"); + return -ENOMEM; + } + nand_dbg_print(NAND_DBG_WARN, + "Spectra: Remapped reg base address: " + "0x%p, len: %d\n", + FlashReg, GLOB_HWCTL_REG_SIZE); + + FlashMem = ioremap_nocache(GLOB_HWCTL_MEM_BASE, + GLOB_HWCTL_MEM_SIZE); + if (!FlashMem) { + printk(KERN_ERR "Spectra: ioremap_nocache failed!"); + iounmap(FlashReg); + return -ENOMEM; + } + nand_dbg_print(NAND_DBG_WARN, + "Spectra: Remapped flash base address: " + "0x%p, len: %d\n", + (void *)FlashMem, GLOB_HWCTL_MEM_SIZE); + + nand_dbg_print(NAND_DBG_DEBUG, "Dump timing register values:" + "acc_clks: %d, re_2_we: %d, we_2_re: %d," + "addr_2_data: %d, rdwr_en_lo_cnt: %d, " + "rdwr_en_hi_cnt: %d, cs_setup_cnt: %d\n", + ioread32(FlashReg + ACC_CLKS), + ioread32(FlashReg + RE_2_WE), + ioread32(FlashReg + WE_2_RE), + ioread32(FlashReg + ADDR_2_DATA), + ioread32(FlashReg + RDWR_EN_LO_CNT), + ioread32(FlashReg + RDWR_EN_HI_CNT), + ioread32(FlashReg + CS_SETUP_CNT)); + + NAND_Flash_Reset(); + + iowrite32(0, FlashReg + GLOBAL_INT_ENABLE); + +#if CMD_DMA + info.pcmds_num = 0; + info.flash_bank = 0; + info.cdma_num = 0; + int_mask = (DMA_INTR__DESC_COMP_CHANNEL0 | + DMA_INTR__DESC_COMP_CHANNEL1 | + DMA_INTR__DESC_COMP_CHANNEL2 | + DMA_INTR__DESC_COMP_CHANNEL3 | + DMA_INTR__MEMCOPY_DESC_COMP); + iowrite32(int_mask, FlashReg + DMA_INTR_EN); + iowrite32(0xFFFF, FlashReg + DMA_INTR); + + int_mask = (INTR_STATUS0__ECC_ERR | + INTR_STATUS0__PROGRAM_FAIL | + INTR_STATUS0__ERASE_FAIL); +#else + int_mask = INTR_STATUS0__DMA_CMD_COMP | + INTR_STATUS0__ECC_TRANSACTION_DONE | + INTR_STATUS0__ECC_ERR | + INTR_STATUS0__PROGRAM_FAIL | + INTR_STATUS0__ERASE_FAIL; +#endif + iowrite32(int_mask, FlashReg + INTR_EN0); + iowrite32(int_mask, FlashReg + INTR_EN1); + iowrite32(int_mask, FlashReg + INTR_EN2); + iowrite32(int_mask, FlashReg + INTR_EN3); + + /* Clear all status bits */ + iowrite32(0xFFFF, FlashReg + INTR_STATUS0); + iowrite32(0xFFFF, FlashReg + INTR_STATUS1); + iowrite32(0xFFFF, FlashReg + INTR_STATUS2); + iowrite32(0xFFFF, FlashReg + INTR_STATUS3); + + iowrite32(0x0F, FlashReg + RB_PIN_ENABLED); + iowrite32(CHIP_EN_DONT_CARE__FLAG, FlashReg + CHIP_ENABLE_DONT_CARE); + + /* Should set value for these registers when init */ + iowrite32(0, FlashReg + TWO_ROW_ADDR_CYCLES); + iowrite32(1, FlashReg + ECC_ENABLE); + enable_ecc = 1; + + retval = pci_register_driver(&nand_pci_driver); + if (retval) + return -ENOMEM; + + return PASS; +} + +/* Free memory */ +int nand_release(void) +{ + pci_unregister_driver(&nand_pci_driver); + iounmap(FlashMem); + iounmap(FlashReg); + + return 0; +} + + + diff --git a/drivers/block/spectra/lld_nand.h b/drivers/block/spectra/lld_nand.h new file mode 100644 index 000000000000..c7d62c5151c7 --- /dev/null +++ b/drivers/block/spectra/lld_nand.h @@ -0,0 +1,131 @@ +/* + * NAND Flash Controller Device Driver + * Copyright (c) 2009, Intel Corporation and its suppliers. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef _LLD_NAND_ +#define _LLD_NAND_ + +#ifdef ELDORA +#include "defs.h" +#else +#include "flash.h" +#include "ffsport.h" +#endif + +#define MODE_00 0x00000000 +#define MODE_01 0x04000000 +#define MODE_10 0x08000000 +#define MODE_11 0x0C000000 + + +#define DATA_TRANSFER_MODE 0 +#define PROTECTION_PER_BLOCK 1 +#define LOAD_WAIT_COUNT 2 +#define PROGRAM_WAIT_COUNT 3 +#define ERASE_WAIT_COUNT 4 +#define INT_MONITOR_CYCLE_COUNT 5 +#define READ_BUSY_PIN_ENABLED 6 +#define MULTIPLANE_OPERATION_SUPPORT 7 +#define PRE_FETCH_MODE 8 +#define CE_DONT_CARE_SUPPORT 9 +#define COPYBACK_SUPPORT 10 +#define CACHE_WRITE_SUPPORT 11 +#define CACHE_READ_SUPPORT 12 +#define NUM_PAGES_IN_BLOCK 13 +#define ECC_ENABLE_SELECT 14 +#define WRITE_ENABLE_2_READ_ENABLE 15 +#define ADDRESS_2_DATA 16 +#define READ_ENABLE_2_WRITE_ENABLE 17 +#define TWO_ROW_ADDRESS_CYCLES 18 +#define MULTIPLANE_ADDRESS_RESTRICT 19 +#define ACC_CLOCKS 20 +#define READ_WRITE_ENABLE_LOW_COUNT 21 +#define READ_WRITE_ENABLE_HIGH_COUNT 22 + +#define ECC_SECTOR_SIZE 512 +#define LLD_MAX_FLASH_BANKS 4 + +struct mrst_nand_info { + struct pci_dev *dev; + u32 state; + u32 flash_bank; + u8 *read_data; + u8 *write_data; + u32 block; + u16 page; + u32 use_dma; + void __iomem *ioaddr; /* Mapped io reg base address */ + int ret; + u32 pcmds_num; + struct pending_cmd *pcmds; + int cdma_num; /* CDMA descriptor number in this chan */ + u8 *cdma_desc_buf; /* CDMA descriptor table */ + u8 *memcp_desc_buf; /* Memory copy descriptor table */ + dma_addr_t cdma_desc; /* Mapped CDMA descriptor table */ + dma_addr_t memcp_desc; /* Mapped memory copy descriptor table */ + struct completion complete; +}; + +int NAND_Flash_Init(void); +int nand_release(void); +u16 NAND_Flash_Reset(void); +u16 NAND_Read_Device_ID(void); +u16 NAND_Erase_Block(u32 flash_add); +u16 NAND_Write_Page_Main(u8 *write_data, u32 block, u16 page, + u16 page_count); +u16 NAND_Read_Page_Main(u8 *read_data, u32 block, u16 page, + u16 page_count); +u16 NAND_UnlockArrayAll(void); +u16 NAND_Write_Page_Main_Spare(u8 *write_data, u32 block, + u16 page, u16 page_count); +u16 NAND_Write_Page_Spare(u8 *read_data, u32 block, u16 page, + u16 page_count); +u16 NAND_Read_Page_Main_Spare(u8 *read_data, u32 block, u16 page, + u16 page_count); +u16 NAND_Read_Page_Spare(u8 *read_data, u32 block, u16 page, + u16 page_count); +void NAND_LLD_Enable_Disable_Interrupts(u16 INT_ENABLE); +u16 NAND_Get_Bad_Block(u32 block); +u16 NAND_Pipeline_Read_Ahead(u8 *read_data, u32 block, u16 page, + u16 page_count); +u16 NAND_Pipeline_Write_Ahead(u8 *write_data, u32 block, + u16 page, u16 page_count); +u16 NAND_Multiplane_Read(u8 *read_data, u32 block, u16 page, + u16 page_count); +u16 NAND_Multiplane_Write(u8 *write_data, u32 block, u16 page, + u16 page_count); +void NAND_ECC_Ctrl(int enable); +u16 NAND_Read_Page_Main_Polling(u8 *read_data, + u32 block, u16 page, u16 page_count); +u16 NAND_Pipeline_Read_Ahead_Polling(u8 *read_data, + u32 block, u16 page, u16 page_count); +void Conv_Spare_Data_Log2Phy_Format(u8 *data); +void Conv_Spare_Data_Phy2Log_Format(u8 *data); +void Conv_Main_Spare_Data_Log2Phy_Format(u8 *data, u16 page_count); +void Conv_Main_Spare_Data_Phy2Log_Format(u8 *data, u16 page_count); + +extern void __iomem *FlashReg; +extern void __iomem *FlashMem; + +extern int totalUsedBanks; +extern u32 GLOB_valid_banks[LLD_MAX_FLASH_BANKS]; + +#endif /*_LLD_NAND_*/ + + + diff --git a/drivers/block/spectra/nand_regs.h b/drivers/block/spectra/nand_regs.h new file mode 100644 index 000000000000..e192e4ae8c1e --- /dev/null +++ b/drivers/block/spectra/nand_regs.h @@ -0,0 +1,619 @@ +/* + * NAND Flash Controller Device Driver + * Copyright (c) 2009, Intel Corporation and its suppliers. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#define DEVICE_RESET 0x0 +#define DEVICE_RESET__BANK0 0x0001 +#define DEVICE_RESET__BANK1 0x0002 +#define DEVICE_RESET__BANK2 0x0004 +#define DEVICE_RESET__BANK3 0x0008 + +#define TRANSFER_SPARE_REG 0x10 +#define TRANSFER_SPARE_REG__FLAG 0x0001 + +#define LOAD_WAIT_CNT 0x20 +#define LOAD_WAIT_CNT__VALUE 0xffff + +#define PROGRAM_WAIT_CNT 0x30 +#define PROGRAM_WAIT_CNT__VALUE 0xffff + +#define ERASE_WAIT_CNT 0x40 +#define ERASE_WAIT_CNT__VALUE 0xffff + +#define INT_MON_CYCCNT 0x50 +#define INT_MON_CYCCNT__VALUE 0xffff + +#define RB_PIN_ENABLED 0x60 +#define RB_PIN_ENABLED__BANK0 0x0001 +#define RB_PIN_ENABLED__BANK1 0x0002 +#define RB_PIN_ENABLED__BANK2 0x0004 +#define RB_PIN_ENABLED__BANK3 0x0008 + +#define MULTIPLANE_OPERATION 0x70 +#define MULTIPLANE_OPERATION__FLAG 0x0001 + +#define MULTIPLANE_READ_ENABLE 0x80 +#define MULTIPLANE_READ_ENABLE__FLAG 0x0001 + +#define COPYBACK_DISABLE 0x90 +#define COPYBACK_DISABLE__FLAG 0x0001 + +#define CACHE_WRITE_ENABLE 0xa0 +#define CACHE_WRITE_ENABLE__FLAG 0x0001 + +#define CACHE_READ_ENABLE 0xb0 +#define CACHE_READ_ENABLE__FLAG 0x0001 + +#define PREFETCH_MODE 0xc0 +#define PREFETCH_MODE__PREFETCH_EN 0x0001 +#define PREFETCH_MODE__PREFETCH_BURST_LENGTH 0xfff0 + +#define CHIP_ENABLE_DONT_CARE 0xd0 +#define CHIP_EN_DONT_CARE__FLAG 0x01 + +#define ECC_ENABLE 0xe0 +#define ECC_ENABLE__FLAG 0x0001 + +#define GLOBAL_INT_ENABLE 0xf0 +#define GLOBAL_INT_EN_FLAG 0x01 + +#define WE_2_RE 0x100 +#define WE_2_RE__VALUE 0x003f + +#define ADDR_2_DATA 0x110 +#define ADDR_2_DATA__VALUE 0x003f + +#define RE_2_WE 0x120 +#define RE_2_WE__VALUE 0x003f + +#define ACC_CLKS 0x130 +#define ACC_CLKS__VALUE 0x000f + +#define NUMBER_OF_PLANES 0x140 +#define NUMBER_OF_PLANES__VALUE 0x0007 + +#define PAGES_PER_BLOCK 0x150 +#define PAGES_PER_BLOCK__VALUE 0xffff + +#define DEVICE_WIDTH 0x160 +#define DEVICE_WIDTH__VALUE 0x0003 + +#define DEVICE_MAIN_AREA_SIZE 0x170 +#define DEVICE_MAIN_AREA_SIZE__VALUE 0xffff + +#define DEVICE_SPARE_AREA_SIZE 0x180 +#define DEVICE_SPARE_AREA_SIZE__VALUE 0xffff + +#define TWO_ROW_ADDR_CYCLES 0x190 +#define TWO_ROW_ADDR_CYCLES__FLAG 0x0001 + +#define MULTIPLANE_ADDR_RESTRICT 0x1a0 +#define MULTIPLANE_ADDR_RESTRICT__FLAG 0x0001 + +#define ECC_CORRECTION 0x1b0 +#define ECC_CORRECTION__VALUE 0x001f + +#define READ_MODE 0x1c0 +#define READ_MODE__VALUE 0x000f + +#define WRITE_MODE 0x1d0 +#define WRITE_MODE__VALUE 0x000f + +#define COPYBACK_MODE 0x1e0 +#define COPYBACK_MODE__VALUE 0x000f + +#define RDWR_EN_LO_CNT 0x1f0 +#define RDWR_EN_LO_CNT__VALUE 0x001f + +#define RDWR_EN_HI_CNT 0x200 +#define RDWR_EN_HI_CNT__VALUE 0x001f + +#define MAX_RD_DELAY 0x210 +#define MAX_RD_DELAY__VALUE 0x000f + +#define CS_SETUP_CNT 0x220 +#define CS_SETUP_CNT__VALUE 0x001f + +#define SPARE_AREA_SKIP_BYTES 0x230 +#define SPARE_AREA_SKIP_BYTES__VALUE 0x003f + +#define SPARE_AREA_MARKER 0x240 +#define SPARE_AREA_MARKER__VALUE 0xffff + +#define DEVICES_CONNECTED 0x250 +#define DEVICES_CONNECTED__VALUE 0x0007 + +#define DIE_MASK 0x260 +#define DIE_MASK__VALUE 0x00ff + +#define FIRST_BLOCK_OF_NEXT_PLANE 0x270 +#define FIRST_BLOCK_OF_NEXT_PLANE__VALUE 0xffff + +#define WRITE_PROTECT 0x280 +#define WRITE_PROTECT__FLAG 0x0001 + +#define RE_2_RE 0x290 +#define RE_2_RE__VALUE 0x003f + +#define MANUFACTURER_ID 0x300 +#define MANUFACTURER_ID__VALUE 0x00ff + +#define DEVICE_ID 0x310 +#define DEVICE_ID__VALUE 0x00ff + +#define DEVICE_PARAM_0 0x320 +#define DEVICE_PARAM_0__VALUE 0x00ff + +#define DEVICE_PARAM_1 0x330 +#define DEVICE_PARAM_1__VALUE 0x00ff + +#define DEVICE_PARAM_2 0x340 +#define DEVICE_PARAM_2__VALUE 0x00ff + +#define LOGICAL_PAGE_DATA_SIZE 0x350 +#define LOGICAL_PAGE_DATA_SIZE__VALUE 0xffff + +#define LOGICAL_PAGE_SPARE_SIZE 0x360 +#define LOGICAL_PAGE_SPARE_SIZE__VALUE 0xffff + +#define REVISION 0x370 +#define REVISION__VALUE 0xffff + +#define ONFI_DEVICE_FEATURES 0x380 +#define ONFI_DEVICE_FEATURES__VALUE 0x003f + +#define ONFI_OPTIONAL_COMMANDS 0x390 +#define ONFI_OPTIONAL_COMMANDS__VALUE 0x003f + +#define ONFI_TIMING_MODE 0x3a0 +#define ONFI_TIMING_MODE__VALUE 0x003f + +#define ONFI_PGM_CACHE_TIMING_MODE 0x3b0 +#define ONFI_PGM_CACHE_TIMING_MODE__VALUE 0x003f + +#define ONFI_DEVICE_NO_OF_LUNS 0x3c0 +#define ONFI_DEVICE_NO_OF_LUNS__NO_OF_LUNS 0x00ff +#define ONFI_DEVICE_NO_OF_LUNS__ONFI_DEVICE 0x0100 + +#define ONFI_DEVICE_NO_OF_BLOCKS_PER_LUN_L 0x3d0 +#define ONFI_DEVICE_NO_OF_BLOCKS_PER_LUN_L__VALUE 0xffff + +#define ONFI_DEVICE_NO_OF_BLOCKS_PER_LUN_U 0x3e0 +#define ONFI_DEVICE_NO_OF_BLOCKS_PER_LUN_U__VALUE 0xffff + +#define FEATURES 0x3f0 +#define FEATURES__N_BANKS 0x0003 +#define FEATURES__ECC_MAX_ERR 0x003c +#define FEATURES__DMA 0x0040 +#define FEATURES__CMD_DMA 0x0080 +#define FEATURES__PARTITION 0x0100 +#define FEATURES__XDMA_SIDEBAND 0x0200 +#define FEATURES__GPREG 0x0400 +#define FEATURES__INDEX_ADDR 0x0800 + +#define TRANSFER_MODE 0x400 +#define TRANSFER_MODE__VALUE 0x0003 + +#define INTR_STATUS0 0x410 +#define INTR_STATUS0__ECC_TRANSACTION_DONE 0x0001 +#define INTR_STATUS0__ECC_ERR 0x0002 +#define INTR_STATUS0__DMA_CMD_COMP 0x0004 +#define INTR_STATUS0__TIME_OUT 0x0008 +#define INTR_STATUS0__PROGRAM_FAIL 0x0010 +#define INTR_STATUS0__ERASE_FAIL 0x0020 +#define INTR_STATUS0__LOAD_COMP 0x0040 +#define INTR_STATUS0__PROGRAM_COMP 0x0080 +#define INTR_STATUS0__ERASE_COMP 0x0100 +#define INTR_STATUS0__PIPE_CPYBCK_CMD_COMP 0x0200 +#define INTR_STATUS0__LOCKED_BLK 0x0400 +#define INTR_STATUS0__UNSUP_CMD 0x0800 +#define INTR_STATUS0__INT_ACT 0x1000 +#define INTR_STATUS0__RST_COMP 0x2000 +#define INTR_STATUS0__PIPE_CMD_ERR 0x4000 +#define INTR_STATUS0__PAGE_XFER_INC 0x8000 + +#define INTR_EN0 0x420 +#define INTR_EN0__ECC_TRANSACTION_DONE 0x0001 +#define INTR_EN0__ECC_ERR 0x0002 +#define INTR_EN0__DMA_CMD_COMP 0x0004 +#define INTR_EN0__TIME_OUT 0x0008 +#define INTR_EN0__PROGRAM_FAIL 0x0010 +#define INTR_EN0__ERASE_FAIL 0x0020 +#define INTR_EN0__LOAD_COMP 0x0040 +#define INTR_EN0__PROGRAM_COMP 0x0080 +#define INTR_EN0__ERASE_COMP 0x0100 +#define INTR_EN0__PIPE_CPYBCK_CMD_COMP 0x0200 +#define INTR_EN0__LOCKED_BLK 0x0400 +#define INTR_EN0__UNSUP_CMD 0x0800 +#define INTR_EN0__INT_ACT 0x1000 +#define INTR_EN0__RST_COMP 0x2000 +#define INTR_EN0__PIPE_CMD_ERR 0x4000 +#define INTR_EN0__PAGE_XFER_INC 0x8000 + +#define PAGE_CNT0 0x430 +#define PAGE_CNT0__VALUE 0x00ff + +#define ERR_PAGE_ADDR0 0x440 +#define ERR_PAGE_ADDR0__VALUE 0xffff + +#define ERR_BLOCK_ADDR0 0x450 +#define ERR_BLOCK_ADDR0__VALUE 0xffff + +#define INTR_STATUS1 0x460 +#define INTR_STATUS1__ECC_TRANSACTION_DONE 0x0001 +#define INTR_STATUS1__ECC_ERR 0x0002 +#define INTR_STATUS1__DMA_CMD_COMP 0x0004 +#define INTR_STATUS1__TIME_OUT 0x0008 +#define INTR_STATUS1__PROGRAM_FAIL 0x0010 +#define INTR_STATUS1__ERASE_FAIL 0x0020 +#define INTR_STATUS1__LOAD_COMP 0x0040 +#define INTR_STATUS1__PROGRAM_COMP 0x0080 +#define INTR_STATUS1__ERASE_COMP 0x0100 +#define INTR_STATUS1__PIPE_CPYBCK_CMD_COMP 0x0200 +#define INTR_STATUS1__LOCKED_BLK 0x0400 +#define INTR_STATUS1__UNSUP_CMD 0x0800 +#define INTR_STATUS1__INT_ACT 0x1000 +#define INTR_STATUS1__RST_COMP 0x2000 +#define INTR_STATUS1__PIPE_CMD_ERR 0x4000 +#define INTR_STATUS1__PAGE_XFER_INC 0x8000 + +#define INTR_EN1 0x470 +#define INTR_EN1__ECC_TRANSACTION_DONE 0x0001 +#define INTR_EN1__ECC_ERR 0x0002 +#define INTR_EN1__DMA_CMD_COMP 0x0004 +#define INTR_EN1__TIME_OUT 0x0008 +#define INTR_EN1__PROGRAM_FAIL 0x0010 +#define INTR_EN1__ERASE_FAIL 0x0020 +#define INTR_EN1__LOAD_COMP 0x0040 +#define INTR_EN1__PROGRAM_COMP 0x0080 +#define INTR_EN1__ERASE_COMP 0x0100 +#define INTR_EN1__PIPE_CPYBCK_CMD_COMP 0x0200 +#define INTR_EN1__LOCKED_BLK 0x0400 +#define INTR_EN1__UNSUP_CMD 0x0800 +#define INTR_EN1__INT_ACT 0x1000 +#define INTR_EN1__RST_COMP 0x2000 +#define INTR_EN1__PIPE_CMD_ERR 0x4000 +#define INTR_EN1__PAGE_XFER_INC 0x8000 + +#define PAGE_CNT1 0x480 +#define PAGE_CNT1__VALUE 0x00ff + +#define ERR_PAGE_ADDR1 0x490 +#define ERR_PAGE_ADDR1__VALUE 0xffff + +#define ERR_BLOCK_ADDR1 0x4a0 +#define ERR_BLOCK_ADDR1__VALUE 0xffff + +#define INTR_STATUS2 0x4b0 +#define INTR_STATUS2__ECC_TRANSACTION_DONE 0x0001 +#define INTR_STATUS2__ECC_ERR 0x0002 +#define INTR_STATUS2__DMA_CMD_COMP 0x0004 +#define INTR_STATUS2__TIME_OUT 0x0008 +#define INTR_STATUS2__PROGRAM_FAIL 0x0010 +#define INTR_STATUS2__ERASE_FAIL 0x0020 +#define INTR_STATUS2__LOAD_COMP 0x0040 +#define INTR_STATUS2__PROGRAM_COMP 0x0080 +#define INTR_STATUS2__ERASE_COMP 0x0100 +#define INTR_STATUS2__PIPE_CPYBCK_CMD_COMP 0x0200 +#define INTR_STATUS2__LOCKED_BLK 0x0400 +#define INTR_STATUS2__UNSUP_CMD 0x0800 +#define INTR_STATUS2__INT_ACT 0x1000 +#define INTR_STATUS2__RST_COMP 0x2000 +#define INTR_STATUS2__PIPE_CMD_ERR 0x4000 +#define INTR_STATUS2__PAGE_XFER_INC 0x8000 + +#define INTR_EN2 0x4c0 +#define INTR_EN2__ECC_TRANSACTION_DONE 0x0001 +#define INTR_EN2__ECC_ERR 0x0002 +#define INTR_EN2__DMA_CMD_COMP 0x0004 +#define INTR_EN2__TIME_OUT 0x0008 +#define INTR_EN2__PROGRAM_FAIL 0x0010 +#define INTR_EN2__ERASE_FAIL 0x0020 +#define INTR_EN2__LOAD_COMP 0x0040 +#define INTR_EN2__PROGRAM_COMP 0x0080 +#define INTR_EN2__ERASE_COMP 0x0100 +#define INTR_EN2__PIPE_CPYBCK_CMD_COMP 0x0200 +#define INTR_EN2__LOCKED_BLK 0x0400 +#define INTR_EN2__UNSUP_CMD 0x0800 +#define INTR_EN2__INT_ACT 0x1000 +#define INTR_EN2__RST_COMP 0x2000 +#define INTR_EN2__PIPE_CMD_ERR 0x4000 +#define INTR_EN2__PAGE_XFER_INC 0x8000 + +#define PAGE_CNT2 0x4d0 +#define PAGE_CNT2__VALUE 0x00ff + +#define ERR_PAGE_ADDR2 0x4e0 +#define ERR_PAGE_ADDR2__VALUE 0xffff + +#define ERR_BLOCK_ADDR2 0x4f0 +#define ERR_BLOCK_ADDR2__VALUE 0xffff + +#define INTR_STATUS3 0x500 +#define INTR_STATUS3__ECC_TRANSACTION_DONE 0x0001 +#define INTR_STATUS3__ECC_ERR 0x0002 +#define INTR_STATUS3__DMA_CMD_COMP 0x0004 +#define INTR_STATUS3__TIME_OUT 0x0008 +#define INTR_STATUS3__PROGRAM_FAIL 0x0010 +#define INTR_STATUS3__ERASE_FAIL 0x0020 +#define INTR_STATUS3__LOAD_COMP 0x0040 +#define INTR_STATUS3__PROGRAM_COMP 0x0080 +#define INTR_STATUS3__ERASE_COMP 0x0100 +#define INTR_STATUS3__PIPE_CPYBCK_CMD_COMP 0x0200 +#define INTR_STATUS3__LOCKED_BLK 0x0400 +#define INTR_STATUS3__UNSUP_CMD 0x0800 +#define INTR_STATUS3__INT_ACT 0x1000 +#define INTR_STATUS3__RST_COMP 0x2000 +#define INTR_STATUS3__PIPE_CMD_ERR 0x4000 +#define INTR_STATUS3__PAGE_XFER_INC 0x8000 + +#define INTR_EN3 0x510 +#define INTR_EN3__ECC_TRANSACTION_DONE 0x0001 +#define INTR_EN3__ECC_ERR 0x0002 +#define INTR_EN3__DMA_CMD_COMP 0x0004 +#define INTR_EN3__TIME_OUT 0x0008 +#define INTR_EN3__PROGRAM_FAIL 0x0010 +#define INTR_EN3__ERASE_FAIL 0x0020 +#define INTR_EN3__LOAD_COMP 0x0040 +#define INTR_EN3__PROGRAM_COMP 0x0080 +#define INTR_EN3__ERASE_COMP 0x0100 +#define INTR_EN3__PIPE_CPYBCK_CMD_COMP 0x0200 +#define INTR_EN3__LOCKED_BLK 0x0400 +#define INTR_EN3__UNSUP_CMD 0x0800 +#define INTR_EN3__INT_ACT 0x1000 +#define INTR_EN3__RST_COMP 0x2000 +#define INTR_EN3__PIPE_CMD_ERR 0x4000 +#define INTR_EN3__PAGE_XFER_INC 0x8000 + +#define PAGE_CNT3 0x520 +#define PAGE_CNT3__VALUE 0x00ff + +#define ERR_PAGE_ADDR3 0x530 +#define ERR_PAGE_ADDR3__VALUE 0xffff + +#define ERR_BLOCK_ADDR3 0x540 +#define ERR_BLOCK_ADDR3__VALUE 0xffff + +#define DATA_INTR 0x550 +#define DATA_INTR__WRITE_SPACE_AV 0x0001 +#define DATA_INTR__READ_DATA_AV 0x0002 + +#define DATA_INTR_EN 0x560 +#define DATA_INTR_EN__WRITE_SPACE_AV 0x0001 +#define DATA_INTR_EN__READ_DATA_AV 0x0002 + +#define GPREG_0 0x570 +#define GPREG_0__VALUE 0xffff + +#define GPREG_1 0x580 +#define GPREG_1__VALUE 0xffff + +#define GPREG_2 0x590 +#define GPREG_2__VALUE 0xffff + +#define GPREG_3 0x5a0 +#define GPREG_3__VALUE 0xffff + +#define ECC_THRESHOLD 0x600 +#define ECC_THRESHOLD__VALUE 0x03ff + +#define ECC_ERROR_BLOCK_ADDRESS 0x610 +#define ECC_ERROR_BLOCK_ADDRESS__VALUE 0xffff + +#define ECC_ERROR_PAGE_ADDRESS 0x620 +#define ECC_ERROR_PAGE_ADDRESS__VALUE 0x0fff +#define ECC_ERROR_PAGE_ADDRESS__BANK 0xf000 + +#define ECC_ERROR_ADDRESS 0x630 +#define ECC_ERROR_ADDRESS__OFFSET 0x0fff +#define ECC_ERROR_ADDRESS__SECTOR_NR 0xf000 + +#define ERR_CORRECTION_INFO 0x640 +#define ERR_CORRECTION_INFO__BYTEMASK 0x00ff +#define ERR_CORRECTION_INFO__DEVICE_NR 0x0f00 +#define ERR_CORRECTION_INFO__ERROR_TYPE 0x4000 +#define ERR_CORRECTION_INFO__LAST_ERR_INFO 0x8000 + +#define DMA_ENABLE 0x700 +#define DMA_ENABLE__FLAG 0x0001 + +#define IGNORE_ECC_DONE 0x710 +#define IGNORE_ECC_DONE__FLAG 0x0001 + +#define DMA_INTR 0x720 +#define DMA_INTR__TARGET_ERROR 0x0001 +#define DMA_INTR__DESC_COMP_CHANNEL0 0x0002 +#define DMA_INTR__DESC_COMP_CHANNEL1 0x0004 +#define DMA_INTR__DESC_COMP_CHANNEL2 0x0008 +#define DMA_INTR__DESC_COMP_CHANNEL3 0x0010 +#define DMA_INTR__MEMCOPY_DESC_COMP 0x0020 + +#define DMA_INTR_EN 0x730 +#define DMA_INTR_EN__TARGET_ERROR 0x0001 +#define DMA_INTR_EN__DESC_COMP_CHANNEL0 0x0002 +#define DMA_INTR_EN__DESC_COMP_CHANNEL1 0x0004 +#define DMA_INTR_EN__DESC_COMP_CHANNEL2 0x0008 +#define DMA_INTR_EN__DESC_COMP_CHANNEL3 0x0010 +#define DMA_INTR_EN__MEMCOPY_DESC_COMP 0x0020 + +#define TARGET_ERR_ADDR_LO 0x740 +#define TARGET_ERR_ADDR_LO__VALUE 0xffff + +#define TARGET_ERR_ADDR_HI 0x750 +#define TARGET_ERR_ADDR_HI__VALUE 0xffff + +#define CHNL_ACTIVE 0x760 +#define CHNL_ACTIVE__CHANNEL0 0x0001 +#define CHNL_ACTIVE__CHANNEL1 0x0002 +#define CHNL_ACTIVE__CHANNEL2 0x0004 +#define CHNL_ACTIVE__CHANNEL3 0x0008 + +#define ACTIVE_SRC_ID 0x800 +#define ACTIVE_SRC_ID__VALUE 0x00ff + +#define PTN_INTR 0x810 +#define PTN_INTR__CONFIG_ERROR 0x0001 +#define PTN_INTR__ACCESS_ERROR_BANK0 0x0002 +#define PTN_INTR__ACCESS_ERROR_BANK1 0x0004 +#define PTN_INTR__ACCESS_ERROR_BANK2 0x0008 +#define PTN_INTR__ACCESS_ERROR_BANK3 0x0010 +#define PTN_INTR__REG_ACCESS_ERROR 0x0020 + +#define PTN_INTR_EN 0x820 +#define PTN_INTR_EN__CONFIG_ERROR 0x0001 +#define PTN_INTR_EN__ACCESS_ERROR_BANK0 0x0002 +#define PTN_INTR_EN__ACCESS_ERROR_BANK1 0x0004 +#define PTN_INTR_EN__ACCESS_ERROR_BANK2 0x0008 +#define PTN_INTR_EN__ACCESS_ERROR_BANK3 0x0010 +#define PTN_INTR_EN__REG_ACCESS_ERROR 0x0020 + +#define PERM_SRC_ID_0 0x830 +#define PERM_SRC_ID_0__SRCID 0x00ff +#define PERM_SRC_ID_0__DIRECT_ACCESS_ACTIVE 0x0800 +#define PERM_SRC_ID_0__WRITE_ACTIVE 0x2000 +#define PERM_SRC_ID_0__READ_ACTIVE 0x4000 +#define PERM_SRC_ID_0__PARTITION_VALID 0x8000 + +#define MIN_BLK_ADDR_0 0x840 +#define MIN_BLK_ADDR_0__VALUE 0xffff + +#define MAX_BLK_ADDR_0 0x850 +#define MAX_BLK_ADDR_0__VALUE 0xffff + +#define MIN_MAX_BANK_0 0x860 +#define MIN_MAX_BANK_0__MIN_VALUE 0x0003 +#define MIN_MAX_BANK_0__MAX_VALUE 0x000c + +#define PERM_SRC_ID_1 0x870 +#define PERM_SRC_ID_1__SRCID 0x00ff +#define PERM_SRC_ID_1__DIRECT_ACCESS_ACTIVE 0x0800 +#define PERM_SRC_ID_1__WRITE_ACTIVE 0x2000 +#define PERM_SRC_ID_1__READ_ACTIVE 0x4000 +#define PERM_SRC_ID_1__PARTITION_VALID 0x8000 + +#define MIN_BLK_ADDR_1 0x880 +#define MIN_BLK_ADDR_1__VALUE 0xffff + +#define MAX_BLK_ADDR_1 0x890 +#define MAX_BLK_ADDR_1__VALUE 0xffff + +#define MIN_MAX_BANK_1 0x8a0 +#define MIN_MAX_BANK_1__MIN_VALUE 0x0003 +#define MIN_MAX_BANK_1__MAX_VALUE 0x000c + +#define PERM_SRC_ID_2 0x8b0 +#define PERM_SRC_ID_2__SRCID 0x00ff +#define PERM_SRC_ID_2__DIRECT_ACCESS_ACTIVE 0x0800 +#define PERM_SRC_ID_2__WRITE_ACTIVE 0x2000 +#define PERM_SRC_ID_2__READ_ACTIVE 0x4000 +#define PERM_SRC_ID_2__PARTITION_VALID 0x8000 + +#define MIN_BLK_ADDR_2 0x8c0 +#define MIN_BLK_ADDR_2__VALUE 0xffff + +#define MAX_BLK_ADDR_2 0x8d0 +#define MAX_BLK_ADDR_2__VALUE 0xffff + +#define MIN_MAX_BANK_2 0x8e0 +#define MIN_MAX_BANK_2__MIN_VALUE 0x0003 +#define MIN_MAX_BANK_2__MAX_VALUE 0x000c + +#define PERM_SRC_ID_3 0x8f0 +#define PERM_SRC_ID_3__SRCID 0x00ff +#define PERM_SRC_ID_3__DIRECT_ACCESS_ACTIVE 0x0800 +#define PERM_SRC_ID_3__WRITE_ACTIVE 0x2000 +#define PERM_SRC_ID_3__READ_ACTIVE 0x4000 +#define PERM_SRC_ID_3__PARTITION_VALID 0x8000 + +#define MIN_BLK_ADDR_3 0x900 +#define MIN_BLK_ADDR_3__VALUE 0xffff + +#define MAX_BLK_ADDR_3 0x910 +#define MAX_BLK_ADDR_3__VALUE 0xffff + +#define MIN_MAX_BANK_3 0x920 +#define MIN_MAX_BANK_3__MIN_VALUE 0x0003 +#define MIN_MAX_BANK_3__MAX_VALUE 0x000c + +#define PERM_SRC_ID_4 0x930 +#define PERM_SRC_ID_4__SRCID 0x00ff +#define PERM_SRC_ID_4__DIRECT_ACCESS_ACTIVE 0x0800 +#define PERM_SRC_ID_4__WRITE_ACTIVE 0x2000 +#define PERM_SRC_ID_4__READ_ACTIVE 0x4000 +#define PERM_SRC_ID_4__PARTITION_VALID 0x8000 + +#define MIN_BLK_ADDR_4 0x940 +#define MIN_BLK_ADDR_4__VALUE 0xffff + +#define MAX_BLK_ADDR_4 0x950 +#define MAX_BLK_ADDR_4__VALUE 0xffff + +#define MIN_MAX_BANK_4 0x960 +#define MIN_MAX_BANK_4__MIN_VALUE 0x0003 +#define MIN_MAX_BANK_4__MAX_VALUE 0x000c + +#define PERM_SRC_ID_5 0x970 +#define PERM_SRC_ID_5__SRCID 0x00ff +#define PERM_SRC_ID_5__DIRECT_ACCESS_ACTIVE 0x0800 +#define PERM_SRC_ID_5__WRITE_ACTIVE 0x2000 +#define PERM_SRC_ID_5__READ_ACTIVE 0x4000 +#define PERM_SRC_ID_5__PARTITION_VALID 0x8000 + +#define MIN_BLK_ADDR_5 0x980 +#define MIN_BLK_ADDR_5__VALUE 0xffff + +#define MAX_BLK_ADDR_5 0x990 +#define MAX_BLK_ADDR_5__VALUE 0xffff + +#define MIN_MAX_BANK_5 0x9a0 +#define MIN_MAX_BANK_5__MIN_VALUE 0x0003 +#define MIN_MAX_BANK_5__MAX_VALUE 0x000c + +#define PERM_SRC_ID_6 0x9b0 +#define PERM_SRC_ID_6__SRCID 0x00ff +#define PERM_SRC_ID_6__DIRECT_ACCESS_ACTIVE 0x0800 +#define PERM_SRC_ID_6__WRITE_ACTIVE 0x2000 +#define PERM_SRC_ID_6__READ_ACTIVE 0x4000 +#define PERM_SRC_ID_6__PARTITION_VALID 0x8000 + +#define MIN_BLK_ADDR_6 0x9c0 +#define MIN_BLK_ADDR_6__VALUE 0xffff + +#define MAX_BLK_ADDR_6 0x9d0 +#define MAX_BLK_ADDR_6__VALUE 0xffff + +#define MIN_MAX_BANK_6 0x9e0 +#define MIN_MAX_BANK_6__MIN_VALUE 0x0003 +#define MIN_MAX_BANK_6__MAX_VALUE 0x000c + +#define PERM_SRC_ID_7 0x9f0 +#define PERM_SRC_ID_7__SRCID 0x00ff +#define PERM_SRC_ID_7__DIRECT_ACCESS_ACTIVE 0x0800 +#define PERM_SRC_ID_7__WRITE_ACTIVE 0x2000 +#define PERM_SRC_ID_7__READ_ACTIVE 0x4000 +#define PERM_SRC_ID_7__PARTITION_VALID 0x8000 + +#define MIN_BLK_ADDR_7 0xa00 +#define MIN_BLK_ADDR_7__VALUE 0xffff + +#define MAX_BLK_ADDR_7 0xa10 +#define MAX_BLK_ADDR_7__VALUE 0xffff + +#define MIN_MAX_BANK_7 0xa20 +#define MIN_MAX_BANK_7__MIN_VALUE 0x0003 +#define MIN_MAX_BANK_7__MAX_VALUE 0x000c diff --git a/drivers/block/spectra/spectraswconfig.h b/drivers/block/spectra/spectraswconfig.h new file mode 100644 index 000000000000..b630f0651b31 --- /dev/null +++ b/drivers/block/spectra/spectraswconfig.h @@ -0,0 +1,81 @@ +/* + * NAND Flash Controller Device Driver + * Copyright (c) 2009, Intel Corporation and its suppliers. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef _SPECTRASWCONFIG_ +#define _SPECTRASWCONFIG_ + +/* NAND driver version */ +#define GLOB_VERSION "driver version 20100311" + + +/***** Common Parameters *****/ +#define RETRY_TIMES 3 + +#define READ_BADBLOCK_INFO 1 +#define READBACK_VERIFY 0 +#define AUTO_FORMAT_FLASH 0 + +/***** Cache Parameters *****/ +#define CACHE_ITEM_NUM 128 +#define BLK_NUM_FOR_L2_CACHE 16 + +/***** Block Table Parameters *****/ +#define BLOCK_TABLE_INDEX 0 + +/***** Wear Leveling Parameters *****/ +#define WEAR_LEVELING_GATE 0x10 +#define WEAR_LEVELING_BLOCK_NUM 10 + +#define DEBUG_BNDRY 0 + +/***** Product Feature Support *****/ +#define FLASH_EMU defined(CONFIG_MRST_NAND_EMU) +#define FLASH_NAND defined(CONFIG_MRST_NAND_HW) +#define CMD_DMA 0 + +#define SPECTRA_PARTITION_ID 0 + +/* Enable this macro if the number of flash blocks is larger than 16K. */ +#define SUPPORT_LARGE_BLOCKNUM 1 + +/**** Block Table and Reserved Block Parameters *****/ +#define SPECTRA_START_BLOCK 3 +//#define NUM_FREE_BLOCKS_GATE 30 +#define NUM_FREE_BLOCKS_GATE 60 + +/**** Hardware Parameters ****/ +#define GLOB_HWCTL_REG_BASE 0xFFA40000 +#define GLOB_HWCTL_REG_SIZE 4096 + +#define GLOB_HWCTL_MEM_BASE 0xFFA48000 +#define GLOB_HWCTL_MEM_SIZE 4096 + +/* KBV - Updated to LNW scratch register address */ +#define SCRATCH_REG_ADDR 0xFF108018 +#define SCRATCH_REG_SIZE 64 + +#define GLOB_HWCTL_DEFAULT_BLKS 2048 + +#define SUPPORT_15BITECC 1 +#define SUPPORT_8BITECC 1 + +#define ONFI_BLOOM_TIME 0 +#define MODE5_WORKAROUND 1 + +#endif /*_SPECTRASWCONFIG_*/ From 90d598285cd1d2cee38ad34dbb3b305816a986aa Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Tue, 6 Oct 2009 14:23:59 +0100 Subject: [PATCH 002/523] spectra: Make it build as a module ... by killing the gratuitous 'res_nand' early_param() and turning it into a module_param() called 'reserved_mb' instead. Signed-off-by: David Woodhouse --- drivers/block/spectra/ffsport.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/drivers/block/spectra/ffsport.c b/drivers/block/spectra/ffsport.c index 0b3d49d2f8a5..c53face1816c 100644 --- a/drivers/block/spectra/ffsport.c +++ b/drivers/block/spectra/ffsport.c @@ -126,7 +126,9 @@ u64 GLOB_u64_Remainder(u64 addr, u32 divisor_type) #define GLOB_SBD_IOCTL_WRITE_DATA (0x7709) #define GLOB_SBD_IOCTL_READ_DATA (0x770A) -static u32 reserved_mb_for_os_image = 0; +static int reserved_mb = 0; +module_param(reserved_mb, int, 0); +MODULE_PARM_DESC(reserved_mb, "Reserved space for OS image, in MiB (default 25 MiB)"); int nand_debug_level; module_param(nand_debug_level, int, 0644); @@ -262,7 +264,7 @@ static int get_res_blk_num_os(void) blk_size = IdentifyDeviceData.PageDataSize * IdentifyDeviceData.PagesPerBlock; - res_blks = (reserved_mb_for_os_image * 1024 * 1024) / blk_size; + res_blks = (reserved_mb * 1024 * 1024) / blk_size; if ((res_blks < 1) || (res_blks >= IdentifyDeviceData.wDataBlockNum)) res_blks = 1; /* Reserved 1 block for block table */ @@ -823,25 +825,5 @@ static void __exit GLOB_SBD_exit(void) GLOB_SBD_majornum); } -static int __init setup_reserve_space_for_os_image(char *cmdline) -{ - unsigned long value; - int error; - - printk(KERN_ALERT "Spectra - cmdline: %s\n", cmdline); - if (!cmdline) - return -EINVAL; - - error = strict_strtoul((const char *)cmdline, 10, &value); - if (error) - return -EINVAL; - - reserved_mb_for_os_image = value; - - return 0; -} - -early_param("res_nand", setup_reserve_space_for_os_image); - module_init(GLOB_SBD_init); module_exit(GLOB_SBD_exit); From 4087524f3924c64791fab469b731f4e7420797a2 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Tue, 6 Oct 2009 15:08:29 +0100 Subject: [PATCH 003/523] spectra: Clean up emulation vs. hardware backend support Only build the parts which are actually needed, and turn the DMA support (which is currently hard-coded off) into a config option (still forced off). Signed-off-by: David Woodhouse --- drivers/block/spectra/Kconfig | 6 ++++++ drivers/block/spectra/Makefile | 5 ++++- drivers/block/spectra/lld.c | 2 ++ drivers/block/spectra/spectraswconfig.h | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/block/spectra/Kconfig b/drivers/block/spectra/Kconfig index fbece109f6c6..dae951e96e6b 100644 --- a/drivers/block/spectra/Kconfig +++ b/drivers/block/spectra/Kconfig @@ -25,3 +25,9 @@ config MRST_NAND_EMU endchoice +config MRST_NAND_HW_DMA + bool + default n + depends on MRST_NAND_HW + help + Use DMA for native hardware interface. diff --git a/drivers/block/spectra/Makefile b/drivers/block/spectra/Makefile index 261891c23577..8f5e0179250f 100644 --- a/drivers/block/spectra/Makefile +++ b/drivers/block/spectra/Makefile @@ -3,5 +3,8 @@ # obj-$(CONFIG_MRST_NAND) += spectra.o -spectra-objs := ffsport.o flash.o lld.o lld_emu.o lld_nand.o lld_cdma.o +spectra-y := ffsport.o flash.o lld.o +spectra-$(CONFIG_MRST_NAND_HW) += lld_nand.o +spectra-$(CONFIG_MRST_NAND_HW_DMA) += lld_cdma.o +spectra-$(CONFIG_MRST_NAND_EMU) += lld_emu.o diff --git a/drivers/block/spectra/lld.c b/drivers/block/spectra/lld.c index 3f411af4405e..c9a311213aff 100644 --- a/drivers/block/spectra/lld.c +++ b/drivers/block/spectra/lld.c @@ -199,6 +199,7 @@ u16 GLOB_LLD_Get_Bad_Block(u32 block) return NAND_Get_Bad_Block(block); } +#if CMD_DMA u16 GLOB_LLD_Event_Status(void) { return CDMA_Event_Status(); @@ -251,6 +252,7 @@ u16 GLOB_LLD_Read_Page_Main_Spare_cdma(u8 *data, LLD_CMD_FLAG_MODE_CDMA); } +#endif /* CMD_DMA */ #endif /* FLASH_NAND */ /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ diff --git a/drivers/block/spectra/spectraswconfig.h b/drivers/block/spectra/spectraswconfig.h index b630f0651b31..1e6afd372fe4 100644 --- a/drivers/block/spectra/spectraswconfig.h +++ b/drivers/block/spectra/spectraswconfig.h @@ -47,7 +47,7 @@ /***** Product Feature Support *****/ #define FLASH_EMU defined(CONFIG_MRST_NAND_EMU) #define FLASH_NAND defined(CONFIG_MRST_NAND_HW) -#define CMD_DMA 0 +#define CMD_DMA defined(CONFIG_MRST_NAND_HW_DMA) #define SPECTRA_PARTITION_ID 0 From 44fa63fc230a3ab3b34c669cf07ae6c487087952 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 14 Oct 2009 23:07:01 +0100 Subject: [PATCH 004/523] spectra: Don't overwrite nand_debug_level. It's a module param Signed-off-by: David Woodhouse --- drivers/block/spectra/ffsport.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/block/spectra/ffsport.c b/drivers/block/spectra/ffsport.c index c53face1816c..3c3565d40545 100644 --- a/drivers/block/spectra/ffsport.c +++ b/drivers/block/spectra/ffsport.c @@ -729,8 +729,6 @@ static int GLOB_SBD_init(void) int i; /* Set debug output level (0~3) here. 3 is most verbose */ - nand_debug_level = 0; - printk(KERN_ALERT "Spectra: %s\n", GLOB_version); mutex_init(&spectra_lock); From b589aece500c16fdcfff74346efc0d4caf7ba968 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Wed, 14 Oct 2009 23:09:13 +0100 Subject: [PATCH 005/523] spectra: Add basic mtd support Signed-off-by: David Woodhouse --- drivers/block/spectra/Kconfig | 7 + drivers/block/spectra/Makefile | 1 + drivers/block/spectra/lld.c | 79 +++ drivers/block/spectra/lld_mtd.c | 684 ++++++++++++++++++++++++ drivers/block/spectra/lld_mtd.h | 51 ++ drivers/block/spectra/spectraswconfig.h | 1 + 6 files changed, 823 insertions(+) create mode 100644 drivers/block/spectra/lld_mtd.c create mode 100644 drivers/block/spectra/lld_mtd.h diff --git a/drivers/block/spectra/Kconfig b/drivers/block/spectra/Kconfig index dae951e96e6b..4bed96f68837 100644 --- a/drivers/block/spectra/Kconfig +++ b/drivers/block/spectra/Kconfig @@ -18,6 +18,13 @@ config MRST_NAND_HW Driver communicates with the actual hardware's register interface. in DMA mode. +config MRST_NAND_MTD + bool "Linux MTD mode" + depends on MTD + help + Driver communicates with the kernel MTD subsystem instead of its own + built-in hardware driver. + config MRST_NAND_EMU bool "RAM emulator testing" help diff --git a/drivers/block/spectra/Makefile b/drivers/block/spectra/Makefile index 8f5e0179250f..2a9490385339 100644 --- a/drivers/block/spectra/Makefile +++ b/drivers/block/spectra/Makefile @@ -7,4 +7,5 @@ spectra-y := ffsport.o flash.o lld.o spectra-$(CONFIG_MRST_NAND_HW) += lld_nand.o spectra-$(CONFIG_MRST_NAND_HW_DMA) += lld_cdma.o spectra-$(CONFIG_MRST_NAND_EMU) += lld_emu.o +spectra-$(CONFIG_MRST_NAND_MTD) += lld_mtd.o diff --git a/drivers/block/spectra/lld.c b/drivers/block/spectra/lld.c index c9a311213aff..ac25eea1a2aa 100644 --- a/drivers/block/spectra/lld.c +++ b/drivers/block/spectra/lld.c @@ -103,6 +103,85 @@ u16 GLOB_LLD_Get_Bad_Block(u32 block) #endif /* FLASH_EMU */ +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +#if FLASH_MTD /* vector all the LLD calls to the LLD_MTD code */ +#include "lld_mtd.h" +#include "lld_cdma.h" + +/* common functions: */ +u16 GLOB_LLD_Flash_Reset(void) +{ + return mtd_Flash_Reset(); +} + +u16 GLOB_LLD_Read_Device_ID(void) +{ + return mtd_Read_Device_ID(); +} + +int GLOB_LLD_Flash_Release(void) +{ + return mtd_Flash_Release(); +} + +u16 GLOB_LLD_Flash_Init(void) +{ + return mtd_Flash_Init(); +} + +u16 GLOB_LLD_Erase_Block(u32 block_add) +{ + return mtd_Erase_Block(block_add); +} + +u16 GLOB_LLD_Write_Page_Main(u8 *write_data, u32 block, u16 Page, + u16 PageCount) +{ + return mtd_Write_Page_Main(write_data, block, Page, PageCount); +} + +u16 GLOB_LLD_Read_Page_Main(u8 *read_data, u32 block, u16 Page, + u16 PageCount) +{ + return mtd_Read_Page_Main(read_data, block, Page, PageCount); +} + +u16 GLOB_LLD_Read_Page_Main_Polling(u8 *read_data, + u32 block, u16 page, u16 page_count) +{ + return mtd_Read_Page_Main(read_data, block, page, page_count); +} + +u16 GLOB_LLD_Write_Page_Main_Spare(u8 *write_data, u32 block, + u16 Page, u16 PageCount) +{ + return mtd_Write_Page_Main_Spare(write_data, block, Page, PageCount); +} + +u16 GLOB_LLD_Read_Page_Main_Spare(u8 *read_data, u32 block, + u16 Page, u16 PageCount) +{ + return mtd_Read_Page_Main_Spare(read_data, block, Page, PageCount); +} + +u16 GLOB_LLD_Write_Page_Spare(u8 *write_data, u32 block, u16 Page, + u16 PageCount) +{ + return mtd_Write_Page_Spare(write_data, block, Page, PageCount); +} + +u16 GLOB_LLD_Read_Page_Spare(u8 *read_data, u32 block, u16 Page, + u16 PageCount) +{ + return mtd_Read_Page_Spare(read_data, block, Page, PageCount); +} + +u16 GLOB_LLD_Get_Bad_Block(u32 block) +{ + return mtd_Get_Bad_Block(block); +} + +#endif /* FLASH_MTD */ /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ #if FLASH_NAND /* vector all the LLD calls to the NAND controller code */ diff --git a/drivers/block/spectra/lld_mtd.c b/drivers/block/spectra/lld_mtd.c new file mode 100644 index 000000000000..f5666a9792b5 --- /dev/null +++ b/drivers/block/spectra/lld_mtd.c @@ -0,0 +1,684 @@ +/* + * NAND Flash Controller Device Driver + * Copyright (c) 2009, Intel Corporation and its suppliers. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include +#include +#include +#include "flash.h" +#include "ffsdefs.h" +#include "lld_emu.h" +#include "lld.h" +#if CMD_DMA +#include "lld_cdma.h" +#endif + +#define GLOB_LLD_PAGES 64 +#define GLOB_LLD_PAGE_SIZE (512+16) +#define GLOB_LLD_PAGE_DATA_SIZE 512 +#define GLOB_LLD_BLOCKS 2048 + +#if CMD_DMA +#include "lld_cdma.h" +u32 totalUsedBanks; +u32 valid_banks[MAX_CHANS]; +#endif + +static struct mtd_info *spectra_mtd; +static int mtddev = -1; +module_param(mtddev, int, 0); + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: mtd_Flash_Init +* Inputs: none +* Outputs: PASS=0 (notice 0=ok here) +* Description: Creates & initializes the flash RAM array. +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 mtd_Flash_Init(void) +{ + if (mtddev == -1) { + printk(KERN_ERR "No MTD device specified. Give mtddev parameter\n"); + return FAIL; + } + + spectra_mtd = get_mtd_device(NULL, mtddev); + if (!spectra_mtd) { + printk(KERN_ERR "Failed to obtain MTD device #%d\n", mtddev); + return FAIL; + } + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: mtd_Flash_Release +* Inputs: none +* Outputs: PASS=0 (notice 0=ok here) +* Description: Releases the flash. +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +int mtd_Flash_Release(void) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + if (!spectra_mtd) + return PASS; + + put_mtd_device(spectra_mtd); + spectra_mtd = NULL; + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: mtd_Read_Device_ID +* Inputs: none +* Outputs: PASS=1 FAIL=0 +* Description: Reads the info from the controller registers. +* Sets up DeviceInfo structure with device parameters +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ + +u16 mtd_Read_Device_ID(void) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (!spectra_mtd) + return FAIL; + + DeviceInfo.wDeviceMaker = 0; + DeviceInfo.wDeviceType = 8; + DeviceInfo.wSpectraStartBlock = SPECTRA_START_BLOCK; + DeviceInfo.wTotalBlocks = spectra_mtd->size / spectra_mtd->erasesize; + DeviceInfo.wSpectraEndBlock = DeviceInfo.wTotalBlocks - 1; + DeviceInfo.wPagesPerBlock = spectra_mtd->erasesize / spectra_mtd->writesize; + DeviceInfo.wPageSize = spectra_mtd->writesize + spectra_mtd->oobsize; + DeviceInfo.wPageDataSize = spectra_mtd->writesize; + DeviceInfo.wPageSpareSize = spectra_mtd->oobsize; + DeviceInfo.wBlockSize = DeviceInfo.wPageSize * DeviceInfo.wPagesPerBlock; + DeviceInfo.wBlockDataSize = DeviceInfo.wPageDataSize * DeviceInfo.wPagesPerBlock; + DeviceInfo.wDataBlockNum = (u32) (DeviceInfo.wSpectraEndBlock - + DeviceInfo.wSpectraStartBlock + + 1); + DeviceInfo.MLCDevice = 0;//spectra_mtd->celltype & NAND_CI_CELLTYPE_MSK; + DeviceInfo.nBitsInPageNumber = + (u8)GLOB_Calc_Used_Bits(DeviceInfo.wPagesPerBlock); + DeviceInfo.nBitsInPageDataSize = + (u8)GLOB_Calc_Used_Bits(DeviceInfo.wPageDataSize); + DeviceInfo.nBitsInBlockDataSize = + (u8)GLOB_Calc_Used_Bits(DeviceInfo.wBlockDataSize); + +#if CMD_DMA + totalUsedBanks = 4; + valid_banks[0] = 1; + valid_banks[1] = 1; + valid_banks[2] = 1; + valid_banks[3] = 1; +#endif + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: mtd_Flash_Reset +* Inputs: none +* Outputs: PASS=0 (notice 0=ok here) +* Description: Reset the flash +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 mtd_Flash_Reset(void) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + return PASS; +} + +void erase_callback(struct erase_info *e) +{ + complete((void *)e->priv); +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: mtd_Erase_Block +* Inputs: Address +* Outputs: PASS=0 (notice 0=ok here) +* Description: Erase a block +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 mtd_Erase_Block(u32 block_add) +{ + struct erase_info erase; + DECLARE_COMPLETION_ONSTACK(comp); + int ret; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (block_add >= DeviceInfo.wTotalBlocks) { + printk(KERN_ERR "mtd_Erase_Block error! " + "Too big block address: %d\n", block_add); + return FAIL; + } + + nand_dbg_print(NAND_DBG_DEBUG, "Erasing block %d\n", + (int)block_add); + + erase.mtd = spectra_mtd; + erase.callback = erase_callback; + erase.addr = block_add * spectra_mtd->erasesize; + erase.len = spectra_mtd->erasesize; + erase.priv = (unsigned long)∁ + + ret = spectra_mtd->erase(spectra_mtd, &erase); + if (!ret) { + wait_for_completion(&comp); + if (erase.state != MTD_ERASE_DONE) + ret = -EIO; + } + if (ret) { + printk(KERN_WARNING "mtd_Erase_Block error! " + "erase of region [0x%llx, 0x%llx] failed\n", + erase.addr, erase.len); + return FAIL; + } + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: mtd_Write_Page_Main +* Inputs: Write buffer address pointer +* Block number +* Page number +* Number of pages to process +* Outputs: PASS=0 (notice 0=ok here) +* Description: Write the data in the buffer to main area of flash +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 mtd_Write_Page_Main(u8 *write_data, u32 Block, + u16 Page, u16 PageCount) +{ + size_t retlen; + int ret = 0; + + if (Block >= DeviceInfo.wTotalBlocks) + return FAIL; + + if (Page + PageCount > DeviceInfo.wPagesPerBlock) + return FAIL; + + nand_dbg_print(NAND_DBG_DEBUG, "mtd_Write_Page_Main: " + "lba %u Page %u PageCount %u\n", + (unsigned int)Block, + (unsigned int)Page, (unsigned int)PageCount); + + + while (PageCount) { + ret = spectra_mtd->write(spectra_mtd, + (Block * spectra_mtd->erasesize) + (Page * spectra_mtd->writesize), + DeviceInfo.wPageDataSize, &retlen, write_data); + if (ret) { + printk(KERN_ERR "%s failed %d\n", __func__, ret); + return FAIL; + } + write_data += DeviceInfo.wPageDataSize; + Page++; + PageCount--; + } + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: mtd_Read_Page_Main +* Inputs: Read buffer address pointer +* Block number +* Page number +* Number of pages to process +* Outputs: PASS=0 (notice 0=ok here) +* Description: Read the data from the flash main area to the buffer +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 mtd_Read_Page_Main(u8 *read_data, u32 Block, + u16 Page, u16 PageCount) +{ + size_t retlen; + int ret = 0; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (Block >= DeviceInfo.wTotalBlocks) + return FAIL; + + if (Page + PageCount > DeviceInfo.wPagesPerBlock) + return FAIL; + + nand_dbg_print(NAND_DBG_DEBUG, "mtd_Read_Page_Main: " + "lba %u Page %u PageCount %u\n", + (unsigned int)Block, + (unsigned int)Page, (unsigned int)PageCount); + + + while (PageCount) { + ret = spectra_mtd->read(spectra_mtd, + (Block * spectra_mtd->erasesize) + (Page * spectra_mtd->writesize), + DeviceInfo.wPageDataSize, &retlen, read_data); + if (ret) { + printk(KERN_ERR "%s failed %d\n", __func__, ret); + return FAIL; + } + read_data += DeviceInfo.wPageDataSize; + Page++; + PageCount--; + } + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + return PASS; +} + +#ifndef ELDORA +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: mtd_Read_Page_Main_Spare +* Inputs: Write Buffer +* Address +* Buffer size +* Outputs: PASS=0 (notice 0=ok here) +* Description: Read from flash main+spare area +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 mtd_Read_Page_Main_Spare(u8 *read_data, u32 Block, + u16 Page, u16 PageCount) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (Block >= DeviceInfo.wTotalBlocks) { + printk(KERN_ERR "Read Page Main+Spare " + "Error: Block Address too big\n"); + return FAIL; + } + + if (Page + PageCount > DeviceInfo.wPagesPerBlock) { + printk(KERN_ERR "Read Page Main+Spare " + "Error: Page number %d+%d too big in block %d\n", + Page, PageCount, Block); + return FAIL; + } + + nand_dbg_print(NAND_DBG_DEBUG, "Read Page Main + Spare - " + "No. of pages %u block %u start page %u\n", + (unsigned int)PageCount, + (unsigned int)Block, (unsigned int)Page); + + + while (PageCount) { + struct mtd_oob_ops ops; + int ret; + + ops.mode = MTD_OOB_AUTO; + ops.datbuf = read_data; + ops.len = DeviceInfo.wPageDataSize; + ops.oobbuf = read_data + DeviceInfo.wPageDataSize + BTSIG_OFFSET; + ops.ooblen = BTSIG_BYTES; + ops.ooboffs = 0; + + ret = spectra_mtd->read_oob(spectra_mtd, + (Block * spectra_mtd->erasesize) + (Page * spectra_mtd->writesize), + &ops); + if (ret) { + printk(KERN_ERR "%s failed %d\n", __func__, ret); + return FAIL; + } + read_data += DeviceInfo.wPageSize; + Page++; + PageCount--; + } + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: mtd_Write_Page_Main_Spare +* Inputs: Write buffer +* address +* buffer length +* Outputs: PASS=0 (notice 0=ok here) +* Description: Write the buffer to main+spare area of flash +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 mtd_Write_Page_Main_Spare(u8 *write_data, u32 Block, + u16 Page, u16 page_count) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (Block >= DeviceInfo.wTotalBlocks) { + printk(KERN_ERR "Write Page Main + Spare " + "Error: Block Address too big\n"); + return FAIL; + } + + if (Page + page_count > DeviceInfo.wPagesPerBlock) { + printk(KERN_ERR "Write Page Main + Spare " + "Error: Page number %d+%d too big in block %d\n", + Page, page_count, Block); + WARN_ON(1); + return FAIL; + } + + nand_dbg_print(NAND_DBG_DEBUG, "Write Page Main+Spare - " + "No. of pages %u block %u start page %u\n", + (unsigned int)page_count, + (unsigned int)Block, (unsigned int)Page); + + while (page_count) { + struct mtd_oob_ops ops; + int ret; + + ops.mode = MTD_OOB_AUTO; + ops.datbuf = write_data; + ops.len = DeviceInfo.wPageDataSize; + ops.oobbuf = write_data + DeviceInfo.wPageDataSize + BTSIG_OFFSET; + ops.ooblen = BTSIG_BYTES; + ops.ooboffs = 0; + + ret = spectra_mtd->write_oob(spectra_mtd, + (Block * spectra_mtd->erasesize) + (Page * spectra_mtd->writesize), + &ops); + if (ret) { + printk(KERN_ERR "%s failed %d\n", __func__, ret); + return FAIL; + } + write_data += DeviceInfo.wPageSize; + Page++; + page_count--; + } + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: mtd_Write_Page_Spare +* Inputs: Write buffer +* Address +* buffer size +* Outputs: PASS=0 (notice 0=ok here) +* Description: Write the buffer in the spare area +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 mtd_Write_Page_Spare(u8 *write_data, u32 Block, + u16 Page, u16 PageCount) +{ + WARN_ON(1); + return FAIL; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: mtd_Read_Page_Spare +* Inputs: Write Buffer +* Address +* Buffer size +* Outputs: PASS=0 (notice 0=ok here) +* Description: Read data from the spare area +* +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 mtd_Read_Page_Spare(u8 *read_data, u32 Block, + u16 Page, u16 PageCount) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + if (Block >= DeviceInfo.wTotalBlocks) { + printk(KERN_ERR "Read Page Spare " + "Error: Block Address too big\n"); + return FAIL; + } + + if (Page + PageCount > DeviceInfo.wPagesPerBlock) { + printk(KERN_ERR "Read Page Spare " + "Error: Page number too big\n"); + return FAIL; + } + + nand_dbg_print(NAND_DBG_DEBUG, "Read Page Spare- " + "block %u page %u (%u pages)\n", + (unsigned int)Block, (unsigned int)Page, PageCount); + + while (PageCount) { + struct mtd_oob_ops ops; + int ret; + + ops.mode = MTD_OOB_AUTO; + ops.datbuf = NULL; + ops.len = 0; + ops.oobbuf = read_data; + ops.ooblen = BTSIG_BYTES; + ops.ooboffs = 0; + + ret = spectra_mtd->read_oob(spectra_mtd, + (Block * spectra_mtd->erasesize) + (Page * spectra_mtd->writesize), + &ops); + if (ret) { + printk(KERN_ERR "%s failed %d\n", __func__, ret); + return FAIL; + } + + read_data += DeviceInfo.wPageSize; + Page++; + PageCount--; + } + + return PASS; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: mtd_Enable_Disable_Interrupts +* Inputs: enable or disable +* Outputs: none +* Description: NOP +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +void mtd_Enable_Disable_Interrupts(u16 INT_ENABLE) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); +} + +u16 mtd_Get_Bad_Block(u32 block) +{ + return 0; +} + +#if CMD_DMA +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Support for CDMA functions +************************************ +* mtd_CDMA_Flash_Init +* CDMA_process_data command (use LLD_CDMA) +* CDMA_MemCopy_CMD (use LLD_CDMA) +* mtd_CDMA_execute all commands +* mtd_CDMA_Event_Status +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 mtd_CDMA_Flash_Init(void) +{ + u16 i; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + for (i = 0; i < MAX_DESCS + MAX_CHANS; i++) { + PendingCMD[i].CMD = 0; + PendingCMD[i].Tag = 0; + PendingCMD[i].DataAddr = 0; + PendingCMD[i].Block = 0; + PendingCMD[i].Page = 0; + PendingCMD[i].PageCount = 0; + PendingCMD[i].DataDestAddr = 0; + PendingCMD[i].DataSrcAddr = 0; + PendingCMD[i].MemCopyByteCnt = 0; + PendingCMD[i].ChanSync[0] = 0; + PendingCMD[i].ChanSync[1] = 0; + PendingCMD[i].ChanSync[2] = 0; + PendingCMD[i].ChanSync[3] = 0; + PendingCMD[i].ChanSync[4] = 0; + PendingCMD[i].Status = 3; + } + + return PASS; +} + +static void mtd_isr(int irq, void *dev_id) +{ + /* TODO: ... */ +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: CDMA_Execute_CMDs +* Inputs: tag_count: the number of pending cmds to do +* Outputs: PASS/FAIL +* Description: execute each command in the pending CMD array +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 mtd_CDMA_Execute_CMDs(u16 tag_count) +{ + u16 i, j; + u8 CMD; /* cmd parameter */ + u8 *data; + u32 block; + u16 page; + u16 count; + u16 status = PASS; + + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + nand_dbg_print(NAND_DBG_TRACE, "At start of Execute CMDs: " + "Tag Count %u\n", tag_count); + + for (i = 0; i < totalUsedBanks; i++) { + PendingCMD[i].CMD = DUMMY_CMD; + PendingCMD[i].Tag = 0xFF; + PendingCMD[i].Block = + (DeviceInfo.wTotalBlocks / totalUsedBanks) * i; + + for (j = 0; j <= MAX_CHANS; j++) + PendingCMD[i].ChanSync[j] = 0; + } + + CDMA_Execute_CMDs(tag_count); + +#ifdef VERBOSE + print_pending_cmds(tag_count); +#endif +#if DEBUG_SYNC + } + debug_sync_cnt++; +#endif + + for (i = MAX_CHANS; + i < tag_count + MAX_CHANS; i++) { + CMD = PendingCMD[i].CMD; + data = PendingCMD[i].DataAddr; + block = PendingCMD[i].Block; + page = PendingCMD[i].Page; + count = PendingCMD[i].PageCount; + + switch (CMD) { + case ERASE_CMD: + mtd_Erase_Block(block); + PendingCMD[i].Status = PASS; + break; + case WRITE_MAIN_CMD: + mtd_Write_Page_Main(data, block, page, count); + PendingCMD[i].Status = PASS; + break; + case WRITE_MAIN_SPARE_CMD: + mtd_Write_Page_Main_Spare(data, block, page, count); + PendingCMD[i].Status = PASS; + break; + case READ_MAIN_CMD: + mtd_Read_Page_Main(data, block, page, count); + PendingCMD[i].Status = PASS; + break; + case MEMCOPY_CMD: + memcpy(PendingCMD[i].DataDestAddr, + PendingCMD[i].DataSrcAddr, + PendingCMD[i].MemCopyByteCnt); + case DUMMY_CMD: + PendingCMD[i].Status = PASS; + break; + default: + PendingCMD[i].Status = FAIL; + break; + } + } + + /* + * Temperory adding code to reset PendingCMD array for basic testing. + * It should be done at the end of event status function. + */ + for (i = tag_count + MAX_CHANS; i < MAX_DESCS; i++) { + PendingCMD[i].CMD = 0; + PendingCMD[i].Tag = 0; + PendingCMD[i].DataAddr = 0; + PendingCMD[i].Block = 0; + PendingCMD[i].Page = 0; + PendingCMD[i].PageCount = 0; + PendingCMD[i].DataDestAddr = 0; + PendingCMD[i].DataSrcAddr = 0; + PendingCMD[i].MemCopyByteCnt = 0; + PendingCMD[i].ChanSync[0] = 0; + PendingCMD[i].ChanSync[1] = 0; + PendingCMD[i].ChanSync[2] = 0; + PendingCMD[i].ChanSync[3] = 0; + PendingCMD[i].ChanSync[4] = 0; + PendingCMD[i].Status = CMD_NOT_DONE; + } + + nand_dbg_print(NAND_DBG_TRACE, "At end of Execute CMDs.\n"); + + mtd_isr(0, 0); /* This is a null isr now. Need fill it in future */ + + return status; +} + +/*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& +* Function: mtd_Event_Status +* Inputs: none +* Outputs: Event_Status code +* Description: This function can also be used to force errors +*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/ +u16 mtd_CDMA_Event_Status(void) +{ + nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", + __FILE__, __LINE__, __func__); + + return EVENT_PASS; +} + +#endif /* CMD_DMA */ +#endif /* !ELDORA */ diff --git a/drivers/block/spectra/lld_mtd.h b/drivers/block/spectra/lld_mtd.h new file mode 100644 index 000000000000..4e81ee87b53d --- /dev/null +++ b/drivers/block/spectra/lld_mtd.h @@ -0,0 +1,51 @@ +/* + * NAND Flash Controller Device Driver + * Copyright (c) 2009, Intel Corporation and its suppliers. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef _LLD_MTD_ +#define _LLD_MTD_ + +#include "ffsport.h" +#include "ffsdefs.h" + +/* prototypes: MTD API functions */ +extern u16 mtd_Flash_Reset(void); +extern u16 mtd_Flash_Init(void); +extern int mtd_Flash_Release(void); +extern u16 mtd_Read_Device_ID(void); +extern u16 mtd_Erase_Block(u32 block_addr); +extern u16 mtd_Write_Page_Main(u8 *write_data, u32 Block, + u16 Page, u16 PageCount); +extern u16 mtd_Read_Page_Main(u8 *read_data, u32 Block, u16 Page, + u16 PageCount); +extern u16 mtd_Event_Status(void); +extern void mtd_Enable_Disable_Interrupts(u16 INT_ENABLE); +extern u16 mtd_Write_Page_Main_Spare(u8 *write_data, u32 Block, + u16 Page, u16 PageCount); +extern u16 mtd_Write_Page_Spare(u8 *write_data, u32 Block, + u16 Page, u16 PageCount); +extern u16 mtd_Read_Page_Main_Spare(u8 *read_data, u32 Block, + u16 Page, u16 PageCount); +extern u16 mtd_Read_Page_Spare(u8 *read_data, u32 Block, u16 Page, + u16 PageCount); +extern u16 mtd_Get_Bad_Block(u32 block); + +u16 mtd_CDMA_Flash_Init(void); +u16 mtd_CDMA_Execute_CMDs(u16 tag_count); +u16 mtd_CDMA_Event_Status(void); +#endif /*_LLD_MTD_*/ diff --git a/drivers/block/spectra/spectraswconfig.h b/drivers/block/spectra/spectraswconfig.h index 1e6afd372fe4..557c091953d7 100644 --- a/drivers/block/spectra/spectraswconfig.h +++ b/drivers/block/spectra/spectraswconfig.h @@ -47,6 +47,7 @@ /***** Product Feature Support *****/ #define FLASH_EMU defined(CONFIG_MRST_NAND_EMU) #define FLASH_NAND defined(CONFIG_MRST_NAND_HW) +#define FLASH_MTD defined(CONFIG_MRST_NAND_MTD) #define CMD_DMA defined(CONFIG_MRST_NAND_HW_DMA) #define SPECTRA_PARTITION_ID 0 From 0dba333c9568b35c9278c98be6d7861a7a709ca9 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Wed, 2 Jun 2010 15:08:37 +0200 Subject: [PATCH 006/523] block/spectra: rename nand_release() so it does not clash with nand_release() in mtd Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: David Woodhouse --- drivers/block/spectra/lld.c | 2 +- drivers/block/spectra/lld_nand.c | 2 +- drivers/block/spectra/lld_nand.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/block/spectra/lld.c b/drivers/block/spectra/lld.c index ac25eea1a2aa..5c3b9762dc3e 100644 --- a/drivers/block/spectra/lld.c +++ b/drivers/block/spectra/lld.c @@ -218,7 +218,7 @@ u16 GLOB_LLD_Flash_Init(void) int GLOB_LLD_Flash_Release(void) { - return nand_release(); + return nand_release_spectra(); } u16 GLOB_LLD_Erase_Block(u32 block_add) diff --git a/drivers/block/spectra/lld_nand.c b/drivers/block/spectra/lld_nand.c index 8c279b8a6a67..13c3ad2db394 100644 --- a/drivers/block/spectra/lld_nand.c +++ b/drivers/block/spectra/lld_nand.c @@ -2588,7 +2588,7 @@ int NAND_Flash_Init(void) } /* Free memory */ -int nand_release(void) +int nand_release_spectra(void) { pci_unregister_driver(&nand_pci_driver); iounmap(FlashMem); diff --git a/drivers/block/spectra/lld_nand.h b/drivers/block/spectra/lld_nand.h index c7d62c5151c7..d08388287da8 100644 --- a/drivers/block/spectra/lld_nand.h +++ b/drivers/block/spectra/lld_nand.h @@ -82,7 +82,7 @@ struct mrst_nand_info { }; int NAND_Flash_Init(void); -int nand_release(void); +int nand_release_spectra(void); u16 NAND_Flash_Reset(void); u16 NAND_Read_Device_ID(void); u16 NAND_Erase_Block(u32 flash_add); From f39b56f6d067786b6c37c9a20776d1c0eb405a49 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Wed, 2 Jun 2010 15:08:36 +0200 Subject: [PATCH 007/523] block/spectra: use do_div() for 64bit divs it does not work on 32bit that way Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: David Woodhouse --- drivers/block/spectra/lld_mtd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/block/spectra/lld_mtd.c b/drivers/block/spectra/lld_mtd.c index f5666a9792b5..0de05b1e75f7 100644 --- a/drivers/block/spectra/lld_mtd.c +++ b/drivers/block/spectra/lld_mtd.c @@ -99,6 +99,7 @@ int mtd_Flash_Release(void) u16 mtd_Read_Device_ID(void) { + uint64_t tmp; nand_dbg_print(NAND_DBG_TRACE, "%s, Line %d, Function: %s\n", __FILE__, __LINE__, __func__); @@ -108,7 +109,9 @@ u16 mtd_Read_Device_ID(void) DeviceInfo.wDeviceMaker = 0; DeviceInfo.wDeviceType = 8; DeviceInfo.wSpectraStartBlock = SPECTRA_START_BLOCK; - DeviceInfo.wTotalBlocks = spectra_mtd->size / spectra_mtd->erasesize; + tmp = spectra_mtd->size; + do_div(tmp, spectra_mtd->erasesize); + DeviceInfo.wTotalBlocks = tmp; DeviceInfo.wSpectraEndBlock = DeviceInfo.wTotalBlocks - 1; DeviceInfo.wPagesPerBlock = spectra_mtd->erasesize / spectra_mtd->writesize; DeviceInfo.wPageSize = spectra_mtd->writesize + spectra_mtd->oobsize; From 8ae4f63623c6a6d164e28d6ac327cf8287b0a24d Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Tue, 8 Jun 2010 18:08:32 +0100 Subject: [PATCH 008/523] spectra: Move to drivers/staging It'll take some work before this is really shippable. Signed-off-by: David Woodhouse --- drivers/block/Kconfig | 2 -- drivers/block/Makefile | 2 -- drivers/staging/Kconfig | 2 ++ drivers/staging/Makefile | 1 + drivers/{block => staging}/spectra/Kconfig | 0 drivers/{block => staging}/spectra/Makefile | 0 drivers/{block => staging}/spectra/README | 0 drivers/{block => staging}/spectra/ffsdefs.h | 0 drivers/{block => staging}/spectra/ffsport.c | 0 drivers/{block => staging}/spectra/ffsport.h | 0 drivers/{block => staging}/spectra/flash.c | 0 drivers/{block => staging}/spectra/flash.h | 0 drivers/{block => staging}/spectra/lld.c | 0 drivers/{block => staging}/spectra/lld.h | 0 drivers/{block => staging}/spectra/lld_cdma.c | 0 drivers/{block => staging}/spectra/lld_cdma.h | 0 drivers/{block => staging}/spectra/lld_emu.c | 0 drivers/{block => staging}/spectra/lld_emu.h | 0 drivers/{block => staging}/spectra/lld_mtd.c | 0 drivers/{block => staging}/spectra/lld_mtd.h | 0 drivers/{block => staging}/spectra/lld_nand.c | 0 drivers/{block => staging}/spectra/lld_nand.h | 0 drivers/{block => staging}/spectra/nand_regs.h | 0 drivers/{block => staging}/spectra/spectraswconfig.h | 0 24 files changed, 3 insertions(+), 4 deletions(-) rename drivers/{block => staging}/spectra/Kconfig (100%) rename drivers/{block => staging}/spectra/Makefile (100%) rename drivers/{block => staging}/spectra/README (100%) rename drivers/{block => staging}/spectra/ffsdefs.h (100%) rename drivers/{block => staging}/spectra/ffsport.c (100%) rename drivers/{block => staging}/spectra/ffsport.h (100%) rename drivers/{block => staging}/spectra/flash.c (100%) rename drivers/{block => staging}/spectra/flash.h (100%) rename drivers/{block => staging}/spectra/lld.c (100%) rename drivers/{block => staging}/spectra/lld.h (100%) rename drivers/{block => staging}/spectra/lld_cdma.c (100%) rename drivers/{block => staging}/spectra/lld_cdma.h (100%) rename drivers/{block => staging}/spectra/lld_emu.c (100%) rename drivers/{block => staging}/spectra/lld_emu.h (100%) rename drivers/{block => staging}/spectra/lld_mtd.c (100%) rename drivers/{block => staging}/spectra/lld_mtd.h (100%) rename drivers/{block => staging}/spectra/lld_nand.c (100%) rename drivers/{block => staging}/spectra/lld_nand.h (100%) rename drivers/{block => staging}/spectra/nand_regs.h (100%) rename drivers/{block => staging}/spectra/spectraswconfig.h (100%) diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index d62b95d2ab00..77bfce52e9ca 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -488,6 +488,4 @@ config BLK_DEV_HD If unsure, say N. -source "drivers/block/spectra/Kconfig" - endif # BLK_DEV diff --git a/drivers/block/Makefile b/drivers/block/Makefile index 568ba651cb5e..aff5ac925c34 100644 --- a/drivers/block/Makefile +++ b/drivers/block/Makefile @@ -38,6 +38,4 @@ obj-$(CONFIG_BLK_DEV_HD) += hd.o obj-$(CONFIG_XEN_BLKDEV_FRONTEND) += xen-blkfront.o obj-$(CONFIG_BLK_DEV_DRBD) += drbd/ -obj-$(CONFIG_MRST_NAND) += spectra/ - swim_mod-objs := swim.o swim_asm.o diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 7696a664f8a5..79cf5f720952 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -97,6 +97,8 @@ source "drivers/staging/octeon/Kconfig" source "drivers/staging/serqt_usb2/Kconfig" +source "drivers/staging/spectra/Kconfig" + source "drivers/staging/quatech_usb2/Kconfig" source "drivers/staging/vt6655/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index ea2e70e2fed4..401049ef01d1 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_R8187SE) += rtl8187se/ obj-$(CONFIG_RTL8192SU) += rtl8192su/ obj-$(CONFIG_RTL8192U) += rtl8192u/ obj-$(CONFIG_RTL8192E) += rtl8192e/ +obj-$(CONFIG_MRST_NAND) += spectra/ obj-$(CONFIG_TRANZPORT) += frontier/ obj-$(CONFIG_DREAM) += dream/ obj-$(CONFIG_POHMELFS) += pohmelfs/ diff --git a/drivers/block/spectra/Kconfig b/drivers/staging/spectra/Kconfig similarity index 100% rename from drivers/block/spectra/Kconfig rename to drivers/staging/spectra/Kconfig diff --git a/drivers/block/spectra/Makefile b/drivers/staging/spectra/Makefile similarity index 100% rename from drivers/block/spectra/Makefile rename to drivers/staging/spectra/Makefile diff --git a/drivers/block/spectra/README b/drivers/staging/spectra/README similarity index 100% rename from drivers/block/spectra/README rename to drivers/staging/spectra/README diff --git a/drivers/block/spectra/ffsdefs.h b/drivers/staging/spectra/ffsdefs.h similarity index 100% rename from drivers/block/spectra/ffsdefs.h rename to drivers/staging/spectra/ffsdefs.h diff --git a/drivers/block/spectra/ffsport.c b/drivers/staging/spectra/ffsport.c similarity index 100% rename from drivers/block/spectra/ffsport.c rename to drivers/staging/spectra/ffsport.c diff --git a/drivers/block/spectra/ffsport.h b/drivers/staging/spectra/ffsport.h similarity index 100% rename from drivers/block/spectra/ffsport.h rename to drivers/staging/spectra/ffsport.h diff --git a/drivers/block/spectra/flash.c b/drivers/staging/spectra/flash.c similarity index 100% rename from drivers/block/spectra/flash.c rename to drivers/staging/spectra/flash.c diff --git a/drivers/block/spectra/flash.h b/drivers/staging/spectra/flash.h similarity index 100% rename from drivers/block/spectra/flash.h rename to drivers/staging/spectra/flash.h diff --git a/drivers/block/spectra/lld.c b/drivers/staging/spectra/lld.c similarity index 100% rename from drivers/block/spectra/lld.c rename to drivers/staging/spectra/lld.c diff --git a/drivers/block/spectra/lld.h b/drivers/staging/spectra/lld.h similarity index 100% rename from drivers/block/spectra/lld.h rename to drivers/staging/spectra/lld.h diff --git a/drivers/block/spectra/lld_cdma.c b/drivers/staging/spectra/lld_cdma.c similarity index 100% rename from drivers/block/spectra/lld_cdma.c rename to drivers/staging/spectra/lld_cdma.c diff --git a/drivers/block/spectra/lld_cdma.h b/drivers/staging/spectra/lld_cdma.h similarity index 100% rename from drivers/block/spectra/lld_cdma.h rename to drivers/staging/spectra/lld_cdma.h diff --git a/drivers/block/spectra/lld_emu.c b/drivers/staging/spectra/lld_emu.c similarity index 100% rename from drivers/block/spectra/lld_emu.c rename to drivers/staging/spectra/lld_emu.c diff --git a/drivers/block/spectra/lld_emu.h b/drivers/staging/spectra/lld_emu.h similarity index 100% rename from drivers/block/spectra/lld_emu.h rename to drivers/staging/spectra/lld_emu.h diff --git a/drivers/block/spectra/lld_mtd.c b/drivers/staging/spectra/lld_mtd.c similarity index 100% rename from drivers/block/spectra/lld_mtd.c rename to drivers/staging/spectra/lld_mtd.c diff --git a/drivers/block/spectra/lld_mtd.h b/drivers/staging/spectra/lld_mtd.h similarity index 100% rename from drivers/block/spectra/lld_mtd.h rename to drivers/staging/spectra/lld_mtd.h diff --git a/drivers/block/spectra/lld_nand.c b/drivers/staging/spectra/lld_nand.c similarity index 100% rename from drivers/block/spectra/lld_nand.c rename to drivers/staging/spectra/lld_nand.c diff --git a/drivers/block/spectra/lld_nand.h b/drivers/staging/spectra/lld_nand.h similarity index 100% rename from drivers/block/spectra/lld_nand.h rename to drivers/staging/spectra/lld_nand.h diff --git a/drivers/block/spectra/nand_regs.h b/drivers/staging/spectra/nand_regs.h similarity index 100% rename from drivers/block/spectra/nand_regs.h rename to drivers/staging/spectra/nand_regs.h diff --git a/drivers/block/spectra/spectraswconfig.h b/drivers/staging/spectra/spectraswconfig.h similarity index 100% rename from drivers/block/spectra/spectraswconfig.h rename to drivers/staging/spectra/spectraswconfig.h From bf46b9a92e45044d0b41beed61ae118e560dd3e4 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Tue, 8 Jun 2010 18:27:31 +0100 Subject: [PATCH 009/523] spectra: Rename config options This is the Spectra driver, so use CONFIG_SPECTRA. Signed-off-by: David Woodhouse --- drivers/staging/Makefile | 2 +- drivers/staging/spectra/Kconfig | 26 +++++++++++------------ drivers/staging/spectra/Makefile | 10 ++++----- drivers/staging/spectra/spectraswconfig.h | 8 +++---- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 401049ef01d1..2e2f96ee2c80 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -22,7 +22,7 @@ obj-$(CONFIG_R8187SE) += rtl8187se/ obj-$(CONFIG_RTL8192SU) += rtl8192su/ obj-$(CONFIG_RTL8192U) += rtl8192u/ obj-$(CONFIG_RTL8192E) += rtl8192e/ -obj-$(CONFIG_MRST_NAND) += spectra/ +obj-$(CONFIG_SPECTRA) += spectra/ obj-$(CONFIG_TRANZPORT) += frontier/ obj-$(CONFIG_DREAM) += dream/ obj-$(CONFIG_POHMELFS) += pohmelfs/ diff --git a/drivers/staging/spectra/Kconfig b/drivers/staging/spectra/Kconfig index 4bed96f68837..5e2ffefb60af 100644 --- a/drivers/staging/spectra/Kconfig +++ b/drivers/staging/spectra/Kconfig @@ -1,40 +1,40 @@ -menuconfig MRST_NAND - tristate "Moorestown NAND Flash controller" +menuconfig SPECTRA + tristate "Denali Spectra Flash Translation Layer" depends on BLOCK default n ---help--- - Enable the driver for the NAND Flash controller in Intel Moorestown - Platform + Enable the FTL pseudo-filesystem used with the NAND Flash + controller on Intel Moorestown Platform to pretend to be a disk choice prompt "Compile for" - depends on MRST_NAND - default MRST_NAND_HW + depends on SPECTRA + default SPECTRA_MRST_HW -config MRST_NAND_HW - bool "Actual hardware mode" +config SPECTRA_MRST_HW + bool "Moorestown hardware mode" help - Driver communicates with the actual hardware's register interface. + Driver communicates with the Moorestown hardware's register interface. in DMA mode. -config MRST_NAND_MTD +config SPECTRA_MTD bool "Linux MTD mode" depends on MTD help Driver communicates with the kernel MTD subsystem instead of its own built-in hardware driver. -config MRST_NAND_EMU +config SPECTRA_EMU bool "RAM emulator testing" help Driver emulates Flash on a RAM buffer and / or disk file. Useful to test the behavior of FTL layer. endchoice -config MRST_NAND_HW_DMA +config SPECTRA_MRST_HW_DMA bool default n - depends on MRST_NAND_HW + depends on SPECTRA_MRST_HW help Use DMA for native hardware interface. diff --git a/drivers/staging/spectra/Makefile b/drivers/staging/spectra/Makefile index 2a9490385339..f777dfba05a5 100644 --- a/drivers/staging/spectra/Makefile +++ b/drivers/staging/spectra/Makefile @@ -2,10 +2,10 @@ # Makefile of Intel Moorestown NAND controller driver # -obj-$(CONFIG_MRST_NAND) += spectra.o +obj-$(CONFIG_SPECTRA) += spectra.o spectra-y := ffsport.o flash.o lld.o -spectra-$(CONFIG_MRST_NAND_HW) += lld_nand.o -spectra-$(CONFIG_MRST_NAND_HW_DMA) += lld_cdma.o -spectra-$(CONFIG_MRST_NAND_EMU) += lld_emu.o -spectra-$(CONFIG_MRST_NAND_MTD) += lld_mtd.o +spectra-$(CONFIG_SPECTRA_MRST_HW) += lld_nand.o +spectra-$(CONFIG_SPECTRA_MRST_HW_DMA) += lld_cdma.o +spectra-$(CONFIG_SPECTRA_EMU) += lld_emu.o +spectra-$(CONFIG_SPECTRA_MTD) += lld_mtd.o diff --git a/drivers/staging/spectra/spectraswconfig.h b/drivers/staging/spectra/spectraswconfig.h index 557c091953d7..17259469e955 100644 --- a/drivers/staging/spectra/spectraswconfig.h +++ b/drivers/staging/spectra/spectraswconfig.h @@ -45,10 +45,10 @@ #define DEBUG_BNDRY 0 /***** Product Feature Support *****/ -#define FLASH_EMU defined(CONFIG_MRST_NAND_EMU) -#define FLASH_NAND defined(CONFIG_MRST_NAND_HW) -#define FLASH_MTD defined(CONFIG_MRST_NAND_MTD) -#define CMD_DMA defined(CONFIG_MRST_NAND_HW_DMA) +#define FLASH_EMU defined(CONFIG_SPECTRA_EMU) +#define FLASH_NAND defined(CONFIG_SPECTRA_MRST_HW) +#define FLASH_MTD defined(CONFIG_SPECTRA_MTD) +#define CMD_DMA defined(CONFIG_SPECTRA_MRST_HW_DMA) #define SPECTRA_PARTITION_ID 0 From 091b4242ebb789e826cbde573a0fee9f60fe998b Mon Sep 17 00:00:00 2001 From: Samuel Richardson Date: Mon, 17 May 2010 19:08:18 +0100 Subject: [PATCH 010/523] Staging: comedi: fixed brace coding style issue in ni_tio.c This is a patch to the ni_tio.c file that fixes a brace warning found by the checkpatch.pl tool Signed-off-by: Samuel Richardson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index 13e5b264ff0d..6621e940c308 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -1688,11 +1688,10 @@ static unsigned ni_tio_next_load_register(struct ni_gpct *counter) NITIO_Gxx_Status_Reg(counter-> counter_index)); - if (bits & Gi_Next_Load_Source_Bit(counter->counter_index)) { + if (bits & Gi_Next_Load_Source_Bit(counter->counter_index)) return NITIO_Gi_LoadB_Reg(counter->counter_index); - } else { + else return NITIO_Gi_LoadA_Reg(counter->counter_index); - } } int ni_tio_winsn(struct ni_gpct *counter, struct comedi_insn *insn, From 3d34023a99d35440d6a22fb0b4547fc9817b7b40 Mon Sep 17 00:00:00 2001 From: Cody Harmon Date: Tue, 18 May 2010 23:03:40 -0700 Subject: [PATCH 011/523] Staging: comedi: ni_tio: fixed brace coding style issues and a few errors Fixed code style and placed KERN_ERR in printk statement. Signed-off-by: Cody Harmon Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_tio.c | 49 ++++++++++--------------- 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_tio.c b/drivers/staging/comedi/drivers/ni_tio.c index 6621e940c308..a9bb6b13dfc4 100644 --- a/drivers/staging/comedi/drivers/ni_tio.c +++ b/drivers/staging/comedi/drivers/ni_tio.c @@ -302,7 +302,7 @@ struct ni_gpct_device *ni_gpct_device_construct(struct comedi_device *dev, ni_gpct_register reg), unsigned (*read_register) - (struct ni_gpct * counter, + (struct ni_gpct *counter, enum ni_gpct_register reg), enum ni_gpct_variant variant, unsigned num_counters) @@ -332,6 +332,7 @@ struct ni_gpct_device *ni_gpct_device_construct(struct comedi_device *dev, counter_dev->num_counters = num_counters; return counter_dev; } +EXPORT_SYMBOL_GPL(ni_gpct_device_construct); void ni_gpct_device_destroy(struct ni_gpct_device *counter_dev) { @@ -340,6 +341,7 @@ void ni_gpct_device_destroy(struct ni_gpct_device *counter_dev) kfree(counter_dev->counters); kfree(counter_dev); } +EXPORT_SYMBOL_GPL(ni_gpct_device_destroy); static int ni_tio_second_gate_registers_present(const struct ni_gpct_device *counter_dev) @@ -418,6 +420,7 @@ void ni_tio_init_counter(struct ni_gpct *counter) NITIO_Gi_Interrupt_Enable_Reg(counter->counter_index), ~0, 0x0); } +EXPORT_SYMBOL_GPL(ni_tio_init_counter); static unsigned int ni_tio_counter_status(struct ni_gpct *counter) { @@ -446,9 +449,7 @@ static void ni_tio_set_sync_mode(struct ni_gpct *counter, int force_alt_sync) if (ni_tio_counting_mode_registers_present(counter_dev) == 0) return; - switch (ni_tio_get_soft_copy(counter, - counting_mode_reg) & Gi_Counting_Mode_Mask) - { + switch (ni_tio_get_soft_copy(counter, counting_mode_reg) & Gi_Counting_Mode_Mask) { case Gi_Counting_Mode_QuadratureX1_Bits: case Gi_Counting_Mode_QuadratureX2_Bits: case Gi_Counting_Mode_QuadratureX4_Bits: @@ -513,9 +514,8 @@ static int ni_tio_set_counter_mode(struct ni_gpct *counter, unsigned mode) counting_mode_bits |= ((mode >> NI_GPCT_INDEX_PHASE_BITSHIFT) << Gi_Index_Phase_Bitshift) & Gi_Index_Phase_Mask; - if (mode & NI_GPCT_INDEX_ENABLE_BIT) { + if (mode & NI_GPCT_INDEX_ENABLE_BIT) counting_mode_bits |= Gi_Index_Mode_Bit; - } ni_tio_set_bits(counter, NITIO_Gi_Counting_Mode_Reg(counter-> counter_index), @@ -529,12 +529,10 @@ static int ni_tio_set_counter_mode(struct ni_gpct *counter, unsigned mode) (mode >> NI_GPCT_COUNTING_DIRECTION_SHIFT) << Gi_Up_Down_Shift); - if (mode & NI_GPCT_OR_GATE_BIT) { + if (mode & NI_GPCT_OR_GATE_BIT) input_select_bits |= Gi_Or_Gate_Bit; - } - if (mode & NI_GPCT_INVERT_OUTPUT_BIT) { + if (mode & NI_GPCT_INVERT_OUTPUT_BIT) input_select_bits |= Gi_Output_Polarity_Bit; - } ni_tio_set_bits(counter, NITIO_Gi_Input_Select_Reg(counter->counter_index), Gi_Gate_Select_Load_Source_Bit | Gi_Or_Gate_Bit | @@ -600,6 +598,7 @@ int ni_tio_arm(struct ni_gpct *counter, int arm, unsigned start_trigger) 0, 0, command_transient_bits); return 0; } +EXPORT_SYMBOL_GPL(ni_tio_arm); static unsigned ni_660x_source_select_bits(unsigned int clock_source) { @@ -706,7 +705,7 @@ static unsigned ni_m_series_source_select_bits(unsigned int clock_source) } if (i <= ni_m_series_max_pfi_channel) break; - printk("invalid clock source 0x%lx\n", + printk(KERN_ERR "invalid clock source 0x%lx\n", (unsigned long)clock_source); BUG(); ni_m_series_clock = 0; @@ -1026,14 +1025,12 @@ static void ni_tio_set_first_gate_modifiers(struct ni_gpct *counter, const unsigned mode_mask = Gi_Gate_Polarity_Bit | Gi_Gating_Mode_Mask; unsigned mode_values = 0; - if (gate_source & CR_INVERT) { + if (gate_source & CR_INVERT) mode_values |= Gi_Gate_Polarity_Bit; - } - if (gate_source & CR_EDGE) { + if (gate_source & CR_EDGE) mode_values |= Gi_Rising_Edge_Gating_Bits; - } else { + else mode_values |= Gi_Level_Gating_Bits; - } ni_tio_set_bits(counter, NITIO_Gi_Mode_Reg(counter->counter_index), mode_mask, mode_values); } @@ -1290,6 +1287,7 @@ int ni_tio_set_gate_src(struct ni_gpct *counter, unsigned gate_index, } return 0; } +EXPORT_SYMBOL_GPL(ni_tio_set_gate_src); static int ni_tio_set_other_src(struct ni_gpct *counter, unsigned index, unsigned int source) @@ -1531,12 +1529,10 @@ static int ni_tio_get_gate_src(struct ni_gpct *counter, unsigned gate_index, BUG(); break; } - if (mode_bits & Gi_Gate_Polarity_Bit) { + if (mode_bits & Gi_Gate_Polarity_Bit) *gate_source |= CR_INVERT; - } - if ((mode_bits & Gi_Gating_Mode_Mask) != Gi_Level_Gating_Bits) { + if ((mode_bits & Gi_Gating_Mode_Mask) != Gi_Level_Gating_Bits) *gate_source |= CR_EDGE; - } break; case 1: if ((mode_bits & Gi_Gating_Mode_Mask) == Gi_Gating_Disabled_Bits @@ -1572,9 +1568,8 @@ static int ni_tio_get_gate_src(struct ni_gpct *counter, unsigned gate_index, *gate_source |= CR_INVERT; } /* second gate can't have edge/level mode set independently */ - if ((mode_bits & Gi_Gating_Mode_Mask) != Gi_Level_Gating_Bits) { + if ((mode_bits & Gi_Gating_Mode_Mask) != Gi_Level_Gating_Bits) *gate_source |= CR_EDGE; - } break; default: return -EINVAL; @@ -1627,6 +1622,7 @@ int ni_tio_insn_config(struct ni_gpct *counter, } return -EINVAL; } +EXPORT_SYMBOL_GPL(ni_tio_insn_config); int ni_tio_rinsn(struct ni_gpct *counter, struct comedi_insn *insn, unsigned int *data) @@ -1681,6 +1677,7 @@ int ni_tio_rinsn(struct ni_gpct *counter, struct comedi_insn *insn, }; return 0; } +EXPORT_SYMBOL_GPL(ni_tio_rinsn); static unsigned ni_tio_next_load_register(struct ni_gpct *counter) { @@ -1734,12 +1731,4 @@ int ni_tio_winsn(struct ni_gpct *counter, struct comedi_insn *insn, } return 0; } - -EXPORT_SYMBOL_GPL(ni_tio_rinsn); EXPORT_SYMBOL_GPL(ni_tio_winsn); -EXPORT_SYMBOL_GPL(ni_tio_insn_config); -EXPORT_SYMBOL_GPL(ni_tio_init_counter); -EXPORT_SYMBOL_GPL(ni_tio_arm); -EXPORT_SYMBOL_GPL(ni_tio_set_gate_src); -EXPORT_SYMBOL_GPL(ni_gpct_device_construct); -EXPORT_SYMBOL_GPL(ni_gpct_device_destroy); From 3c17ba0743d75f9888d905ddf9f8551c7dd36493 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Wed, 19 May 2010 14:10:00 +0100 Subject: [PATCH 012/523] Staging: comedi: Allow 'open' driver method to fail Some comedi drivers should return an error from their 'open' method when something goes wrong. Change the prototype of the 'open' method in 'struct comedi_device' to allow this, and change the drivers that use it. Propagate any error to the 'open' file operation. The corresponding 'close' method won't be called when the 'open' method fails, so drivers failing the 'open' need to clean up any mess they created. The dt9812 and serial2002 drivers can now return an error on 'open'. The jr3_pci driver also uses the 'open' method but doesn't fail it. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 11 +++++++++-- drivers/staging/comedi/comedidev.h | 2 +- drivers/staging/comedi/drivers/dt9812.c | 6 +++++- drivers/staging/comedi/drivers/jr3_pci.c | 3 ++- drivers/staging/comedi/drivers/serial2002.c | 9 ++++++--- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index aeb2c00875cd..14091313cebb 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1845,8 +1845,15 @@ ok: } } - if (dev->attached && dev->use_count == 0 && dev->open) - dev->open(dev); + if (dev->attached && dev->use_count == 0 && dev->open) { + int rc = dev->open(dev); + if (rc < 0) { + module_put(dev->driver->module); + module_put(THIS_MODULE); + mutex_unlock(&dev->mutex); + return rc; + } + } dev->use_count++; diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 4eb2b77f56dc..41ef9207f99c 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -285,7 +285,7 @@ struct comedi_device { struct fasync_struct *async_queue; - void (*open) (struct comedi_device *dev); + int (*open) (struct comedi_device *dev); void (*close) (struct comedi_device *dev); }; diff --git a/drivers/staging/comedi/drivers/dt9812.c b/drivers/staging/comedi/drivers/dt9812.c index 96caae36279c..d01d2dc79112 100644 --- a/drivers/staging/comedi/drivers/dt9812.c +++ b/drivers/staging/comedi/drivers/dt9812.c @@ -890,8 +890,10 @@ static struct usb_driver dt9812_usb_driver = { * Comedi functions */ -static void dt9812_comedi_open(struct comedi_device *dev) +static int dt9812_comedi_open(struct comedi_device *dev) { + int result = -ENODEV; + down(&devpriv->slot->mutex); if (devpriv->slot->usb) { /* We have an attached device, fill in current range info */ @@ -934,8 +936,10 @@ static void dt9812_comedi_open(struct comedi_device *dev) } break; } + result = 0; } up(&devpriv->slot->mutex); + return result; } static int dt9812_di_rinsn(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c index d330b1886846..4683a0b90f22 100644 --- a/drivers/staging/comedi/drivers/jr3_pci.c +++ b/drivers/staging/comedi/drivers/jr3_pci.c @@ -373,7 +373,7 @@ static int jr3_pci_ai_insn_read(struct comedi_device *dev, return result; } -static void jr3_pci_open(struct comedi_device *dev) +static int jr3_pci_open(struct comedi_device *dev) { int i; struct jr3_pci_dev_private *devpriv = dev->private; @@ -388,6 +388,7 @@ static void jr3_pci_open(struct comedi_device *dev) p->channel_no); } } + return 0; } int read_idm_word(const u8 * data, size_t size, int *pos, unsigned int *val) diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index 0792617ebc35..a4a99b870369 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -393,15 +393,16 @@ static void serial_write(struct file *f, struct serial_data data) } } -static void serial_2002_open(struct comedi_device *dev) +static int serial_2002_open(struct comedi_device *dev) { + int result; char port[20]; sprintf(port, "/dev/ttyS%d", devpriv->port); devpriv->tty = filp_open(port, O_RDWR, 0); if (IS_ERR(devpriv->tty)) { - printk("serial_2002: file open error = %ld\n", - PTR_ERR(devpriv->tty)); + result = (int)PTR_ERR(devpriv->tty); + printk("serial_2002: file open error = %d\n", result); } else { struct config_t { @@ -673,7 +674,9 @@ static void serial_2002_open(struct comedi_device *dev) } } } + result = 0; } + return result; } static void serial_2002_close(struct comedi_device *dev) From 9e7f2256883c954691e5d395d471e0f125f6b30b Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Wed, 19 May 2010 14:10:01 +0100 Subject: [PATCH 013/523] Staging: comedi: serial2002: handle allocation failures on 'open' The comedi device 'open' method for the serial2002 driver frees any old 'maxdata_list' and 'range_table_list' arrays belonging to a subdevice and allocates them again, but was missing checks for allocation failure. If an allocation fails, free the 'maxdata_list' and 'range_table_list' arrays for all subdevices and return an error. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/serial2002.c | 37 ++++++++++++++++----- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index a4a99b870369..880fe89e866f 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -418,6 +418,7 @@ static int serial_2002_open(struct comedi_device *dev) struct config_t chan_out_config[32]; int i; + result = 0; for (i = 0; i < 32; i++) { dig_in_config[i].kind = 0; dig_in_config[i].bits = 0; @@ -633,22 +634,23 @@ static int serial_2002_open(struct comedi_device *dev) s = &dev->subdevices[i]; s->n_chan = chan; s->maxdata = 0; - if (s->maxdata_list) { - kfree(s->maxdata_list); - } + kfree(s->maxdata_list); s->maxdata_list = maxdata_list = kmalloc(sizeof(unsigned int) * s->n_chan, GFP_KERNEL); - if (s->range_table_list) { - kfree(s->range_table_list); - } + if (!s->maxdata_list) + break; /* error handled below */ + kfree(s->range_table_list); + s->range_table = NULL; + s->range_table_list = NULL; if (range) { - s->range_table = 0; s->range_table_list = range_table_list = kmalloc(sizeof (struct serial2002_range_table_t) * s->n_chan, GFP_KERNEL); + if (!s->range_table_list) + break; /* err handled below */ } for (chan = 0, j = 0; j < 32; j++) { if (c[j].kind == kind) { @@ -674,7 +676,26 @@ static int serial_2002_open(struct comedi_device *dev) } } } - result = 0; + if (i <= 4) { + /* Failed to allocate maxdata_list or range_table_list + * for a subdevice that needed it. */ + result = -ENOMEM; + for (i = 0; i <= 4; i++) { + struct comedi_subdevice *s; + + s = &dev->subdevices[i]; + kfree(s->maxdata_list); + s->maxdata_list = NULL; + kfree(s->range_table_list); + s->range_table_list = NULL; + } + } + if (result) { + if (devpriv->tty) { + filp_close(devpriv->tty, 0); + devpriv->tty = NULL; + } + } } return result; } From fa3b5d9ab0487f58b45d55a37070aa0d417f59d5 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Wed, 19 May 2010 14:10:02 +0100 Subject: [PATCH 014/523] Staging: comedi: serial2002: Fix memory leak on detach The comedi device 'detach' method for the serial2002 driver has an off-by-one error in its loop for freeing data belonging to its subdevices. Fix it. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/serial2002.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index 880fe89e866f..6813e3465f6e 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -903,7 +903,7 @@ static int serial2002_detach(struct comedi_device *dev) int i; printk("comedi%d: serial2002: remove\n", dev->minor); - for (i = 0; i < 4; i++) { + for (i = 0; i < 5; i++) { s = &dev->subdevices[i]; if (s->maxdata_list) { kfree(s->maxdata_list); From 668f272e57e80ece987bed273096f8e3a707123c Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Wed, 19 May 2010 14:10:03 +0100 Subject: [PATCH 015/523] Staging: comedi: serial2002: Reduce stack usage on 'open' Reduce stack usage in serial_2002_open() by allocating dig_in_config, dig_out_config, chan_in_config, and chan_out_config temporary arrays using kcalloc() and freeing them when done with. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/serial2002.c | 44 +++++++++++---------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index 6813e3465f6e..c929f986118c 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -412,30 +412,25 @@ static int serial_2002_open(struct comedi_device *dev) int max; }; - struct config_t dig_in_config[32]; - struct config_t dig_out_config[32]; - struct config_t chan_in_config[32]; - struct config_t chan_out_config[32]; + struct config_t *dig_in_config; + struct config_t *dig_out_config; + struct config_t *chan_in_config; + struct config_t *chan_out_config; int i; result = 0; - for (i = 0; i < 32; i++) { - dig_in_config[i].kind = 0; - dig_in_config[i].bits = 0; - dig_in_config[i].min = 0; - dig_in_config[i].max = 0; - dig_out_config[i].kind = 0; - dig_out_config[i].bits = 0; - dig_out_config[i].min = 0; - dig_out_config[i].max = 0; - chan_in_config[i].kind = 0; - chan_in_config[i].bits = 0; - chan_in_config[i].min = 0; - chan_in_config[i].max = 0; - chan_out_config[i].kind = 0; - chan_out_config[i].bits = 0; - chan_out_config[i].min = 0; - chan_out_config[i].max = 0; + dig_in_config = kcalloc(32, sizeof(struct config_t), + GFP_KERNEL); + dig_out_config = kcalloc(32, sizeof(struct config_t), + GFP_KERNEL); + chan_in_config = kcalloc(32, sizeof(struct config_t), + GFP_KERNEL); + chan_out_config = kcalloc(32, sizeof(struct config_t), + GFP_KERNEL); + if (!dig_in_config || !dig_out_config + || !chan_in_config || !chan_out_config) { + result = -ENOMEM; + goto err_alloc_configs; } tty_setspeed(devpriv->tty, devpriv->speed); @@ -690,6 +685,13 @@ static int serial_2002_open(struct comedi_device *dev) s->range_table_list = NULL; } } + +err_alloc_configs: + kfree(dig_in_config); + kfree(dig_out_config); + kfree(chan_in_config); + kfree(chan_out_config); + if (result) { if (devpriv->tty) { filp_close(devpriv->tty, 0); From c5da20905c8ce21a73a9b443e5d7ef0dc623cff0 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Wed, 19 May 2010 14:10:04 +0100 Subject: [PATCH 016/523] Staging: comedi: serial2002: Use NULL instead of 0 for pointers Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/serial2002.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index c929f986118c..5886ebfd043a 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -444,7 +444,7 @@ static int serial_2002_open(struct comedi_device *dev) break; } else { int command, channel, kind; - struct config_t *cur_config = 0; + struct config_t *cur_config = NULL; channel = data.value & 0x1f; kind = (data.value >> 5) & 0x7; @@ -571,8 +571,8 @@ static int serial_2002_open(struct comedi_device *dev) for (i = 0; i <= 4; i++) { /* Fill in subdev data */ struct config_t *c; - unsigned char *mapping = 0; - struct serial2002_range_table_t *range = 0; + unsigned char *mapping = NULL; + struct serial2002_range_table_t *range = NULL; int kind = 0; switch (i) { @@ -610,7 +610,7 @@ static int serial_2002_open(struct comedi_device *dev) } break; default:{ - c = 0; + c = NULL; } break; } From f25bd6bfdf9bccd8164c151b027f9c14ec07960b Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sat, 22 May 2010 22:42:38 +0200 Subject: [PATCH 017/523] Staging: comedi: cleanup: remove unneeded null checks These checks are obviously pointless because kfree() can handle null dereferences. But really the main problem is that if the pointers were null that would cause problems on the ealier lines. The dereferences would cause an oops and the _release() functions use ->priv to determine which IRQ to free. I looked into it and quite a few of the detach functions assume link->priv is non-null. It seems like we can remove these checks. Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_das16_cs.c | 3 +-- drivers/staging/comedi/drivers/das08_cs.c | 3 +-- drivers/staging/comedi/drivers/ni_daq_700.c | 3 +-- drivers/staging/comedi/drivers/ni_daq_dio24.c | 3 +-- drivers/staging/comedi/drivers/quatech_daqp_cs.c | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index cfeb11f443e3..d8d4ed6de35c 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -719,8 +719,7 @@ static void das16cs_pcmcia_detach(struct pcmcia_device *link) ((struct local_info_t *)link->priv)->stop = 1; das16cs_pcmcia_release(link); /* This points to the parent struct local_info_t struct */ - if (link->priv) - kfree(link->priv); + kfree(link->priv); } /* das16cs_pcmcia_detach */ diff --git a/drivers/staging/comedi/drivers/das08_cs.c b/drivers/staging/comedi/drivers/das08_cs.c index 8761a6d285dc..fb561ab7f07c 100644 --- a/drivers/staging/comedi/drivers/das08_cs.c +++ b/drivers/staging/comedi/drivers/das08_cs.c @@ -206,8 +206,7 @@ static void das08_pcmcia_detach(struct pcmcia_device *link) das08_pcmcia_release(link); /* This points to the parent struct local_info_t struct */ - if (link->priv) - kfree(link->priv); + kfree(link->priv); } /* das08_pcmcia_detach */ diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c index 6ec77bf88c63..701abd9eabe6 100644 --- a/drivers/staging/comedi/drivers/ni_daq_700.c +++ b/drivers/staging/comedi/drivers/ni_daq_700.c @@ -537,8 +537,7 @@ static void dio700_cs_detach(struct pcmcia_device *link) dio700_release(link); /* This points to the parent struct local_info_t struct */ - if (link->priv) - kfree(link->priv); + kfree(link->priv); } /* dio700_cs_detach */ diff --git a/drivers/staging/comedi/drivers/ni_daq_dio24.c b/drivers/staging/comedi/drivers/ni_daq_dio24.c index e4865b1c2310..0b65f247d5dd 100644 --- a/drivers/staging/comedi/drivers/ni_daq_dio24.c +++ b/drivers/staging/comedi/drivers/ni_daq_dio24.c @@ -289,8 +289,7 @@ static void dio24_cs_detach(struct pcmcia_device *link) dio24_release(link); /* This points to the parent local_info_t struct */ - if (link->priv) - kfree(link->priv); + kfree(link->priv); } /* dio24_cs_detach */ diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c index a91db6c42028..78eb254bd619 100644 --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c @@ -1076,8 +1076,7 @@ static void daqp_cs_detach(struct pcmcia_device *link) /* Unlink device structure, and free it */ dev_table[dev->table_index] = NULL; - if (dev) - kfree(dev); + kfree(dev); } /* daqp_cs_detach */ From 2f6df34cd3455245c44b420d7c3fb11d1137df79 Mon Sep 17 00:00:00 2001 From: Mark Rankilor Date: Mon, 24 May 2010 17:59:10 +0800 Subject: [PATCH 018/523] Staging: comedi: Checkpatch cleanups in adl_pci9111.c This patch cleans up some various warnings generated from checkpatch.pl Signed-off-by: Mark Rankilor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/adl_pci9111.c | 105 +++++++++++-------- 1 file changed, 59 insertions(+), 46 deletions(-) diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index 36a254cd4413..595689d5f17f 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -68,8 +68,9 @@ CHANGELOG: TODO: - Really test implemented functionality. - - Add support for the PCI-9111DG with a probe routine to identify the card type - (perhaps with the help of the channel number readback of the A/D Data register). + - Add support for the PCI-9111DG with a probe routine to identify the card + type (perhaps with the help of the channel number readback of the A/D Data + register). - Add external multiplexer support. */ @@ -83,12 +84,12 @@ TODO: #include "comedi_pci.h" #include "comedi_fc.h" -#define PCI9111_DRIVER_NAME "adl_pci9111" -#define PCI9111_HR_DEVICE_ID 0x9111 +#define PCI9111_DRIVER_NAME "adl_pci9111" +#define PCI9111_HR_DEVICE_ID 0x9111 /* TODO: Add other pci9111 board id */ -#define PCI9111_IO_RANGE 0x0100 +#define PCI9111_IO_RANGE 0x0100 #define PCI9111_FIFO_HALF_SIZE 512 @@ -134,27 +135,29 @@ TODO: /* IO address map */ -#define PCI9111_REGISTER_AD_FIFO_VALUE 0x00 /* AD Data stored in FIFO */ -#define PCI9111_REGISTER_DA_OUTPUT 0x00 -#define PCI9111_REGISTER_DIGITAL_IO 0x02 -#define PCI9111_REGISTER_EXTENDED_IO_PORTS 0x04 -#define PCI9111_REGISTER_AD_CHANNEL_CONTROL 0x06 /* Channel selection */ -#define PCI9111_REGISTER_AD_CHANNEL_READBACK 0x06 -#define PCI9111_REGISTER_INPUT_SIGNAL_RANGE 0x08 -#define PCI9111_REGISTER_RANGE_STATUS_READBACK 0x08 -#define PCI9111_REGISTER_TRIGGER_MODE_CONTROL 0x0A -#define PCI9111_REGISTER_AD_MODE_INTERRUPT_READBACK 0x0A -#define PCI9111_REGISTER_SOFTWARE_TRIGGER 0x0E -#define PCI9111_REGISTER_INTERRUPT_CONTROL 0x0C +#define PCI9111_REGISTER_AD_FIFO_VALUE 0x00 /* AD Data stored + in FIFO */ +#define PCI9111_REGISTER_DA_OUTPUT 0x00 +#define PCI9111_REGISTER_DIGITAL_IO 0x02 +#define PCI9111_REGISTER_EXTENDED_IO_PORTS 0x04 +#define PCI9111_REGISTER_AD_CHANNEL_CONTROL 0x06 /* Channel + selection */ +#define PCI9111_REGISTER_AD_CHANNEL_READBACK 0x06 +#define PCI9111_REGISTER_INPUT_SIGNAL_RANGE 0x08 +#define PCI9111_REGISTER_RANGE_STATUS_READBACK 0x08 +#define PCI9111_REGISTER_TRIGGER_MODE_CONTROL 0x0A +#define PCI9111_REGISTER_AD_MODE_INTERRUPT_READBACK 0x0A +#define PCI9111_REGISTER_SOFTWARE_TRIGGER 0x0E +#define PCI9111_REGISTER_INTERRUPT_CONTROL 0x0C #define PCI9111_REGISTER_8254_COUNTER_0 0x40 #define PCI9111_REGISTER_8254_COUNTER_1 0x42 -#define PCI9111_REGISTER_8254_COUNTER_2 0X44 +#define PCI9111_REGISTER_8254_COUNTER_2 0X44 #define PCI9111_REGISTER_8254_CONTROL 0x46 -#define PCI9111_REGISTER_INTERRUPT_CLEAR 0x48 +#define PCI9111_REGISTER_INTERRUPT_CLEAR 0x48 -#define PCI9111_TRIGGER_MASK 0x0F -#define PCI9111_PTRG_OFF (0 << 3) -#define PCI9111_PTRG_ON (1 << 3) +#define PCI9111_TRIGGER_MASK 0x0F +#define PCI9111_PTRG_OFF (0 << 3) +#define PCI9111_PTRG_ON (1 << 3) #define PCI9111_EITS_EXTERNAL (1 << 2) #define PCI9111_EITS_INTERNAL (0 << 2) #define PCI9111_TPST_SOFTWARE_TRIGGER (0 << 1) @@ -164,9 +167,9 @@ TODO: #define PCI9111_ISC0_SET_IRQ_ON_ENDING_OF_AD_CONVERSION (0 << 0) #define PCI9111_ISC0_SET_IRQ_ON_FIFO_HALF_FULL (1 << 0) -#define PCI9111_ISC1_SET_IRQ_ON_TIMER_TICK (0 << 1) -#define PCI9111_ISC1_SET_IRQ_ON_EXT_TRG (1 << 1) -#define PCI9111_FFEN_SET_FIFO_ENABLE (0 << 2) +#define PCI9111_ISC1_SET_IRQ_ON_TIMER_TICK (0 << 1) +#define PCI9111_ISC1_SET_IRQ_ON_EXT_TRG (1 << 1) +#define PCI9111_FFEN_SET_FIFO_ENABLE (0 << 2) #define PCI9111_FFEN_SET_FIFO_DISABLE (1 << 2) #define PCI9111_CHANNEL_MASK 0x0F @@ -177,7 +180,7 @@ TODO: #define PCI9111_FIFO_FULL_MASK 0x40 #define PCI9111_AD_BUSY_MASK 0x80 -#define PCI9111_IO_BASE dev->iobase +#define PCI9111_IO_BASE (dev->iobase) /* * Define inlined function @@ -189,8 +192,9 @@ TODO: #define pci9111_trigger_and_autoscan_set(flags) \ outb(flags, PCI9111_IO_BASE+PCI9111_REGISTER_TRIGGER_MODE_CONTROL) -#define pci9111_interrupt_and_fifo_get() \ - ((inb(PCI9111_IO_BASE+PCI9111_REGISTER_AD_MODE_INTERRUPT_READBACK) >> 4) &0x03) +#define pci9111_interrupt_and_fifo_get() \ + ((inb(PCI9111_IO_BASE+PCI9111_REGISTER_AD_MODE_INTERRUPT_READBACK) >> 4) \ + &0x03) #define pci9111_interrupt_and_fifo_set(flags) \ outb(flags, PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL) @@ -201,38 +205,47 @@ TODO: #define pci9111_software_trigger() \ outb(0, PCI9111_IO_BASE+PCI9111_REGISTER_SOFTWARE_TRIGGER) -#define pci9111_fifo_reset() \ - outb(PCI9111_FFEN_SET_FIFO_ENABLE, PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \ - outb(PCI9111_FFEN_SET_FIFO_DISABLE, PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \ - outb(PCI9111_FFEN_SET_FIFO_ENABLE, PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL) +#define pci9111_fifo_reset() do { \ + outb(PCI9111_FFEN_SET_FIFO_ENABLE, \ + PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \ + outb(PCI9111_FFEN_SET_FIFO_DISABLE, \ + PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \ + outb(PCI9111_FFEN_SET_FIFO_ENABLE, \ + PCI9111_IO_BASE+PCI9111_REGISTER_INTERRUPT_CONTROL); \ + } while (0) #define pci9111_is_fifo_full() \ ((inb(PCI9111_IO_BASE+PCI9111_REGISTER_RANGE_STATUS_READBACK)& \ - PCI9111_FIFO_FULL_MASK)==0) + PCI9111_FIFO_FULL_MASK) == 0) #define pci9111_is_fifo_half_full() \ ((inb(PCI9111_IO_BASE+PCI9111_REGISTER_RANGE_STATUS_READBACK)& \ - PCI9111_FIFO_HALF_FULL_MASK)==0) + PCI9111_FIFO_HALF_FULL_MASK) == 0) #define pci9111_is_fifo_empty() \ ((inb(PCI9111_IO_BASE+PCI9111_REGISTER_RANGE_STATUS_READBACK)& \ - PCI9111_FIFO_EMPTY_MASK)==0) + PCI9111_FIFO_EMPTY_MASK) == 0) -#define pci9111_ai_channel_set(channel) \ - outb((channel)&PCI9111_CHANNEL_MASK, PCI9111_IO_BASE+PCI9111_REGISTER_AD_CHANNEL_CONTROL) +#define pci9111_ai_channel_set(channel) \ + outb((channel)&PCI9111_CHANNEL_MASK, \ + PCI9111_IO_BASE+PCI9111_REGISTER_AD_CHANNEL_CONTROL) -#define pci9111_ai_channel_get() \ - inb(PCI9111_IO_BASE+PCI9111_REGISTER_AD_CHANNEL_READBACK)&PCI9111_CHANNEL_MASK +#define pci9111_ai_channel_get() \ + (inb(PCI9111_IO_BASE+PCI9111_REGISTER_AD_CHANNEL_READBACK) \ + &PCI9111_CHANNEL_MASK) -#define pci9111_ai_range_set(range) \ - outb((range)&PCI9111_RANGE_MASK, PCI9111_IO_BASE+PCI9111_REGISTER_INPUT_SIGNAL_RANGE) +#define pci9111_ai_range_set(range) \ + outb((range)&PCI9111_RANGE_MASK, \ + PCI9111_IO_BASE+PCI9111_REGISTER_INPUT_SIGNAL_RANGE) -#define pci9111_ai_range_get() \ - inb(PCI9111_IO_BASE+PCI9111_REGISTER_RANGE_STATUS_READBACK)&PCI9111_RANGE_MASK +#define pci9111_ai_range_get() \ + (inb(PCI9111_IO_BASE+PCI9111_REGISTER_RANGE_STATUS_READBACK) \ + &PCI9111_RANGE_MASK) -#define pci9111_ai_get_data() \ - ((inw(PCI9111_IO_BASE+PCI9111_REGISTER_AD_FIFO_VALUE)>>4)&PCI9111_AI_RESOLUTION_MASK) \ - ^ PCI9111_AI_RESOLUTION_2_CMP_BIT +#define pci9111_ai_get_data() \ + (((inw(PCI9111_IO_BASE+PCI9111_REGISTER_AD_FIFO_VALUE)>>4) \ + &PCI9111_AI_RESOLUTION_MASK) \ + ^ PCI9111_AI_RESOLUTION_2_CMP_BIT) #define pci9111_hr_ai_get_data() \ (inw(PCI9111_IO_BASE+PCI9111_REGISTER_AD_FIFO_VALUE) & PCI9111_HR_AI_RESOLUTION_MASK) \ From 4c67da06f0248fc0ee0fcbf65afd887b023b4591 Mon Sep 17 00:00:00 2001 From: Mark Rankilor Date: Thu, 27 May 2010 17:39:15 +0800 Subject: [PATCH 019/523] Staging: comedi: Fixed long lines in gsc_hpdi.c This patch fixes some long line lengths in gsc_hpdi.c as found by the checkpatch.pl tool Signed-off-by: Mark Rankilor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/gsc_hpdi.c | 30 +++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 51f12bf45cf1..17c4f1f8117d 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -311,17 +311,25 @@ struct hpdi_private { void *plx9080_iobase; void *hpdi_iobase; uint32_t *dio_buffer[NUM_DMA_BUFFERS]; /* dma buffers */ - dma_addr_t dio_buffer_phys_addr[NUM_DMA_BUFFERS]; /* physical addresses of dma buffers */ - struct plx_dma_desc *dma_desc; /* array of dma descriptors read by plx9080, allocated to get proper alignment */ - dma_addr_t dma_desc_phys_addr; /* physical address of dma descriptor array */ + /* physical addresses of dma buffers */ + dma_addr_t dio_buffer_phys_addr[NUM_DMA_BUFFERS]; + /* array of dma descriptors read by plx9080, allocated to get proper + * alignment */ + struct plx_dma_desc *dma_desc; + /* physical address of dma descriptor array */ + dma_addr_t dma_desc_phys_addr; unsigned int num_dma_descriptors; - uint32_t *desc_dio_buffer[NUM_DMA_DESCRIPTORS]; /* pointer to start of buffers indexed by descriptor */ - volatile unsigned int dma_desc_index; /* index of the dma descriptor that is currently being used */ + /* pointer to start of buffers indexed by descriptor */ + uint32_t *desc_dio_buffer[NUM_DMA_DESCRIPTORS]; + /* index of the dma descriptor that is currently being used */ + volatile unsigned int dma_desc_index; unsigned int tx_fifo_size; unsigned int rx_fifo_size; volatile unsigned long dio_count; - volatile uint32_t bits[24]; /* software copies of values written to hpdi registers */ - volatile unsigned int block_size; /* number of bytes at which to generate COMEDI_CB_BLOCK events */ + /* software copies of values written to hpdi registers */ + volatile uint32_t bits[24]; + /* number of bytes at which to generate COMEDI_CB_BLOCK events */ + volatile unsigned int block_size; unsigned dio_config_output:1; }; @@ -570,7 +578,8 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it) return -ENOMEM; pcidev = NULL; - for (i = 0; i < ARRAY_SIZE(hpdi_boards) && dev->board_ptr == NULL; i++) { + for (i = 0; i < ARRAY_SIZE(hpdi_boards) && + dev->board_ptr == NULL; i++) { do { pcidev = pci_get_subsys(PCI_VENDOR_ID_PLX, hpdi_boards[i].device_id, @@ -618,7 +627,7 @@ static int hpdi_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* remap, won't work with 2.0 kernels but who cares */ priv(dev)->plx9080_iobase = ioremap(priv(dev)->plx9080_phys_iobase, pci_resource_len(pcidev, - PLX9080_BADDRINDEX)); + PLX9080_BADDRINDEX)); priv(dev)->hpdi_iobase = ioremap(priv(dev)->hpdi_phys_iobase, pci_resource_len(pcidev, HPDI_BADDRINDEX)); @@ -769,7 +778,8 @@ static int di_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, if (err) return 1; - /* step 2: make sure trigger sources are unique and mutually compatible */ + /* step 2: make sure trigger sources are unique and mutually + * compatible */ /* uniqueness check */ if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE) From 6fd071cccf4127f1e81767a819720d8915b2a800 Mon Sep 17 00:00:00 2001 From: John Sheehan Date: Thu, 27 May 2010 12:41:38 +0100 Subject: [PATCH 020/523] Staging: comedi: fix code style errors in unioxx5.c A patch for unioxx5.c which fixes "trailing statements should be on next line" errors raised by the chechpatch.pl tool Signed-off-by: John Sheehan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/unioxx5.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/unioxx5.c b/drivers/staging/comedi/drivers/unioxx5.c index 16d4c9f69165..d5f6d758a8be 100644 --- a/drivers/staging/comedi/drivers/unioxx5.c +++ b/drivers/staging/comedi/drivers/unioxx5.c @@ -302,7 +302,8 @@ static int __unioxx5_subdev_init(struct comedi_subdevice *subdev, __unioxx5_analog_config(usp, i * 2); outb(i + 1, subdev_iobase + 5); /* sends channel number to card */ outb('H', subdev_iobase + 6); /* requests EEPROM world */ - while (!(inb(subdev_iobase + 0) & TxBE)) ; /* waits while writting will be allowed */ + while (!(inb(subdev_iobase + 0) & TxBE)) + ; /* waits while writting will be allowed */ outb(0, subdev_iobase + 6); /* waits while reading of two bytes will be allowed */ @@ -437,7 +438,8 @@ static int __unioxx5_analog_write(struct unioxx5_subd_priv *usp, /* sending for bytes to module(one byte per cycle iteration) */ for (i = 0; i < 4; i++) { - while (!((inb(usp->usp_iobase + 0)) & TxBE)) ; /* waits while writting will be allowed */ + while (!((inb(usp->usp_iobase + 0)) & TxBE)) + ; /* waits while writting will be allowed */ outb(usp->usp_extra_data[module][i], usp->usp_iobase + 6); } @@ -467,7 +469,8 @@ static int __unioxx5_analog_read(struct unioxx5_subd_priv *usp, control = inb(usp->usp_iobase); /* get control register byte */ /* waits while reading four bytes will be allowed */ - while (!((control = inb(usp->usp_iobase + 0)) & Rx4CA)) ; + while (!((control = inb(usp->usp_iobase + 0)) & Rx4CA)) + ; /* if four bytes readding error occurs - return 0(false) */ if ((control & Rx4CA_ERR_MASK)) { From daca497d8035cdb649b37ef1c962f1f0de8f16d9 Mon Sep 17 00:00:00 2001 From: John Sheehan Date: Fri, 28 May 2010 16:33:25 +0100 Subject: [PATCH 021/523] Staging: comedi: fix code warnings in s626.c A patch for s626.c to fix some of the warnings reported by the checkpatch.pl tool, namely, printk() should include KERN_ facility level unnecessary whitespace before a quoted newline Signed-off-by: John Sheehan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/s626.c | 38 +++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index a3cc93362ec2..febb62e86ec3 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -543,13 +543,13 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it) devpriv->pdev = pdev; if (pdev == NULL) { - printk("s626_attach: Board not present!!!\n"); + printk(KERN_ERR "s626_attach: Board not present!!!\n"); return -ENODEV; } result = comedi_pci_enable(pdev, "s626"); if (result < 0) { - printk("s626_attach: comedi_pci_enable fails\n"); + printk(KERN_ERR "s626_attach: comedi_pci_enable fails\n"); return -ENODEV; } devpriv->got_regions = 1; @@ -558,7 +558,7 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it) devpriv->base_addr = ioremap(resourceStart, SIZEOF_ADDRESS_SPACE); if (devpriv->base_addr == NULL) { - printk("s626_attach: IOREMAP failed\n"); + printk(KERN_ERR "s626_attach: IOREMAP failed\n"); return -ENODEV; } @@ -579,7 +579,7 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it) pci_alloc_consistent(devpriv->pdev, DMABUF_SIZE, &appdma); if (devpriv->ANABuf.LogicalBase == NULL) { - printk("s626_attach: DMA Memory mapping error\n"); + printk(KERN_ERR "s626_attach: DMA Memory mapping error\n"); return -ENOMEM; } @@ -596,7 +596,7 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it) pci_alloc_consistent(devpriv->pdev, DMABUF_SIZE, &appdma); if (devpriv->RPSBuf.LogicalBase == NULL) { - printk("s626_attach: DMA Memory mapping error\n"); + printk(KERN_ERR "s626_attach: DMA Memory mapping error\n"); return -ENOMEM; } @@ -622,18 +622,18 @@ static int s626_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* set up interrupt handler */ if (dev->irq == 0) { - printk(" unknown irq (bad)\n"); + printk(KERN_ERR " unknown irq (bad)\n"); } else { ret = request_irq(dev->irq, s626_irq_handler, IRQF_SHARED, "s626", dev); if (ret < 0) { - printk(" irq not available\n"); + printk(KERN_ERR " irq not available\n"); dev->irq = 0; } } - DEBUG("s626_attach: -- it opts %d,%d -- \n", + DEBUG("s626_attach: -- it opts %d,%d --\n", it->options[0], it->options[1]); s = dev->subdevices + 0; @@ -1513,7 +1513,7 @@ void ResetADC(struct comedi_device *dev, uint8_t * ppl) break; /* Exit poll list processing loop. */ } } - DEBUG("ResetADC: ADC items %d \n", devpriv->AdcItems); + DEBUG("ResetADC: ADC items %d\n", devpriv->AdcItems); /* VERSION 2.01 CHANGE: DELAY CHANGED FROM 250NS to 2US. Allow the * ADC to stabilize for 2 microseconds before starting the final @@ -1574,7 +1574,7 @@ static int s626_ai_insn_config(struct comedi_device *dev, /* register uint8_t i; */ /* register int32_t *readaddr; */ -/* DEBUG("as626_ai_rinsn: ai_rinsn enter \n"); */ +/* DEBUG("as626_ai_rinsn: ai_rinsn enter\n"); */ /* Trigger ADC scan loop start by setting RPS Signal 0. */ /* MC_ENABLE( P_MC2, MC2_ADC_RPS ); */ @@ -1591,11 +1591,11 @@ static int s626_ai_insn_config(struct comedi_device *dev, /* Convert ADC data to 16-bit integer values and copy to application buffer. */ /* for ( i = 0; i < devpriv->AdcItems; i++ ) { */ /* *data = s626_ai_reg_to_uint( *readaddr++ ); */ -/* DEBUG("s626_ai_rinsn: data %d \n",*data); */ +/* DEBUG("s626_ai_rinsn: data %d\n",*data); */ /* data++; */ /* } */ -/* DEBUG("s626_ai_rinsn: ai_rinsn escape \n"); */ +/* DEBUG("s626_ai_rinsn: ai_rinsn escape\n"); */ /* return i; */ /* } */ @@ -1743,7 +1743,7 @@ static int s626_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) DEBUG("s626_ai_cmd: entering command function\n"); if (devpriv->ai_cmd_running) { - printk("s626_ai_cmd: Another ai_cmd is running %d\n", + printk(KERN_ERR "s626_ai_cmd: Another ai_cmd is running %d\n", dev->minor); return -EBUSY; } @@ -2147,7 +2147,7 @@ static void s626_dio_init(struct comedi_device *dev) DEBIwrite(dev, diopriv->WRDOut, 0); /* Program all outputs */ /* to inactive state. */ } - DEBUG("s626_dio_init: DIO initialized \n"); + DEBUG("s626_dio_init: DIO initialized\n"); } /* DIO devices are slightly special. Although it is possible to @@ -2346,7 +2346,7 @@ static int s626_enc_insn_read(struct comedi_device *dev, int n; struct enc_private *k = &encpriv[CR_CHAN(insn->chanspec)]; - DEBUG("s626_enc_insn_read: encoder read channel %d \n", + DEBUG("s626_enc_insn_read: encoder read channel %d\n", CR_CHAN(insn->chanspec)); for (n = 0; n < insn->n; n++) @@ -2364,7 +2364,7 @@ static int s626_enc_insn_write(struct comedi_device *dev, struct enc_private *k = &encpriv[CR_CHAN(insn->chanspec)]; - DEBUG("s626_enc_insn_write: encoder write channel %d \n", + DEBUG("s626_enc_insn_write: encoder write channel %d\n", CR_CHAN(insn->chanspec)); /* Set the preload register */ @@ -3099,12 +3099,12 @@ static uint16_t GetEnable_B(struct comedi_device *dev, struct enc_private *k) static void SetLatchSource(struct comedi_device *dev, struct enc_private *k, uint16_t value) { - DEBUG("SetLatchSource: SetLatchSource enter 3550 \n"); + DEBUG("SetLatchSource: SetLatchSource enter 3550\n"); DEBIreplace(dev, k->MyCRB, (uint16_t) (~(CRBMSK_INTCTRL | CRBMSK_LATCHSRC)), (uint16_t) (value << CRBBIT_LATCHSRC)); - DEBUG("SetLatchSource: SetLatchSource exit \n"); + DEBUG("SetLatchSource: SetLatchSource exit\n"); } /* @@ -3317,6 +3317,6 @@ static void CountersInit(struct comedi_device *dev) k->ResetCapFlags(dev, k); k->SetEnable(dev, k, CLKENAB_ALWAYS); } - DEBUG("CountersInit: counters initialized \n"); + DEBUG("CountersInit: counters initialized\n"); } From 0c55484dcae163aa28736a0da7e33fe747f3e302 Mon Sep 17 00:00:00 2001 From: Bob Beattie Date: Fri, 4 Jun 2010 00:19:02 +0100 Subject: [PATCH 022/523] Staging: comedi: drivers: fix space coding style in am9513.h This is a patch to the file am9513.h that fixes missing space warnings found by the checkpatch.pl tool. Signed-off-by: Bob Beattie Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/am9513.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/comedi/drivers/am9513.h b/drivers/staging/comedi/drivers/am9513.h index 73367d6afffe..0bb839e51493 100644 --- a/drivers/staging/comedi/drivers/am9513.h +++ b/drivers/staging/comedi/drivers/am9513.h @@ -47,32 +47,32 @@ #ifdef Am9513_8BITBUS #define Am9513_write_register(reg, val) \ - do{ \ + do { \ Am9513_output_control(reg); \ Am9513_output_data(val>>8); \ Am9513_output_data(val&0xff); \ - }while (0) + } while (0) #define Am9513_read_register(reg, val) \ - do{ \ + do { \ Am9513_output_control(reg); \ - val=Am9513_input_data()<<8; \ - val|=Am9513_input_data(); \ - }while (0) + val = Am9513_input_data()<<8; \ + val |= Am9513_input_data(); \ + } while (0) #else /* Am9513_16BITBUS */ #define Am9513_write_register(reg, val) \ - do{ \ + do { \ Am9513_output_control(reg); \ Am9513_output_data(val); \ - }while (0) + } while (0) #define Am9513_read_register(reg, val) \ - do{ \ + do { \ Am9513_output_control(reg); \ - val=Am9513_input_data(); \ - }while (0) + val = Am9513_input_data(); \ + } while (0) #endif From 88d8ed4b643d2064a663b2f07426963289def676 Mon Sep 17 00:00:00 2001 From: Maurice Dawson Date: Fri, 4 Jun 2010 13:07:06 +0100 Subject: [PATCH 023/523] Staging: comedi: fix printk() coding style issue in ni_labpc.c This is a patch to the ni_labpc.c file that fixes all, printk() should include KERN-facility level, warnings found by the checkpatch.pl tool Signed-off-by: Maurice Dawson Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc.c | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index 67c8a538802c..0e3ac5a5b050 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -526,7 +526,8 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase, unsigned long dma_flags, isr_flags; short lsb, msb; - printk("comedi%d: ni_labpc: %s, io 0x%lx", dev->minor, thisboard->name, + printk(KERN_ERR "comedi%d: ni_labpc: %s, io 0x%lx", dev->minor, + thisboard->name, iobase); if (irq) printk(", irq %u", irq); @@ -543,7 +544,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase, /* check if io addresses are available */ if (!request_region(iobase, LABPC_SIZE, driver_labpc.driver_name)) { - printk("I/O port conflict\n"); + printk(KERN_ERR "I/O port conflict\n"); return -EIO; } } @@ -575,7 +576,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase, isr_flags |= IRQF_SHARED; if (request_irq(irq, labpc_interrupt, isr_flags, driver_labpc.driver_name, dev)) { - printk("unable to allocate irq %u\n", irq); + printk(KERN_ERR "unable to allocate irq %u\n", irq); return -EINVAL; } } @@ -583,18 +584,18 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase, /* grab dma channel */ if (dma_chan > 3) { - printk(" invalid dma channel %u\n", dma_chan); + printk(KERN_ERR " invalid dma channel %u\n", dma_chan); return -EINVAL; } else if (dma_chan) { /* allocate dma buffer */ devpriv->dma_buffer = kmalloc(dma_buffer_size, GFP_KERNEL | GFP_DMA); if (devpriv->dma_buffer == NULL) { - printk(" failed to allocate dma buffer\n"); + printk(KERN_ERR " failed to allocate dma buffer\n"); return -ENOMEM; } if (request_dma(dma_chan, driver_labpc.driver_name)) { - printk(" failed to allocate dma channel %u\n", + printk(KERN_ERR " failed to allocate dma channel %u\n", dma_chan); return -EINVAL; } @@ -690,7 +691,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase, for (i = 0; i < EEPROM_SIZE; i++) devpriv->eeprom_data[i] = labpc_eeprom_read(dev, i); #ifdef LABPC_DEBUG - printk(" eeprom:"); + printk(KERN_ERR " eeprom:"); for (i = 0; i < EEPROM_SIZE; i++) printk(" %i:0x%x ", i, devpriv->eeprom_data[i]); printk("\n"); @@ -732,7 +733,8 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it) iobase = (unsigned long)devpriv->mite->daq_io_addr; irq = mite_irq(devpriv->mite); #else - printk(" this driver has not been built with PCI support.\n"); + printk(KERN_ERR " this driver has not been built with PCI " + "support.\n"); return -EINVAL; #endif break; @@ -742,7 +744,7 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it) return -EINVAL; break; default: - printk("bug! couldn't determine board type\n"); + printk(KERN_ERR "bug! couldn't determine board type\n"); return -EINVAL; break; } @@ -776,7 +778,7 @@ static int labpc_find_device(struct comedi_device *dev, int bus, int slot) } } } - printk("no device found\n"); + printk(KERN_ERR "no device found\n"); mite_list_devices(); return -EIO; } @@ -784,7 +786,7 @@ static int labpc_find_device(struct comedi_device *dev, int bus, int slot) int labpc_common_detach(struct comedi_device *dev) { - printk("comedi%d: ni_labpc: detach\n", dev->minor); + printk(KERN_ERR "comedi%d: ni_labpc: detach\n", dev->minor); if (dev->subdevices) subdev_8255_cleanup(dev, dev->subdevices + 2); @@ -846,7 +848,7 @@ static enum scan_mode labpc_ai_scan_mode(const struct comedi_cmd *cmd) if (CR_CHAN(cmd->chanlist[0]) > CR_CHAN(cmd->chanlist[1])) return MODE_MULT_CHAN_DOWN; - printk("ni_labpc: bug! this should never happen\n"); + printk(KERN_ERR "ni_labpc: bug! this should never happen\n"); return 0; } @@ -902,7 +904,7 @@ static int labpc_ai_chanlist_invalid(const struct comedi_device *dev, } break; default: - printk("ni_labpc: bug! in chanlist check\n"); + printk(KERN_ERR "ni_labpc: bug! in chanlist check\n"); return 1; break; } From 90f703d30dd3e0c16ff80f35e34e511385a05ad5 Mon Sep 17 00:00:00 2001 From: Arun Thomas Date: Sun, 6 Jun 2010 22:23:29 +0200 Subject: [PATCH 024/523] Staging: comedi: Remove COMEDI_MODULES_MACRO Add MODULE_AUTHOR, MODULE_LICENSE, and MODULE_DESCRIPTION calls to the respective C source files instead of calling COMEDI_MODULES_MACRO Signed-off-by: Arun Thomas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 7 ------- drivers/staging/comedi/drivers/8255.c | 4 ++++ drivers/staging/comedi/drivers/acl7225b.c | 4 ++++ drivers/staging/comedi/drivers/addi_apci_035.c | 4 ++++ drivers/staging/comedi/drivers/addi_apci_1032.c | 4 ++++ drivers/staging/comedi/drivers/addi_apci_1500.c | 4 ++++ drivers/staging/comedi/drivers/addi_apci_1516.c | 4 ++++ drivers/staging/comedi/drivers/addi_apci_1564.c | 4 ++++ drivers/staging/comedi/drivers/addi_apci_16xx.c | 4 ++++ drivers/staging/comedi/drivers/addi_apci_2016.c | 4 ++++ drivers/staging/comedi/drivers/addi_apci_2032.c | 4 ++++ drivers/staging/comedi/drivers/addi_apci_2200.c | 4 ++++ drivers/staging/comedi/drivers/addi_apci_3001.c | 4 ++++ drivers/staging/comedi/drivers/addi_apci_3120.c | 4 ++++ drivers/staging/comedi/drivers/addi_apci_3501.c | 4 ++++ drivers/staging/comedi/drivers/addi_apci_3xxx.c | 4 ++++ drivers/staging/comedi/drivers/adl_pci6208.c | 4 ++++ drivers/staging/comedi/drivers/adl_pci7230.c | 4 ++++ drivers/staging/comedi/drivers/adl_pci7296.c | 4 ++++ drivers/staging/comedi/drivers/adl_pci7432.c | 4 ++++ drivers/staging/comedi/drivers/adl_pci8164.c | 4 ++++ drivers/staging/comedi/drivers/adl_pci9111.c | 4 ++++ drivers/staging/comedi/drivers/adl_pci9118.c | 4 ++++ drivers/staging/comedi/drivers/adq12b.c | 4 ++++ drivers/staging/comedi/drivers/adv_pci1710.c | 4 ++++ drivers/staging/comedi/drivers/adv_pci1723.c | 4 ++++ drivers/staging/comedi/drivers/adv_pci_dio.c | 4 ++++ drivers/staging/comedi/drivers/aio_aio12_8.c | 4 ++++ drivers/staging/comedi/drivers/aio_iiro_16.c | 4 ++++ drivers/staging/comedi/drivers/amplc_dio200.c | 4 ++++ drivers/staging/comedi/drivers/amplc_pc236.c | 4 ++++ drivers/staging/comedi/drivers/amplc_pc263.c | 4 ++++ drivers/staging/comedi/drivers/amplc_pci224.c | 4 ++++ drivers/staging/comedi/drivers/amplc_pci230.c | 4 ++++ drivers/staging/comedi/drivers/c6xdigio.c | 4 ++++ drivers/staging/comedi/drivers/cb_pcidas.c | 4 ++++ drivers/staging/comedi/drivers/cb_pcidas64.c | 4 ++++ drivers/staging/comedi/drivers/cb_pcidda.c | 4 ++++ drivers/staging/comedi/drivers/cb_pcidio.c | 4 ++++ drivers/staging/comedi/drivers/cb_pcimdas.c | 4 ++++ drivers/staging/comedi/drivers/comedi_parport.c | 4 ++++ drivers/staging/comedi/drivers/comedi_test.c | 4 ++++ drivers/staging/comedi/drivers/contec_pci_dio.c | 4 ++++ drivers/staging/comedi/drivers/daqboard2000.c | 4 ++++ drivers/staging/comedi/drivers/das08.c | 4 ++++ drivers/staging/comedi/drivers/das16.c | 4 ++++ drivers/staging/comedi/drivers/das16m1.c | 4 ++++ drivers/staging/comedi/drivers/das1800.c | 4 ++++ drivers/staging/comedi/drivers/das6402.c | 4 ++++ drivers/staging/comedi/drivers/das800.c | 4 ++++ drivers/staging/comedi/drivers/dmm32at.c | 4 ++++ drivers/staging/comedi/drivers/dt2801.c | 4 ++++ drivers/staging/comedi/drivers/dt2811.c | 4 ++++ drivers/staging/comedi/drivers/dt2814.c | 4 ++++ drivers/staging/comedi/drivers/dt2815.c | 4 ++++ drivers/staging/comedi/drivers/dt2817.c | 4 ++++ drivers/staging/comedi/drivers/dt282x.c | 4 ++++ drivers/staging/comedi/drivers/dt3000.c | 4 ++++ drivers/staging/comedi/drivers/fl512.c | 4 ++++ drivers/staging/comedi/drivers/gsc_hpdi.c | 4 ++++ drivers/staging/comedi/drivers/icp_multi.c | 4 ++++ drivers/staging/comedi/drivers/ii_pci20kc.c | 4 ++++ drivers/staging/comedi/drivers/jr3_pci.c | 4 ++++ drivers/staging/comedi/drivers/ke_counter.c | 4 ++++ drivers/staging/comedi/drivers/me4000.c | 4 ++++ drivers/staging/comedi/drivers/me_daq.c | 4 ++++ drivers/staging/comedi/drivers/mite.c | 4 ++++ drivers/staging/comedi/drivers/mpc624.c | 4 ++++ drivers/staging/comedi/drivers/multiq3.c | 4 ++++ drivers/staging/comedi/drivers/ni_at_a2150.c | 4 ++++ drivers/staging/comedi/drivers/ni_at_ao.c | 4 ++++ drivers/staging/comedi/drivers/ni_atmio16d.c | 4 ++++ drivers/staging/comedi/drivers/ni_labpc.c | 4 ++++ drivers/staging/comedi/drivers/pcl711.c | 4 ++++ drivers/staging/comedi/drivers/pcl724.c | 4 ++++ drivers/staging/comedi/drivers/pcl725.c | 4 ++++ drivers/staging/comedi/drivers/pcl726.c | 4 ++++ drivers/staging/comedi/drivers/pcl730.c | 4 ++++ drivers/staging/comedi/drivers/pcl812.c | 4 ++++ drivers/staging/comedi/drivers/pcl816.c | 4 ++++ drivers/staging/comedi/drivers/pcl818.c | 4 ++++ drivers/staging/comedi/drivers/pcm3724.c | 4 ++++ drivers/staging/comedi/drivers/pcm3730.c | 4 ++++ drivers/staging/comedi/drivers/pcm_common.c | 4 ++++ drivers/staging/comedi/drivers/pcmad.c | 4 ++++ drivers/staging/comedi/drivers/pcmda12.c | 4 ++++ drivers/staging/comedi/drivers/pcmmio.c | 4 ++++ drivers/staging/comedi/drivers/pcmuio.c | 4 ++++ drivers/staging/comedi/drivers/poc.c | 4 ++++ drivers/staging/comedi/drivers/rtd520.c | 4 ++++ drivers/staging/comedi/drivers/rti800.c | 4 ++++ drivers/staging/comedi/drivers/rti802.c | 4 ++++ drivers/staging/comedi/drivers/s526.c | 4 ++++ drivers/staging/comedi/drivers/serial2002.c | 4 ++++ drivers/staging/comedi/drivers/skel.c | 4 ++++ drivers/staging/comedi/drivers/ssv_dnp.c | 4 ++++ drivers/staging/comedi/drivers/unioxx5.c | 4 ++++ 97 files changed, 384 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 41ef9207f99c..8daff9464fb4 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -61,13 +61,7 @@ module_init(x ## _init_module); \ module_exit(x ## _cleanup_module); -#define COMEDI_MODULE_MACROS \ - MODULE_AUTHOR("Comedi http://www.comedi.org"); \ - MODULE_DESCRIPTION("Comedi low-level driver"); \ - MODULE_LICENSE("GPL"); - #define COMEDI_INITCLEANUP(x) \ - COMEDI_MODULE_MACROS \ COMEDI_INITCLEANUP_NOMODULE(x) #define COMEDI_PCI_INITCLEANUP_NOMODULE(comedi_driver, pci_id_table) \ @@ -106,7 +100,6 @@ module_exit(comedi_driver ## _cleanup_module); #define COMEDI_PCI_INITCLEANUP(comedi_driver, pci_id_table) \ - COMEDI_MODULE_MACROS \ COMEDI_PCI_INITCLEANUP_NOMODULE(comedi_driver, pci_id_table) #define PCI_VENDOR_ID_ADLINK 0x144a diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c index fe63830bd850..0f83090488d5 100644 --- a/drivers/staging/comedi/drivers/8255.c +++ b/drivers/staging/comedi/drivers/8255.c @@ -457,3 +457,7 @@ static int dev_8255_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/acl7225b.c b/drivers/staging/comedi/drivers/acl7225b.c index e20c3542c069..1d0a8ea77950 100644 --- a/drivers/staging/comedi/drivers/acl7225b.c +++ b/drivers/staging/comedi/drivers/acl7225b.c @@ -150,3 +150,7 @@ static int acl7225b_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_035.c b/drivers/staging/comedi/drivers/addi_apci_035.c index 6dfcbe803f2d..4c00df4bc153 100644 --- a/drivers/staging/comedi/drivers/addi_apci_035.c +++ b/drivers/staging/comedi/drivers/addi_apci_035.c @@ -5,3 +5,7 @@ #define ADDIDATA_DRIVER_NAME "addi_apci_035" #include "addi-data/addi_common.c" + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c index 4722ec834f7b..7831ce33b02e 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1032.c +++ b/drivers/staging/comedi/drivers/addi_apci_1032.c @@ -3,3 +3,7 @@ #define ADDIDATA_DRIVER_NAME "addi_apci_1032" #include "addi-data/addi_common.c" + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index db3dafdcf691..bfd84f66d9c0 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -3,3 +3,7 @@ #define ADDIDATA_DRIVER_NAME "addi_apci_1500" #include "addi-data/addi_common.c" + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_1516.c b/drivers/staging/comedi/drivers/addi_apci_1516.c index f591baff6a0b..a12e2f421370 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1516.c +++ b/drivers/staging/comedi/drivers/addi_apci_1516.c @@ -3,3 +3,7 @@ #define ADDIDATA_DRIVER_NAME "addi_apci_1516" #include "addi-data/addi_common.c" + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c index 6f5c923ac226..1b9d598fb6ca 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1564.c +++ b/drivers/staging/comedi/drivers/addi_apci_1564.c @@ -3,3 +3,7 @@ #define ADDIDATA_DRIVER_NAME "addi_apci_1564" #include "addi-data/addi_common.c" + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_16xx.c b/drivers/staging/comedi/drivers/addi_apci_16xx.c index 1d926add9e6d..d54218d59c58 100644 --- a/drivers/staging/comedi/drivers/addi_apci_16xx.c +++ b/drivers/staging/comedi/drivers/addi_apci_16xx.c @@ -3,3 +3,7 @@ #define ADDIDATA_DRIVER_NAME "addi_apci_16xx" #include "addi-data/addi_common.c" + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_2016.c b/drivers/staging/comedi/drivers/addi_apci_2016.c index 7266e412f0a6..fa50c7bb7ade 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2016.c +++ b/drivers/staging/comedi/drivers/addi_apci_2016.c @@ -3,3 +3,7 @@ #define ADDIDATA_DRIVER_NAME "addi_apci_2016" #include "addi-data/addi_common.c" + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c b/drivers/staging/comedi/drivers/addi_apci_2032.c index f67da94119e8..073a8a56dbe4 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2032.c +++ b/drivers/staging/comedi/drivers/addi_apci_2032.c @@ -3,3 +3,7 @@ #define ADDIDATA_DRIVER_NAME "addi_apci_2032" #include "addi-data/addi_common.c" + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_2200.c b/drivers/staging/comedi/drivers/addi_apci_2200.c index bc7f7d653503..adfbb5d410ef 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2200.c +++ b/drivers/staging/comedi/drivers/addi_apci_2200.c @@ -3,3 +3,7 @@ #define ADDIDATA_DRIVER_NAME "addi_apci_2200" #include "addi-data/addi_common.c" + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_3001.c b/drivers/staging/comedi/drivers/addi_apci_3001.c index d86c4209cb90..00ac762965c1 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3001.c +++ b/drivers/staging/comedi/drivers/addi_apci_3001.c @@ -3,3 +3,7 @@ #define ADDIDATA_DRIVER_NAME "addi_apci_3001" #include "addi-data/addi_common.c" + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_3120.c b/drivers/staging/comedi/drivers/addi_apci_3120.c index 0b22cf10415d..c35515845cf3 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3120.c +++ b/drivers/staging/comedi/drivers/addi_apci_3120.c @@ -3,3 +3,7 @@ #define ADDIDATA_DRIVER_NAME "addi_apci_3120" #include "addi-data/addi_common.c" + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c b/drivers/staging/comedi/drivers/addi_apci_3501.c index d8a01b154e35..dd2c1d3bc18b 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3501.c +++ b/drivers/staging/comedi/drivers/addi_apci_3501.c @@ -3,3 +3,7 @@ #define ADDIDATA_DRIVER_NAME "addi_apci_3501" #include "addi-data/addi_common.c" + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/addi_apci_3xxx.c b/drivers/staging/comedi/drivers/addi_apci_3xxx.c index 942bc9e259a8..03161c88eac2 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3xxx.c +++ b/drivers/staging/comedi/drivers/addi_apci_3xxx.c @@ -3,3 +3,7 @@ #define ADDIDATA_DRIVER_NAME "addi_apci_3xxx" #include "addi-data/addi_common.c" + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c index 712b9e0788b6..3816115b18ce 100644 --- a/drivers/staging/comedi/drivers/adl_pci6208.c +++ b/drivers/staging/comedi/drivers/adl_pci6208.c @@ -408,3 +408,7 @@ pci6208_pci_setup(struct pci_dev *pci_dev, unsigned long *io_base_ptr, return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/adl_pci7230.c b/drivers/staging/comedi/drivers/adl_pci7230.c index 24a82eb9d153..46b5c5c27621 100644 --- a/drivers/staging/comedi/drivers/adl_pci7230.c +++ b/drivers/staging/comedi/drivers/adl_pci7230.c @@ -204,3 +204,7 @@ static int adl_pci7230_di_insn_bits(struct comedi_device *dev, } COMEDI_PCI_INITCLEANUP(driver_adl_pci7230, adl_pci7230_pci_table); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/adl_pci7296.c b/drivers/staging/comedi/drivers/adl_pci7296.c index 8602865ae6b7..e7c5d66ccd95 100644 --- a/drivers/staging/comedi/drivers/adl_pci7296.c +++ b/drivers/staging/comedi/drivers/adl_pci7296.c @@ -178,3 +178,7 @@ static int adl_pci7296_detach(struct comedi_device *dev) } COMEDI_PCI_INITCLEANUP(driver_adl_pci7296, adl_pci7296_pci_table); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/adl_pci7432.c b/drivers/staging/comedi/drivers/adl_pci7432.c index b5a9499e438c..d68fbe2bdad6 100644 --- a/drivers/staging/comedi/drivers/adl_pci7432.c +++ b/drivers/staging/comedi/drivers/adl_pci7432.c @@ -211,3 +211,7 @@ static int adl_pci7432_di_insn_bits(struct comedi_device *dev, } COMEDI_PCI_INITCLEANUP(driver_adl_pci7432, adl_pci7432_pci_table); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/adl_pci8164.c b/drivers/staging/comedi/drivers/adl_pci8164.c index da256a1e0b4d..5fafaf0ff999 100644 --- a/drivers/staging/comedi/drivers/adl_pci8164.c +++ b/drivers/staging/comedi/drivers/adl_pci8164.c @@ -390,3 +390,7 @@ static int adl_pci8164_insn_write_buf1(struct comedi_device *dev, } COMEDI_PCI_INITCLEANUP(driver_adl_pci8164, adl_pci8164_pci_table); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index 595689d5f17f..429a551bd5dd 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -1409,3 +1409,7 @@ static int pci9111_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index ccef549778e4..d6c17e268ccd 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -2432,3 +2432,7 @@ static int pci9118_detach(struct comedi_device *dev) /* ============================================================================== */ + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/adq12b.c b/drivers/staging/comedi/drivers/adq12b.c index f3ba645bf63b..f318a01dd57a 100644 --- a/drivers/staging/comedi/drivers/adq12b.c +++ b/drivers/staging/comedi/drivers/adq12b.c @@ -403,3 +403,7 @@ static int adq12b_do_insn_bits(struct comedi_device *dev, * as necessary. */ COMEDI_INITCLEANUP(driver_adq12b); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 67c4f11a36ab..dbb50cf7e83c 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -1613,3 +1613,7 @@ COMEDI_PCI_INITCLEANUP(driver_pci1710, pci1710_pci_table); /* ============================================================================== */ + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 9fe8fcc7f1d6..b973249fb224 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -497,3 +497,7 @@ static int pci1723_detach(struct comedi_device *dev) * as necessary. */ COMEDI_PCI_INITCLEANUP(driver_pci1723, pci1723_pci_table); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index e424a0c7d34f..e7ba1f0b4e68 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -1257,3 +1257,7 @@ COMEDI_PCI_INITCLEANUP(driver_pci_dio, pci_dio_pci_table); /* ============================================================================== */ + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/aio_aio12_8.c b/drivers/staging/comedi/drivers/aio_aio12_8.c index 7a1c636df5be..dc00c4b4a155 100644 --- a/drivers/staging/comedi/drivers/aio_aio12_8.c +++ b/drivers/staging/comedi/drivers/aio_aio12_8.c @@ -228,3 +228,7 @@ static struct comedi_driver driver_aio_aio12_8 = { }; COMEDI_INITCLEANUP(driver_aio_aio12_8); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c b/drivers/staging/comedi/drivers/aio_iiro_16.c index 4baef9ff932a..ad5e75babdd1 100644 --- a/drivers/staging/comedi/drivers/aio_iiro_16.c +++ b/drivers/staging/comedi/drivers/aio_iiro_16.c @@ -185,3 +185,7 @@ static int aio_iiro_16_dio_insn_bits_read(struct comedi_device *dev, } COMEDI_INITCLEANUP(driver_aio_iiro_16); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c index bf27617aa62d..9a60c214373e 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.c +++ b/drivers/staging/comedi/drivers/amplc_dio200.c @@ -1501,3 +1501,7 @@ static int dio200_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c index a307d68d79c6..e94fb3e3d0e8 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/drivers/staging/comedi/drivers/amplc_pc236.c @@ -664,3 +664,7 @@ static irqreturn_t pc236_interrupt(int irq, void *d) } return IRQ_RETVAL(handled); } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c index 15808e95ceab..14855e37476d 100644 --- a/drivers/staging/comedi/drivers/amplc_pc263.c +++ b/drivers/staging/comedi/drivers/amplc_pc263.c @@ -436,3 +436,7 @@ COMEDI_PCI_INITCLEANUP(driver_amplc_pc263, pc263_pci_table); #else COMEDI_INITCLEANUP(driver_amplc_pc263); #endif + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index c486a878e180..a27e27f5b7b8 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -1557,3 +1557,7 @@ static int pci224_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 7fffd967d47e..53d34147813b 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -3014,3 +3014,7 @@ static int pci230_ai_cancel(struct comedi_device *dev, pci230_ai_stop(dev, s); return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/c6xdigio.c b/drivers/staging/comedi/drivers/c6xdigio.c index fb0d5fa71765..d830176bbd02 100644 --- a/drivers/staging/comedi/drivers/c6xdigio.c +++ b/drivers/staging/comedi/drivers/c6xdigio.c @@ -518,3 +518,7 @@ static int c6xdigio_detach(struct comedi_device *dev) } COMEDI_INITCLEANUP(driver_c6xdigio); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 434591de37c5..04c71704507f 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -1872,3 +1872,7 @@ static int nvram_read(struct comedi_device *dev, unsigned int address, * as necessary. */ COMEDI_PCI_INITCLEANUP(driver_cb_pcidas, cb_pcidas_pci_table); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 79aa286e9bb4..168a33511648 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -4303,3 +4303,7 @@ static void i2c_write(struct comedi_device *dev, unsigned int address, } i2c_stop(dev); } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/cb_pcidda.c b/drivers/staging/comedi/drivers/cb_pcidda.c index 81829d6fd287..3c2a84e2065b 100644 --- a/drivers/staging/comedi/drivers/cb_pcidda.c +++ b/drivers/staging/comedi/drivers/cb_pcidda.c @@ -858,3 +858,7 @@ static void cb_pcidda_calibrate(struct comedi_device *dev, unsigned int channel, * as necessary. */ COMEDI_PCI_INITCLEANUP(driver_cb_pcidda, cb_pcidda_pci_table); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/cb_pcidio.c b/drivers/staging/comedi/drivers/cb_pcidio.c index 38ccd105fa35..3afba5fd85d6 100644 --- a/drivers/staging/comedi/drivers/cb_pcidio.c +++ b/drivers/staging/comedi/drivers/cb_pcidio.c @@ -301,3 +301,7 @@ static int pcidio_detach(struct comedi_device *dev) * as necessary. */ COMEDI_PCI_INITCLEANUP(driver_cb_pcidio, pcidio_pci_table); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index 49dccbbd713f..bb5553d6b360 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -492,3 +492,7 @@ static int cb_pcimdas_ao_rinsn(struct comedi_device *dev, * as necessary. */ COMEDI_PCI_INITCLEANUP(driver_cb_pcimdas, cb_pcimdas_pci_table); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/comedi_parport.c b/drivers/staging/comedi/drivers/comedi_parport.c index fcd7721c5537..9cf76fdd7cb1 100644 --- a/drivers/staging/comedi/drivers/comedi_parport.c +++ b/drivers/staging/comedi/drivers/comedi_parport.c @@ -396,3 +396,7 @@ static int parport_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index ef83a1a445ba..a21fe2e47a4e 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -549,3 +549,7 @@ static int waveform_ao_insn_write(struct comedi_device *dev, return insn->n; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c b/drivers/staging/comedi/drivers/contec_pci_dio.c index 9511814e6413..a3d55f46f0fb 100644 --- a/drivers/staging/comedi/drivers/contec_pci_dio.c +++ b/drivers/staging/comedi/drivers/contec_pci_dio.c @@ -233,3 +233,7 @@ static int contec_di_insn_bits(struct comedi_device *dev, } COMEDI_PCI_INITCLEANUP(driver_contec, contec_pci_table); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 078ec273b277..83cde27ab725 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -888,3 +888,7 @@ static int daqboard2000_detach(struct comedi_device *dev) } COMEDI_PCI_INITCLEANUP(driver_daqboard2000, daqboard2000_pci_table); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 9cb144f7e70c..3a52a0c0f926 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -1090,3 +1090,7 @@ COMEDI_INITCLEANUP(driver_das08); #ifdef CONFIG_COMEDI_PCMCIA EXPORT_SYMBOL_GPL(das08_cs_boards); #endif + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index ccee4f1802d6..407d011a7606 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -1776,3 +1776,7 @@ static void das16_ai_munge(struct comedi_device *dev, } } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index c403d8827434..387a8cbe855d 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -777,3 +777,7 @@ static int das16m1_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index de5e82fec878..a68a1e47db82 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -1800,3 +1800,7 @@ static unsigned int suggest_transfer_size(struct comedi_cmd *cmd) return size; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c index a404a1831911..3aac876869dd 100644 --- a/drivers/staging/comedi/drivers/das6402.c +++ b/drivers/staging/comedi/drivers/das6402.c @@ -360,3 +360,7 @@ static int das6402_attach(struct comedi_device *dev, return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index aadc4971c909..b4083af4a66a 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -905,3 +905,7 @@ static int das800_set_frequency(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index d5cbd515c370..572b7a9e8673 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -1096,3 +1096,7 @@ void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec) * as necessary. */ COMEDI_INITCLEANUP(driver_dmm32at); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c index 83fb6e56c3e9..a6f1546b39e5 100644 --- a/drivers/staging/comedi/drivers/dt2801.c +++ b/drivers/staging/comedi/drivers/dt2801.c @@ -720,3 +720,7 @@ static int dt2801_dio_insn_config(struct comedi_device *dev, return 1; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index ea9bfb7fd88e..2d103eb1ebc8 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -625,3 +625,7 @@ static int dt2811_do_insn_bits(struct comedi_device *dev, return 2; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/dt2814.c b/drivers/staging/comedi/drivers/dt2814.c index 16fde066d266..0871fe0dc46f 100644 --- a/drivers/staging/comedi/drivers/dt2814.c +++ b/drivers/staging/comedi/drivers/dt2814.c @@ -387,3 +387,7 @@ static irqreturn_t dt2814_interrupt(int irq, void *d) comedi_event(dev, s); return IRQ_HANDLED; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/dt2815.c b/drivers/staging/comedi/drivers/dt2815.c index d1a4f7822433..8ff420eda1b1 100644 --- a/drivers/staging/comedi/drivers/dt2815.c +++ b/drivers/staging/comedi/drivers/dt2815.c @@ -255,3 +255,7 @@ static int dt2815_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/dt2817.c b/drivers/staging/comedi/drivers/dt2817.c index 54e0dea0fc59..019aa4dfeeb3 100644 --- a/drivers/staging/comedi/drivers/dt2817.c +++ b/drivers/staging/comedi/drivers/dt2817.c @@ -180,3 +180,7 @@ static int dt2817_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index fd8728c83669..58a2fdfcd340 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -1502,3 +1502,7 @@ static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index ca687890fc12..79ea24d2ce5a 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -991,3 +991,7 @@ static struct pci_dev *dt_pci_find_device(struct pci_dev *from, int *board) *board = -1; return from; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/fl512.c b/drivers/staging/comedi/drivers/fl512.c index a10a2b070a24..19f018438612 100644 --- a/drivers/staging/comedi/drivers/fl512.c +++ b/drivers/staging/comedi/drivers/fl512.c @@ -205,3 +205,7 @@ static int fl512_detach(struct comedi_device *dev) printk(KERN_INFO "comedi%d: fl512: dummy i detach\n", dev->minor); return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index 17c4f1f8117d..a24d0994a195 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -1076,3 +1076,7 @@ static int hpdi_cancel(struct comedi_device *dev, struct comedi_subdevice *s) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c index fa0e48173bd4..ba42478e6e1c 100644 --- a/drivers/staging/comedi/drivers/icp_multi.c +++ b/drivers/staging/comedi/drivers/icp_multi.c @@ -1125,3 +1125,7 @@ static int icp_multi_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index e26c1b88ebeb..0951f0e28a64 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -641,3 +641,7 @@ static unsigned int pci20xxx_di(struct comedi_device *dev, #endif COMEDI_INITCLEANUP(driver_pci20xxx); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c index 4683a0b90f22..35a789226997 100644 --- a/drivers/staging/comedi/drivers/jr3_pci.c +++ b/drivers/staging/comedi/drivers/jr3_pci.c @@ -988,3 +988,7 @@ static int jr3_pci_detach(struct comedi_device *dev) } COMEDI_PCI_INITCLEANUP(driver_jr3_pci, jr3_pci_pci_table); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ke_counter.c b/drivers/staging/comedi/drivers/ke_counter.c index 73b0445e310f..35d9869884db 100644 --- a/drivers/staging/comedi/drivers/ke_counter.c +++ b/drivers/staging/comedi/drivers/ke_counter.c @@ -259,3 +259,7 @@ static int cnt_detach(struct comedi_device *dev) dev->minor); return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index 8b9fa0f9f1f6..58df32676e41 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -2384,3 +2384,7 @@ static int me4000_cnt_insn_write(struct comedi_device *dev, } COMEDI_PCI_INITCLEANUP(driver_me4000, me4000_pci_table); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index c8484aec657d..d03c0f79ce45 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -857,3 +857,7 @@ static int me_detach(struct comedi_device *dev) } return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 99d9985c5b37..4b7d207ab14d 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -829,3 +829,7 @@ void __exit cleanup_module(void) mite_cleanup(); } #endif + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/mpc624.c b/drivers/staging/comedi/drivers/mpc624.c index 9874ac3749c3..df001e1738a0 100644 --- a/drivers/staging/comedi/drivers/mpc624.c +++ b/drivers/staging/comedi/drivers/mpc624.c @@ -407,3 +407,7 @@ static int mpc624_ai_rinsn(struct comedi_device *dev, } COMEDI_INITCLEANUP(driver_mpc624); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/multiq3.c b/drivers/staging/comedi/drivers/multiq3.c index 6b22f0f8f06a..41bc51da388c 100644 --- a/drivers/staging/comedi/drivers/multiq3.c +++ b/drivers/staging/comedi/drivers/multiq3.c @@ -338,3 +338,7 @@ static int multiq3_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index 9bff34cf06d1..709fc85ac703 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -910,3 +910,7 @@ static int a2150_set_chanlist(struct comedi_device *dev, return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c index ce60224bb7bf..be1ddf28a549 100644 --- a/drivers/staging/comedi/drivers/ni_at_ao.c +++ b/drivers/staging/comedi/drivers/ni_at_ao.c @@ -459,3 +459,7 @@ static int atao_calib_insn_write(struct comedi_device *dev, return insn->n; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index cf4f241f210a..78fdf7bfb33a 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -887,3 +887,7 @@ static int atmio16d_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index 0e3ac5a5b050..4966c8e496d5 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -2088,3 +2088,7 @@ EXPORT_SYMBOL_GPL(labpc_common_detach); EXPORT_SYMBOL_GPL(range_labpc_1200_ai); EXPORT_SYMBOL_GPL(labpc_1200_ai_gain_bits); EXPORT_SYMBOL_GPL(labpc_1200_is_unipolar); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index a499f7070f72..870c40a75463 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -628,3 +628,7 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcl724.c b/drivers/staging/comedi/drivers/pcl724.c index 0f103c328064..2811060b424b 100644 --- a/drivers/staging/comedi/drivers/pcl724.c +++ b/drivers/staging/comedi/drivers/pcl724.c @@ -221,3 +221,7 @@ static int pcl724_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcl725.c b/drivers/staging/comedi/drivers/pcl725.c index 60261f4ba5b4..cab4c13fff99 100644 --- a/drivers/staging/comedi/drivers/pcl725.c +++ b/drivers/staging/comedi/drivers/pcl725.c @@ -110,3 +110,7 @@ static int pcl725_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcl726.c b/drivers/staging/comedi/drivers/pcl726.c index 6a1a9790a907..e54463136cc8 100644 --- a/drivers/staging/comedi/drivers/pcl726.c +++ b/drivers/staging/comedi/drivers/pcl726.c @@ -381,3 +381,7 @@ static int pcl726_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcl730.c b/drivers/staging/comedi/drivers/pcl730.c index e5e7bed21de0..7d4f29a71423 100644 --- a/drivers/staging/comedi/drivers/pcl730.c +++ b/drivers/staging/comedi/drivers/pcl730.c @@ -166,3 +166,7 @@ static int pcl730_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 1ddc19c705a6..b82c37c5d167 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -1660,3 +1660,7 @@ static int pcl812_detach(struct comedi_device *dev) free_resources(dev); return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index 71c2a3aa379e..c26dfad2c897 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -1285,3 +1285,7 @@ static int pcl816_detach(struct comedi_device *dev) #endif return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 9d6aa393ef13..887f1c37aa6b 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -2036,3 +2036,7 @@ static int pcl818_detach(struct comedi_device *dev) free_resources(dev); return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c index ed6103079232..972cd2bdf454 100644 --- a/drivers/staging/comedi/drivers/pcm3724.c +++ b/drivers/staging/comedi/drivers/pcm3724.c @@ -307,3 +307,7 @@ static int pcm3724_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcm3730.c b/drivers/staging/comedi/drivers/pcm3730.c index 22b7aae63add..3c826b7b8e75 100644 --- a/drivers/staging/comedi/drivers/pcm3730.c +++ b/drivers/staging/comedi/drivers/pcm3730.c @@ -154,3 +154,7 @@ static int pcm3730_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcm_common.c b/drivers/staging/comedi/drivers/pcm_common.c index 52c2a6698214..474af7bc6c8b 100644 --- a/drivers/staging/comedi/drivers/pcm_common.c +++ b/drivers/staging/comedi/drivers/pcm_common.c @@ -109,3 +109,7 @@ int comedi_pcm_cmdtest(struct comedi_device *dev, return 0; } EXPORT_SYMBOL(comedi_pcm_cmdtest); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcmad.c b/drivers/staging/comedi/drivers/pcmad.c index fab8092bd7aa..9f63a6cacfca 100644 --- a/drivers/staging/comedi/drivers/pcmad.c +++ b/drivers/staging/comedi/drivers/pcmad.c @@ -176,3 +176,7 @@ static int pcmad_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcmda12.c b/drivers/staging/comedi/drivers/pcmda12.c index 7133eb0352bc..b09c0da8690c 100644 --- a/drivers/staging/comedi/drivers/pcmda12.c +++ b/drivers/staging/comedi/drivers/pcmda12.c @@ -304,3 +304,7 @@ static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, * as necessary. */ COMEDI_INITCLEANUP(driver); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index 025a52e8981d..3e80da04277f 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -1334,3 +1334,7 @@ static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, * as necessary. */ COMEDI_INITCLEANUP(driver); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index 5af4c8448a3a..785b3ec8fec8 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c @@ -1019,3 +1019,7 @@ pcmuio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, * as necessary. */ COMEDI_INITCLEANUP(driver); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/poc.c b/drivers/staging/comedi/drivers/poc.c index 1ebc356ce40e..9270b9f15823 100644 --- a/drivers/staging/comedi/drivers/poc.c +++ b/drivers/staging/comedi/drivers/poc.c @@ -249,3 +249,7 @@ static int pcl734_insn_bits(struct comedi_device *dev, } COMEDI_INITCLEANUP(driver_poc); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 8626658e778c..1ca92f949362 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -2357,3 +2357,7 @@ static int rtd_dio_insn_config(struct comedi_device *dev, * as necessary. */ COMEDI_PCI_INITCLEANUP(rtd520Driver, rtd520_pci_table); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/rti800.c b/drivers/staging/comedi/drivers/rti800.c index 028ed6f89c4c..4add63328508 100644 --- a/drivers/staging/comedi/drivers/rti800.c +++ b/drivers/staging/comedi/drivers/rti800.c @@ -475,3 +475,7 @@ static int rti800_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/rti802.c b/drivers/staging/comedi/drivers/rti802.c index 2157edcf7997..132415b2d005 100644 --- a/drivers/staging/comedi/drivers/rti802.c +++ b/drivers/staging/comedi/drivers/rti802.c @@ -150,3 +150,7 @@ static int rti802_detach(struct comedi_device *dev) return 0; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c index 07c21e686f27..8afed1307bdd 100644 --- a/drivers/staging/comedi/drivers/s526.c +++ b/drivers/staging/comedi/drivers/s526.c @@ -1003,3 +1003,7 @@ static int s526_dio_insn_config(struct comedi_device *dev, * as necessary. */ COMEDI_INITCLEANUP(driver_s526); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index 5886ebfd043a..85d127fb7eb1 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -918,3 +918,7 @@ static int serial2002_detach(struct comedi_device *dev) } COMEDI_INITCLEANUP(driver_serial2002); + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index 490753b3d904..5a0767333bbc 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -629,3 +629,7 @@ COMEDI_INITCLEANUP(driver_skel); * instead. */ /* COMEDI_PCI_INITCLEANUP(driver_skel, skel_pci_table) */ + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/ssv_dnp.c b/drivers/staging/comedi/drivers/ssv_dnp.c index 18b0a83c4bbc..ce0cbb4c37bf 100644 --- a/drivers/staging/comedi/drivers/ssv_dnp.c +++ b/drivers/staging/comedi/drivers/ssv_dnp.c @@ -314,3 +314,7 @@ static int dnp_dio_insn_config(struct comedi_device *dev, return 1; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/comedi/drivers/unioxx5.c b/drivers/staging/comedi/drivers/unioxx5.c index d5f6d758a8be..1aca98895f83 100644 --- a/drivers/staging/comedi/drivers/unioxx5.c +++ b/drivers/staging/comedi/drivers/unioxx5.c @@ -529,3 +529,7 @@ static int __unioxx5_define_chan_offset(int chan_num) return (chan_num >> 3) + 1; } + +MODULE_AUTHOR("Comedi http://www.comedi.org"); +MODULE_DESCRIPTION("Comedi low-level driver"); +MODULE_LICENSE("GPL"); From 7114a28011f9d5f3d981731ad341177c21f9d948 Mon Sep 17 00:00:00 2001 From: Arun Thomas Date: Sun, 6 Jun 2010 22:23:30 +0200 Subject: [PATCH 025/523] Staging: comedi: Remove COMEDI_INITCLEANUP macro Move the init/exit routines to the respective C source files instead of calling COMEDI_INITCLEANUP Signed-off-by: Arun Thomas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 11 ----------- drivers/staging/comedi/drivers/8255.c | 13 ++++++++++++- drivers/staging/comedi/drivers/acl7225b.c | 13 ++++++++++++- drivers/staging/comedi/drivers/adq12b.c | 13 ++++++++++++- drivers/staging/comedi/drivers/aio_aio12_8.c | 13 ++++++++++++- drivers/staging/comedi/drivers/aio_iiro_16.c | 13 ++++++++++++- drivers/staging/comedi/drivers/amplc_dio200.c | 13 ++++++++++++- drivers/staging/comedi/drivers/amplc_pc236.c | 13 ++++++++++++- drivers/staging/comedi/drivers/amplc_pc263.c | 13 ++++++++++++- drivers/staging/comedi/drivers/c6xdigio.c | 13 ++++++++++++- drivers/staging/comedi/drivers/cb_das16_cs.c | 13 ++++++++++++- drivers/staging/comedi/drivers/comedi_parport.c | 13 ++++++++++++- drivers/staging/comedi/drivers/comedi_test.c | 13 ++++++++++++- drivers/staging/comedi/drivers/das08.c | 13 ++++++++++++- drivers/staging/comedi/drivers/das16.c | 13 ++++++++++++- drivers/staging/comedi/drivers/das16m1.c | 13 ++++++++++++- drivers/staging/comedi/drivers/das1800.c | 13 ++++++++++++- drivers/staging/comedi/drivers/das6402.c | 13 ++++++++++++- drivers/staging/comedi/drivers/das800.c | 13 ++++++++++++- drivers/staging/comedi/drivers/dmm32at.c | 13 ++++++++++++- drivers/staging/comedi/drivers/dt2801.c | 13 ++++++++++++- drivers/staging/comedi/drivers/dt2811.c | 13 ++++++++++++- drivers/staging/comedi/drivers/dt2814.c | 13 ++++++++++++- drivers/staging/comedi/drivers/dt2815.c | 13 ++++++++++++- drivers/staging/comedi/drivers/dt2817.c | 13 ++++++++++++- drivers/staging/comedi/drivers/dt282x.c | 13 ++++++++++++- drivers/staging/comedi/drivers/fl512.c | 13 ++++++++++++- drivers/staging/comedi/drivers/icp_multi.c | 13 ++++++++++++- drivers/staging/comedi/drivers/ii_pci20kc.c | 13 ++++++++++++- drivers/staging/comedi/drivers/mpc624.c | 13 ++++++++++++- drivers/staging/comedi/drivers/mpc8260cpm.c | 13 ++++++++++++- drivers/staging/comedi/drivers/multiq3.c | 13 ++++++++++++- drivers/staging/comedi/drivers/ni_at_a2150.c | 13 ++++++++++++- drivers/staging/comedi/drivers/ni_at_ao.c | 13 ++++++++++++- drivers/staging/comedi/drivers/ni_atmio.c | 13 ++++++++++++- drivers/staging/comedi/drivers/ni_atmio16d.c | 13 ++++++++++++- drivers/staging/comedi/drivers/ni_labpc.c | 13 ++++++++++++- drivers/staging/comedi/drivers/pcl711.c | 13 ++++++++++++- drivers/staging/comedi/drivers/pcl724.c | 13 ++++++++++++- drivers/staging/comedi/drivers/pcl725.c | 13 ++++++++++++- drivers/staging/comedi/drivers/pcl726.c | 13 ++++++++++++- drivers/staging/comedi/drivers/pcl730.c | 13 ++++++++++++- drivers/staging/comedi/drivers/pcl812.c | 13 ++++++++++++- drivers/staging/comedi/drivers/pcl816.c | 13 ++++++++++++- drivers/staging/comedi/drivers/pcl818.c | 13 ++++++++++++- drivers/staging/comedi/drivers/pcm3724.c | 13 ++++++++++++- drivers/staging/comedi/drivers/pcm3730.c | 13 ++++++++++++- drivers/staging/comedi/drivers/pcmad.c | 13 ++++++++++++- drivers/staging/comedi/drivers/pcmda12.c | 13 ++++++++++++- drivers/staging/comedi/drivers/pcmmio.c | 13 ++++++++++++- drivers/staging/comedi/drivers/pcmuio.c | 13 ++++++++++++- drivers/staging/comedi/drivers/poc.c | 13 ++++++++++++- drivers/staging/comedi/drivers/rti800.c | 13 ++++++++++++- drivers/staging/comedi/drivers/rti802.c | 13 ++++++++++++- drivers/staging/comedi/drivers/s526.c | 13 ++++++++++++- drivers/staging/comedi/drivers/serial2002.c | 13 ++++++++++++- drivers/staging/comedi/drivers/skel.c | 17 ++++++++++++----- drivers/staging/comedi/drivers/ssv_dnp.c | 13 ++++++++++++- drivers/staging/comedi/drivers/unioxx5.c | 13 ++++++++++++- 59 files changed, 696 insertions(+), 73 deletions(-) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 8daff9464fb4..8e0106520c2f 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -53,17 +53,6 @@ COMEDI_MINORVERSION, COMEDI_MICROVERSION) #define COMEDI_RELEASE VERSION -#define COMEDI_INITCLEANUP_NOMODULE(x) \ - static int __init x ## _init_module(void) \ - {return comedi_driver_register(&(x)); } \ - static void __exit x ## _cleanup_module(void) \ - {comedi_driver_unregister(&(x)); } \ - module_init(x ## _init_module); \ - module_exit(x ## _cleanup_module); - -#define COMEDI_INITCLEANUP(x) \ - COMEDI_INITCLEANUP_NOMODULE(x) - #define COMEDI_PCI_INITCLEANUP_NOMODULE(comedi_driver, pci_id_table) \ static int __devinit comedi_driver ## _pci_probe(struct pci_dev *dev, \ const struct pci_device_id *ent) \ diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c index 0f83090488d5..95049a8d3b38 100644 --- a/drivers/staging/comedi/drivers/8255.c +++ b/drivers/staging/comedi/drivers/8255.c @@ -117,7 +117,18 @@ static struct comedi_driver driver_8255 = { .detach = dev_8255_detach, }; -COMEDI_INITCLEANUP(driver_8255); +static int __init driver_8255_init_module(void) +{ + return comedi_driver_register(&driver_8255); +} + +static void __exit driver_8255_cleanup_module(void) +{ + comedi_driver_unregister(&driver_8255); +} + +module_init(driver_8255_init_module); +module_exit(driver_8255_cleanup_module); static void do_config(struct comedi_device *dev, struct comedi_subdevice *s); diff --git a/drivers/staging/comedi/drivers/acl7225b.c b/drivers/staging/comedi/drivers/acl7225b.c index 1d0a8ea77950..9def2250bb80 100644 --- a/drivers/staging/comedi/drivers/acl7225b.c +++ b/drivers/staging/comedi/drivers/acl7225b.c @@ -49,7 +49,18 @@ static struct comedi_driver driver_acl7225b = { .offset = sizeof(struct boardtype), }; -COMEDI_INITCLEANUP(driver_acl7225b); +static int __init driver_acl7225b_init_module(void) +{ + return comedi_driver_register(&driver_acl7225b); +} + +static void __exit driver_acl7225b_cleanup_module(void) +{ + comedi_driver_unregister(&driver_acl7225b); +} + +module_init(driver_acl7225b_init_module); +module_exit(driver_acl7225b_cleanup_module); static int acl7225b_do_insn(struct comedi_device *dev, struct comedi_subdevice *s, diff --git a/drivers/staging/comedi/drivers/adq12b.c b/drivers/staging/comedi/drivers/adq12b.c index f318a01dd57a..4b470000b69c 100644 --- a/drivers/staging/comedi/drivers/adq12b.c +++ b/drivers/staging/comedi/drivers/adq12b.c @@ -402,7 +402,18 @@ static int adq12b_do_insn_bits(struct comedi_device *dev, * A convenient macro that defines init_module() and cleanup_module(), * as necessary. */ -COMEDI_INITCLEANUP(driver_adq12b); +static int __init driver_adq12b_init_module(void) +{ + return comedi_driver_register(&driver_adq12b); +} + +static void __exit driver_adq12b_cleanup_module(void) +{ + comedi_driver_unregister(&driver_adq12b); +} + +module_init(driver_adq12b_init_module); +module_exit(driver_adq12b_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/aio_aio12_8.c b/drivers/staging/comedi/drivers/aio_aio12_8.c index dc00c4b4a155..1728cc013d16 100644 --- a/drivers/staging/comedi/drivers/aio_aio12_8.c +++ b/drivers/staging/comedi/drivers/aio_aio12_8.c @@ -227,7 +227,18 @@ static struct comedi_driver driver_aio_aio12_8 = { .offset = sizeof(struct aio12_8_boardtype), }; -COMEDI_INITCLEANUP(driver_aio_aio12_8); +static int __init driver_aio_aio12_8_init_module(void) +{ + return comedi_driver_register(&driver_aio_aio12_8); +} + +static void __exit driver_aio_aio12_8_cleanup_module(void) +{ + comedi_driver_unregister(&driver_aio_aio12_8); +} + +module_init(driver_aio_aio12_8_init_module); +module_exit(driver_aio_aio12_8_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c b/drivers/staging/comedi/drivers/aio_iiro_16.c index ad5e75babdd1..487599531fed 100644 --- a/drivers/staging/comedi/drivers/aio_iiro_16.c +++ b/drivers/staging/comedi/drivers/aio_iiro_16.c @@ -184,7 +184,18 @@ static int aio_iiro_16_dio_insn_bits_read(struct comedi_device *dev, return 2; } -COMEDI_INITCLEANUP(driver_aio_iiro_16); +static int __init driver_aio_iiro_16_init_module(void) +{ + return comedi_driver_register(&driver_aio_iiro_16); +} + +static void __exit driver_aio_iiro_16_cleanup_module(void) +{ + comedi_driver_unregister(&driver_aio_iiro_16); +} + +module_init(driver_aio_iiro_16_init_module); +module_exit(driver_aio_iiro_16_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c index 9a60c214373e..674cf1df7e2c 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.c +++ b/drivers/staging/comedi/drivers/amplc_dio200.c @@ -496,7 +496,18 @@ static struct comedi_driver driver_amplc_dio200 = { #ifdef CONFIG_COMEDI_PCI COMEDI_PCI_INITCLEANUP(driver_amplc_dio200, dio200_pci_table); #else -COMEDI_INITCLEANUP(driver_amplc_dio200); +static int __init driver_amplc_dio200_init_module(void) +{ + return comedi_driver_register(&driver_amplc_dio200); +} + +static void __exit driver_amplc_dio200_cleanup_module(void) +{ + comedi_driver_unregister(&driver_amplc_dio200); +} + +module_init(driver_amplc_dio200_init_module); +module_exit(driver_amplc_dio200_cleanup_module); #endif /* diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c index e94fb3e3d0e8..5ffee055c9a9 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/drivers/staging/comedi/drivers/amplc_pc236.c @@ -184,7 +184,18 @@ static struct comedi_driver driver_amplc_pc236 = { #ifdef CONFIG_COMEDI_PCI COMEDI_PCI_INITCLEANUP(driver_amplc_pc236, pc236_pci_table); #else -COMEDI_INITCLEANUP(driver_amplc_pc236); +static int __init driver_amplc_pc236_init_module(void) +{ + return comedi_driver_register(&driver_amplc_pc236); +} + +static void __exit driver_amplc_pc236_cleanup_module(void) +{ + comedi_driver_unregister(&driver_amplc_pc236); +} + +module_init(driver_amplc_pc236_init_module); +module_exit(driver_amplc_pc236_cleanup_module); #endif static int pc236_request_region(unsigned minor, unsigned long from, diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c index 14855e37476d..83af437eb436 100644 --- a/drivers/staging/comedi/drivers/amplc_pc263.c +++ b/drivers/staging/comedi/drivers/amplc_pc263.c @@ -434,7 +434,18 @@ static int pc263_dio_insn_config(struct comedi_device *dev, #ifdef CONFIG_COMEDI_PCI COMEDI_PCI_INITCLEANUP(driver_amplc_pc263, pc263_pci_table); #else -COMEDI_INITCLEANUP(driver_amplc_pc263); +static int __init driver_amplc_pc263_init_module(void) +{ + return comedi_driver_register(&driver_amplc_pc263); +} + +static void __exit driver_amplc_pc263_cleanup_module(void) +{ + comedi_driver_unregister(&driver_amplc_pc263); +} + +module_init(driver_amplc_pc263_init_module); +module_exit(driver_amplc_pc263_cleanup_module); #endif MODULE_AUTHOR("Comedi http://www.comedi.org"); diff --git a/drivers/staging/comedi/drivers/c6xdigio.c b/drivers/staging/comedi/drivers/c6xdigio.c index d830176bbd02..e0ac825ea58a 100644 --- a/drivers/staging/comedi/drivers/c6xdigio.c +++ b/drivers/staging/comedi/drivers/c6xdigio.c @@ -517,7 +517,18 @@ static int c6xdigio_detach(struct comedi_device *dev) return 0; } -COMEDI_INITCLEANUP(driver_c6xdigio); +static int __init driver_c6xdigio_init_module(void) +{ + return comedi_driver_register(&driver_c6xdigio); +} + +static void __exit driver_c6xdigio_cleanup_module(void) +{ + comedi_driver_unregister(&driver_c6xdigio); +} + +module_init(driver_c6xdigio_init_module); +module_exit(driver_c6xdigio_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index d8d4ed6de35c..6d893c65adc8 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -880,5 +880,16 @@ void __exit cleanup_module(void) } #else -COMEDI_INITCLEANUP(driver_das16cs); +static int __init driver_das16cs_init_module(void) +{ + return comedi_driver_register(&driver_das16cs); +} + +static void __exit driver_das16cs_cleanup_module(void) +{ + comedi_driver_unregister(&driver_das16cs); +} + +module_init(driver_das16cs_init_module); +module_exit(driver_das16cs_cleanup_module); #endif /* CONFIG_PCMCIA */ diff --git a/drivers/staging/comedi/drivers/comedi_parport.c b/drivers/staging/comedi/drivers/comedi_parport.c index 9cf76fdd7cb1..21d834dd92b6 100644 --- a/drivers/staging/comedi/drivers/comedi_parport.c +++ b/drivers/staging/comedi/drivers/comedi_parport.c @@ -101,7 +101,18 @@ static struct comedi_driver driver_parport = { .detach = parport_detach, }; -COMEDI_INITCLEANUP(driver_parport); +static int __init driver_parport_init_module(void) +{ + return comedi_driver_register(&driver_parport); +} + +static void __exit driver_parport_cleanup_module(void) +{ + comedi_driver_unregister(&driver_parport); +} + +module_init(driver_parport_init_module); +module_exit(driver_parport_cleanup_module); struct parport_private { unsigned int a_data; diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index a21fe2e47a4e..b220b3055412 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -107,7 +107,18 @@ static struct comedi_driver driver_waveform = { .num_names = ARRAY_SIZE(waveform_boards), }; -COMEDI_INITCLEANUP(driver_waveform); +static int __init driver_waveform_init_module(void) +{ + return comedi_driver_register(&driver_waveform); +} + +static void __exit driver_waveform_cleanup_module(void) +{ + comedi_driver_unregister(&driver_waveform); +} + +module_init(driver_waveform_init_module); +module_exit(driver_waveform_cleanup_module); static int waveform_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 3a52a0c0f926..c3f1fedc6eb7 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -1084,7 +1084,18 @@ EXPORT_SYMBOL_GPL(das08_common_detach); #ifdef CONFIG_COMEDI_PCI COMEDI_PCI_INITCLEANUP(driver_das08, das08_pci_table); #else -COMEDI_INITCLEANUP(driver_das08); +static int __init driver_das08_init_module(void) +{ + return comedi_driver_register(&driver_das08); +} + +static void __exit driver_das08_cleanup_module(void) +{ + comedi_driver_unregister(&driver_das08); +} + +module_init(driver_das08_init_module); +module_exit(driver_das08_cleanup_module); #endif #ifdef CONFIG_COMEDI_PCMCIA diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index 407d011a7606..0af1b4659088 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -1717,7 +1717,18 @@ static int das16_detach(struct comedi_device *dev) return 0; } -COMEDI_INITCLEANUP(driver_das16); +static int __init driver_das16_init_module(void) +{ + return comedi_driver_register(&driver_das16); +} + +static void __exit driver_das16_cleanup_module(void) +{ + comedi_driver_unregister(&driver_das16); +} + +module_init(driver_das16_init_module); +module_exit(driver_das16_cleanup_module); /* utility function that suggests a dma transfer size in bytes */ static unsigned int das16_suggest_transfer_size(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index 387a8cbe855d..a5ce3b2abe4a 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -198,7 +198,18 @@ struct das16m1_private_struct { #define devpriv ((struct das16m1_private_struct *)(dev->private)) #define thisboard ((const struct das16m1_board *)(dev->board_ptr)) -COMEDI_INITCLEANUP(driver_das16m1); +static int __init driver_das16m1_init_module(void) +{ + return comedi_driver_register(&driver_das16m1); +} + +static void __exit driver_das16m1_cleanup_module(void) +{ + comedi_driver_unregister(&driver_das16m1); +} + +module_init(driver_das16m1_init_module); +module_exit(driver_das16m1_cleanup_module); static inline short munge_sample(short data) { diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index a68a1e47db82..6ea93f9c0b48 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -531,7 +531,18 @@ static struct comedi_driver driver_das1800 = { * A convenient macro that defines init_module() and cleanup_module(), * as necessary. */ -COMEDI_INITCLEANUP(driver_das1800); +static int __init driver_das1800_init_module(void) +{ + return comedi_driver_register(&driver_das1800); +} + +static void __exit driver_das1800_cleanup_module(void) +{ + comedi_driver_unregister(&driver_das1800); +} + +module_init(driver_das1800_init_module); +module_exit(driver_das1800_cleanup_module); static int das1800_init_dma(struct comedi_device *dev, unsigned int dma0, unsigned int dma1) diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c index 3aac876869dd..6328f5280b66 100644 --- a/drivers/staging/comedi/drivers/das6402.c +++ b/drivers/staging/comedi/drivers/das6402.c @@ -109,7 +109,18 @@ static struct comedi_driver driver_das6402 = { .detach = das6402_detach, }; -COMEDI_INITCLEANUP(driver_das6402); +static int __init driver_das6402_init_module(void) +{ + return comedi_driver_register(&driver_das6402); +} + +static void __exit driver_das6402_cleanup_module(void) +{ + comedi_driver_unregister(&driver_das6402); +} + +module_init(driver_das6402_init_module); +module_exit(driver_das6402_cleanup_module); struct das6402_private { int ai_bytes_to_read; diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index b4083af4a66a..aecaedc5027e 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -347,7 +347,18 @@ static int das800_probe(struct comedi_device *dev) * A convenient macro that defines init_module() and cleanup_module(), * as necessary. */ -COMEDI_INITCLEANUP(driver_das800); +static int __init driver_das800_init_module(void) +{ + return comedi_driver_register(&driver_das800); +} + +static void __exit driver_das800_cleanup_module(void) +{ + comedi_driver_unregister(&driver_das800); +} + +module_init(driver_das800_init_module); +module_exit(driver_das800_cleanup_module); /* interrupt service routine */ static irqreturn_t das800_interrupt(int irq, void *d) diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 572b7a9e8673..dcde8d8dd406 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -1095,7 +1095,18 @@ void dmm32at_setaitimer(struct comedi_device *dev, unsigned int nansec) * A convenient macro that defines init_module() and cleanup_module(), * as necessary. */ -COMEDI_INITCLEANUP(driver_dmm32at); +static int __init driver_dmm32at_init_module(void) +{ + return comedi_driver_register(&driver_dmm32at); +} + +static void __exit driver_dmm32at_cleanup_module(void) +{ + comedi_driver_unregister(&driver_dmm32at); +} + +module_init(driver_dmm32at_init_module); +module_exit(driver_dmm32at_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c index a6f1546b39e5..5cce1b5f4484 100644 --- a/drivers/staging/comedi/drivers/dt2801.c +++ b/drivers/staging/comedi/drivers/dt2801.c @@ -98,7 +98,18 @@ static struct comedi_driver driver_dt2801 = { .detach = dt2801_detach, }; -COMEDI_INITCLEANUP(driver_dt2801); +static int __init driver_dt2801_init_module(void) +{ + return comedi_driver_register(&driver_dt2801); +} + +static void __exit driver_dt2801_cleanup_module(void) +{ + comedi_driver_unregister(&driver_dt2801); +} + +module_init(driver_dt2801_init_module); +module_exit(driver_dt2801_cleanup_module); #if 0 /* ignore 'defined but not used' warning */ diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c index 2d103eb1ebc8..a1664caa1d96 100644 --- a/drivers/staging/comedi/drivers/dt2811.c +++ b/drivers/staging/comedi/drivers/dt2811.c @@ -239,7 +239,18 @@ static struct comedi_driver driver_dt2811 = { .offset = sizeof(struct dt2811_board), }; -COMEDI_INITCLEANUP(driver_dt2811); +static int __init driver_dt2811_init_module(void) +{ + return comedi_driver_register(&driver_dt2811); +} + +static void __exit driver_dt2811_cleanup_module(void) +{ + comedi_driver_unregister(&driver_dt2811); +} + +module_init(driver_dt2811_init_module); +module_exit(driver_dt2811_cleanup_module); static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); diff --git a/drivers/staging/comedi/drivers/dt2814.c b/drivers/staging/comedi/drivers/dt2814.c index 0871fe0dc46f..1c6248cf5928 100644 --- a/drivers/staging/comedi/drivers/dt2814.c +++ b/drivers/staging/comedi/drivers/dt2814.c @@ -70,7 +70,18 @@ static struct comedi_driver driver_dt2814 = { .detach = dt2814_detach, }; -COMEDI_INITCLEANUP(driver_dt2814); +static int __init driver_dt2814_init_module(void) +{ + return comedi_driver_register(&driver_dt2814); +} + +static void __exit driver_dt2814_cleanup_module(void) +{ + comedi_driver_unregister(&driver_dt2814); +} + +module_init(driver_dt2814_init_module); +module_exit(driver_dt2814_cleanup_module); static irqreturn_t dt2814_interrupt(int irq, void *dev); diff --git a/drivers/staging/comedi/drivers/dt2815.c b/drivers/staging/comedi/drivers/dt2815.c index 8ff420eda1b1..4155da43fd51 100644 --- a/drivers/staging/comedi/drivers/dt2815.c +++ b/drivers/staging/comedi/drivers/dt2815.c @@ -82,7 +82,18 @@ static struct comedi_driver driver_dt2815 = { .detach = dt2815_detach, }; -COMEDI_INITCLEANUP(driver_dt2815); +static int __init driver_dt2815_init_module(void) +{ + return comedi_driver_register(&driver_dt2815); +} + +static void __exit driver_dt2815_cleanup_module(void) +{ + comedi_driver_unregister(&driver_dt2815); +} + +module_init(driver_dt2815_init_module); +module_exit(driver_dt2815_cleanup_module); static void dt2815_free_resources(struct comedi_device *dev); diff --git a/drivers/staging/comedi/drivers/dt2817.c b/drivers/staging/comedi/drivers/dt2817.c index 019aa4dfeeb3..651fe050d029 100644 --- a/drivers/staging/comedi/drivers/dt2817.c +++ b/drivers/staging/comedi/drivers/dt2817.c @@ -57,7 +57,18 @@ static struct comedi_driver driver_dt2817 = { .detach = dt2817_detach, }; -COMEDI_INITCLEANUP(driver_dt2817); +static int __init driver_dt2817_init_module(void) +{ + return comedi_driver_register(&driver_dt2817); +} + +static void __exit driver_dt2817_cleanup_module(void) +{ + comedi_driver_unregister(&driver_dt2817); +} + +module_init(driver_dt2817_init_module); +module_exit(driver_dt2817_cleanup_module); static int dt2817_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 58a2fdfcd340..8cea9dca3d7e 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -423,7 +423,18 @@ static struct comedi_driver driver_dt282x = { .offset = sizeof(struct dt282x_board), }; -COMEDI_INITCLEANUP(driver_dt282x); +static int __init driver_dt282x_init_module(void) +{ + return comedi_driver_register(&driver_dt282x); +} + +static void __exit driver_dt282x_cleanup_module(void) +{ + comedi_driver_unregister(&driver_dt282x); +} + +module_init(driver_dt282x_init_module); +module_exit(driver_dt282x_cleanup_module); static void free_resources(struct comedi_device *dev); static int prep_ai_dma(struct comedi_device *dev, int chan, int size); diff --git a/drivers/staging/comedi/drivers/fl512.c b/drivers/staging/comedi/drivers/fl512.c index 19f018438612..7f49add60b21 100644 --- a/drivers/staging/comedi/drivers/fl512.c +++ b/drivers/staging/comedi/drivers/fl512.c @@ -52,7 +52,18 @@ static struct comedi_driver driver_fl512 = { .detach = fl512_detach, }; -COMEDI_INITCLEANUP(driver_fl512); +static int __init driver_fl512_init_module(void) +{ + return comedi_driver_register(&driver_fl512); +} + +static void __exit driver_fl512_cleanup_module(void) +{ + comedi_driver_unregister(&driver_fl512); +} + +module_init(driver_fl512_init_module); +module_exit(driver_fl512_cleanup_module); static int fl512_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c index ba42478e6e1c..809d17efd5b3 100644 --- a/drivers/staging/comedi/drivers/icp_multi.c +++ b/drivers/staging/comedi/drivers/icp_multi.c @@ -185,7 +185,18 @@ board_name : &boardtypes[0].name, offset : sizeof(struct boardtype), }; -COMEDI_INITCLEANUP(driver_icp_multi); +static int __init driver_icp_multi_init_module(void) +{ + return comedi_driver_register(&driver_icp_multi); +} + +static void __exit driver_icp_multi_cleanup_module(void) +{ + comedi_driver_unregister(&driver_icp_multi); +} + +module_init(driver_icp_multi_init_module); +module_exit(driver_icp_multi_cleanup_module); struct icp_multi_private { struct pcilst_struct *card; /* pointer to card */ diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 0951f0e28a64..39a6a850d63c 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -640,7 +640,18 @@ static unsigned int pci20xxx_di(struct comedi_device *dev, } #endif -COMEDI_INITCLEANUP(driver_pci20xxx); +static int __init driver_pci20xxx_init_module(void) +{ + return comedi_driver_register(&driver_pci20xxx); +} + +static void __exit driver_pci20xxx_cleanup_module(void) +{ + comedi_driver_unregister(&driver_pci20xxx); +} + +module_init(driver_pci20xxx_init_module); +module_exit(driver_pci20xxx_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/mpc624.c b/drivers/staging/comedi/drivers/mpc624.c index df001e1738a0..a89eebd23f65 100644 --- a/drivers/staging/comedi/drivers/mpc624.c +++ b/drivers/staging/comedi/drivers/mpc624.c @@ -406,7 +406,18 @@ static int mpc624_ai_rinsn(struct comedi_device *dev, return n; } -COMEDI_INITCLEANUP(driver_mpc624); +static int __init driver_mpc624_init_module(void) +{ + return comedi_driver_register(&driver_mpc624); +} + +static void __exit driver_mpc624_cleanup_module(void) +{ + comedi_driver_unregister(&driver_mpc624); +} + +module_init(driver_mpc624_init_module); +module_exit(driver_mpc624_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/mpc8260cpm.c b/drivers/staging/comedi/drivers/mpc8260cpm.c index 440a144a037e..5f6816a3fe8c 100644 --- a/drivers/staging/comedi/drivers/mpc8260cpm.c +++ b/drivers/staging/comedi/drivers/mpc8260cpm.c @@ -56,7 +56,18 @@ static struct comedi_driver driver_mpc8260cpm = { .detach = mpc8260cpm_detach, }; -COMEDI_INITCLEANUP(driver_mpc8260cpm); +static int __init driver_mpc8260cpm_init_module(void) +{ + return comedi_driver_register(&driver_mpc8260cpm); +} + +static void __exit driver_mpc8260cpm_cleanup_module(void) +{ + comedi_driver_unregister(&driver_mpc8260cpm); +} + +module_init(driver_mpc8260cpm_init_module); +module_exit(driver_mpc8260cpm_cleanup_module); static int mpc8260cpm_dio_config(struct comedi_device *dev, struct comedi_subdevice *s, diff --git a/drivers/staging/comedi/drivers/multiq3.c b/drivers/staging/comedi/drivers/multiq3.c index 41bc51da388c..dace902d3bce 100644 --- a/drivers/staging/comedi/drivers/multiq3.c +++ b/drivers/staging/comedi/drivers/multiq3.c @@ -93,7 +93,18 @@ static struct comedi_driver driver_multiq3 = { .detach = multiq3_detach, }; -COMEDI_INITCLEANUP(driver_multiq3); +static int __init driver_multiq3_init_module(void) +{ + return comedi_driver_register(&driver_multiq3); +} + +static void __exit driver_multiq3_cleanup_module(void) +{ + comedi_driver_unregister(&driver_multiq3); +} + +module_init(driver_multiq3_init_module); +module_exit(driver_multiq3_cleanup_module); struct multiq3_private { unsigned int ao_readback[2]; diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index 709fc85ac703..e46d62b75fc0 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -197,7 +197,18 @@ static int a2150_set_chanlist(struct comedi_device *dev, * A convenient macro that defines init_module() and cleanup_module(), * as necessary. */ -COMEDI_INITCLEANUP(driver_a2150); +static int __init driver_a2150_init_module(void) +{ + return comedi_driver_register(&driver_a2150); +} + +static void __exit driver_a2150_cleanup_module(void) +{ + comedi_driver_unregister(&driver_a2150); +} + +module_init(driver_a2150_init_module); +module_exit(driver_a2150_cleanup_module); #ifdef A2150_DEBUG diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c index be1ddf28a549..138dcc2275ab 100644 --- a/drivers/staging/comedi/drivers/ni_at_ao.c +++ b/drivers/staging/comedi/drivers/ni_at_ao.c @@ -194,7 +194,18 @@ static struct comedi_driver driver_atao = { .num_names = ARRAY_SIZE(atao_boards), }; -COMEDI_INITCLEANUP(driver_atao); +static int __init driver_atao_init_module(void) +{ + return comedi_driver_register(&driver_atao); +} + +static void __exit driver_atao_cleanup_module(void) +{ + comedi_driver_unregister(&driver_atao); +} + +module_init(driver_atao_init_module); +module_exit(driver_atao_cleanup_module); static void atao_reset(struct comedi_device *dev); diff --git a/drivers/staging/comedi/drivers/ni_atmio.c b/drivers/staging/comedi/drivers/ni_atmio.c index 003d00b595b0..3330b3d53e8d 100644 --- a/drivers/staging/comedi/drivers/ni_atmio.c +++ b/drivers/staging/comedi/drivers/ni_atmio.c @@ -349,7 +349,18 @@ static struct comedi_driver driver_atmio = { .detach = ni_atmio_detach, }; -COMEDI_INITCLEANUP(driver_atmio); +static int __init driver_atmio_init_module(void) +{ + return comedi_driver_register(&driver_atmio); +} + +static void __exit driver_atmio_cleanup_module(void) +{ + comedi_driver_unregister(&driver_atmio); +} + +module_init(driver_atmio_init_module); +module_exit(driver_atmio_cleanup_module); #include "ni_mio_common.c" diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index 78fdf7bfb33a..285b933551ab 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -151,7 +151,18 @@ static struct comedi_driver driver_atmio16d = { .offset = sizeof(struct atmio16_board_t), }; -COMEDI_INITCLEANUP(driver_atmio16d); +static int __init driver_atmio16d_init_module(void) +{ + return comedi_driver_register(&driver_atmio16d); +} + +static void __exit driver_atmio16d_cleanup_module(void) +{ + comedi_driver_unregister(&driver_atmio16d); +} + +module_init(driver_atmio16d_init_module); +module_exit(driver_atmio16d_cleanup_module); /* range structs */ static const struct comedi_lrange range_atmio16d_ai_10_bipolar = { 4, { diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index 4966c8e496d5..383ee1024ad3 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -2080,7 +2080,18 @@ static void write_caldac(struct comedi_device *dev, unsigned int channel, #ifdef CONFIG_COMEDI_PCI COMEDI_PCI_INITCLEANUP(driver_labpc, labpc_pci_table); #else -COMEDI_INITCLEANUP(driver_labpc); +static int __init driver_labpc_init_module(void) +{ + return comedi_driver_register(&driver_labpc); +} + +static void __exit driver_labpc_cleanup_module(void) +{ + comedi_driver_unregister(&driver_labpc); +} + +module_init(driver_labpc_init_module); +module_exit(driver_labpc_cleanup_module); #endif EXPORT_SYMBOL_GPL(labpc_common_attach); diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index 870c40a75463..22d14fb3121b 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -171,7 +171,18 @@ static struct comedi_driver driver_pcl711 = { .offset = sizeof(struct pcl711_board), }; -COMEDI_INITCLEANUP(driver_pcl711); +static int __init driver_pcl711_init_module(void) +{ + return comedi_driver_register(&driver_pcl711); +} + +static void __exit driver_pcl711_cleanup_module(void) +{ + comedi_driver_unregister(&driver_pcl711); +} + +module_init(driver_pcl711_init_module); +module_exit(driver_pcl711_cleanup_module); struct pcl711_private { diff --git a/drivers/staging/comedi/drivers/pcl724.c b/drivers/staging/comedi/drivers/pcl724.c index 2811060b424b..396a058bb67d 100644 --- a/drivers/staging/comedi/drivers/pcl724.c +++ b/drivers/staging/comedi/drivers/pcl724.c @@ -93,7 +93,18 @@ static struct comedi_driver driver_pcl724 = { .offset = sizeof(struct pcl724_board), }; -COMEDI_INITCLEANUP(driver_pcl724); +static int __init driver_pcl724_init_module(void) +{ + return comedi_driver_register(&driver_pcl724); +} + +static void __exit driver_pcl724_cleanup_module(void) +{ + comedi_driver_unregister(&driver_pcl724); +} + +module_init(driver_pcl724_init_module); +module_exit(driver_pcl724_cleanup_module); static int subdev_8255_cb(int dir, int port, int data, unsigned long arg) { diff --git a/drivers/staging/comedi/drivers/pcl725.c b/drivers/staging/comedi/drivers/pcl725.c index cab4c13fff99..24b223ca4399 100644 --- a/drivers/staging/comedi/drivers/pcl725.c +++ b/drivers/staging/comedi/drivers/pcl725.c @@ -30,7 +30,18 @@ static struct comedi_driver driver_pcl725 = { .detach = pcl725_detach, }; -COMEDI_INITCLEANUP(driver_pcl725); +static int __init driver_pcl725_init_module(void) +{ + return comedi_driver_register(&driver_pcl725); +} + +static void __exit driver_pcl725_cleanup_module(void) +{ + comedi_driver_unregister(&driver_pcl725); +} + +module_init(driver_pcl725_init_module); +module_exit(driver_pcl725_cleanup_module); static int pcl725_do_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) diff --git a/drivers/staging/comedi/drivers/pcl726.c b/drivers/staging/comedi/drivers/pcl726.c index e54463136cc8..897cd808eeb7 100644 --- a/drivers/staging/comedi/drivers/pcl726.c +++ b/drivers/staging/comedi/drivers/pcl726.c @@ -162,7 +162,18 @@ static struct comedi_driver driver_pcl726 = { .offset = sizeof(struct pcl726_board), }; -COMEDI_INITCLEANUP(driver_pcl726); +static int __init driver_pcl726_init_module(void) +{ + return comedi_driver_register(&driver_pcl726); +} + +static void __exit driver_pcl726_cleanup_module(void) +{ + comedi_driver_unregister(&driver_pcl726); +} + +module_init(driver_pcl726_init_module); +module_exit(driver_pcl726_cleanup_module); struct pcl726_private { diff --git a/drivers/staging/comedi/drivers/pcl730.c b/drivers/staging/comedi/drivers/pcl730.c index 7d4f29a71423..c9682d614e0e 100644 --- a/drivers/staging/comedi/drivers/pcl730.c +++ b/drivers/staging/comedi/drivers/pcl730.c @@ -55,7 +55,18 @@ static struct comedi_driver driver_pcl730 = { .offset = sizeof(struct pcl730_board), }; -COMEDI_INITCLEANUP(driver_pcl730); +static int __init driver_pcl730_init_module(void) +{ + return comedi_driver_register(&driver_pcl730); +} + +static void __exit driver_pcl730_cleanup_module(void) +{ + comedi_driver_unregister(&driver_pcl730); +} + +module_init(driver_pcl730_init_module); +module_exit(driver_pcl730_cleanup_module); static int pcl730_do_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index b82c37c5d167..943fb713bd7d 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -407,7 +407,18 @@ static struct comedi_driver driver_pcl812 = { .offset = sizeof(struct pcl812_board), }; -COMEDI_INITCLEANUP(driver_pcl812); +static int __init driver_pcl812_init_module(void) +{ + return comedi_driver_register(&driver_pcl812); +} + +static void __exit driver_pcl812_cleanup_module(void) +{ + comedi_driver_unregister(&driver_pcl812); +} + +module_init(driver_pcl812_init_module); +module_exit(driver_pcl812_cleanup_module); struct pcl812_private { diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index c26dfad2c897..a84b942c5a93 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -168,7 +168,18 @@ static struct comedi_driver driver_pcl816 = { .offset = sizeof(struct pcl816_board), }; -COMEDI_INITCLEANUP(driver_pcl816); +static int __init driver_pcl816_init_module(void) +{ + return comedi_driver_register(&driver_pcl816); +} + +static void __exit driver_pcl816_cleanup_module(void) +{ + comedi_driver_unregister(&driver_pcl816); +} + +module_init(driver_pcl816_init_module); +module_exit(driver_pcl816_cleanup_module); struct pcl816_private { diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c index 887f1c37aa6b..d2bd6f82b830 100644 --- a/drivers/staging/comedi/drivers/pcl818.c +++ b/drivers/staging/comedi/drivers/pcl818.c @@ -313,7 +313,18 @@ static struct comedi_driver driver_pcl818 = { .offset = sizeof(struct pcl818_board), }; -COMEDI_INITCLEANUP(driver_pcl818); +static int __init driver_pcl818_init_module(void) +{ + return comedi_driver_register(&driver_pcl818); +} + +static void __exit driver_pcl818_cleanup_module(void) +{ + comedi_driver_unregister(&driver_pcl818); +} + +module_init(driver_pcl818_init_module); +module_exit(driver_pcl818_cleanup_module); struct pcl818_private { diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c index 972cd2bdf454..26850954442f 100644 --- a/drivers/staging/comedi/drivers/pcm3724.c +++ b/drivers/staging/comedi/drivers/pcm3724.c @@ -97,7 +97,18 @@ static struct comedi_driver driver_pcm3724 = { .offset = sizeof(struct pcm3724_board), }; -COMEDI_INITCLEANUP(driver_pcm3724); +static int __init driver_pcm3724_init_module(void) +{ + return comedi_driver_register(&driver_pcm3724); +} + +static void __exit driver_pcm3724_cleanup_module(void) +{ + comedi_driver_unregister(&driver_pcm3724); +} + +module_init(driver_pcm3724_init_module); +module_exit(driver_pcm3724_cleanup_module); /* (setq c-basic-offset 8) */ diff --git a/drivers/staging/comedi/drivers/pcm3730.c b/drivers/staging/comedi/drivers/pcm3730.c index 3c826b7b8e75..bada6b236ff1 100644 --- a/drivers/staging/comedi/drivers/pcm3730.c +++ b/drivers/staging/comedi/drivers/pcm3730.c @@ -38,7 +38,18 @@ static struct comedi_driver driver_pcm3730 = { .detach = pcm3730_detach, }; -COMEDI_INITCLEANUP(driver_pcm3730); +static int __init driver_pcm3730_init_module(void) +{ + return comedi_driver_register(&driver_pcm3730); +} + +static void __exit driver_pcm3730_cleanup_module(void) +{ + comedi_driver_unregister(&driver_pcm3730); +} + +module_init(driver_pcm3730_init_module); +module_exit(driver_pcm3730_cleanup_module); static int pcm3730_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, diff --git a/drivers/staging/comedi/drivers/pcmad.c b/drivers/staging/comedi/drivers/pcmad.c index 9f63a6cacfca..23b3d777340c 100644 --- a/drivers/staging/comedi/drivers/pcmad.c +++ b/drivers/staging/comedi/drivers/pcmad.c @@ -89,7 +89,18 @@ static struct comedi_driver driver_pcmad = { .offset = sizeof(pcmad_boards[0]), }; -COMEDI_INITCLEANUP(driver_pcmad); +static int __init driver_pcmad_init_module(void) +{ + return comedi_driver_register(&driver_pcmad); +} + +static void __exit driver_pcmad_cleanup_module(void) +{ + comedi_driver_unregister(&driver_pcmad); +} + +module_init(driver_pcmad_init_module); +module_exit(driver_pcmad_cleanup_module); #define TIMEOUT 100 diff --git a/drivers/staging/comedi/drivers/pcmda12.c b/drivers/staging/comedi/drivers/pcmda12.c index b09c0da8690c..6d6b86ad817d 100644 --- a/drivers/staging/comedi/drivers/pcmda12.c +++ b/drivers/staging/comedi/drivers/pcmda12.c @@ -303,7 +303,18 @@ static int ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, * A convenient macro that defines init_module() and cleanup_module(), * as necessary. */ -COMEDI_INITCLEANUP(driver); +static int __init driver_init_module(void) +{ + return comedi_driver_register(&driver); +} + +static void __exit driver_cleanup_module(void) +{ + comedi_driver_unregister(&driver); +} + +module_init(driver_init_module); +module_exit(driver_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index 3e80da04277f..f0df9d1e4fec 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -1333,7 +1333,18 @@ static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, * A convenient macro that defines init_module() and cleanup_module(), * as necessary. */ -COMEDI_INITCLEANUP(driver); +static int __init driver_init_module(void) +{ + return comedi_driver_register(&driver); +} + +static void __exit driver_cleanup_module(void) +{ + comedi_driver_unregister(&driver); +} + +module_init(driver_init_module); +module_exit(driver_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/pcmuio.c b/drivers/staging/comedi/drivers/pcmuio.c index 785b3ec8fec8..7a9287433b2e 100644 --- a/drivers/staging/comedi/drivers/pcmuio.c +++ b/drivers/staging/comedi/drivers/pcmuio.c @@ -1018,7 +1018,18 @@ pcmuio_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, * A convenient macro that defines init_module() and cleanup_module(), * as necessary. */ -COMEDI_INITCLEANUP(driver); +static int __init driver_init_module(void) +{ + return comedi_driver_register(&driver); +} + +static void __exit driver_cleanup_module(void) +{ + comedi_driver_unregister(&driver); +} + +module_init(driver_init_module); +module_exit(driver_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/poc.c b/drivers/staging/comedi/drivers/poc.c index 9270b9f15823..831a576c24aa 100644 --- a/drivers/staging/comedi/drivers/poc.c +++ b/drivers/staging/comedi/drivers/poc.c @@ -248,7 +248,18 @@ static int pcl734_insn_bits(struct comedi_device *dev, return 2; } -COMEDI_INITCLEANUP(driver_poc); +static int __init driver_poc_init_module(void) +{ + return comedi_driver_register(&driver_poc); +} + +static void __exit driver_poc_cleanup_module(void) +{ + comedi_driver_unregister(&driver_poc); +} + +module_init(driver_poc_init_module); +module_exit(driver_poc_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/rti800.c b/drivers/staging/comedi/drivers/rti800.c index 4add63328508..72042b818310 100644 --- a/drivers/staging/comedi/drivers/rti800.c +++ b/drivers/staging/comedi/drivers/rti800.c @@ -158,7 +158,18 @@ static struct comedi_driver driver_rti800 = { .offset = sizeof(struct rti800_board), }; -COMEDI_INITCLEANUP(driver_rti800); +static int __init driver_rti800_init_module(void) +{ + return comedi_driver_register(&driver_rti800); +} + +static void __exit driver_rti800_cleanup_module(void) +{ + comedi_driver_unregister(&driver_rti800); +} + +module_init(driver_rti800_init_module); +module_exit(driver_rti800_cleanup_module); static irqreturn_t rti800_interrupt(int irq, void *dev); diff --git a/drivers/staging/comedi/drivers/rti802.c b/drivers/staging/comedi/drivers/rti802.c index 132415b2d005..f59cb11590f6 100644 --- a/drivers/staging/comedi/drivers/rti802.c +++ b/drivers/staging/comedi/drivers/rti802.c @@ -57,7 +57,18 @@ static struct comedi_driver driver_rti802 = { .detach = rti802_detach, }; -COMEDI_INITCLEANUP(driver_rti802); +static int __init driver_rti802_init_module(void) +{ + return comedi_driver_register(&driver_rti802); +} + +static void __exit driver_rti802_cleanup_module(void) +{ + comedi_driver_unregister(&driver_rti802); +} + +module_init(driver_rti802_init_module); +module_exit(driver_rti802_cleanup_module); struct rti802_private { enum { diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c index 8afed1307bdd..3607aaee4af6 100644 --- a/drivers/staging/comedi/drivers/s526.c +++ b/drivers/staging/comedi/drivers/s526.c @@ -1002,7 +1002,18 @@ static int s526_dio_insn_config(struct comedi_device *dev, * A convenient macro that defines init_module() and cleanup_module(), * as necessary. */ -COMEDI_INITCLEANUP(driver_s526); +static int __init driver_s526_init_module(void) +{ + return comedi_driver_register(&driver_s526); +} + +static void __exit driver_s526_cleanup_module(void) +{ + comedi_driver_unregister(&driver_s526); +} + +module_init(driver_s526_init_module); +module_exit(driver_s526_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index 85d127fb7eb1..c9be9e05f028 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -917,7 +917,18 @@ static int serial2002_detach(struct comedi_device *dev) return 0; } -COMEDI_INITCLEANUP(driver_serial2002); +static int __init driver_serial2002_init_module(void) +{ + return comedi_driver_register(&driver_serial2002); +} + +static void __exit driver_serial2002_cleanup_module(void) +{ + comedi_driver_unregister(&driver_serial2002); +} + +module_init(driver_serial2002_init_module); +module_exit(driver_serial2002_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index 5a0767333bbc..d1d5437c5995 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -620,11 +620,18 @@ static int skel_dio_insn_config(struct comedi_device *dev, return insn->n; } -/* - * A convenient macro that defines init_module() and cleanup_module(), - * as necessary. - */ -COMEDI_INITCLEANUP(driver_skel); +static int __init driver_skel_init_module(void) +{ + return comedi_driver_register(&driver_skel); +} + +static void __exit driver_skel_cleanup_module(void) +{ + comedi_driver_unregister(&driver_skel); +} + +module_init(driver_skel_init_module); +module_exit(driver_skel_cleanup_module); /* If you are writing a PCI driver you should use COMEDI_PCI_INITCLEANUP * instead. */ diff --git a/drivers/staging/comedi/drivers/ssv_dnp.c b/drivers/staging/comedi/drivers/ssv_dnp.c index ce0cbb4c37bf..526de2efa125 100644 --- a/drivers/staging/comedi/drivers/ssv_dnp.c +++ b/drivers/staging/comedi/drivers/ssv_dnp.c @@ -102,7 +102,18 @@ static struct comedi_driver driver_dnp = { .num_names = ARRAY_SIZE(dnp_boards), }; -COMEDI_INITCLEANUP(driver_dnp); +static int __init driver_dnp_init_module(void) +{ + return comedi_driver_register(&driver_dnp); +} + +static void __exit driver_dnp_cleanup_module(void) +{ + comedi_driver_unregister(&driver_dnp); +} + +module_init(driver_dnp_init_module); +module_exit(driver_dnp_cleanup_module); static int dnp_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, diff --git a/drivers/staging/comedi/drivers/unioxx5.c b/drivers/staging/comedi/drivers/unioxx5.c index 1aca98895f83..598884ec3ede 100644 --- a/drivers/staging/comedi/drivers/unioxx5.c +++ b/drivers/staging/comedi/drivers/unioxx5.c @@ -114,7 +114,18 @@ static struct comedi_driver unioxx5_driver = { .detach = unioxx5_detach }; -COMEDI_INITCLEANUP(unioxx5_driver); +static int __init unioxx5_driver_init_module(void) +{ + return comedi_driver_register(&unioxx5_driver); +} + +static void __exit unioxx5_driver_cleanup_module(void) +{ + comedi_driver_unregister(&unioxx5_driver); +} + +module_init(unioxx5_driver_init_module); +module_exit(unioxx5_driver_cleanup_module); static int unioxx5_attach(struct comedi_device *dev, struct comedi_devconfig *it) From 727b286b44ea359d66f47d241cc2cdad36ed7bdc Mon Sep 17 00:00:00 2001 From: Arun Thomas Date: Sun, 6 Jun 2010 22:23:31 +0200 Subject: [PATCH 026/523] Staging: comedi: Remove COMEDI_PCI_INITCLEANUP macro Move the PCI devinit/devexit routines to the respective C source files instead of calling COMEDI_PCI_INITCLEANUP Signed-off-by: Arun Thomas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 38 ---------------- .../comedi/drivers/addi-data/addi_common.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/adl_pci6208.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/adl_pci7230.c | 40 ++++++++++++++++- drivers/staging/comedi/drivers/adl_pci7296.c | 40 ++++++++++++++++- drivers/staging/comedi/drivers/adl_pci7432.c | 40 ++++++++++++++++- drivers/staging/comedi/drivers/adl_pci8164.c | 40 ++++++++++++++++- drivers/staging/comedi/drivers/adl_pci9111.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/adl_pci9118.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/adv_pci1710.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/adv_pci1723.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/adv_pci_dio.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/amplc_dio200.c | 40 ++++++++++++++++- drivers/staging/comedi/drivers/amplc_pc236.c | 40 ++++++++++++++++- drivers/staging/comedi/drivers/amplc_pc263.c | 40 ++++++++++++++++- drivers/staging/comedi/drivers/amplc_pci224.c | 40 ++++++++++++++++- drivers/staging/comedi/drivers/amplc_pci230.c | 40 ++++++++++++++++- drivers/staging/comedi/drivers/cb_pcidas.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/cb_pcidas64.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/cb_pcidda.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/cb_pcidio.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/cb_pcimdas.c | 40 ++++++++++++++++- drivers/staging/comedi/drivers/cb_pcimdda.c | 40 ++++++++++++++++- .../staging/comedi/drivers/contec_pci_dio.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/daqboard2000.c | 40 ++++++++++++++++- drivers/staging/comedi/drivers/das08.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/dt3000.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/gsc_hpdi.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/jr3_pci.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/ke_counter.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/me4000.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/me_daq.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/ni_6527.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/ni_65xx.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/ni_660x.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/ni_670x.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/ni_labpc.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/ni_pcidio.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/ni_pcimio.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/rtd520.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/s626.c | 38 +++++++++++++++- drivers/staging/comedi/drivers/skel.c | 44 +++++++++++++++++-- 42 files changed, 1544 insertions(+), 82 deletions(-) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 8e0106520c2f..68aa9176d249 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -53,44 +53,6 @@ COMEDI_MINORVERSION, COMEDI_MICROVERSION) #define COMEDI_RELEASE VERSION -#define COMEDI_PCI_INITCLEANUP_NOMODULE(comedi_driver, pci_id_table) \ - static int __devinit comedi_driver ## _pci_probe(struct pci_dev *dev, \ - const struct pci_device_id *ent) \ - { \ - return comedi_pci_auto_config(dev, comedi_driver.driver_name); \ - } \ - static void __devexit comedi_driver ## _pci_remove(\ - struct pci_dev *dev) \ - { \ - comedi_pci_auto_unconfig(dev); \ - } \ - static struct pci_driver comedi_driver ## _pci_driver = \ - { \ - .id_table = pci_id_table, \ - .probe = &comedi_driver ## _pci_probe, \ - .remove = __devexit_p(&comedi_driver ## _pci_remove) \ - }; \ - static int __init comedi_driver ## _init_module(void) \ - { \ - int retval; \ - retval = comedi_driver_register(&comedi_driver); \ - if (retval < 0) \ - return retval; \ - comedi_driver ## _pci_driver.name = \ - (char *)comedi_driver.driver_name; \ - return pci_register_driver(&comedi_driver ## _pci_driver); \ - } \ - static void __exit comedi_driver ## _cleanup_module(void) \ - { \ - pci_unregister_driver(&comedi_driver ## _pci_driver); \ - comedi_driver_unregister(&comedi_driver); \ - } \ - module_init(comedi_driver ## _init_module); \ - module_exit(comedi_driver ## _cleanup_module); - -#define COMEDI_PCI_INITCLEANUP(comedi_driver, pci_id_table) \ - COMEDI_PCI_INITCLEANUP_NOMODULE(comedi_driver, pci_id_table) - #define PCI_VENDOR_ID_ADLINK 0x144a #define PCI_VENDOR_ID_ICP 0x104c #define PCI_VENDOR_ID_CONTEC 0x1221 diff --git a/drivers/staging/comedi/drivers/addi-data/addi_common.c b/drivers/staging/comedi/drivers/addi-data/addi_common.c index b18e81d8cf8a..5ed4b9451f28 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_common.c +++ b/drivers/staging/comedi/drivers/addi-data/addi_common.c @@ -2541,7 +2541,43 @@ static struct comedi_driver driver_addi = { .offset = sizeof(struct addi_board), }; -COMEDI_PCI_INITCLEANUP(driver_addi, addi_apci_tbl); +static int __devinit driver_addi_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_addi.driver_name); +} + +static void __devexit driver_addi_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_addi_pci_driver = { + .id_table = addi_apci_tbl, + .probe = &driver_addi_pci_probe, + .remove = __devexit_p(&driver_addi_pci_remove) +}; + +static int __init driver_addi_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_addi); + if (retval < 0) + return retval; + + driver_addi_pci_driver.name = (char *)driver_addi.driver_name; + return pci_register_driver(&driver_addi_pci_driver); +} + +static void __exit driver_addi_cleanup_module(void) +{ + pci_unregister_driver(&driver_addi_pci_driver); + comedi_driver_unregister(&driver_addi); +} + +module_init(driver_addi_init_module); +module_exit(driver_addi_cleanup_module); /* +----------------------------------------------------------------------------+ diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c index 3816115b18ce..0bc6ac2b6424 100644 --- a/drivers/staging/comedi/drivers/adl_pci6208.c +++ b/drivers/staging/comedi/drivers/adl_pci6208.c @@ -119,7 +119,43 @@ static struct comedi_driver driver_pci6208 = { .detach = pci6208_detach, }; -COMEDI_PCI_INITCLEANUP(driver_pci6208, pci6208_pci_table); +static int __devinit driver_pci6208_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_pci6208.driver_name); +} + +static void __devexit driver_pci6208_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_pci6208_pci_driver = { + .id_table = pci6208_pci_table, + .probe = &driver_pci6208_pci_probe, + .remove = __devexit_p(&driver_pci6208_pci_remove) +}; + +static int __init driver_pci6208_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_pci6208); + if (retval < 0) + return retval; + + driver_pci6208_pci_driver.name = (char *)driver_pci6208.driver_name; + return pci_register_driver(&driver_pci6208_pci_driver); +} + +static void __exit driver_pci6208_cleanup_module(void) +{ + pci_unregister_driver(&driver_pci6208_pci_driver); + comedi_driver_unregister(&driver_pci6208); +} + +module_init(driver_pci6208_init_module); +module_exit(driver_pci6208_cleanup_module); static int pci6208_find_device(struct comedi_device *dev, int bus, int slot); static int diff --git a/drivers/staging/comedi/drivers/adl_pci7230.c b/drivers/staging/comedi/drivers/adl_pci7230.c index 46b5c5c27621..caeb4e11ac59 100644 --- a/drivers/staging/comedi/drivers/adl_pci7230.c +++ b/drivers/staging/comedi/drivers/adl_pci7230.c @@ -203,7 +203,45 @@ static int adl_pci7230_di_insn_bits(struct comedi_device *dev, return 2; } -COMEDI_PCI_INITCLEANUP(driver_adl_pci7230, adl_pci7230_pci_table); +static int __devinit driver_adl_pci7230_pci_probe(struct pci_dev *dev, + const struct pci_device_id + *ent) +{ + return comedi_pci_auto_config(dev, driver_adl_pci7230.driver_name); +} + +static void __devexit driver_adl_pci7230_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_adl_pci7230_pci_driver = { + .id_table = adl_pci7230_pci_table, + .probe = &driver_adl_pci7230_pci_probe, + .remove = __devexit_p(&driver_adl_pci7230_pci_remove) +}; + +static int __init driver_adl_pci7230_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_adl_pci7230); + if (retval < 0) + return retval; + + driver_adl_pci7230_pci_driver.name = + (char *)driver_adl_pci7230.driver_name; + return pci_register_driver(&driver_adl_pci7230_pci_driver); +} + +static void __exit driver_adl_pci7230_cleanup_module(void) +{ + pci_unregister_driver(&driver_adl_pci7230_pci_driver); + comedi_driver_unregister(&driver_adl_pci7230); +} + +module_init(driver_adl_pci7230_init_module); +module_exit(driver_adl_pci7230_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/adl_pci7296.c b/drivers/staging/comedi/drivers/adl_pci7296.c index e7c5d66ccd95..947fae5adb94 100644 --- a/drivers/staging/comedi/drivers/adl_pci7296.c +++ b/drivers/staging/comedi/drivers/adl_pci7296.c @@ -177,7 +177,45 @@ static int adl_pci7296_detach(struct comedi_device *dev) return 0; } -COMEDI_PCI_INITCLEANUP(driver_adl_pci7296, adl_pci7296_pci_table); +static int __devinit driver_adl_pci7296_pci_probe(struct pci_dev *dev, + const struct pci_device_id + *ent) +{ + return comedi_pci_auto_config(dev, driver_adl_pci7296.driver_name); +} + +static void __devexit driver_adl_pci7296_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_adl_pci7296_pci_driver = { + .id_table = adl_pci7296_pci_table, + .probe = &driver_adl_pci7296_pci_probe, + .remove = __devexit_p(&driver_adl_pci7296_pci_remove) +}; + +static int __init driver_adl_pci7296_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_adl_pci7296); + if (retval < 0) + return retval; + + driver_adl_pci7296_pci_driver.name = + (char *)driver_adl_pci7296.driver_name; + return pci_register_driver(&driver_adl_pci7296_pci_driver); +} + +static void __exit driver_adl_pci7296_cleanup_module(void) +{ + pci_unregister_driver(&driver_adl_pci7296_pci_driver); + comedi_driver_unregister(&driver_adl_pci7296); +} + +module_init(driver_adl_pci7296_init_module); +module_exit(driver_adl_pci7296_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/adl_pci7432.c b/drivers/staging/comedi/drivers/adl_pci7432.c index d68fbe2bdad6..3b2f8e3fccd2 100644 --- a/drivers/staging/comedi/drivers/adl_pci7432.c +++ b/drivers/staging/comedi/drivers/adl_pci7432.c @@ -210,7 +210,45 @@ static int adl_pci7432_di_insn_bits(struct comedi_device *dev, return 2; } -COMEDI_PCI_INITCLEANUP(driver_adl_pci7432, adl_pci7432_pci_table); +static int __devinit driver_adl_pci7432_pci_probe(struct pci_dev *dev, + const struct pci_device_id + *ent) +{ + return comedi_pci_auto_config(dev, driver_adl_pci7432.driver_name); +} + +static void __devexit driver_adl_pci7432_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_adl_pci7432_pci_driver = { + .id_table = adl_pci7432_pci_table, + .probe = &driver_adl_pci7432_pci_probe, + .remove = __devexit_p(&driver_adl_pci7432_pci_remove) +}; + +static int __init driver_adl_pci7432_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_adl_pci7432); + if (retval < 0) + return retval; + + driver_adl_pci7432_pci_driver.name = + (char *)driver_adl_pci7432.driver_name; + return pci_register_driver(&driver_adl_pci7432_pci_driver); +} + +static void __exit driver_adl_pci7432_cleanup_module(void) +{ + pci_unregister_driver(&driver_adl_pci7432_pci_driver); + comedi_driver_unregister(&driver_adl_pci7432); +} + +module_init(driver_adl_pci7432_init_module); +module_exit(driver_adl_pci7432_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/adl_pci8164.c b/drivers/staging/comedi/drivers/adl_pci8164.c index 5fafaf0ff999..1b7155e4895e 100644 --- a/drivers/staging/comedi/drivers/adl_pci8164.c +++ b/drivers/staging/comedi/drivers/adl_pci8164.c @@ -389,7 +389,45 @@ static int adl_pci8164_insn_write_buf1(struct comedi_device *dev, return 2; } -COMEDI_PCI_INITCLEANUP(driver_adl_pci8164, adl_pci8164_pci_table); +static int __devinit driver_adl_pci8164_pci_probe(struct pci_dev *dev, + const struct pci_device_id + *ent) +{ + return comedi_pci_auto_config(dev, driver_adl_pci8164.driver_name); +} + +static void __devexit driver_adl_pci8164_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_adl_pci8164_pci_driver = { + .id_table = adl_pci8164_pci_table, + .probe = &driver_adl_pci8164_pci_probe, + .remove = __devexit_p(&driver_adl_pci8164_pci_remove) +}; + +static int __init driver_adl_pci8164_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_adl_pci8164); + if (retval < 0) + return retval; + + driver_adl_pci8164_pci_driver.name = + (char *)driver_adl_pci8164.driver_name; + return pci_register_driver(&driver_adl_pci8164_pci_driver); +} + +static void __exit driver_adl_pci8164_cleanup_module(void) +{ + pci_unregister_driver(&driver_adl_pci8164_pci_driver); + comedi_driver_unregister(&driver_adl_pci8164); +} + +module_init(driver_adl_pci8164_init_module); +module_exit(driver_adl_pci8164_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index 429a551bd5dd..38a5752bc4fc 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -350,7 +350,43 @@ static struct comedi_driver pci9111_driver = { .detach = pci9111_detach, }; -COMEDI_PCI_INITCLEANUP(pci9111_driver, pci9111_pci_table); +static int __devinit pci9111_driver_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, pci9111_driver.driver_name); +} + +static void __devexit pci9111_driver_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver pci9111_driver_pci_driver = { + .id_table = pci9111_pci_table, + .probe = &pci9111_driver_pci_probe, + .remove = __devexit_p(&pci9111_driver_pci_remove) +}; + +static int __init pci9111_driver_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&pci9111_driver); + if (retval < 0) + return retval; + + pci9111_driver_pci_driver.name = (char *)pci9111_driver.driver_name; + return pci_register_driver(&pci9111_driver_pci_driver); +} + +static void __exit pci9111_driver_cleanup_module(void) +{ + pci_unregister_driver(&pci9111_driver_pci_driver); + comedi_driver_unregister(&pci9111_driver); +} + +module_init(pci9111_driver_init_module); +module_exit(pci9111_driver_cleanup_module); /* Private data structure */ diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index d6c17e268ccd..b0e39cb74774 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -289,7 +289,43 @@ static struct comedi_driver driver_pci9118 = { .offset = sizeof(struct boardtype), }; -COMEDI_PCI_INITCLEANUP(driver_pci9118, pci9118_pci_table); +static int __devinit driver_pci9118_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_pci9118.driver_name); +} + +static void __devexit driver_pci9118_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_pci9118_pci_driver = { + .id_table = pci9118_pci_table, + .probe = &driver_pci9118_pci_probe, + .remove = __devexit_p(&driver_pci9118_pci_remove) +}; + +static int __init driver_pci9118_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_pci9118); + if (retval < 0) + return retval; + + driver_pci9118_pci_driver.name = (char *)driver_pci9118.driver_name; + return pci_register_driver(&driver_pci9118_pci_driver); +} + +static void __exit driver_pci9118_cleanup_module(void) +{ + pci_unregister_driver(&driver_pci9118_pci_driver); + comedi_driver_unregister(&driver_pci9118); +} + +module_init(driver_pci9118_init_module); +module_exit(driver_pci9118_cleanup_module); struct pci9118_private { unsigned long iobase_a; /* base+size for AMCC chip */ diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index dbb50cf7e83c..2791f9037b98 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -1609,7 +1609,43 @@ static int pci1710_detach(struct comedi_device *dev) /* ============================================================================== */ -COMEDI_PCI_INITCLEANUP(driver_pci1710, pci1710_pci_table); +static int __devinit driver_pci1710_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_pci1710.driver_name); +} + +static void __devexit driver_pci1710_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_pci1710_pci_driver = { + .id_table = pci1710_pci_table, + .probe = &driver_pci1710_pci_probe, + .remove = __devexit_p(&driver_pci1710_pci_remove) +}; + +static int __init driver_pci1710_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_pci1710); + if (retval < 0) + return retval; + + driver_pci1710_pci_driver.name = (char *)driver_pci1710.driver_name; + return pci_register_driver(&driver_pci1710_pci_driver); +} + +static void __exit driver_pci1710_cleanup_module(void) +{ + pci_unregister_driver(&driver_pci1710_pci_driver); + comedi_driver_unregister(&driver_pci1710); +} + +module_init(driver_pci1710_init_module); +module_exit(driver_pci1710_cleanup_module); /* ============================================================================== */ diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index b973249fb224..b133bb84c4fe 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -496,7 +496,43 @@ static int pci1723_detach(struct comedi_device *dev) * A convenient macro that defines init_module() and cleanup_module(), * as necessary. */ -COMEDI_PCI_INITCLEANUP(driver_pci1723, pci1723_pci_table); +static int __devinit driver_pci1723_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_pci1723.driver_name); +} + +static void __devexit driver_pci1723_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_pci1723_pci_driver = { + .id_table = pci1723_pci_table, + .probe = &driver_pci1723_pci_probe, + .remove = __devexit_p(&driver_pci1723_pci_remove) +}; + +static int __init driver_pci1723_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_pci1723); + if (retval < 0) + return retval; + + driver_pci1723_pci_driver.name = (char *)driver_pci1723.driver_name; + return pci_register_driver(&driver_pci1723_pci_driver); +} + +static void __exit driver_pci1723_cleanup_module(void) +{ + pci_unregister_driver(&driver_pci1723_pci_driver); + comedi_driver_unregister(&driver_pci1723); +} + +module_init(driver_pci1723_init_module); +module_exit(driver_pci1723_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index e7ba1f0b4e68..d81bbfac695a 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -1253,7 +1253,43 @@ static int pci_dio_detach(struct comedi_device *dev) /* ============================================================================== */ -COMEDI_PCI_INITCLEANUP(driver_pci_dio, pci_dio_pci_table); +static int __devinit driver_pci_dio_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_pci_dio.driver_name); +} + +static void __devexit driver_pci_dio_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_pci_dio_pci_driver = { + .id_table = pci_dio_pci_table, + .probe = &driver_pci_dio_pci_probe, + .remove = __devexit_p(&driver_pci_dio_pci_remove) +}; + +static int __init driver_pci_dio_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_pci_dio); + if (retval < 0) + return retval; + + driver_pci_dio_pci_driver.name = (char *)driver_pci_dio.driver_name; + return pci_register_driver(&driver_pci_dio_pci_driver); +} + +static void __exit driver_pci_dio_cleanup_module(void) +{ + pci_unregister_driver(&driver_pci_dio_pci_driver); + comedi_driver_unregister(&driver_pci_dio); +} + +module_init(driver_pci_dio_init_module); +module_exit(driver_pci_dio_cleanup_module); /* ============================================================================== */ diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c index 674cf1df7e2c..93bbe4ec318d 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.c +++ b/drivers/staging/comedi/drivers/amplc_dio200.c @@ -494,7 +494,45 @@ static struct comedi_driver driver_amplc_dio200 = { }; #ifdef CONFIG_COMEDI_PCI -COMEDI_PCI_INITCLEANUP(driver_amplc_dio200, dio200_pci_table); +static int __devinit driver_amplc_dio200_pci_probe(struct pci_dev *dev, + const struct pci_device_id + *ent) +{ + return comedi_pci_auto_config(dev, driver_amplc_dio200.driver_name); +} + +static void __devexit driver_amplc_dio200_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_amplc_dio200_pci_driver = { + .id_table = dio200_pci_table, + .probe = &driver_amplc_dio200_pci_probe, + .remove = __devexit_p(&driver_amplc_dio200_pci_remove) +}; + +static int __init driver_amplc_dio200_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_amplc_dio200); + if (retval < 0) + return retval; + + driver_amplc_dio200_pci_driver.name = + (char *)driver_amplc_dio200.driver_name; + return pci_register_driver(&driver_amplc_dio200_pci_driver); +} + +static void __exit driver_amplc_dio200_cleanup_module(void) +{ + pci_unregister_driver(&driver_amplc_dio200_pci_driver); + comedi_driver_unregister(&driver_amplc_dio200); +} + +module_init(driver_amplc_dio200_init_module); +module_exit(driver_amplc_dio200_cleanup_module); #else static int __init driver_amplc_dio200_init_module(void) { diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c index 5ffee055c9a9..48246cd50d47 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/drivers/staging/comedi/drivers/amplc_pc236.c @@ -182,7 +182,45 @@ static struct comedi_driver driver_amplc_pc236 = { }; #ifdef CONFIG_COMEDI_PCI -COMEDI_PCI_INITCLEANUP(driver_amplc_pc236, pc236_pci_table); +static int __devinit driver_amplc_pc236_pci_probe(struct pci_dev *dev, + const struct pci_device_id + *ent) +{ + return comedi_pci_auto_config(dev, driver_amplc_pc236.driver_name); +} + +static void __devexit driver_amplc_pc236_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_amplc_pc236_pci_driver = { + .id_table = pc236_pci_table, + .probe = &driver_amplc_pc236_pci_probe, + .remove = __devexit_p(&driver_amplc_pc236_pci_remove) +}; + +static int __init driver_amplc_pc236_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_amplc_pc236); + if (retval < 0) + return retval; + + driver_amplc_pc236_pci_driver.name = + (char *)driver_amplc_pc236.driver_name; + return pci_register_driver(&driver_amplc_pc236_pci_driver); +} + +static void __exit driver_amplc_pc236_cleanup_module(void) +{ + pci_unregister_driver(&driver_amplc_pc236_pci_driver); + comedi_driver_unregister(&driver_amplc_pc236); +} + +module_init(driver_amplc_pc236_init_module); +module_exit(driver_amplc_pc236_cleanup_module); #else static int __init driver_amplc_pc236_init_module(void) { diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c index 83af437eb436..8a3388079094 100644 --- a/drivers/staging/comedi/drivers/amplc_pc263.c +++ b/drivers/staging/comedi/drivers/amplc_pc263.c @@ -432,7 +432,45 @@ static int pc263_dio_insn_config(struct comedi_device *dev, * as necessary. */ #ifdef CONFIG_COMEDI_PCI -COMEDI_PCI_INITCLEANUP(driver_amplc_pc263, pc263_pci_table); +static int __devinit driver_amplc_pc263_pci_probe(struct pci_dev *dev, + const struct pci_device_id + *ent) +{ + return comedi_pci_auto_config(dev, driver_amplc_pc263.driver_name); +} + +static void __devexit driver_amplc_pc263_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_amplc_pc263_pci_driver = { + .id_table = pc263_pci_table, + .probe = &driver_amplc_pc263_pci_probe, + .remove = __devexit_p(&driver_amplc_pc263_pci_remove) +}; + +static int __init driver_amplc_pc263_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_amplc_pc263); + if (retval < 0) + return retval; + + driver_amplc_pc263_pci_driver.name = + (char *)driver_amplc_pc263.driver_name; + return pci_register_driver(&driver_amplc_pc263_pci_driver); +} + +static void __exit driver_amplc_pc263_cleanup_module(void) +{ + pci_unregister_driver(&driver_amplc_pc263_pci_driver); + comedi_driver_unregister(&driver_amplc_pc263); +} + +module_init(driver_amplc_pc263_init_module); +module_exit(driver_amplc_pc263_cleanup_module); #else static int __init driver_amplc_pc263_init_module(void) { diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index a27e27f5b7b8..1b5ba1c27259 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -443,7 +443,45 @@ static struct comedi_driver driver_amplc_pci224 = { .num_names = ARRAY_SIZE(pci224_boards), }; -COMEDI_PCI_INITCLEANUP(driver_amplc_pci224, pci224_pci_table); +static int __devinit driver_amplc_pci224_pci_probe(struct pci_dev *dev, + const struct pci_device_id + *ent) +{ + return comedi_pci_auto_config(dev, driver_amplc_pci224.driver_name); +} + +static void __devexit driver_amplc_pci224_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_amplc_pci224_pci_driver = { + .id_table = pci224_pci_table, + .probe = &driver_amplc_pci224_pci_probe, + .remove = __devexit_p(&driver_amplc_pci224_pci_remove) +}; + +static int __init driver_amplc_pci224_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_amplc_pci224); + if (retval < 0) + return retval; + + driver_amplc_pci224_pci_driver.name = + (char *)driver_amplc_pci224.driver_name; + return pci_register_driver(&driver_amplc_pci224_pci_driver); +} + +static void __exit driver_amplc_pci224_cleanup_module(void) +{ + pci_unregister_driver(&driver_amplc_pci224_pci_driver); + comedi_driver_unregister(&driver_amplc_pci224); +} + +module_init(driver_amplc_pci224_init_module); +module_exit(driver_amplc_pci224_cleanup_module); /* * Called from the 'insn_write' function to perform a single write. diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 53d34147813b..b572df718f21 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -617,7 +617,45 @@ static struct comedi_driver driver_amplc_pci230 = { .num_names = ARRAY_SIZE(pci230_boards), }; -COMEDI_PCI_INITCLEANUP(driver_amplc_pci230, pci230_pci_table); +static int __devinit driver_amplc_pci230_pci_probe(struct pci_dev *dev, + const struct pci_device_id + *ent) +{ + return comedi_pci_auto_config(dev, driver_amplc_pci230.driver_name); +} + +static void __devexit driver_amplc_pci230_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_amplc_pci230_pci_driver = { + .id_table = pci230_pci_table, + .probe = &driver_amplc_pci230_pci_probe, + .remove = __devexit_p(&driver_amplc_pci230_pci_remove) +}; + +static int __init driver_amplc_pci230_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_amplc_pci230); + if (retval < 0) + return retval; + + driver_amplc_pci230_pci_driver.name = + (char *)driver_amplc_pci230.driver_name; + return pci_register_driver(&driver_amplc_pci230_pci_driver); +} + +static void __exit driver_amplc_pci230_cleanup_module(void) +{ + pci_unregister_driver(&driver_amplc_pci230_pci_driver); + comedi_driver_unregister(&driver_amplc_pci230); +} + +module_init(driver_amplc_pci230_init_module); +module_exit(driver_amplc_pci230_cleanup_module); static int pci230_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 04c71704507f..2d9ad537793e 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -1871,7 +1871,43 @@ static int nvram_read(struct comedi_device *dev, unsigned int address, * A convenient macro that defines init_module() and cleanup_module(), * as necessary. */ -COMEDI_PCI_INITCLEANUP(driver_cb_pcidas, cb_pcidas_pci_table); +static int __devinit driver_cb_pcidas_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_cb_pcidas.driver_name); +} + +static void __devexit driver_cb_pcidas_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_cb_pcidas_pci_driver = { + .id_table = cb_pcidas_pci_table, + .probe = &driver_cb_pcidas_pci_probe, + .remove = __devexit_p(&driver_cb_pcidas_pci_remove) +}; + +static int __init driver_cb_pcidas_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_cb_pcidas); + if (retval < 0) + return retval; + + driver_cb_pcidas_pci_driver.name = (char *)driver_cb_pcidas.driver_name; + return pci_register_driver(&driver_cb_pcidas_pci_driver); +} + +static void __exit driver_cb_pcidas_cleanup_module(void) +{ + pci_unregister_driver(&driver_cb_pcidas_pci_driver); + comedi_driver_unregister(&driver_cb_pcidas); +} + +module_init(driver_cb_pcidas_init_module); +module_exit(driver_cb_pcidas_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 168a33511648..ba7c48ab6d92 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -1237,7 +1237,43 @@ static unsigned int get_ao_divisor(unsigned int ns, unsigned int flags); static void load_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd); -COMEDI_PCI_INITCLEANUP(driver_cb_pcidas, pcidas64_pci_table); +static int __devinit driver_cb_pcidas_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_cb_pcidas.driver_name); +} + +static void __devexit driver_cb_pcidas_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_cb_pcidas_pci_driver = { + .id_table = pcidas64_pci_table, + .probe = &driver_cb_pcidas_pci_probe, + .remove = __devexit_p(&driver_cb_pcidas_pci_remove) +}; + +static int __init driver_cb_pcidas_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_cb_pcidas); + if (retval < 0) + return retval; + + driver_cb_pcidas_pci_driver.name = (char *)driver_cb_pcidas.driver_name; + return pci_register_driver(&driver_cb_pcidas_pci_driver); +} + +static void __exit driver_cb_pcidas_cleanup_module(void) +{ + pci_unregister_driver(&driver_cb_pcidas_pci_driver); + comedi_driver_unregister(&driver_cb_pcidas); +} + +module_init(driver_cb_pcidas_init_module); +module_exit(driver_cb_pcidas_cleanup_module); static unsigned int ai_range_bits_6xxx(const struct comedi_device *dev, unsigned int range_index) diff --git a/drivers/staging/comedi/drivers/cb_pcidda.c b/drivers/staging/comedi/drivers/cb_pcidda.c index 3c2a84e2065b..349c7a61763a 100644 --- a/drivers/staging/comedi/drivers/cb_pcidda.c +++ b/drivers/staging/comedi/drivers/cb_pcidda.c @@ -857,7 +857,43 @@ static void cb_pcidda_calibrate(struct comedi_device *dev, unsigned int channel, * A convenient macro that defines init_module() and cleanup_module(), * as necessary. */ -COMEDI_PCI_INITCLEANUP(driver_cb_pcidda, cb_pcidda_pci_table); +static int __devinit driver_cb_pcidda_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_cb_pcidda.driver_name); +} + +static void __devexit driver_cb_pcidda_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_cb_pcidda_pci_driver = { + .id_table = cb_pcidda_pci_table, + .probe = &driver_cb_pcidda_pci_probe, + .remove = __devexit_p(&driver_cb_pcidda_pci_remove) +}; + +static int __init driver_cb_pcidda_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_cb_pcidda); + if (retval < 0) + return retval; + + driver_cb_pcidda_pci_driver.name = (char *)driver_cb_pcidda.driver_name; + return pci_register_driver(&driver_cb_pcidda_pci_driver); +} + +static void __exit driver_cb_pcidda_cleanup_module(void) +{ + pci_unregister_driver(&driver_cb_pcidda_pci_driver); + comedi_driver_unregister(&driver_cb_pcidda); +} + +module_init(driver_cb_pcidda_init_module); +module_exit(driver_cb_pcidda_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/cb_pcidio.c b/drivers/staging/comedi/drivers/cb_pcidio.c index 3afba5fd85d6..a9d902f418a1 100644 --- a/drivers/staging/comedi/drivers/cb_pcidio.c +++ b/drivers/staging/comedi/drivers/cb_pcidio.c @@ -300,7 +300,43 @@ static int pcidio_detach(struct comedi_device *dev) * A convenient macro that defines init_module() and cleanup_module(), * as necessary. */ -COMEDI_PCI_INITCLEANUP(driver_cb_pcidio, pcidio_pci_table); +static int __devinit driver_cb_pcidio_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_cb_pcidio.driver_name); +} + +static void __devexit driver_cb_pcidio_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_cb_pcidio_pci_driver = { + .id_table = pcidio_pci_table, + .probe = &driver_cb_pcidio_pci_probe, + .remove = __devexit_p(&driver_cb_pcidio_pci_remove) +}; + +static int __init driver_cb_pcidio_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_cb_pcidio); + if (retval < 0) + return retval; + + driver_cb_pcidio_pci_driver.name = (char *)driver_cb_pcidio.driver_name; + return pci_register_driver(&driver_cb_pcidio_pci_driver); +} + +static void __exit driver_cb_pcidio_cleanup_module(void) +{ + pci_unregister_driver(&driver_cb_pcidio_pci_driver); + comedi_driver_unregister(&driver_cb_pcidio); +} + +module_init(driver_cb_pcidio_init_module); +module_exit(driver_cb_pcidio_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index bb5553d6b360..e50b8c259e2c 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -491,7 +491,45 @@ static int cb_pcimdas_ao_rinsn(struct comedi_device *dev, * A convenient macro that defines init_module() and cleanup_module(), * as necessary. */ -COMEDI_PCI_INITCLEANUP(driver_cb_pcimdas, cb_pcimdas_pci_table); +static int __devinit driver_cb_pcimdas_pci_probe(struct pci_dev *dev, + const struct pci_device_id + *ent) +{ + return comedi_pci_auto_config(dev, driver_cb_pcimdas.driver_name); +} + +static void __devexit driver_cb_pcimdas_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_cb_pcimdas_pci_driver = { + .id_table = cb_pcimdas_pci_table, + .probe = &driver_cb_pcimdas_pci_probe, + .remove = __devexit_p(&driver_cb_pcimdas_pci_remove) +}; + +static int __init driver_cb_pcimdas_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_cb_pcimdas); + if (retval < 0) + return retval; + + driver_cb_pcimdas_pci_driver.name = + (char *)driver_cb_pcimdas.driver_name; + return pci_register_driver(&driver_cb_pcimdas_pci_driver); +} + +static void __exit driver_cb_pcimdas_cleanup_module(void) +{ + pci_unregister_driver(&driver_cb_pcimdas_pci_driver); + comedi_driver_unregister(&driver_cb_pcimdas); +} + +module_init(driver_cb_pcimdas_init_module); +module_exit(driver_cb_pcimdas_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c index f404ec7723e5..3160330b1d9e 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdda.c +++ b/drivers/staging/comedi/drivers/cb_pcimdda.c @@ -195,7 +195,45 @@ MODULE_DESCRIPTION("Comedi low-level driver for the Computerboards PCIM-DDA " "series. Currently only supports PCIM-DDA06-16 (which " "also happens to be the only board in this series. :) ) "); MODULE_LICENSE("GPL"); -COMEDI_PCI_INITCLEANUP_NOMODULE(cb_pcimdda_driver, pci_table); +static int __devinit cb_pcimdda_driver_pci_probe(struct pci_dev *dev, + const struct pci_device_id + *ent) +{ + return comedi_pci_auto_config(dev, cb_pcimdda_driver.driver_name); +} + +static void __devexit cb_pcimdda_driver_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver cb_pcimdda_driver_pci_driver = { + .id_table = pci_table, + .probe = &cb_pcimdda_driver_pci_probe, + .remove = __devexit_p(&cb_pcimdda_driver_pci_remove) +}; + +static int __init cb_pcimdda_driver_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&cb_pcimdda_driver); + if (retval < 0) + return retval; + + cb_pcimdda_driver_pci_driver.name = + (char *)cb_pcimdda_driver.driver_name; + return pci_register_driver(&cb_pcimdda_driver_pci_driver); +} + +static void __exit cb_pcimdda_driver_cleanup_module(void) +{ + pci_unregister_driver(&cb_pcimdda_driver_pci_driver); + comedi_driver_unregister(&cb_pcimdda_driver); +} + +module_init(cb_pcimdda_driver_init_module); +module_exit(cb_pcimdda_driver_cleanup_module); static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c b/drivers/staging/comedi/drivers/contec_pci_dio.c index a3d55f46f0fb..24ac10ce0bae 100644 --- a/drivers/staging/comedi/drivers/contec_pci_dio.c +++ b/drivers/staging/comedi/drivers/contec_pci_dio.c @@ -232,7 +232,43 @@ static int contec_di_insn_bits(struct comedi_device *dev, return 2; } -COMEDI_PCI_INITCLEANUP(driver_contec, contec_pci_table); +static int __devinit driver_contec_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_contec.driver_name); +} + +static void __devexit driver_contec_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_contec_pci_driver = { + .id_table = contec_pci_table, + .probe = &driver_contec_pci_probe, + .remove = __devexit_p(&driver_contec_pci_remove) +}; + +static int __init driver_contec_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_contec); + if (retval < 0) + return retval; + + driver_contec_pci_driver.name = (char *)driver_contec.driver_name; + return pci_register_driver(&driver_contec_pci_driver); +} + +static void __exit driver_contec_cleanup_module(void) +{ + pci_unregister_driver(&driver_contec_pci_driver); + comedi_driver_unregister(&driver_contec); +} + +module_init(driver_contec_init_module); +module_exit(driver_contec_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index 83cde27ab725..6af6c8323d56 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -887,7 +887,45 @@ static int daqboard2000_detach(struct comedi_device *dev) return 0; } -COMEDI_PCI_INITCLEANUP(driver_daqboard2000, daqboard2000_pci_table); +static int __devinit driver_daqboard2000_pci_probe(struct pci_dev *dev, + const struct pci_device_id + *ent) +{ + return comedi_pci_auto_config(dev, driver_daqboard2000.driver_name); +} + +static void __devexit driver_daqboard2000_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_daqboard2000_pci_driver = { + .id_table = daqboard2000_pci_table, + .probe = &driver_daqboard2000_pci_probe, + .remove = __devexit_p(&driver_daqboard2000_pci_remove) +}; + +static int __init driver_daqboard2000_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_daqboard2000); + if (retval < 0) + return retval; + + driver_daqboard2000_pci_driver.name = + (char *)driver_daqboard2000.driver_name; + return pci_register_driver(&driver_daqboard2000_pci_driver); +} + +static void __exit driver_daqboard2000_cleanup_module(void) +{ + pci_unregister_driver(&driver_daqboard2000_pci_driver); + comedi_driver_unregister(&driver_daqboard2000); +} + +module_init(driver_daqboard2000_init_module); +module_exit(driver_daqboard2000_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index c3f1fedc6eb7..7e7b1a7d3fe5 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -1082,7 +1082,43 @@ int das08_common_detach(struct comedi_device *dev) EXPORT_SYMBOL_GPL(das08_common_detach); #ifdef CONFIG_COMEDI_PCI -COMEDI_PCI_INITCLEANUP(driver_das08, das08_pci_table); +static int __devinit driver_das08_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_das08.driver_name); +} + +static void __devexit driver_das08_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_das08_pci_driver = { + .id_table = das08_pci_table, + .probe = &driver_das08_pci_probe, + .remove = __devexit_p(&driver_das08_pci_remove) +}; + +static int __init driver_das08_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_das08); + if (retval < 0) + return retval; + + driver_das08_pci_driver.name = (char *)driver_das08.driver_name; + return pci_register_driver(&driver_das08_pci_driver); +} + +static void __exit driver_das08_cleanup_module(void) +{ + pci_unregister_driver(&driver_das08_pci_driver); + comedi_driver_unregister(&driver_das08); +} + +module_init(driver_das08_init_module); +module_exit(driver_das08_cleanup_module); #else static int __init driver_das08_init_module(void) { diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index 79ea24d2ce5a..656e7bbf2fcb 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -287,7 +287,43 @@ static struct comedi_driver driver_dt3000 = { .detach = dt3000_detach, }; -COMEDI_PCI_INITCLEANUP(driver_dt3000, dt3k_pci_table); +static int __devinit driver_dt3000_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_dt3000.driver_name); +} + +static void __devexit driver_dt3000_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_dt3000_pci_driver = { + .id_table = dt3k_pci_table, + .probe = &driver_dt3000_pci_probe, + .remove = __devexit_p(&driver_dt3000_pci_remove) +}; + +static int __init driver_dt3000_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_dt3000); + if (retval < 0) + return retval; + + driver_dt3000_pci_driver.name = (char *)driver_dt3000.driver_name; + return pci_register_driver(&driver_dt3000_pci_driver); +} + +static void __exit driver_dt3000_cleanup_module(void) +{ + pci_unregister_driver(&driver_dt3000_pci_driver); + comedi_driver_unregister(&driver_dt3000); +} + +module_init(driver_dt3000_init_module); +module_exit(driver_dt3000_cleanup_module); static void dt3k_ai_empty_fifo(struct comedi_device *dev, struct comedi_subdevice *s); diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c index a24d0994a195..1661b57ca2ad 100644 --- a/drivers/staging/comedi/drivers/gsc_hpdi.c +++ b/drivers/staging/comedi/drivers/gsc_hpdi.c @@ -345,7 +345,43 @@ static struct comedi_driver driver_hpdi = { .detach = hpdi_detach, }; -COMEDI_PCI_INITCLEANUP(driver_hpdi, hpdi_pci_table); +static int __devinit driver_hpdi_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_hpdi.driver_name); +} + +static void __devexit driver_hpdi_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_hpdi_pci_driver = { + .id_table = hpdi_pci_table, + .probe = &driver_hpdi_pci_probe, + .remove = __devexit_p(&driver_hpdi_pci_remove) +}; + +static int __init driver_hpdi_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_hpdi); + if (retval < 0) + return retval; + + driver_hpdi_pci_driver.name = (char *)driver_hpdi.driver_name; + return pci_register_driver(&driver_hpdi_pci_driver); +} + +static void __exit driver_hpdi_cleanup_module(void) +{ + pci_unregister_driver(&driver_hpdi_pci_driver); + comedi_driver_unregister(&driver_hpdi); +} + +module_init(driver_hpdi_init_module); +module_exit(driver_hpdi_cleanup_module); static int dio_config_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c index 35a789226997..788a01b11d28 100644 --- a/drivers/staging/comedi/drivers/jr3_pci.c +++ b/drivers/staging/comedi/drivers/jr3_pci.c @@ -987,7 +987,43 @@ static int jr3_pci_detach(struct comedi_device *dev) return 0; } -COMEDI_PCI_INITCLEANUP(driver_jr3_pci, jr3_pci_pci_table); +static int __devinit driver_jr3_pci_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_jr3_pci.driver_name); +} + +static void __devexit driver_jr3_pci_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_jr3_pci_pci_driver = { + .id_table = jr3_pci_pci_table, + .probe = &driver_jr3_pci_pci_probe, + .remove = __devexit_p(&driver_jr3_pci_pci_remove) +}; + +static int __init driver_jr3_pci_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_jr3_pci); + if (retval < 0) + return retval; + + driver_jr3_pci_pci_driver.name = (char *)driver_jr3_pci.driver_name; + return pci_register_driver(&driver_jr3_pci_pci_driver); +} + +static void __exit driver_jr3_pci_cleanup_module(void) +{ + pci_unregister_driver(&driver_jr3_pci_pci_driver); + comedi_driver_unregister(&driver_jr3_pci); +} + +module_init(driver_jr3_pci_init_module); +module_exit(driver_jr3_pci_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/ke_counter.c b/drivers/staging/comedi/drivers/ke_counter.c index 35d9869884db..e30aa0123692 100644 --- a/drivers/staging/comedi/drivers/ke_counter.c +++ b/drivers/staging/comedi/drivers/ke_counter.c @@ -96,7 +96,43 @@ static struct comedi_driver cnt_driver = { .detach = cnt_detach, }; -COMEDI_PCI_INITCLEANUP(cnt_driver, cnt_pci_table); +static int __devinit cnt_driver_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, cnt_driver.driver_name); +} + +static void __devexit cnt_driver_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver cnt_driver_pci_driver = { + .id_table = cnt_pci_table, + .probe = &cnt_driver_pci_probe, + .remove = __devexit_p(&cnt_driver_pci_remove) +}; + +static int __init cnt_driver_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&cnt_driver); + if (retval < 0) + return retval; + + cnt_driver_pci_driver.name = (char *)cnt_driver.driver_name; + return pci_register_driver(&cnt_driver_pci_driver); +} + +static void __exit cnt_driver_cleanup_module(void) +{ + pci_unregister_driver(&cnt_driver_pci_driver); + comedi_driver_unregister(&cnt_driver); +} + +module_init(cnt_driver_init_module); +module_exit(cnt_driver_cleanup_module); /*-- counter write ----------------------------------------------------------*/ diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index 58df32676e41..29e04819769e 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -2383,7 +2383,43 @@ static int me4000_cnt_insn_write(struct comedi_device *dev, return 1; } -COMEDI_PCI_INITCLEANUP(driver_me4000, me4000_pci_table); +static int __devinit driver_me4000_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_me4000.driver_name); +} + +static void __devexit driver_me4000_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_me4000_pci_driver = { + .id_table = me4000_pci_table, + .probe = &driver_me4000_pci_probe, + .remove = __devexit_p(&driver_me4000_pci_remove) +}; + +static int __init driver_me4000_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_me4000); + if (retval < 0) + return retval; + + driver_me4000_pci_driver.name = (char *)driver_me4000.driver_name; + return pci_register_driver(&driver_me4000_pci_driver); +} + +static void __exit driver_me4000_cleanup_module(void) +{ + pci_unregister_driver(&driver_me4000_pci_driver); + comedi_driver_unregister(&driver_me4000); +} + +module_init(driver_me4000_init_module); +module_exit(driver_me4000_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index d03c0f79ce45..579e6a571800 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -257,7 +257,43 @@ static struct comedi_driver me_driver = { .detach = me_detach, }; -COMEDI_PCI_INITCLEANUP(me_driver, me_pci_table); +static int __devinit me_driver_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, me_driver.driver_name); +} + +static void __devexit me_driver_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver me_driver_pci_driver = { + .id_table = me_pci_table, + .probe = &me_driver_pci_probe, + .remove = __devexit_p(&me_driver_pci_remove) +}; + +static int __init me_driver_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&me_driver); + if (retval < 0) + return retval; + + me_driver_pci_driver.name = (char *)me_driver.driver_name; + return pci_register_driver(&me_driver_pci_driver); +} + +static void __exit me_driver_cleanup_module(void) +{ + pci_unregister_driver(&me_driver_pci_driver); + comedi_driver_unregister(&me_driver); +} + +module_init(me_driver_init_module); +module_exit(me_driver_cleanup_module); /* Private data structure */ struct me_private_data { diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c index 1fc76cc6a28e..14e716e99a5c 100644 --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -490,4 +490,40 @@ static int ni6527_find_device(struct comedi_device *dev, int bus, int slot) return -EIO; } -COMEDI_PCI_INITCLEANUP(driver_ni6527, ni6527_pci_table); +static int __devinit driver_ni6527_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_ni6527.driver_name); +} + +static void __devexit driver_ni6527_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_ni6527_pci_driver = { + .id_table = ni6527_pci_table, + .probe = &driver_ni6527_pci_probe, + .remove = __devexit_p(&driver_ni6527_pci_remove) +}; + +static int __init driver_ni6527_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_ni6527); + if (retval < 0) + return retval; + + driver_ni6527_pci_driver.name = (char *)driver_ni6527.driver_name; + return pci_register_driver(&driver_ni6527_pci_driver); +} + +static void __exit driver_ni6527_cleanup_module(void) +{ + pci_unregister_driver(&driver_ni6527_pci_driver); + comedi_driver_unregister(&driver_ni6527); +} + +module_init(driver_ni6527_init_module); +module_exit(driver_ni6527_cleanup_module); diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index d793f5a4ac98..8b8e2aaf77fb 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -834,4 +834,40 @@ static int ni_65xx_find_device(struct comedi_device *dev, int bus, int slot) return -EIO; } -COMEDI_PCI_INITCLEANUP(driver_ni_65xx, ni_65xx_pci_table); +static int __devinit driver_ni_65xx_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_ni_65xx.driver_name); +} + +static void __devexit driver_ni_65xx_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_ni_65xx_pci_driver = { + .id_table = ni_65xx_pci_table, + .probe = &driver_ni_65xx_pci_probe, + .remove = __devexit_p(&driver_ni_65xx_pci_remove) +}; + +static int __init driver_ni_65xx_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_ni_65xx); + if (retval < 0) + return retval; + + driver_ni_65xx_pci_driver.name = (char *)driver_ni_65xx.driver_name; + return pci_register_driver(&driver_ni_65xx_pci_driver); +} + +static void __exit driver_ni_65xx_cleanup_module(void) +{ + pci_unregister_driver(&driver_ni_65xx_pci_driver); + comedi_driver_unregister(&driver_ni_65xx); +} + +module_init(driver_ni_65xx_init_module); +module_exit(driver_ni_65xx_cleanup_module); diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c index 6a6fae53ea0b..523cb2973373 100644 --- a/drivers/staging/comedi/drivers/ni_660x.c +++ b/drivers/staging/comedi/drivers/ni_660x.c @@ -471,7 +471,43 @@ static struct comedi_driver driver_ni_660x = { .detach = ni_660x_detach, }; -COMEDI_PCI_INITCLEANUP(driver_ni_660x, ni_660x_pci_table); +static int __devinit driver_ni_660x_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_ni_660x.driver_name); +} + +static void __devexit driver_ni_660x_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_ni_660x_pci_driver = { + .id_table = ni_660x_pci_table, + .probe = &driver_ni_660x_pci_probe, + .remove = __devexit_p(&driver_ni_660x_pci_remove) +}; + +static int __init driver_ni_660x_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_ni_660x); + if (retval < 0) + return retval; + + driver_ni_660x_pci_driver.name = (char *)driver_ni_660x.driver_name; + return pci_register_driver(&driver_ni_660x_pci_driver); +} + +static void __exit driver_ni_660x_cleanup_module(void) +{ + pci_unregister_driver(&driver_ni_660x_pci_driver); + comedi_driver_unregister(&driver_ni_660x); +} + +module_init(driver_ni_660x_init_module); +module_exit(driver_ni_660x_cleanup_module); static int ni_660x_find_device(struct comedi_device *dev, int bus, int slot); static int ni_660x_set_pfi_routing(struct comedi_device *dev, unsigned chan, diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c index 44ae8368454d..e9f034efdc6f 100644 --- a/drivers/staging/comedi/drivers/ni_670x.c +++ b/drivers/staging/comedi/drivers/ni_670x.c @@ -120,7 +120,43 @@ static struct comedi_driver driver_ni_670x = { .detach = ni_670x_detach, }; -COMEDI_PCI_INITCLEANUP(driver_ni_670x, ni_670x_pci_table); +static int __devinit driver_ni_670x_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_ni_670x.driver_name); +} + +static void __devexit driver_ni_670x_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_ni_670x_pci_driver = { + .id_table = ni_670x_pci_table, + .probe = &driver_ni_670x_pci_probe, + .remove = __devexit_p(&driver_ni_670x_pci_remove) +}; + +static int __init driver_ni_670x_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_ni_670x); + if (retval < 0) + return retval; + + driver_ni_670x_pci_driver.name = (char *)driver_ni_670x.driver_name; + return pci_register_driver(&driver_ni_670x_pci_driver); +} + +static void __exit driver_ni_670x_cleanup_module(void) +{ + pci_unregister_driver(&driver_ni_670x_pci_driver); + comedi_driver_unregister(&driver_ni_670x); +} + +module_init(driver_ni_670x_init_module); +module_exit(driver_ni_670x_cleanup_module); static struct comedi_lrange range_0_20mA = { 1, {RANGE_mA(0, 20)} }; diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index 383ee1024ad3..170bab60555a 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -2078,7 +2078,43 @@ static void write_caldac(struct comedi_device *dev, unsigned int channel, } #ifdef CONFIG_COMEDI_PCI -COMEDI_PCI_INITCLEANUP(driver_labpc, labpc_pci_table); +static int __devinit driver_labpc_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_labpc.driver_name); +} + +static void __devexit driver_labpc_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_labpc_pci_driver = { + .id_table = labpc_pci_table, + .probe = &driver_labpc_pci_probe, + .remove = __devexit_p(&driver_labpc_pci_remove) +}; + +static int __init driver_labpc_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_labpc); + if (retval < 0) + return retval; + + driver_labpc_pci_driver.name = (char *)driver_labpc.driver_name; + return pci_register_driver(&driver_labpc_pci_driver); +} + +static void __exit driver_labpc_cleanup_module(void) +{ + pci_unregister_driver(&driver_labpc_pci_driver); + comedi_driver_unregister(&driver_labpc); +} + +module_init(driver_labpc_init_module); +module_exit(driver_labpc_cleanup_module); #else static int __init driver_labpc_init_module(void) { diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index b126638d33b2..84a15c34e484 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -1317,4 +1317,40 @@ static int nidio_find_device(struct comedi_device *dev, int bus, int slot) return -EIO; } -COMEDI_PCI_INITCLEANUP(driver_pcidio, ni_pcidio_pci_table); +static int __devinit driver_pcidio_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_pcidio.driver_name); +} + +static void __devexit driver_pcidio_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_pcidio_pci_driver = { + .id_table = ni_pcidio_pci_table, + .probe = &driver_pcidio_pci_probe, + .remove = __devexit_p(&driver_pcidio_pci_remove) +}; + +static int __init driver_pcidio_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_pcidio); + if (retval < 0) + return retval; + + driver_pcidio_pci_driver.name = (char *)driver_pcidio.driver_name; + return pci_register_driver(&driver_pcidio_pci_driver); +} + +static void __exit driver_pcidio_cleanup_module(void) +{ + pci_unregister_driver(&driver_pcidio_pci_driver); + comedi_driver_unregister(&driver_pcidio); +} + +module_init(driver_pcidio_init_module); +module_exit(driver_pcidio_cleanup_module); diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c index 577fda84190d..23a381247285 100644 --- a/drivers/staging/comedi/drivers/ni_pcimio.c +++ b/drivers/staging/comedi/drivers/ni_pcimio.c @@ -1239,7 +1239,43 @@ static struct comedi_driver driver_pcimio = { .detach = pcimio_detach, }; -COMEDI_PCI_INITCLEANUP(driver_pcimio, ni_pci_table) +static int __devinit driver_pcimio_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_pcimio.driver_name); +} + +static void __devexit driver_pcimio_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_pcimio_pci_driver = { + .id_table = ni_pci_table, + .probe = &driver_pcimio_pci_probe, + .remove = __devexit_p(&driver_pcimio_pci_remove) +}; + +static int __init driver_pcimio_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_pcimio); + if (retval < 0) + return retval; + + driver_pcimio_pci_driver.name = (char *)driver_pcimio.driver_name; + return pci_register_driver(&driver_pcimio_pci_driver); +} + +static void __exit driver_pcimio_cleanup_module(void) +{ + pci_unregister_driver(&driver_pcimio_pci_driver); + comedi_driver_unregister(&driver_pcimio); +} + +module_init(driver_pcimio_init_module); +module_exit(driver_pcimio_cleanup_module); struct ni_private { NI_PRIVATE_COMMON}; diff --git a/drivers/staging/comedi/drivers/rtd520.c b/drivers/staging/comedi/drivers/rtd520.c index 1ca92f949362..0367d2b9e2fa 100644 --- a/drivers/staging/comedi/drivers/rtd520.c +++ b/drivers/staging/comedi/drivers/rtd520.c @@ -2356,7 +2356,43 @@ static int rtd_dio_insn_config(struct comedi_device *dev, * A convenient macro that defines init_module() and cleanup_module(), * as necessary. */ -COMEDI_PCI_INITCLEANUP(rtd520Driver, rtd520_pci_table); +static int __devinit rtd520Driver_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, rtd520Driver.driver_name); +} + +static void __devexit rtd520Driver_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver rtd520Driver_pci_driver = { + .id_table = rtd520_pci_table, + .probe = &rtd520Driver_pci_probe, + .remove = __devexit_p(&rtd520Driver_pci_remove) +}; + +static int __init rtd520Driver_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&rtd520Driver); + if (retval < 0) + return retval; + + rtd520Driver_pci_driver.name = (char *)rtd520Driver.driver_name; + return pci_register_driver(&rtd520Driver_pci_driver); +} + +static void __exit rtd520Driver_cleanup_module(void) +{ + pci_unregister_driver(&rtd520Driver_pci_driver); + comedi_driver_unregister(&rtd520Driver); +} + +module_init(rtd520Driver_init_module); +module_exit(rtd520Driver_cleanup_module); MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index febb62e86ec3..f775ee6171ab 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -224,7 +224,43 @@ static struct dio_private *dio_private_word[]={ #define devpriv ((struct s626_private *)dev->private) #define diopriv ((struct dio_private *)s->private) -COMEDI_PCI_INITCLEANUP_NOMODULE(driver_s626, s626_pci_table); +static int __devinit driver_s626_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_s626.driver_name); +} + +static void __devexit driver_s626_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_s626_pci_driver = { + .id_table = s626_pci_table, + .probe = &driver_s626_pci_probe, + .remove = __devexit_p(&driver_s626_pci_remove) +}; + +static int __init driver_s626_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_s626); + if (retval < 0) + return retval; + + driver_s626_pci_driver.name = (char *)driver_s626.driver_name; + return pci_register_driver(&driver_s626_pci_driver); +} + +static void __exit driver_s626_cleanup_module(void) +{ + pci_unregister_driver(&driver_s626_pci_driver); + comedi_driver_unregister(&driver_s626); +} + +module_init(driver_s626_init_module); +module_exit(driver_s626_cleanup_module); /* ioctl routines */ static int s626_ai_insn_config(struct comedi_device *dev, diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index d1d5437c5995..732a323ab710 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -620,6 +620,45 @@ static int skel_dio_insn_config(struct comedi_device *dev, return insn->n; } +#ifdef CONFIG_COMEDI_PCI +static int __devinit driver_skel_pci_probe(struct pci_dev *dev, + const struct pci_device_id *ent) +{ + return comedi_pci_auto_config(dev, driver_skel.driver_name); +} + +static void __devexit driver_skel_pci_remove(struct pci_dev *dev) +{ + comedi_pci_auto_unconfig(dev); +} + +static struct pci_driver driver_skel_pci_driver = { + .id_table = skel_pci_table, + .probe = &driver_skel_pci_probe, + .remove = __devexit_p(&driver_skel_pci_remove) +}; + +static int __init driver_skel_init_module(void) +{ + int retval; + + retval = comedi_driver_register(&driver_skel); + if (retval < 0) + return retval; + + driver_skel_pci_driver.name = (char *)driver_skel.driver_name; + return pci_register_driver(&driver_skel_pci_driver); +} + +static void __exit driver_skel_cleanup_module(void) +{ + pci_unregister_driver(&driver_skel_pci_driver); + comedi_driver_unregister(&driver_skel); +} + +module_init(driver_skel_init_module); +module_exit(driver_skel_cleanup_module); +#else static int __init driver_skel_init_module(void) { return comedi_driver_register(&driver_skel); @@ -632,10 +671,7 @@ static void __exit driver_skel_cleanup_module(void) module_init(driver_skel_init_module); module_exit(driver_skel_cleanup_module); -/* If you are writing a PCI driver you should use COMEDI_PCI_INITCLEANUP - * instead. - */ -/* COMEDI_PCI_INITCLEANUP(driver_skel, skel_pci_table) */ +#endif MODULE_AUTHOR("Comedi http://www.comedi.org"); MODULE_DESCRIPTION("Comedi low-level driver"); From 56b8421ceef7f2dae95b882034ebf6958bad58f6 Mon Sep 17 00:00:00 2001 From: Arun Thomas Date: Thu, 10 Jun 2010 23:38:29 +0200 Subject: [PATCH 027/523] Staging: comedi: Remove typedefs Remove all remaining typedefs from comedi drivers Signed-off-by: Arun Thomas Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/TODO | 1 - .../comedi/drivers/addi-data/addi_eeprom.c | 10 +++++----- drivers/staging/comedi/drivers/jr3_pci.c | 7 ++----- drivers/staging/comedi/drivers/pcmmio.c | 17 ++++++++++++----- drivers/staging/comedi/drivers/s626.h | 9 --------- 5 files changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/staging/comedi/TODO b/drivers/staging/comedi/TODO index 15c9348fb938..b10f739b7e3e 100644 --- a/drivers/staging/comedi/TODO +++ b/drivers/staging/comedi/TODO @@ -2,7 +2,6 @@ TODO: - checkpatch.pl cleanups - Lindent - remove all wrappers - - remove typedefs - audit userspace interface - reserve major number - cleanup the individual comedi drivers as well diff --git a/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c b/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c index bea329f44d80..8fef6f4ea6a0 100644 --- a/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c +++ b/drivers/staging/comedi/drivers/addi-data/addi_eeprom.c @@ -101,10 +101,10 @@ struct str_TimerMainHeader { }; -typedef struct { +struct str_AnalogOutputHeader { unsigned short w_Nchannel; unsigned char b_Resolution; -} str_AnalogOutputHeader; +}; struct str_AnalogInputHeader { unsigned short w_Nchannel; @@ -136,7 +136,7 @@ int i_EepromReadTimerHeader(unsigned short w_PCIBoardEepromAddress, int i_EepromReadAnlogOutputHeader(unsigned short w_PCIBoardEepromAddress, char *pc_PCIChipInformation, unsigned short w_Address, - str_AnalogOutputHeader *s_Header); + struct str_AnalogOutputHeader *s_Header); int i_EepromReadAnlogInputHeader(unsigned short w_PCIBoardEepromAddress, char *pc_PCIChipInformation, unsigned short w_Address, @@ -811,7 +811,7 @@ int i_EepromReadMainHeader(unsigned short w_PCIBoardEepromAddress, struct str_DigitalInputHeader s_DigitalInputHeader; struct str_DigitalOutputHeader s_DigitalOutputHeader; /* struct str_TimerMainHeader s_TimerMainHeader,s_WatchdogMainHeader; */ - str_AnalogOutputHeader s_AnalogOutputHeader; + struct str_AnalogOutputHeader s_AnalogOutputHeader; struct str_AnalogInputHeader s_AnalogInputHeader; /* Read size */ @@ -1081,7 +1081,7 @@ int i_EepromReadTimerHeader(unsigned short w_PCIBoardEepromAddress, int i_EepromReadAnlogOutputHeader(unsigned short w_PCIBoardEepromAddress, char *pc_PCIChipInformation, unsigned short w_Address, - str_AnalogOutputHeader *s_Header) + struct str_AnalogOutputHeader *s_Header) { unsigned short w_Temp; /* No of channels for 1st hard component */ diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c index 788a01b11d28..ba900a80a470 100644 --- a/drivers/staging/comedi/drivers/jr3_pci.c +++ b/drivers/staging/comedi/drivers/jr3_pci.c @@ -123,12 +123,9 @@ struct jr3_pci_subdev_private { }; /* Hotplug firmware loading stuff */ - -typedef int comedi_firmware_callback(struct comedi_device *dev, - const u8 * data, size_t size); - static int comedi_load_firmware(struct comedi_device *dev, char *name, - comedi_firmware_callback cb) + int (*cb)(struct comedi_device *dev, + const u8 *data, size_t size)) { int result = 0; const struct firmware *fw; diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index f0df9d1e4fec..5c832d7ed45d 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -145,10 +145,6 @@ Configuration Options: #define PAGE_ENAB 2 #define PAGE_INT_ID 3 -typedef int (*comedi_insn_fn_t) (struct comedi_device *, - struct comedi_subdevice *, - struct comedi_insn *, unsigned int *); - static int ai_rinsn(struct comedi_device *, struct comedi_subdevice *, struct comedi_insn *, unsigned int *); static int ao_rinsn(struct comedi_device *, struct comedi_subdevice *, @@ -171,7 +167,18 @@ struct pcmmio_board { const int n_ai_chans; const int n_ao_chans; const struct comedi_lrange *ai_range_table, *ao_range_table; - comedi_insn_fn_t ai_rinsn, ao_rinsn, ao_winsn; + int (*ai_rinsn) (struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); + int (*ao_rinsn) (struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); + int (*ao_winsn) (struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); }; static const struct comedi_lrange ranges_ai = { diff --git a/drivers/staging/comedi/drivers/s626.h b/drivers/staging/comedi/drivers/s626.h index d02742a95294..2d1afecbbb60 100644 --- a/drivers/staging/comedi/drivers/s626.h +++ b/drivers/staging/comedi/drivers/s626.h @@ -720,15 +720,6 @@ #define STDMSK_CLKMULT ((uint16_t)(3 << STDBIT_CLKMULT)) #define STDMSK_CLKENAB ((uint16_t)(1 << STDBIT_CLKENAB)) -/* typedef struct indexCounter */ -/* { */ -/* unsigned int ao; */ -/* unsigned int ai; */ -/* unsigned int digout; */ -/* unsigned int digin; */ -/* unsigned int enc; */ -/* }CallCounter; */ - struct bufferDMA { dma_addr_t PhysicalBase; void *LogicalBase; From b6241fda0a25062cecc88cefd43658460cfe26a4 Mon Sep 17 00:00:00 2001 From: Gustavo Silva Date: Sat, 12 Jun 2010 16:39:18 -0500 Subject: [PATCH 028/523] Staging: comedi: drivers: fix coding style issues in me4000.c This is a patch to the me4000.c file that fixes up the following issues: ERROR: space required after that close brace '}' x 13 ERROR: spaces required around that ':' (ctx:VxV) x 3 WARNING: line over 80 characters x 96 WARNING: braces {} are not necessary for any arm of this statement x 2 Signed-off-by: Gustavo Silva Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/me4000.c | 416 +++++++++++++----------- 1 file changed, 227 insertions(+), 189 deletions(-) diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c index 29e04819769e..56c9279c700e 100644 --- a/drivers/staging/comedi/drivers/me4000.c +++ b/drivers/staging/comedi/drivers/me4000.c @@ -91,22 +91,22 @@ static DEFINE_PCI_DEVICE_TABLE(me4000_pci_table) = { MODULE_DEVICE_TABLE(pci, me4000_pci_table); static const struct me4000_board me4000_boards[] = { - {"ME-4650", 0x4650, {0, 0}, {16, 0, 0, 0}, {4}, {0}}, + {"ME-4650", 0x4650, {0, 0}, {16, 0, 0, 0}, {4}, {0} }, - {"ME-4660", 0x4660, {0, 0}, {32, 0, 16, 0}, {4}, {3}}, - {"ME-4660i", 0x4661, {0, 0}, {32, 0, 16, 0}, {4}, {3}}, - {"ME-4660s", 0x4662, {0, 0}, {32, 8, 16, 0}, {4}, {3}}, - {"ME-4660is", 0x4663, {0, 0}, {32, 8, 16, 0}, {4}, {3}}, + {"ME-4660", 0x4660, {0, 0}, {32, 0, 16, 0}, {4}, {3} }, + {"ME-4660i", 0x4661, {0, 0}, {32, 0, 16, 0}, {4}, {3} }, + {"ME-4660s", 0x4662, {0, 0}, {32, 8, 16, 0}, {4}, {3} }, + {"ME-4660is", 0x4663, {0, 0}, {32, 8, 16, 0}, {4}, {3} }, - {"ME-4670", 0x4670, {4, 0}, {32, 0, 16, 1}, {4}, {3}}, - {"ME-4670i", 0x4671, {4, 0}, {32, 0, 16, 1}, {4}, {3}}, - {"ME-4670s", 0x4672, {4, 0}, {32, 8, 16, 1}, {4}, {3}}, - {"ME-4670is", 0x4673, {4, 0}, {32, 8, 16, 1}, {4}, {3}}, + {"ME-4670", 0x4670, {4, 0}, {32, 0, 16, 1}, {4}, {3} }, + {"ME-4670i", 0x4671, {4, 0}, {32, 0, 16, 1}, {4}, {3} }, + {"ME-4670s", 0x4672, {4, 0}, {32, 8, 16, 1}, {4}, {3} }, + {"ME-4670is", 0x4673, {4, 0}, {32, 8, 16, 1}, {4}, {3} }, - {"ME-4680", 0x4680, {4, 4}, {32, 0, 16, 1}, {4}, {3}}, - {"ME-4680i", 0x4681, {4, 4}, {32, 0, 16, 1}, {4}, {3}}, - {"ME-4680s", 0x4682, {4, 4}, {32, 8, 16, 1}, {4}, {3}}, - {"ME-4680is", 0x4683, {4, 4}, {32, 8, 16, 1}, {4}, {3}}, + {"ME-4680", 0x4680, {4, 4}, {32, 0, 16, 1}, {4}, {3} }, + {"ME-4680i", 0x4681, {4, 4}, {32, 0, 16, 1}, {4}, {3} }, + {"ME-4680s", 0x4682, {4, 4}, {32, 8, 16, 1}, {4}, {3} }, + {"ME-4680is", 0x4683, {4, 4}, {32, 8, 16, 1}, {4}, {3} }, {0}, }; @@ -120,10 +120,10 @@ static int me4000_attach(struct comedi_device *dev, struct comedi_devconfig *it); static int me4000_detach(struct comedi_device *dev); static struct comedi_driver driver_me4000 = { -driver_name:"me4000", -module:THIS_MODULE, -attach:me4000_attach, -detach:me4000_detach, +driver_name: "me4000", +module : THIS_MODULE, +attach : me4000_attach, +detach : me4000_detach, }; /*----------------------------------------------------------------------------- @@ -302,8 +302,8 @@ static int me4000_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (request_irq(info->irq, me4000_ai_isr, IRQF_SHARED, "ME-4000", dev)) { printk - ("comedi%d: me4000: me4000_attach(): Unable to allocate irq\n", - dev->minor); + ("comedi%d: me4000: me4000_attach(): " + "Unable to allocate irq\n", dev->minor); } else { dev->read_subdev = s; s->subdev_flags |= SDF_CMD_READ; @@ -313,8 +313,8 @@ static int me4000_attach(struct comedi_device *dev, struct comedi_devconfig *it) } } else { printk(KERN_WARNING - "comedi%d: me4000: me4000_attach(): No interrupt available\n", - dev->minor); + "comedi%d: me4000: me4000_attach(): " + "No interrupt available\n", dev->minor); } } else { s->type = COMEDI_SUBD_UNUSED; @@ -409,10 +409,16 @@ static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it) for (i = 0; i < ME4000_BOARD_VERSIONS; i++) { if (me4000_boards[i].device_id == pci_device->device) { - /* Was a particular bus/slot requested? */ + /* + * Was a particular + * bus/slot requested? + */ if ((it->options[0] != 0) || (it->options[1] != 0)) { - /* Are we on the wrong bus/slot? */ + /* + * Are we on the wrong + * bus/slot? + */ if (pci_device->bus->number != it->options[0] || @@ -433,14 +439,16 @@ static int me4000_probe(struct comedi_device *dev, struct comedi_devconfig *it) } printk(KERN_ERR - "comedi%d: me4000: me4000_probe(): No supported board found (req. bus/slot : %d/%d)\n", + "comedi%d: me4000: me4000_probe(): " + "No supported board found (req. bus/slot : %d/%d)\n", dev->minor, it->options[0], it->options[1]); return -ENODEV; found: printk(KERN_INFO - "comedi%d: me4000: me4000_probe(): Found %s at PCI bus %d, slot %d\n", + "comedi%d: me4000: me4000_probe(): " + "Found %s at PCI bus %d, slot %d\n", dev->minor, me4000_boards[i].name, pci_device->bus->number, PCI_SLOT(pci_device->devfn)); @@ -451,8 +459,8 @@ found: result = comedi_pci_enable(pci_device, dev->board_name); if (result) { printk(KERN_ERR - "comedi%d: me4000: me4000_probe(): Cannot enable PCI device and request I/O regions\n", - dev->minor); + "comedi%d: me4000: me4000_probe(): Cannot enable PCI " + "device and request I/O regions\n", dev->minor); return result; } @@ -460,16 +468,16 @@ found: result = get_registers(dev, pci_device); if (result) { printk(KERN_ERR - "comedi%d: me4000: me4000_probe(): Cannot get registers\n", - dev->minor); + "comedi%d: me4000: me4000_probe(): " + "Cannot get registers\n", dev->minor); return result; } /* Initialize board info */ result = init_board_info(dev, pci_device); if (result) { printk(KERN_ERR - "comedi%d: me4000: me4000_probe(): Cannot init baord info\n", - dev->minor); + "comedi%d: me4000: me4000_probe(): " + "Cannot init baord info\n", dev->minor); return result; } @@ -477,8 +485,8 @@ found: result = init_ao_context(dev); if (result) { printk(KERN_ERR - "comedi%d: me4000: me4000_probe(): Cannot init ao context\n", - dev->minor); + "comedi%d: me4000: me4000_probe(): " + "Cannot init ao context\n", dev->minor); return result; } @@ -486,8 +494,8 @@ found: result = init_ai_context(dev); if (result) { printk(KERN_ERR - "comedi%d: me4000: me4000_probe(): Cannot init ai context\n", - dev->minor); + "comedi%d: me4000: me4000_probe(): " + "Cannot init ai context\n", dev->minor); return result; } @@ -495,8 +503,8 @@ found: result = init_dio_context(dev); if (result) { printk(KERN_ERR - "comedi%d: me4000: me4000_probe(): Cannot init dio context\n", - dev->minor); + "comedi%d: me4000: me4000_probe(): " + "Cannot init dio context\n", dev->minor); return result; } @@ -504,8 +512,8 @@ found: result = init_cnt_context(dev); if (result) { printk(KERN_ERR - "comedi%d: me4000: me4000_probe(): Cannot init cnt context\n", - dev->minor); + "comedi%d: me4000: me4000_probe(): " + "Cannot init cnt context\n", dev->minor); return result; } @@ -513,8 +521,8 @@ found: result = xilinx_download(dev); if (result) { printk(KERN_ERR - "comedi%d: me4000: me4000_probe(): Can't download firmware\n", - dev->minor); + "comedi%d: me4000: me4000_probe(): " + "Can't download firmware\n", dev->minor); return result; } @@ -535,24 +543,24 @@ static int get_registers(struct comedi_device *dev, struct pci_dev *pci_dev_p) CALL_PDEBUG("In get_registers()\n"); - /*--------------------------- plx regbase ---------------------------------*/ + /*--------------------------- plx regbase -------------------------------*/ info->plx_regbase = pci_resource_start(pci_dev_p, 1); if (info->plx_regbase == 0) { printk(KERN_ERR - "comedi%d: me4000: get_registers(): PCI base address 1 is not available\n", - dev->minor); + "comedi%d: me4000: get_registers(): " + "PCI base address 1 is not available\n", dev->minor); return -ENODEV; } info->plx_regbase_size = pci_resource_len(pci_dev_p, 1); - /*--------------------------- me4000 regbase ------------------------------*/ + /*--------------------------- me4000 regbase ----------------------------*/ info->me4000_regbase = pci_resource_start(pci_dev_p, 2); if (info->me4000_regbase == 0) { printk(KERN_ERR - "comedi%d: me4000: get_registers(): PCI base address 2 is not available\n", - dev->minor); + "comedi%d: me4000: get_registers(): " + "PCI base address 2 is not available\n", dev->minor); return -ENODEV; } info->me4000_regbase_size = pci_resource_len(pci_dev_p, 2); @@ -562,19 +570,19 @@ static int get_registers(struct comedi_device *dev, struct pci_dev *pci_dev_p) info->timer_regbase = pci_resource_start(pci_dev_p, 3); if (info->timer_regbase == 0) { printk(KERN_ERR - "comedi%d: me4000: get_registers(): PCI base address 3 is not available\n", - dev->minor); + "comedi%d: me4000: get_registers(): " + "PCI base address 3 is not available\n", dev->minor); return -ENODEV; } info->timer_regbase_size = pci_resource_len(pci_dev_p, 3); - /*--------------------------- program regbase ------------------------------*/ + /*--------------------------- program regbase ----------------------------*/ info->program_regbase = pci_resource_start(pci_dev_p, 5); if (info->program_regbase == 0) { printk(KERN_ERR - "comedi%d: me4000: get_registers(): PCI base address 5 is not available\n", - dev->minor); + "comedi%d: me4000: get_registers(): " + "PCI base address 5 is not available\n", dev->minor); return -ENODEV; } info->program_regbase_size = pci_resource_len(pci_dev_p, 5); @@ -800,8 +808,8 @@ static int xilinx_download(struct comedi_device *dev) udelay(20); if (!(inl(info->plx_regbase + PLX_INTCSR) & 0x20)) { printk(KERN_ERR - "comedi%d: me4000: xilinx_download(): Can't init Xilinx\n", - dev->minor); + "comedi%d: me4000: xilinx_download(): " + "Can't init Xilinx\n", dev->minor); return -EIO; } @@ -810,8 +818,8 @@ static int xilinx_download(struct comedi_device *dev) value &= ~0x100; outl(value, info->plx_regbase + PLX_ICR); if (FIRMWARE_NOT_AVAILABLE) { - comedi_error(dev, - "xilinx firmware unavailable due to licensing, aborting"); + comedi_error(dev, "xilinx firmware unavailable " + "due to licensing, aborting"); return -EIO; } else { /* Download Xilinx firmware */ @@ -826,7 +834,8 @@ static int xilinx_download(struct comedi_device *dev) /* Check if BUSY flag is low */ if (inl(info->plx_regbase + PLX_ICR) & 0x20) { printk(KERN_ERR - "comedi%d: me4000: xilinx_download(): Xilinx is still busy (idx = %d)\n", + "comedi%d: me4000: xilinx_download(): " + "Xilinx is still busy (idx = %d)\n", dev->minor, idx); return -EIO; } @@ -837,11 +846,11 @@ static int xilinx_download(struct comedi_device *dev) if (inl(info->plx_regbase + PLX_ICR) & 0x4) { } else { printk(KERN_ERR - "comedi%d: me4000: xilinx_download(): DONE flag is not set\n", - dev->minor); + "comedi%d: me4000: xilinx_download(): " + "DONE flag is not set\n", dev->minor); printk(KERN_ERR - "comedi%d: me4000: xilinx_download(): Download not successful\n", - dev->minor); + "comedi%d: me4000: xilinx_download(): " + "Download not successful\n", dev->minor); return -EIO; } @@ -902,7 +911,10 @@ static int reset_board(struct comedi_device *dev) me4000_outl(dev, ME4000_AO_DEMUX_ADJUST_VALUE, info->me4000_regbase + ME4000_AO_DEMUX_ADJUST_REG); - /* Set digital I/O direction for port 0 to output on isolated versions */ + /* + * Set digital I/O direction for port 0 + * to output on isolated versions + */ if (!(me4000_inl(dev, info->me4000_regbase + ME4000_DIO_DIR_REG) & 0x1)) { me4000_outl(dev, 0x1, info->me4000_regbase + ME4000_DIO_CTRL_REG); @@ -950,8 +962,8 @@ static int me4000_ai_insn_read(struct comedi_device *dev, return 0; } else if (insn->n > 1) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_insn_read(): Invalid instruction length %d\n", - dev->minor, insn->n); + "comedi%d: me4000: me4000_ai_insn_read(): " + "Invalid instruction length %d\n", dev->minor, insn->n); return -EINVAL; } @@ -970,8 +982,8 @@ static int me4000_ai_insn_read(struct comedi_device *dev, break; default: printk(KERN_ERR - "comedi%d: me4000: me4000_ai_insn_read(): Invalid range specified\n", - dev->minor); + "comedi%d: me4000: me4000_ai_insn_read(): " + "Invalid range specified\n", dev->minor); return -EINVAL; } @@ -980,8 +992,8 @@ static int me4000_ai_insn_read(struct comedi_device *dev, case AREF_COMMON: if (chan >= thisboard->ai.count) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_insn_read(): Analog input is not available\n", - dev->minor); + "comedi%d: me4000: me4000_ai_insn_read(): " + "Analog input is not available\n", dev->minor); return -EINVAL; } entry |= ME4000_AI_LIST_INPUT_SINGLE_ENDED | chan; @@ -990,23 +1002,24 @@ static int me4000_ai_insn_read(struct comedi_device *dev, case AREF_DIFF: if (rang == 0 || rang == 1) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_insn_read(): Range must be bipolar when aref = diff\n", + "comedi%d: me4000: me4000_ai_insn_read(): " + "Range must be bipolar when aref = diff\n", dev->minor); return -EINVAL; } if (chan >= thisboard->ai.diff_count) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_insn_read(): Analog input is not available\n", - dev->minor); + "comedi%d: me4000: me4000_ai_insn_read(): " + "Analog input is not available\n", dev->minor); return -EINVAL; } entry |= ME4000_AI_LIST_INPUT_DIFFERENTIAL | chan; break; default: printk(KERN_ERR - "comedi%d: me4000: me4000_ai_insn_read(): Invalid aref specified\n", - dev->minor); + "comedi%d: me4000: me4000_ai_insn_read(): " + "Invalid aref specified\n", dev->minor); return -EINVAL; } @@ -1045,8 +1058,8 @@ static int me4000_ai_insn_read(struct comedi_device *dev, (me4000_inl(dev, info->ai_context.status_reg) & ME4000_AI_STATUS_BIT_EF_DATA)) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_insn_read(): Value not available after wait\n", - dev->minor); + "comedi%d: me4000: me4000_ai_insn_read(): " + "Value not available after wait\n", dev->minor); return -EIO; } @@ -1086,24 +1099,24 @@ static int ai_check_chanlist(struct comedi_device *dev, /* Check whether a channel list is available */ if (!cmd->chanlist_len) { printk(KERN_ERR - "comedi%d: me4000: ai_check_chanlist(): No channel list available\n", - dev->minor); + "comedi%d: me4000: ai_check_chanlist(): " + "No channel list available\n", dev->minor); return -EINVAL; } /* Check the channel list size */ if (cmd->chanlist_len > ME4000_AI_CHANNEL_LIST_COUNT) { printk(KERN_ERR - "comedi%d: me4000: ai_check_chanlist(): Channel list is to large\n", - dev->minor); + "comedi%d: me4000: ai_check_chanlist(): " + "Channel list is to large\n", dev->minor); return -EINVAL; } /* Check the pointer */ if (!cmd->chanlist) { printk(KERN_ERR - "comedi%d: me4000: ai_check_chanlist(): NULL pointer to channel list\n", - dev->minor); + "comedi%d: me4000: ai_check_chanlist(): " + "NULL pointer to channel list\n", dev->minor); return -EFAULT; } @@ -1112,7 +1125,8 @@ static int ai_check_chanlist(struct comedi_device *dev, for (i = 0; i < cmd->chanlist_len; i++) { if (CR_AREF(cmd->chanlist[i]) != aref) { printk(KERN_ERR - "comedi%d: me4000: ai_check_chanlist(): Mode is not equal for all entries\n", + "comedi%d: me4000: ai_check_chanlist(): " + "Mode is not equal for all entries\n", dev->minor); return -EINVAL; } @@ -1124,8 +1138,8 @@ static int ai_check_chanlist(struct comedi_device *dev, if (CR_CHAN(cmd->chanlist[i]) >= thisboard->ai.diff_count) { printk(KERN_ERR - "comedi%d: me4000: ai_check_chanlist(): Channel number to high\n", - dev->minor); + "comedi%d: me4000: ai_check_chanlist():" + " Channel number to high\n", dev->minor); return -EINVAL; } } @@ -1133,8 +1147,8 @@ static int ai_check_chanlist(struct comedi_device *dev, for (i = 0; i < cmd->chanlist_len; i++) { if (CR_CHAN(cmd->chanlist[i]) >= thisboard->ai.count) { printk(KERN_ERR - "comedi%d: me4000: ai_check_chanlist(): Channel number to high\n", - dev->minor); + "comedi%d: me4000: ai_check_chanlist(): " + "Channel number to high\n", dev->minor); return -EINVAL; } } @@ -1146,7 +1160,9 @@ static int ai_check_chanlist(struct comedi_device *dev, if (CR_RANGE(cmd->chanlist[i]) != 1 && CR_RANGE(cmd->chanlist[i]) != 2) { printk(KERN_ERR - "comedi%d: me4000: ai_check_chanlist(): Bipolar is not selected in differential mode\n", + "comedi%d: me4000: ai_check_chanlist(): " + "Bipolar is not selected in " + "differential mode\n", dev->minor); return -EINVAL; } @@ -1330,21 +1346,19 @@ static int ai_write_chanlist(struct comedi_device *dev, entry = chan; - if (rang == 0) { + if (rang == 0) entry |= ME4000_AI_LIST_RANGE_UNIPOLAR_2_5; - } else if (rang == 1) { + else if (rang == 1) entry |= ME4000_AI_LIST_RANGE_UNIPOLAR_10; - } else if (rang == 2) { + else if (rang == 2) entry |= ME4000_AI_LIST_RANGE_BIPOLAR_2_5; - } else { + else entry |= ME4000_AI_LIST_RANGE_BIPOLAR_10; - } - if (aref == SDF_DIFF) { + if (aref == SDF_DIFF) entry |= ME4000_AI_LIST_INPUT_DIFFERENTIAL; - } else { + else entry |= ME4000_AI_LIST_INPUT_SINGLE_ENDED; - } me4000_outl(dev, entry, info->ai_context.channel_list_reg); } @@ -1454,8 +1468,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, break; default: printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start source\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid start source\n", dev->minor); cmd->start_src = TRIG_NOW; err++; } @@ -1470,8 +1484,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, break; default: printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid scan begin source\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid scan begin source\n", dev->minor); cmd->scan_begin_src = TRIG_FOLLOW; err++; } @@ -1485,8 +1499,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, break; default: printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid convert source\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid convert source\n", dev->minor); cmd->convert_src = TRIG_TIMER; err++; } @@ -1500,8 +1514,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, break; default: printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid scan end source\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid scan end source\n", dev->minor); cmd->scan_end_src = TRIG_NONE; err++; } @@ -1515,8 +1529,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, break; default: printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid stop source\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid stop source\n", dev->minor); cmd->stop_src = TRIG_NONE; err++; } @@ -1546,8 +1560,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, cmd->convert_src == TRIG_EXT) { } else { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start trigger combination\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid start trigger combination\n", dev->minor); cmd->start_src = TRIG_NOW; cmd->scan_begin_src = TRIG_FOLLOW; cmd->convert_src = TRIG_TIMER; @@ -1563,8 +1577,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, cmd->scan_end_src == TRIG_COUNT) { } else { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid stop trigger combination\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid stop trigger combination\n", dev->minor); cmd->stop_src = TRIG_NONE; cmd->scan_end_src = TRIG_NONE; err++; @@ -1577,29 +1591,29 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, */ if (cmd->chanlist_len < 1) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): No channel list\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "No channel list\n", dev->minor); cmd->chanlist_len = 1; err++; } if (init_ticks < 66) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Start arg to low\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Start arg to low\n", dev->minor); cmd->start_arg = 2000; err++; } if (scan_ticks && scan_ticks < 67) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Scan begin arg to low\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Scan begin arg to low\n", dev->minor); cmd->scan_begin_arg = 2031; err++; } if (chan_ticks < 66) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Convert arg to low\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Convert arg to low\n", dev->minor); cmd->convert_arg = 2000; err++; } @@ -1617,23 +1631,25 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, /* Check timer arguments */ if (init_ticks < ME4000_AI_MIN_TICKS) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start arg\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid start arg\n", dev->minor); cmd->start_arg = 2000; /* 66 ticks at least */ err++; } if (chan_ticks < ME4000_AI_MIN_TICKS) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid convert arg\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid convert arg\n", dev->minor); cmd->convert_arg = 2000; /* 66 ticks at least */ err++; } if (scan_ticks <= cmd->chanlist_len * chan_ticks) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid scan end arg\n", - dev->minor); - cmd->scan_end_arg = 2000 * cmd->chanlist_len + 31; /* At least one tick more */ + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid scan end arg\n", dev->minor); + + /* At least one tick more */ + cmd->scan_end_arg = 2000 * cmd->chanlist_len + 31; err++; } } else if (cmd->start_src == TRIG_NOW && @@ -1643,15 +1659,15 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, /* Check timer arguments */ if (init_ticks < ME4000_AI_MIN_TICKS) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start arg\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid start arg\n", dev->minor); cmd->start_arg = 2000; /* 66 ticks at least */ err++; } if (chan_ticks < ME4000_AI_MIN_TICKS) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid convert arg\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid convert arg\n", dev->minor); cmd->convert_arg = 2000; /* 66 ticks at least */ err++; } @@ -1662,23 +1678,25 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, /* Check timer arguments */ if (init_ticks < ME4000_AI_MIN_TICKS) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start arg\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid start arg\n", dev->minor); cmd->start_arg = 2000; /* 66 ticks at least */ err++; } if (chan_ticks < ME4000_AI_MIN_TICKS) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid convert arg\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid convert arg\n", dev->minor); cmd->convert_arg = 2000; /* 66 ticks at least */ err++; } if (scan_ticks <= cmd->chanlist_len * chan_ticks) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid scan end arg\n", - dev->minor); - cmd->scan_end_arg = 2000 * cmd->chanlist_len + 31; /* At least one tick more */ + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid scan end arg\n", dev->minor); + + /* At least one tick more */ + cmd->scan_end_arg = 2000 * cmd->chanlist_len + 31; err++; } } else if (cmd->start_src == TRIG_EXT && @@ -1688,15 +1706,15 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, /* Check timer arguments */ if (init_ticks < ME4000_AI_MIN_TICKS) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start arg\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid start arg\n", dev->minor); cmd->start_arg = 2000; /* 66 ticks at least */ err++; } if (chan_ticks < ME4000_AI_MIN_TICKS) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid convert arg\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid convert arg\n", dev->minor); cmd->convert_arg = 2000; /* 66 ticks at least */ err++; } @@ -1707,15 +1725,15 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, /* Check timer arguments */ if (init_ticks < ME4000_AI_MIN_TICKS) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start arg\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid start arg\n", dev->minor); cmd->start_arg = 2000; /* 66 ticks at least */ err++; } if (chan_ticks < ME4000_AI_MIN_TICKS) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid convert arg\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid convert arg\n", dev->minor); cmd->convert_arg = 2000; /* 66 ticks at least */ err++; } @@ -1726,8 +1744,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, /* Check timer arguments */ if (init_ticks < ME4000_AI_MIN_TICKS) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid start arg\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid start arg\n", dev->minor); cmd->start_arg = 2000; /* 66 ticks at least */ err++; } @@ -1735,8 +1753,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, if (cmd->stop_src == TRIG_COUNT) { if (cmd->stop_arg == 0) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid stop arg\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid stop arg\n", dev->minor); cmd->stop_arg = 1; err++; } @@ -1744,8 +1762,8 @@ static int me4000_ai_do_cmd_test(struct comedi_device *dev, if (cmd->scan_end_src == TRIG_COUNT) { if (cmd->scan_end_arg == 0) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_do_cmd_test(): Invalid scan end arg\n", - dev->minor); + "comedi%d: me4000: me4000_ai_do_cmd_test(): " + "Invalid scan end arg\n", dev->minor); cmd->scan_end_arg = 1; err++; } @@ -1786,8 +1804,8 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id) /* Check if irq number is right */ if (irq != ai_context->irq) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_isr(): Incorrect interrupt num: %d\n", - dev->minor, irq); + "comedi%d: me4000: me4000_ai_isr(): " + "Incorrect interrupt num: %d\n", dev->minor, irq); return IRQ_HANDLED; } @@ -1806,7 +1824,10 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id) ISR_PDEBUG("me4000_ai_isr(): Fifo full\n"); c = ME4000_AI_FIFO_COUNT; - /* FIFO overflow, so stop conversion and disable all interrupts */ + /* + * FIFO overflow, so stop conversion + * and disable all interrupts + */ tmp |= ME4000_AI_CTRL_BIT_IMMEDIATE_STOP; tmp &= ~(ME4000_AI_CTRL_BIT_HF_IRQ | ME4000_AI_CTRL_BIT_SC_IRQ); @@ -1815,8 +1836,8 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id) s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; printk(KERN_ERR - "comedi%d: me4000: me4000_ai_isr(): FIFO overflow\n", - dev->minor); + "comedi%d: me4000: me4000_ai_isr(): " + "FIFO overflow\n", dev->minor); } else if ((tmp & ME4000_AI_STATUS_BIT_FF_DATA) && !(tmp & ME4000_AI_STATUS_BIT_HF_DATA) && (tmp & ME4000_AI_STATUS_BIT_EF_DATA)) { @@ -1827,11 +1848,14 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id) c = ME4000_AI_FIFO_COUNT / 2; } else { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_isr(): Can't determine state of fifo\n", - dev->minor); + "comedi%d: me4000: me4000_ai_isr(): " + "Can't determine state of fifo\n", dev->minor); c = 0; - /* Undefined state, so stop conversion and disable all interrupts */ + /* + * Undefined state, so stop conversion + * and disable all interrupts + */ tmp |= ME4000_AI_CTRL_BIT_IMMEDIATE_STOP; tmp &= ~(ME4000_AI_CTRL_BIT_HF_IRQ | ME4000_AI_CTRL_BIT_SC_IRQ); @@ -1840,8 +1864,8 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id) s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; printk(KERN_ERR - "comedi%d: me4000: me4000_ai_isr(): Undefined FIFO state\n", - dev->minor); + "comedi%d: me4000: me4000_ai_isr(): " + "Undefined FIFO state\n", dev->minor); } ISR_PDEBUG("me4000_ai_isr(): Try to read %d values\n", c); @@ -1852,7 +1876,10 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id) lval ^= 0x8000; if (!comedi_buf_put(s->async, lval)) { - /* Buffer overflow, so stop conversion and disable all interrupts */ + /* + * Buffer overflow, so stop conversion + * and disable all interrupts + */ tmp |= ME4000_AI_CTRL_BIT_IMMEDIATE_STOP; tmp &= ~(ME4000_AI_CTRL_BIT_HF_IRQ | ME4000_AI_CTRL_BIT_SC_IRQ); @@ -1861,8 +1888,8 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id) s->async->events |= COMEDI_CB_OVERFLOW; printk(KERN_ERR - "comedi%d: me4000: me4000_ai_isr(): Buffer overflow\n", - dev->minor); + "comedi%d: me4000: me4000_ai_isr(): " + "Buffer overflow\n", dev->minor); break; } @@ -1883,7 +1910,10 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id) s->async->events |= COMEDI_CB_BLOCK | COMEDI_CB_EOA; - /* Acquisition is complete, so stop conversion and disable all interrupts */ + /* + * Acquisition is complete, so stop + * conversion and disable all interrupts + */ tmp = me4000_inl(dev, ai_context->ctrl_reg); tmp |= ME4000_AI_CTRL_BIT_IMMEDIATE_STOP; tmp &= ~(ME4000_AI_CTRL_BIT_HF_IRQ | ME4000_AI_CTRL_BIT_SC_IRQ); @@ -1897,8 +1927,8 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id) if (!comedi_buf_put(s->async, lval)) { printk(KERN_ERR - "comedi%d: me4000: me4000_ai_isr(): Buffer overflow\n", - dev->minor); + "comedi%d: me4000: me4000_ai_isr(): " + "Buffer overflow\n", dev->minor); s->async->events |= COMEDI_CB_OVERFLOW; break; } @@ -1941,29 +1971,29 @@ static int me4000_ao_insn_write(struct comedi_device *dev, return 0; } else if (insn->n > 1) { printk(KERN_ERR - "comedi%d: me4000: me4000_ao_insn_write(): Invalid instruction length %d\n", - dev->minor, insn->n); + "comedi%d: me4000: me4000_ao_insn_write(): " + "Invalid instruction length %d\n", dev->minor, insn->n); return -EINVAL; } if (chan >= thisboard->ao.count) { printk(KERN_ERR - "comedi%d: me4000: me4000_ao_insn_write(): Invalid channel %d\n", - dev->minor, insn->n); + "comedi%d: me4000: me4000_ao_insn_write(): " + "Invalid channel %d\n", dev->minor, insn->n); return -EINVAL; } if (rang != 0) { printk(KERN_ERR - "comedi%d: me4000: me4000_ao_insn_write(): Invalid range %d\n", - dev->minor, insn->n); + "comedi%d: me4000: me4000_ao_insn_write(): " + "Invalid range %d\n", dev->minor, insn->n); return -EINVAL; } if (aref != AREF_GROUND && aref != AREF_COMMON) { printk(KERN_ERR - "comedi%d: me4000: me4000_ao_insn_write(): Invalid aref %d\n", - dev->minor, insn->n); + "comedi%d: me4000: me4000_ao_insn_write(): " + "Invalid aref %d\n", dev->minor, insn->n); return -EINVAL; } @@ -1994,8 +2024,8 @@ static int me4000_ao_insn_read(struct comedi_device *dev, return 0; } else if (insn->n > 1) { printk - ("comedi%d: me4000: me4000_ao_insn_read(): Invalid instruction length\n", - dev->minor); + ("comedi%d: me4000: me4000_ao_insn_read(): " + "Invalid instruction length\n", dev->minor); return -EINVAL; } @@ -2021,8 +2051,8 @@ static int me4000_dio_insn_bits(struct comedi_device *dev, if (insn->n != 2) { printk - ("comedi%d: me4000: me4000_dio_insn_bits(): Invalid instruction length\n", - dev->minor); + ("comedi%d: me4000: me4000_dio_insn_bits(): " + "Invalid instruction length\n", dev->minor); return -EINVAL; } @@ -2095,8 +2125,9 @@ static int me4000_dio_insn_config(struct comedi_device *dev, tmp |= ME4000_DIO_CTRL_BIT_MODE_0; } else if (chan < 16) { /* - * Chech for optoisolated ME-4000 version. If one the first - * port is a fixed output port and the second is a fixed input port. + * Chech for optoisolated ME-4000 version. + * If one the first port is a fixed output + * port and the second is a fixed input port. */ if (!me4000_inl(dev, info->dio_context.dir_reg)) return -ENODEV; @@ -2121,8 +2152,9 @@ static int me4000_dio_insn_config(struct comedi_device *dev, } else { if (chan < 8) { /* - * Chech for optoisolated ME-4000 version. If one the first - * port is a fixed output port and the second is a fixed input port. + * Chech for optoisolated ME-4000 version. + * If one the first port is a fixed output + * port and the second is a fixed input port. */ if (!me4000_inl(dev, info->dio_context.dir_reg)) return -ENODEV; @@ -2257,7 +2289,8 @@ static int me4000_cnt_insn_config(struct comedi_device *dev, case GPCT_RESET: if (insn->n != 1) { printk(KERN_ERR - "comedi%d: me4000: me4000_cnt_insn_config(): Invalid instruction length%d\n", + "comedi%d: me4000: me4000_cnt_insn_config(): " + "Invalid instruction length%d\n", dev->minor, insn->n); return -EINVAL; } @@ -2269,7 +2302,8 @@ static int me4000_cnt_insn_config(struct comedi_device *dev, case GPCT_SET_OPERATION: if (insn->n != 2) { printk(KERN_ERR - "comedi%d: me4000: me4000_cnt_insn_config(): Invalid instruction length%d\n", + "comedi%d: me4000: me4000_cnt_insn_config(): " + "Invalid instruction length%d\n", dev->minor, insn->n); return -EINVAL; } @@ -2280,8 +2314,8 @@ static int me4000_cnt_insn_config(struct comedi_device *dev, break; default: printk(KERN_ERR - "comedi%d: me4000: me4000_cnt_insn_config(): Invalid instruction\n", - dev->minor); + "comedi%d: me4000: me4000_cnt_insn_config(): " + "Invalid instruction\n", dev->minor); return -EINVAL; } @@ -2302,7 +2336,8 @@ static int me4000_cnt_insn_read(struct comedi_device *dev, if (insn->n > 1) { printk(KERN_ERR - "comedi%d: me4000: me4000_cnt_insn_read(): Invalid instruction length %d\n", + "comedi%d: me4000: me4000_cnt_insn_read(): " + "Invalid instruction length %d\n", dev->minor, insn->n); return -EINVAL; } @@ -2328,7 +2363,8 @@ static int me4000_cnt_insn_read(struct comedi_device *dev, break; default: printk(KERN_ERR - "comedi%d: me4000: me4000_cnt_insn_read(): Invalid channel %d\n", + "comedi%d: me4000: me4000_cnt_insn_read(): " + "Invalid channel %d\n", dev->minor, insn->chanspec); return -EINVAL; } @@ -2349,7 +2385,8 @@ static int me4000_cnt_insn_write(struct comedi_device *dev, return 0; } else if (insn->n > 1) { printk(KERN_ERR - "comedi%d: me4000: me4000_cnt_insn_write(): Invalid instruction length %d\n", + "comedi%d: me4000: me4000_cnt_insn_write(): " + "Invalid instruction length %d\n", dev->minor, insn->n); return -EINVAL; } @@ -2375,7 +2412,8 @@ static int me4000_cnt_insn_write(struct comedi_device *dev, break; default: printk(KERN_ERR - "comedi%d: me4000: me4000_cnt_insn_write(): Invalid channel %d\n", + "comedi%d: me4000: me4000_cnt_insn_write(): " + "Invalid channel %d\n", dev->minor, insn->chanspec); return -EINVAL; } From 8f4e80af3aa509902bd2319c3b5512580f64868f Mon Sep 17 00:00:00 2001 From: Gustavo Silva Date: Sat, 12 Jun 2010 19:15:22 -0500 Subject: [PATCH 029/523] Staging: comedi: drivers: Fix coding style issues in pcl711.c This is a patch to the pcl711.c file that fixes up printk() warning issues. Signed-off-by: Gustavo Silva Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl711.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c index 22d14fb3121b..b44386a6b636 100644 --- a/drivers/staging/comedi/drivers/pcl711.c +++ b/drivers/staging/comedi/drivers/pcl711.c @@ -281,7 +281,7 @@ static int pcl711_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s, goto ok; udelay(1); } - printk("comedi%d: pcl711: A/D timeout\n", dev->minor); + printk(KERN_ERR "comedi%d: pcl711: A/D timeout\n", dev->minor); return -ETIME; ok: @@ -516,7 +516,7 @@ static int pcl711_do_insn_bits(struct comedi_device *dev, /* Free any resources that we have claimed */ static int pcl711_detach(struct comedi_device *dev) { - printk("comedi%d: pcl711: remove\n", dev->minor); + printk(KERN_INFO "comedi%d: pcl711: remove\n", dev->minor); if (dev->irq) free_irq(dev->irq, dev); @@ -538,7 +538,7 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* claim our I/O space */ iobase = it->options[0]; - printk("comedi%d: pcl711: 0x%04lx ", dev->minor, iobase); + printk(KERN_INFO "comedi%d: pcl711: 0x%04lx ", dev->minor, iobase); if (!request_region(iobase, PCL711_SIZE, "pcl711")) { printk("I/O port conflict\n"); return -EIO; @@ -553,15 +553,15 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* grab our IRQ */ irq = it->options[1]; if (irq > this_board->maxirq) { - printk("irq out of range\n"); + printk(KERN_ERR "irq out of range\n"); return -EINVAL; } if (irq) { if (request_irq(irq, pcl711_interrupt, 0, "pcl711", dev)) { - printk("unable to allocate irq %u\n", irq); + printk(KERN_ERR "unable to allocate irq %u\n", irq); return -EINVAL; } else { - printk("( irq = %u )\n", irq); + printk(KERN_INFO "( irq = %u )\n", irq); } } dev->irq = irq; @@ -635,7 +635,7 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it) outb(0, dev->iobase + PCL711_DA1_LO); outb(0, dev->iobase + PCL711_DA1_HI); - printk("\n"); + printk(KERN_INFO "\n"); return 0; } From 4c68fb42c2a39b89daca2b7175eb93ffe6860da4 Mon Sep 17 00:00:00 2001 From: Gustavo Silva Date: Wed, 16 Jun 2010 00:17:52 -0500 Subject: [PATCH 030/523] Staging: comedi: drivers: fix coding style issues in pcl816.c This is a patch to the pcl816.c file that fixes up the following issues: ERROR: code indent should use tabs where possible x 2 WARNING: line over 80 characters x 34 WARNING: please, no space before tabs x 1 WARNING: braces {} are not necessary for single statement blocks x 6 WARNING: printk() should include KERN_ facility level x 15 WARNING: braces {} are not necessary for any arm of this statement x 1 Signed-off-by: Gustavo Silva Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl816.c | 223 +++++++++++++++--------- 1 file changed, 140 insertions(+), 83 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c index a84b942c5a93..3d0f018faa6b 100644 --- a/drivers/staging/comedi/drivers/pcl816.c +++ b/drivers/staging/comedi/drivers/pcl816.c @@ -2,7 +2,7 @@ comedi/drivers/pcl816.c Author: Juan Grigera - based on pcl818 by Michal Dobes and bits of pcl812 + based on pcl818 by Michal Dobes and bits of pcl812 hardware driver for Advantech cards: card: PCL-816, PCL814B @@ -28,7 +28,7 @@ Configuration Options: [1] - IRQ (0=disable, 2, 3, 4, 5, 6, 7) [2] - DMA (0=disable, 1, 3) [3] - 0, 10=10MHz clock for 8254 - 1= 1MHz clock for 8254 + 1= 1MHz clock for 8254 */ @@ -85,7 +85,7 @@ Configuration Options: #define INT_TYPE_AI3_DMA_RTC 10 /* RTC stuff... */ -#define RTC_IRQ 8 +#define RTC_IRQ 8 #define RTC_IO_EXTENT 0x10 #endif @@ -264,7 +264,8 @@ static int pcl816_ai_insn_read(struct comedi_device *dev, /* Set the input channel */ outb(CR_CHAN(insn->chanspec) & 0xf, dev->iobase + PCL816_MUX); - outb(CR_RANGE(insn->chanspec), dev->iobase + PCL816_RANGE); /* select gain */ + /* select gain */ + outb(CR_RANGE(insn->chanspec), dev->iobase + PCL816_RANGE); for (n = 0; n < insn->n; n++) { @@ -279,8 +280,8 @@ static int pcl816_ai_insn_read(struct comedi_device *dev, ((inb(dev->iobase + PCL816_AD_HI) << 8) | (inb(dev->iobase + PCL816_AD_LO))); - - outb(0, dev->iobase + PCL816_CLRINT); /* clear INT (conversion end) flag */ + /* clear INT (conversion end) flag */ + outb(0, dev->iobase + PCL816_CLRINT); break; } udelay(1); @@ -289,7 +290,8 @@ static int pcl816_ai_insn_read(struct comedi_device *dev, if (!timeout) { comedi_error(dev, "A/D insn timeout\n"); data[0] = 0; - outb(0, dev->iobase + PCL816_CLRINT); /* clear INT (conversion end) flag */ + /* clear INT (conversion end) flag */ + outb(0, dev->iobase + PCL816_CLRINT); return -EIO; } @@ -343,7 +345,8 @@ static irqreturn_t interrupt_pcl816_ai_mode13_int(int irq, void *d) } if (!devpriv->ai_neverending) - if (devpriv->ai_act_scan >= devpriv->ai_scans) { /* all data sampled */ + /* all data sampled */ + if (devpriv->ai_act_scan >= devpriv->ai_scans) { /* all data sampled */ pcl816_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA; @@ -380,7 +383,8 @@ static void transfer_from_dma_buf(struct comedi_device *dev, } if (!devpriv->ai_neverending) - if (devpriv->ai_act_scan >= devpriv->ai_scans) { /* all data sampled */ + /* all data sampled */ + if (devpriv->ai_act_scan >= devpriv->ai_scans) { pcl816_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA; s->async->events |= COMEDI_CB_BLOCK; @@ -402,7 +406,8 @@ static irqreturn_t interrupt_pcl816_ai_mode13_dma(int irq, void *d) disable_dma(devpriv->dma); this_dma_buf = devpriv->next_dma_buf; - if ((devpriv->dma_runs_to_end > -1) || devpriv->ai_neverending) { /* switch dma bufs */ + /* switch dma bufs */ + if ((devpriv->dma_runs_to_end > -1) || devpriv->ai_neverending) { devpriv->next_dma_buf = 1 - devpriv->next_dma_buf; set_dma_mode(devpriv->dma, DMA_MODE_READ); @@ -478,14 +483,14 @@ static irqreturn_t interrupt_pcl816(int irq, void *d) */ static void pcl816_cmdtest_out(int e, struct comedi_cmd *cmd) { - printk("pcl816 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e, + printk(KERN_INFO "pcl816 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e, cmd->start_src, cmd->scan_begin_src, cmd->convert_src); - printk("pcl816 e=%d startarg=%d scanarg=%d convarg=%d\n", e, + printk(KERN_INFO "pcl816 e=%d startarg=%d scanarg=%d convarg=%d\n", e, cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg); - printk("pcl816 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src, - cmd->scan_end_src); - printk("pcl816 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n", e, - cmd->stop_arg, cmd->scan_end_arg, cmd->chanlist_len); + printk(KERN_INFO "pcl816 e=%d stopsrc=%x scanend=%x\n", e, + cmd->stop_src, cmd->scan_end_src); + printk(KERN_INFO "pcl816 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n", + e, cmd->stop_arg, cmd->scan_end_arg, cmd->chanlist_len); } /* @@ -497,8 +502,9 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev, int err = 0; int tmp, divisor1 = 0, divisor2 = 0; - DEBUG(printk("pcl816 pcl812_ai_cmdtest\n"); pcl816_cmdtest_out(-1, cmd); - ); + DEBUG(printk(KERN_INFO "pcl816 pcl812_ai_cmdtest\n"); + pcl816_cmdtest_out(-1, cmd); + ); /* step 1: make sure trigger sources are trivially valid */ tmp = cmd->start_src; @@ -526,11 +532,14 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev, if (!cmd->stop_src || tmp != cmd->stop_src) err++; - if (err) { + if (err) return 1; - } - /* step 2: make sure trigger sources are unique and mutually compatible */ + + /* + * step 2: make sure trigger sources + * are unique and mutually compatible + */ if (cmd->start_src != TRIG_NOW) { cmd->start_src = TRIG_NOW; @@ -555,9 +564,9 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev, if (cmd->stop_src != TRIG_NONE && cmd->stop_src != TRIG_COUNT) err++; - if (err) { + if (err) return 2; - } + /* step 3: make sure arguments are trivially compatible */ if (cmd->start_arg != 0) { @@ -597,9 +606,9 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev, } } - if (err) { + if (err) return 3; - } + /* step 4: fix up any arguments */ if (cmd->convert_src == TRIG_TIMER) { @@ -614,9 +623,9 @@ static int pcl816_ai_cmdtest(struct comedi_device *dev, err++; } - if (err) { + if (err) return 4; - } + /* step 5: complain about special chanlist considerations */ @@ -654,7 +663,9 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) i8253_cascade_ns_to_timer(this_board->i8254_osc_base, &divisor1, &divisor2, &cmd->convert_arg, cmd->flags & TRIG_ROUND_MASK); - if (divisor1 == 1) { /* PCL816 crash if any divisor is set to 1 */ + + /* PCL816 crash if any divisor is set to 1 */ + if (divisor1 == 1) { divisor1 = 2; divisor2 /= 2; } @@ -687,8 +698,10 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_neverending = 1; } - if ((cmd->flags & TRIG_WAKE_EOS)) { /* don't we want wake up every scan? */ - printk("pl816: You wankt WAKE_EOS but I dont want handle it"); + /* don't we want wake up every scan? */ + if ((cmd->flags & TRIG_WAKE_EOS)) { + printk(KERN_INFO + "pl816: You wankt WAKE_EOS but I dont want handle it"); /* devpriv->ai_eos=1; */ /* if (devpriv->ai_n_chan==1) */ /* devpriv->dma=0; // DMA is useless for this situation */ @@ -697,9 +710,17 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (devpriv->dma) { bytes = devpriv->hwdmasize[0]; if (!devpriv->ai_neverending) { - bytes = s->async->cmd.chanlist_len * s->async->cmd.chanlist_len * sizeof(short); /* how many */ - devpriv->dma_runs_to_end = bytes / devpriv->hwdmasize[0]; /* how many DMA pages we must fill */ - devpriv->last_dma_run = bytes % devpriv->hwdmasize[0]; /* on last dma transfer must be moved */ + /* how many */ + bytes = s->async->cmd.chanlist_len * + s->async->cmd.chanlist_len * + sizeof(short); + + /* how many DMA pages we must fill */ + devpriv->dma_runs_to_end = bytes / + devpriv->hwdmasize[0]; + + /* on last dma transfer must be moved */ + devpriv->last_dma_run = bytes % devpriv->hwdmasize[0]; devpriv->dma_runs_to_end--; if (devpriv->dma_runs_to_end >= 0) bytes = devpriv->hwdmasize[0]; @@ -722,14 +743,22 @@ static int pcl816_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) switch (cmd->convert_src) { case TRIG_TIMER: devpriv->int816_mode = INT_TYPE_AI1_DMA; - outb(0x32, dev->iobase + PCL816_CONTROL); /* Pacer+IRQ+DMA */ - outb(dmairq, dev->iobase + PCL816_STATUS); /* write irq and DMA to card */ + + /* Pacer+IRQ+DMA */ + outb(0x32, dev->iobase + PCL816_CONTROL); + + /* write irq and DMA to card */ + outb(dmairq, dev->iobase + PCL816_STATUS); break; default: devpriv->int816_mode = INT_TYPE_AI3_DMA; - outb(0x34, dev->iobase + PCL816_CONTROL); /* Ext trig+IRQ+DMA */ - outb(dmairq, dev->iobase + PCL816_STATUS); /* write irq to card */ + + /* Ext trig+IRQ+DMA */ + outb(0x34, dev->iobase + PCL816_CONTROL); + + /* write irq to card */ + outb(dmairq, dev->iobase + PCL816_STATUS); break; } @@ -758,7 +787,8 @@ static int pcl816_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s) return 0; } - top1 = devpriv->hwdmasize[0] - top1; /* where is now DMA in buffer */ + /* where is now DMA in buffer */ + top1 = devpriv->hwdmasize[0] - top1; top1 >>= 1; /* sample position */ top2 = top1 - devpriv->ai_poll_ptr; if (top2 < 1) { /* no new samples */ @@ -798,16 +828,23 @@ static int pcl816_ai_cancel(struct comedi_device *dev, disable_dma(devpriv->dma); case INT_TYPE_AI1_INT: case INT_TYPE_AI3_INT: - outb(inb(dev->iobase + PCL816_CONTROL) & 0x73, dev->iobase + PCL816_CONTROL); /* Stop A/D */ + outb(inb(dev->iobase + PCL816_CONTROL) & 0x73, + dev->iobase + PCL816_CONTROL); /* Stop A/D */ udelay(1); outb(0, dev->iobase + PCL816_CONTROL); /* Stop A/D */ - outb(0xb0, dev->iobase + PCL816_CTRCTL); /* Stop pacer */ + + /* Stop pacer */ + outb(0xb0, dev->iobase + PCL816_CTRCTL); outb(0x70, dev->iobase + PCL816_CTRCTL); outb(0, dev->iobase + PCL816_AD_LO); inb(dev->iobase + PCL816_AD_LO); inb(dev->iobase + PCL816_AD_HI); - outb(0, dev->iobase + PCL816_CLRINT); /* clear INT request */ - outb(0, dev->iobase + PCL816_CONTROL); /* Stop A/D */ + + /* clear INT request */ + outb(0, dev->iobase + PCL816_CLRINT); + + /* Stop A/D */ + outb(0, dev->iobase + PCL816_CONTROL); devpriv->irq_blocked = 0; devpriv->irq_was_now_closed = devpriv->int816_mode; devpriv->int816_mode = 0; @@ -877,8 +914,11 @@ start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, outb(0xff, dev->iobase + PCL816_CTR0); outb(0x00, dev->iobase + PCL816_CTR0); udelay(1); - outb(0xb4, dev->iobase + PCL816_CTRCTL); /* set counter 2 as mode 3 */ - outb(0x74, dev->iobase + PCL816_CTRCTL); /* set counter 1 as mode 3 */ + + /* set counter 2 as mode 3 */ + outb(0xb4, dev->iobase + PCL816_CTRCTL); + /* set counter 1 as mode 3 */ + outb(0x74, dev->iobase + PCL816_CTRCTL); udelay(1); if (mode == 1) { @@ -914,41 +954,51 @@ check_channel_list(struct comedi_device *dev, } if (chanlen > 1) { - chansegment[0] = chanlist[0]; /* first channel is everytime ok */ + /* first channel is everytime ok */ + chansegment[0] = chanlist[0]; for (i = 1, seglen = 1; i < chanlen; i++, seglen++) { /* build part of chanlist */ - DEBUG(printk("%d. %d %d\n", i, CR_CHAN(chanlist[i]), + DEBUG(printk(KERN_INFO "%d. %d %d\n", i, + CR_CHAN(chanlist[i]), CR_RANGE(chanlist[i]));) + + /* we detect loop, this must by finish */ if (chanlist[0] == chanlist[i]) - break; /* we detect loop, this must by finish */ + break; nowmustbechan = (CR_CHAN(chansegment[i - 1]) + 1) % chanlen; if (nowmustbechan != CR_CHAN(chanlist[i])) { /* channel list isn't continous :-( */ - printk - ("comedi%d: pcl816: channel list must be continous! chanlist[%i]=%d but must be %d or %d!\n", - dev->minor, i, CR_CHAN(chanlist[i]), - nowmustbechan, CR_CHAN(chanlist[0])); + printk(KERN_WARNING + "comedi%d: pcl816: channel list must " + "be continous! chanlist[%i]=%d but " + "must be %d or %d!\n", dev->minor, + i, CR_CHAN(chanlist[i]), nowmustbechan, + CR_CHAN(chanlist[0])); return 0; } - chansegment[i] = chanlist[i]; /* well, this is next correct channel in list */ + /* well, this is next correct channel in list */ + chansegment[i] = chanlist[i]; } - for (i = 0, segpos = 0; i < chanlen; i++) { /* check whole chanlist */ + /* check whole chanlist */ + for (i = 0, segpos = 0; i < chanlen; i++) { DEBUG(printk("%d %d=%d %d\n", CR_CHAN(chansegment[i % seglen]), CR_RANGE(chansegment[i % seglen]), CR_CHAN(chanlist[i]), CR_RANGE(chanlist[i]));) if (chanlist[i] != chansegment[i % seglen]) { - printk - ("comedi%d: pcl816: bad channel or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n", - dev->minor, i, CR_CHAN(chansegment[i]), - CR_RANGE(chansegment[i]), - CR_AREF(chansegment[i]), - CR_CHAN(chanlist[i % seglen]), - CR_RANGE(chanlist[i % seglen]), - CR_AREF(chansegment[i % seglen])); + printk(KERN_WARNING + "comedi%d: pcl816: bad channel or range" + " number! chanlist[%i]=%d,%d,%d and not" + " %d,%d,%d!\n", dev->minor, i, + CR_CHAN(chansegment[i]), + CR_RANGE(chansegment[i]), + CR_AREF(chansegment[i]), + CR_CHAN(chanlist[i % seglen]), + CR_RANGE(chanlist[i % seglen]), + CR_AREF(chansegment[i % seglen])); return 0; /* chan/gain list is strange */ } } @@ -976,12 +1026,15 @@ setup_channel_list(struct comedi_device *dev, for (i = 0; i < seglen; i++) { /* store range list to card */ devpriv->ai_act_chanlist[i] = CR_CHAN(chanlist[i]); outb(CR_CHAN(chanlist[0]) & 0xf, dev->iobase + PCL816_MUX); - outb(CR_RANGE(chanlist[0]), dev->iobase + PCL816_RANGE); /* select gain */ + /* select gain */ + outb(CR_RANGE(chanlist[0]), dev->iobase + PCL816_RANGE); } udelay(1); - - outb(devpriv->ai_act_chanlist[0] | (devpriv->ai_act_chanlist[seglen - 1] << 4), dev->iobase + PCL816_MUX); /* select channel interval to scan */ + /* select channel interval to scan */ + outb(devpriv->ai_act_chanlist[0] | + (devpriv->ai_act_chanlist[seglen - 1] << 4), + dev->iobase + PCL816_MUX); } #ifdef unused @@ -1009,11 +1062,11 @@ static int set_rtc_irq_bit(unsigned char bit) save_flags(flags); cli(); val = CMOS_READ(RTC_CONTROL); - if (bit) { + if (bit) val |= RTC_PIE; - } else { + else val &= ~RTC_PIE; - } + CMOS_WRITE(val, RTC_CONTROL); CMOS_READ(RTC_INTR_FLAGS); restore_flags(flags); @@ -1083,7 +1136,7 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) dev->iobase = iobase; if (pcl816_check(iobase)) { - printk(", I cann't detect board. FAIL!\n"); + printk(KERN_ERR ", I cann't detect board. FAIL!\n"); return -EIO; } @@ -1101,30 +1154,29 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (irq) { /* we want to use IRQ */ if (((1 << irq) & this_board->IRQbits) == 0) { printk - (", IRQ %u is out of allowed range, DISABLING IT", - irq); + (", IRQ %u is out of allowed range, " + "DISABLING IT", irq); irq = 0; /* Bad IRQ */ } else { if (request_irq (irq, interrupt_pcl816, 0, "pcl816", dev)) { printk - (", unable to allocate IRQ %u, DISABLING IT", - irq); + (", unable to allocate IRQ %u, " + "DISABLING IT", irq); irq = 0; /* Can't use IRQ */ } else { - printk(", irq=%u", irq); + printk(KERN_INFO ", irq=%u", irq); } } } } dev->irq = irq; - if (irq) { + if (irq) /* 1=we have allocated irq */ devpriv->irq_free = 1; - } /* 1=we have allocated irq */ - else { + else devpriv->irq_free = 0; - } + devpriv->irq_blocked = 0; /* number of subdevice which use IRQ */ devpriv->int816_mode = 0; /* mode of irq */ @@ -1181,18 +1233,22 @@ no_rtc: } ret = request_dma(dma, "pcl816"); if (ret) { - printk(", unable to allocate DMA %u, FAIL!\n", dma); + printk(KERN_ERR + ", unable to allocate DMA %u, FAIL!\n", dma); return -EBUSY; /* DMA isn't free */ } devpriv->dma = dma; - printk(", dma=%u", dma); + printk(KERN_INFO ", dma=%u", dma); pages = 2; /* we need 16KB */ devpriv->dmabuf[0] = __get_dma_pages(GFP_KERNEL, pages); if (!devpriv->dmabuf[0]) { printk(", unable to allocate DMA buffer, FAIL!\n"); - /* maybe experiment with try_to_free_pages() will help .... */ + /* + * maybe experiment with try_to_free_pages() + * will help .... + */ return -EBUSY; /* no buffer :-( */ } devpriv->dmapages[0] = pages; @@ -1203,8 +1259,9 @@ no_rtc: if (devpriv->dma_rtc == 0) { /* we must do duble buff :-( */ devpriv->dmabuf[1] = __get_dma_pages(GFP_KERNEL, pages); if (!devpriv->dmabuf[1]) { - printk - (", unable to allocate DMA buffer, FAIL!\n"); + printk(KERN_ERR + ", unable to allocate DMA buffer, " + "FAIL!\n"); return -EBUSY; } devpriv->dmapages[1] = pages; @@ -1288,7 +1345,7 @@ case COMEDI_SUBD_DO: */ static int pcl816_detach(struct comedi_device *dev) { - DEBUG(printk("comedi%d: pcl816: remove\n", dev->minor);) + DEBUG(printk(KERN_INFO "comedi%d: pcl816: remove\n", dev->minor);) free_resources(dev); #ifdef unused if (devpriv->dma_rtc) From 8b83e005d11bce0f9a59d9be337a285e6cc487a6 Mon Sep 17 00:00:00 2001 From: Gustavo Silva Date: Wed, 16 Jun 2010 00:36:54 -0500 Subject: [PATCH 031/523] Staging: comedi: drivers: fix coding style issues in pcmda12.c This is a patch to the pcmda12.c file that fixes up five printk() warning issues Signed-off-by: Gustavo Silva Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcmda12.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcmda12.c b/drivers/staging/comedi/drivers/pcmda12.c index 6d6b86ad817d..0e9ffa28d745 100644 --- a/drivers/staging/comedi/drivers/pcmda12.c +++ b/drivers/staging/comedi/drivers/pcmda12.c @@ -157,7 +157,8 @@ static int pcmda12_attach(struct comedi_device *dev, unsigned long iobase; iobase = it->options[0]; - printk("comedi%d: %s: io: %lx %s ", dev->minor, driver.driver_name, + printk(KERN_INFO + "comedi%d: %s: io: %lx %s ", dev->minor, driver.driver_name, iobase, it->options[1] ? "simultaneous xfer mode enabled" : ""); if (!request_region(iobase, IOSIZE, driver.driver_name)) { @@ -177,7 +178,7 @@ static int pcmda12_attach(struct comedi_device *dev, * convenient macro defined in comedidev.h. */ if (alloc_private(dev, sizeof(struct pcmda12_private)) < 0) { - printk("cannot allocate private data structure\n"); + printk(KERN_ERR "cannot allocate private data structure\n"); return -ENOMEM; } @@ -191,7 +192,7 @@ static int pcmda12_attach(struct comedi_device *dev, * 96-channel version of the board. */ if (alloc_subdevices(dev, 1) < 0) { - printk("cannot allocate subdevice data structures\n"); + printk(KERN_ERR "cannot allocate subdevice data structures\n"); return -ENOMEM; } @@ -207,7 +208,7 @@ static int pcmda12_attach(struct comedi_device *dev, zero_chans(dev); /* clear out all the registers, basically */ - printk("attached\n"); + printk(KERN_INFO "attached\n"); return 1; } @@ -222,7 +223,8 @@ static int pcmda12_attach(struct comedi_device *dev, */ static int pcmda12_detach(struct comedi_device *dev) { - printk("comedi%d: %s: remove\n", dev->minor, driver.driver_name); + printk(KERN_INFO + "comedi%d: %s: remove\n", dev->minor, driver.driver_name); if (dev->iobase) release_region(dev->iobase, IOSIZE); return 0; From 3420f6b4c1ac731e80d0911e0092705992cef14f Mon Sep 17 00:00:00 2001 From: Gustavo Silva Date: Wed, 16 Jun 2010 01:01:07 -0500 Subject: [PATCH 032/523] Staging: comedi: drivers: fix coding style issues in quatech_daqp_cs.c This is a patch to the quatech_daqp_cs.c file that fixes up the following issues: ERROR: code indent should use tabs where possible x 1 WARNING: line over 80 characters x 1 WARNING: braces {} are not necessary for single statement blocks x 10 WARNING: printk() should include KERN_ facility level x 6 Signed-off-by: Gustavo Silva Signed-off-by: Greg Kroah-Hartman --- .../staging/comedi/drivers/quatech_daqp_cs.c | 53 +++++++++---------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c index 78eb254bd619..8d16380744b2 100644 --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c @@ -14,7 +14,7 @@ Documentation for the DAQP PCMCIA cards can be found on Quatech's site: - ftp://ftp.quatech.com/Manuals/daqp-208.pdf + ftp://ftp.quatech.com/Manuals/daqp-208.pdf This manual is for both the DAQP-208 and the DAQP-308. @@ -195,7 +195,7 @@ static struct comedi_driver driver_daqp = { static void daqp_dump(struct comedi_device *dev) { - printk("DAQP: status %02x; aux status %02x\n", + printk(KERN_INFO "DAQP: status %02x; aux status %02x\n", inb(dev->iobase + DAQP_STATUS), inb(dev->iobase + DAQP_AUX)); } @@ -207,9 +207,9 @@ static void hex_dump(char *str, void *ptr, int len) printk(str); for (i = 0; i < len; i++) { - if (i % 16 == 0) { + if (i % 16 == 0) printk("\n0x%08x:", (unsigned int)cptr); - } + printk(" %02x", *(cptr++)); } printk("\n"); @@ -223,9 +223,9 @@ static int daqp_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { struct local_info_t *local = (struct local_info_t *)s->private; - if (local->stop) { + if (local->stop) return -EIO; - } + outb(DAQP_COMMAND_STOP, dev->iobase + DAQP_COMMAND); @@ -355,9 +355,9 @@ static int daqp_ai_insn_read(struct comedi_device *dev, int v; int counter = 10000; - if (local->stop) { + if (local->stop) return -EIO; - } + /* Stop any running conversion */ daqp_ai_cancel(dev, s); @@ -372,9 +372,9 @@ static int daqp_ai_insn_read(struct comedi_device *dev, v = DAQP_SCANLIST_CHANNEL(CR_CHAN(insn->chanspec)) | DAQP_SCANLIST_GAIN(CR_RANGE(insn->chanspec)); - if (CR_AREF(insn->chanspec) == AREF_DIFF) { + if (CR_AREF(insn->chanspec) == AREF_DIFF) v |= DAQP_SCANLIST_DIFFERENTIAL; - } + v |= DAQP_SCANLIST_START; @@ -488,7 +488,10 @@ static int daqp_ai_cmdtest(struct comedi_device *dev, if (err) return 1; - /* step 2: make sure trigger sources are unique and mutually compatible */ + /* + * step 2: make sure trigger sources + * are unique and mutually compatible + */ /* note that mutual compatibility is not an issue here */ if (cmd->scan_begin_src != TRIG_TIMER && @@ -588,9 +591,9 @@ static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) int i; int v; - if (local->stop) { + if (local->stop) return -EIO; - } + /* Stop any running conversion */ daqp_ai_cancel(dev, s); @@ -640,13 +643,11 @@ static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) v = DAQP_SCANLIST_CHANNEL(CR_CHAN(chanspec)) | DAQP_SCANLIST_GAIN(CR_RANGE(chanspec)); - if (CR_AREF(chanspec) == AREF_DIFF) { + if (CR_AREF(chanspec) == AREF_DIFF) v |= DAQP_SCANLIST_DIFFERENTIAL; - } - if (i == 0 || scanlist_start_on_every_entry) { + if (i == 0 || scanlist_start_on_every_entry) v |= DAQP_SCANLIST_START; - } outb(v & 0xff, dev->iobase + DAQP_SCANLIST); outb(v >> 8, dev->iobase + DAQP_SCANLIST); @@ -760,7 +761,8 @@ static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) while (--counter && (inb(dev->iobase + DAQP_STATUS) & DAQP_STATUS_EVENTS)) ; if (!counter) { - printk("daqp: couldn't clear interrupts in status register\n"); + printk(KERN_ERR + "daqp: couldn't clear interrupts in status register\n"); return -1; } @@ -785,9 +787,8 @@ static int daqp_ao_insn_write(struct comedi_device *dev, int d; unsigned int chan; - if (local->stop) { + if (local->stop) return -EIO; - } chan = CR_CHAN(insn->chanspec); d = data[0]; @@ -811,9 +812,8 @@ static int daqp_di_insn_read(struct comedi_device *dev, { struct local_info_t *local = (struct local_info_t *)s->private; - if (local->stop) { + if (local->stop) return -EIO; - } data[0] = inb(dev->iobase + DAQP_DIGITAL_IO); @@ -828,9 +828,8 @@ static int daqp_do_insn_write(struct comedi_device *dev, { struct local_info_t *local = (struct local_info_t *)s->private; - if (local->stop) { + if (local->stop) return -EIO; - } outw(data[0] & 0xf, dev->iobase + DAQP_DIGITAL_IO); @@ -878,7 +877,7 @@ static int daqp_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret < 0) return ret; - printk("comedi%d: attaching daqp%d (io 0x%04lx)\n", + printk(KERN_INFO "comedi%d: attaching daqp%d (io 0x%04lx)\n", dev->minor, it->options[0], dev->iobase); s = dev->subdevices + 0; @@ -931,7 +930,7 @@ static int daqp_attach(struct comedi_device *dev, struct comedi_devconfig *it) static int daqp_detach(struct comedi_device *dev) { - printk("comedi%d: detaching daqp\n", dev->minor); + printk(KERN_INFO "comedi%d: detaching daqp\n", dev->minor); return 0; } @@ -1152,7 +1151,7 @@ static void daqp_cs_config(struct pcmcia_device *link) /* Finally, report what we've done */ dev_info(&link->dev, "index 0x%02x", link->conf.ConfigIndex); if (link->conf.Attributes & CONF_ENABLE_IRQ) - printk(", irq %u", link->irq); + printk(KERN_INFO ", irq %u", link->irq); if (link->io.NumPorts1) printk(", io 0x%04x-0x%04x", link->io.BasePort1, link->io.BasePort1 + link->io.NumPorts1 - 1); From 389cd417e3b0f707ecd933b8fd26e910898ac2fc Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Mon, 14 Jun 2010 12:25:05 +0100 Subject: [PATCH 033/523] Staging: comedi: drivers: das08: Add whitespace to driver comment block Previous whitespace changes to das08.c removed some whitespace from a "driver comment block" that the Comedi team would like to keep. "Header continuation lines" in this comment block should be indented with whitespace. (This is after the " * " at the start of each line.) Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/das08.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 7e7b1a7d3fe5..ad18572a1224 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -29,11 +29,11 @@ * Description: DAS-08 compatible boards * Author: Warren Jasper, ds, Frank Hess * Devices: [Keithley Metrabyte] DAS08 (isa-das08), - * [ComputerBoards] DAS08 (isa-das08), DAS08-PGM (das08-pgm), - * DAS08-PGH (das08-pgh), DAS08-PGL (das08-pgl), DAS08-AOH (das08-aoh), - * DAS08-AOL (das08-aol), DAS08-AOM (das08-aom), DAS08/JR-AO (das08/jr-ao), - * DAS08/JR-16-AO (das08jr-16-ao), PCI-DAS08 (das08), - * PC104-DAS08 (pc104-das08), DAS08/JR/16 (das08jr/16) + * [ComputerBoards] DAS08 (isa-das08), DAS08-PGM (das08-pgm), + * DAS08-PGH (das08-pgh), DAS08-PGL (das08-pgl), DAS08-AOH (das08-aoh), + * DAS08-AOL (das08-aol), DAS08-AOM (das08-aom), DAS08/JR-AO (das08/jr-ao), + * DAS08/JR-16-AO (das08jr-16-ao), PCI-DAS08 (das08), + * PC104-DAS08 (pc104-das08), DAS08/JR/16 (das08jr/16) * Status: works * * This is a rewrite of the das08 and das08jr drivers. From 9a390f38b6a84d5a11c89a116363db3fe587598b Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Mon, 14 Jun 2010 12:49:26 +0100 Subject: [PATCH 034/523] Staging: comedi: drivers: skel: Add whitespace to example comment block The Comedi team have a script 'dump_doc' to extract text from the driver comment block (starting with line 'Driver:') in (most of) the comedi driver source files. This was recently updated to allow and strip off a " * " prefix at the start of each line (well actually, it uses the perl substitution 's/^ ?\* ?//'). The skel.c file contains an instructional comment block about how to format this driver comment block, but the updated 'dump_doc' script mistakenly treats this as a valid driver comment block. This patch adds some extra whitespace to stop the instructional comment block being treated as a valid driver comment block by Comedi's 'dump_doc' script. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/skel.c | 44 +++++++++++++-------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index 732a323ab710..0b9ecb19511e 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -39,28 +39,28 @@ Configuration Options: * The previous block comment is used to automatically generate * documentation in Comedi and Comedilib. The fields: * - * Driver: the name of the driver - * Description: a short phrase describing the driver. Don't list boards. - * Devices: a full list of the boards that attempt to be supported by - * the driver. Format is "(manufacturer) board name [comedi name]", - * where comedi_name is the name that is used to configure the board. - * See the comment near board_name: in the struct comedi_driver structure - * below. If (manufacturer) or [comedi name] is missing, the previous - * value is used. - * Author: you - * Updated: date when the _documentation_ was last updated. Use 'date -R' - * to get a value for this. - * Status: a one-word description of the status. Valid values are: - * works - driver works correctly on most boards supported, and - * passes comedi_test. - * unknown - unknown. Usually put there by ds. - * experimental - may not work in any particular release. Author - * probably wants assistance testing it. - * bitrotten - driver has not been update in a long time, probably - * doesn't work, and probably is missing support for significant - * Comedi interface features. - * untested - author probably wrote it "blind", and is believed to - * work, but no confirmation. + * Driver: the name of the driver + * Description: a short phrase describing the driver. Don't list boards. + * Devices: a full list of the boards that attempt to be supported by + * the driver. Format is "(manufacturer) board name [comedi name]", + * where comedi_name is the name that is used to configure the board. + * See the comment near board_name: in the struct comedi_driver structure + * below. If (manufacturer) or [comedi name] is missing, the previous + * value is used. + * Author: you + * Updated: date when the _documentation_ was last updated. Use 'date -R' + * to get a value for this. + * Status: a one-word description of the status. Valid values are: + * works - driver works correctly on most boards supported, and + * passes comedi_test. + * unknown - unknown. Usually put there by ds. + * experimental - may not work in any particular release. Author + * probably wants assistance testing it. + * bitrotten - driver has not been update in a long time, probably + * doesn't work, and probably is missing support for significant + * Comedi interface features. + * untested - author probably wrote it "blind", and is believed to + * work, but no confirmation. * * These headers should be followed by a blank line, and any comments * you wish to say about the driver. The comment area is the place From 80370692f60b4d5dfa243cb0fbd0a87a42a939a8 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Mon, 14 Jun 2010 12:49:27 +0100 Subject: [PATCH 035/523] Staging: Comedi: drivers: Remove comment copied from skel.c The dmm32at.c and comedi_bond.c comedi driver files contain an instructional comment block copied over from skel.c about how to format a driver comment block. This comment was modified in skel.c by a previous patch in this series to stop Comedi's 'dump_doc' script treating it as an actual driver comment block. There isn't any need to repeat this comment block in the other source files, so rather than modify it, this patch just removes it from those files. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/comedi_bond.c | 37 -------------------- drivers/staging/comedi/drivers/dmm32at.c | 37 -------------------- 2 files changed, 74 deletions(-) diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 701622280ff4..cfcbd9b8f393 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -50,43 +50,6 @@ Configuration Options: within each minor will be concatenated together in the order given here. */ -/* - * The previous block comment is used to automatically generate - * documentation in Comedi and Comedilib. The fields: - * - * Driver: the name of the driver - * Description: a short phrase describing the driver. Don't list boards. - * Devices: a full list of the boards that attempt to be supported by - * the driver. Format is "(manufacturer) board name [comedi name]", - * where comedi_name is the name that is used to configure the board. - * See the comment near board_name: in the struct comedi_driver structure - * below. If (manufacturer) or [comedi name] is missing, the previous - * value is used. - * Author: you - * Updated: date when the _documentation_ was last updated. Use 'date -R' - * to get a value for this. - * Status: a one-word description of the status. Valid values are: - * works - driver works correctly on most boards supported, and - * passes comedi_test. - * unknown - unknown. Usually put there by ds. - * experimental - may not work in any particular release. Author - * probably wants assistance testing it. - * bitrotten - driver has not been update in a long time, probably - * doesn't work, and probably is missing support for significant - * Comedi interface features. - * untested - author probably wrote it "blind", and is believed to - * work, but no confirmation. - * - * These headers should be followed by a blank line, and any comments - * you wish to say about the driver. The comment area is the place - * to put any known bugs, limitations, unsupported features, supported - * command triggers, whether or not commands are supported on particular - * subdevices, etc. - * - * Somewhere in the comment should be information about configuration - * options that are used with comedi_config. - */ - #include #include #include "../comedi.h" diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index dcde8d8dd406..957322320b73 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -37,43 +37,6 @@ Configuration Options: comedi_config /dev/comedi0 dmm32at baseaddr,irq */ -/* - * The previous block comment is used to automatically generate - * documentation in Comedi and Comedilib. The fields: - * - * Driver: the name of the driver - * Description: a short phrase describing the driver. Don't list boards. - * Devices: a full list of the boards that attempt to be supported by - * the driver. Format is "(manufacturer) board name [comedi name]", - * where comedi_name is the name that is used to configure the board. - * See the comment near board_name: in the struct comedi_driver structure - * below. If (manufacturer) or [comedi name] is missing, the previous - * value is used. - * Author: you - * Updated: date when the _documentation_ was last updated. Use 'date -R' - * to get a value for this. - * Status: a one-word description of the status. Valid values are: - * works - driver works correctly on most boards supported, and - * passes comedi_test. - * unknown - unknown. Usually put there by ds. - * experimental - may not work in any particular release. Author - * probably wants assistance testing it. - * bitrotten - driver has not been update in a long time, probably - * doesn't work, and probably is missing support for significant - * Comedi interface features. - * untested - author probably wrote it "blind", and is believed to - * work, but no confirmation. - * - * These headers should be followed by a blank line, and any comments - * you wish to say about the driver. The comment area is the place - * to put any known bugs, limitations, unsupported features, supported - * command triggers, whether or not commands are supported on particular - * subdevices, etc. - * - * Somewhere in the comment should be information about configuration - * options that are used with comedi_config. - */ - #include #include "../comedidev.h" #include From ba22a15ae8018606234b3c2c99e3ae1b922b3f60 Mon Sep 17 00:00:00 2001 From: Lars Lindley Date: Wed, 19 May 2010 15:07:30 +0100 Subject: [PATCH 036/523] Staging: et131x: Small format/style tidyups I fixed indentation in one place and two long lines, a space and a brace found by checkpatch.pl and fixed some long lines and whitespace around an =. Signed-off-by: Lars Lindley Signed-off-by: Alan Cox Signed-off-by: Greg Kroah-Hartman --- drivers/staging/et131x/et1310_phy.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index a6d9f29ff49c..21c5eeec62dd 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -760,7 +760,8 @@ void et131x_Mii_check(struct et131x_adapter *etdev, if (etdev->linkspeed == TRUEPHY_SPEED_10MBPS) { /* NOTE - Is there a way to query this without * TruePHY? - * && TRU_QueryCoreType(etdev->hTruePhy, 0) == EMI_TRUEPHY_A13O) { + * && TRU_QueryCoreType(etdev->hTruePhy, 0) == + * EMI_TRUEPHY_A13O) { */ u16 Register18; @@ -778,7 +779,7 @@ void et131x_Mii_check(struct et131x_adapter *etdev, * in the LinkDetectionDPC). */ if (!(etdev->Flags & fMP_ADAPTER_LINK_DETECTION) || - (etdev->MediaState == NETIF_STATUS_MEDIA_DISCONNECT)) { + (etdev->MediaState == NETIF_STATUS_MEDIA_DISCONNECT)) { spin_lock_irqsave(&etdev->Lock, flags); etdev->MediaState = NETIF_STATUS_MEDIA_DISCONNECT; @@ -836,7 +837,8 @@ void et131x_Mii_check(struct et131x_adapter *etdev, /* * NOTE - Is there a way to query this without * TruePHY? - * && TRU_QueryCoreType(etdev->hTruePhy, 0)== EMI_TRUEPHY_A13O) { + * && TRU_QueryCoreType(etdev->hTruePhy, 0)== + * EMI_TRUEPHY_A13O) { */ u16 Register18; From 3cc544df9373c7947be35f30ddee9725710994b0 Mon Sep 17 00:00:00 2001 From: Gustavo Silva Date: Fri, 18 Jun 2010 00:01:34 -0500 Subject: [PATCH 037/523] Staging: comedi: drivers: fix coding style issues in pcl812.c This is a patch to the pcl812.c file that fixes up the following issues: ERROR: code indent should use tabs where possible x 27 WARNING: line over 80 characters x 37 WARNING: please, no space before tabs x 13 WARNING: braces {} are not necessary for single statement blocks x 2 WARNING: printk() should include KERN_ facility level x 22 WARNING: braces {} are not necessary for any arm of this statement x 5 Signed-off-by: Gustavo Silva Acked-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/pcl812.c | 464 +++++++++++++----------- 1 file changed, 253 insertions(+), 211 deletions(-) diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c index 943fb713bd7d..c6dce4a1425e 100644 --- a/drivers/staging/comedi/drivers/pcl812.c +++ b/drivers/staging/comedi/drivers/pcl812.c @@ -15,97 +15,98 @@ * card: A-823PGH, A-823PGL, A-826PG * driver: a823pgh, a823pgl, a826pg */ + /* -Driver: pcl812 -Description: Advantech PCL-812/PG, PCL-813/B, - ADLink ACL-8112DG/HG/PG, ACL-8113, ACL-8216, - ICP DAS A-821PGH/PGL/PGL-NDA, A-822PGH/PGL, A-823PGH/PGL, A-826PG, - ICP DAS ISO-813 -Author: Michal Dobes -Devices: [Advantech] PCL-812 (pcl812), PCL-812PG (pcl812pg), - PCL-813 (pcl813), PCL-813B (pcl813b), [ADLink] ACL-8112DG (acl8112dg), - ACL-8112HG (acl8112hg), ACL-8113 (acl-8113), ACL-8216 (acl8216), - [ICP] ISO-813 (iso813), A-821PGH (a821pgh), A-821PGL (a821pgl), - A-821PGL-NDA (a821pclnda), A-822PGH (a822pgh), A-822PGL (a822pgl), - A-823PGH (a823pgh), A-823PGL (a823pgl), A-826PG (a826pg) -Updated: Mon, 06 Aug 2007 12:03:15 +0100 -Status: works (I hope. My board fire up under my hands - and I cann't test all features.) - -This driver supports insn and cmd interfaces. Some boards support only insn -becouse their hardware don't allow more (PCL-813/B, ACL-8113, ISO-813). -Data transfer over DMA is supported only when you measure only one -channel, this is too hardware limitation of these boards. - -Options for PCL-812: - [0] - IO Base - [1] - IRQ (0=disable, 2, 3, 4, 5, 6, 7; 10, 11, 12, 14, 15) - [2] - DMA (0=disable, 1, 3) - [3] - 0=trigger source is internal 8253 with 2MHz clock - 1=trigger source is external - [4] - 0=A/D input range is +/-10V - 1=A/D input range is +/-5V - 2=A/D input range is +/-2.5V - 3=A/D input range is +/-1.25V - 4=A/D input range is +/-0.625V - 5=A/D input range is +/-0.3125V - [5] - 0=D/A outputs 0-5V (internal reference -5V) - 1=D/A outputs 0-10V (internal reference -10V) - 2=D/A outputs unknown (external reference) - -Options for PCL-812PG, ACL-8112PG: - [0] - IO Base - [1] - IRQ (0=disable, 2, 3, 4, 5, 6, 7; 10, 11, 12, 14, 15) - [2] - DMA (0=disable, 1, 3) - [3] - 0=trigger source is internal 8253 with 2MHz clock - 1=trigger source is external - [4] - 0=A/D have max +/-5V input - 1=A/D have max +/-10V input - [5] - 0=D/A outputs 0-5V (internal reference -5V) - 1=D/A outputs 0-10V (internal reference -10V) - 2=D/A outputs unknown (external reference) - -Options for ACL-8112DG/HG, A-822PGL/PGH, A-823PGL/PGH, ACL-8216, A-826PG: - [0] - IO Base - [1] - IRQ (0=disable, 2, 3, 4, 5, 6, 7; 10, 11, 12, 14, 15) - [2] - DMA (0=disable, 1, 3) - [3] - 0=trigger source is internal 8253 with 2MHz clock - 1=trigger source is external - [4] - 0=A/D channels are S.E. - 1=A/D channels are DIFF - [5] - 0=D/A outputs 0-5V (internal reference -5V) - 1=D/A outputs 0-10V (internal reference -10V) - 2=D/A outputs unknown (external reference) - -Options for A-821PGL/PGH: - [0] - IO Base - [1] - IRQ (0=disable, 2, 3, 4, 5, 6, 7) - [2] - 0=A/D channels are S.E. - 1=A/D channels are DIFF - [3] - 0=D/A output 0-5V (internal reference -5V) - 1=D/A output 0-10V (internal reference -10V) - -Options for A-821PGL-NDA: - [0] - IO Base - [1] - IRQ (0=disable, 2, 3, 4, 5, 6, 7) - [2] - 0=A/D channels are S.E. - 1=A/D channels are DIFF - -Options for PCL-813: - [0] - IO Base - -Options for PCL-813B: - [0] - IO Base - [1] - 0= bipolar inputs - 1= unipolar inputs - -Options for ACL-8113, ISO-813: - [0] - IO Base - [1] - 0= 10V bipolar inputs - 1= 10V unipolar inputs - 2= 20V bipolar inputs - 3= 20V unipolar inputs -*/ + * Driver: pcl812 + * Description: Advantech PCL-812/PG, PCL-813/B, + * ADLink ACL-8112DG/HG/PG, ACL-8113, ACL-8216, + * ICP DAS A-821PGH/PGL/PGL-NDA, A-822PGH/PGL, A-823PGH/PGL, A-826PG, + * ICP DAS ISO-813 + * Author: Michal Dobes + * Devices: [Advantech] PCL-812 (pcl812), PCL-812PG (pcl812pg), + * PCL-813 (pcl813), PCL-813B (pcl813b), [ADLink] ACL-8112DG (acl8112dg), + * ACL-8112HG (acl8112hg), ACL-8113 (acl-8113), ACL-8216 (acl8216), + * [ICP] ISO-813 (iso813), A-821PGH (a821pgh), A-821PGL (a821pgl), + * A-821PGL-NDA (a821pclnda), A-822PGH (a822pgh), A-822PGL (a822pgl), + * A-823PGH (a823pgh), A-823PGL (a823pgl), A-826PG (a826pg) + * Updated: Mon, 06 Aug 2007 12:03:15 +0100 + * Status: works (I hope. My board fire up under my hands + * and I cann't test all features.) + * + * This driver supports insn and cmd interfaces. Some boards support only insn + * becouse their hardware don't allow more (PCL-813/B, ACL-8113, ISO-813). + * Data transfer over DMA is supported only when you measure only one + * channel, this is too hardware limitation of these boards. + * + * Options for PCL-812: + * [0] - IO Base + * [1] - IRQ (0=disable, 2, 3, 4, 5, 6, 7; 10, 11, 12, 14, 15) + * [2] - DMA (0=disable, 1, 3) + * [3] - 0=trigger source is internal 8253 with 2MHz clock + * 1=trigger source is external + * [4] - 0=A/D input range is +/-10V + * 1=A/D input range is +/-5V + * 2=A/D input range is +/-2.5V + * 3=A/D input range is +/-1.25V + * 4=A/D input range is +/-0.625V + * 5=A/D input range is +/-0.3125V + * [5] - 0=D/A outputs 0-5V (internal reference -5V) + * 1=D/A outputs 0-10V (internal reference -10V) + * 2=D/A outputs unknown (external reference) + * + * Options for PCL-812PG, ACL-8112PG: + * [0] - IO Base + * [1] - IRQ (0=disable, 2, 3, 4, 5, 6, 7; 10, 11, 12, 14, 15) + * [2] - DMA (0=disable, 1, 3) + * [3] - 0=trigger source is internal 8253 with 2MHz clock + * 1=trigger source is external + * [4] - 0=A/D have max +/-5V input + * 1=A/D have max +/-10V input + * [5] - 0=D/A outputs 0-5V (internal reference -5V) + * 1=D/A outputs 0-10V (internal reference -10V) + * 2=D/A outputs unknown (external reference) + * + * Options for ACL-8112DG/HG, A-822PGL/PGH, A-823PGL/PGH, ACL-8216, A-826PG: + * [0] - IO Base + * [1] - IRQ (0=disable, 2, 3, 4, 5, 6, 7; 10, 11, 12, 14, 15) + * [2] - DMA (0=disable, 1, 3) + * [3] - 0=trigger source is internal 8253 with 2MHz clock + * 1=trigger source is external + * [4] - 0=A/D channels are S.E. + * 1=A/D channels are DIFF + * [5] - 0=D/A outputs 0-5V (internal reference -5V) + * 1=D/A outputs 0-10V (internal reference -10V) + * 2=D/A outputs unknown (external reference) + * + * Options for A-821PGL/PGH: + * [0] - IO Base + * [1] - IRQ (0=disable, 2, 3, 4, 5, 6, 7) + * [2] - 0=A/D channels are S.E. + * 1=A/D channels are DIFF + * [3] - 0=D/A output 0-5V (internal reference -5V) + * 1=D/A output 0-10V (internal reference -10V) + * + * Options for A-821PGL-NDA: + * [0] - IO Base + * [1] - IRQ (0=disable, 2, 3, 4, 5, 6, 7) + * [2] - 0=A/D channels are S.E. + * 1=A/D channels are DIFF + * + * Options for PCL-813: + * [0] - IO Base + * + * Options for PCL-813B: + * [0] - IO Base + * [1] - 0= bipolar inputs + * 1= unipolar inputs + * + * Options for ACL-8113, ISO-813: + * [0] - IO Base + * [1] - 0= 10V bipolar inputs + * 1= 10V unipolar inputs + * 2= 20V bipolar inputs + * 3= 20V unipolar inputs + */ #include #include @@ -117,49 +118,50 @@ Options for ACL-8113, ISO-813: #include "8253.h" -#undef PCL812_EXTDEBUG /* if this is defined then a lot of messages is printed */ +/* if this is defined then a lot of messages is printed */ +#undef PCL812_EXTDEBUG /* hardware types of the cards */ -#define boardPCL812PG 0 /* and ACL-8112PG */ -#define boardPCL813B 1 -#define boardPCL812 2 -#define boardPCL813 3 -#define boardISO813 5 -#define boardACL8113 6 -#define boardACL8112 7 /* ACL-8112DG/HG, A-822PGL/PGH, A-823PGL/PGH */ -#define boardACL8216 8 /* and ICP DAS A-826PG */ -#define boardA821 9 /* PGH, PGL, PGL/NDA versions */ +#define boardPCL812PG 0 /* and ACL-8112PG */ +#define boardPCL813B 1 +#define boardPCL812 2 +#define boardPCL813 3 +#define boardISO813 5 +#define boardACL8113 6 +#define boardACL8112 7 /* ACL-8112DG/HG, A-822PGL/PGH, A-823PGL/PGH */ +#define boardACL8216 8 /* and ICP DAS A-826PG */ +#define boardA821 9 /* PGH, PGL, PGL/NDA versions */ -#define PCLx1x_IORANGE 16 +#define PCLx1x_IORANGE 16 -#define PCL812_CTR0 0 -#define PCL812_CTR1 1 -#define PCL812_CTR2 2 -#define PCL812_CTRCTL 3 -#define PCL812_AD_LO 4 -#define PCL812_DA1_LO 4 -#define PCL812_AD_HI 5 -#define PCL812_DA1_HI 5 -#define PCL812_DA2_LO 6 -#define PCL812_DI_LO 6 -#define PCL812_DA2_HI 7 -#define PCL812_DI_HI 7 -#define PCL812_CLRINT 8 -#define PCL812_GAIN 9 -#define PCL812_MUX 10 -#define PCL812_MODE 11 -#define PCL812_CNTENABLE 10 -#define PCL812_SOFTTRIG 12 -#define PCL812_DO_LO 13 -#define PCL812_DO_HI 14 +#define PCL812_CTR0 0 +#define PCL812_CTR1 1 +#define PCL812_CTR2 2 +#define PCL812_CTRCTL 3 +#define PCL812_AD_LO 4 +#define PCL812_DA1_LO 4 +#define PCL812_AD_HI 5 +#define PCL812_DA1_HI 5 +#define PCL812_DA2_LO 6 +#define PCL812_DI_LO 6 +#define PCL812_DA2_HI 7 +#define PCL812_DI_HI 7 +#define PCL812_CLRINT 8 +#define PCL812_GAIN 9 +#define PCL812_MUX 10 +#define PCL812_MODE 11 +#define PCL812_CNTENABLE 10 +#define PCL812_SOFTTRIG 12 +#define PCL812_DO_LO 13 +#define PCL812_DO_HI 14 -#define PCL812_DRDY 0x10 /* =0 data ready */ +#define PCL812_DRDY 0x10 /* =0 data ready */ -#define ACL8216_STATUS 8 /* 5. bit signalize data ready */ +#define ACL8216_STATUS 8 /* 5. bit signalize data ready */ -#define ACL8216_DRDY 0x20 /* =0 data ready */ +#define ACL8216_DRDY 0x20 /* =0 data ready */ -#define MAX_CHANLIST_LEN 256 /* length of scan list */ +#define MAX_CHANLIST_LEN 256 /* length of scan list */ static const struct comedi_lrange range_pcl812pg_ai = { 5, { BIP_RANGE(5), @@ -477,10 +479,13 @@ static int pcl812_ai_insn_read(struct comedi_device *dev, int n; int timeout, hi; - outb(devpriv->mode_reg_int | 1, dev->iobase + PCL812_MODE); /* select software trigger */ - setup_range_channel(dev, s, insn->chanspec, 1); /* select channel and renge */ + /* select software trigger */ + outb(devpriv->mode_reg_int | 1, dev->iobase + PCL812_MODE); + /* select channel and renge */ + setup_range_channel(dev, s, insn->chanspec, 1); for (n = 0; n < insn->n; n++) { - outb(255, dev->iobase + PCL812_SOFTTRIG); /* start conversion */ + /* start conversion */ + outb(255, dev->iobase + PCL812_SOFTTRIG); udelay(5); timeout = 50; /* wait max 50us, it must finish under 33us */ while (timeout--) { @@ -512,10 +517,13 @@ static int acl8216_ai_insn_read(struct comedi_device *dev, int n; int timeout; - outb(1, dev->iobase + PCL812_MODE); /* select software trigger */ - setup_range_channel(dev, s, insn->chanspec, 1); /* select channel and renge */ + /* select software trigger */ + outb(1, dev->iobase + PCL812_MODE); + /* select channel and renge */ + setup_range_channel(dev, s, insn->chanspec, 1); for (n = 0; n < insn->n; n++) { - outb(255, dev->iobase + PCL812_SOFTTRIG); /* start conversion */ + /* start conversion */ + outb(255, dev->iobase + PCL812_SOFTTRIG); udelay(5); timeout = 50; /* wait max 50us, it must finish under 33us */ while (timeout--) { @@ -569,9 +577,8 @@ static int pcl812_ao_insn_read(struct comedi_device *dev, int chan = CR_CHAN(insn->chanspec); int i; - for (i = 0; i < insn->n; i++) { + for (i = 0; i < insn->n; i++) data[i] = devpriv->ao_readback[chan]; - } return i; } @@ -619,14 +626,15 @@ static int pcl812_do_insn_bits(struct comedi_device *dev, */ static void pcl812_cmdtest_out(int e, struct comedi_cmd *cmd) { - printk("pcl812 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e, + printk(KERN_INFO "pcl812 e=%d startsrc=%x scansrc=%x convsrc=%x\n", e, cmd->start_src, cmd->scan_begin_src, cmd->convert_src); - printk("pcl812 e=%d startarg=%d scanarg=%d convarg=%d\n", e, + printk(KERN_INFO "pcl812 e=%d startarg=%d scanarg=%d convarg=%d\n", e, cmd->start_arg, cmd->scan_begin_arg, cmd->convert_arg); - printk("pcl812 e=%d stopsrc=%x scanend=%x\n", e, cmd->stop_src, - cmd->scan_end_src); - printk("pcl812 e=%d stoparg=%d scanendarg=%d chanlistlen=%d\n", e, - cmd->stop_arg, cmd->scan_end_arg, cmd->chanlist_len); + printk(KERN_INFO "pcl812 e=%d stopsrc=%x scanend=%x\n", e, + cmd->stop_src, cmd->scan_end_src); + printk(KERN_INFO "pcl812 e=%d stoparg=%d scanendarg=%d " + "chanlistlen=%d\n", e, cmd->stop_arg, cmd->scan_end_arg, + cmd->chanlist_len); } #endif @@ -656,11 +664,11 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, err++; tmp = cmd->convert_src; - if (devpriv->use_ext_trg) { + if (devpriv->use_ext_trg) cmd->convert_src &= TRIG_EXT; - } else { + else cmd->convert_src &= TRIG_TIMER; - } + if (!cmd->convert_src || tmp != cmd->convert_src) err++; @@ -684,7 +692,10 @@ static int pcl812_ai_cmdtest(struct comedi_device *dev, return 1; } - /* step 2: make sure trigger sources are unique and mutually compatible */ + /* + * step 2: make sure trigger sources are + * unique and mutually compatible + */ if (cmd->start_src != TRIG_NOW) { cmd->start_src = TRIG_NOW; @@ -818,7 +829,7 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) struct comedi_cmd *cmd = &s->async->cmd; #ifdef PCL812_EXTDEBUG - printk("pcl812 EDBG: BGN: pcl812_ai_cmd(...)\n"); + printk(KERN_DEBUG "pcl812 EDBG: BGN: pcl812_ai_cmd(...)\n"); #endif if (cmd->start_src != TRIG_NOW) @@ -853,13 +864,15 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_n_chan = cmd->chanlist_len; memcpy(devpriv->ai_chanlist, cmd->chanlist, sizeof(unsigned int) * cmd->scan_end_arg); - setup_range_channel(dev, s, devpriv->ai_chanlist[0], 1); /* select first channel and range */ + /* select first channel and range */ + setup_range_channel(dev, s, devpriv->ai_chanlist[0], 1); if (devpriv->dma) { /* check if we can use DMA transfer */ devpriv->ai_dma = 1; for (i = 1; i < devpriv->ai_n_chan; i++) if (devpriv->ai_chanlist[0] != devpriv->ai_chanlist[i]) { - devpriv->ai_dma = 0; /* we cann't use DMA :-( */ + /* we cann't use DMA :-( */ + devpriv->ai_dma = 0; break; } } else @@ -880,14 +893,18 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_poll_ptr = 0; s->async->cur_chan = 0; - if ((devpriv->ai_flags & TRIG_WAKE_EOS)) { /* don't we want wake up every scan? */ + /* don't we want wake up every scan? */ + if ((devpriv->ai_flags & TRIG_WAKE_EOS)) { devpriv->ai_eos = 1; + + /* DMA is useless for this situation */ if (devpriv->ai_n_chan == 1) - devpriv->ai_dma = 0; /* DMA is useless for this situation */ + devpriv->ai_dma = 0; } if (devpriv->ai_dma) { - if (devpriv->ai_eos) { /* we use EOS, so adapt DMA buffer to one scan */ + /* we use EOS, so adapt DMA buffer to one scan */ + if (devpriv->ai_eos) { devpriv->dmabytestomove[0] = devpriv->ai_n_chan * sizeof(short); devpriv->dmabytestomove[1] = @@ -905,9 +922,17 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (devpriv->ai_neverending) { devpriv->dma_runs_to_end = 1; } else { - bytes = devpriv->ai_n_chan * devpriv->ai_scans * sizeof(short); /* how many samples we must transfer? */ - devpriv->dma_runs_to_end = bytes / devpriv->dmabytestomove[0]; /* how many DMA pages we must fill */ - devpriv->last_dma_run = bytes % devpriv->dmabytestomove[0]; /* on last dma transfer must be moved */ + /* how many samples we must transfer? */ + bytes = devpriv->ai_n_chan * + devpriv->ai_scans * sizeof(short); + + /* how many DMA pages we must fill */ + devpriv->dma_runs_to_end = + bytes / devpriv->dmabytestomove[0]; + + /* on last dma transfer must be moved */ + devpriv->last_dma_run = + bytes % devpriv->dmabytestomove[0]; if (devpriv->dma_runs_to_end == 0) devpriv->dmabytestomove[0] = devpriv->last_dma_run; @@ -945,14 +970,13 @@ static int pcl812_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) break; } - if (devpriv->ai_dma) { - outb(devpriv->mode_reg_int | 2, dev->iobase + PCL812_MODE); /* let's go! */ - } else { - outb(devpriv->mode_reg_int | 6, dev->iobase + PCL812_MODE); /* let's go! */ - } + if (devpriv->ai_dma) /* let's go! */ + outb(devpriv->mode_reg_int | 2, dev->iobase + PCL812_MODE); + else /* let's go! */ + outb(devpriv->mode_reg_int | 6, dev->iobase + PCL812_MODE); #ifdef PCL812_EXTDEBUG - printk("pcl812 EDBG: END: pcl812_ai_cmd(...)\n"); + printk(KERN_DEBUG "pcl812 EDBG: END: pcl812_ai_cmd(...)\n"); #endif return 0; @@ -994,7 +1018,8 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d) if (err) { printk - ("comedi%d: pcl812: (%s at 0x%lx) A/D cmd IRQ without DRDY!\n", + ("comedi%d: pcl812: (%s at 0x%lx) " + "A/D cmd IRQ without DRDY!\n", dev->minor, dev->board_name, dev->iobase); pcl812_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR; @@ -1020,7 +1045,8 @@ static irqreturn_t interrupt_pcl812_ai_int(int irq, void *d) if (next_chan == 0) { /* one scan done */ devpriv->ai_act_scan++; if (!(devpriv->ai_neverending)) - if (devpriv->ai_act_scan >= devpriv->ai_scans) { /* all data sampled */ + /* all data sampled */ + if (devpriv->ai_act_scan >= devpriv->ai_scans) { pcl812_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA; } @@ -1041,14 +1067,16 @@ static void transfer_from_dma_buf(struct comedi_device *dev, s->async->events = 0; for (i = len; i; i--) { - comedi_buf_put(s->async, ptr[bufptr++]); /* get one sample */ + /* get one sample */ + comedi_buf_put(s->async, ptr[bufptr++]); s->async->cur_chan++; if (s->async->cur_chan >= devpriv->ai_n_chan) { s->async->cur_chan = 0; devpriv->ai_act_scan++; if (!devpriv->ai_neverending) - if (devpriv->ai_act_scan >= devpriv->ai_scans) { /* all data sampled */ + /* all data sampled */ + if (devpriv->ai_act_scan >= devpriv->ai_scans) { pcl812_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA; break; @@ -1071,7 +1099,7 @@ static irqreturn_t interrupt_pcl812_ai_dma(int irq, void *d) short *ptr; #ifdef PCL812_EXTDEBUG - printk("pcl812 EDBG: BGN: interrupt_pcl812_ai_dma(...)\n"); + printk(KERN_DEBUG "pcl812 EDBG: BGN: interrupt_pcl812_ai_dma(...)\n"); #endif ptr = (short *)devpriv->dmabuf[devpriv->next_dma_buf]; len = (devpriv->dmabytestomove[devpriv->next_dma_buf] >> 1) - @@ -1106,7 +1134,7 @@ static irqreturn_t interrupt_pcl812_ai_dma(int irq, void *d) transfer_from_dma_buf(dev, s, ptr, bufptr, len); #ifdef PCL812_EXTDEBUG - printk("pcl812 EDBG: END: interrupt_pcl812_ai_dma(...)\n"); + printk(KERN_DEBUG "pcl812 EDBG: END: interrupt_pcl812_ai_dma(...)\n"); #endif return IRQ_HANDLED; } @@ -1122,11 +1150,10 @@ static irqreturn_t interrupt_pcl812(int irq, void *d) comedi_error(dev, "spurious interrupt"); return IRQ_HANDLED; } - if (devpriv->ai_dma) { + if (devpriv->ai_dma) return interrupt_pcl812_ai_dma(irq, d); - } else { + else return interrupt_pcl812_ai_int(irq, d); - }; } /* @@ -1143,7 +1170,8 @@ static int pcl812_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s) spin_lock_irqsave(&dev->spinlock, flags); for (i = 0; i < 10; i++) { - top1 = get_dma_residue(devpriv->ai_dma); /* where is now DMA */ + /* where is now DMA */ + top1 = get_dma_residue(devpriv->ai_dma); top2 = get_dma_residue(devpriv->ai_dma); if (top1 == top2) break; @@ -1153,8 +1181,8 @@ static int pcl812_ai_poll(struct comedi_device *dev, struct comedi_subdevice *s) spin_unlock_irqrestore(&dev->spinlock, flags); return 0; } - - top1 = devpriv->dmabytestomove[1 - devpriv->next_dma_buf] - top1; /* where is now DMA in buffer */ + /* where is now DMA in buffer */ + top1 = devpriv->dmabytestomove[1 - devpriv->next_dma_buf] - top1; top1 >>= 1; /* sample position */ top2 = top1 - devpriv->ai_poll_ptr; if (top2 < 1) { /* no new samples */ @@ -1182,7 +1210,9 @@ static void setup_range_channel(struct comedi_device *dev, unsigned int rangechan, char wait) { unsigned char chan_reg = CR_CHAN(rangechan); /* normal board */ - unsigned char gain_reg = CR_RANGE(rangechan) + devpriv->range_correction; /* gain index */ + /* gain index */ + unsigned char gain_reg = CR_RANGE(rangechan) + + devpriv->range_correction; if ((chan_reg == devpriv->old_chan_reg) && (gain_reg == devpriv->old_gain_reg)) @@ -1195,20 +1225,25 @@ static void setup_range_channel(struct comedi_device *dev, if (devpriv->use_diff) { chan_reg = chan_reg | 0x30; /* DIFF inputs */ } else { - if (chan_reg & 0x80) { - chan_reg = chan_reg | 0x20; /* SE inputs 8-15 */ - } else { - chan_reg = chan_reg | 0x10; /* SE inputs 0-7 */ - } + if (chan_reg & 0x80) + /* SE inputs 8-15 */ + chan_reg = chan_reg | 0x20; + else + /* SE inputs 0-7 */ + chan_reg = chan_reg | 0x10; } } outb(chan_reg, dev->iobase + PCL812_MUX); /* select channel */ outb(gain_reg, dev->iobase + PCL812_GAIN); /* select gain */ - if (wait) { - udelay(devpriv->max_812_ai_mode0_rangewait); /* XXX this depends on selected range and can be very long for some high gain ranges! */ - } + + if (wait) + /* + * XXX this depends on selected range and can be very long for + * some high gain ranges! + */ + udelay(devpriv->max_812_ai_mode0_rangewait); } /* @@ -1218,8 +1253,8 @@ static void start_pacer(struct comedi_device *dev, int mode, unsigned int divisor1, unsigned int divisor2) { #ifdef PCL812_EXTDEBUG - printk("pcl812 EDBG: BGN: start_pacer(%d,%u,%u)\n", mode, divisor1, - divisor2); + printk(KERN_DEBUG "pcl812 EDBG: BGN: start_pacer(%d,%u,%u)\n", mode, + divisor1, divisor2); #endif outb(0xb4, dev->iobase + PCL812_CTRCTL); outb(0x74, dev->iobase + PCL812_CTRCTL); @@ -1232,7 +1267,7 @@ static void start_pacer(struct comedi_device *dev, int mode, outb((divisor1 >> 8) & 0xff, dev->iobase + PCL812_CTR1); } #ifdef PCL812_EXTDEBUG - printk("pcl812 EDBG: END: start_pacer(...)\n"); + printk(KERN_DEBUG "pcl812 EDBG: END: start_pacer(...)\n"); #endif } @@ -1263,16 +1298,17 @@ static int pcl812_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { #ifdef PCL812_EXTDEBUG - printk("pcl812 EDBG: BGN: pcl812_ai_cancel(...)\n"); + printk(KERN_DEBUG "pcl812 EDBG: BGN: pcl812_ai_cancel(...)\n"); #endif if (devpriv->ai_dma) disable_dma(devpriv->dma); outb(0, dev->iobase + PCL812_CLRINT); /* clear INT request */ - outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE); /* Stop A/D */ + /* Stop A/D */ + outb(devpriv->mode_reg_int | 0, dev->iobase + PCL812_MODE); start_pacer(dev, -1, 0, 0); /* stop 8254 */ outb(0, dev->iobase + PCL812_CLRINT); /* clear INT request */ #ifdef PCL812_EXTDEBUG - printk("pcl812 EDBG: END: pcl812_ai_cancel(...)\n"); + printk(KERN_DEBUG "pcl812 EDBG: END: pcl812_ai_cancel(...)\n"); #endif return 0; } @@ -1283,7 +1319,7 @@ static int pcl812_ai_cancel(struct comedi_device *dev, static void pcl812_reset(struct comedi_device *dev) { #ifdef PCL812_EXTDEBUG - printk("pcl812 EDBG: BGN: pcl812_reset(...)\n"); + printk(KERN_DEBUG "pcl812 EDBG: BGN: pcl812_reset(...)\n"); #endif outb(0, dev->iobase + PCL812_MUX); outb(0 + devpriv->range_correction, dev->iobase + PCL812_GAIN); @@ -1315,7 +1351,7 @@ static void pcl812_reset(struct comedi_device *dev) } udelay(5); #ifdef PCL812_EXTDEBUG - printk("pcl812 EDBG: END: pcl812_reset(...)\n"); + printk(KERN_DEBUG "pcl812 EDBG: END: pcl812_reset(...)\n"); #endif } @@ -1333,8 +1369,8 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) int n_subdevices; iobase = it->options[0]; - printk("comedi%d: pcl812: board=%s, ioport=0x%03lx", dev->minor, - this_board->name, iobase); + printk(KERN_INFO "comedi%d: pcl812: board=%s, ioport=0x%03lx", + dev->minor, this_board->name, iobase); if (!request_region(iobase, this_board->io_range, "pcl812")) { printk("I/O port conflict\n"); @@ -1356,18 +1392,18 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (irq) { /* we want to use IRQ */ if (((1 << irq) & this_board->IRQbits) == 0) { printk - (", IRQ %u is out of allowed range, DISABLING IT", - irq); + (", IRQ %u is out of allowed range, " + "DISABLING IT", irq); irq = 0; /* Bad IRQ */ } else { if (request_irq (irq, interrupt_pcl812, 0, "pcl812", dev)) { printk - (", unable to allocate IRQ %u, DISABLING IT", - irq); + (", unable to allocate IRQ %u, " + "DISABLING IT", irq); irq = 0; /* Can't use IRQ */ } else { - printk(", irq=%u", irq); + printk(KERN_INFO ", irq=%u", irq); } } } @@ -1387,16 +1423,20 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) } ret = request_dma(dma, "pcl812"); if (ret) { - printk(", unable to allocate DMA %u, FAIL!\n", dma); + printk(KERN_ERR ", unable to allocate DMA %u, FAIL!\n", + dma); return -EBUSY; /* DMA isn't free */ } devpriv->dma = dma; - printk(", dma=%u", dma); + printk(KERN_INFO ", dma=%u", dma); pages = 1; /* we want 8KB */ devpriv->dmabuf[0] = __get_dma_pages(GFP_KERNEL, pages); if (!devpriv->dmabuf[0]) { printk(", unable to allocate DMA buffer, FAIL!\n"); - /* maybe experiment with try_to_free_pages() will help .... */ + /* + * maybe experiment with try_to_free_pages() + * will help .... + */ free_resources(dev); return -EBUSY; /* no buffer :-( */ } @@ -1405,7 +1445,7 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it) devpriv->hwdmasize[0] = PAGE_SIZE * (1 << pages); devpriv->dmabuf[1] = __get_dma_pages(GFP_KERNEL, pages); if (!devpriv->dmabuf[1]) { - printk(", unable to allocate DMA buffer, FAIL!\n"); + printk(KERN_ERR ", unable to allocate DMA buffer, FAIL!\n"); free_resources(dev); return -EBUSY; } @@ -1468,11 +1508,11 @@ no_dma: s->maxdata = this_board->ai_maxdata; s->len_chanlist = MAX_CHANLIST_LEN; s->range_table = this_board->rangelist_ai; - if (this_board->board_type == boardACL8216) { + if (this_board->board_type == boardACL8216) s->insn_read = acl8216_ai_insn_read; - } else { + else s->insn_read = pcl812_ai_insn_read; - } + devpriv->use_MPC = this_board->haveMPC508; s->cancel = pcl812_ai_cancel; if (dev->irq) { @@ -1511,8 +1551,8 @@ no_dma: s->range_table = &range_bipolar10; break; printk - (", incorrect range number %d, changing to 0 (+/-10V)", - it->options[4]); + (", incorrect range number %d, changing " + "to 0 (+/-10V)", it->options[4]); break; } break; @@ -1541,8 +1581,8 @@ no_dma: s->range_table = &range_iso813_1_ai; break; printk - (", incorrect range number %d, changing to 0 ", - it->options[1]); + (", incorrect range number %d, " + "changing to 0 ", it->options[1]); break; } break; @@ -1566,8 +1606,8 @@ no_dma: s->range_table = &range_acl8113_1_ai; break; printk - (", incorrect range number %d, changing to 0 ", - it->options[1]); + (", incorrect range number %d, " + "changing to 0 ", it->options[1]); break; } break; @@ -1638,7 +1678,8 @@ no_dma: case boardACL8112: devpriv->max_812_ai_mode0_rangewait = 1; if (it->options[3] > 0) - devpriv->use_ext_trg = 1; /* we use external trigger */ + /* we use external trigger */ + devpriv->use_ext_trg = 1; case boardA821: devpriv->max_812_ai_mode0_rangewait = 1; devpriv->mode_reg_int = (irq << 4) & 0xf0; @@ -1647,11 +1688,12 @@ no_dma: case boardPCL813: case boardISO813: case boardACL8113: - devpriv->max_812_ai_mode0_rangewait = 5; /* maybe there must by greatest timeout */ + /* maybe there must by greatest timeout */ + devpriv->max_812_ai_mode0_rangewait = 5; break; } - printk("\n"); + printk(KERN_INFO "\n"); devpriv->valid = 1; pcl812_reset(dev); @@ -1666,7 +1708,7 @@ static int pcl812_detach(struct comedi_device *dev) { #ifdef PCL812_EXTDEBUG - printk("comedi%d: pcl812: remove\n", dev->minor); + printk(KERN_DEBUG "comedi%d: pcl812: remove\n", dev->minor); #endif free_resources(dev); return 0; From 15f0beb16937acef2bbfd1d7541612c2e7b0d37c Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 20 May 2010 10:39:38 +0200 Subject: [PATCH 038/523] Staging: hv: Storage class should be before const qualifier The C99 specification states in section 6.11.5: The placement of a storage-class specifier other than at the beginning of the declaration specifiers in a declaration is an obsolescent feature. Signed-off-by: Tobias Klauser Cc: Haiyang Zhang Cc: Hank Janssen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hv/vmbus_drv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index c21731a12ca7..4f6f64031f8f 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -1025,7 +1025,7 @@ static void __exit vmbus_exit(void) * installed and/or configured. We don't do anything else with the table, but * it needs to be present. */ -const static struct pci_device_id microsoft_hv_pci_table[] = { +static const struct pci_device_id microsoft_hv_pci_table[] = { { PCI_DEVICE(0x1414, 0x5353) }, /* VGA compatible controller */ { 0 } }; From cb016cc48a011cbe23c4c742a577108853b66e3f Mon Sep 17 00:00:00 2001 From: Adam Latham Date: Wed, 19 May 2010 06:55:26 +0100 Subject: [PATCH 039/523] Staging: winbond: Fix C99 Comment issues in mac_structures.h This patch fixes the use of //C99 comments in the mac_structures.h found by the checkpatch.pl tool Signed-off-by: Adam Latham Acked-by: Pekka Enberg Signed-off-by: Greg Kroah-Hartman --- drivers/staging/winbond/mac_structures.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/winbond/mac_structures.h b/drivers/staging/winbond/mac_structures.h index 7441015cb187..a390adff247b 100644 --- a/drivers/staging/winbond/mac_structures.h +++ b/drivers/staging/winbond/mac_structures.h @@ -98,28 +98,28 @@ #define ELEMENT_ID_CF_PARAMETER_SET 4 #define ELEMENT_ID_TIM 5 #define ELEMENT_ID_IBSS_PARAMETER_SET 6 -// 7~15 reserverd +/* 7~15 reserverd */ #define ELEMENT_ID_CHALLENGE_TEXT 16 -// 17~31 reserved for challenge text extension -// 32~255 reserved -//-- 11G -- +/* 17~31 reserved for challenge text extension */ +/* 32~255 reserved */ +/*-- 11G -- */ #define ELEMENT_ID_ERP_INFORMATION 42 #define ELEMENT_ID_EXTENDED_SUPPORTED_RATES 50 -//-- WPA -- +/* -- WPA -- */ #define ELEMENT_ID_RSN_WPA 221 #ifdef _WPA2_ #define ELEMENT_ID_RSN_WPA2 48 -#endif //endif WPA2 +#endif /* endif WPA2 */ #define WLAN_MAX_PAIRWISE_CIPHER_SUITE_COUNT ((u16) 6) #define WLAN_MAX_AUTH_KEY_MGT_SUITE_LIST_COUNT ((u16) 2) -//=================================================================== -// Reason Code (Table 18): indicate the reason of DisAssoc, DeAuthen -// length of ReasonCode is 2 Octs. -//=================================================================== +/* =================================================================== +* Reason Code (Table 18): indicate the reason of DisAssoc, DeAuthen +* length of ReasonCode is 2 Octs. +* =================================================================== */ #define REASON_REASERED 0 #define REASON_UNSPECIDIED 1 #define REASON_PREAUTH_INVALID 2 @@ -433,7 +433,7 @@ struct suite_selector }; }; -//-- WPA -- +/* -- WPA -- */ struct RSN_Information_Element { u8 Element_ID; From 07bbf350483e75823ff9c21d213d63a8bbf751ca Mon Sep 17 00:00:00 2001 From: Adam Latham Date: Fri, 21 May 2010 06:22:09 +0100 Subject: [PATCH 040/523] Staging: winbond: Fix for brace style, length and whitespace in mac_structures.h This patch fixes line length, brace style and whitespace issues in the mac_structures.h file found by the checkpatch.pl tool Signed-off-by: Adam Latham Signed-off-by: Greg Kroah-Hartman --- drivers/staging/winbond/mac_structures.h | 122 +++++++++++------------ 1 file changed, 59 insertions(+), 63 deletions(-) diff --git a/drivers/staging/winbond/mac_structures.h b/drivers/staging/winbond/mac_structures.h index a390adff247b..415256f69c32 100644 --- a/drivers/staging/winbond/mac_structures.h +++ b/drivers/staging/winbond/mac_structures.h @@ -41,8 +41,10 @@ #define DOT_11_MAC_HEADER_SIZE 24 #define DOT_11_SNAP_SIZE 6 #define DOT_11_DURATION_OFFSET 2 -#define DOT_11_SEQUENCE_OFFSET 22 /* Sequence control offset */ -#define DOT_11_TYPE_OFFSET 30 /* The start offset of 802.11 Frame// */ +/* Sequence control offset */ +#define DOT_11_SEQUENCE_OFFSET 22 +/* The start offset of 802.11 Frame// */ +#define DOT_11_TYPE_OFFSET 30 #define DOT_11_DATA_OFFSET 24 #define DOT_11_DA_OFFSET 4 #define DOT_3_TYPE_ARP 0x80F3 @@ -385,9 +387,11 @@ struct Extended_Supported_Rates_Element { #ifdef _WPA2_ #define VERSION_WPA2 1 #endif /* end def _WPA2_ */ -#define OUI_WPA 0x00F25000 /* WPA2.0 OUI=00:50:F2, the MSB is reserved for suite type */ +/* WPA2.0 OUI=00:50:F2, the MSB is reserved for suite type */ +#define OUI_WPA 0x00F25000 #ifdef _WPA2_ -#define OUI_WPA2 0x00AC0F00 /* for wpa2 change to 0x00ACOF04 by Ws 26/04/04 */ +/* for wpa2 change to 0x00ACOF04 by Ws 26/04/04 */ +#define OUI_WPA2 0x00AC0F00 #endif /* end def _WPA2_ */ #define OUI_WPA_ADDITIONAL 0x01 @@ -400,8 +404,8 @@ struct Extended_Supported_Rates_Element { #define WPA_OUI_BIG ((u32) 0x01F25000)/* added by ws 09/23/04 */ #define WPA_OUI_LITTLE ((u32) 0x01F25001)/* added by ws 09/23/04 */ - -#define WPA_WPS_OUI cpu_to_le32(0x04F25000) /* 20061108 For WPS. It's little endian. Big endian is 0x0050F204 */ +/* 20061108 For WPS. It's little endian. Big endian is 0x0050F204 */ +#define WPA_WPS_OUI cpu_to_le32(0x04F25000) /* -----WPA2----- */ #ifdef _WPA2_ @@ -420,75 +424,65 @@ struct Extended_Supported_Rates_Element { #define OUI_CIPHER_CCMP 0x04 #define OUI_CIPHER_WEP_104 0x05 -struct suite_selector -{ - union - { +struct suite_selector{ + union{ u8 Value[4]; - struct _SUIT_ - { + struct _SUIT_ { u8 OUI[3]; u8 Type; - }SuitSelector; + } SuitSelector; }; }; /* -- WPA -- */ -struct RSN_Information_Element -{ +struct RSN_Information_Element{ u8 Element_ID; u8 Length; - struct suite_selector OuiWPAAdditional; /* WPA version 2.0 additional field, and should be 00:50:F2:01 */ + /* WPA version 2.0 additional field, and should be 00:50:F2:01 */ + struct suite_selector OuiWPAAdditional; u16 Version; struct suite_selector GroupKeySuite; u16 PairwiseKeySuiteCount; struct suite_selector PairwiseKeySuite[1]; -}__attribute__ ((packed)); -struct RSN_Auth_Sub_Information_Element -{ +} __attribute__ ((packed)); +struct RSN_Auth_Sub_Information_Element { u16 AuthKeyMngtSuiteCount; struct suite_selector AuthKeyMngtSuite[1]; -}__attribute__ ((packed)); +} __attribute__ ((packed)); /* -- WPA2 -- */ -struct RSN_Capability_Element -{ - union - { +struct RSN_Capability_Element { + union { u16 __attribute__ ((packed)) wValue; #ifdef _BIG_ENDIAN_ /* 20060927 add by anson's endian */ - struct _RSN_Capability - { - u16 __attribute__ ((packed)) Reserved2 : 8; /* 20051201 */ - u16 __attribute__ ((packed)) Reserved1 : 2; - u16 __attribute__ ((packed)) GTK_Replay_Counter : 2; - u16 __attribute__ ((packed)) PTK_Replay_Counter : 2; - u16 __attribute__ ((packed)) No_Pairwise : 1; - u16 __attribute__ ((packed)) Pre_Auth : 1; - }__attribute__ ((packed)) RSN_Capability; + struct _RSN_Capability { + u16 __attribute__ ((packed)) Reserved2:8; /* 20051201 */ + u16 __attribute__ ((packed)) Reserved1:2; + u16 __attribute__ ((packed)) GTK_Replay_Counter:2; + u16 __attribute__ ((packed)) PTK_Replay_Counter:2; + u16 __attribute__ ((packed)) No_Pairwise:1; + u16 __attribute__ ((packed)) Pre_Auth:1; + } __attribute__ ((packed)) RSN_Capability; #else - struct _RSN_Capability - { - u16 __attribute__ ((packed)) Pre_Auth : 1; - u16 __attribute__ ((packed)) No_Pairwise : 1; - u16 __attribute__ ((packed)) PTK_Replay_Counter : 2; - u16 __attribute__ ((packed)) GTK_Replay_Counter : 2; - u16 __attribute__ ((packed)) Reserved1 : 2; - u16 __attribute__ ((packed)) Reserved2 : 8; /* 20051201 */ - }__attribute__ ((packed)) RSN_Capability; + struct _RSN_Capability { + u16 __attribute__ ((packed)) Pre_Auth:1; + u16 __attribute__ ((packed)) No_Pairwise:1; + u16 __attribute__ ((packed)) PTK_Replay_Counter:2; + u16 __attribute__ ((packed)) GTK_Replay_Counter:2; + u16 __attribute__ ((packed)) Reserved1:2; + u16 __attribute__ ((packed)) Reserved2:8; /* 20051201 */ + } __attribute__ ((packed)) RSN_Capability; #endif - }__attribute__ ((packed)) ; -}__attribute__ ((packed)) ; + } __attribute__ ((packed)) ; +} __attribute__ ((packed)) ; #ifdef _WPA2_ -struct pmkid -{ +struct pmkid { u8 pValue[16]; }; -struct WPA2_RSN_Information_Element -{ +struct WPA2_RSN_Information_Element { u8 Element_ID; u8 Length; u16 Version; @@ -496,29 +490,28 @@ struct WPA2_RSN_Information_Element u16 PairwiseKeySuiteCount; struct suite_selector PairwiseKeySuite[1]; -}__attribute__ ((packed)); +} __attribute__ ((packed)); -struct WPA2_RSN_Auth_Sub_Information_Element -{ +struct WPA2_RSN_Auth_Sub_Information_Element { u16 AuthKeyMngtSuiteCount; struct suite_selector AuthKeyMngtSuite[1]; -}__attribute__ ((packed)); +} __attribute__ ((packed)); -struct PMKID_Information_Element -{ +struct PMKID_Information_Element { u16 PMKID_Count; struct pmkid pmkid[16]; -}__attribute__ ((packed)); +} __attribute__ ((packed)); #endif /* enddef _WPA2_ */ /*============================================================ // MAC Frame structure (different type) and subfield structure //============================================================*/ -struct MAC_frame_control -{ - u8 mac_frame_info; /* a combination of the [Protocol Version, Control Type, Control Subtype]*/ - #ifdef _BIG_ENDIAN_ /* 20060927 add by anson's endian */ +struct MAC_frame_control { +/* a combination of the [Protocol Version, Control Type, Control Subtype]*/ + u8 mac_frame_info; +/* 20060927 add by anson's endian */ + #ifdef _BIG_ENDIAN_ u8 order:1; u8 WEP:1; u8 more_data:1; @@ -540,7 +533,8 @@ struct MAC_frame_control } __attribute__ ((packed)); struct Management_Frame { - struct MAC_frame_control frame_control; /* 2B, ToDS,FromDS,MoreFrag,MoreData,Order=0 */ +/* 2B, ToDS,FromDS,MoreFrag,MoreData,Order=0 */ + struct MAC_frame_control frame_control; u16 duration; u8 DA[MAC_ADDR_LENGTH]; /* Addr1 */ u8 SA[MAC_ADDR_LENGTH]; /* Addr2 */ @@ -552,7 +546,8 @@ struct Management_Frame { /* SW-MAC don't Tx/Rx Control-Frame, HW-MAC do it. */ struct Control_Frame { - struct MAC_frame_control frame_control; /* ToDS,FromDS,MoreFrag,Retry,MoreData,WEP,Order=0 */ +/* ToDS,FromDS,MoreFrag,Retry,MoreData,WEP,Order=0 */ + struct MAC_frame_control frame_control; u16 duration; u8 RA[MAC_ADDR_LENGTH]; u8 TA[MAC_ADDR_LENGTH]; @@ -627,8 +622,9 @@ struct Authentication_Frame_Body { u16 algorithmNumber; u16 sequenceNumber; u16 statusCode; - /* NB: don't include ChallengeText in this structure - // struct Challenge_Text_Element sChallengeTextElement; // wkchen added */ + /* NB: don't include ChallengeText in this structure + // struct Challenge_Text_Element sChallengeTextElement; + // wkchen added */ } __attribute__ ((packed)); From 3a4d1b9096cce99f3dd8870cc87980dcabf6787e Mon Sep 17 00:00:00 2001 From: Timofey Trofimov Date: Tue, 25 May 2010 18:19:54 +0400 Subject: [PATCH 041/523] Staging: winbond: fix some checkpatch.pl issues in phy_calibration.c This is a patch to the phy_calibration.c that fixes up almost all warnings and errors (except 80 characters limit and lack of tabs errors) found by the checkpatch.pl tool Signed-off-by: Timofey Trofimov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/winbond/phy_calibration.c | 817 +++++++++------------- 1 file changed, 336 insertions(+), 481 deletions(-) diff --git a/drivers/staging/winbond/phy_calibration.c b/drivers/staging/winbond/phy_calibration.c index 78935865df19..5eefea31948c 100644 --- a/drivers/staging/winbond/phy_calibration.c +++ b/drivers/staging/winbond/phy_calibration.c @@ -19,23 +19,25 @@ /****************** LOCAL CONSTANT AND MACRO SECTION ************************/ #define LOOP_TIMES 20 -#define US 1000//MICROSECOND +#define US 1000/* MICROSECOND*/ #define AG_CONST 0.6072529350 #define FIXED(X) ((s32)((X) * 32768.0)) #define DEG2RAD(X) 0.017453 * (X) -static const s32 Angles[] = -{ - FIXED(DEG2RAD(45.0)), FIXED(DEG2RAD(26.565)), FIXED(DEG2RAD(14.0362)), - FIXED(DEG2RAD(7.12502)), FIXED(DEG2RAD(3.57633)), FIXED(DEG2RAD(1.78991)), - FIXED(DEG2RAD(0.895174)),FIXED(DEG2RAD(0.447614)),FIXED(DEG2RAD(0.223811)), - FIXED(DEG2RAD(0.111906)),FIXED(DEG2RAD(0.055953)),FIXED(DEG2RAD(0.027977)) +static const s32 Angles[] = { + FIXED(DEG2RAD(45.0)), FIXED(DEG2RAD(26.565)), FIXED(DEG2RAD(14.0362)), + FIXED(DEG2RAD(7.12502)), FIXED(DEG2RAD(3.57633)), FIXED(DEG2RAD(1.78991)), + FIXED(DEG2RAD(0.895174)), FIXED(DEG2RAD(0.447614)), FIXED(DEG2RAD(0.223811)), + FIXED(DEG2RAD(0.111906)), FIXED(DEG2RAD(0.055953)), FIXED(DEG2RAD(0.027977)) }; -/****************** LOCAL FUNCTION DECLARATION SECTION **********************/ -//void _phy_rf_write_delay(struct hw_data *phw_data); -//void phy_init_rf(struct hw_data *phw_data); +/****************** LOCAL FUNCTION DECLARATION SECTION ********************** + +/* + * void _phy_rf_write_delay(struct hw_data *phw_data); + * void phy_init_rf(struct hw_data *phw_data); + */ /****************** FUNCTION DEFINITION SECTION *****************************/ @@ -46,9 +48,7 @@ s32 _s13_to_s32(u32 data) val = (data & 0x0FFF); if ((data & BIT(12)) != 0) - { val |= 0xFFFFF000; - } return ((s32) val); } @@ -58,13 +58,9 @@ u32 _s32_to_s13(s32 data) u32 val; if (data > 4095) - { data = 4095; - } else if (data < -4096) - { data = -4096; - } val = data & 0x1FFF; @@ -79,9 +75,7 @@ s32 _s4_to_s32(u32 data) val = (data & 0x0007); if ((data & BIT(3)) != 0) - { val |= 0xFFFFFFF8; - } return val; } @@ -91,13 +85,9 @@ u32 _s32_to_s4(s32 data) u32 val; if (data > 7) - { data = 7; - } else if (data < -8) - { data = -8; - } val = data & 0x000F; @@ -112,9 +102,7 @@ s32 _s5_to_s32(u32 data) val = (data & 0x000F); if ((data & BIT(4)) != 0) - { val |= 0xFFFFFFF0; - } return val; } @@ -124,13 +112,9 @@ u32 _s32_to_s5(s32 data) u32 val; if (data > 15) - { data = 15; - } else if (data < -16) - { data = -16; - } val = data & 0x001F; @@ -145,9 +129,7 @@ s32 _s6_to_s32(u32 data) val = (data & 0x001F); if ((data & BIT(5)) != 0) - { val |= 0xFFFFFFE0; - } return val; } @@ -157,11 +139,8 @@ u32 _s32_to_s6(s32 data) u32 val; if (data > 31) - { data = 31; - } else if (data < -32) - { data = -32; } @@ -178,9 +157,7 @@ s32 _s9_to_s32(u32 data) val = data & 0x00FF; if ((data & BIT(8)) != 0) - { val |= 0xFFFFFF00; - } return val; } @@ -190,13 +167,9 @@ u32 _s32_to_s9(s32 data) u32 val; if (data > 255) - { data = 255; - } else if (data < -256) - { data = -256; - } val = data & 0x01FF; @@ -207,21 +180,19 @@ u32 _s32_to_s9(s32 data) s32 _floor(s32 n) { if (n > 0) - { - n += 5; - } + n += 5; else - { n -= 5; - } return (n/10); } /****************************************************************************/ -// The following code is sqare-root function. -// sqsum is the input and the output is sq_rt; -// The maximum of sqsum = 2^27 -1; +/* + * The following code is sqare-root function. + * sqsum is the input and the output is sq_rt; + * The maximum of sqsum = 2^27 -1; + */ u32 _sqrt(u32 sqsum) { u32 sq_rt; @@ -232,18 +203,17 @@ u32 _sqrt(u32 sqsum) int step; g4 = sqsum / 100000000; - g3 = (sqsum - g4*100000000) /1000000; - g2 = (sqsum - g4*100000000 - g3*1000000) /10000; - g1 = (sqsum - g4*100000000 - g3*1000000 - g2*10000) /100; + g3 = (sqsum - g4*100000000) / 1000000; + g2 = (sqsum - g4*100000000 - g3*1000000) / 10000; + g1 = (sqsum - g4*100000000 - g3*1000000 - g2*10000) / 100; g0 = (sqsum - g4*100000000 - g3*1000000 - g2*10000 - g1*100); next = g4; step = 0; seed = 0; - while (((seed+1)*(step+1)) <= next) - { - step++; - seed++; + while (((seed+1)*(step+1)) <= next) { + step++; + seed++; } sq_rt = seed * 10000; @@ -251,20 +221,18 @@ u32 _sqrt(u32 sqsum) step = 0; seed = 2 * seed * 10; - while (((seed+1)*(step+1)) <= next) - { + while (((seed+1)*(step+1)) <= next) { step++; - seed++; + seed++; } sq_rt = sq_rt + step * 1000; next = (next - seed * step) * 100 + g2; seed = (seed + step) * 10; step = 0; - while (((seed+1)*(step+1)) <= next) - { + while (((seed+1)*(step+1)) <= next) { step++; - seed++; + seed++; } sq_rt = sq_rt + step * 100; @@ -272,21 +240,19 @@ u32 _sqrt(u32 sqsum) seed = (seed + step) * 10; step = 0; - while (((seed+1)*(step+1)) <= next) - { + while (((seed+1)*(step+1)) <= next) { step++; - seed++; + seed++; } sq_rt = sq_rt + step * 10; - next = (next - seed* step) * 100 + g0; + next = (next - seed * step) * 100 + g0; seed = (seed + step) * 10; step = 0; - while (((seed+1)*(step+1)) <= next) - { + while (((seed+1)*(step+1)) <= next) { step++; - seed++; + seed++; } sq_rt = sq_rt + step; @@ -300,38 +266,31 @@ void _sin_cos(s32 angle, s32 *sin, s32 *cos) s32 X, Y, TargetAngle, CurrAngle; unsigned Step; - X=FIXED(AG_CONST); // AG_CONST * cos(0) - Y=0; // AG_CONST * sin(0) - TargetAngle=abs(angle); - CurrAngle=0; + X = FIXED(AG_CONST); /* AG_CONST * cos(0) */ + Y = 0; /* AG_CONST * sin(0) */ + TargetAngle = abs(angle); + CurrAngle = 0; - for (Step=0; Step < 12; Step++) - { + for (Step = 0; Step < 12; Step++) { s32 NewX; - if(TargetAngle > CurrAngle) - { - NewX=X - (Y >> Step); - Y=(X >> Step) + Y; - X=NewX; + if (TargetAngle > CurrAngle) { + NewX = X - (Y >> Step); + Y = (X >> Step) + Y; + X = NewX; CurrAngle += Angles[Step]; - } - else - { - NewX=X + (Y >> Step); - Y=-(X >> Step) + Y; - X=NewX; + } else { + NewX = X + (Y >> Step); + Y = -(X >> Step) + Y; + X = NewX; CurrAngle -= Angles[Step]; } } - if (angle > 0) - { + if (angle > 0) { *cos = X; *sin = Y; - } - else - { + } else { *cos = X; *sin = -Y; } @@ -343,7 +302,7 @@ static unsigned char hal_get_dxx_reg(struct hw_data *pHwData, u16 number, u32 * number += 0x1000; return Wb35Reg_ReadSync(pHwData, number, pValue); } -#define hw_get_dxx_reg( _A, _B, _C ) hal_get_dxx_reg( _A, _B, (u32 *)_C ) +#define hw_get_dxx_reg(_A, _B, _C) hal_get_dxx_reg(_A, _B, (u32 *)_C) static unsigned char hal_set_dxx_reg(struct hw_data *pHwData, u16 number, u32 value) { @@ -354,7 +313,7 @@ static unsigned char hal_set_dxx_reg(struct hw_data *pHwData, u16 number, u32 va ret = Wb35Reg_WriteSync(pHwData, number, value); return ret; } -#define hw_set_dxx_reg( _A, _B, _C ) hal_set_dxx_reg( _A, _B, (u32)_C ) +#define hw_set_dxx_reg(_A, _B, _C) hal_set_dxx_reg(_A, _B, (u32)_C) void _reset_rx_cal(struct hw_data *phw_data) @@ -363,25 +322,20 @@ void _reset_rx_cal(struct hw_data *phw_data) hw_get_dxx_reg(phw_data, 0x54, &val); - if (phw_data->revision == 0x2002) // 1st-cut - { + if (phw_data->revision == 0x2002) /* 1st-cut */ val &= 0xFFFF0000; - } - else // 2nd-cut - { + else /* 2nd-cut */ val &= 0x000003FF; - } hw_set_dxx_reg(phw_data, 0x54, val); } -// ************for winbond calibration********* -// +/**************for winbond calibration*********/ -// -// -// ********************************************* + + +/**********************************************/ void _rxadc_dc_offset_cancellation_winbond(struct hw_data *phw_data, u32 frequency) { u32 reg_agc_ctrl3; @@ -392,35 +346,31 @@ void _rxadc_dc_offset_cancellation_winbond(struct hw_data *phw_data, u32 frequen PHY_DEBUG(("[CAL] -> [1]_rxadc_dc_offset_cancellation()\n")); phy_init_rf(phw_data); - // set calibration channel - if( (RF_WB_242 == phw_data->phy_type) || - (RF_WB_242_1 == phw_data->phy_type) ) // 20060619.5 Add - { - if ((frequency >= 2412) && (frequency <= 2484)) - { - // w89rf242 change frequency to 2390Mhz + /* set calibration channel */ + if ((RF_WB_242 == phw_data->phy_type) || + (RF_WB_242_1 == phw_data->phy_type)) /* 20060619.5 Add */{ + if ((frequency >= 2412) && (frequency <= 2484)) { + /* w89rf242 change frequency to 2390Mhz */ PHY_DEBUG(("[CAL] W89RF242/11G/Channel=2390Mhz\n")); phy_set_rf_data(phw_data, 3, (3<<24)|0x025586); } - } - else - { + } else { } - // reset cancel_dc_i[9:5] and cancel_dc_q[4:0] in register DC_Cancel + /* reset cancel_dc_i[9:5] and cancel_dc_q[4:0] in register DC_Cancel */ hw_get_dxx_reg(phw_data, 0x5C, &val); val &= ~(0x03FF); hw_set_dxx_reg(phw_data, 0x5C, val); - // reset the TX and RX IQ calibration data + /* reset the TX and RX IQ calibration data */ hw_set_dxx_reg(phw_data, 0x3C, 0); hw_set_dxx_reg(phw_data, 0x54, 0); - hw_set_dxx_reg(phw_data, 0x58, 0x30303030); // IQ_Alpha Changed + hw_set_dxx_reg(phw_data, 0x58, 0x30303030); /* IQ_Alpha Changed */ - // a. Disable AGC + /* a. Disable AGC */ hw_get_dxx_reg(phw_data, REG_AGC_CTRL3, ®_agc_ctrl3); reg_agc_ctrl3 &= ~BIT(2); reg_agc_ctrl3 |= (MASK_LNA_FIX_GAIN|MASK_AGC_FIX); @@ -430,7 +380,7 @@ void _rxadc_dc_offset_cancellation_winbond(struct hw_data *phw_data, u32 frequen val |= MASK_AGC_FIX_GAIN; hw_set_dxx_reg(phw_data, REG_AGC_CTRL5, val); - // b. Turn off BB RX + /* b. Turn off BB RX */ hw_get_dxx_reg(phw_data, REG_A_ACQ_CTRL, ®_a_acq_ctrl); reg_a_acq_ctrl |= MASK_AMER_OFF_REG; hw_set_dxx_reg(phw_data, REG_A_ACQ_CTRL, reg_a_acq_ctrl); @@ -439,9 +389,9 @@ void _rxadc_dc_offset_cancellation_winbond(struct hw_data *phw_data, u32 frequen reg_b_acq_ctrl |= MASK_BMER_OFF_REG; hw_set_dxx_reg(phw_data, REG_B_ACQ_CTRL, reg_b_acq_ctrl); - // c. Make sure MAC is in receiving mode - // d. Turn ON ADC calibration - // - ADC calibrator is triggered by this signal rising from 0 to 1 + /* c. Make sure MAC is in receiving mode + * d. Turn ON ADC calibration + * - ADC calibrator is triggered by this signal rising from 0 to 1 */ hw_get_dxx_reg(phw_data, REG_MODE_CTRL, &val); val &= ~MASK_ADC_DC_CAL_STR; hw_set_dxx_reg(phw_data, REG_MODE_CTRL, val); @@ -449,7 +399,7 @@ void _rxadc_dc_offset_cancellation_winbond(struct hw_data *phw_data, u32 frequen val |= MASK_ADC_DC_CAL_STR; hw_set_dxx_reg(phw_data, REG_MODE_CTRL, val); - // e. The result are shown in "adc_dc_cal_i[8:0] and adc_dc_cal_q[8:0]" + /* e. The result are shown in "adc_dc_cal_i[8:0] and adc_dc_cal_q[8:0]" */ #ifdef _DEBUG hw_get_dxx_reg(phw_data, REG_OFFSET_READ, &val); PHY_DEBUG(("[CAL] REG_OFFSET_READ = 0x%08X\n", val)); @@ -464,23 +414,23 @@ void _rxadc_dc_offset_cancellation_winbond(struct hw_data *phw_data, u32 frequen val &= ~MASK_ADC_DC_CAL_STR; hw_set_dxx_reg(phw_data, REG_MODE_CTRL, val); - // f. Turn on BB RX - //hw_get_dxx_reg(phw_data, REG_A_ACQ_CTRL, ®_a_acq_ctrl); + /* f. Turn on BB RX */ + /* hw_get_dxx_reg(phw_data, REG_A_ACQ_CTRL, ®_a_acq_ctrl); */ reg_a_acq_ctrl &= ~MASK_AMER_OFF_REG; hw_set_dxx_reg(phw_data, REG_A_ACQ_CTRL, reg_a_acq_ctrl); - //hw_get_dxx_reg(phw_data, REG_B_ACQ_CTRL, ®_b_acq_ctrl); + /* hw_get_dxx_reg(phw_data, REG_B_ACQ_CTRL, ®_b_acq_ctrl); */ reg_b_acq_ctrl &= ~MASK_BMER_OFF_REG; hw_set_dxx_reg(phw_data, REG_B_ACQ_CTRL, reg_b_acq_ctrl); - // g. Enable AGC - //hw_get_dxx_reg(phw_data, REG_AGC_CTRL3, &val); + /* g. Enable AGC */ + /* hw_get_dxx_reg(phw_data, REG_AGC_CTRL3, &val); */ reg_agc_ctrl3 |= BIT(2); reg_agc_ctrl3 &= ~(MASK_LNA_FIX_GAIN|MASK_AGC_FIX); hw_set_dxx_reg(phw_data, REG_AGC_CTRL3, reg_agc_ctrl3); } -//////////////////////////////////////////////////////// +/****************************************************************/ void _txidac_dc_offset_cancellation_winbond(struct hw_data *phw_data) { u32 reg_agc_ctrl3; @@ -497,22 +447,22 @@ void _txidac_dc_offset_cancellation_winbond(struct hw_data *phw_data) PHY_DEBUG(("[CAL] -> [2]_txidac_dc_offset_cancellation()\n")); - // a. Set to "TX calibration mode" + /* a. Set to "TX calibration mode" */ - //0x01 0xEE3FC2 ; 3B8FF ; Calibration (6a). enable TX IQ calibration loop circuits + /* 0x01 0xEE3FC2 ; 3B8FF ; Calibration (6a). enable TX IQ calibration loop circuits */ phy_set_rf_data(phw_data, 1, (1<<24)|0xEE3FC2); - //0x0B 0x1905D6 ; 06417 ; Calibration (6b). enable TX I/Q cal loop squaring circuit + /* 0x0B 0x1905D6 ; 06417 ; Calibration (6b). enable TX I/Q cal loop squaring circuit */ phy_set_rf_data(phw_data, 11, (11<<24)|0x1901D6); - //0x05 0x24C60A ; 09318 ; Calibration (6c). setting TX-VGA gain: TXGCH=2 & GPK=110 --> to be optimized + /* 0x05 0x24C60A ; 09318 ; Calibration (6c). setting TX-VGA gain: TXGCH=2 & GPK=110 --> to be optimized */ phy_set_rf_data(phw_data, 5, (5<<24)|0x24C48A); - //0x06 0x06880C ; 01A20 ; Calibration (6d). RXGCH=00; RXGCL=100 000 (RXVGA=32) --> to be optimized + /* 0x06 0x06880C ; 01A20 ; Calibration (6d). RXGCH=00; RXGCL=100 000 (RXVGA=32) --> to be optimized */ phy_set_rf_data(phw_data, 6, (6<<24)|0x06890C); - //0x00 0xFDF1C0 ; 3F7C7 ; Calibration (6e). turn on IQ imbalance/Test mode + /* 0x00 0xFDF1C0 ; 3F7C7 ; Calibration (6e). turn on IQ imbalance/Test mode */ phy_set_rf_data(phw_data, 0, (0<<24)|0xFDF1C0); - hw_set_dxx_reg(phw_data, 0x58, 0x30303030); // IQ_Alpha Changed + hw_set_dxx_reg(phw_data, 0x58, 0x30303030); /* IQ_Alpha Changed */ - // a. Disable AGC + /* a. Disable AGC */ hw_get_dxx_reg(phw_data, REG_AGC_CTRL3, ®_agc_ctrl3); reg_agc_ctrl3 &= ~BIT(2); reg_agc_ctrl3 |= (MASK_LNA_FIX_GAIN|MASK_AGC_FIX); @@ -522,19 +472,19 @@ void _txidac_dc_offset_cancellation_winbond(struct hw_data *phw_data) val |= MASK_AGC_FIX_GAIN; hw_set_dxx_reg(phw_data, REG_AGC_CTRL5, val); - // b. set iqcal_mode[1:0] to 0x2 and set iqcal_tone[3:2] to 0 + /* b. set iqcal_mode[1:0] to 0x2 and set iqcal_tone[3:2] to 0 */ hw_get_dxx_reg(phw_data, REG_MODE_CTRL, ®_mode_ctrl); PHY_DEBUG(("[CAL] MODE_CTRL (read) = 0x%08X\n", reg_mode_ctrl)); reg_mode_ctrl &= ~(MASK_IQCAL_TONE_SEL|MASK_IQCAL_MODE); - // mode=2, tone=0 - //reg_mode_ctrl |= (MASK_CALIB_START|2); + /* mode=2, tone=0 */ + /* reg_mode_ctrl |= (MASK_CALIB_START|2); */ - // mode=2, tone=1 - //reg_mode_ctrl |= (MASK_CALIB_START|2|(1<<2)); + /* mode=2, tone=1 */ + /* reg_mode_ctrl |= (MASK_CALIB_START|2|(1<<2)); */ - // mode=2, tone=2 + /* mode=2, tone=2 */ reg_mode_ctrl |= (MASK_CALIB_START|2|(2<<2)); hw_set_dxx_reg(phw_data, REG_MODE_CTRL, reg_mode_ctrl); PHY_DEBUG(("[CAL] MODE_CTRL (write) = 0x%08X\n", reg_mode_ctrl)); @@ -542,12 +492,10 @@ void _txidac_dc_offset_cancellation_winbond(struct hw_data *phw_data) hw_get_dxx_reg(phw_data, 0x5C, ®_dc_cancel); PHY_DEBUG(("[CAL] DC_CANCEL (read) = 0x%08X\n", reg_dc_cancel)); - for (loop = 0; loop < LOOP_TIMES; loop++) - { + for (loop = 0; loop < LOOP_TIMES; loop++) { PHY_DEBUG(("[CAL] [%d.] ==================================\n", loop)); - // c. - // reset cancel_dc_i[9:5] and cancel_dc_q[4:0] in register DC_Cancel + /* c. reset cancel_dc_i[9:5] and cancel_dc_q[4:0] in register DC_Cancel */ reg_dc_cancel &= ~(0x03FF); PHY_DEBUG(("[CAL] DC_CANCEL (write) = 0x%08X\n", reg_dc_cancel)); hw_set_dxx_reg(phw_data, 0x5C, reg_dc_cancel); @@ -562,7 +510,7 @@ void _txidac_dc_offset_cancellation_winbond(struct hw_data *phw_data) PHY_DEBUG(("[CAL] mag_0=%d (iqcal_image_i=%d, iqcal_image_q=%d)\n", mag_0, iqcal_image_i, iqcal_image_q)); - // d. + /* d. */ reg_dc_cancel |= (1 << CANCEL_DC_I_SHIFT); PHY_DEBUG(("[CAL] DC_CANCEL (write) = 0x%08X\n", reg_dc_cancel)); hw_set_dxx_reg(phw_data, 0x5C, reg_dc_cancel); @@ -577,18 +525,12 @@ void _txidac_dc_offset_cancellation_winbond(struct hw_data *phw_data) PHY_DEBUG(("[CAL] mag_1=%d (iqcal_image_i=%d, iqcal_image_q=%d)\n", mag_1, iqcal_image_i, iqcal_image_q)); - // e. Calculate the correct DC offset cancellation value for I + /* e. Calculate the correct DC offset cancellation value for I */ if (mag_0 != mag_1) - { fix_cancel_dc_i = (mag_0*10000) / (mag_0*10000 - mag_1*10000); - } - else - { + else { if (mag_0 == mag_1) - { PHY_DEBUG(("[CAL] ***** mag_0 = mag_1 !!\n")); - } - fix_cancel_dc_i = 0; } @@ -596,12 +538,10 @@ void _txidac_dc_offset_cancellation_winbond(struct hw_data *phw_data) fix_cancel_dc_i, _s32_to_s5(fix_cancel_dc_i))); if ((abs(mag_1-mag_0)*6) > mag_0) - { break; - } } - if ( loop >= 19 ) + if (loop >= 19) fix_cancel_dc_i = 0; reg_dc_cancel &= ~(0x03FF); @@ -609,13 +549,13 @@ void _txidac_dc_offset_cancellation_winbond(struct hw_data *phw_data) hw_set_dxx_reg(phw_data, 0x5C, reg_dc_cancel); PHY_DEBUG(("[CAL] DC_CANCEL (write) = 0x%08X\n", reg_dc_cancel)); - // g. + /* g. */ reg_mode_ctrl &= ~MASK_CALIB_START; hw_set_dxx_reg(phw_data, REG_MODE_CTRL, reg_mode_ctrl); PHY_DEBUG(("[CAL] MODE_CTRL (write) = 0x%08X\n", reg_mode_ctrl)); } -/////////////////////////////////////////////////////// +/*****************************************************/ void _txqdac_dc_offset_cacellation_winbond(struct hw_data *phw_data) { u32 reg_agc_ctrl3; @@ -631,20 +571,20 @@ void _txqdac_dc_offset_cacellation_winbond(struct hw_data *phw_data) int loop; PHY_DEBUG(("[CAL] -> [3]_txqdac_dc_offset_cacellation()\n")); - //0x01 0xEE3FC2 ; 3B8FF ; Calibration (6a). enable TX IQ calibration loop circuits + /*0x01 0xEE3FC2 ; 3B8FF ; Calibration (6a). enable TX IQ calibration loop circuits */ phy_set_rf_data(phw_data, 1, (1<<24)|0xEE3FC2); - //0x0B 0x1905D6 ; 06417 ; Calibration (6b). enable TX I/Q cal loop squaring circuit + /* 0x0B 0x1905D6 ; 06417 ; Calibration (6b). enable TX I/Q cal loop squaring circuit */ phy_set_rf_data(phw_data, 11, (11<<24)|0x1901D6); - //0x05 0x24C60A ; 09318 ; Calibration (6c). setting TX-VGA gain: TXGCH=2 & GPK=110 --> to be optimized + /* 0x05 0x24C60A ; 09318 ; Calibration (6c). setting TX-VGA gain: TXGCH=2 & GPK=110 --> to be optimized */ phy_set_rf_data(phw_data, 5, (5<<24)|0x24C48A); - //0x06 0x06880C ; 01A20 ; Calibration (6d). RXGCH=00; RXGCL=100 000 (RXVGA=32) --> to be optimized + /* 0x06 0x06880C ; 01A20 ; Calibration (6d). RXGCH=00; RXGCL=100 000 (RXVGA=32) --> to be optimized */ phy_set_rf_data(phw_data, 6, (6<<24)|0x06890C); - //0x00 0xFDF1C0 ; 3F7C7 ; Calibration (6e). turn on IQ imbalance/Test mode + /* 0x00 0xFDF1C0 ; 3F7C7 ; Calibration (6e). turn on IQ imbalance/Test mode */ phy_set_rf_data(phw_data, 0, (0<<24)|0xFDF1C0); - hw_set_dxx_reg(phw_data, 0x58, 0x30303030); // IQ_Alpha Changed + hw_set_dxx_reg(phw_data, 0x58, 0x30303030); /* IQ_Alpha Changed */ - // a. Disable AGC + /* a. Disable AGC */ hw_get_dxx_reg(phw_data, REG_AGC_CTRL3, ®_agc_ctrl3); reg_agc_ctrl3 &= ~BIT(2); reg_agc_ctrl3 |= (MASK_LNA_FIX_GAIN|MASK_AGC_FIX); @@ -654,11 +594,11 @@ void _txqdac_dc_offset_cacellation_winbond(struct hw_data *phw_data) val |= MASK_AGC_FIX_GAIN; hw_set_dxx_reg(phw_data, REG_AGC_CTRL5, val); - // a. set iqcal_mode[1:0] to 0x3 and set iqcal_tone[3:2] to 0 + /* a. set iqcal_mode[1:0] to 0x3 and set iqcal_tone[3:2] to 0 */ hw_get_dxx_reg(phw_data, REG_MODE_CTRL, ®_mode_ctrl); PHY_DEBUG(("[CAL] MODE_CTRL (read) = 0x%08X\n", reg_mode_ctrl)); - //reg_mode_ctrl &= ~(MASK_IQCAL_TONE_SEL|MASK_IQCAL_MODE); + /* reg_mode_ctrl &= ~(MASK_IQCAL_TONE_SEL|MASK_IQCAL_MODE); */ reg_mode_ctrl &= ~(MASK_IQCAL_MODE); reg_mode_ctrl |= (MASK_CALIB_START|3); hw_set_dxx_reg(phw_data, REG_MODE_CTRL, reg_mode_ctrl); @@ -667,12 +607,10 @@ void _txqdac_dc_offset_cacellation_winbond(struct hw_data *phw_data) hw_get_dxx_reg(phw_data, 0x5C, ®_dc_cancel); PHY_DEBUG(("[CAL] DC_CANCEL (read) = 0x%08X\n", reg_dc_cancel)); - for (loop = 0; loop < LOOP_TIMES; loop++) - { + for (loop = 0; loop < LOOP_TIMES; loop++) { PHY_DEBUG(("[CAL] [%d.] ==================================\n", loop)); - // b. - // reset cancel_dc_q[4:0] in register DC_Cancel + /* b. reset cancel_dc_q[4:0] in register DC_Cancel */ reg_dc_cancel &= ~(0x001F); PHY_DEBUG(("[CAL] DC_CANCEL (write) = 0x%08X\n", reg_dc_cancel)); hw_set_dxx_reg(phw_data, 0x5C, reg_dc_cancel); @@ -687,7 +625,7 @@ void _txqdac_dc_offset_cacellation_winbond(struct hw_data *phw_data) PHY_DEBUG(("[CAL] mag_0=%d (iqcal_image_i=%d, iqcal_image_q=%d)\n", mag_0, iqcal_image_i, iqcal_image_q)); - // c. + /* c. */ reg_dc_cancel |= (1 << CANCEL_DC_Q_SHIFT); PHY_DEBUG(("[CAL] DC_CANCEL (write) = 0x%08X\n", reg_dc_cancel)); hw_set_dxx_reg(phw_data, 0x5C, reg_dc_cancel); @@ -702,18 +640,12 @@ void _txqdac_dc_offset_cacellation_winbond(struct hw_data *phw_data) PHY_DEBUG(("[CAL] mag_1=%d (iqcal_image_i=%d, iqcal_image_q=%d)\n", mag_1, iqcal_image_i, iqcal_image_q)); - // d. Calculate the correct DC offset cancellation value for I + /* d. Calculate the correct DC offset cancellation value for I */ if (mag_0 != mag_1) - { fix_cancel_dc_q = (mag_0*10000) / (mag_0*10000 - mag_1*10000); - } - else - { + else { if (mag_0 == mag_1) - { PHY_DEBUG(("[CAL] ***** mag_0 = mag_1 !!\n")); - } - fix_cancel_dc_q = 0; } @@ -721,12 +653,10 @@ void _txqdac_dc_offset_cacellation_winbond(struct hw_data *phw_data) fix_cancel_dc_q, _s32_to_s5(fix_cancel_dc_q))); if ((abs(mag_1-mag_0)*6) > mag_0) - { break; - } } - if ( loop >= 19 ) + if (loop >= 19) fix_cancel_dc_q = 0; reg_dc_cancel &= ~(0x001F); @@ -735,13 +665,13 @@ void _txqdac_dc_offset_cacellation_winbond(struct hw_data *phw_data) PHY_DEBUG(("[CAL] DC_CANCEL (write) = 0x%08X\n", reg_dc_cancel)); - // f. + /* f. */ reg_mode_ctrl &= ~MASK_CALIB_START; hw_set_dxx_reg(phw_data, REG_MODE_CTRL, reg_mode_ctrl); PHY_DEBUG(("[CAL] MODE_CTRL (write) = 0x%08X\n", reg_mode_ctrl)); } -//20060612.1.a 20060718.1 Modify +/* 20060612.1.a 20060718.1 Modify */ u8 _tx_iq_calibration_loop_winbond(struct hw_data *phw_data, s32 a_2_threshold, s32 b_2_threshold) @@ -765,7 +695,7 @@ u8 _tx_iq_calibration_loop_winbond(struct hw_data *phw_data, s32 temp1, temp2; u32 val; u16 loop; - s32 iqcal_tone_i_avg,iqcal_tone_q_avg; + s32 iqcal_tone_i_avg, iqcal_tone_q_avg; u8 verify_count; int capture_time; @@ -780,18 +710,18 @@ u8 _tx_iq_calibration_loop_winbond(struct hw_data *phw_data, loop = LOOP_TIMES; - while (loop > 0) - { + while (loop > 0) { PHY_DEBUG(("[CAL] [%d.] <_tx_iq_calibration_loop>\n", (LOOP_TIMES-loop+1))); - iqcal_tone_i_avg=0; - iqcal_tone_q_avg=0; - if( !hw_set_dxx_reg(phw_data, 0x3C, 0x00) ) // 20060718.1 modify + iqcal_tone_i_avg = 0; + iqcal_tone_q_avg = 0; + if (!hw_set_dxx_reg(phw_data, 0x3C, 0x00)) /* 20060718.1 modify */ return 0; - for(capture_time=0;capture_time<10;capture_time++) - { - // a. Set iqcal_mode[1:0] to 0x2 and set "calib_start" to 0x1 to - // enable "IQ alibration Mode II" + for (capture_time = 0; capture_time < 10; capture_time++) { + /* + * a. Set iqcal_mode[1:0] to 0x2 and set "calib_start" to 0x1 to + * enable "IQ alibration Mode II" + */ reg_mode_ctrl &= ~(MASK_IQCAL_TONE_SEL|MASK_IQCAL_MODE); reg_mode_ctrl &= ~MASK_IQCAL_MODE; reg_mode_ctrl |= (MASK_CALIB_START|0x02); @@ -799,7 +729,7 @@ u8 _tx_iq_calibration_loop_winbond(struct hw_data *phw_data, hw_set_dxx_reg(phw_data, REG_MODE_CTRL, reg_mode_ctrl); PHY_DEBUG(("[CAL] MODE_CTRL (write) = 0x%08X\n", reg_mode_ctrl)); - // b. + /* b. */ hw_get_dxx_reg(phw_data, REG_CALIB_READ1, &val); PHY_DEBUG(("[CAL] CALIB_READ1 = 0x%08X\n", val)); @@ -813,21 +743,23 @@ u8 _tx_iq_calibration_loop_winbond(struct hw_data *phw_data, iq_mag_0_tx = (s32) _sqrt(sqsum); PHY_DEBUG(("[CAL] ** iq_mag_0_tx=%d\n", iq_mag_0_tx)); - // c. Set "calib_start" to 0x0 + /* c. Set "calib_start" to 0x0 */ reg_mode_ctrl &= ~MASK_CALIB_START; hw_set_dxx_reg(phw_data, REG_MODE_CTRL, reg_mode_ctrl); PHY_DEBUG(("[CAL] MODE_CTRL (write) = 0x%08X\n", reg_mode_ctrl)); - // d. Set iqcal_mode[1:0] to 0x3 and set "calib_start" to 0x1 to - // enable "IQ alibration Mode II" - //hw_get_dxx_reg(phw_data, REG_MODE_CTRL, &val); + /* + * d. Set iqcal_mode[1:0] to 0x3 and set "calib_start" to 0x1 to + * enable "IQ alibration Mode II" + */ + /* hw_get_dxx_reg(phw_data, REG_MODE_CTRL, &val); */ hw_get_dxx_reg(phw_data, REG_MODE_CTRL, ®_mode_ctrl); reg_mode_ctrl &= ~MASK_IQCAL_MODE; reg_mode_ctrl |= (MASK_CALIB_START|0x03); hw_set_dxx_reg(phw_data, REG_MODE_CTRL, reg_mode_ctrl); PHY_DEBUG(("[CAL] MODE_CTRL (write) = 0x%08X\n", reg_mode_ctrl)); - // e. + /* e. */ hw_get_dxx_reg(phw_data, REG_CALIB_READ1, &val); PHY_DEBUG(("[CAL] CALIB_READ1 = 0x%08X\n", val)); @@ -835,14 +767,11 @@ u8 _tx_iq_calibration_loop_winbond(struct hw_data *phw_data, iqcal_tone_q = _s13_to_s32((val & 0x03FFE000) >> 13); PHY_DEBUG(("[CAL] ** iqcal_tone_i = %d, iqcal_tone_q = %d\n", iqcal_tone_i, iqcal_tone_q)); - if( capture_time == 0) - { + if (capture_time == 0) continue; - } - else - { - iqcal_tone_i_avg=( iqcal_tone_i_avg*(capture_time-1) +iqcal_tone_i)/capture_time; - iqcal_tone_q_avg=( iqcal_tone_q_avg*(capture_time-1) +iqcal_tone_q)/capture_time; + else { + iqcal_tone_i_avg = (iqcal_tone_i_avg*(capture_time-1) + iqcal_tone_i)/capture_time; + iqcal_tone_q_avg = (iqcal_tone_q_avg*(capture_time-1) + iqcal_tone_q)/capture_time; } } @@ -857,11 +786,10 @@ u8 _tx_iq_calibration_loop_winbond(struct hw_data *phw_data, PHY_DEBUG(("[CAL] ** rot_i_b = %d, rot_q_b = %d\n", rot_i_b, rot_q_b)); - // f. + /* f. */ divisor = ((iq_mag_0_tx * iq_mag_0_tx * 2)/1024 - rot_i_b) * 2; - if (divisor == 0) - { + if (divisor == 0) { PHY_DEBUG(("[CAL] ** <_tx_iq_calibration_loop> ERROR *******\n")); PHY_DEBUG(("[CAL] ** divisor=0 to calculate EPS and THETA !!\n")); PHY_DEBUG(("[CAL] ******************************************\n")); @@ -876,18 +804,16 @@ u8 _tx_iq_calibration_loop_winbond(struct hw_data *phw_data, phw_data->iq_rsdl_gain_tx_d2 = a_2; phw_data->iq_rsdl_phase_tx_d2 = b_2; - //if ((abs(a_2) < 150) && (abs(b_2) < 100)) - //if ((abs(a_2) < 200) && (abs(b_2) < 200)) - if ((abs(a_2) < a_2_threshold) && (abs(b_2) < b_2_threshold)) - { + /* if ((abs(a_2) < 150) && (abs(b_2) < 100)) */ + /* if ((abs(a_2) < 200) && (abs(b_2) < 200)) */ + if ((abs(a_2) < a_2_threshold) && (abs(b_2) < b_2_threshold)) { verify_count++; PHY_DEBUG(("[CAL] ** <_tx_iq_calibration_loop> *************\n")); PHY_DEBUG(("[CAL] ** VERIFY OK # %d !!\n", verify_count)); PHY_DEBUG(("[CAL] ******************************************\n")); - if (verify_count > 2) - { + if (verify_count > 2) { PHY_DEBUG(("[CAL] ** <_tx_iq_calibration_loop> *********\n")); PHY_DEBUG(("[CAL] ** TX_IQ_CALIBRATION (EPS,THETA) OK !!\n")); PHY_DEBUG(("[CAL] **************************************\n")); @@ -895,37 +821,29 @@ u8 _tx_iq_calibration_loop_winbond(struct hw_data *phw_data, } continue; - } - else - { + } else verify_count = 0; - } _sin_cos(b_2, &sin_b, &cos_b); _sin_cos(b_2*2, &sin_2b, &cos_2b); PHY_DEBUG(("[CAL] ** sin(b/2)=%d, cos(b/2)=%d\n", sin_b, cos_b)); PHY_DEBUG(("[CAL] ** sin(b)=%d, cos(b)=%d\n", sin_2b, cos_2b)); - if (cos_2b == 0) - { + if (cos_2b == 0) { PHY_DEBUG(("[CAL] ** <_tx_iq_calibration_loop> ERROR *******\n")); PHY_DEBUG(("[CAL] ** cos(b)=0 !!\n")); PHY_DEBUG(("[CAL] ******************************************\n")); break; } - // 1280 * 32768 = 41943040 + /* 1280 * 32768 = 41943040 */ temp1 = (41943040/cos_2b)*cos_b; - //temp2 = (41943040/cos_2b)*sin_b*(-1); - if (phw_data->revision == 0x2002) // 1st-cut - { + /* temp2 = (41943040/cos_2b)*sin_b*(-1); */ + if (phw_data->revision == 0x2002) /* 1st-cut */ temp2 = (41943040/cos_2b)*sin_b*(-1); - } - else // 2nd-cut - { + else /* 2nd-cut */ temp2 = (41943040*4/cos_2b)*sin_b*(-1); - } tx_cal_flt_b[0] = _floor(temp1/(32768+a_2)); tx_cal_flt_b[1] = _floor(temp2/(32768+a_2)); @@ -937,37 +855,34 @@ u8 _tx_iq_calibration_loop_winbond(struct hw_data *phw_data, PHY_DEBUG(("[CAL] tx_cal_flt_b[3] = %d\n", tx_cal_flt_b[3])); tx_cal[2] = tx_cal_flt_b[2]; - tx_cal[2] = tx_cal[2] +3; + tx_cal[2] = tx_cal[2] + 3; tx_cal[1] = tx_cal[2]; tx_cal[3] = tx_cal_flt_b[3] - 128; - tx_cal[0] = -tx_cal[3]+1; + tx_cal[0] = -tx_cal[3] + 1; PHY_DEBUG(("[CAL] tx_cal[0] = %d\n", tx_cal[0])); PHY_DEBUG(("[CAL] tx_cal[1] = %d\n", tx_cal[1])); PHY_DEBUG(("[CAL] tx_cal[2] = %d\n", tx_cal[2])); PHY_DEBUG(("[CAL] tx_cal[3] = %d\n", tx_cal[3])); - //if ((tx_cal[0] == 0) && (tx_cal[1] == 0) && - // (tx_cal[2] == 0) && (tx_cal[3] == 0)) - //{ - // PHY_DEBUG(("[CAL] ** <_tx_iq_calibration_loop> *************\n")); - // PHY_DEBUG(("[CAL] ** TX_IQ_CALIBRATION COMPLETE !!\n")); - // PHY_DEBUG(("[CAL] ******************************************\n")); - // return 0; - //} + /* if ((tx_cal[0] == 0) && (tx_cal[1] == 0) && + (tx_cal[2] == 0) && (tx_cal[3] == 0)) + { */ + /* PHY_DEBUG(("[CAL] ** <_tx_iq_calibration_loop> *************\n")); + * PHY_DEBUG(("[CAL] ** TX_IQ_CALIBRATION COMPLETE !!\n")); + * PHY_DEBUG(("[CAL] ******************************************\n")); + * return 0; + } */ - // g. - if (phw_data->revision == 0x2002) // 1st-cut - { + /* g. */ + if (phw_data->revision == 0x2002) /* 1st-cut */{ hw_get_dxx_reg(phw_data, 0x54, &val); PHY_DEBUG(("[CAL] ** 0x54 = 0x%08X\n", val)); tx_cal_reg[0] = _s4_to_s32((val & 0xF0000000) >> 28); tx_cal_reg[1] = _s4_to_s32((val & 0x0F000000) >> 24); tx_cal_reg[2] = _s4_to_s32((val & 0x00F00000) >> 20); tx_cal_reg[3] = _s4_to_s32((val & 0x000F0000) >> 16); - } - else // 2nd-cut - { + } else /* 2nd-cut */{ hw_get_dxx_reg(phw_data, 0x3C, &val); PHY_DEBUG(("[CAL] ** 0x3C = 0x%08X\n", val)); tx_cal_reg[0] = _s5_to_s32((val & 0xF8000000) >> 27); @@ -982,22 +897,17 @@ u8 _tx_iq_calibration_loop_winbond(struct hw_data *phw_data, PHY_DEBUG(("[CAL] tx_cal_reg[2] = %d\n", tx_cal_reg[2])); PHY_DEBUG(("[CAL] tx_cal_reg[3] = %d\n", tx_cal_reg[3])); - if (phw_data->revision == 0x2002) // 1st-cut - { - if (((tx_cal_reg[0]==7) || (tx_cal_reg[0]==(-8))) && - ((tx_cal_reg[3]==7) || (tx_cal_reg[3]==(-8)))) - { + if (phw_data->revision == 0x2002) /* 1st-cut */{ + if (((tx_cal_reg[0] == 7) || (tx_cal_reg[0] == (-8))) && + ((tx_cal_reg[3] == 7) || (tx_cal_reg[3] == (-8)))) { PHY_DEBUG(("[CAL] ** <_tx_iq_calibration_loop> *********\n")); PHY_DEBUG(("[CAL] ** TX_IQ_CALIBRATION SATUATION !!\n")); PHY_DEBUG(("[CAL] **************************************\n")); break; } - } - else // 2nd-cut - { - if (((tx_cal_reg[0]==31) || (tx_cal_reg[0]==(-32))) && - ((tx_cal_reg[3]==31) || (tx_cal_reg[3]==(-32)))) - { + } else /* 2nd-cut */{ + if (((tx_cal_reg[0] == 31) || (tx_cal_reg[0] == (-32))) && + ((tx_cal_reg[3] == 31) || (tx_cal_reg[3] == (-32)))) { PHY_DEBUG(("[CAL] ** <_tx_iq_calibration_loop> *********\n")); PHY_DEBUG(("[CAL] ** TX_IQ_CALIBRATION SATUATION !!\n")); PHY_DEBUG(("[CAL] **************************************\n")); @@ -1014,8 +924,7 @@ u8 _tx_iq_calibration_loop_winbond(struct hw_data *phw_data, PHY_DEBUG(("[CAL] apply tx_cal[2] = %d\n", tx_cal[2])); PHY_DEBUG(("[CAL] apply tx_cal[3] = %d\n", tx_cal[3])); - if (phw_data->revision == 0x2002) // 1st-cut - { + if (phw_data->revision == 0x2002) /* 1st-cut */{ val &= 0x0000FFFF; val |= ((_s32_to_s4(tx_cal[0]) << 28)| (_s32_to_s4(tx_cal[1]) << 24)| @@ -1024,9 +933,7 @@ u8 _tx_iq_calibration_loop_winbond(struct hw_data *phw_data, hw_set_dxx_reg(phw_data, 0x54, val); PHY_DEBUG(("[CAL] ** CALIB_DATA = 0x%08X\n", val)); return 0; - } - else // 2nd-cut - { + } else /* 2nd-cut */{ val &= 0x000003FF; val |= ((_s32_to_s5(tx_cal[0]) << 27)| (_s32_to_s6(tx_cal[1]) << 21)| @@ -1037,7 +944,7 @@ u8 _tx_iq_calibration_loop_winbond(struct hw_data *phw_data, return 0; } - // i. Set "calib_start" to 0x0 + /* i. Set "calib_start" to 0x0 */ reg_mode_ctrl &= ~MASK_CALIB_START; hw_set_dxx_reg(phw_data, REG_MODE_CTRL, reg_mode_ctrl); PHY_DEBUG(("[CAL] MODE_CTRL (write) = 0x%08X\n", reg_mode_ctrl)); @@ -1061,26 +968,26 @@ void _tx_iq_calibration_winbond(struct hw_data *phw_data) PHY_DEBUG(("[CAL] -> [4]_tx_iq_calibration()\n")); - //0x01 0xEE3FC2 ; 3B8FF ; Calibration (6a). enable TX IQ calibration loop circuits + /* 0x01 0xEE3FC2 ; 3B8FF ; Calibration (6a). enable TX IQ calibration loop circuits */ phy_set_rf_data(phw_data, 1, (1<<24)|0xEE3FC2); - //0x0B 0x1905D6 ; 06417 ; Calibration (6b). enable TX I/Q cal loop squaring circuit - phy_set_rf_data(phw_data, 11, (11<<24)|0x19BDD6); // 20060612.1.a 0x1905D6); - //0x05 0x24C60A ; 09318 ; Calibration (6c). setting TX-VGA gain: TXGCH=2 & GPK=110 --> to be optimized - phy_set_rf_data(phw_data, 5, (5<<24)|0x24C60A); //0x24C60A (high temperature) - //0x06 0x06880C ; 01A20 ; Calibration (6d). RXGCH=00; RXGCL=100 000 (RXVGA=32) --> to be optimized - phy_set_rf_data(phw_data, 6, (6<<24)|0x34880C); // 20060612.1.a 0x06890C); - //0x00 0xFDF1C0 ; 3F7C7 ; Calibration (6e). turn on IQ imbalance/Test mode + /* 0x0B 0x1905D6 ; 06417 ; Calibration (6b). enable TX I/Q cal loop squaring circuit */ + phy_set_rf_data(phw_data, 11, (11<<24)|0x19BDD6); /* 20060612.1.a 0x1905D6); */ + /* 0x05 0x24C60A ; 09318 ; Calibration (6c). setting TX-VGA gain: TXGCH=2 & GPK=110 --> to be optimized */ + phy_set_rf_data(phw_data, 5, (5<<24)|0x24C60A); /* 0x24C60A (high temperature) */ + /* 0x06 0x06880C ; 01A20 ; Calibration (6d). RXGCH=00; RXGCL=100 000 (RXVGA=32) --> to be optimized */ + phy_set_rf_data(phw_data, 6, (6<<24)|0x34880C); /* 20060612.1.a 0x06890C); */ + /* 0x00 0xFDF1C0 ; 3F7C7 ; Calibration (6e). turn on IQ imbalance/Test mode */ phy_set_rf_data(phw_data, 0, (0<<24)|0xFDF1C0); - //; [BB-chip]: Calibration (6f).Send test pattern - //; [BB-chip]: Calibration (6g). Search RXGCL optimal value - //; [BB-chip]: Calibration (6h). Caculate TX-path IQ imbalance and setting TX path IQ compensation table - //phy_set_rf_data(phw_data, 3, (3<<24)|0x025586); + /* ; [BB-chip]: Calibration (6f).Send test pattern */ + /* ; [BB-chip]: Calibration (6g). Search RXGCL optimal value */ + /* ; [BB-chip]: Calibration (6h). Caculate TX-path IQ imbalance and setting TX path IQ compensation table */ + /* phy_set_rf_data(phw_data, 3, (3<<24)|0x025586); */ - msleep(30); // 20060612.1.a 30ms delay. Add the follow 2 lines - //To adjust TXVGA to fit iq_mag_0 range from 1250 ~ 1750 - adjust_TXVGA_for_iq_mag( phw_data ); + msleep(30); /* 20060612.1.a 30ms delay. Add the follow 2 lines */ + /* To adjust TXVGA to fit iq_mag_0 range from 1250 ~ 1750 */ + adjust_TXVGA_for_iq_mag(phw_data); - // a. Disable AGC + /* a. Disable AGC */ hw_get_dxx_reg(phw_data, REG_AGC_CTRL3, ®_agc_ctrl3); reg_agc_ctrl3 &= ~BIT(2); reg_agc_ctrl3 |= (MASK_LNA_FIX_GAIN|MASK_AGC_FIX); @@ -1092,16 +999,12 @@ void _tx_iq_calibration_winbond(struct hw_data *phw_data) result = _tx_iq_calibration_loop_winbond(phw_data, 150, 100); - if (result > 0) - { - if (phw_data->revision == 0x2002) // 1st-cut - { + if (result > 0) { + if (phw_data->revision == 0x2002) /* 1st-cut */{ hw_get_dxx_reg(phw_data, 0x54, &val); val &= 0x0000FFFF; hw_set_dxx_reg(phw_data, 0x54, val); - } - else // 2nd-cut - { + } else /* 2nd-cut*/{ hw_get_dxx_reg(phw_data, 0x3C, &val); val &= 0x000003FF; hw_set_dxx_reg(phw_data, 0x3C, val); @@ -1109,32 +1012,24 @@ void _tx_iq_calibration_winbond(struct hw_data *phw_data) result = _tx_iq_calibration_loop_winbond(phw_data, 300, 200); - if (result > 0) - { - if (phw_data->revision == 0x2002) // 1st-cut - { + if (result > 0) { + if (phw_data->revision == 0x2002) /* 1st-cut */{ hw_get_dxx_reg(phw_data, 0x54, &val); val &= 0x0000FFFF; hw_set_dxx_reg(phw_data, 0x54, val); - } - else // 2nd-cut - { + } else /* 2nd-cut*/{ hw_get_dxx_reg(phw_data, 0x3C, &val); val &= 0x000003FF; hw_set_dxx_reg(phw_data, 0x3C, val); } result = _tx_iq_calibration_loop_winbond(phw_data, 500, 400); - if (result > 0) - { - if (phw_data->revision == 0x2002) // 1st-cut - { + if (result > 0) { + if (phw_data->revision == 0x2002) /* 1st-cut */{ hw_get_dxx_reg(phw_data, 0x54, &val); val &= 0x0000FFFF; hw_set_dxx_reg(phw_data, 0x54, val); - } - else // 2nd-cut - { + } else /* 2nd-cut */{ hw_get_dxx_reg(phw_data, 0x3C, &val); val &= 0x000003FF; hw_set_dxx_reg(phw_data, 0x3C, val); @@ -1143,20 +1038,16 @@ void _tx_iq_calibration_winbond(struct hw_data *phw_data) result = _tx_iq_calibration_loop_winbond(phw_data, 700, 500); - if (result > 0) - { + if (result > 0) { PHY_DEBUG(("[CAL] ** <_tx_iq_calibration> **************\n")); PHY_DEBUG(("[CAL] ** TX_IQ_CALIBRATION FAILURE !!\n")); PHY_DEBUG(("[CAL] **************************************\n")); - if (phw_data->revision == 0x2002) // 1st-cut - { + if (phw_data->revision == 0x2002) /* 1st-cut */{ hw_get_dxx_reg(phw_data, 0x54, &val); val &= 0x0000FFFF; hw_set_dxx_reg(phw_data, 0x54, val); - } - else // 2nd-cut - { + } else /* 2nd-cut */{ hw_get_dxx_reg(phw_data, 0x3C, &val); val &= 0x000003FF; hw_set_dxx_reg(phw_data, 0x3C, val); @@ -1166,30 +1057,27 @@ void _tx_iq_calibration_winbond(struct hw_data *phw_data) } } - // i. Set "calib_start" to 0x0 + /* i. Set "calib_start" to 0x0 */ hw_get_dxx_reg(phw_data, REG_MODE_CTRL, ®_mode_ctrl); reg_mode_ctrl &= ~MASK_CALIB_START; hw_set_dxx_reg(phw_data, REG_MODE_CTRL, reg_mode_ctrl); PHY_DEBUG(("[CAL] MODE_CTRL (write) = 0x%08X\n", reg_mode_ctrl)); - // g. Enable AGC - //hw_get_dxx_reg(phw_data, REG_AGC_CTRL3, &val); + /* g. Enable AGC */ + /* hw_get_dxx_reg(phw_data, REG_AGC_CTRL3, &val); */ reg_agc_ctrl3 |= BIT(2); reg_agc_ctrl3 &= ~(MASK_LNA_FIX_GAIN|MASK_AGC_FIX); hw_set_dxx_reg(phw_data, REG_AGC_CTRL3, reg_agc_ctrl3); #ifdef _DEBUG - if (phw_data->revision == 0x2002) // 1st-cut - { + if (phw_data->revision == 0x2002) /* 1st-cut */{ hw_get_dxx_reg(phw_data, 0x54, &val); PHY_DEBUG(("[CAL] ** 0x54 = 0x%08X\n", val)); tx_cal_reg[0] = _s4_to_s32((val & 0xF0000000) >> 28); tx_cal_reg[1] = _s4_to_s32((val & 0x0F000000) >> 24); tx_cal_reg[2] = _s4_to_s32((val & 0x00F00000) >> 20); tx_cal_reg[3] = _s4_to_s32((val & 0x000F0000) >> 16); - } - else // 2nd-cut - { + } else /* 2nd-cut */ { hw_get_dxx_reg(phw_data, 0x3C, &val); PHY_DEBUG(("[CAL] ** 0x3C = 0x%08X\n", val)); tx_cal_reg[0] = _s5_to_s32((val & 0xF8000000) >> 27); @@ -1206,11 +1094,13 @@ void _tx_iq_calibration_winbond(struct hw_data *phw_data) #endif - // for test - BEN - // RF Control Override + /* + * for test - BEN + * RF Control Override + */ } -///////////////////////////////////////////////////////////////////////////////////////// +/*****************************************************/ u8 _rx_iq_calibration_loop_winbond(struct hw_data *phw_data, u16 factor, u32 frequency) { u32 reg_mode_ctrl; @@ -1236,51 +1126,49 @@ u8 _rx_iq_calibration_loop_winbond(struct hw_data *phw_data, u16 factor, u32 fre u32 pwr_image; u8 verify_count; - s32 iqcal_tone_i_avg,iqcal_tone_q_avg; - s32 iqcal_image_i_avg,iqcal_image_q_avg; - u16 capture_time; + s32 iqcal_tone_i_avg, iqcal_tone_q_avg; + s32 iqcal_image_i_avg, iqcal_image_q_avg; + u16 capture_time; PHY_DEBUG(("[CAL] -> [5]_rx_iq_calibration_loop()\n")); PHY_DEBUG(("[CAL] ** factor = %d\n", factor)); -// RF Control Override +/* RF Control Override */ hw_get_cxx_reg(phw_data, 0x80, &val); val |= BIT(19); hw_set_cxx_reg(phw_data, 0x80, val); -// RF_Ctrl +/* RF_Ctrl */ hw_get_cxx_reg(phw_data, 0xE4, &val); val |= BIT(0); hw_set_cxx_reg(phw_data, 0xE4, val); PHY_DEBUG(("[CAL] ** RF_CTRL(0xE4) = 0x%08X", val)); - hw_set_dxx_reg(phw_data, 0x58, 0x44444444); // IQ_Alpha + hw_set_dxx_reg(phw_data, 0x58, 0x44444444); /* IQ_Alpha */ - // b. + /* b. */ hw_get_dxx_reg(phw_data, REG_MODE_CTRL, ®_mode_ctrl); PHY_DEBUG(("[CAL] MODE_CTRL (read) = 0x%08X\n", reg_mode_ctrl)); verify_count = 0; - //for (loop = 0; loop < 1; loop++) - //for (loop = 0; loop < LOOP_TIMES; loop++) + /* for (loop = 0; loop < 1; loop++) */ + /* for (loop = 0; loop < LOOP_TIMES; loop++) */ loop = LOOP_TIMES; - while (loop > 0) - { + while (loop > 0) { PHY_DEBUG(("[CAL] [%d.] <_rx_iq_calibration_loop>\n", (LOOP_TIMES-loop+1))); - iqcal_tone_i_avg=0; - iqcal_tone_q_avg=0; - iqcal_image_i_avg=0; - iqcal_image_q_avg=0; - capture_time=0; + iqcal_tone_i_avg = 0; + iqcal_tone_q_avg = 0; + iqcal_image_i_avg = 0; + iqcal_image_q_avg = 0; + capture_time = 0; - for(capture_time=0; capture_time<10; capture_time++) - { - // i. Set "calib_start" to 0x0 + for (capture_time = 0; capture_time < 10; capture_time++) { + /* i. Set "calib_start" to 0x0 */ reg_mode_ctrl &= ~MASK_CALIB_START; - if( !hw_set_dxx_reg(phw_data, REG_MODE_CTRL, reg_mode_ctrl) )//20060718.1 modify + if (!hw_set_dxx_reg(phw_data, REG_MODE_CTRL, reg_mode_ctrl))/*20060718.1 modify */ return 0; PHY_DEBUG(("[CAL] MODE_CTRL (write) = 0x%08X\n", reg_mode_ctrl)); @@ -1289,7 +1177,7 @@ u8 _rx_iq_calibration_loop_winbond(struct hw_data *phw_data, u16 factor, u32 fre hw_set_dxx_reg(phw_data, REG_MODE_CTRL, reg_mode_ctrl); PHY_DEBUG(("[CAL] MODE_CTRL (write) = 0x%08X\n", reg_mode_ctrl)); - // c. + /* c. */ hw_get_dxx_reg(phw_data, REG_CALIB_READ1, &val); PHY_DEBUG(("[CAL] CALIB_READ1 = 0x%08X\n", val)); @@ -1305,16 +1193,13 @@ u8 _rx_iq_calibration_loop_winbond(struct hw_data *phw_data, u16 factor, u32 fre iqcal_image_q = _s13_to_s32((val & 0x03FFE000) >> 13); PHY_DEBUG(("[CAL] ** iqcal_image_i = %d, iqcal_image_q = %d\n", iqcal_image_i, iqcal_image_q)); - if( capture_time == 0) - { + if (capture_time == 0) continue; - } - else - { - iqcal_image_i_avg=( iqcal_image_i_avg*(capture_time-1) +iqcal_image_i)/capture_time; - iqcal_image_q_avg=( iqcal_image_q_avg*(capture_time-1) +iqcal_image_q)/capture_time; - iqcal_tone_i_avg=( iqcal_tone_i_avg*(capture_time-1) +iqcal_tone_i)/capture_time; - iqcal_tone_q_avg=( iqcal_tone_q_avg*(capture_time-1) +iqcal_tone_q)/capture_time; + else { + iqcal_image_i_avg = (iqcal_image_i_avg*(capture_time-1) + iqcal_image_i)/capture_time; + iqcal_image_q_avg = (iqcal_image_q_avg*(capture_time-1) + iqcal_image_q)/capture_time; + iqcal_tone_i_avg = (iqcal_tone_i_avg*(capture_time-1) + iqcal_tone_i)/capture_time; + iqcal_tone_q_avg = (iqcal_tone_q_avg*(capture_time-1) + iqcal_tone_q)/capture_time; } } @@ -1324,7 +1209,7 @@ u8 _rx_iq_calibration_loop_winbond(struct hw_data *phw_data, u16 factor, u32 fre iqcal_tone_i = iqcal_tone_i_avg; iqcal_tone_q = iqcal_tone_q_avg; - // d. + /* d. */ rot_tone_i_b = (iqcal_tone_i * iqcal_tone_i + iqcal_tone_q * iqcal_tone_q) / 1024; rot_tone_q_b = (iqcal_tone_i * iqcal_tone_q * (-1) + @@ -1339,9 +1224,8 @@ u8 _rx_iq_calibration_loop_winbond(struct hw_data *phw_data, u16 factor, u32 fre PHY_DEBUG(("[CAL] ** rot_image_i_b = %d\n", rot_image_i_b)); PHY_DEBUG(("[CAL] ** rot_image_q_b = %d\n", rot_image_q_b)); - // f. - if (rot_tone_i_b == 0) - { + /* f. */ + if (rot_tone_i_b == 0) { PHY_DEBUG(("[CAL] ** <_rx_iq_calibration_loop> ERROR *******\n")); PHY_DEBUG(("[CAL] ** rot_tone_i_b=0 to calculate EPS and THETA !!\n")); PHY_DEBUG(("[CAL] ******************************************\n")); @@ -1363,26 +1247,21 @@ u8 _rx_iq_calibration_loop_winbond(struct hw_data *phw_data, u16 factor, u32 fre PHY_DEBUG(("[CAL] ** sin(b/2)=%d, cos(b/2)=%d\n", sin_b, cos_b)); PHY_DEBUG(("[CAL] ** sin(b)=%d, cos(b)=%d\n", sin_2b, cos_2b)); - if (cos_2b == 0) - { + if (cos_2b == 0) { PHY_DEBUG(("[CAL] ** <_rx_iq_calibration_loop> ERROR *******\n")); PHY_DEBUG(("[CAL] ** cos(b)=0 !!\n")); PHY_DEBUG(("[CAL] ******************************************\n")); break; } - // 1280 * 32768 = 41943040 + /* 1280 * 32768 = 41943040 */ temp1 = (41943040/cos_2b)*cos_b; - //temp2 = (41943040/cos_2b)*sin_b*(-1); - if (phw_data->revision == 0x2002) // 1st-cut - { + /* temp2 = (41943040/cos_2b)*sin_b*(-1); */ + if (phw_data->revision == 0x2002)/* 1st-cut */ temp2 = (41943040/cos_2b)*sin_b*(-1); - } - else // 2nd-cut - { + else/* 2nd-cut */ temp2 = (41943040*4/cos_2b)*sin_b*(-1); - } rx_cal_flt_b[0] = _floor(temp1/(32768+a_2)); rx_cal_flt_b[1] = _floor(temp2/(32768-a_2)); @@ -1403,23 +1282,21 @@ u8 _rx_iq_calibration_loop_winbond(struct hw_data *phw_data, u16 factor, u32 fre PHY_DEBUG(("[CAL] rx_cal[2] = %d\n", rx_cal[2])); PHY_DEBUG(("[CAL] rx_cal[3] = %d\n", rx_cal[3])); - // e. + /* e. */ pwr_tone = (iqcal_tone_i*iqcal_tone_i + iqcal_tone_q*iqcal_tone_q); pwr_image = (iqcal_image_i*iqcal_image_i + iqcal_image_q*iqcal_image_q)*factor; PHY_DEBUG(("[CAL] ** pwr_tone = %d\n", pwr_tone)); PHY_DEBUG(("[CAL] ** pwr_image = %d\n", pwr_image)); - if (pwr_tone > pwr_image) - { + if (pwr_tone > pwr_image) { verify_count++; PHY_DEBUG(("[CAL] ** <_rx_iq_calibration_loop> *************\n")); PHY_DEBUG(("[CAL] ** VERIFY OK # %d !!\n", verify_count)); PHY_DEBUG(("[CAL] ******************************************\n")); - if (verify_count > 2) - { + if (verify_count > 2) { PHY_DEBUG(("[CAL] ** <_rx_iq_calibration_loop> *********\n")); PHY_DEBUG(("[CAL] ** RX_IQ_CALIBRATION OK !!\n")); PHY_DEBUG(("[CAL] **************************************\n")); @@ -1428,19 +1305,16 @@ u8 _rx_iq_calibration_loop_winbond(struct hw_data *phw_data, u16 factor, u32 fre continue; } - // g. + /* g. */ hw_get_dxx_reg(phw_data, 0x54, &val); PHY_DEBUG(("[CAL] ** 0x54 = 0x%08X\n", val)); - if (phw_data->revision == 0x2002) // 1st-cut - { + if (phw_data->revision == 0x2002) /* 1st-cut */{ rx_cal_reg[0] = _s4_to_s32((val & 0x0000F000) >> 12); rx_cal_reg[1] = _s4_to_s32((val & 0x00000F00) >> 8); rx_cal_reg[2] = _s4_to_s32((val & 0x000000F0) >> 4); rx_cal_reg[3] = _s4_to_s32((val & 0x0000000F)); - } - else // 2nd-cut - { + } else /* 2nd-cut */{ rx_cal_reg[0] = _s5_to_s32((val & 0xF8000000) >> 27); rx_cal_reg[1] = _s6_to_s32((val & 0x07E00000) >> 21); rx_cal_reg[2] = _s6_to_s32((val & 0x001F8000) >> 15); @@ -1452,22 +1326,17 @@ u8 _rx_iq_calibration_loop_winbond(struct hw_data *phw_data, u16 factor, u32 fre PHY_DEBUG(("[CAL] rx_cal_reg[2] = %d\n", rx_cal_reg[2])); PHY_DEBUG(("[CAL] rx_cal_reg[3] = %d\n", rx_cal_reg[3])); - if (phw_data->revision == 0x2002) // 1st-cut - { - if (((rx_cal_reg[0]==7) || (rx_cal_reg[0]==(-8))) && - ((rx_cal_reg[3]==7) || (rx_cal_reg[3]==(-8)))) - { + if (phw_data->revision == 0x2002) /* 1st-cut */{ + if (((rx_cal_reg[0] == 7) || (rx_cal_reg[0] == (-8))) && + ((rx_cal_reg[3] == 7) || (rx_cal_reg[3] == (-8)))) { PHY_DEBUG(("[CAL] ** <_rx_iq_calibration_loop> *********\n")); PHY_DEBUG(("[CAL] ** RX_IQ_CALIBRATION SATUATION !!\n")); PHY_DEBUG(("[CAL] **************************************\n")); break; } - } - else // 2nd-cut - { - if (((rx_cal_reg[0]==31) || (rx_cal_reg[0]==(-32))) && - ((rx_cal_reg[3]==31) || (rx_cal_reg[3]==(-32)))) - { + } else /* 2nd-cut */{ + if (((rx_cal_reg[0] == 31) || (rx_cal_reg[0] == (-32))) && + ((rx_cal_reg[3] == 31) || (rx_cal_reg[3] == (-32)))) { PHY_DEBUG(("[CAL] ** <_rx_iq_calibration_loop> *********\n")); PHY_DEBUG(("[CAL] ** RX_IQ_CALIBRATION SATUATION !!\n")); PHY_DEBUG(("[CAL] **************************************\n")); @@ -1485,17 +1354,14 @@ u8 _rx_iq_calibration_loop_winbond(struct hw_data *phw_data, u16 factor, u32 fre PHY_DEBUG(("[CAL] apply rx_cal[3] = %d\n", rx_cal[3])); hw_get_dxx_reg(phw_data, 0x54, &val); - if (phw_data->revision == 0x2002) // 1st-cut - { + if (phw_data->revision == 0x2002) /* 1st-cut */{ val &= 0x0000FFFF; val |= ((_s32_to_s4(rx_cal[0]) << 12)| (_s32_to_s4(rx_cal[1]) << 8)| (_s32_to_s4(rx_cal[2]) << 4)| (_s32_to_s4(rx_cal[3]))); hw_set_dxx_reg(phw_data, 0x54, val); - } - else // 2nd-cut - { + } else /* 2nd-cut */{ val &= 0x000003FF; val |= ((_s32_to_s5(rx_cal[0]) << 27)| (_s32_to_s6(rx_cal[1]) << 21)| @@ -1503,7 +1369,7 @@ u8 _rx_iq_calibration_loop_winbond(struct hw_data *phw_data, u16 factor, u32 fre (_s32_to_s5(rx_cal[3]) << 10)); hw_set_dxx_reg(phw_data, 0x54, val); - if( loop == 3 ) + if (loop == 3) return 0; } PHY_DEBUG(("[CAL] ** CALIB_DATA = 0x%08X\n", val)); @@ -1514,12 +1380,12 @@ u8 _rx_iq_calibration_loop_winbond(struct hw_data *phw_data, u16 factor, u32 fre return 1; } -////////////////////////////////////////////////////////// +/*************************************************/ -////////////////////////////////////////////////////////////////////////// +/***************************************************************/ void _rx_iq_calibration_winbond(struct hw_data *phw_data, u32 frequency) { -// figo 20050523 marked thsi flag for can't compile for relesase +/* figo 20050523 marked this flag for can't compile for relesase */ #ifdef _DEBUG s32 rx_cal_reg[4]; u32 val; @@ -1528,37 +1394,34 @@ void _rx_iq_calibration_winbond(struct hw_data *phw_data, u32 frequency) u8 result; PHY_DEBUG(("[CAL] -> [5]_rx_iq_calibration()\n")); -// a. Set RFIC to "RX calibration mode" - //; ----- Calibration (7). RX path IQ imbalance calibration loop - // 0x01 0xFFBFC2 ; 3FEFF ; Calibration (7a). enable RX IQ calibration loop circuits +/* a. Set RFIC to "RX calibration mode" */ + /* ; ----- Calibration (7). RX path IQ imbalance calibration loop */ + /* 0x01 0xFFBFC2 ; 3FEFF ; Calibration (7a). enable RX IQ calibration loop circuits */ phy_set_rf_data(phw_data, 1, (1<<24)|0xEFBFC2); - // 0x0B 0x1A01D6 ; 06817 ; Calibration (7b). enable RX I/Q cal loop SW1 circuit + /* 0x0B 0x1A01D6 ; 06817 ; Calibration (7b). enable RX I/Q cal loop SW1 circuits */ phy_set_rf_data(phw_data, 11, (11<<24)|0x1A05D6); - //0x05 0x24848A ; 09212 ; Calibration (7c). setting TX-VGA gain (TXGCH) to 2 --> to be optimized - phy_set_rf_data(phw_data, 5, (5<<24)| phw_data->txvga_setting_for_cal); - //0x06 0x06840C ; 01A10 ; Calibration (7d). RXGCH=00; RXGCL=010 000 (RXVGA) --> to be optimized + /* 0x05 0x24848A ; 09212 ; Calibration (7c). setting TX-VGA gain (TXGCH) to 2 --> to be optimized */ + phy_set_rf_data(phw_data, 5, (5<<24) | phw_data->txvga_setting_for_cal); + /* 0x06 0x06840C ; 01A10 ; Calibration (7d). RXGCH=00; RXGCL=010 000 (RXVGA) --> to be optimized */ phy_set_rf_data(phw_data, 6, (6<<24)|0x06834C); - //0x00 0xFFF1C0 ; 3F7C7 ; Calibration (7e). turn on IQ imbalance/Test mode + /* 0x00 0xFFF1C0 ; 3F7C7 ; Calibration (7e). turn on IQ imbalance/Test mode */ phy_set_rf_data(phw_data, 0, (0<<24)|0xFFF1C0); - // ; [BB-chip]: Calibration (7f). Send test pattern - // ; [BB-chip]: Calibration (7g). Search RXGCL optimal value - // ; [BB-chip]: Calibration (7h). Caculate RX-path IQ imbalance and setting RX path IQ compensation table + /* ; [BB-chip]: Calibration (7f). Send test pattern */ + /* ; [BB-chip]: Calibration (7g). Search RXGCL optimal value */ + /* ; [BB-chip]: Calibration (7h). Caculate RX-path IQ imbalance and setting RX path IQ compensation table */ result = _rx_iq_calibration_loop_winbond(phw_data, 12589, frequency); - if (result > 0) - { + if (result > 0) { _reset_rx_cal(phw_data); result = _rx_iq_calibration_loop_winbond(phw_data, 7943, frequency); - if (result > 0) - { + if (result > 0) { _reset_rx_cal(phw_data); result = _rx_iq_calibration_loop_winbond(phw_data, 5011, frequency); - if (result > 0) - { + if (result > 0) { PHY_DEBUG(("[CAL] ** <_rx_iq_calibration> **************\n")); PHY_DEBUG(("[CAL] ** RX_IQ_CALIBRATION FAILURE !!\n")); PHY_DEBUG(("[CAL] **************************************\n")); @@ -1571,15 +1434,12 @@ void _rx_iq_calibration_winbond(struct hw_data *phw_data, u32 frequency) hw_get_dxx_reg(phw_data, 0x54, &val); PHY_DEBUG(("[CAL] ** 0x54 = 0x%08X\n", val)); - if (phw_data->revision == 0x2002) // 1st-cut - { + if (phw_data->revision == 0x2002) /* 1st-cut */{ rx_cal_reg[0] = _s4_to_s32((val & 0x0000F000) >> 12); rx_cal_reg[1] = _s4_to_s32((val & 0x00000F00) >> 8); rx_cal_reg[2] = _s4_to_s32((val & 0x000000F0) >> 4); rx_cal_reg[3] = _s4_to_s32((val & 0x0000000F)); - } - else // 2nd-cut - { + } else /* 2nd-cut */{ rx_cal_reg[0] = _s5_to_s32((val & 0xF8000000) >> 27); rx_cal_reg[1] = _s6_to_s32((val & 0x07E00000) >> 21); rx_cal_reg[2] = _s6_to_s32((val & 0x001F8000) >> 15); @@ -1594,7 +1454,7 @@ void _rx_iq_calibration_winbond(struct hw_data *phw_data, u32 frequency) } -//////////////////////////////////////////////////////////////////////// +/*******************************************************/ void phy_calibration_winbond(struct hw_data *phw_data, u32 frequency) { u32 reg_mode_ctrl; @@ -1602,7 +1462,7 @@ void phy_calibration_winbond(struct hw_data *phw_data, u32 frequency) PHY_DEBUG(("[CAL] -> phy_calibration_winbond()\n")); - // 20040701 1.1.25.1000 kevin + /* 20040701 1.1.25.1000 kevin */ hw_get_cxx_reg(phw_data, 0x80, &mac_ctrl); hw_get_cxx_reg(phw_data, 0xE4, &rf_ctrl); hw_get_dxx_reg(phw_data, 0x58, &iq_alpha); @@ -1610,72 +1470,71 @@ void phy_calibration_winbond(struct hw_data *phw_data, u32 frequency) _rxadc_dc_offset_cancellation_winbond(phw_data, frequency); - //_txidac_dc_offset_cancellation_winbond(phw_data); - //_txqdac_dc_offset_cacellation_winbond(phw_data); + /* _txidac_dc_offset_cancellation_winbond(phw_data); */ + /* _txqdac_dc_offset_cacellation_winbond(phw_data); */ _tx_iq_calibration_winbond(phw_data); _rx_iq_calibration_winbond(phw_data, frequency); - //------------------------------------------------------------------------ + /*********************************************************************/ hw_get_dxx_reg(phw_data, REG_MODE_CTRL, ®_mode_ctrl); - reg_mode_ctrl &= ~(MASK_IQCAL_TONE_SEL|MASK_IQCAL_MODE|MASK_CALIB_START); // set when finish + reg_mode_ctrl &= ~(MASK_IQCAL_TONE_SEL|MASK_IQCAL_MODE|MASK_CALIB_START); /* set when finish */ hw_set_dxx_reg(phw_data, REG_MODE_CTRL, reg_mode_ctrl); PHY_DEBUG(("[CAL] MODE_CTRL (write) = 0x%08X\n", reg_mode_ctrl)); - // i. Set RFIC to "Normal mode" + /* i. Set RFIC to "Normal mode" */ hw_set_cxx_reg(phw_data, 0x80, mac_ctrl); hw_set_cxx_reg(phw_data, 0xE4, rf_ctrl); hw_set_dxx_reg(phw_data, 0x58, iq_alpha); - //------------------------------------------------------------------------ + /*********************************************************************/ phy_init_rf(phw_data); } -//=========================== -void phy_set_rf_data( struct hw_data * pHwData, u32 index, u32 value ) +/******************/ +void phy_set_rf_data(struct hw_data *pHwData, u32 index, u32 value) { - u32 ltmp=0; + u32 ltmpi = 0; - switch( pHwData->phy_type ) - { - case RF_MAXIM_2825: - case RF_MAXIM_V1: // 11g Winbond 2nd BB(with Phy board (v1) + Maxim 331) - ltmp = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( value, 18 ); - break; + switch (pHwData->phy_type) { + case RF_MAXIM_2825: + case RF_MAXIM_V1: /* 11g Winbond 2nd BB(with Phy board (v1) + Maxim 331) */ + ltmp = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(value, 18); + break; - case RF_MAXIM_2827: - ltmp = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( value, 18 ); - break; + case RF_MAXIM_2827: + ltmp = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(value, 18); + break; - case RF_MAXIM_2828: - ltmp = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( value, 18 ); - break; + case RF_MAXIM_2828: + ltmp = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(value, 18); + break; - case RF_MAXIM_2829: - ltmp = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( value, 18 ); - break; + case RF_MAXIM_2829: + ltmp = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(value, 18); + break; - case RF_AIROHA_2230: - case RF_AIROHA_2230S: // 20060420 Add this - ltmp = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse( value, 20 ); - break; + case RF_AIROHA_2230: + case RF_AIROHA_2230S: /* 20060420 Add this */ + ltmp = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse(value, 20); + break; - case RF_AIROHA_7230: - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | (value&0xffffff); - break; + case RF_AIROHA_7230: + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | (value&0xffffff); + break; - case RF_WB_242: - case RF_WB_242_1: // 20060619.5 Add - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( value, 24 ); - break; - } + case RF_WB_242: + case RF_WB_242_1:/* 20060619.5 Add */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse(value, 24); + break; + } - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); } -// 20060717 modify as Bruce's mail +/* 20060717 modify as Bruce's mail */ unsigned char adjust_TXVGA_for_iq_mag(struct hw_data *phw_data) { int init_txvga = 0; @@ -1685,26 +1544,27 @@ unsigned char adjust_TXVGA_for_iq_mag(struct hw_data *phw_data) s32 iqcal_tone_q0; u32 sqsum; s32 iq_mag_0_tx; - u8 reg_state; - int current_txvga; + u8 reg_state; + int current_txvga; reg_state = 0; - for( init_txvga=0; init_txvga<10; init_txvga++) - { - current_txvga = ( 0x24C40A|(init_txvga<<6) ); - phy_set_rf_data(phw_data, 5, ((5<<24)|current_txvga) ); + for (init_txvga = 0; init_txvga < 10; init_txvga++) { + current_txvga = (0x24C40A|(init_txvga<<6)); + phy_set_rf_data(phw_data, 5, ((5<<24)|current_txvga)); phw_data->txvga_setting_for_cal = current_txvga; - msleep(30); // 20060612.1.a + msleep(30);/* 20060612.1.a */ - if( !hw_get_dxx_reg(phw_data, REG_MODE_CTRL, ®_mode_ctrl) ) // 20060718.1 modify + if (!hw_get_dxx_reg(phw_data, REG_MODE_CTRL, ®_mode_ctrl))/* 20060718.1 modify */ return false; PHY_DEBUG(("[CAL] MODE_CTRL (read) = 0x%08X\n", reg_mode_ctrl)); - // a. Set iqcal_mode[1:0] to 0x2 and set "calib_start" to 0x1 to - // enable "IQ alibration Mode II" + /* + * a. Set iqcal_mode[1:0] to 0x2 and set "calib_start" to 0x1 to + * enable "IQ alibration Mode II" + */ reg_mode_ctrl &= ~(MASK_IQCAL_TONE_SEL|MASK_IQCAL_MODE); reg_mode_ctrl &= ~MASK_IQCAL_MODE; reg_mode_ctrl |= (MASK_CALIB_START|0x02); @@ -1712,15 +1572,15 @@ unsigned char adjust_TXVGA_for_iq_mag(struct hw_data *phw_data) hw_set_dxx_reg(phw_data, REG_MODE_CTRL, reg_mode_ctrl); PHY_DEBUG(("[CAL] MODE_CTRL (write) = 0x%08X\n", reg_mode_ctrl)); - udelay(1); // 20060612.1.a + udelay(1);/* 20060612.1.a */ - udelay(300); // 20060612.1.a + udelay(300);/* 20060612.1.a */ - // b. + /* b. */ hw_get_dxx_reg(phw_data, REG_CALIB_READ1, &val); PHY_DEBUG(("[CAL] CALIB_READ1 = 0x%08X\n", val)); - udelay(300); // 20060612.1.a + udelay(300);/* 20060612.1.a */ iqcal_tone_i0 = _s13_to_s32(val & 0x00001FFF); iqcal_tone_q0 = _s13_to_s32((val & 0x03FFE000) >> 13); @@ -1731,23 +1591,18 @@ unsigned char adjust_TXVGA_for_iq_mag(struct hw_data *phw_data) iq_mag_0_tx = (s32) _sqrt(sqsum); PHY_DEBUG(("[CAL] ** auto_adjust_txvga_for_iq_mag_0_tx=%d\n", iq_mag_0_tx)); - if( iq_mag_0_tx>=700 && iq_mag_0_tx<=1750 ) + if (iq_mag_0_tx >= 700 && iq_mag_0_tx <= 1750) break; - else if(iq_mag_0_tx > 1750) - { - init_txvga=-2; + else if (iq_mag_0_tx > 1750) { + init_txvga = -2; continue; - } - else + } else continue; } - if( iq_mag_0_tx>=700 && iq_mag_0_tx<=1750 ) + if (iq_mag_0_tx >= 700 && iq_mag_0_tx <= 1750) return true; else return false; } - - - From c92069f3d74c9b62dcffb359a4ae00388290d338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Wed, 19 May 2010 09:53:17 -0700 Subject: [PATCH 042/523] Staging: vt6655: use ETH_ZLEN macro instead of custom one MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace custom minimum packet lenght definition MIN_PACKET_LEN by ETH_ZLEN from . Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/mib.c | 4 ++-- drivers/staging/vt6655/tether.h | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vt6655/mib.c b/drivers/staging/vt6655/mib.c index 4ca7877075b2..2f390ab5ed9d 100644 --- a/drivers/staging/vt6655/mib.c +++ b/drivers/staging/vt6655/mib.c @@ -341,10 +341,10 @@ void STAvUpdateRDStatCounter (PSStatCounter pStatistic, if (WLAN_GET_FC_MOREFRAG(pHeader->wFrameCtl)) pStatistic->dwRsrRxFragment++; - if (cbFrameLength < MIN_PACKET_LEN + 4) { + if (cbFrameLength < ETH_ZLEN + 4) { pStatistic->dwRsrRunt++; } - else if (cbFrameLength == MIN_PACKET_LEN + 4) { + else if (cbFrameLength == ETH_ZLEN + 4) { pStatistic->dwRsrRxFrmLen64++; } else if ((65 <= cbFrameLength) && (cbFrameLength <= 127)) { diff --git a/drivers/staging/vt6655/tether.h b/drivers/staging/vt6655/tether.h index 3c9acd7903a8..99fdc032d47a 100644 --- a/drivers/staging/vt6655/tether.h +++ b/drivers/staging/vt6655/tether.h @@ -39,12 +39,6 @@ #define U_ETHER_ADDR_STR_LEN (ETH_ALEN * 2 + 1) // Ethernet address string length -#define MIN_DATA_LEN 46 // min data length - -#define MIN_PACKET_LEN (MIN_DATA_LEN + ETH_HLEN) - // 60 - // min total packet length (tx) - #define MAX_LOOKAHEAD_SIZE ETH_FRAME_LEN #define U_MULTI_ADDR_LEN 8 // multicast address length From 670ea81eadf68fa68023731e3f747fd6b0c61dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Wed, 19 May 2010 11:30:51 -0700 Subject: [PATCH 043/523] Staging: vt6655: use is_multicast_ether_addr instead of custom macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace custom macro IS_MULTICAST_ADDRESS by is_multicast_ether_addr from . Remove linux/if_ether.h include as it is included in linux/etherdevice.h already. Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 2 +- drivers/staging/vt6655/dpc.c | 4 ++-- drivers/staging/vt6655/mib.c | 4 ++-- drivers/staging/vt6655/rxtx.c | 10 +++++----- drivers/staging/vt6655/tether.h | 5 +---- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index e49bb258b5c3..24b6d4507db6 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -2307,7 +2307,7 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { spin_unlock_irq(&pDevice->lock); return 0; } - if (IS_MULTICAST_ADDRESS((PBYTE)(skb->data))) { + if (is_multicast_ether_addr((PBYTE)(skb->data))) { uNodeIndex = 0; bNodeExist = TRUE; if (pMgmt->sNodeDBTable[0].bPSEnable) { diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index 6b758a8c1af3..addbd4d1989d 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -463,7 +463,7 @@ device_receive_frame ( return FALSE; } - if (!IS_MULTICAST_ADDRESS(pbyFrame) && !IS_BROADCAST_ADDRESS(pbyFrame)) { + if (!is_multicast_ether_addr(pbyFrame) && !IS_BROADCAST_ADDRESS(pbyFrame)) { if (WCTLbIsDuplicate(&(pDevice->sDupRxCache), (PS802_11Header) (skb->data + 4))) { pDevice->s802_11Counter.FrameDuplicateCount++; return FALSE; @@ -1460,7 +1460,7 @@ static BOOL s_bAPModeRxData ( if (FrameSize > CB_MAX_BUF_SIZE) return FALSE; // check DA - if(IS_MULTICAST_ADDRESS((PBYTE)(skb->data+cbHeaderOffset))) { + if(is_multicast_ether_addr((PBYTE)(skb->data+cbHeaderOffset))) { if (pMgmt->sNodeDBTable[0].bPSEnable) { skbcpy = dev_alloc_skb((int)pDevice->rx_buf_sz); diff --git a/drivers/staging/vt6655/mib.c b/drivers/staging/vt6655/mib.c index 2f390ab5ed9d..1300f06aae9a 100644 --- a/drivers/staging/vt6655/mib.c +++ b/drivers/staging/vt6655/mib.c @@ -475,7 +475,7 @@ STAvUpdateTDStatCounter ( pStatistic->ullTxBroadcastFrames[uIdx]++; pStatistic->ullTxBroadcastBytes[uIdx] += (ULONGLONG)cbFrameLength; } - else if (IS_MULTICAST_ADDRESS(pbyDestAddr)) { + else if (is_multicast_ether_addr(pbyDestAddr)) { pStatistic->ullTxMulticastFrames[uIdx]++; pStatistic->ullTxMulticastBytes[uIdx] += (ULONGLONG)cbFrameLength; } @@ -497,7 +497,7 @@ STAvUpdateTDStatCounter ( if (IS_BROADCAST_ADDRESS(pbyDestAddr)) pStatistic->dwTsrBroadcast[uIdx]++; - else if (IS_MULTICAST_ADDRESS(pbyDestAddr)) + else if (is_multicast_ether_addr(pbyDestAddr)) pStatistic->dwTsrMulticast[uIdx]++; else pStatistic->dwTsrDirected[uIdx]++; diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index a0445c3427ea..253ca249e3df 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -1394,7 +1394,7 @@ s_cbFillTxBufHead ( if ((pDevice->eOPMode == OP_MODE_ADHOC) || (pDevice->eOPMode == OP_MODE_AP)) { - if (IS_MULTICAST_ADDRESS(&(psEthHeader->abyDstAddr[0])) || + if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0])) || IS_BROADCAST_ADDRESS(&(psEthHeader->abyDstAddr[0]))) { bNeedACK = FALSE; } @@ -2123,7 +2123,7 @@ vGenerateFIFOHeader ( if ((pDevice->eOPMode == OP_MODE_ADHOC) || (pDevice->eOPMode == OP_MODE_AP)) { - if (IS_MULTICAST_ADDRESS(&(psEthHeader->abyDstAddr[0])) || + if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0])) || IS_BROADCAST_ADDRESS(&(psEthHeader->abyDstAddr[0]))) { bNeedACK = FALSE; pTxBufHead->wFIFOCtl = pTxBufHead->wFIFOCtl & (~FIFOCTL_NEEDACK); @@ -2424,7 +2424,7 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); - if (IS_MULTICAST_ADDRESS(&(pPacket->p80211Header->sA3.abyAddr1[0])) || + if (is_multicast_ether_addr(&(pPacket->p80211Header->sA3.abyAddr1[0])) || IS_BROADCAST_ADDRESS(&(pPacket->p80211Header->sA3.abyAddr1[0]))) { bNeedACK = FALSE; } @@ -2760,7 +2760,7 @@ cbGetFragCount ( if ((pDevice->eOPMode == OP_MODE_ADHOC) || (pDevice->eOPMode == OP_MODE_AP)) { - if (IS_MULTICAST_ADDRESS(&(psEthHeader->abyDstAddr[0])) || + if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0])) || IS_BROADCAST_ADDRESS(&(psEthHeader->abyDstAddr[0]))) { bNeedACK = FALSE; } @@ -2938,7 +2938,7 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, UINT cbMPDU pTxBufHead->wTimeStamp = cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us); - if (IS_MULTICAST_ADDRESS(&(p80211Header->sA3.abyAddr1[0])) || + if (is_multicast_ether_addr(&(p80211Header->sA3.abyAddr1[0])) || IS_BROADCAST_ADDRESS(&(p80211Header->sA3.abyAddr1[0]))) { bNeedACK = FALSE; if (pDevice->bEnableHostWEP) { diff --git a/drivers/staging/vt6655/tether.h b/drivers/staging/vt6655/tether.h index 99fdc032d47a..5365e7fadeab 100644 --- a/drivers/staging/vt6655/tether.h +++ b/drivers/staging/vt6655/tether.h @@ -29,7 +29,7 @@ #ifndef __TETHER_H__ #define __TETHER_H__ -#include +#include #include "ttype.h" /*--------------------- Export Definitions -------------------------*/ @@ -188,9 +188,6 @@ S802_11Header, *PS802_11Header; /*--------------------- Export Macros ------------------------------*/ // Frame type macro -#define IS_MULTICAST_ADDRESS(pbyEtherAddr) \ - ((*(PBYTE)(pbyEtherAddr) & 0x01) == 1) - #define IS_BROADCAST_ADDRESS(pbyEtherAddr) ( \ (*(PDWORD)(pbyEtherAddr) == 0xFFFFFFFFL) && \ (*(PWORD)((PBYTE)(pbyEtherAddr) + 4) == 0xFFFF) \ From ca9e12acda7ab451ab481d29911af7ee27c512cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Wed, 19 May 2010 11:30:52 -0700 Subject: [PATCH 044/523] Staging: vt6655: use is_broadcast_ether_addr instead of custom macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace custom macro IS_BROADCAST_ADDRESS by is_broadcast_ether_addr from . Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/bssdb.c | 2 +- drivers/staging/vt6655/dpc.c | 2 +- drivers/staging/vt6655/iwctl.c | 2 +- drivers/staging/vt6655/key.c | 2 +- drivers/staging/vt6655/mib.c | 4 ++-- drivers/staging/vt6655/rxtx.c | 10 +++++----- drivers/staging/vt6655/tether.h | 5 ----- drivers/staging/vt6655/wpactl.c | 4 ++-- 8 files changed, 13 insertions(+), 18 deletions(-) diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c index 6312a55dab1a..0c27150ed47c 100644 --- a/drivers/staging/vt6655/bssdb.c +++ b/drivers/staging/vt6655/bssdb.c @@ -144,7 +144,7 @@ BYTE ZeroBSSID[WLAN_BSSID_LEN]={0x00,0x00,0x00,0x00,0x00,0x00}; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSpSearchBSSList BSSID[%02X %02X %02X-%02X %02X %02X]\n", *pbyDesireBSSID,*(pbyDesireBSSID+1),*(pbyDesireBSSID+2), *(pbyDesireBSSID+3),*(pbyDesireBSSID+4),*(pbyDesireBSSID+5)); - if ((!IS_BROADCAST_ADDRESS(pbyDesireBSSID)) && + if ((!is_broadcast_ether_addr(pbyDesireBSSID)) && (memcmp(pbyDesireBSSID, ZeroBSSID, 6)!= 0)){ pbyBSSID = pbyDesireBSSID; } diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index addbd4d1989d..c82fc3101fa3 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -463,7 +463,7 @@ device_receive_frame ( return FALSE; } - if (!is_multicast_ether_addr(pbyFrame) && !IS_BROADCAST_ADDRESS(pbyFrame)) { + if (!is_multicast_ether_addr(pbyFrame) && !is_broadcast_ether_addr(pbyFrame)) { if (WCTLbIsDuplicate(&(pDevice->sDupRxCache), (PS802_11Header) (skb->data + 4))) { pDevice->s802_11Counter.FrameDuplicateCount++; return FALSE; diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c index cf69034fc0f0..16632357d500 100644 --- a/drivers/staging/vt6655/iwctl.c +++ b/drivers/staging/vt6655/iwctl.c @@ -706,7 +706,7 @@ if (pMgmt->eScanState == WMAC_IS_SCANNING) { return rc; } //mike :add - if ((IS_BROADCAST_ADDRESS(pMgmt->abyDesireBSSID)) || + if ((is_broadcast_ether_addr(pMgmt->abyDesireBSSID)) || (memcmp(pMgmt->abyDesireBSSID, ZeroBSSID, 6) == 0)){ PRINT_K("SIOCSIWAP:invalid desired BSSID return!\n"); return rc; diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c index bfc5c509d902..474091c69047 100644 --- a/drivers/staging/vt6655/key.c +++ b/drivers/staging/vt6655/key.c @@ -371,7 +371,7 @@ BOOL KeybRemoveKey ( { int i; - if (IS_BROADCAST_ADDRESS(pbyBSSID)) { + if (is_broadcast_ether_addr(pbyBSSID)) { // dealte all key if ((dwKeyIndex & PAIRWISE_KEY) != 0) { for (i=0;iCustomStat.ullTsrAllOK = (pStatistic->ullTsrOK[TYPE_AC0DMA] + pStatistic->ullTsrOK[TYPE_TXDMA0]); // update counters in case that successful transmit - if (IS_BROADCAST_ADDRESS(pbyDestAddr)) { + if (is_broadcast_ether_addr(pbyDestAddr)) { pStatistic->ullTxBroadcastFrames[uIdx]++; pStatistic->ullTxBroadcastBytes[uIdx] += (ULONGLONG)cbFrameLength; } @@ -495,7 +495,7 @@ STAvUpdateTDStatCounter ( pStatistic->dwTsrACKData[uIdx]++; } - if (IS_BROADCAST_ADDRESS(pbyDestAddr)) + if (is_broadcast_ether_addr(pbyDestAddr)) pStatistic->dwTsrBroadcast[uIdx]++; else if (is_multicast_ether_addr(pbyDestAddr)) pStatistic->dwTsrMulticast[uIdx]++; diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 253ca249e3df..590fc7f7fcb5 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -1395,7 +1395,7 @@ s_cbFillTxBufHead ( (pDevice->eOPMode == OP_MODE_AP)) { if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0])) || - IS_BROADCAST_ADDRESS(&(psEthHeader->abyDstAddr[0]))) { + is_broadcast_ether_addr(&(psEthHeader->abyDstAddr[0]))) { bNeedACK = FALSE; } else { @@ -2124,7 +2124,7 @@ vGenerateFIFOHeader ( if ((pDevice->eOPMode == OP_MODE_ADHOC) || (pDevice->eOPMode == OP_MODE_AP)) { if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0])) || - IS_BROADCAST_ADDRESS(&(psEthHeader->abyDstAddr[0]))) { + is_broadcast_ether_addr(&(psEthHeader->abyDstAddr[0]))) { bNeedACK = FALSE; pTxBufHead->wFIFOCtl = pTxBufHead->wFIFOCtl & (~FIFOCTL_NEEDACK); } @@ -2425,7 +2425,7 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { if (is_multicast_ether_addr(&(pPacket->p80211Header->sA3.abyAddr1[0])) || - IS_BROADCAST_ADDRESS(&(pPacket->p80211Header->sA3.abyAddr1[0]))) { + is_broadcast_ether_addr(&(pPacket->p80211Header->sA3.abyAddr1[0]))) { bNeedACK = FALSE; } else { @@ -2761,7 +2761,7 @@ cbGetFragCount ( if ((pDevice->eOPMode == OP_MODE_ADHOC) || (pDevice->eOPMode == OP_MODE_AP)) { if (is_multicast_ether_addr(&(psEthHeader->abyDstAddr[0])) || - IS_BROADCAST_ADDRESS(&(psEthHeader->abyDstAddr[0]))) { + is_broadcast_ether_addr(&(psEthHeader->abyDstAddr[0]))) { bNeedACK = FALSE; } else { @@ -2939,7 +2939,7 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, UINT cbMPDU if (is_multicast_ether_addr(&(p80211Header->sA3.abyAddr1[0])) || - IS_BROADCAST_ADDRESS(&(p80211Header->sA3.abyAddr1[0]))) { + is_broadcast_ether_addr(&(p80211Header->sA3.abyAddr1[0]))) { bNeedACK = FALSE; if (pDevice->bEnableHostWEP) { uNodeIndex = 0; diff --git a/drivers/staging/vt6655/tether.h b/drivers/staging/vt6655/tether.h index 5365e7fadeab..e25ad4b47285 100644 --- a/drivers/staging/vt6655/tether.h +++ b/drivers/staging/vt6655/tether.h @@ -188,11 +188,6 @@ S802_11Header, *PS802_11Header; /*--------------------- Export Macros ------------------------------*/ // Frame type macro -#define IS_BROADCAST_ADDRESS(pbyEtherAddr) ( \ - (*(PDWORD)(pbyEtherAddr) == 0xFFFFFFFFL) && \ - (*(PWORD)((PBYTE)(pbyEtherAddr) + 4) == 0xFFFF) \ -) - #define IS_NULL_ADDRESS(pbyEtherAddr) ( \ (*(PDWORD)(pbyEtherAddr) == 0L) && \ (*(PWORD)((PBYTE)(pbyEtherAddr) + 4) == 0) \ diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c index 22c2fab3f328..3d1371239ce7 100644 --- a/drivers/staging/vt6655/wpactl.c +++ b/drivers/staging/vt6655/wpactl.c @@ -351,8 +351,8 @@ spin_lock_irq(&pDevice->lock); } // spin_lock_irq(&pDevice->lock); - if (IS_BROADCAST_ADDRESS(¶m->addr[0]) || (param->addr == NULL)) { - // If IS_BROADCAST_ADDRESS, set the key as every key entry's group key. + if (is_broadcast_ether_addr(¶m->addr[0]) || (param->addr == NULL)) { + // If is_broadcast_ether_addr, set the key as every key entry's group key. DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Groupe Key Assign.\n"); if ((KeybSetAllGroupKey(&(pDevice->sKey), From 8b0591e5017ea2a78f5181fd136e1b281323e5a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Wed, 19 May 2010 11:30:53 -0700 Subject: [PATCH 045/523] Staging: vt6655: use is_zero_ether_addr instead of custom macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace custom macro IS_NULL_ADDRESS by is_zero_ether_addr from . Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 2 +- drivers/staging/vt6655/tether.h | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 7bc2d7654b07..de5f2ba2cf46 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -1319,7 +1319,7 @@ BOOL CARDbSetBSSID(void *pDeviceHandler, PBYTE pbyBSSID, CARD_OP_MODE eOPMode) pDevice->byRxMode &= ~RCR_BSSID; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "wcmd: rx_mode = %x\n", pDevice->byRxMode ); } else { - if (IS_NULL_ADDRESS(pDevice->abyBSSID) == FALSE) { + if (is_zero_ether_addr(pDevice->abyBSSID) == FALSE) { MACvRegBitsOn(pDevice->PortOffset, MAC_REG_RCR, RCR_BSSID); pDevice->bBSSIDFilter = TRUE; pDevice->byRxMode |= RCR_BSSID; diff --git a/drivers/staging/vt6655/tether.h b/drivers/staging/vt6655/tether.h index e25ad4b47285..71ef0f1c898b 100644 --- a/drivers/staging/vt6655/tether.h +++ b/drivers/staging/vt6655/tether.h @@ -188,11 +188,6 @@ S802_11Header, *PS802_11Header; /*--------------------- Export Macros ------------------------------*/ // Frame type macro -#define IS_NULL_ADDRESS(pbyEtherAddr) ( \ - (*(PDWORD)(pbyEtherAddr) == 0L) && \ - (*(PWORD)((PBYTE)(pbyEtherAddr) + 4) == 0) \ -) - #define IS_ETH_ADDRESS_EQUAL(pbyAddr1, pbyAddr2) ( \ (*(PDWORD)(pbyAddr1) == *(PDWORD)(pbyAddr2)) && \ (*(PWORD)((PBYTE)(pbyAddr1) + 4) == \ From 2ef98c606516be4efb176c3c5e339b769ca1833a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Wed, 19 May 2010 11:30:54 -0700 Subject: [PATCH 046/523] Staging: vt6655: use compare_ether_addr instead of custom macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace custom macro IS_ETH_ADDRESS_EQUAL by compare_ether_addr from . Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/bssdb.c | 8 ++++---- drivers/staging/vt6655/dpc.c | 6 +++--- drivers/staging/vt6655/iwctl.c | 4 ++-- drivers/staging/vt6655/key.c | 10 +++++----- drivers/staging/vt6655/tether.h | 7 ------- drivers/staging/vt6655/vntwifi.c | 2 +- drivers/staging/vt6655/wctl.c | 4 ++-- drivers/staging/vt6655/wmgr.c | 4 ++-- drivers/staging/vt6655/wpactl.c | 2 +- 9 files changed, 20 insertions(+), 27 deletions(-) diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c index 0c27150ed47c..d07241af7c08 100644 --- a/drivers/staging/vt6655/bssdb.c +++ b/drivers/staging/vt6655/bssdb.c @@ -162,7 +162,7 @@ BYTE ZeroBSSID[WLAN_BSSID_LEN]={0x00,0x00,0x00,0x00,0x00,0x00}; if(pDevice->bLinkPass==FALSE) pCurrBSS->bSelected = FALSE; if ((pCurrBSS->bActive) && (pCurrBSS->bSelected == FALSE)) { - if (IS_ETH_ADDRESS_EQUAL(pCurrBSS->abyBSSID, pbyBSSID)) { + if (!compare_ether_addr(pCurrBSS->abyBSSID, pbyBSSID)) { if (pSSID != NULL) { // compare ssid if ( !memcmp(pSSID->abySSID, @@ -293,7 +293,7 @@ BSSvClearBSSList( for (ii = 0; ii < MAX_BSS_NUM; ii++) { if (bKeepCurrBSSID) { if (pMgmt->sBSSList[ii].bActive && - IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID, pMgmt->abyCurrBSSID)) { + !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID, pMgmt->abyCurrBSSID)) { // bKeepCurrBSSID = FALSE; continue; } @@ -338,7 +338,7 @@ BSSpAddrIsInBSSList( for (ii = 0; ii < MAX_BSS_NUM; ii++) { pBSSList = &(pMgmt->sBSSList[ii]); if (pBSSList->bActive) { - if (IS_ETH_ADDRESS_EQUAL(pBSSList->abyBSSID, abyBSSID)) { + if (!compare_ether_addr(pBSSList->abyBSSID, abyBSSID)) { // if (pSSID == NULL) // return pBSSList; if (pSSID->len == ((PWLAN_IE_SSID)pBSSList->abySSID)->len){ @@ -775,7 +775,7 @@ BSSDBbIsSTAInNodeDB( // Index = 0 reserved for AP Node for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) { if (pMgmt->sNodeDBTable[ii].bActive) { - if (IS_ETH_ADDRESS_EQUAL(abyDstAddr, pMgmt->sNodeDBTable[ii].abyMACAddr)) { + if (!compare_ether_addr(abyDstAddr, pMgmt->sNodeDBTable[ii].abyMACAddr)) { *puNodeIndex = ii; return TRUE; } diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index c82fc3101fa3..535e033427a9 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -198,10 +198,10 @@ s_vProcessRxMACHeader ( }; pbyRxBuffer = (PBYTE) (pbyRxBufferAddr + cbHeaderSize); - if (IS_ETH_ADDRESS_EQUAL(pbyRxBuffer, &pDevice->abySNAP_Bridgetunnel[0])) { + if (!compare_ether_addr(pbyRxBuffer, &pDevice->abySNAP_Bridgetunnel[0])) { cbHeaderSize += 6; } - else if (IS_ETH_ADDRESS_EQUAL(pbyRxBuffer, &pDevice->abySNAP_RFC1042[0])) { + else if (!compare_ether_addr(pbyRxBuffer, &pDevice->abySNAP_RFC1042[0])) { cbHeaderSize += 6; pwType = (PWORD) (pbyRxBufferAddr + cbHeaderSize); if ((*pwType!= TYPE_PKT_IPX) && (*pwType != cpu_to_le16(0xF380))) { @@ -475,7 +475,7 @@ device_receive_frame ( s_vGetDASA(skb->data+4, &cbHeaderSize, &pDevice->sRxEthHeader); // filter packet send from myself - if (IS_ETH_ADDRESS_EQUAL((PBYTE)&(pDevice->sRxEthHeader.abySrcAddr[0]), pDevice->abyCurrentNetAddr)) + if (!compare_ether_addr((PBYTE)&(pDevice->sRxEthHeader.abySrcAddr[0]), pDevice->abyCurrentNetAddr)) return FALSE; if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) { diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c index 16632357d500..00564535c9a3 100644 --- a/drivers/staging/vt6655/iwctl.c +++ b/drivers/staging/vt6655/iwctl.c @@ -717,7 +717,7 @@ if (pMgmt->eScanState == WMAC_IS_SCANNING) { UINT ii , uSameBssidNum=0; for (ii = 0; ii < MAX_BSS_NUM; ii++) { if (pMgmt->sBSSList[ii].bActive && - IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID,pMgmt->abyDesireBSSID)) { + !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID, pMgmt->abyDesireBSSID)) { uSameBssidNum++; } } @@ -906,7 +906,7 @@ if (pMgmt->eScanState == WMAC_IS_SCANNING) { // by means of judging if there are two same BSSID exist in list ? for (ii = 0; ii < MAX_BSS_NUM; ii++) { if (pMgmt->sBSSList[ii].bActive && - IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID, pCurr->abyBSSID)) { + !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID, pCurr->abyBSSID)) { uSameBssidNum++; } } diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c index 474091c69047..f8527a704635 100644 --- a/drivers/staging/vt6655/key.c +++ b/drivers/staging/vt6655/key.c @@ -145,7 +145,7 @@ BOOL KeybGetKey ( *pKey = NULL; for (i=0;iKeyTable[i].bInUse == TRUE) && - IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) { + !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { if (dwKeyIndex == 0xFFFFFFFF) { if (pTable->KeyTable[i].PairwiseKey.bKeyValid == TRUE) { *pKey = &(pTable->KeyTable[i].PairwiseKey); @@ -216,7 +216,7 @@ BOOL KeybSetKey ( j = i; } if ((pTable->KeyTable[i].bInUse == TRUE) && - IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) { + !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { // found table already exist if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key @@ -398,7 +398,7 @@ BOOL KeybRemoveKey ( for (i=0;iKeyTable[i].bInUse == TRUE) && - IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) { + !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { if ((dwKeyIndex & PAIRWISE_KEY) != 0) { pTable->KeyTable[i].PairwiseKey.bKeyValid = FALSE; s_vCheckKeyTableValid(pTable, dwIoBase); @@ -445,7 +445,7 @@ BOOL KeybRemoveAllKey ( for (i=0;iKeyTable[i].bInUse == TRUE) && - IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) { + !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { pTable->KeyTable[i].PairwiseKey.bKeyValid = FALSE; for(u=0;uKeyTable[i].GroupKey[u].bKeyValid = FALSE; @@ -529,7 +529,7 @@ BOOL KeybGetTransmitKey ( *pKey = NULL; for (i=0;iKeyTable[i].bInUse == TRUE) && - IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) { + !compare_ether_addr(pTable->KeyTable[i].abyBSSID, pbyBSSID)) { if (dwKeyType == PAIRWISE_KEY) { diff --git a/drivers/staging/vt6655/tether.h b/drivers/staging/vt6655/tether.h index 71ef0f1c898b..d0183a25e651 100644 --- a/drivers/staging/vt6655/tether.h +++ b/drivers/staging/vt6655/tether.h @@ -186,13 +186,6 @@ typedef struct tagS802_11Header { S802_11Header, *PS802_11Header; /*--------------------- Export Macros ------------------------------*/ -// Frame type macro - -#define IS_ETH_ADDRESS_EQUAL(pbyAddr1, pbyAddr2) ( \ - (*(PDWORD)(pbyAddr1) == *(PDWORD)(pbyAddr2)) && \ - (*(PWORD)((PBYTE)(pbyAddr1) + 4) == \ - *(PWORD)((PBYTE)(pbyAddr2) + 4)) \ -) /*--------------------- Export Classes ----------------------------*/ diff --git a/drivers/staging/vt6655/vntwifi.c b/drivers/staging/vt6655/vntwifi.c index b527a019188b..680c4962cd33 100644 --- a/drivers/staging/vt6655/vntwifi.c +++ b/drivers/staging/vt6655/vntwifi.c @@ -800,7 +800,7 @@ VNTWIFIbRadarPresent( (byChannel == (BYTE) pMgmt->uCurrChannel) && (pMgmt->bSwitchChannel != TRUE) && (pMgmt->b11hEnable == TRUE)) { - if (IS_ETH_ADDRESS_EQUAL(pMgmt->abyIBSSDFSOwner, CARDpGetCurrentAddress(pMgmt->pAdapter))) { + if (!compare_ether_addr(pMgmt->abyIBSSDFSOwner, CARDpGetCurrentAddress(pMgmt->pAdapter))) { pMgmt->byNewChannel = CARDbyAutoChannelSelect(pMgmt->pAdapter,(BYTE) pMgmt->uCurrChannel); pMgmt->bSwitchChannel = TRUE; } diff --git a/drivers/staging/vt6655/wctl.c b/drivers/staging/vt6655/wctl.c index 64a66b2f1fc5..e9c3a6e57a0d 100644 --- a/drivers/staging/vt6655/wctl.c +++ b/drivers/staging/vt6655/wctl.c @@ -78,7 +78,7 @@ BOOL WCTLbIsDuplicate (PSCache pCache, PS802_11Header pMACHeader) for (ii = 0; ii < DUPLICATE_RX_CACHE_LENGTH; ii++) { pCacheEntry = &(pCache->asCacheEntry[uIndex]); if ((pCacheEntry->wFmSequence == pMACHeader->wSeqCtl) && - (IS_ETH_ADDRESS_EQUAL (&(pCacheEntry->abyAddr2[0]), &(pMACHeader->abyAddr2[0]))) + (!compare_ether_addr(&(pCacheEntry->abyAddr2[0]), &(pMACHeader->abyAddr2[0]))) ) { /* Duplicate match */ return TRUE; @@ -114,7 +114,7 @@ UINT ii; for(ii=0;iicbDFCB;ii++) { if ((pDevice->sRxDFCB[ii].bInUse == TRUE) && - (IS_ETH_ADDRESS_EQUAL (&(pDevice->sRxDFCB[ii].abyAddr2[0]), &(pMACHeader->abyAddr2[0]))) + (!compare_ether_addr(&(pDevice->sRxDFCB[ii].abyAddr2[0]), &(pMACHeader->abyAddr2[0]))) ) { // return(ii); diff --git a/drivers/staging/vt6655/wmgr.c b/drivers/staging/vt6655/wmgr.c index 8af356fd139e..56e15a19675e 100644 --- a/drivers/staging/vt6655/wmgr.c +++ b/drivers/staging/vt6655/wmgr.c @@ -1769,7 +1769,7 @@ s_vMgrRxDeauthentication( vMgrDecodeDeauthen(&sFrame); DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "AP deauthed me, reason=%d.\n", cpu_to_le16((*(sFrame.pwReason)))); // TODO: update BSS list for specific BSSID if pre-authentication case - if (IS_ETH_ADDRESS_EQUAL(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID)) { + if (!compare_ether_addr(sFrame.pHdr->sA3.abyAddr3, pMgmt->abyCurrBSSID)) { if (pMgmt->eCurrState >= WMAC_STATE_AUTHPENDING) { pMgmt->sNodeDBTable[0].bActive = FALSE; pMgmt->eCurrMode = WMAC_MODE_STANDBY; @@ -3098,7 +3098,7 @@ s_vMgrSynchBSS ( // for (ii = 0; ii < MAX_BSS_NUM; ii++) { // if (pMgmt->sBSSList[ii].bActive && - // IS_ETH_ADDRESS_EQUAL(pMgmt->sBSSList[ii].abyBSSID, pCurr->abyBSSID)) { + // !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID, pCurr->abyBSSID)) { // uSameBssidNum++; // } // } diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c index 3d1371239ce7..4adc2f05be14 100644 --- a/drivers/staging/vt6655/wpactl.c +++ b/drivers/staging/vt6655/wpactl.c @@ -408,7 +408,7 @@ spin_lock_irq(&pDevice->lock); } else { // Key Table Full - if (IS_ETH_ADDRESS_EQUAL(¶m->addr[0], pDevice->abyBSSID)) { + if (!compare_ether_addr(¶m->addr[0], pDevice->abyBSSID)) { //DBG_PRN_WLAN03(("return NDIS_STATUS_INVALID_DATA -Key Table Full.2\n")); //spin_unlock_irq(&pDevice->lock); return -EINVAL; From 6b1e6b8f957386e60e3fac15a64518c8f7ce5a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Thu, 20 May 2010 11:08:55 -0700 Subject: [PATCH 047/523] Staging: vt6655: remove unused argument in ChannelValid function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 5 ++--- drivers/staging/vt6655/card.h | 2 +- drivers/staging/vt6655/wcmd.c | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index de5f2ba2cf46..f239920d7f23 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -440,8 +440,7 @@ s_vCaculateOFDMRParameter( /*--------------------- Export function -------------------------*/ /************************************************************************ * Country Channel Valid - * Input: CountryCode, ChannelNum - * ChanneIndex is defined as VT3253 MAC channel: + * Input: ChannelIndex is defined as VT3253 MAC channel: * 1 = 2.4G channel 1 * 2 = 2.4G channel 2 * ... @@ -458,7 +457,7 @@ s_vCaculateOFDMRParameter( ************************************************************************/ //2008-8-4 by chester BOOL -ChannelValid(UINT CountryCode, UINT ChannelIndex) +ChannelValid(UINT ChannelIndex) { BOOL bValid; diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index 76313462cf76..d2207bfbe11f 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -86,7 +86,7 @@ typedef enum _CARD_OP_MODE { /*--------------------- Export Functions --------------------------*/ -BOOL ChannelValid(UINT CountryCode, UINT ChannelIndex); +BOOL ChannelValid(UINT ChannelIndex); void CARDvSetRSPINF(void *pDeviceHandler, CARD_PHY_TYPE ePHYType); void vUpdateIFS(void *pDeviceHandler); void CARDvUpdateBasicTopRate(void *pDeviceHandler); diff --git a/drivers/staging/vt6655/wcmd.c b/drivers/staging/vt6655/wcmd.c index 28665d870f59..c2bf287961a9 100644 --- a/drivers/staging/vt6655/wcmd.c +++ b/drivers/staging/vt6655/wcmd.c @@ -408,7 +408,7 @@ vCommandTimer ( } else { //2008-8-4 by chester - if (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel)) { + if (!ChannelValid(pMgmt->uScanChannel)) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Invalid channel pMgmt->uScanChannel = %d \n",pMgmt->uScanChannel); s_bCommandComplete(pDevice); return; @@ -441,7 +441,7 @@ vCommandTimer ( // printk("chester-ch=%d\n",pMgmt->uScanChannel); pMgmt->uScanChannel++; //2008-8-4 by chester - if (!ChannelValid(pDevice->byZoneType, pMgmt->uScanChannel) && + if (!ChannelValid(pMgmt->uScanChannel) && pMgmt->uScanChannel <= pDevice->byMaxChannel ){ pMgmt->uScanChannel=pDevice->byMaxChannel+1; pMgmt->eCommandState = WLAN_CMD_SCAN_END; From 8fee12e4d1fbf03a44594b4c3951cb0f86958d7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Fri, 21 May 2010 12:55:33 -0700 Subject: [PATCH 048/523] Staging: vt6655: remove double definition of Calcu_LinkQual MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calcu_LinkQual is already defined a couple lines earlier. Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/ttype.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h index 2921083a9f22..f436da04a3b0 100644 --- a/drivers/staging/vt6655/ttype.h +++ b/drivers/staging/vt6655/ttype.h @@ -65,10 +65,6 @@ typedef int BOOL; #define Calcu_LinkQual #endif -#ifndef Calcu_LinkQual -#define Calcu_LinkQual -#endif - /****** Simple typedefs ***************************************************/ /* These lines assume that your compiler's longs are 32 bits and From 8fa5dd133ed38cb412c42f7daca2f6de3fdbbce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Fri, 28 May 2010 09:17:44 -0700 Subject: [PATCH 049/523] Staging: vt6655: remove unused OUT definition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/ttype.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h index f436da04a3b0..0ee260c84794 100644 --- a/drivers/staging/vt6655/ttype.h +++ b/drivers/staging/vt6655/ttype.h @@ -33,10 +33,6 @@ /******* Common definitions and typedefs ***********************************/ -#ifndef OUT -#define OUT -#endif - #ifndef TxInSleep #define TxInSleep #endif From ec28c7fab4c5e5e5c168f0b48bc10bfc7f9896d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Fri, 28 May 2010 12:34:18 -0700 Subject: [PATCH 050/523] Staging: vt6655: remove I8 custom macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove custom macro for signed 8-bit integers. Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 4 ++-- drivers/staging/vt6655/card.h | 4 ++-- drivers/staging/vt6655/device.h | 10 +++++----- drivers/staging/vt6655/ttype.h | 2 -- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index f239920d7f23..b972130f7e96 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -2095,7 +2095,7 @@ void CARDvSetPowerConstraint ( void *pDeviceHandler, BYTE byChannel, - I8 byPower + char byPower ) { PSDevice pDevice = (PSDevice) pDeviceHandler; @@ -2253,7 +2253,7 @@ CARDbySetSupportChannels ( * Return Value: none. * -*/ -I8 +char CARDbyGetTransmitPower ( void *pDeviceHandler ) diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index d2207bfbe11f..00dce0310b5d 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -189,7 +189,7 @@ void CARDvSetPowerConstraint ( void *pDeviceHandler, BYTE byChannel, - I8 byPower + char byPower ); void @@ -205,7 +205,7 @@ CARDbySetSupportChannels ( PBYTE pbyIEs ); -I8 +char CARDbyGetTransmitPower ( void *pDeviceHandler ); diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 40ee4e14237e..de1289196e74 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -693,13 +693,13 @@ typedef struct __device_info { BYTE byCCKPwr; BYTE byOFDMPwrG; BYTE byCurPwr; - I8 byCurPwrdBm; + char byCurPwrdBm; BYTE abyCCKPwrTbl[CB_MAX_CHANNEL_24G+1]; BYTE abyOFDMPwrTbl[CB_MAX_CHANNEL+1]; - I8 abyCCKDefaultPwr[CB_MAX_CHANNEL_24G+1]; - I8 abyOFDMDefaultPwr[CB_MAX_CHANNEL+1]; - I8 abyRegPwr[CB_MAX_CHANNEL+1]; - I8 abyLocalPwr[CB_MAX_CHANNEL+1]; + char abyCCKDefaultPwr[CB_MAX_CHANNEL_24G+1]; + char abyOFDMDefaultPwr[CB_MAX_CHANNEL+1]; + char abyRegPwr[CB_MAX_CHANNEL+1]; + char abyLocalPwr[CB_MAX_CHANNEL+1]; // BaseBand Loopback Use diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h index 0ee260c84794..574edfe62281 100644 --- a/drivers/staging/vt6655/ttype.h +++ b/drivers/staging/vt6655/ttype.h @@ -68,8 +68,6 @@ typedef int BOOL; * but it doesn't matter if they're signed or unsigned. */ -typedef signed char I8; /* 8-bit signed integer */ - typedef unsigned char U8; /* 8-bit unsigned integer */ typedef unsigned short U16; /* 16-bit unsigned integer */ typedef unsigned long U32; /* 32-bit unsigned integer */ From 737c3d708c845ab39bfeb1b656e51e84d5771035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Fri, 28 May 2010 12:34:19 -0700 Subject: [PATCH 051/523] Staging: vt6655: remove U8 custom macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove custom macro for unsigned 8-bit integers. Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/desc.h | 12 ++--- drivers/staging/vt6655/device_main.c | 2 +- drivers/staging/vt6655/iocmd.h | 66 ++++++++++++++-------------- drivers/staging/vt6655/mac.c | 2 +- drivers/staging/vt6655/ttype.h | 1 - 5 files changed, 41 insertions(+), 42 deletions(-) diff --git a/drivers/staging/vt6655/desc.h b/drivers/staging/vt6655/desc.h index cedb1e7df4fa..b4327c015e28 100644 --- a/drivers/staging/vt6655/desc.h +++ b/drivers/staging/vt6655/desc.h @@ -259,9 +259,9 @@ typedef struct tagRDES0 { union { volatile U16 f15Reserved; struct { - volatile U8 f8Reserved1; - volatile U8 f1Owner:1; - volatile U8 f7Reserved:7; + volatile u8 f8Reserved1; + volatile u8 f1Owner:1; + volatile u8 f7Reserved:7; } __attribute__ ((__packed__)); } __attribute__ ((__packed__)); } __attribute__ ((__packed__)) @@ -319,9 +319,9 @@ typedef struct tagTDES0 { union { volatile U16 f15Txtime; struct { - volatile U8 f8Reserved1; - volatile U8 f1Owner:1; - volatile U8 f7Reserved:7; + volatile u8 f8Reserved1; + volatile u8 f1Owner:1; + volatile u8 f7Reserved:7; } __attribute__ ((__packed__)); } __attribute__ ((__packed__)); } __attribute__ ((__packed__)) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 24b6d4507db6..12d1e8b8a0ee 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1151,7 +1151,7 @@ static BOOL device_init_info(struct pci_dev* pcid, PSDevice* ppDevice, static BOOL device_get_pci_info(PSDevice pDevice, struct pci_dev* pcid) { U16 pci_cmd; - U8 b; + u8 b; UINT cis_addr; #ifdef PLICE_DEBUG BYTE pci_config[256]; diff --git a/drivers/staging/vt6655/iocmd.h b/drivers/staging/vt6655/iocmd.h index 60c0a3623613..aedcefe4aac5 100644 --- a/drivers/staging/vt6655/iocmd.h +++ b/drivers/staging/vt6655/iocmd.h @@ -109,7 +109,7 @@ typedef enum tagWZONETYPE { // #pragma pack(1) typedef struct tagSCmdRequest { - U8 name[16]; + u8 name[16]; void *data; U16 wResult; U16 wCmdCode; @@ -121,7 +121,7 @@ typedef struct tagSCmdRequest { typedef struct tagSCmdScan { - U8 ssid[SSID_MAXLEN + 2]; + u8 ssid[SSID_MAXLEN + 2]; } SCmdScan, *PSCmdScan; @@ -134,7 +134,7 @@ typedef struct tagSCmdBSSJoin { U16 wBSSType; U16 wBBPType; - U8 ssid[SSID_MAXLEN + 2]; + u8 ssid[SSID_MAXLEN + 2]; U32 uChannel; BOOL bPSEnable; BOOL bShareKeyAuth; @@ -155,9 +155,9 @@ typedef struct tagSCmdZoneTypeSet { #ifdef WPA_SM_Transtatus typedef struct tagSWPAResult { char ifname[100]; - U8 proto; - U8 key_mgmt; - U8 eap_type; + u8 proto; + u8 key_mgmt; + u8 eap_type; BOOL authenticated; } SWPAResult, *PSWPAResult; #endif @@ -166,11 +166,11 @@ typedef struct tagSCmdStartAP { U16 wBSSType; U16 wBBPType; - U8 ssid[SSID_MAXLEN + 2]; + u8 ssid[SSID_MAXLEN + 2]; U32 uChannel; U32 uBeaconInt; BOOL bShareKeyAuth; - U8 byBasicRate; + u8 byBasicRate; } SCmdStartAP, *PSCmdStartAP; @@ -178,8 +178,8 @@ typedef struct tagSCmdStartAP { typedef struct tagSCmdSetWEP { BOOL bEnableWep; - U8 byKeyIndex; - U8 abyWepKey[WEP_NKEYS][WEP_KEYMAXLEN]; + u8 byKeyIndex; + u8 abyWepKey[WEP_NKEYS][WEP_KEYMAXLEN]; BOOL bWepKeyAvailable[WEP_NKEYS]; U32 auWepKeyLength[WEP_NKEYS]; @@ -190,13 +190,13 @@ typedef struct tagSCmdSetWEP { typedef struct tagSBSSIDItem { U32 uChannel; - U8 abyBSSID[BSSID_LEN]; - U8 abySSID[SSID_MAXLEN + 1]; + u8 abyBSSID[BSSID_LEN]; + u8 abySSID[SSID_MAXLEN + 1]; //2006-1116-01, by NomadZhao //U16 wBeaconInterval; //U16 wCapInfo; - //U8 byNetType; - U8 byNetType; + //u8 byNetType; + u8 byNetType; U16 wBeaconInterval; U16 wCapInfo; // for address of byNetType at align 4 @@ -217,9 +217,9 @@ typedef struct tagSCmdLinkStatus { BOOL bLink; U16 wBSSType; - U8 byState; - U8 abyBSSID[BSSID_LEN]; - U8 abySSID[SSID_MAXLEN + 2]; + u8 byState; + u8 abyBSSID[BSSID_LEN]; + u8 abySSID[SSID_MAXLEN + 2]; U32 uChannel; U32 uLinkRate; @@ -329,8 +329,8 @@ typedef struct tagSStatMIBCount { U32 dwCntRxFrmLength; U32 dwCntTxBufLength; - U8 abyCntRxPattern[16]; - U8 abyCntTxPattern[16]; + u8 abyCntRxPattern[16]; + u8 abyCntTxPattern[16]; // Software check.... U32 dwCntRxDataErr; // rx buffer data software compare CRC err count @@ -354,15 +354,15 @@ typedef struct tagSStatMIBCount { typedef struct tagSNodeItem { // STA info U16 wAID; - U8 abyMACAddr[6]; + u8 abyMACAddr[6]; U16 wTxDataRate; U16 wInActiveCount; U16 wEnQueueCnt; U16 wFlags; BOOL bPWBitOn; - U8 byKeyIndex; + u8 byKeyIndex; U16 wWepKeyLength; - U8 abyWepKey[WEP_KEYMAXLEN]; + u8 abyWepKey[WEP_KEYMAXLEN]; // Auto rate fallback vars BOOL bIsInFallback; U32 uTxFailures; @@ -419,24 +419,24 @@ enum { struct viawget_hostapd_param { U32 cmd; - U8 sta_addr[6]; + u8 sta_addr[6]; union { struct { U16 aid; U16 capability; - U8 tx_supp_rates; + u8 tx_supp_rates; } add_sta; struct { U32 inactive_sec; } get_info_sta; struct { - U8 alg; + u8 alg; U32 flags; U32 err; - U8 idx; - U8 seq[8]; + u8 idx; + u8 seq[8]; U16 key_len; - U8 key[0]; + u8 key[0]; } crypt; struct { U32 flags_and; @@ -445,19 +445,19 @@ struct viawget_hostapd_param { struct { U16 rid; U16 len; - U8 data[0]; + u8 data[0]; } rid; struct { - U8 len; - U8 data[0]; + u8 len; + u8 data[0]; } generic_elem; struct { U16 cmd; U16 reason_code; } mlme; struct { - U8 ssid_len; - U8 ssid[32]; + u8 ssid_len; + u8 ssid[32]; } scan_req; } u; }; diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c index f1ef7da75c2b..eae881c5a9f9 100644 --- a/drivers/staging/vt6655/mac.c +++ b/drivers/staging/vt6655/mac.c @@ -1046,7 +1046,7 @@ void MACvInitialize (DWORD_PTR dwIoBase) //MACvRegBitsOn(dwIoBase, MAC_REG_I2MCSR, I2MCSR_AUTOLD); // wait until EEPROM loading complete //while (TRUE) { - // U8 u8Data; + // u8 u8Data; // VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &u8Data); // if ( !(u8Data & I2MCSR_AUTOLD)) // break; diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h index 574edfe62281..105cabce97ab 100644 --- a/drivers/staging/vt6655/ttype.h +++ b/drivers/staging/vt6655/ttype.h @@ -68,7 +68,6 @@ typedef int BOOL; * but it doesn't matter if they're signed or unsigned. */ -typedef unsigned char U8; /* 8-bit unsigned integer */ typedef unsigned short U16; /* 16-bit unsigned integer */ typedef unsigned long U32; /* 32-bit unsigned integer */ From c17ce8c21d809c62b427bf8e2d2672ebe0904fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Fri, 28 May 2010 12:34:20 -0700 Subject: [PATCH 052/523] Staging: vt6655: remove U16 custom macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove custom macro for unsigned 16-bit integers. Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/desc.h | 4 +-- drivers/staging/vt6655/device_main.c | 4 +-- drivers/staging/vt6655/iocmd.h | 50 ++++++++++++++-------------- drivers/staging/vt6655/ttype.h | 1 - 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/drivers/staging/vt6655/desc.h b/drivers/staging/vt6655/desc.h index b4327c015e28..d99b19a25b15 100644 --- a/drivers/staging/vt6655/desc.h +++ b/drivers/staging/vt6655/desc.h @@ -257,7 +257,7 @@ SRDES0; typedef struct tagRDES0 { volatile WORD wResCount; union { - volatile U16 f15Reserved; + volatile u16 f15Reserved; struct { volatile u8 f8Reserved1; volatile u8 f1Owner:1; @@ -317,7 +317,7 @@ typedef struct tagTDES0 { volatile BYTE byTSR0; volatile BYTE byTSR1; union { - volatile U16 f15Txtime; + volatile u16 f15Txtime; struct { volatile u8 f8Reserved1; volatile u8 f1Owner:1; diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 12d1e8b8a0ee..06585c1d3c83 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1150,14 +1150,14 @@ static BOOL device_init_info(struct pci_dev* pcid, PSDevice* ppDevice, static BOOL device_get_pci_info(PSDevice pDevice, struct pci_dev* pcid) { - U16 pci_cmd; + u16 pci_cmd; u8 b; UINT cis_addr; #ifdef PLICE_DEBUG BYTE pci_config[256]; BYTE value =0x00; int ii,j; - U16 max_lat=0x0000; + u16 max_lat=0x0000; memset(pci_config,0x00,256); #endif diff --git a/drivers/staging/vt6655/iocmd.h b/drivers/staging/vt6655/iocmd.h index aedcefe4aac5..d61f596a394a 100644 --- a/drivers/staging/vt6655/iocmd.h +++ b/drivers/staging/vt6655/iocmd.h @@ -111,8 +111,8 @@ typedef enum tagWZONETYPE { typedef struct tagSCmdRequest { u8 name[16]; void *data; - U16 wResult; - U16 wCmdCode; + u16 wResult; + u16 wCmdCode; } SCmdRequest, *PSCmdRequest; // @@ -132,8 +132,8 @@ typedef struct tagSCmdScan { typedef struct tagSCmdBSSJoin { - U16 wBSSType; - U16 wBBPType; + u16 wBSSType; + u16 wBBPType; u8 ssid[SSID_MAXLEN + 2]; U32 uChannel; BOOL bPSEnable; @@ -164,8 +164,8 @@ typedef struct tagSWPAResult { typedef struct tagSCmdStartAP { - U16 wBSSType; - U16 wBBPType; + u16 wBSSType; + u16 wBBPType; u8 ssid[SSID_MAXLEN + 2]; U32 uChannel; U32 uBeaconInt; @@ -193,12 +193,12 @@ typedef struct tagSBSSIDItem { u8 abyBSSID[BSSID_LEN]; u8 abySSID[SSID_MAXLEN + 1]; //2006-1116-01, by NomadZhao - //U16 wBeaconInterval; - //U16 wCapInfo; + //u16 wBeaconInterval; + //u16 wCapInfo; //u8 byNetType; u8 byNetType; - U16 wBeaconInterval; - U16 wCapInfo; // for address of byNetType at align 4 + u16 wBeaconInterval; + u16 wCapInfo; // for address of byNetType at align 4 BOOL bWEPOn; U32 uRSSI; @@ -216,7 +216,7 @@ typedef struct tagSBSSIDList { typedef struct tagSCmdLinkStatus { BOOL bLink; - U16 wBSSType; + u16 wBSSType; u8 byState; u8 abyBSSID[BSSID_LEN]; u8 abySSID[SSID_MAXLEN + 2]; @@ -353,21 +353,21 @@ typedef struct tagSStatMIBCount { typedef struct tagSNodeItem { // STA info - U16 wAID; + u16 wAID; u8 abyMACAddr[6]; - U16 wTxDataRate; - U16 wInActiveCount; - U16 wEnQueueCnt; - U16 wFlags; + u16 wTxDataRate; + u16 wInActiveCount; + u16 wEnQueueCnt; + u16 wFlags; BOOL bPWBitOn; u8 byKeyIndex; - U16 wWepKeyLength; + u16 wWepKeyLength; u8 abyWepKey[WEP_KEYMAXLEN]; // Auto rate fallback vars BOOL bIsInFallback; U32 uTxFailures; U32 uTxAttempts; - U16 wFailureRatio; + u16 wFailureRatio; } SNodeItem; @@ -422,8 +422,8 @@ struct viawget_hostapd_param { u8 sta_addr[6]; union { struct { - U16 aid; - U16 capability; + u16 aid; + u16 capability; u8 tx_supp_rates; } add_sta; struct { @@ -435,7 +435,7 @@ struct viawget_hostapd_param { U32 err; u8 idx; u8 seq[8]; - U16 key_len; + u16 key_len; u8 key[0]; } crypt; struct { @@ -443,8 +443,8 @@ struct viawget_hostapd_param { U32 flags_or; } set_flags_sta; struct { - U16 rid; - U16 len; + u16 rid; + u16 len; u8 data[0]; } rid; struct { @@ -452,8 +452,8 @@ struct viawget_hostapd_param { u8 data[0]; } generic_elem; struct { - U16 cmd; - U16 reason_code; + u16 cmd; + u16 reason_code; } mlme; struct { u8 ssid_len; diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h index 105cabce97ab..fd1efeb62e68 100644 --- a/drivers/staging/vt6655/ttype.h +++ b/drivers/staging/vt6655/ttype.h @@ -68,7 +68,6 @@ typedef int BOOL; * but it doesn't matter if they're signed or unsigned. */ -typedef unsigned short U16; /* 16-bit unsigned integer */ typedef unsigned long U32; /* 32-bit unsigned integer */ From 902d2411298a6e0b8a473a0163aa4bf6d5c8a073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Fri, 28 May 2010 12:34:21 -0700 Subject: [PATCH 053/523] Staging: vt6655: remove U32 custom macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove custom macro for unsigned 32-bit integers, replace by u32. Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/desc.h | 12 +- drivers/staging/vt6655/device.h | 18 +-- drivers/staging/vt6655/device_main.c | 4 +- drivers/staging/vt6655/iocmd.h | 204 +++++++++++++-------------- drivers/staging/vt6655/iwctl.c | 2 +- drivers/staging/vt6655/ttype.h | 3 - 6 files changed, 120 insertions(+), 123 deletions(-) diff --git a/drivers/staging/vt6655/desc.h b/drivers/staging/vt6655/desc.h index d99b19a25b15..a16d2e0049dc 100644 --- a/drivers/staging/vt6655/desc.h +++ b/drivers/staging/vt6655/desc.h @@ -291,11 +291,11 @@ SRDES1; typedef struct tagSRxDesc { volatile SRDES0 m_rd0RD0; volatile SRDES1 m_rd1RD1; - volatile U32 buff_addr; - volatile U32 next_desc; + volatile u32 buff_addr; + volatile u32 next_desc; struct tagSRxDesc *next;//4 bytes volatile PDEVICE_RD_INFO pRDInfo;//4 bytes - volatile U32 Reserved[2];//8 bytes + volatile u32 Reserved[2];//8 bytes } __attribute__ ((__packed__)) SRxDesc, *PSRxDesc; typedef const SRxDesc *PCSRxDesc; @@ -378,11 +378,11 @@ static inline PDEVICE_TD_INFO alloc_td_info(void) { typedef struct tagSTxDesc { volatile STDES0 m_td0TD0; volatile STDES1 m_td1TD1; - volatile U32 buff_addr; - volatile U32 next_desc; + volatile u32 buff_addr; + volatile u32 next_desc; struct tagSTxDesc* next; //4 bytes volatile PDEVICE_TD_INFO pTDInfo;//4 bytes - volatile U32 Reserved[2];//8 bytes + volatile u32 Reserved[2];//8 bytes } __attribute__ ((__packed__)) STxDesc, *PSTxDesc; typedef const STxDesc *PCSTxDesc; diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index de1289196e74..0766a917237a 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -291,7 +291,7 @@ typedef struct __chip_info_tbl{ char* name; int io_size; int nTxQueue; - U32 flags; + u32 flags; } CHIP_INFO, *PCHIP_INFO; @@ -386,7 +386,7 @@ typedef struct __device_opt { int short_retry; int long_retry; int bbp_type; - U32 flags; + u32 flags; } OPTIONS, *POPTIONS; @@ -423,11 +423,11 @@ typedef struct __device_info { CHIP_TYPE chip_id; - U32 PortOffset; + u32 PortOffset; DWORD dwIsr; - U32 memaddr; - U32 ioaddr; - U32 io_size; + u32 memaddr; + u32 ioaddr; + u32 io_size; BYTE byRevId; WORD SubSystemID; @@ -454,9 +454,9 @@ typedef struct __device_info { OPTIONS sOpts; - U32 flags; + u32 flags; - U32 rx_buf_sz; + u32 rx_buf_sz; int multicast_limit; BYTE byRxMode; @@ -472,7 +472,7 @@ typedef struct __device_info { //PLICE_DEBUG <- - U32 rx_bytes; + u32 rx_bytes; // Version control BYTE byLocalID; diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 06585c1d3c83..38f93d6041f0 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -384,7 +384,7 @@ device_set_int_opt(int *opt, int val, int min, int max, int def,char* name,char* } static void -device_set_bool_opt(unsigned int *opt, int val,BOOL def,U32 flag, char* name,char* devname) { +device_set_bool_opt(unsigned int *opt, int val,BOOL def,u32 flag, char* name,char* devname) { (*opt)&=(~flag); if (val==-1) *opt|=(def ? flag : 0); @@ -976,7 +976,7 @@ device_found1(struct pci_dev *pcid, const struct pci_device_id *ent) printk("after get pci_info memaddr is %x, io addr is %x,io_size is %d\n",pDevice->memaddr,pDevice->ioaddr,pDevice->io_size); { int i; - U32 bar,len; + u32 bar,len; u32 address[] = { PCI_BASE_ADDRESS_0, PCI_BASE_ADDRESS_1, diff --git a/drivers/staging/vt6655/iocmd.h b/drivers/staging/vt6655/iocmd.h index d61f596a394a..3deaafae7df1 100644 --- a/drivers/staging/vt6655/iocmd.h +++ b/drivers/staging/vt6655/iocmd.h @@ -135,7 +135,7 @@ typedef struct tagSCmdBSSJoin { u16 wBSSType; u16 wBBPType; u8 ssid[SSID_MAXLEN + 2]; - U32 uChannel; + u32 uChannel; BOOL bPSEnable; BOOL bShareKeyAuth; @@ -167,8 +167,8 @@ typedef struct tagSCmdStartAP { u16 wBSSType; u16 wBBPType; u8 ssid[SSID_MAXLEN + 2]; - U32 uChannel; - U32 uBeaconInt; + u32 uChannel; + u32 uBeaconInt; BOOL bShareKeyAuth; u8 byBasicRate; @@ -181,7 +181,7 @@ typedef struct tagSCmdSetWEP { u8 byKeyIndex; u8 abyWepKey[WEP_NKEYS][WEP_KEYMAXLEN]; BOOL bWepKeyAvailable[WEP_NKEYS]; - U32 auWepKeyLength[WEP_NKEYS]; + u32 auWepKeyLength[WEP_NKEYS]; } SCmdSetWEP, *PSCmdSetWEP; @@ -189,7 +189,7 @@ typedef struct tagSCmdSetWEP { typedef struct tagSBSSIDItem { - U32 uChannel; + u32 uChannel; u8 abyBSSID[BSSID_LEN]; u8 abySSID[SSID_MAXLEN + 1]; //2006-1116-01, by NomadZhao @@ -201,14 +201,14 @@ typedef struct tagSBSSIDItem { u16 wCapInfo; // for address of byNetType at align 4 BOOL bWEPOn; - U32 uRSSI; + u32 uRSSI; } SBSSIDItem; typedef struct tagSBSSIDList { - U32 uItem; + u32 uItem; SBSSIDItem sBSSIDList[0]; } SBSSIDList, *PSBSSIDList; @@ -220,8 +220,8 @@ typedef struct tagSCmdLinkStatus { u8 byState; u8 abyBSSID[BSSID_LEN]; u8 abySSID[SSID_MAXLEN + 2]; - U32 uChannel; - U32 uLinkRate; + u32 uChannel; + u32 uLinkRate; } SCmdLinkStatus, *PSCmdLinkStatus; @@ -229,18 +229,18 @@ typedef struct tagSCmdLinkStatus { // 802.11 counter // typedef struct tagSDot11MIBCount { - U32 TransmittedFragmentCount; - U32 MulticastTransmittedFrameCount; - U32 FailedCount; - U32 RetryCount; - U32 MultipleRetryCount; - U32 RTSSuccessCount; - U32 RTSFailureCount; - U32 ACKFailureCount; - U32 FrameDuplicateCount; - U32 ReceivedFragmentCount; - U32 MulticastReceivedFrameCount; - U32 FCSErrorCount; + u32 TransmittedFragmentCount; + u32 MulticastTransmittedFrameCount; + u32 FailedCount; + u32 RetryCount; + u32 MultipleRetryCount; + u32 RTSSuccessCount; + u32 RTSFailureCount; + u32 ACKFailureCount; + u32 FrameDuplicateCount; + u32 ReceivedFragmentCount; + u32 MulticastReceivedFrameCount; + u32 FCSErrorCount; } SDot11MIBCount, *PSDot11MIBCount; @@ -252,102 +252,102 @@ typedef struct tagSStatMIBCount { // // ISR status count // - U32 dwIsrTx0OK; - U32 dwIsrTx1OK; - U32 dwIsrBeaconTxOK; - U32 dwIsrRxOK; - U32 dwIsrTBTTInt; - U32 dwIsrSTIMERInt; - U32 dwIsrUnrecoverableError; - U32 dwIsrSoftInterrupt; - U32 dwIsrRxNoBuf; + u32 dwIsrTx0OK; + u32 dwIsrTx1OK; + u32 dwIsrBeaconTxOK; + u32 dwIsrRxOK; + u32 dwIsrTBTTInt; + u32 dwIsrSTIMERInt; + u32 dwIsrUnrecoverableError; + u32 dwIsrSoftInterrupt; + u32 dwIsrRxNoBuf; ///////////////////////////////////// - U32 dwIsrUnknown; // unknown interrupt count + u32 dwIsrUnknown; // unknown interrupt count // RSR status count // - U32 dwRsrFrmAlgnErr; - U32 dwRsrErr; - U32 dwRsrCRCErr; - U32 dwRsrCRCOk; - U32 dwRsrBSSIDOk; - U32 dwRsrADDROk; - U32 dwRsrICVOk; - U32 dwNewRsrShortPreamble; - U32 dwRsrLong; - U32 dwRsrRunt; + u32 dwRsrFrmAlgnErr; + u32 dwRsrErr; + u32 dwRsrCRCErr; + u32 dwRsrCRCOk; + u32 dwRsrBSSIDOk; + u32 dwRsrADDROk; + u32 dwRsrICVOk; + u32 dwNewRsrShortPreamble; + u32 dwRsrLong; + u32 dwRsrRunt; - U32 dwRsrRxControl; - U32 dwRsrRxData; - U32 dwRsrRxManage; + u32 dwRsrRxControl; + u32 dwRsrRxData; + u32 dwRsrRxManage; - U32 dwRsrRxPacket; - U32 dwRsrRxOctet; - U32 dwRsrBroadcast; - U32 dwRsrMulticast; - U32 dwRsrDirected; + u32 dwRsrRxPacket; + u32 dwRsrRxOctet; + u32 dwRsrBroadcast; + u32 dwRsrMulticast; + u32 dwRsrDirected; // 64-bit OID - U32 ullRsrOK; + u32 ullRsrOK; // for some optional OIDs (64 bits) and DMI support - U32 ullRxBroadcastBytes; - U32 ullRxMulticastBytes; - U32 ullRxDirectedBytes; - U32 ullRxBroadcastFrames; - U32 ullRxMulticastFrames; - U32 ullRxDirectedFrames; + u32 ullRxBroadcastBytes; + u32 ullRxMulticastBytes; + u32 ullRxDirectedBytes; + u32 ullRxBroadcastFrames; + u32 ullRxMulticastFrames; + u32 ullRxDirectedFrames; - U32 dwRsrRxFragment; - U32 dwRsrRxFrmLen64; - U32 dwRsrRxFrmLen65_127; - U32 dwRsrRxFrmLen128_255; - U32 dwRsrRxFrmLen256_511; - U32 dwRsrRxFrmLen512_1023; - U32 dwRsrRxFrmLen1024_1518; + u32 dwRsrRxFragment; + u32 dwRsrRxFrmLen64; + u32 dwRsrRxFrmLen65_127; + u32 dwRsrRxFrmLen128_255; + u32 dwRsrRxFrmLen256_511; + u32 dwRsrRxFrmLen512_1023; + u32 dwRsrRxFrmLen1024_1518; // TSR0,1 status count // - U32 dwTsrTotalRetry[2]; // total collision retry count - U32 dwTsrOnceRetry[2]; // this packet only occur one collision - U32 dwTsrMoreThanOnceRetry[2]; // this packet occur more than one collision - U32 dwTsrRetry[2]; // this packet has ever occur collision, + u32 dwTsrTotalRetry[2]; // total collision retry count + u32 dwTsrOnceRetry[2]; // this packet only occur one collision + u32 dwTsrMoreThanOnceRetry[2]; // this packet occur more than one collision + u32 dwTsrRetry[2]; // this packet has ever occur collision, // that is (dwTsrOnceCollision0 + dwTsrMoreThanOnceCollision0) - U32 dwTsrACKData[2]; - U32 dwTsrErr[2]; - U32 dwAllTsrOK[2]; - U32 dwTsrRetryTimeout[2]; - U32 dwTsrTransmitTimeout[2]; + u32 dwTsrACKData[2]; + u32 dwTsrErr[2]; + u32 dwAllTsrOK[2]; + u32 dwTsrRetryTimeout[2]; + u32 dwTsrTransmitTimeout[2]; - U32 dwTsrTxPacket[2]; - U32 dwTsrTxOctet[2]; - U32 dwTsrBroadcast[2]; - U32 dwTsrMulticast[2]; - U32 dwTsrDirected[2]; + u32 dwTsrTxPacket[2]; + u32 dwTsrTxOctet[2]; + u32 dwTsrBroadcast[2]; + u32 dwTsrMulticast[2]; + u32 dwTsrDirected[2]; // RD/TD count - U32 dwCntRxFrmLength; - U32 dwCntTxBufLength; + u32 dwCntRxFrmLength; + u32 dwCntTxBufLength; - u8 abyCntRxPattern[16]; - u8 abyCntTxPattern[16]; + u8 abyCntRxPattern[16]; + u8 abyCntTxPattern[16]; // Software check.... - U32 dwCntRxDataErr; // rx buffer data software compare CRC err count - U32 dwCntDecryptErr; // rx buffer data software compare CRC err count - U32 dwCntRxICVErr; // rx buffer data software compare CRC err count - U32 idxRxErrorDesc; // index for rx data error RD + u32 dwCntRxDataErr; // rx buffer data software compare CRC err count + u32 dwCntDecryptErr; // rx buffer data software compare CRC err count + u32 dwCntRxICVErr; // rx buffer data software compare CRC err count + u32 idxRxErrorDesc; // index for rx data error RD // 64-bit OID - U32 ullTsrOK[2]; + u32 ullTsrOK[2]; // for some optional OIDs (64 bits) and DMI support - U32 ullTxBroadcastFrames[2]; - U32 ullTxMulticastFrames[2]; - U32 ullTxDirectedFrames[2]; - U32 ullTxBroadcastBytes[2]; - U32 ullTxMulticastBytes[2]; - U32 ullTxDirectedBytes[2]; + u32 ullTxBroadcastFrames[2]; + u32 ullTxMulticastFrames[2]; + u32 ullTxDirectedFrames[2]; + u32 ullTxBroadcastBytes[2]; + u32 ullTxMulticastBytes[2]; + u32 ullTxDirectedBytes[2]; } SStatMIBCount, *PSStatMIBCount; @@ -365,8 +365,8 @@ typedef struct tagSNodeItem { u8 abyWepKey[WEP_KEYMAXLEN]; // Auto rate fallback vars BOOL bIsInFallback; - U32 uTxFailures; - U32 uTxAttempts; + u32 uTxFailures; + u32 uTxAttempts; u16 wFailureRatio; } SNodeItem; @@ -374,7 +374,7 @@ typedef struct tagSNodeItem { typedef struct tagSNodeList { - U32 uItem; + u32 uItem; SNodeItem sNodeList[0]; } SNodeList, *PSNodeList; @@ -383,7 +383,7 @@ typedef struct tagSNodeList { typedef struct tagSCmdValue { - U32 dwValue; + u32 dwValue; } SCmdValue, *PSCmdValue; @@ -418,7 +418,7 @@ enum { struct viawget_hostapd_param { - U32 cmd; + u32 cmd; u8 sta_addr[6]; union { struct { @@ -427,20 +427,20 @@ struct viawget_hostapd_param { u8 tx_supp_rates; } add_sta; struct { - U32 inactive_sec; + u32 inactive_sec; } get_info_sta; struct { u8 alg; - U32 flags; - U32 err; + u32 flags; + u32 err; u8 idx; u8 seq[8]; u16 key_len; u8 key[0]; } crypt; struct { - U32 flags_and; - U32 flags_or; + u32 flags_and; + u32 flags_or; } set_flags_sta; struct { u16 rid; diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c index 00564535c9a3..f778e7d670cc 100644 --- a/drivers/staging/vt6655/iwctl.c +++ b/drivers/staging/vt6655/iwctl.c @@ -116,7 +116,7 @@ struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev) pDevice->wstats.discard.nwid = 0; pDevice->wstats.discard.code = 0; pDevice->wstats.discard.fragment = 0; - pDevice->wstats.discard.retries = (U32)pDevice->scStatistic.dwTsrErr; + pDevice->wstats.discard.retries = (u32)pDevice->scStatistic.dwTsrErr; pDevice->wstats.discard.misc = 0; pDevice->wstats.miss.beacon = 0; diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h index fd1efeb62e68..4974703bab9d 100644 --- a/drivers/staging/vt6655/ttype.h +++ b/drivers/staging/vt6655/ttype.h @@ -68,9 +68,6 @@ typedef int BOOL; * but it doesn't matter if they're signed or unsigned. */ -typedef unsigned long U32; /* 32-bit unsigned integer */ - - typedef char CHAR; typedef signed short SHORT; typedef signed int INT; From 5a4197bdda7914558fdc24f63d4ed6c64c5e54b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Tue, 1 Jun 2010 12:38:54 -0700 Subject: [PATCH 054/523] Staging: vt6655: removed custom CHAR typedef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/country.h | 2 +- drivers/staging/vt6655/device.h | 4 ++-- drivers/staging/vt6655/ttype.h | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6655/country.h b/drivers/staging/vt6655/country.h index 2005d2768680..3206feec8b34 100644 --- a/drivers/staging/vt6655/country.h +++ b/drivers/staging/vt6655/country.h @@ -162,7 +162,7 @@ typedef enum _COUNTRY_CODE { typedef struct tagSCountryTable { BYTE byChannelCountryCode; /* The country code */ - CHAR chCountryCode[2]; + char chCountryCode[2]; BYTE bChannelIdxList[CB_MAX_CHANNEL]; /* Available channels Index */ BYTE byPower[CB_MAX_CHANNEL]; } SCountryTable, *PSCountryTable; diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 0766a917237a..4ea94a7d5ff5 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -686,8 +686,8 @@ typedef struct __device_info { SHORT sPSetPointOFDMA; LONG lPFormulaOffset; SHORT sPThreshold; - CHAR cAdjustStep; - CHAR cMinTxAGC; + char cAdjustStep; + char cMinTxAGC; // For RF Power table BYTE byCCKPwr; diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h index 4974703bab9d..1be30d8108a7 100644 --- a/drivers/staging/vt6655/ttype.h +++ b/drivers/staging/vt6655/ttype.h @@ -68,7 +68,6 @@ typedef int BOOL; * but it doesn't matter if they're signed or unsigned. */ -typedef char CHAR; typedef signed short SHORT; typedef signed int INT; typedef signed long LONG; From 0c93a98a0e9073e0ffa7aea1e515a5e146e798a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Tue, 1 Jun 2010 12:38:55 -0700 Subject: [PATCH 055/523] Staging: vt6655: removed custom SHORT typedef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 8 ++++---- drivers/staging/vt6655/ttype.h | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 4ea94a7d5ff5..5f4efb5904db 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -681,11 +681,11 @@ typedef struct __device_info { // For Auto Power Tunning BYTE byAutoPwrTunning; - SHORT sPSetPointCCK; - SHORT sPSetPointOFDMG; - SHORT sPSetPointOFDMA; + short sPSetPointCCK; + short sPSetPointOFDMG; + short sPSetPointOFDMA; LONG lPFormulaOffset; - SHORT sPThreshold; + short sPThreshold; char cAdjustStep; char cMinTxAGC; diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h index 1be30d8108a7..52f1a0c2adc7 100644 --- a/drivers/staging/vt6655/ttype.h +++ b/drivers/staging/vt6655/ttype.h @@ -68,7 +68,6 @@ typedef int BOOL; * but it doesn't matter if they're signed or unsigned. */ -typedef signed short SHORT; typedef signed int INT; typedef signed long LONG; From 7ca3019525e6e3ba727e36dfdc07d8e8d487a5e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Tue, 1 Jun 2010 12:38:56 -0700 Subject: [PATCH 056/523] Staging: vt6655: remove custom INT typedef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 2 +- drivers/staging/vt6655/device_main.c | 38 ++++++++++++++-------------- drivers/staging/vt6655/dpc.c | 16 ++++++------ drivers/staging/vt6655/mib.c | 26 +++++++++---------- drivers/staging/vt6655/ttype.h | 1 - drivers/staging/vt6655/wmgr.c | 2 +- 6 files changed, 42 insertions(+), 43 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index b972130f7e96..f6ecbadc7f36 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -2362,7 +2362,7 @@ CARDbyAutoChannelSelect( // PSDevice pDevice = (PSDevice) pDeviceHandler; UINT ii = 0; BYTE byOptionChannel = 0; - INT aiWeight[CB_MAX_CHANNEL_24G+1] = {-1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + int aiWeight[CB_MAX_CHANNEL_24G+1] = {-1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; if (ePHYType == PHY_TYPE_11A) { for(ii=CB_MAX_CHANNEL_24G+1;ii<=CB_MAX_CHANNEL;ii++) { diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 38f93d6041f0..3c1ae3962173 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -464,18 +464,18 @@ pDevice->bUpdateBBVGA = TRUE; pDevice->byPreambleType = 0; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" uChannel= %d\n",(INT)pDevice->uChannel); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" byOpMode= %d\n",(INT)pDevice->byOpMode); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" ePSMode= %d\n",(INT)pDevice->ePSMode); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" wRTSThreshold= %d\n",(INT)pDevice->wRTSThreshold); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" byShortRetryLimit= %d\n",(INT)pDevice->byShortRetryLimit); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" byLongRetryLimit= %d\n",(INT)pDevice->byLongRetryLimit); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" byPreambleType= %d\n",(INT)pDevice->byPreambleType); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" byShortPreamble= %d\n",(INT)pDevice->byShortPreamble); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" uConnectionRate= %d\n",(INT)pDevice->uConnectionRate); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" byBBType= %d\n",(INT)pDevice->byBBType); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->b11hEnable= %d\n",(INT)pDevice->b11hEnable); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->bDiversityRegCtlON= %d\n",(INT)pDevice->bDiversityRegCtlON); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" uChannel= %d\n",(int)pDevice->uChannel); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" byOpMode= %d\n",(int)pDevice->byOpMode); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" ePSMode= %d\n",(int)pDevice->ePSMode); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" wRTSThreshold= %d\n",(int)pDevice->wRTSThreshold); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" byShortRetryLimit= %d\n",(int)pDevice->byShortRetryLimit); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" byLongRetryLimit= %d\n",(int)pDevice->byLongRetryLimit); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" byPreambleType= %d\n",(int)pDevice->byPreambleType); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" byShortPreamble= %d\n",(int)pDevice->byShortPreamble); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" uConnectionRate= %d\n",(int)pDevice->uConnectionRate); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" byBBType= %d\n",(int)pDevice->byBBType); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->b11hEnable= %d\n",(int)pDevice->b11hEnable); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" pDevice->bDiversityRegCtlON= %d\n",(int)pDevice->bDiversityRegCtlON); } static void s_vCompleteCurrentMeasure (PSDevice pDevice, BYTE byResult) @@ -530,7 +530,7 @@ static void device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) BYTE byValue1; BYTE byCCKPwrdBm = 0; BYTE byOFDMPwrdBm = 0; - INT zonetype=0; + int zonetype=0; PSMgmtObject pMgmt = &(pDevice->sMgmtObj); MACbShutdown(pDevice->PortOffset); BBvSoftwareReset(pDevice->PortOffset); @@ -1710,7 +1710,7 @@ static int device_tx_srv(PSDevice pDevice, UINT uIdx) { if ( !(byTsr1 & TSR1_TERR)) { if (byTsr0 != 0) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Tx[%d] OK but has error. tsr1[%02X] tsr0[%02X].\n", - (INT)uIdx, byTsr1, byTsr0); + (int)uIdx, byTsr1, byTsr0); } if ((pTxBufHead->wFragCtl & FRAGCTL_ENDFRAG) != FRAGCTL_NONFRAG) { pDevice->s802_11Counter.TransmittedFragmentCount ++; @@ -1720,7 +1720,7 @@ static int device_tx_srv(PSDevice pDevice, UINT uIdx) { } else { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Tx[%d] dropped & tsr1[%02X] tsr0[%02X].\n", - (INT)uIdx, byTsr1, byTsr0); + (int)uIdx, byTsr1, byTsr0); pStats->tx_errors++; pStats->tx_dropped++; } @@ -1742,11 +1742,11 @@ static int device_tx_srv(PSDevice pDevice, UINT uIdx) { if (byTsr1 & TSR1_TERR) { if ((pTD->pTDInfo->byFlags & TD_FLAGS_PRIV_SKB) != 0) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Tx[%d] fail has error. tsr1[%02X] tsr0[%02X].\n", - (INT)uIdx, byTsr1, byTsr0); + (int)uIdx, byTsr1, byTsr0); } // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" Tx[%d] fail has error. tsr1[%02X] tsr0[%02X].\n", -// (INT)uIdx, byTsr1, byTsr0); +// (int)uIdx, byTsr1, byTsr0); if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) && (pTD->pTDInfo->byFlags & TD_FLAGS_NETIF_SKB)) { @@ -1763,7 +1763,7 @@ static int device_tx_srv(PSDevice pDevice, UINT uIdx) { pMgmt->abyPSTxMap[wAID >> 3] |= byMask[wAID & 7]; pTD->pTDInfo->byFlags &= ~(TD_FLAGS_NETIF_SKB); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "tx_srv:tx fail re-queue sta index= %d, QueCnt= %d\n" - ,(INT)uNodeIndex, pMgmt->sNodeDBTable[uNodeIndex].wEnQueueCnt); + ,(int)uNodeIndex, pMgmt->sNodeDBTable[uNodeIndex].wEnQueueCnt); pStats->tx_errors--; pStats->tx_dropped--; } @@ -1844,7 +1844,7 @@ void InitRxManagementQueue(PSDevice pDevice) //PLICE_DEBUG -> -INT MlmeThread( +int MlmeThread( void * Context) { PSDevice pDevice = (PSDevice) Context; diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index 535e033427a9..e00999fb8107 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -101,7 +101,7 @@ s_vProcessRxMACHeader ( static BOOL s_bAPModeRxCtl( PSDevice pDevice, PBYTE pbyFrame, - INT iSANodeIndex + int iSANodeIndex ); @@ -111,8 +111,8 @@ static BOOL s_bAPModeRxData ( struct sk_buff* skb, UINT FrameSize, UINT cbHeaderOffset, - INT iSANodeIndex, - INT iDANodeIndex + int iSANodeIndex, + int iDANodeIndex ); @@ -360,8 +360,8 @@ device_receive_frame ( UINT cbHeaderOffset; UINT FrameSize; WORD wEtherType = 0; - INT iSANodeIndex = -1; - INT iDANodeIndex = -1; + int iSANodeIndex = -1; + int iDANodeIndex = -1; UINT ii; UINT cbIVOffset; BOOL bExtIV = FALSE; @@ -1041,7 +1041,7 @@ device_receive_frame ( static BOOL s_bAPModeRxCtl ( PSDevice pDevice, PBYTE pbyFrame, - INT iSANodeIndex + int iSANodeIndex ) { PS802_11Header p802_11Header; @@ -1444,8 +1444,8 @@ static BOOL s_bAPModeRxData ( struct sk_buff* skb, UINT FrameSize, UINT cbHeaderOffset, - INT iSANodeIndex, - INT iDANodeIndex + int iSANodeIndex, + int iDANodeIndex ) { PSMgmtObject pMgmt = pDevice->pMgmt; diff --git a/drivers/staging/vt6655/mib.c b/drivers/staging/vt6655/mib.c index 7f7dc7e7e247..b4e916f2c650 100644 --- a/drivers/staging/vt6655/mib.c +++ b/drivers/staging/vt6655/mib.c @@ -212,87 +212,87 @@ void STAvUpdateRDStatCounter (PSStatCounter pStatistic, if(byRSR & RSR_CRCOK) { pStatistic->CustomStat.ullRsr11MCRCOk++; } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"11M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr11M, (INT)pStatistic->CustomStat.ullRsr11MCRCOk, byRSR); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"11M: ALL[%d], OK[%d]:[%02x]\n", (int)pStatistic->CustomStat.ullRsr11M, (int)pStatistic->CustomStat.ullRsr11MCRCOk, byRSR); } else if(byRxRate==11) { pStatistic->CustomStat.ullRsr5M++; if(byRSR & RSR_CRCOK) { pStatistic->CustomStat.ullRsr5MCRCOk++; } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 5M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr5M, (INT)pStatistic->CustomStat.ullRsr5MCRCOk, byRSR); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 5M: ALL[%d], OK[%d]:[%02x]\n", (int)pStatistic->CustomStat.ullRsr5M, (int)pStatistic->CustomStat.ullRsr5MCRCOk, byRSR); } else if(byRxRate==4) { pStatistic->CustomStat.ullRsr2M++; if(byRSR & RSR_CRCOK) { pStatistic->CustomStat.ullRsr2MCRCOk++; } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 2M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr2M, (INT)pStatistic->CustomStat.ullRsr2MCRCOk, byRSR); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 2M: ALL[%d], OK[%d]:[%02x]\n", (int)pStatistic->CustomStat.ullRsr2M, (int)pStatistic->CustomStat.ullRsr2MCRCOk, byRSR); } else if(byRxRate==2){ pStatistic->CustomStat.ullRsr1M++; if(byRSR & RSR_CRCOK) { pStatistic->CustomStat.ullRsr1MCRCOk++; } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 1M: ALL[%d], OK[%d]:[%02x]\n", (INT)pStatistic->CustomStat.ullRsr1M, (INT)pStatistic->CustomStat.ullRsr1MCRCOk, byRSR); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 1M: ALL[%d], OK[%d]:[%02x]\n", (int)pStatistic->CustomStat.ullRsr1M, (int)pStatistic->CustomStat.ullRsr1MCRCOk, byRSR); } else if(byRxRate==12){ pStatistic->CustomStat.ullRsr6M++; if(byRSR & RSR_CRCOK) { pStatistic->CustomStat.ullRsr6MCRCOk++; } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 6M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr6M, (INT)pStatistic->CustomStat.ullRsr6MCRCOk); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 6M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr6M, (int)pStatistic->CustomStat.ullRsr6MCRCOk); } else if(byRxRate==18){ pStatistic->CustomStat.ullRsr9M++; if(byRSR & RSR_CRCOK) { pStatistic->CustomStat.ullRsr9MCRCOk++; } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 9M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr9M, (INT)pStatistic->CustomStat.ullRsr9MCRCOk); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO" 9M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr9M, (int)pStatistic->CustomStat.ullRsr9MCRCOk); } else if(byRxRate==24){ pStatistic->CustomStat.ullRsr12M++; if(byRSR & RSR_CRCOK) { pStatistic->CustomStat.ullRsr12MCRCOk++; } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"12M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr12M, (INT)pStatistic->CustomStat.ullRsr12MCRCOk); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"12M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr12M, (int)pStatistic->CustomStat.ullRsr12MCRCOk); } else if(byRxRate==36){ pStatistic->CustomStat.ullRsr18M++; if(byRSR & RSR_CRCOK) { pStatistic->CustomStat.ullRsr18MCRCOk++; } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"18M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr18M, (INT)pStatistic->CustomStat.ullRsr18MCRCOk); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"18M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr18M, (int)pStatistic->CustomStat.ullRsr18MCRCOk); } else if(byRxRate==48){ pStatistic->CustomStat.ullRsr24M++; if(byRSR & RSR_CRCOK) { pStatistic->CustomStat.ullRsr24MCRCOk++; } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"24M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr24M, (INT)pStatistic->CustomStat.ullRsr24MCRCOk); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"24M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr24M, (int)pStatistic->CustomStat.ullRsr24MCRCOk); } else if(byRxRate==72){ pStatistic->CustomStat.ullRsr36M++; if(byRSR & RSR_CRCOK) { pStatistic->CustomStat.ullRsr36MCRCOk++; } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"36M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr36M, (INT)pStatistic->CustomStat.ullRsr36MCRCOk); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"36M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr36M, (int)pStatistic->CustomStat.ullRsr36MCRCOk); } else if(byRxRate==96){ pStatistic->CustomStat.ullRsr48M++; if(byRSR & RSR_CRCOK) { pStatistic->CustomStat.ullRsr48MCRCOk++; } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"48M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr48M, (INT)pStatistic->CustomStat.ullRsr48MCRCOk); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"48M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr48M, (int)pStatistic->CustomStat.ullRsr48MCRCOk); } else if(byRxRate==108){ pStatistic->CustomStat.ullRsr54M++; if(byRSR & RSR_CRCOK) { pStatistic->CustomStat.ullRsr54MCRCOk++; } - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"54M: ALL[%d], OK[%d]\n", (INT)pStatistic->CustomStat.ullRsr54M, (INT)pStatistic->CustomStat.ullRsr54MCRCOk); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"54M: ALL[%d], OK[%d]\n", (int)pStatistic->CustomStat.ullRsr54M, (int)pStatistic->CustomStat.ullRsr54MCRCOk); } else { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Unknown: Total[%d], CRCOK[%d]\n", (INT)pStatistic->dwRsrRxPacket+1, (INT)pStatistic->dwRsrCRCOk); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Unknown: Total[%d], CRCOK[%d]\n", (int)pStatistic->dwRsrRxPacket+1, (int)pStatistic->dwRsrCRCOk); } if (byRSR & RSR_BSSIDOK) diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h index 52f1a0c2adc7..9ccef04cab59 100644 --- a/drivers/staging/vt6655/ttype.h +++ b/drivers/staging/vt6655/ttype.h @@ -68,7 +68,6 @@ typedef int BOOL; * but it doesn't matter if they're signed or unsigned. */ -typedef signed int INT; typedef signed long LONG; typedef unsigned char UCHAR; diff --git a/drivers/staging/vt6655/wmgr.c b/drivers/staging/vt6655/wmgr.c index 56e15a19675e..d9980f17055b 100644 --- a/drivers/staging/vt6655/wmgr.c +++ b/drivers/staging/vt6655/wmgr.c @@ -3077,7 +3077,7 @@ s_vMgrSynchBSS ( pMgmt->uCurrChannel = pCurr->uChannel; pMgmt->eCurrentPHYMode = ePhyType; pMgmt->byERPContext = pCurr->sERP.byERP; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Sync:Set to channel = [%d]\n", (INT)pCurr->uChannel); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Sync:Set to channel = [%d]\n", (int)pCurr->uChannel); *pStatus = CMD_STATUS_SUCCESS; From b83cc2ed466f1b9938521d73fefe8b34baf265ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Tue, 1 Jun 2010 12:38:57 -0700 Subject: [PATCH 057/523] Staging: vt6655: remove custom LONG typedef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/bssdb.c | 6 +++--- drivers/staging/vt6655/bssdb.h | 6 +++--- drivers/staging/vt6655/device.h | 4 ++-- drivers/staging/vt6655/device_main.c | 2 +- drivers/staging/vt6655/dpc.c | 4 ++-- drivers/staging/vt6655/ioctl.c | 2 +- drivers/staging/vt6655/mib.h | 12 ++++++------ drivers/staging/vt6655/rf.c | 4 ++-- drivers/staging/vt6655/ttype.h | 2 -- 9 files changed, 20 insertions(+), 22 deletions(-) diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c index d07241af7c08..16aaedca8c25 100644 --- a/drivers/staging/vt6655/bssdb.c +++ b/drivers/staging/vt6655/bssdb.c @@ -609,7 +609,7 @@ BSSbUpdateToBSSList ( PSDevice pDevice = (PSDevice)hDeviceContext; PSMgmtObject pMgmt = pDevice->pMgmt; PSRxMgmtPacket pRxPacket = (PSRxMgmtPacket)pRxPacketContext; - LONG ldBm; + long ldBm; BOOL bParsingQuiet = FALSE; PWLAN_IE_QUIET pQuiet = NULL; @@ -1629,8 +1629,8 @@ void s_vCheckSensitivity( pBSSList = BSSpAddrIsInBSSList(pDevice, pMgmt->abyCurrBSSID, (PWLAN_IE_SSID)pMgmt->abyCurrSSID); if (pBSSList != NULL) { // Updata BB Reg if RSSI is too strong. - LONG LocalldBmAverage = 0; - LONG uNumofdBm = 0; + long LocalldBmAverage = 0; + long uNumofdBm = 0; for (ii = 0; ii < RSSI_STAT_COUNT; ii++) { if (pBSSList->ldBmAverage[ii] != 0) { uNumofdBm ++; diff --git a/drivers/staging/vt6655/bssdb.h b/drivers/staging/vt6655/bssdb.h index e09ef8762979..6a98834d7516 100644 --- a/drivers/staging/vt6655/bssdb.h +++ b/drivers/staging/vt6655/bssdb.h @@ -118,9 +118,9 @@ typedef struct tagKnownBSS { // WORD wATIMWindow; BYTE byRSSIStatCnt; - LONG ldBmMAX; - LONG ldBmAverage[RSSI_STAT_COUNT]; - LONG ldBmAverRange; + long ldBmMAX; + long ldBmAverage[RSSI_STAT_COUNT]; + long ldBmAverRange; //For any BSSID selection improvment BOOL bSelected; diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 5f4efb5904db..5dc081f560d8 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -666,7 +666,7 @@ typedef struct __device_info { BYTE byBBVGANew; BYTE byBBVGACurrent; BYTE abyBBVGA[BB_VGA_LEVEL]; - LONG ldBmThreshold[BB_VGA_LEVEL]; + long ldBmThreshold[BB_VGA_LEVEL]; BYTE byBBPreEDRSSI; BYTE byBBPreEDIndex; @@ -684,7 +684,7 @@ typedef struct __device_info { short sPSetPointCCK; short sPSetPointOFDMG; short sPSetPointOFDMA; - LONG lPFormulaOffset; + long lPFormulaOffset; short sPThreshold; char cAdjustStep; char cMinTxAGC; diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 3c1ae3962173..a84c9199e854 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -2830,7 +2830,7 @@ static irqreturn_t device_intr(int irq, void *dev_instance) { //pDevice->bBeaconSent = FALSE; } else { if ((pDevice->bUpdateBBVGA) && (pDevice->bLinkPass == TRUE) && (pDevice->uCurrRSSI != 0)) { - LONG ldBm; + long ldBm; RFvRSSITodBm(pDevice, (BYTE) pDevice->uCurrRSSI, &ldBm); for (ii=0;iiwResult = 0; diff --git a/drivers/staging/vt6655/mib.h b/drivers/staging/vt6655/mib.h index 2308319a4051..190fc475e5d5 100644 --- a/drivers/staging/vt6655/mib.h +++ b/drivers/staging/vt6655/mib.h @@ -72,15 +72,15 @@ typedef struct tagSDot11Counters { // MIB2 counter // typedef struct tagSMib2Counter { - LONG ifIndex; + long ifIndex; char ifDescr[256]; // max size 255 plus zero ending // e.g. "interface 1" - LONG ifType; - LONG ifMtu; + long ifType; + long ifMtu; DWORD ifSpeed; BYTE ifPhysAddress[ETH_ALEN]; - LONG ifAdminStatus; - LONG ifOperStatus; + long ifAdminStatus; + long ifOperStatus; DWORD ifLastChange; DWORD ifInOctets; DWORD ifInUcastPkts; @@ -111,7 +111,7 @@ typedef struct tagSMib2Counter { // RMON counter // typedef struct tagSRmonCounter { - LONG etherStatsIndex; + long etherStatsIndex; DWORD etherStatsDataSource; DWORD etherStatsDropEvents; DWORD etherStatsOctets; diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c index 7cb86fe2eeb9..4f2c01bceb76 100644 --- a/drivers/staging/vt6655/rf.c +++ b/drivers/staging/vt6655/rf.c @@ -1209,8 +1209,8 @@ RFvRSSITodBm ( ) { BYTE byIdx = (((byCurrRSSI & 0xC0) >> 6) & 0x03); - LONG b = (byCurrRSSI & 0x3F); - LONG a = 0; + long b = (byCurrRSSI & 0x3F); + long a = 0; BYTE abyAIROHARF[4] = {0, 18, 0, 40}; switch (pDevice->byRFType) { diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h index 9ccef04cab59..302829af6ebe 100644 --- a/drivers/staging/vt6655/ttype.h +++ b/drivers/staging/vt6655/ttype.h @@ -68,8 +68,6 @@ typedef int BOOL; * but it doesn't matter if they're signed or unsigned. */ -typedef signed long LONG; - typedef unsigned char UCHAR; typedef unsigned short USHORT; typedef unsigned int UINT; From 5c9824e124f67c2590e1dbd33045603c36168609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Wed, 2 Jun 2010 09:51:59 -0700 Subject: [PATCH 058/523] Staging: vt6655: remove custom UCHAR typedef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 2 +- drivers/staging/vt6655/device_main.c | 14 ++++++++------ drivers/staging/vt6655/ttype.h | 1 - drivers/staging/vt6655/wmgr.h | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 5dc081f560d8..915dd901fc93 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -218,7 +218,7 @@ typedef enum __device_init_type { #define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED 0x01 // PMKID Structures -typedef UCHAR NDIS_802_11_PMKID_VALUE[16]; +typedef unsigned char NDIS_802_11_PMKID_VALUE[16]; typedef enum _NDIS_802_11_WEP_STATUS diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index a84c9199e854..32d38931a5e2 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -340,7 +340,8 @@ static void device_free_rd0_ring(PSDevice pDevice); static void device_free_rd1_ring(PSDevice pDevice); static void device_free_rings(PSDevice pDevice); static void device_free_frag_buf(PSDevice pDevice); -static int Config_FileGetParameter(UCHAR *string, UCHAR *dest,UCHAR *source); +static int Config_FileGetParameter(unsigned char *string, + unsigned char *dest, unsigned char *source); /*--------------------- Export Variables --------------------------*/ @@ -2978,9 +2979,10 @@ static inline u32 ether_crc(int length, unsigned char *data) } //2008-8-4 by chester -static int Config_FileGetParameter(UCHAR *string, UCHAR *dest,UCHAR *source) +static int Config_FileGetParameter(unsigned char *string, + unsigned char *dest, unsigned char *source) { - UCHAR buf1[100]; + unsigned char buf1[100]; int source_len = strlen(source); memset(buf1,0,100); @@ -2993,9 +2995,9 @@ static int Config_FileGetParameter(UCHAR *string, UCHAR *dest,UCHAR *source) } int Config_FileOperation(PSDevice pDevice,BOOL fwrite,unsigned char *Parameter) { - UCHAR *config_path=CONFIG_PATH; - UCHAR *buffer=NULL; - UCHAR tmpbuffer[20]; + unsigned char *config_path = CONFIG_PATH; + unsigned char *buffer = NULL; + unsigned char tmpbuffer[20]; struct file *filp=NULL; mm_segment_t old_fs = get_fs(); //int oldfsuid=0,oldfsgid=0; diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h index 302829af6ebe..74ec69f822fe 100644 --- a/drivers/staging/vt6655/ttype.h +++ b/drivers/staging/vt6655/ttype.h @@ -68,7 +68,6 @@ typedef int BOOL; * but it doesn't matter if they're signed or unsigned. */ -typedef unsigned char UCHAR; typedef unsigned short USHORT; typedef unsigned int UINT; typedef unsigned long ULONG; diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index 9ae7e0d55bc4..d53aed7ad526 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -88,7 +88,7 @@ typedef void (*TimerFunction)(ULONG); //+++ NDIS related -typedef UCHAR NDIS_802_11_MAC_ADDRESS[6]; +typedef unsigned char NDIS_802_11_MAC_ADDRESS[6]; typedef struct _NDIS_802_11_AI_REQFI { USHORT Capabilities; From 800acdbdf83efe6a2b4dbe61e3ab676b5c99d153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Wed, 2 Jun 2010 09:52:00 -0700 Subject: [PATCH 059/523] Staging: vt6655: remove custom USHORT typedef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/ttype.h | 1 - drivers/staging/vt6655/wmgr.h | 14 +++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h index 74ec69f822fe..eaf77d5348e4 100644 --- a/drivers/staging/vt6655/ttype.h +++ b/drivers/staging/vt6655/ttype.h @@ -68,7 +68,6 @@ typedef int BOOL; * but it doesn't matter if they're signed or unsigned. */ -typedef unsigned short USHORT; typedef unsigned int UINT; typedef unsigned long ULONG; typedef unsigned long long ULONGLONG; //64 bit diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index d53aed7ad526..9367f478dbf6 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -91,26 +91,26 @@ typedef void (*TimerFunction)(ULONG); typedef unsigned char NDIS_802_11_MAC_ADDRESS[6]; typedef struct _NDIS_802_11_AI_REQFI { - USHORT Capabilities; - USHORT ListenInterval; + unsigned short Capabilities; + unsigned short ListenInterval; NDIS_802_11_MAC_ADDRESS CurrentAPAddress; } NDIS_802_11_AI_REQFI, *PNDIS_802_11_AI_REQFI; typedef struct _NDIS_802_11_AI_RESFI { - USHORT Capabilities; - USHORT StatusCode; - USHORT AssociationId; + unsigned short Capabilities; + unsigned short StatusCode; + unsigned short AssociationId; } NDIS_802_11_AI_RESFI, *PNDIS_802_11_AI_RESFI; typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION { ULONG Length; - USHORT AvailableRequestFixedIEs; + unsigned short AvailableRequestFixedIEs; NDIS_802_11_AI_REQFI RequestFixedIEs; ULONG RequestIELength; ULONG OffsetRequestIEs; - USHORT AvailableResponseFixedIEs; + unsigned short AvailableResponseFixedIEs; NDIS_802_11_AI_RESFI ResponseFixedIEs; ULONG ResponseIELength; ULONG OffsetResponseIEs; From b6e95cd52a81079abc1def7867e27bf541953089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Wed, 2 Jun 2010 09:52:01 -0700 Subject: [PATCH 060/523] Staging: vt6655: remove custom UINT typedef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/80211mgr.h | 48 +++--- drivers/staging/vt6655/IEEE11h.c | 5 +- drivers/staging/vt6655/baseband.c | 26 +-- drivers/staging/vt6655/baseband.h | 6 +- drivers/staging/vt6655/bssdb.c | 66 +++---- drivers/staging/vt6655/bssdb.h | 44 ++--- drivers/staging/vt6655/card.c | 71 ++++---- drivers/staging/vt6655/card.h | 14 +- drivers/staging/vt6655/datarate.c | 12 +- drivers/staging/vt6655/datarate.h | 2 +- drivers/staging/vt6655/device.h | 60 +++---- drivers/staging/vt6655/device_main.c | 40 ++--- drivers/staging/vt6655/dpc.c | 40 ++--- drivers/staging/vt6655/hostap.c | 12 +- drivers/staging/vt6655/ioctl.c | 6 +- drivers/staging/vt6655/iwctl.c | 8 +- drivers/staging/vt6655/key.c | 12 +- drivers/staging/vt6655/mac.c | 41 +++-- drivers/staging/vt6655/mac.h | 25 +-- drivers/staging/vt6655/mib.c | 12 +- drivers/staging/vt6655/mib.h | 11 +- drivers/staging/vt6655/michael.c | 8 +- drivers/staging/vt6655/michael.h | 2 +- drivers/staging/vt6655/power.c | 4 +- drivers/staging/vt6655/rc4.c | 22 +-- drivers/staging/vt6655/rc4.h | 10 +- drivers/staging/vt6655/rf.c | 8 +- drivers/staging/vt6655/rf.h | 6 +- drivers/staging/vt6655/rxtx.c | 248 +++++++++++++-------------- drivers/staging/vt6655/rxtx.h | 20 +-- drivers/staging/vt6655/tcrc.c | 6 +- drivers/staging/vt6655/tcrc.h | 6 +- drivers/staging/vt6655/tether.c | 2 +- drivers/staging/vt6655/tether.h | 2 +- drivers/staging/vt6655/ttype.h | 1 - drivers/staging/vt6655/vntwifi.c | 20 +-- drivers/staging/vt6655/vntwifi.h | 4 +- drivers/staging/vt6655/wcmd.c | 12 +- drivers/staging/vt6655/wcmd.h | 2 +- drivers/staging/vt6655/wctl.c | 16 +- drivers/staging/vt6655/wctl.h | 7 +- drivers/staging/vt6655/wmgr.c | 66 +++---- drivers/staging/vt6655/wmgr.h | 30 ++-- drivers/staging/vt6655/wpa2.c | 4 +- drivers/staging/vt6655/wpa2.h | 2 +- drivers/staging/vt6655/wroute.c | 10 +- drivers/staging/vt6655/wroute.h | 2 +- 47 files changed, 544 insertions(+), 537 deletions(-) diff --git a/drivers/staging/vt6655/80211mgr.h b/drivers/staging/vt6655/80211mgr.h index 658fe144f898..b6ee8220f1f6 100644 --- a/drivers/staging/vt6655/80211mgr.h +++ b/drivers/staging/vt6655/80211mgr.h @@ -495,8 +495,8 @@ typedef struct _WLAN_IE_IBSS_DFS { // prototype structure, all mgmt frame types will start with these members typedef struct tagWLAN_FR_MGMT { - UINT uType; - UINT len; + unsigned int uType; + unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; @@ -505,8 +505,8 @@ typedef struct tagWLAN_FR_MGMT { // Beacon frame typedef struct tagWLAN_FR_BEACON { - UINT uType; - UINT len; + unsigned int uType; + unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; // fixed fields @@ -537,8 +537,8 @@ typedef struct tagWLAN_FR_BEACON { // IBSS ATIM frame typedef struct tagWLAN_FR_IBSSATIM { - UINT uType; - UINT len; + unsigned int uType; + unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; @@ -551,8 +551,8 @@ typedef struct tagWLAN_FR_IBSSATIM { // Disassociation typedef struct tagWLAN_FR_DISASSOC { - UINT uType; - UINT len; + unsigned int uType; + unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ @@ -564,8 +564,8 @@ typedef struct tagWLAN_FR_DISASSOC { // Association Request typedef struct tagWLAN_FR_ASSOCREQ { - UINT uType; - UINT len; + unsigned int uType; + unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ @@ -585,8 +585,8 @@ typedef struct tagWLAN_FR_ASSOCREQ { // Association Response typedef struct tagWLAN_FR_ASSOCRESP { - UINT uType; - UINT len; + unsigned int uType; + unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ @@ -602,8 +602,8 @@ typedef struct tagWLAN_FR_ASSOCRESP { // Reassociation Request typedef struct tagWLAN_FR_REASSOCREQ { - UINT uType; - UINT len; + unsigned int uType; + unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; @@ -624,8 +624,8 @@ typedef struct tagWLAN_FR_REASSOCREQ { // Reassociation Response typedef struct tagWLAN_FR_REASSOCRESP { - UINT uType; - UINT len; + unsigned int uType; + unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ @@ -641,8 +641,8 @@ typedef struct tagWLAN_FR_REASSOCRESP { // Probe Request typedef struct tagWLAN_FR_PROBEREQ { - UINT uType; - UINT len; + unsigned int uType; + unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ @@ -656,8 +656,8 @@ typedef struct tagWLAN_FR_PROBEREQ { // Probe Response typedef struct tagWLAN_FR_PROBERESP { - UINT uType; - UINT len; + unsigned int uType; + unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ @@ -685,8 +685,8 @@ typedef struct tagWLAN_FR_PROBERESP { // Authentication typedef struct tagWLAN_FR_AUTHEN { - UINT uType; - UINT len; + unsigned int uType; + unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ @@ -701,8 +701,8 @@ typedef struct tagWLAN_FR_AUTHEN { // Deauthenication typedef struct tagWLAN_FR_DEAUTHEN { - UINT uType; - UINT len; + unsigned int uType; + unsigned int len; PBYTE pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ diff --git a/drivers/staging/vt6655/IEEE11h.c b/drivers/staging/vt6655/IEEE11h.c index 22f12f5ef90c..55e66e9e0dde 100644 --- a/drivers/staging/vt6655/IEEE11h.c +++ b/drivers/staging/vt6655/IEEE11h.c @@ -97,7 +97,8 @@ typedef struct _WLAN_FRAME_TPCREP { /*--------------------- Static Variables --------------------------*/ /*--------------------- Static Functions --------------------------*/ -static BOOL s_bRxMSRReq(PSMgmtObject pMgmt, PWLAN_FRAME_MSRREQ pMSRReq, UINT uLength) +static BOOL s_bRxMSRReq(PSMgmtObject pMgmt, PWLAN_FRAME_MSRREQ pMSRReq, + unsigned int uLength) { size_t uNumOfEIDs = 0; BOOL bResult = TRUE; @@ -209,7 +210,7 @@ IEEE11hbMgrRxAction ( { PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle; PWLAN_FRAME_ACTION pAction = NULL; - UINT uLength = 0; + unsigned int uLength = 0; PWLAN_IE_CH_SW pChannelSwitch = NULL; diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index 5414c6c6c050..2fe91b87666a 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -1776,19 +1776,19 @@ s_vChangeAntenna ( * Return Value: FrameTime * */ -UINT +unsigned int BBuGetFrameTime ( BYTE byPreambleType, BYTE byPktType, - UINT cbFrameLength, + unsigned int cbFrameLength, WORD wRate ) { - UINT uFrameTime; - UINT uPreamble; - UINT uTmp; - UINT uRateIdx = (UINT)wRate; - UINT uRate = 0; + unsigned int uFrameTime; + unsigned int uPreamble; + unsigned int uTmp; + unsigned int uRateIdx = (unsigned int) wRate; + unsigned int uRate = 0; if (uRateIdx > RATE_54M) { @@ -1796,7 +1796,7 @@ BBuGetFrameTime ( return 0; } - uRate = (UINT)awcFrameTime[uRateIdx]; + uRate = (unsigned int) awcFrameTime[uRateIdx]; if (uRateIdx <= 3) { //CCK mode @@ -1846,7 +1846,7 @@ BBuGetFrameTime ( void BBvCaculateParameter ( PSDevice pDevice, - UINT cbFrameLength, + unsigned int cbFrameLength, WORD wRate, BYTE byPacketType, PWORD pwPhyLen, @@ -1854,9 +1854,9 @@ BBvCaculateParameter ( PBYTE pbyPhySgn ) { - UINT cbBitCount; - UINT cbUsCount = 0; - UINT cbTmp; + unsigned int cbBitCount; + unsigned int cbUsCount = 0; + unsigned int cbTmp; BOOL bExtBit; BYTE byPreambleType = pDevice->byPreambleType; BOOL bCCK = pDevice->bCCK; @@ -2762,7 +2762,7 @@ ULONG ulPacketNum; void BBvClearAntDivSQ3Value (PSDevice pDevice) { - UINT ii; + unsigned int ii; pDevice->uDiversityCnt = 0; for (ii = 0; ii < MAX_RATE; ii++) { diff --git a/drivers/staging/vt6655/baseband.h b/drivers/staging/vt6655/baseband.h index b236ff4139a0..3372546662d9 100644 --- a/drivers/staging/vt6655/baseband.h +++ b/drivers/staging/vt6655/baseband.h @@ -118,18 +118,18 @@ /*--------------------- Export Functions --------------------------*/ -UINT +unsigned int BBuGetFrameTime( BYTE byPreambleType, BYTE byPktType, - UINT cbFrameLength, + unsigned int cbFrameLength, WORD wRate ); void BBvCaculateParameter ( PSDevice pDevice, - UINT cbFrameLength, + unsigned int cbFrameLength, WORD wRate, BYTE byPacketType, PWORD pwPhyLen, diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c index 16aaedca8c25..e919b2954a52 100644 --- a/drivers/staging/vt6655/bssdb.c +++ b/drivers/staging/vt6655/bssdb.c @@ -138,8 +138,8 @@ BSSpSearchBSSList( PKnownBSS pCurrBSS = NULL; PKnownBSS pSelect = NULL; BYTE ZeroBSSID[WLAN_BSSID_LEN]={0x00,0x00,0x00,0x00,0x00,0x00}; - UINT ii = 0; -// UINT jj = 0; //DavidWang + unsigned int ii = 0; + if (pbyDesireBSSID != NULL) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BSSpSearchBSSList BSSID[%02X %02X %02X-%02X %02X %02X]\n", *pbyDesireBSSID,*(pbyDesireBSSID+1),*(pbyDesireBSSID+2), @@ -288,7 +288,7 @@ BSSvClearBSSList( { PSDevice pDevice = (PSDevice)hDeviceContext; PSMgmtObject pMgmt = pDevice->pMgmt; - UINT ii; + unsigned int ii; for (ii = 0; ii < MAX_BSS_NUM; ii++) { if (bKeepCurrBSSID) { @@ -333,7 +333,7 @@ BSSpAddrIsInBSSList( PSDevice pDevice = (PSDevice)hDeviceContext; PSMgmtObject pMgmt = pDevice->pMgmt; PKnownBSS pBSSList = NULL; - UINT ii; + unsigned int ii; for (ii = 0; ii < MAX_BSS_NUM; ii++) { pBSSList = &(pMgmt->sBSSList[ii]); @@ -382,7 +382,7 @@ BSSbInsertToBSSList ( PWLAN_IE_RSN_EXT pRSNWPA, PWLAN_IE_COUNTRY pIE_Country, PWLAN_IE_QUIET pIE_Quiet, - UINT uIELength, + unsigned int uIELength, PBYTE pbyIEs, void *pRxPacketContext ) @@ -392,7 +392,7 @@ BSSbInsertToBSSList ( PSMgmtObject pMgmt = pDevice->pMgmt; PSRxMgmtPacket pRxPacket = (PSRxMgmtPacket)pRxPacketContext; PKnownBSS pBSSList = NULL; - UINT ii; + unsigned int ii; BOOL bParsingQuiet = FALSE; PWLAN_IE_QUIET pQuiet = NULL; @@ -468,9 +468,9 @@ BSSbInsertToBSSList ( WPA_ClearRSN(pBSSList); if (pRSNWPA != NULL) { - UINT uLen = pRSNWPA->len + 2; + unsigned int uLen = pRSNWPA->len + 2; - if (uLen <= (uIELength - (UINT)(ULONG_PTR)((PBYTE)pRSNWPA - pbyIEs))) { + if (uLen <= (uIELength - (unsigned int)(ULONG_PTR)((PBYTE)pRSNWPA - pbyIEs))) { pBSSList->wWPALen = uLen; memcpy(pBSSList->byWPAIE, pRSNWPA, uLen); WPA_ParseRSN(pBSSList, pRSNWPA); @@ -480,8 +480,8 @@ BSSbInsertToBSSList ( WPA2_ClearRSN(pBSSList); if (pRSN != NULL) { - UINT uLen = pRSN->len + 2; - if (uLen <= (uIELength - (UINT)(ULONG_PTR)((PBYTE)pRSN - pbyIEs))) { + unsigned int uLen = pRSN->len + 2; + if (uLen <= (uIELength - (unsigned int)(ULONG_PTR)((PBYTE)pRSN - pbyIEs))) { pBSSList->wRSNLen = uLen; memcpy(pBSSList->byRSNIE, pRSN, uLen); WPA2vParseRSN(pBSSList, pRSN); @@ -600,7 +600,7 @@ BSSbUpdateToBSSList ( PWLAN_IE_COUNTRY pIE_Country, PWLAN_IE_QUIET pIE_Quiet, PKnownBSS pBSSList, - UINT uIELength, + unsigned int uIELength, PBYTE pbyIEs, void *pRxPacketContext ) @@ -670,8 +670,8 @@ BSSbUpdateToBSSList ( WPA_ClearRSN(pBSSList); //mike update if (pRSNWPA != NULL) { - UINT uLen = pRSNWPA->len + 2; - if (uLen <= (uIELength - (UINT)(ULONG_PTR)((PBYTE)pRSNWPA - pbyIEs))) { + unsigned int uLen = pRSNWPA->len + 2; + if (uLen <= (uIELength - (unsigned int)(ULONG_PTR)((PBYTE)pRSNWPA - pbyIEs))) { pBSSList->wWPALen = uLen; memcpy(pBSSList->byWPAIE, pRSNWPA, uLen); WPA_ParseRSN(pBSSList, pRSNWPA); @@ -681,8 +681,8 @@ BSSbUpdateToBSSList ( WPA2_ClearRSN(pBSSList); //mike update if (pRSN != NULL) { - UINT uLen = pRSN->len + 2; - if (uLen <= (uIELength - (UINT)(ULONG_PTR)((PBYTE)pRSN - pbyIEs))) { + unsigned int uLen = pRSN->len + 2; + if (uLen <= (uIELength - (unsigned int)(ULONG_PTR)((PBYTE)pRSN - pbyIEs))) { pBSSList->wRSNLen = uLen; memcpy(pBSSList->byRSNIE, pRSN, uLen); WPA2vParseRSN(pBSSList, pRSN); @@ -770,7 +770,7 @@ BSSDBbIsSTAInNodeDB( ) { PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject; - UINT ii; + unsigned int ii; // Index = 0 reserved for AP Node for (ii = 1; ii < (MAX_NODE_NUM + 1); ii++) { @@ -806,9 +806,9 @@ BSSvCreateOneNode( PSDevice pDevice = (PSDevice)hDeviceContext; PSMgmtObject pMgmt = pDevice->pMgmt; - UINT ii; - UINT BigestCount = 0; - UINT SelectIndex; + unsigned int ii; + unsigned int BigestCount = 0; + unsigned int SelectIndex; struct sk_buff *skb; // Index = 0 reserved for AP Node (In STA mode) // Index = 0 reserved for Broadcast/MultiCast (In AP mode) @@ -865,7 +865,7 @@ BSSvCreateOneNode( void BSSvRemoveOneNode( void *hDeviceContext, - UINT uNodeIndex + unsigned int uNodeIndex ) { @@ -905,7 +905,7 @@ BSSvUpdateAPNode( { PSDevice pDevice = (PSDevice)hDeviceContext; PSMgmtObject pMgmt = pDevice->pMgmt; - UINT uRateLen = WLAN_RATES_MAXLEN; + unsigned int uRateLen = WLAN_RATES_MAXLEN; memset(&pMgmt->sNodeDBTable[0], 0, sizeof(KnownNodeDB)); @@ -1009,7 +1009,7 @@ BSSvAddMulticastNode( //2008-4-14 by chester for led issue #ifdef FOR_LED_ON_NOTEBOOK BOOL cc=FALSE; -UINT status; +unsigned int status; #endif void BSSvSecondCallBack( @@ -1018,11 +1018,11 @@ BSSvSecondCallBack( { PSDevice pDevice = (PSDevice)hDeviceContext; PSMgmtObject pMgmt = pDevice->pMgmt; - UINT ii; + unsigned int ii; PWLAN_IE_SSID pItemSSID, pCurrSSID; - UINT uSleepySTACnt = 0; - UINT uNonShortSlotSTACnt = 0; - UINT uLongPreambleSTACnt = 0; + unsigned int uSleepySTACnt = 0; + unsigned int uNonShortSlotSTACnt = 0; + unsigned int uLongPreambleSTACnt = 0; viawget_wpa_header* wpahdr; //DavidWang spin_lock_irq(&pDevice->lock); @@ -1394,20 +1394,20 @@ BSSvUpdateNodeTxCounter( BYTE byTsr0, BYTE byTsr1, PBYTE pbyBuffer, - UINT uFIFOHeaderSize + unsigned int uFIFOHeaderSize ) { PSDevice pDevice = (PSDevice)hDeviceContext; PSMgmtObject pMgmt = pDevice->pMgmt; - UINT uNodeIndex = 0; + unsigned int uNodeIndex = 0; BYTE byTxRetry = (byTsr0 & TSR0_NCR); PSTxBufHead pTxBufHead; PS802_11Header pMACHeader; WORD wRate; WORD wFallBackRate = RATE_1M; BYTE byFallBack; - UINT ii; -// UINT txRetryTemp; + unsigned int ii; +// unsigned int txRetryTemp; //PLICE_DEBUG-> //txRetryTemp = byTxRetry; //if (txRetryTemp== 8) @@ -1584,14 +1584,14 @@ BSSvUpdateNodeTxCounter( void BSSvClearNodeDBTable( void *hDeviceContext, - UINT uStartIndex + unsigned int uStartIndex ) { PSDevice pDevice = (PSDevice)hDeviceContext; PSMgmtObject pMgmt = pDevice->pMgmt; struct sk_buff *skb; - UINT ii; + unsigned int ii; for (ii = uStartIndex; ii < (MAX_NODE_NUM + 1); ii++) { if (pMgmt->sNodeDBTable[ii].bActive) { @@ -1666,7 +1666,7 @@ BSSvClearAnyBSSJoinRecord ( { PSDevice pDevice = (PSDevice)hDeviceContext; PSMgmtObject pMgmt = pDevice->pMgmt; - UINT ii; + unsigned int ii; for (ii = 0; ii < MAX_BSS_NUM; ii++) { pMgmt->sBSSList[ii].bSelected = FALSE; diff --git a/drivers/staging/vt6655/bssdb.h b/drivers/staging/vt6655/bssdb.h index 6a98834d7516..c7283d208dfb 100644 --- a/drivers/staging/vt6655/bssdb.h +++ b/drivers/staging/vt6655/bssdb.h @@ -106,10 +106,10 @@ typedef struct tagKnownBSS { // BSS info BOOL bActive; BYTE abyBSSID[WLAN_BSSID_LEN]; - UINT uChannel; + unsigned int uChannel; BYTE abySuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; BYTE abyExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; - UINT uRSSI; + unsigned int uRSSI; BYTE bySQ; WORD wBeaconInterval; WORD wCapInfo; @@ -150,9 +150,9 @@ typedef struct tagKnownBSS { WORD wRSNLen; // Clear count - UINT uClearCount; + unsigned int uClearCount; // BYTE abyIEs[WLAN_BEACON_FR_MAXLEN]; - UINT uIELength; + unsigned int uIELength; QWORD qwBSSTimestamp; QWORD qwLocalTSF; // local TSF timer @@ -189,7 +189,7 @@ typedef struct tagKnownNodeDB { BOOL bShortPreamble; BOOL bERPExist; BOOL bShortSlotTime; - UINT uInActiveCount; + unsigned int uInActiveCount; WORD wMaxBasicRate; //Get from byTopOFDMBasicRate or byTopCCKBasicRate which depends on packetTyp. WORD wMaxSuppRate; //Records the highest supported rate getting from SuppRates IE and ExtSuppRates IE in Beacon. WORD wSuppRate; @@ -217,23 +217,23 @@ typedef struct tagKnownNodeDB { BYTE byCipherSuite; DWORD dwTSC47_16; WORD wTSC15_0; - UINT uWepKeyLength; + unsigned int uWepKeyLength; BYTE abyWepKey[WLAN_WEPMAX_KEYLEN]; // // Auto rate fallback vars BOOL bIsInFallback; - UINT uAverageRSSI; - UINT uRateRecoveryTimeout; - UINT uRatePollTimeout; - UINT uTxFailures; - UINT uTxAttempts; + unsigned int uAverageRSSI; + unsigned int uRateRecoveryTimeout; + unsigned int uRatePollTimeout; + unsigned int uTxFailures; + unsigned int uTxAttempts; - UINT uTxRetry; - UINT uFailureRatio; - UINT uRetryRatio; - UINT uTxOk[MAX_RATE+1]; - UINT uTxFail[MAX_RATE+1]; - UINT uTimeCount; + unsigned int uTxRetry; + unsigned int uFailureRatio; + unsigned int uRetryRatio; + unsigned int uTxOk[MAX_RATE+1]; + unsigned int uTxFail[MAX_RATE+1]; + unsigned int uTimeCount; } KnownNodeDB, *PKnownNodeDB; @@ -279,7 +279,7 @@ BSSbInsertToBSSList( PWLAN_IE_RSN_EXT pRSNWPA, PWLAN_IE_COUNTRY pIE_Country, PWLAN_IE_QUIET pIE_Quiet, - UINT uIELength, + unsigned int uIELength, PBYTE pbyIEs, void *pRxPacketContext ); @@ -302,7 +302,7 @@ BSSbUpdateToBSSList( PWLAN_IE_COUNTRY pIE_Country, PWLAN_IE_QUIET pIE_Quiet, PKnownBSS pBSSList, - UINT uIELength, + unsigned int uIELength, PBYTE pbyIEs, void *pRxPacketContext ); @@ -342,13 +342,13 @@ BSSvUpdateNodeTxCounter( BYTE byTsr0, BYTE byTsr1, PBYTE pbyBuffer, - UINT uFIFOHeaderSize + unsigned int uFIFOHeaderSize ); void BSSvRemoveOneNode( void *hDeviceContext, - UINT uNodeIndex + unsigned int uNodeIndex ); void @@ -360,7 +360,7 @@ BSSvAddMulticastNode( void BSSvClearNodeDBTable( void *hDeviceContext, - UINT uStartIndex + unsigned int uStartIndex ); void diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index f6ecbadc7f36..439bb0c4ca68 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -82,7 +82,7 @@ static int msglevel =MSG_LEVEL_INFO; typedef struct tagSChannelTblElement { BYTE byChannelNumber; - UINT uFrequency; + unsigned int uFrequency; BOOL bValid; BYTE byMAP; }SChannelTblElement, *PSChannelTblElement; @@ -457,7 +457,7 @@ s_vCaculateOFDMRParameter( ************************************************************************/ //2008-8-4 by chester BOOL -ChannelValid(UINT ChannelIndex) +ChannelValid(unsigned int ChannelIndex) { BOOL bValid; @@ -729,7 +729,7 @@ s_vSetRSPINF (PSDevice pDevice, CARD_PHY_TYPE ePHYType, void *pvSupportRateIEs, /*--------------------- Export Functions --------------------------*/ BYTE CARDbyGetChannelMapping (void *pDeviceHandler, BYTE byChannelNumber, CARD_PHY_TYPE ePhyType) { - UINT ii; + unsigned int ii; if ((ePhyType == PHY_TYPE_11B) || (ePhyType == PHY_TYPE_11G)) { return (byChannelNumber); @@ -764,7 +764,7 @@ BYTE CARDbyGetChannelNumber (void *pDeviceHandler, BYTE byChannelIndex) * Return Value: TRUE if succeeded; FALSE if failed. * */ -BOOL CARDbSetChannel (void *pDeviceHandler, UINT uConnectionChannel) +BOOL CARDbSetChannel (void *pDeviceHandler, unsigned int uConnectionChannel) { PSDevice pDevice = (PSDevice) pDeviceHandler; BOOL bResult = TRUE; @@ -852,7 +852,7 @@ BOOL CARDbSetChannel (void *pDeviceHandler, UINT uConnectionChannel) * */ /* -BOOL CARDbSendPacket (void *pDeviceHandler, void *pPacket, CARD_PKT_TYPE ePktType, UINT uLength) +BOOL CARDbSendPacket (void *pDeviceHandler, void *pPacket, CARD_PKT_TYPE ePktType, unsigned int uLength) { PSDevice pDevice = (PSDevice) pDeviceHandler; if (ePktType == PKT_TYPE_802_11_MNG) { @@ -1145,10 +1145,10 @@ BOOL CARDbUpdateTSF (void *pDeviceHandler, BYTE byRxRate, QWORD qwBSSTimestamp, BOOL CARDbSetBeaconPeriod (void *pDeviceHandler, WORD wBeaconInterval) { PSDevice pDevice = (PSDevice) pDeviceHandler; - UINT uBeaconInterval = 0; - UINT uLowNextTBTT = 0; - UINT uHighRemain = 0; - UINT uLowRemain = 0; + unsigned int uBeaconInterval = 0; + unsigned int uLowNextTBTT = 0; + unsigned int uHighRemain = 0; + unsigned int uLowRemain = 0; QWORD qwNextTBTT; HIDWORD(qwNextTBTT) = 0; @@ -1396,7 +1396,7 @@ CARDbPowerDown( ) { PSDevice pDevice = (PSDevice)pDeviceHandler; - UINT uIdx; + unsigned int uIdx; // check if already in Doze mode if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) @@ -1557,7 +1557,7 @@ CARDbAdd_PMKID_Candidate ( { PSDevice pDevice = (PSDevice) pDeviceHandler; PPMKID_CANDIDATE pCandidateList; - UINT ii = 0; + unsigned int ii = 0; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"bAdd_PMKID_Candidate START: (%d)\n", (int)pDevice->gsPMKIDCandidate.NumCandidates); @@ -1614,7 +1614,7 @@ void CARDvInitChannelTable (void *pDeviceHandler) { PSDevice pDevice = (PSDevice) pDeviceHandler; BOOL bMultiBand = FALSE; - UINT ii; + unsigned int ii; for(ii=1;ii<=CARD_MAX_CHANNEL_TBL;ii++) { sChannelTbl[ii].bValid = FALSE; @@ -1709,7 +1709,7 @@ BOOL CARDbStartMeasure ( void *pDeviceHandler, void *pvMeasureEIDs, - UINT uNumOfMeasureEIDs + unsigned int uNumOfMeasureEIDs ) { PSDevice pDevice = (PSDevice) pDeviceHandler; @@ -1886,7 +1886,7 @@ CARDbSetQuiet ( ) { PSDevice pDevice = (PSDevice) pDeviceHandler; - UINT ii = 0; + unsigned int ii = 0; if (bResetQuiet == TRUE) { MACvRegBitsOff(pDevice->PortOffset, MAC_REG_MSRCTL, (MSRCTL_QUIETTXCHK | MSRCTL_QUIETEN)); @@ -1937,9 +1937,9 @@ CARDbStartQuiet ( ) { PSDevice pDevice = (PSDevice) pDeviceHandler; - UINT ii = 0; + unsigned int ii = 0; DWORD dwStartTime = 0xFFFFFFFF; - UINT uCurrentQuietIndex = 0; + unsigned int uCurrentQuietIndex = 0; DWORD dwNextTime = 0; DWORD dwGap = 0; DWORD dwDuration = 0; @@ -2040,10 +2040,10 @@ CARDvSetCountryInfo ( ) { PSDevice pDevice = (PSDevice) pDeviceHandler; - UINT ii = 0; - UINT uu = 0; - UINT step = 0; - UINT uNumOfCountryInfo = 0; + unsigned int ii = 0; + unsigned int uu = 0; + unsigned int step = 0; + unsigned int uNumOfCountryInfo = 0; BYTE byCh = 0; PWLAN_IE_COUNTRY pIE_Country = (PWLAN_IE_COUNTRY) pIE; @@ -2169,7 +2169,7 @@ CARDbySetSupportChannels ( ) { PSDevice pDevice = (PSDevice) pDeviceHandler; - UINT ii; + unsigned int ii; BYTE byCount; PWLAN_IE_SUPP_CH pIE = (PWLAN_IE_SUPP_CH) pbyIEs; PBYTE pbyChTupple; @@ -2266,7 +2266,7 @@ CARDbyGetTransmitPower ( BOOL CARDbChannelGetList ( - UINT uCountryCodeIdx, + unsigned int uCountryCodeIdx, PBYTE pbyChannelTable ) { @@ -2285,7 +2285,7 @@ CARDvSetCountryIE( ) { PSDevice pDevice = (PSDevice) pDeviceHandler; - UINT ii; + unsigned int ii; PWLAN_IE_COUNTRY pIECountry = (PWLAN_IE_COUNTRY) pIE; pIECountry->byElementID = WLAN_EID_COUNTRY; @@ -2307,7 +2307,7 @@ CARDvSetCountryIE( BOOL CARDbGetChannelMapInfo( void *pDeviceHandler, - UINT uChannelIndex, + unsigned int uChannelIndex, PBYTE pbyChannelNumber, PBYTE pbyMap ) @@ -2326,7 +2326,7 @@ CARDbGetChannelMapInfo( void CARDvSetChannelMapInfo( void *pDeviceHandler, - UINT uChannelIndex, + unsigned int uChannelIndex, BYTE byMap ) { @@ -2345,7 +2345,7 @@ CARDvClearChannelMapInfo( ) { // PSDevice pDevice = (PSDevice) pDeviceHandler; - UINT ii = 0; + unsigned int ii = 0; for (ii = 1; ii <= CB_MAX_CHANNEL; ii++) { sChannelTbl[ii].byMAP = 0; @@ -2360,7 +2360,7 @@ CARDbyAutoChannelSelect( ) { // PSDevice pDevice = (PSDevice) pDeviceHandler; - UINT ii = 0; + unsigned int ii = 0; BYTE byOptionChannel = 0; int aiWeight[CB_MAX_CHANNEL_24G+1] = {-1000,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; @@ -2425,7 +2425,7 @@ CARDvSafeResetTx ( ) { PSDevice pDevice = (PSDevice) pDeviceHandler; - UINT uu; + unsigned int uu; PSTxDesc pCurrTD; // initialize TD index @@ -2481,7 +2481,7 @@ CARDvSafeResetRx ( ) { PSDevice pDevice = (PSDevice) pDeviceHandler; - UINT uu; + unsigned int uu; PSRxDesc pDesc; @@ -2539,7 +2539,7 @@ CARDvSafeResetRx ( WORD CARDwGetCCKControlRate(void *pDeviceHandler, WORD wRateIdx) { PSDevice pDevice = (PSDevice) pDeviceHandler; - UINT ui = (UINT)wRateIdx; + unsigned int ui = (unsigned int) wRateIdx; while (ui > RATE_1M) { if (pDevice->wBasicRate & ((WORD)1 << ui)) { @@ -2566,7 +2566,7 @@ WORD CARDwGetCCKControlRate(void *pDeviceHandler, WORD wRateIdx) WORD CARDwGetOFDMControlRate (void *pDeviceHandler, WORD wRateIdx) { PSDevice pDevice = (PSDevice) pDeviceHandler; - UINT ui = (UINT)wRateIdx; + unsigned int ui = (unsigned int) wRateIdx; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BASIC RATE: %X\n", pDevice->wBasicRate); @@ -3002,9 +3002,9 @@ BOOL CARDbGetCurrentTSF (DWORD_PTR dwIoBase, PQWORD pqwCurrTSF) QWORD CARDqGetNextTBTT (QWORD qwTSF, WORD wBeaconInterval) { - UINT uLowNextTBTT; - UINT uHighRemain, uLowRemain; - UINT uBeaconInterval; + unsigned int uLowNextTBTT; + unsigned int uHighRemain, uLowRemain; + unsigned int uBeaconInterval; uBeaconInterval = wBeaconInterval * 1024; // Next TBTT = ((local_current_TSF / beacon_interval) + 1 ) * beacon_interval @@ -3084,7 +3084,8 @@ void CARDvUpdateNextTBTT (DWORD_PTR dwIoBase, QWORD qwTSF, WORD wBeaconInterval) VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT, LODWORD(qwTSF)); VNSvOutPortD(dwIoBase + MAC_REG_NEXTTBTT + 4, HIDWORD(qwTSF)); MACvRegBitsOn(dwIoBase, MAC_REG_TFTCTL, TFTCTL_TBTTSYNCEN); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Card:Update Next TBTT[%8xh:%8xh] \n",(UINT)HIDWORD(qwTSF), (UINT)LODWORD(qwTSF)); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Card:Update Next TBTT[%8xh:%8xh] \n", + (unsigned int) HIDWORD(qwTSF), (unsigned int) LODWORD(qwTSF)); return; } diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index 00dce0310b5d..f2f79407f4ab 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -86,7 +86,7 @@ typedef enum _CARD_OP_MODE { /*--------------------- Export Functions --------------------------*/ -BOOL ChannelValid(UINT ChannelIndex); +BOOL ChannelValid(unsigned int ChannelIndex); void CARDvSetRSPINF(void *pDeviceHandler, CARD_PHY_TYPE ePHYType); void vUpdateIFS(void *pDeviceHandler); void CARDvUpdateBasicTopRate(void *pDeviceHandler); @@ -107,8 +107,8 @@ void CARDvSafeResetRx(void *pDeviceHandler); //xxx BOOL CARDbRadioPowerOff(void *pDeviceHandler); BOOL CARDbRadioPowerOn(void *pDeviceHandler); -BOOL CARDbSetChannel(void *pDeviceHandler, UINT uConnectionChannel); -//BOOL CARDbSendPacket(void *pDeviceHandler, void *pPacket, CARD_PKT_TYPE ePktType, UINT uLength); +BOOL CARDbSetChannel(void *pDeviceHandler, unsigned int uConnectionChannel); +//BOOL CARDbSendPacket(void *pDeviceHandler, void *pPacket, CARD_PKT_TYPE ePktType, unsigned int uLength); BOOL CARDbIsShortPreamble(void *pDeviceHandler); BOOL CARDbIsShorSlotTime(void *pDeviceHandler); BOOL CARDbSetPhyParameter(void *pDeviceHandler, CARD_PHY_TYPE ePHYType, WORD wCapInfo, BYTE byERPField, void *pvSupportRateIEs, void *pvExtSupportRateIEs); @@ -152,7 +152,7 @@ BOOL CARDbStartMeasure ( void *pDeviceHandler, void *pvMeasureEIDs, - UINT uNumOfMeasureEIDs + unsigned int uNumOfMeasureEIDs ); BOOL @@ -212,7 +212,7 @@ CARDbyGetTransmitPower ( BOOL CARDbChannelGetList ( - UINT uCountryCodeIdx, + unsigned int uCountryCodeIdx, PBYTE pbyChannelTable ); @@ -225,7 +225,7 @@ CARDvSetCountryIE( BOOL CARDbGetChannelMapInfo( void *pDeviceHandler, - UINT uChannelIndex, + unsigned int uChannelIndex, PBYTE pbyChannelNumber, PBYTE pbyMap ); @@ -233,7 +233,7 @@ CARDbGetChannelMapInfo( void CARDvSetChannelMapInfo( void *pDeviceHandler, - UINT uChannelIndex, + unsigned int uChannelIndex, BYTE byMap ); diff --git a/drivers/staging/vt6655/datarate.c b/drivers/staging/vt6655/datarate.c index 38b09a7fb53b..ecec01ea0807 100644 --- a/drivers/staging/vt6655/datarate.c +++ b/drivers/staging/vt6655/datarate.c @@ -208,11 +208,11 @@ RATEvParseMaxRate ( ) { PSDevice pDevice = (PSDevice) pDeviceHandler; -UINT ii; +unsigned int ii; BYTE byHighSuppRate = 0; BYTE byRate = 0; WORD wOldBasicRate = pDevice->wBasicRate; -UINT uRateLen; +unsigned int uRateLen; if (pItemRates == NULL) @@ -248,7 +248,7 @@ UINT uRateLen; if ((pItemExtRates != NULL) && (pItemExtRates->byElementID == WLAN_EID_EXTSUPP_RATES) && (pDevice->eCurrentPHYType != PHY_TYPE_11B)) { - UINT uExtRateLen = pItemExtRates->len; + unsigned int uExtRateLen = pItemExtRates->len; if (uExtRateLen > WLAN_RATES_MAXLEN) uExtRateLen = WLAN_RATES_MAXLEN; @@ -315,7 +315,7 @@ RATEvTxRateFallBack ( { PSDevice pDevice = (PSDevice) pDeviceHandler; WORD wIdxDownRate = 0; -UINT ii; +unsigned int ii; //DWORD dwRateTable[MAX_RATE] = {1, 2, 5, 11, 6, 9, 12, 18, 24, 36, 48, 54}; BOOL bAutoRate[MAX_RATE] = {TRUE,TRUE,TRUE,TRUE,FALSE,FALSE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE}; DWORD dwThroughputTbl[MAX_RATE] = {10, 20, 55, 110, 60, 90, 120, 180, 240, 360, 480, 540}; @@ -413,10 +413,10 @@ BYTE RATEuSetIE ( PWLAN_IE_SUPP_RATES pSrcRates, PWLAN_IE_SUPP_RATES pDstRates, - UINT uRateLen + unsigned int uRateLen ) { - UINT ii, uu, uRateCnt = 0; + unsigned int ii, uu, uRateCnt = 0; if ((pSrcRates == NULL) || (pDstRates == NULL)) return 0; diff --git a/drivers/staging/vt6655/datarate.h b/drivers/staging/vt6655/datarate.h index b8ca792e9c6e..760d464890c7 100644 --- a/drivers/staging/vt6655/datarate.h +++ b/drivers/staging/vt6655/datarate.h @@ -77,7 +77,7 @@ BYTE RATEuSetIE( PWLAN_IE_SUPP_RATES pSrcRates, PWLAN_IE_SUPP_RATES pDstRates, - UINT uRateLen + unsigned int uRateLen ); WORD diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 915dd901fc93..1685fb98d2fd 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -311,7 +311,7 @@ typedef struct tagSCache{ /* The receive cache is updated circularly. The next entry to be written is * indexed by the "InPtr". */ - UINT uInPtr; // Place to use next + unsigned int uInPtr; // Place to use next SCacheEntry asCacheEntry[DUPLICATE_RX_CACHE_LENGTH]; } SCache, *PSCache; @@ -322,10 +322,10 @@ typedef struct tagSDeFragControlBlock WORD wSequence; WORD wFragNum; BYTE abyAddr2[ETH_ALEN]; - UINT uLifetime; + unsigned int uLifetime; struct sk_buff* skb; PBYTE pbyRxBuffer; - UINT cbFrameLength; + unsigned int cbFrameLength; BOOL bInUse; } SDeFragControlBlock, *PSDeFragControlBlock; @@ -448,9 +448,9 @@ typedef struct __device_info { SCache sDupRxCache; SDeFragControlBlock sRxDFCB[CB_MAX_RX_FRAG]; - UINT cbDFCB; - UINT cbFreeDFCB; - UINT uCurrentDFCBIdx; + unsigned int cbDFCB; + unsigned int cbFreeDFCB; + unsigned int uCurrentDFCBIdx; OPTIONS sOpts; @@ -497,7 +497,7 @@ typedef struct __device_info { SMgmtObject sMgmtObj; // 802.11 MAC specific - UINT uCurrRSSI; + unsigned int uCurrRSSI; BYTE byCurrSQ; DWORD dwTxAntennaSel; @@ -508,12 +508,12 @@ typedef struct __device_info { BOOL bTxRxAntInv; PBYTE pbyTmpBuff; - UINT uSIFS; //Current SIFS - UINT uDIFS; //Current DIFS - UINT uEIFS; //Current EIFS - UINT uSlot; //Current SlotTime - UINT uCwMin; //Current CwMin - UINT uCwMax; //CwMax is fixed on 1023. + unsigned int uSIFS; //Current SIFS + unsigned int uDIFS; //Current DIFS + unsigned int uEIFS; //Current EIFS + unsigned int uSlot; //Current SlotTime + unsigned int uCwMin; //Current CwMin + unsigned int uCwMax; //CwMax is fixed on 1023. // PHY parameter BYTE bySIFS; BYTE byDIFS; @@ -532,7 +532,7 @@ typedef struct __device_info { BYTE byMinChannel; BYTE byMaxChannel; - UINT uConnectionRate; + unsigned int uConnectionRate; BYTE byPreambleType; BYTE byShortPreamble; @@ -588,10 +588,10 @@ typedef struct __device_info { BOOL bBeaconBufReady; BOOL bBeaconSent; BOOL bIsBeaconBufReadySet; - UINT cbBeaconBufReadySetCnt; + unsigned int cbBeaconBufReadySetCnt; BOOL bFixRate; BYTE byCurrentCh; - UINT uScanTime; + unsigned int uScanTime; CMD_STATE eCommandState; @@ -601,14 +601,14 @@ typedef struct __device_info { BOOL bStopBeacon; BOOL bStopDataPkt; BOOL bStopTx0Pkt; - UINT uAutoReConnectTime; + unsigned int uAutoReConnectTime; // 802.11 counter CMD_ITEM eCmdQueue[CMD_Q_SIZE]; - UINT uCmdDequeueIdx; - UINT uCmdEnqueueIdx; - UINT cbFreeCmdQueue; + unsigned int uCmdDequeueIdx; + unsigned int uCmdEnqueueIdx; + unsigned int cbFreeCmdQueue; BOOL bCmdRunning; BOOL bCmdClear; @@ -629,19 +629,19 @@ typedef struct __device_info { DWORD dwIVCounter; QWORD qwPacketNumber; //For CCMP and TKIP as TSC(6 bytes) - UINT uCurrentWEPMode; + unsigned int uCurrentWEPMode; RC4Ext SBox; BYTE abyPRNG[WLAN_WEPMAX_KEYLEN+3]; BYTE byKeyIndex; - UINT uKeyLength; + unsigned int uKeyLength; BYTE abyKey[WLAN_WEP232_KEYLEN]; BOOL bAES; BYTE byCntMeasure; // for AP mode - UINT uAssocCount; + unsigned int uAssocCount; BOOL bMoreData; // QoS @@ -657,12 +657,12 @@ typedef struct __device_info { BOOL bRxMICFail; - UINT uRATEIdx; + unsigned int uRATEIdx; // For Update BaseBand VGA Gain Offset BOOL bUpdateBBVGA; - UINT uBBVGADiffCount; + unsigned int uBBVGADiffCount; BYTE byBBVGANew; BYTE byBBVGACurrent; BYTE abyBBVGA[BB_VGA_LEVEL]; @@ -766,7 +766,7 @@ typedef struct __device_info { BOOL b11hEnable; BYTE abyCountryCode[3]; // for 802.11h DFS - UINT uNumOfMeasureEIDs; + unsigned int uNumOfMeasureEIDs; PWLAN_IE_MEASURE_REQ pCurrMeasureEID; BOOL bMeasureInProgress; BYTE byOrgChannel; @@ -783,7 +783,7 @@ typedef struct __device_info { BOOL bQuietEnable; BOOL bEnableFirstQuiet; BYTE byQuietStartCount; - UINT uQuietEnqueue; + unsigned int uQuietEnqueue; DWORD dwCurrentQuietEndTime; SQuietControl sQuiet[MAX_QUIET_COUNT]; // for 802.11h TPC @@ -803,7 +803,7 @@ typedef struct __device_info { BOOL bwextstep2; BOOL bwextstep3; */ - UINT bwextcount; + unsigned int bwextcount; BOOL bWPASuppWextEnabled; #endif @@ -816,7 +816,7 @@ typedef struct __device_info { struct net_device *apdev; int (*tx_80211)(struct sk_buff *skb, struct net_device *dev); #endif - UINT uChannel; + unsigned int uChannel; BOOL bMACSuspend; struct iw_statistics wstats; // wireless stats @@ -920,7 +920,7 @@ static inline PDEVICE_TD_INFO alloc_td_info(void) { /*--------------------- Export Functions --------------------------*/ -BOOL device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, UINT uNodeIndex); +BOOL device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, unsigned int uNodeIndex); BOOL device_alloc_frag_buf(PSDevice pDevice, PSDeFragControlBlock pDeF); int Config_FileOperation(PSDevice pDevice,BOOL fwrite,unsigned char *Parameter); #endif diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 32d38931a5e2..c8ae43aba80e 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -329,8 +329,8 @@ static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev); static BOOL device_release_WPADEV(PSDevice pDevice); static int ethtool_ioctl(struct net_device *dev, void *useraddr); -static int device_rx_srv(PSDevice pDevice, UINT uIdx); -static int device_tx_srv(PSDevice pDevice, UINT uIdx); +static int device_rx_srv(PSDevice pDevice, unsigned int uIdx); +static int device_tx_srv(PSDevice pDevice, unsigned int uIdx); static BOOL device_alloc_rx_buf(PSDevice pDevice, PSRxDesc pDesc); static void device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType); static void device_free_tx_buf(PSDevice pDevice, PSTxDesc pDesc); @@ -481,7 +481,7 @@ pDevice->bUpdateBBVGA = TRUE; static void s_vCompleteCurrentMeasure (PSDevice pDevice, BYTE byResult) { - UINT ii; + unsigned int ii; DWORD dwDuration = 0; BYTE byRPI0 = 0; @@ -526,7 +526,7 @@ static void s_vCompleteCurrentMeasure (PSDevice pDevice, BYTE byResult) static void device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) { - UINT ii; + unsigned int ii; BYTE byValue; BYTE byValue1; BYTE byCCKPwrdBm = 0; @@ -1153,7 +1153,7 @@ static BOOL device_get_pci_info(PSDevice pDevice, struct pci_dev* pcid) { u16 pci_cmd; u8 b; - UINT cis_addr; + unsigned int cis_addr; #ifdef PLICE_DEBUG BYTE pci_config[256]; BYTE value =0x00; @@ -1594,7 +1594,7 @@ static void device_free_td1_ring(PSDevice pDevice) { /*-----------------------------------------------------------------*/ -static int device_rx_srv(PSDevice pDevice, UINT uIdx) { +static int device_rx_srv(PSDevice pDevice, unsigned int uIdx) { PSRxDesc pRD; int works = 0; @@ -1662,17 +1662,17 @@ BOOL device_alloc_frag_buf(PSDevice pDevice, PSDeFragControlBlock pDeF) { -static int device_tx_srv(PSDevice pDevice, UINT uIdx) { +static int device_tx_srv(PSDevice pDevice, unsigned int uIdx) { PSTxDesc pTD; BOOL bFull=FALSE; int works = 0; BYTE byTsr0; BYTE byTsr1; - UINT uFrameSize, uFIFOHeaderSize; + unsigned int uFrameSize, uFIFOHeaderSize; PSTxBufHead pTxBufHead; struct net_device_stats* pStats = &pDevice->stats; struct sk_buff* skb; - UINT uNodeIndex; + unsigned int uNodeIndex; PSMgmtObject pMgmt = pDevice->pMgmt; @@ -2084,7 +2084,7 @@ device_release_WPADEV(pDevice); static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev) { PSDevice pDevice=netdev_priv(dev); PBYTE pbMPDU; - UINT cbMPDULen = 0; + unsigned int cbMPDULen = 0; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "device_dma0_tx_80211\n"); @@ -2116,16 +2116,16 @@ static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev) { -BOOL device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, UINT uNodeIndex) { +BOOL device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, unsigned int uNodeIndex) { PSMgmtObject pMgmt = pDevice->pMgmt; PSTxDesc pHeadTD, pLastTD; - UINT cbFrameBodySize; - UINT uMACfragNum; + unsigned int cbFrameBodySize; + unsigned int uMACfragNum; BYTE byPktType; BOOL bNeedEncryption = FALSE; PSKeyItem pTransmitKey = NULL; - UINT cbHeaderSize; - UINT ii; + unsigned int cbHeaderSize; + unsigned int ii; SKeyItem STempKey; // BYTE byKeyIndex = 0; @@ -2270,17 +2270,17 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { PSMgmtObject pMgmt = pDevice->pMgmt; PSTxDesc pHeadTD, pLastTD; - UINT uNodeIndex = 0; + unsigned int uNodeIndex = 0; BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; WORD wAID; - UINT uMACfragNum = 1; - UINT cbFrameBodySize; + unsigned int uMACfragNum = 1; + unsigned int cbFrameBodySize; BYTE byPktType; - UINT cbHeaderSize; + unsigned int cbHeaderSize; BOOL bNeedEncryption = FALSE; PSKeyItem pTransmitKey = NULL; SKeyItem STempKey; - UINT ii; + unsigned int ii; BOOL bTKIP_UseGTK = FALSE; BOOL bNeedDeAuth = FALSE; PBYTE pbyBSSID; diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index ce6ccab25e26..8fa87dd5c43b 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -92,7 +92,7 @@ void s_vProcessRxMACHeader ( PSDevice pDevice, PBYTE pbyRxBufferAddr, - UINT cbPacketSize, + unsigned int cbPacketSize, BOOL bIsWEP, BOOL bExtIV, PUINT pcbHeadSize @@ -109,8 +109,8 @@ static BOOL s_bAPModeRxCtl( static BOOL s_bAPModeRxData ( PSDevice pDevice, struct sk_buff* skb, - UINT FrameSize, - UINT cbHeaderOffset, + unsigned int FrameSize, + unsigned int cbHeaderOffset, int iSANodeIndex, int iDANodeIndex ); @@ -119,7 +119,7 @@ static BOOL s_bAPModeRxData ( static BOOL s_bHandleRxEncryption( PSDevice pDevice, PBYTE pbyFrame, - UINT FrameSize, + unsigned int FrameSize, PBYTE pbyRsr, PBYTE pbyNewRsr, PSKeyItem *pKeyOut, @@ -132,7 +132,7 @@ static BOOL s_bHostWepRxEncryption( PSDevice pDevice, PBYTE pbyFrame, - UINT FrameSize, + unsigned int FrameSize, PBYTE pbyRsr, BOOL bOnFly, PSKeyItem pKey, @@ -167,14 +167,14 @@ void s_vProcessRxMACHeader ( PSDevice pDevice, PBYTE pbyRxBufferAddr, - UINT cbPacketSize, + unsigned int cbPacketSize, BOOL bIsWEP, BOOL bExtIV, PUINT pcbHeadSize ) { PBYTE pbyRxBuffer; - UINT cbHeaderSize = 0; + unsigned int cbHeaderSize = 0; PWORD pwType; PS802_11Header pMACHeader; int ii; @@ -269,7 +269,7 @@ s_vGetDASA ( PSEthernetHeader psEthHeader ) { - UINT cbHeaderSize = 0; + unsigned int cbHeaderSize = 0; PS802_11Header pMACHeader; int ii; @@ -357,18 +357,18 @@ device_receive_frame ( PBYTE pbyFrame; BOOL bDeFragRx = FALSE; BOOL bIsWEP = FALSE; - UINT cbHeaderOffset; - UINT FrameSize; + unsigned int cbHeaderOffset; + unsigned int FrameSize; WORD wEtherType = 0; int iSANodeIndex = -1; int iDANodeIndex = -1; - UINT ii; - UINT cbIVOffset; + unsigned int ii; + unsigned int cbIVOffset; BOOL bExtIV = FALSE; PBYTE pbyRxSts; PBYTE pbyRxRate; PBYTE pbySQ; - UINT cbHeaderSize; + unsigned int cbHeaderSize; PSKeyItem pKey = NULL; WORD wRxTSC15_0 = 0; DWORD dwRxTSC47_16 = 0; @@ -1165,7 +1165,7 @@ static BOOL s_bAPModeRxCtl ( static BOOL s_bHandleRxEncryption ( PSDevice pDevice, PBYTE pbyFrame, - UINT FrameSize, + unsigned int FrameSize, PBYTE pbyRsr, PBYTE pbyNewRsr, PSKeyItem *pKeyOut, @@ -1174,7 +1174,7 @@ static BOOL s_bHandleRxEncryption ( PDWORD pdwRxTSC47_16 ) { - UINT PayloadLen = FrameSize; + unsigned int PayloadLen = FrameSize; PBYTE pbyIV; BYTE byKeyIdx; PSKeyItem pKey = NULL; @@ -1311,7 +1311,7 @@ static BOOL s_bHandleRxEncryption ( static BOOL s_bHostWepRxEncryption ( PSDevice pDevice, PBYTE pbyFrame, - UINT FrameSize, + unsigned int FrameSize, PBYTE pbyRsr, BOOL bOnFly, PSKeyItem pKey, @@ -1321,7 +1321,7 @@ static BOOL s_bHostWepRxEncryption ( PDWORD pdwRxTSC47_16 ) { - UINT PayloadLen = FrameSize; + unsigned int PayloadLen = FrameSize; PBYTE pbyIV; BYTE byKeyIdx; BYTE byDecMode = KEY_CTL_WEP; @@ -1442,8 +1442,8 @@ static BOOL s_bHostWepRxEncryption ( static BOOL s_bAPModeRxData ( PSDevice pDevice, struct sk_buff* skb, - UINT FrameSize, - UINT cbHeaderOffset, + unsigned int FrameSize, + unsigned int cbHeaderOffset, int iSANodeIndex, int iDANodeIndex ) @@ -1515,7 +1515,7 @@ static BOOL s_bAPModeRxData ( iDANodeIndex = 0; if ((pDevice->uAssocCount > 1) && (iDANodeIndex >= 0)) { - ROUTEbRelay(pDevice, (PBYTE)(skb->data + cbHeaderOffset), FrameSize, (UINT)iDANodeIndex); + ROUTEbRelay(pDevice, (PBYTE)(skb->data + cbHeaderOffset), FrameSize, (unsigned int)iDANodeIndex); } if (bRelayOnly) diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c index 195cc36654ae..01429d1a95b5 100644 --- a/drivers/staging/vt6655/hostap.c +++ b/drivers/staging/vt6655/hostap.c @@ -215,7 +215,7 @@ int vt6655_hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked) static int hostap_remove_sta(PSDevice pDevice, struct viawget_hostapd_param *param) { - UINT uNodeIndex; + unsigned int uNodeIndex; if (BSSDBbIsSTAInNodeDB(pDevice->pMgmt, param->sta_addr, &uNodeIndex)) { @@ -244,7 +244,7 @@ static int hostap_add_sta(PSDevice pDevice, struct viawget_hostapd_param *param) { PSMgmtObject pMgmt = pDevice->pMgmt; - UINT uNodeIndex; + unsigned int uNodeIndex; if (!BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) { @@ -304,7 +304,7 @@ static int hostap_get_info_sta(PSDevice pDevice, struct viawget_hostapd_param *param) { PSMgmtObject pMgmt = pDevice->pMgmt; - UINT uNodeIndex; + unsigned int uNodeIndex; if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) { param->u.get_info_sta.inactive_sec = @@ -338,7 +338,7 @@ static int hostap_reset_txexc_sta(PSDevice pDevice, struct viawget_hostapd_param *param) { PSMgmtObject pMgmt = pDevice->pMgmt; - UINT uNodeIndex; + unsigned int uNodeIndex; if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) { pMgmt->sNodeDBTable[uNodeIndex].uTxAttempts = 0; @@ -368,13 +368,13 @@ static int hostap_set_flags_sta(PSDevice pDevice, struct viawget_hostapd_param *param) { PSMgmtObject pMgmt = pDevice->pMgmt; - UINT uNodeIndex; + unsigned int uNodeIndex; if (BSSDBbIsSTAInNodeDB(pMgmt, param->sta_addr, &uNodeIndex)) { pMgmt->sNodeDBTable[uNodeIndex].dwFlags |= param->u.set_flags_sta.flags_or; pMgmt->sNodeDBTable[uNodeIndex].dwFlags &= param->u.set_flags_sta.flags_and; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " dwFlags = %x \n", - (UINT)pMgmt->sNodeDBTable[uNodeIndex].dwFlags); + (unsigned int)pMgmt->sNodeDBTable[uNodeIndex].dwFlags); } else { return -ENOENT; diff --git a/drivers/staging/vt6655/ioctl.c b/drivers/staging/vt6655/ioctl.c index d8c8ee572334..b7049938c30a 100644 --- a/drivers/staging/vt6655/ioctl.c +++ b/drivers/staging/vt6655/ioctl.c @@ -70,10 +70,10 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) { SNodeList sNodeList; PSBSSIDList pList; PSNodeList pNodeList; - UINT cbListCount; + unsigned int cbListCount; PKnownBSS pBSS; PKnownNodeDB pNode; - UINT ii, jj; + unsigned int ii, jj; SCmdLinkStatus sLinkStatus; BYTE abySuppRates[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16}; BYTE abyNullAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; @@ -341,7 +341,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) { pList->sBSSIDList[ii].wCapInfo = pBSS->wCapInfo; // pList->sBSSIDList[ii].uRSSI = pBSS->uRSSI; RFvRSSITodBm(pDevice, (BYTE)(pBSS->uRSSI), &ldBm); - pList->sBSSIDList[ii].uRSSI = (UINT)ldBm; + pList->sBSSIDList[ii].uRSSI = (unsigned int)ldBm; memcpy(pList->sBSSIDList[ii].abyBSSID, pBSS->abyBSSID, WLAN_BSSID_LEN); pItemSSID = (PWLAN_IE_SSID)pBSS->abySSID; memset(pList->sBSSIDList[ii].abySSID, 0, WLAN_SSID_MAXLEN + 1); diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c index f778e7d670cc..74c0b9afd658 100644 --- a/drivers/staging/vt6655/iwctl.c +++ b/drivers/staging/vt6655/iwctl.c @@ -714,7 +714,7 @@ if (pMgmt->eScanState == WMAC_IS_SCANNING) { //mike add: if desired AP is hidden ssid(there are two same BSSID in list), // then ignore,because you don't known which one to be connect with?? { - UINT ii , uSameBssidNum=0; + unsigned int ii , uSameBssidNum=0; for (ii = 0; ii < MAX_BSS_NUM; ii++) { if (pMgmt->sBSSList[ii].bActive && !compare_ether_addr(pMgmt->sBSSList[ii].abyBSSID, pMgmt->abyDesireBSSID)) { @@ -886,7 +886,7 @@ if (pMgmt->eScanState == WMAC_IS_SCANNING) { { PKnownBSS pCurr = NULL; BYTE abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; - UINT ii , uSameBssidNum=0; + unsigned int ii , uSameBssidNum=0; memcpy(abyTmpDesireSSID,pMgmt->abyDesireSSID,sizeof(abyTmpDesireSSID)); pCurr = BSSpSearchBSSList(pDevice, @@ -1515,7 +1515,7 @@ int iwctl_giwencode(struct net_device *dev, PSMgmtObject pMgmt = &(pDevice->sMgmtObj); int rc = 0; char abyKey[WLAN_WEP232_KEYLEN]; - UINT index = (UINT)(wrq->flags & IW_ENCODE_INDEX); + unsigned int index = (unsigned int)(wrq->flags & IW_ENCODE_INDEX); PSKeyItem pKey = NULL; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n"); @@ -1584,7 +1584,7 @@ int iwctl_giwencode(struct net_device *dev, PSMgmtObject pMgmt = &(pDevice->sMgmtObj); char abyKey[WLAN_WEP232_KEYLEN]; - UINT index = (UINT)(wrq->flags & IW_ENCODE_INDEX); + unsigned int index = (unsigned int)(wrq->flags & IW_ENCODE_INDEX); PSKeyItem pKey = NULL; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWENCODE\n"); diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c index f8527a704635..da5def3214b3 100644 --- a/drivers/staging/vt6655/key.c +++ b/drivers/staging/vt6655/key.c @@ -202,9 +202,9 @@ BOOL KeybSetKey ( ) { int i,j; - UINT ii; + unsigned int ii; PSKeyItem pKey; - UINT uKeyIdx; + unsigned int uKeyIdx; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetKey: %lX\n", dwKeyIndex); @@ -642,9 +642,9 @@ BOOL KeybSetDefaultKey ( BYTE byLocalID ) { - UINT ii; + unsigned int ii; PSKeyItem pKey; - UINT uKeyIdx; + unsigned int uKeyIdx; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetDefaultKey: %1x, %d \n", (int)dwKeyIndex, (int)uKeyLength); @@ -750,9 +750,9 @@ BOOL KeybSetAllGroupKey ( ) { int i; - UINT ii; + unsigned int ii; PSKeyItem pKey; - UINT uKeyIdx; + unsigned int uKeyIdx; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Enter KeybSetAllGroupKey: %lX\n", dwKeyIndex); diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c index eae881c5a9f9..f4acb2f3213f 100644 --- a/drivers/staging/vt6655/mac.c +++ b/drivers/staging/vt6655/mac.c @@ -209,7 +209,7 @@ BOOL MACbIsIntDisable (DWORD_PTR dwIoBase) * Return Value: Mask Value read * */ -BYTE MACbyReadMultiAddr (DWORD_PTR dwIoBase, UINT uByteIdx) +BYTE MACbyReadMultiAddr (DWORD_PTR dwIoBase, unsigned int uByteIdx) { BYTE byData; @@ -234,7 +234,7 @@ BYTE MACbyReadMultiAddr (DWORD_PTR dwIoBase, UINT uByteIdx) * Return Value: none * */ -void MACvWriteMultiAddr (DWORD_PTR dwIoBase, UINT uByteIdx, BYTE byData) +void MACvWriteMultiAddr (DWORD_PTR dwIoBase, unsigned int uByteIdx, BYTE byData) { MACvSelectPage1(dwIoBase); VNSvOutPortB(dwIoBase + MAC_REG_MAR0 + uByteIdx, byData); @@ -257,7 +257,7 @@ void MACvWriteMultiAddr (DWORD_PTR dwIoBase, UINT uByteIdx, BYTE byData) */ void MACvSetMultiAddrByHash (DWORD_PTR dwIoBase, BYTE byHashIdx) { - UINT uByteIdx; + unsigned int uByteIdx; BYTE byBitMask; BYTE byOrgValue; @@ -288,7 +288,7 @@ void MACvSetMultiAddrByHash (DWORD_PTR dwIoBase, BYTE byHashIdx) */ void MACvResetMultiAddrByHash (DWORD_PTR dwIoBase, BYTE byHashIdx) { - UINT uByteIdx; + unsigned int uByteIdx; BYTE byBitMask; BYTE byOrgValue; @@ -1244,10 +1244,10 @@ void MACvSetCurrTXDescAddr (int iTxType, DWORD_PTR dwIoBase, DWORD dwCurrDescAdd * Return Value: none * */ -void MACvTimer0MicroSDelay (DWORD_PTR dwIoBase, UINT uDelay) +void MACvTimer0MicroSDelay (DWORD_PTR dwIoBase, unsigned int uDelay) { BYTE byValue; -UINT uu,ii; +unsigned int uu,ii; VNSvOutPortB(dwIoBase + MAC_REG_TMCTL0, 0); VNSvOutPortD(dwIoBase + MAC_REG_TMDATA0, uDelay); @@ -1280,7 +1280,7 @@ UINT uu,ii; * Return Value: none * */ -void MACvOneShotTimer0MicroSec (DWORD_PTR dwIoBase, UINT uDelayTime) +void MACvOneShotTimer0MicroSec (DWORD_PTR dwIoBase, unsigned int uDelayTime) { VNSvOutPortB(dwIoBase + MAC_REG_TMCTL0, 0); VNSvOutPortD(dwIoBase + MAC_REG_TMDATA0, uDelayTime); @@ -1301,7 +1301,7 @@ void MACvOneShotTimer0MicroSec (DWORD_PTR dwIoBase, UINT uDelayTime) * Return Value: none * */ -void MACvOneShotTimer1MicroSec (DWORD_PTR dwIoBase, UINT uDelayTime) +void MACvOneShotTimer1MicroSec (DWORD_PTR dwIoBase, unsigned int uDelayTime) { VNSvOutPortB(dwIoBase + MAC_REG_TMCTL1, 0); VNSvOutPortD(dwIoBase + MAC_REG_TMDATA1, uDelayTime); @@ -1319,10 +1319,10 @@ void MACvSetMISCFifo (DWORD_PTR dwIoBase, WORD wOffset, DWORD dwData) } -BOOL MACbTxDMAOff (DWORD_PTR dwIoBase, UINT idx) +BOOL MACbTxDMAOff (DWORD_PTR dwIoBase, unsigned int idx) { BYTE byData; -UINT ww = 0; +unsigned int ww = 0; if (idx == TYPE_TXDMA0) { VNSvOutPortB(dwIoBase + MAC_REG_TXDMACTL0+2, DMACTL_RUN); @@ -1350,7 +1350,7 @@ UINT ww = 0; void MACvClearBusSusInd (DWORD_PTR dwIoBase) { DWORD dwOrgValue; - UINT ww; + unsigned int ww; // check if BcnSusInd enabled VNSvInPortD(dwIoBase + MAC_REG_ENCFG , &dwOrgValue); if( !(dwOrgValue & EnCFG_BcnSusInd)) @@ -1373,7 +1373,7 @@ void MACvEnableBusSusEn (DWORD_PTR dwIoBase) { BYTE byOrgValue; DWORD dwOrgValue; - UINT ww; + unsigned int ww; // check if BcnSusInd enabled VNSvInPortB(dwIoBase + MAC_REG_CFG , &byOrgValue); @@ -1394,7 +1394,7 @@ void MACvEnableBusSusEn (DWORD_PTR dwIoBase) BOOL MACbFlushSYNCFifo (DWORD_PTR dwIoBase) { BYTE byOrgValue; - UINT ww; + unsigned int ww; // Read MACCR VNSvInPortB(dwIoBase + MAC_REG_MACCR , &byOrgValue); @@ -1418,7 +1418,7 @@ BOOL MACbFlushSYNCFifo (DWORD_PTR dwIoBase) BOOL MACbPSWakeup (DWORD_PTR dwIoBase) { BYTE byOrgValue; - UINT ww; + unsigned int ww; // Read PSCTL if (MACbIsRegBitsOff(dwIoBase, MAC_REG_PSCTL, PSCTL_PS)) { return TRUE; @@ -1455,7 +1455,8 @@ BOOL MACbPSWakeup (DWORD_PTR dwIoBase) * */ -void MACvSetKeyEntry (DWORD_PTR dwIoBase, WORD wKeyCtl, UINT uEntryIdx, UINT uKeyIdx, PBYTE pbyAddr, PDWORD pdwKey, BYTE byLocalID) +void MACvSetKeyEntry (DWORD_PTR dwIoBase, WORD wKeyCtl, unsigned int uEntryIdx, + unsigned int uKeyIdx, PBYTE pbyAddr, PDWORD pdwKey, BYTE byLocalID) { WORD wOffset; DWORD dwData; @@ -1521,7 +1522,7 @@ int ii; * Return Value: none * */ -void MACvDisableKeyEntry (DWORD_PTR dwIoBase, UINT uEntryIdx) +void MACvDisableKeyEntry (DWORD_PTR dwIoBase, unsigned int uEntryIdx) { WORD wOffset; @@ -1549,7 +1550,8 @@ WORD wOffset; * */ -void MACvSetDefaultKeyEntry (DWORD_PTR dwIoBase, UINT uKeyLen, UINT uKeyIdx, PDWORD pdwKey, BYTE byLocalID) +void MACvSetDefaultKeyEntry (DWORD_PTR dwIoBase, unsigned int uKeyLen, + unsigned int uKeyIdx, PDWORD pdwKey, BYTE byLocalID) { WORD wOffset; DWORD dwData; @@ -1664,7 +1666,8 @@ DWORD dwData; * Return Value: none * */ -void MACvSetDefaultTKIPKeyEntry (DWORD_PTR dwIoBase, UINT uKeyLen, UINT uKeyIdx, PDWORD pdwKey, BYTE byLocalID) +void MACvSetDefaultTKIPKeyEntry (DWORD_PTR dwIoBase, unsigned int uKeyLen, + unsigned int uKeyIdx, PDWORD pdwKey, BYTE byLocalID) { WORD wOffset; DWORD dwData; @@ -1720,7 +1723,7 @@ int ii; * */ -void MACvSetDefaultKeyCtl (DWORD_PTR dwIoBase, WORD wKeyCtl, UINT uEntryIdx, BYTE byLocalID) +void MACvSetDefaultKeyCtl (DWORD_PTR dwIoBase, WORD wKeyCtl, unsigned int uEntryIdx, BYTE byLocalID) { WORD wOffset; DWORD dwData; diff --git a/drivers/staging/vt6655/mac.h b/drivers/staging/vt6655/mac.h index 5eb7f57f7182..88a440398734 100644 --- a/drivers/staging/vt6655/mac.h +++ b/drivers/staging/vt6655/mac.h @@ -1082,8 +1082,8 @@ BOOL MACbIsRegBitsOff(DWORD_PTR dwIoBase, BYTE byRegOfs, BYTE byTestBits); BOOL MACbIsIntDisable(DWORD_PTR dwIoBase); -BYTE MACbyReadMultiAddr(DWORD_PTR dwIoBase, UINT uByteIdx); -void MACvWriteMultiAddr(DWORD_PTR dwIoBase, UINT uByteIdx, BYTE byData); +BYTE MACbyReadMultiAddr(DWORD_PTR dwIoBase, unsigned int uByteIdx); +void MACvWriteMultiAddr(DWORD_PTR dwIoBase, unsigned int uByteIdx, BYTE byData); void MACvSetMultiAddrByHash(DWORD_PTR dwIoBase, BYTE byHashIdx); void MACvResetMultiAddrByHash(DWORD_PTR dwIoBase, BYTE byHashIdx); @@ -1125,13 +1125,13 @@ void MACvSetCurrTx0DescAddrEx(DWORD_PTR dwIoBase, DWORD dwCurrDescAddr); void MACvSetCurrAC0DescAddrEx(DWORD_PTR dwIoBase, DWORD dwCurrDescAddr); void MACvSetCurrSyncDescAddrEx(DWORD_PTR dwIoBase, DWORD dwCurrDescAddr); void MACvSetCurrATIMDescAddrEx(DWORD_PTR dwIoBase, DWORD dwCurrDescAddr); -void MACvTimer0MicroSDelay(DWORD_PTR dwIoBase, UINT uDelay); -void MACvOneShotTimer0MicroSec(DWORD_PTR dwIoBase, UINT uDelayTime); -void MACvOneShotTimer1MicroSec(DWORD_PTR dwIoBase, UINT uDelayTime); +void MACvTimer0MicroSDelay(DWORD_PTR dwIoBase, unsigned int uDelay); +void MACvOneShotTimer0MicroSec(DWORD_PTR dwIoBase, unsigned int uDelayTime); +void MACvOneShotTimer1MicroSec(DWORD_PTR dwIoBase, unsigned int uDelayTime); void MACvSetMISCFifo(DWORD_PTR dwIoBase, WORD wOffset, DWORD dwData); -BOOL MACbTxDMAOff (DWORD_PTR dwIoBase, UINT idx); +BOOL MACbTxDMAOff (DWORD_PTR dwIoBase, unsigned int idx); void MACvClearBusSusInd(DWORD_PTR dwIoBase); void MACvEnableBusSusEn(DWORD_PTR dwIoBase); @@ -1139,13 +1139,16 @@ void MACvEnableBusSusEn(DWORD_PTR dwIoBase); BOOL MACbFlushSYNCFifo(DWORD_PTR dwIoBase); BOOL MACbPSWakeup(DWORD_PTR dwIoBase); -void MACvSetKeyEntry(DWORD_PTR dwIoBase, WORD wKeyCtl, UINT uEntryIdx, UINT uKeyIdx, PBYTE pbyAddr, PDWORD pdwKey, BYTE byLocalID); -void MACvDisableKeyEntry(DWORD_PTR dwIoBase, UINT uEntryIdx); -void MACvSetDefaultKeyEntry(DWORD_PTR dwIoBase, UINT uKeyLen, UINT uKeyIdx, PDWORD pdwKey, BYTE byLocalID); +void MACvSetKeyEntry(DWORD_PTR dwIoBase, WORD wKeyCtl, unsigned int uEntryIdx, + unsigned int uKeyIdx, PBYTE pbyAddr, PDWORD pdwKey, BYTE byLocalID); +void MACvDisableKeyEntry(DWORD_PTR dwIoBase, unsigned int uEntryIdx); +void MACvSetDefaultKeyEntry(DWORD_PTR dwIoBase, unsigned int uKeyLen, + unsigned int uKeyIdx, PDWORD pdwKey, BYTE byLocalID); //void MACvEnableDefaultKey(DWORD_PTR dwIoBase, BYTE byLocalID); void MACvDisableDefaultKey(DWORD_PTR dwIoBase); -void MACvSetDefaultTKIPKeyEntry(DWORD_PTR dwIoBase, UINT uKeyLen, UINT uKeyIdx, PDWORD pdwKey, BYTE byLocalID); -void MACvSetDefaultKeyCtl(DWORD_PTR dwIoBase, WORD wKeyCtl, UINT uEntryIdx, BYTE byLocalID); +void MACvSetDefaultTKIPKeyEntry(DWORD_PTR dwIoBase, unsigned int uKeyLen, + unsigned int uKeyIdx, PDWORD pdwKey, BYTE byLocalID); +void MACvSetDefaultKeyCtl(DWORD_PTR dwIoBase, WORD wKeyCtl, unsigned int uEntryIdx, BYTE byLocalID); #endif // __MAC_H__ diff --git a/drivers/staging/vt6655/mib.c b/drivers/staging/vt6655/mib.c index b4e916f2c650..e6cab78de0f4 100644 --- a/drivers/staging/vt6655/mib.c +++ b/drivers/staging/vt6655/mib.c @@ -178,7 +178,7 @@ void STAvUpdateIsrStatCounter (PSStatCounter pStatistic, DWORD dwIsr) */ void STAvUpdateRDStatCounter (PSStatCounter pStatistic, BYTE byRSR, BYTE byNewRSR, BYTE byRxRate, - PBYTE pbyBuffer, UINT cbFrameLength) + PBYTE pbyBuffer, unsigned int cbFrameLength) { //need change PS802_11Header pHeader = (PS802_11Header)pbyBuffer; @@ -393,7 +393,7 @@ STAvUpdateRDStatCounterEx ( BYTE byNewRSR, BYTE byRxRate, PBYTE pbyBuffer, - UINT cbFrameLength + unsigned int cbFrameLength ) { STAvUpdateRDStatCounter( @@ -435,8 +435,8 @@ STAvUpdateTDStatCounter ( BYTE byTSR0, BYTE byTSR1, PBYTE pbyBuffer, - UINT cbFrameLength, - UINT uIdx + unsigned int cbFrameLength, + unsigned int uIdx ) { PWLAN_80211HDR_A4 pHeader; @@ -526,9 +526,9 @@ STAvUpdateTDStatCounterEx ( DWORD cbFrameLength ) { - UINT uPktLength; + unsigned int uPktLength; - uPktLength = (UINT)cbFrameLength; + uPktLength = (unsigned int)cbFrameLength; // tx length pStatistic->dwCntTxBufLength = uPktLength; diff --git a/drivers/staging/vt6655/mib.h b/drivers/staging/vt6655/mib.h index 190fc475e5d5..ffd5fb1d39d5 100644 --- a/drivers/staging/vt6655/mib.h +++ b/drivers/staging/vt6655/mib.h @@ -301,7 +301,7 @@ typedef struct tagSStatCounter { DWORD dwCntRxDataErr; // rx buffer data software compare CRC err count DWORD dwCntDecryptErr; // rx buffer data software compare CRC err count DWORD dwCntRxICVErr; // rx buffer data software compare CRC err count - UINT idxRxErrorDesc[TYPE_MAXRD]; // index for rx data error RD + unsigned int idxRxErrorDesc[TYPE_MAXRD]; // index for rx data error RD // 64-bit OID ULONGLONG ullTsrOK[TYPE_MAXTD]; @@ -348,15 +348,14 @@ void STAvUpdateIsrStatCounter(PSStatCounter pStatistic, DWORD dwIsr); void STAvUpdateRDStatCounter(PSStatCounter pStatistic, BYTE byRSR, BYTE byNewRSR, BYTE byRxRate, - PBYTE pbyBuffer, UINT cbFrameLength); + PBYTE pbyBuffer, unsigned int cbFrameLength); void STAvUpdateRDStatCounterEx(PSStatCounter pStatistic, BYTE byRSR, BYTE byNewRsr, BYTE byRxRate, - PBYTE pbyBuffer, UINT cbFrameLength); + PBYTE pbyBuffer, unsigned int cbFrameLength); -void STAvUpdateTDStatCounter(PSStatCounter pStatistic, - BYTE byTSR0, BYTE byTSR1, - PBYTE pbyBuffer, UINT cbFrameLength, UINT uIdx ); +void STAvUpdateTDStatCounter(PSStatCounter pStatistic, BYTE byTSR0, BYTE byTSR1, + PBYTE pbyBuffer, unsigned int cbFrameLength, unsigned int uIdx); void STAvUpdateTDStatCounterEx( PSStatCounter pStatistic, diff --git a/drivers/staging/vt6655/michael.c b/drivers/staging/vt6655/michael.c index 0bf57efdede0..3a92257bd3e8 100644 --- a/drivers/staging/vt6655/michael.c +++ b/drivers/staging/vt6655/michael.c @@ -61,7 +61,7 @@ static DWORD L, R; // Current state static DWORD K0, K1; // Key static DWORD M; // Message accumulator (single word) -static UINT nBytesInM; // # bytes in M +static unsigned int nBytesInM; // # bytes in M /*--------------------- Export Functions --------------------------*/ @@ -70,7 +70,7 @@ static DWORD s_dwGetUINT32 (BYTE * p) // Convert from BYTE[] to DWORD in a portable way { DWORD res = 0; - UINT i; + unsigned int i; for(i=0; i<4; i++ ) { res |= (*p++) << (8*i); @@ -81,7 +81,7 @@ static DWORD s_dwGetUINT32 (BYTE * p) static void s_vPutUINT32 (BYTE* p, DWORD val) // Convert from DWORD to BYTE[] in a portable way { - UINT i; + unsigned int i; for(i=0; i<4; i++ ) { *p++ = (BYTE) (val & 0xff); @@ -149,7 +149,7 @@ void MIC_vUnInit (void) s_vClear(); } -void MIC_vAppend (PBYTE src, UINT nBytes) +void MIC_vAppend (PBYTE src, unsigned int nBytes) { // This is simple while (nBytes > 0) diff --git a/drivers/staging/vt6655/michael.h b/drivers/staging/vt6655/michael.h index 97de77b4da2c..c1584a0ce7a1 100644 --- a/drivers/staging/vt6655/michael.h +++ b/drivers/staging/vt6655/michael.h @@ -40,7 +40,7 @@ void MIC_vInit(DWORD dwK0, DWORD dwK1); void MIC_vUnInit(void); // Append bytes to the message to be MICed -void MIC_vAppend(PBYTE src, UINT nBytes); +void MIC_vAppend(PBYTE src, unsigned int nBytes); // Get the MIC result. Destination should accept 8 bytes of result. // This also resets the message to empty. diff --git a/drivers/staging/vt6655/power.c b/drivers/staging/vt6655/power.c index 64c22c3e4bb3..d4e076513f63 100644 --- a/drivers/staging/vt6655/power.c +++ b/drivers/staging/vt6655/power.c @@ -191,7 +191,7 @@ PSbConsiderPowerDown( { PSDevice pDevice = (PSDevice)hDeviceContext; PSMgmtObject pMgmt = pDevice->pMgmt; - UINT uIdx; + unsigned int uIdx; // check if already in Doze mode if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) @@ -304,7 +304,7 @@ PSbSendNullPacket( PSDevice pDevice = (PSDevice)hDeviceContext; PSTxMgmtPacket pTxPacket = NULL; PSMgmtObject pMgmt = pDevice->pMgmt; - UINT uIdx; + unsigned int uIdx; if (pDevice->bLinkPass == FALSE) { diff --git a/drivers/staging/vt6655/rc4.c b/drivers/staging/vt6655/rc4.c index 4a53f159cb30..0d641ffefc99 100644 --- a/drivers/staging/vt6655/rc4.c +++ b/drivers/staging/vt6655/rc4.c @@ -32,13 +32,13 @@ #include "rc4.h" -void rc4_init(PRC4Ext pRC4, PBYTE pbyKey, UINT cbKey_len) +void rc4_init(PRC4Ext pRC4, PBYTE pbyKey, unsigned int cbKey_len) { - UINT ust1, ust2; - UINT keyindex; - UINT stateindex; + unsigned int ust1, ust2; + unsigned int keyindex; + unsigned int stateindex; PBYTE pbyst; - UINT idx; + unsigned int idx; pbyst = pRC4->abystate; pRC4->ux = 0; @@ -58,11 +58,11 @@ void rc4_init(PRC4Ext pRC4, PBYTE pbyKey, UINT cbKey_len) } } -UINT rc4_byte(PRC4Ext pRC4) +unsigned int rc4_byte(PRC4Ext pRC4) { - UINT ux; - UINT uy; - UINT ustx, usty; + unsigned int ux; + unsigned int uy; + unsigned int ustx, usty; PBYTE pbyst; pbyst = pRC4->abystate; @@ -79,9 +79,9 @@ UINT rc4_byte(PRC4Ext pRC4) } void rc4_encrypt(PRC4Ext pRC4, PBYTE pbyDest, - PBYTE pbySrc, UINT cbData_len) + PBYTE pbySrc, unsigned int cbData_len) { - UINT ii; + unsigned int ii; for (ii = 0; ii < cbData_len; ii++) pbyDest[ii] = (BYTE)(pbySrc[ii] ^ rc4_byte(pRC4)); } diff --git a/drivers/staging/vt6655/rc4.h b/drivers/staging/vt6655/rc4.h index e65cae69efaf..a40030461c12 100644 --- a/drivers/staging/vt6655/rc4.h +++ b/drivers/staging/vt6655/rc4.h @@ -35,13 +35,13 @@ /*--------------------- Export Definitions -------------------------*/ /*--------------------- Export Types ------------------------------*/ typedef struct { - UINT ux; - UINT uy; + unsigned int ux; + unsigned int uy; BYTE abystate[256]; } RC4Ext, *PRC4Ext; -void rc4_init(PRC4Ext pRC4, PBYTE pbyKey, UINT cbKey_len); -UINT rc4_byte(PRC4Ext pRC4); -void rc4_encrypt(PRC4Ext pRC4, PBYTE pbyDest, PBYTE pbySrc, UINT cbData_len); +void rc4_init(PRC4Ext pRC4, PBYTE pbyKey, unsigned int cbKey_len); +unsigned int rc4_byte(PRC4Ext pRC4); +void rc4_encrypt(PRC4Ext pRC4, PBYTE pbyDest, PBYTE pbySrc, unsigned int cbData_len); #endif //__RC4_H__ diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c index 4f2c01bceb76..c86504dc38b8 100644 --- a/drivers/staging/vt6655/rf.c +++ b/drivers/staging/vt6655/rf.c @@ -911,7 +911,7 @@ BOOL bResult = TRUE; * Return Value: None. * */ -BOOL RFvWriteWakeProgSyn (DWORD_PTR dwIoBase, BYTE byRFType, UINT uChannel) +BOOL RFvWriteWakeProgSyn (DWORD_PTR dwIoBase, BYTE byRFType, unsigned int uChannel) { int ii; BYTE byInitCount = 0; @@ -998,8 +998,8 @@ BOOL RFvWriteWakeProgSyn (DWORD_PTR dwIoBase, BYTE byRFType, UINT uChannel) */ BOOL RFbSetPower ( PSDevice pDevice, - UINT uRATE, - UINT uCH + unsigned int uRATE, + unsigned int uCH ) { BOOL bResult = TRUE; @@ -1138,7 +1138,7 @@ BYTE byPwrdBm = 0; BOOL RFbRawSetPower ( PSDevice pDevice, BYTE byPwr, - UINT uRATE + unsigned int uRATE ) { BOOL bResult = TRUE; diff --git a/drivers/staging/vt6655/rf.h b/drivers/staging/vt6655/rf.h index 25dfc7942f67..7571b3d1ca48 100644 --- a/drivers/staging/vt6655/rf.h +++ b/drivers/staging/vt6655/rf.h @@ -81,12 +81,12 @@ BOOL RFbSelectChannel(DWORD_PTR dwIoBase, BYTE byRFType, BYTE byChannel); BOOL RFbInit ( PSDevice pDevice ); -BOOL RFvWriteWakeProgSyn(DWORD_PTR dwIoBase, BYTE byRFType, UINT uChannel); -BOOL RFbSetPower(PSDevice pDevice, UINT uRATE, UINT uCH); +BOOL RFvWriteWakeProgSyn(DWORD_PTR dwIoBase, BYTE byRFType, unsigned int uChannel); +BOOL RFbSetPower(PSDevice pDevice, unsigned int uRATE, unsigned int uCH); BOOL RFbRawSetPower( PSDevice pDevice, BYTE byPwr, - UINT uRATE + unsigned int uRATE ); void diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 590fc7f7fcb5..271a4ab94886 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -134,7 +134,7 @@ s_vFillRTSHead( PSDevice pDevice, BYTE byPktType, void * pvRTS, - UINT cbFrameLength, + unsigned int cbFrameLength, BOOL bNeedAck, BOOL bDisCRC, PSEthernetHeader psEthHeader, @@ -151,9 +151,9 @@ s_vGenerateTxParameter( void * pvRrvTime, void * pvRTS, void * pvCTS, - UINT cbFrameSize, + unsigned int cbFrameSize, BOOL bNeedACK, - UINT uDMAIdx, + unsigned int uDMAIdx, PSEthernetHeader psEthHeader, WORD wCurrentRate ); @@ -163,43 +163,43 @@ s_vGenerateTxParameter( static void s_vFillFragParameter( PSDevice pDevice, PBYTE pbyBuffer, - UINT uTxType, + unsigned int uTxType, void * pvtdCurr, WORD wFragType, - UINT cbReqCount + unsigned int cbReqCount ); static -UINT +unsigned int s_cbFillTxBufHead ( PSDevice pDevice, BYTE byPktType, PBYTE pbyTxBufferAddr, - UINT cbFrameBodySize, - UINT uDMAIdx, + unsigned int cbFrameBodySize, + unsigned int uDMAIdx, PSTxDesc pHeadTD, PSEthernetHeader psEthHeader, PBYTE pPacket, BOOL bNeedEncrypt, PSKeyItem pTransmitKey, - UINT uNodeIndex, + unsigned int uNodeIndex, PUINT puMACfragNum ); static -UINT +unsigned int s_uFillDataHead ( PSDevice pDevice, BYTE byPktType, void * pTxDataHead, - UINT cbFrameLength, - UINT uDMAIdx, + unsigned int cbFrameLength, + unsigned int uDMAIdx, BOOL bNeedAck, - UINT uFragIdx, - UINT cbLastFragmentSize, - UINT uMACfragNum, + unsigned int uFragIdx, + unsigned int cbLastFragmentSize, + unsigned int uMACfragNum, BYTE byFBOption, WORD wCurrentRate ); @@ -336,7 +336,7 @@ s_vSWencryption ( WORD wPayloadSize ) { - UINT cbICVlen = 4; + unsigned int cbICVlen = 4; DWORD dwICV = 0xFFFFFFFFL; PDWORD pdwICV; @@ -377,16 +377,16 @@ s_vSWencryption ( PK_TYPE_11GA 3 */ static -UINT +unsigned int s_uGetTxRsvTime ( PSDevice pDevice, BYTE byPktType, - UINT cbFrameLength, + unsigned int cbFrameLength, WORD wRate, BOOL bNeedAck ) { - UINT uDataTime, uAckTime; + unsigned int uDataTime, uAckTime; uDataTime = BBuGetFrameTime(pDevice->byPreambleType, byPktType, cbFrameLength, wRate); #ifdef PLICE_DEBUG @@ -408,16 +408,16 @@ s_uGetTxRsvTime ( //byFreqType: 0=>5GHZ 1=>2.4GHZ static -UINT +unsigned int s_uGetRTSCTSRsvTime ( PSDevice pDevice, BYTE byRTSRsvType, BYTE byPktType, - UINT cbFrameLength, + unsigned int cbFrameLength, WORD wCurrentRate ) { - UINT uRrvTime , uRTSTime, uCTSTime, uAckTime, uDataTime; + unsigned int uRrvTime , uRTSTime, uCTSTime, uAckTime, uDataTime; uRrvTime = uRTSTime = uCTSTime = uAckTime = uDataTime = 0; @@ -450,22 +450,22 @@ s_uGetRTSCTSRsvTime ( //byFreqType 0: 5GHz, 1:2.4Ghz static -UINT +unsigned int s_uGetDataDuration ( PSDevice pDevice, BYTE byDurType, - UINT cbFrameLength, + unsigned int cbFrameLength, BYTE byPktType, WORD wRate, BOOL bNeedAck, - UINT uFragIdx, - UINT cbLastFragmentSize, - UINT uMACfragNum, + unsigned int uFragIdx, + unsigned int cbLastFragmentSize, + unsigned int uMACfragNum, BYTE byFBOption ) { BOOL bLastFrag = 0; - UINT uAckTime =0, uNextPktTime = 0; + unsigned int uAckTime =0, uNextPktTime = 0; @@ -621,18 +621,18 @@ s_uGetDataDuration ( //byFreqType: 0=>5GHZ 1=>2.4GHZ static -UINT +unsigned int s_uGetRTSCTSDuration ( PSDevice pDevice, BYTE byDurType, - UINT cbFrameLength, + unsigned int cbFrameLength, BYTE byPktType, WORD wRate, BOOL bNeedAck, BYTE byFBOption ) { - UINT uCTSTime = 0, uDurTime = 0; + unsigned int uCTSTime = 0, uDurTime = 0; switch (byDurType) { @@ -719,17 +719,17 @@ s_uGetRTSCTSDuration ( static -UINT +unsigned int s_uFillDataHead ( PSDevice pDevice, BYTE byPktType, void * pTxDataHead, - UINT cbFrameLength, - UINT uDMAIdx, + unsigned int cbFrameLength, + unsigned int uDMAIdx, BOOL bNeedAck, - UINT uFragIdx, - UINT cbLastFragmentSize, - UINT uMACfragNum, + unsigned int uFragIdx, + unsigned int cbLastFragmentSize, + unsigned int uMACfragNum, BYTE byFBOption, WORD wCurrentRate ) @@ -856,7 +856,7 @@ s_vFillRTSHead ( PSDevice pDevice, BYTE byPktType, void * pvRTS, - UINT cbFrameLength, + unsigned int cbFrameLength, BOOL bNeedAck, BOOL bDisCRC, PSEthernetHeader psEthHeader, @@ -864,7 +864,7 @@ s_vFillRTSHead ( BYTE byFBOption ) { - UINT uRTSFrameLen = 20; + unsigned int uRTSFrameLen = 20; WORD wLen = 0x0000; if (pvRTS == NULL) @@ -1048,17 +1048,17 @@ static void s_vFillCTSHead ( PSDevice pDevice, - UINT uDMAIdx, + unsigned int uDMAIdx, BYTE byPktType, void * pvCTS, - UINT cbFrameLength, + unsigned int cbFrameLength, BOOL bNeedAck, BOOL bDisCRC, WORD wCurrentRate, BYTE byFBOption ) { - UINT uCTSFrameLen = 14; + unsigned int uCTSFrameLen = 14; WORD wLen = 0x0000; if (pvCTS == NULL) { @@ -1148,7 +1148,7 @@ s_vFillCTSHead ( * Return Value: none * -*/ -// UINT cbFrameSize,//Hdr+Payload+FCS +// unsigned int cbFrameSize,//Hdr+Payload+FCS static void s_vGenerateTxParameter ( @@ -1158,14 +1158,14 @@ s_vGenerateTxParameter ( void * pvRrvTime, void * pvRTS, void * pvCTS, - UINT cbFrameSize, + unsigned int cbFrameSize, BOOL bNeedACK, - UINT uDMAIdx, + unsigned int uDMAIdx, PSEthernetHeader psEthHeader, WORD wCurrentRate ) { - UINT cbMACHdLen = WLAN_HDR_ADDR3_LEN; //24 + unsigned int cbMACHdLen = WLAN_HDR_ADDR3_LEN; //24 WORD wFifoCtl; BOOL bDisCRC = FALSE; BYTE byFBOption = AUTO_FB_NONE; @@ -1265,17 +1265,17 @@ s_vGenerateTxParameter ( /* PBYTE pbyBuffer,//point to pTxBufHead WORD wFragType,//00:Non-Frag, 01:Start, 02:Mid, 03:Last - UINT cbFragmentSize,//Hdr+payoad+FCS + unsigned int cbFragmentSize,//Hdr+payoad+FCS */ static void s_vFillFragParameter( PSDevice pDevice, PBYTE pbyBuffer, - UINT uTxType, + unsigned int uTxType, void * pvtdCurr, WORD wFragType, - UINT cbReqCount + unsigned int cbReqCount ) { PSTxBufHead pTxBufHead = (PSTxBufHead) pbyBuffer; @@ -1316,57 +1316,57 @@ s_vFillFragParameter( } static -UINT +unsigned int s_cbFillTxBufHead ( PSDevice pDevice, BYTE byPktType, PBYTE pbyTxBufferAddr, - UINT cbFrameBodySize, - UINT uDMAIdx, + unsigned int cbFrameBodySize, + unsigned int uDMAIdx, PSTxDesc pHeadTD, PSEthernetHeader psEthHeader, PBYTE pPacket, BOOL bNeedEncrypt, PSKeyItem pTransmitKey, - UINT uNodeIndex, + unsigned int uNodeIndex, PUINT puMACfragNum ) { - UINT cbMACHdLen; - UINT cbFrameSize; - UINT cbFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS - UINT cbFragPayloadSize; - UINT cbLastFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS - UINT cbLastFragPayloadSize; - UINT uFragIdx; + unsigned int cbMACHdLen; + unsigned int cbFrameSize; + unsigned int cbFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS + unsigned int cbFragPayloadSize; + unsigned int cbLastFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS + unsigned int cbLastFragPayloadSize; + unsigned int uFragIdx; PBYTE pbyPayloadHead; PBYTE pbyIVHead; PBYTE pbyMacHdr; WORD wFragType; //00:Non-Frag, 01:Start, 10:Mid, 11:Last - UINT uDuration; + unsigned int uDuration; PBYTE pbyBuffer; -// UINT uKeyEntryIdx = NUM_KEY_ENTRY+1; +// unsigned int uKeyEntryIdx = NUM_KEY_ENTRY+1; // BYTE byKeySel = 0xFF; - UINT cbIVlen = 0; - UINT cbICVlen = 0; - UINT cbMIClen = 0; - UINT cbFCSlen = 4; - UINT cb802_1_H_len = 0; - UINT uLength = 0; - UINT uTmpLen = 0; + unsigned int cbIVlen = 0; + unsigned int cbICVlen = 0; + unsigned int cbMIClen = 0; + unsigned int cbFCSlen = 4; + unsigned int cb802_1_H_len = 0; + unsigned int uLength = 0; + unsigned int uTmpLen = 0; // BYTE abyTmp[8]; // DWORD dwCRC; - UINT cbMICHDR = 0; + unsigned int cbMICHDR = 0; DWORD dwMICKey0, dwMICKey1; DWORD dwMIC_Priority; PDWORD pdwMIC_L; PDWORD pdwMIC_R; DWORD dwSafeMIC_L, dwSafeMIC_R; //Fix "Last Frag Size" < "MIC length". BOOL bMIC2Frag = FALSE; - UINT uMICFragLen = 0; - UINT uMACfragNum = 1; - UINT uPadding = 0; - UINT cbReqCount = 0; + unsigned int uMICFragLen = 0; + unsigned int uMACfragNum = 1; + unsigned int uPadding = 0; + unsigned int cbReqCount = 0; BOOL bNeedACK; BOOL bRTS; @@ -1374,15 +1374,15 @@ s_cbFillTxBufHead ( PBYTE pbyType; PSTxDesc ptdCurr; PSTxBufHead psTxBufHd = (PSTxBufHead) pbyTxBufferAddr; -// UINT tmpDescIdx; - UINT cbHeaderLength = 0; +// unsigned int tmpDescIdx; + unsigned int cbHeaderLength = 0; void * pvRrvTime; PSMICHDRHead pMICHDR; void * pvRTS; void * pvCTS; void * pvTxDataHd; WORD wTxBufSize; // FFinfo size - UINT uTotalCopyLength = 0; + unsigned int uTotalCopyLength = 0; BYTE byFBOption = AUTO_FB_NONE; BOOL bIsWEP256 = FALSE; PSMgmtObject pMgmt = pDevice->pMgmt; @@ -2099,18 +2099,18 @@ vGenerateFIFOHeader ( BYTE byPktType, PBYTE pbyTxBufferAddr, BOOL bNeedEncrypt, - UINT cbPayloadSize, - UINT uDMAIdx, + unsigned int cbPayloadSize, + unsigned int uDMAIdx, PSTxDesc pHeadTD, PSEthernetHeader psEthHeader, PBYTE pPacket, PSKeyItem pTransmitKey, - UINT uNodeIndex, + unsigned int uNodeIndex, PUINT puMACfragNum, PUINT pcbHeaderSize ) { - UINT wTxBufSize; // FFinfo size + unsigned int wTxBufSize; // FFinfo size BOOL bNeedACK; BOOL bIsAdhoc; WORD cbMacHdLen; @@ -2272,8 +2272,8 @@ vGenerateMACHeader ( PSEthernetHeader psEthHeader, BOOL bNeedEncrypt, WORD wFragType, - UINT uDMAIdx, - UINT uFragIdx + unsigned int uDMAIdx, + unsigned int uFragIdx ) { PS802_11Header pMACHeader = (PS802_11Header)pbyBufferAddr; @@ -2345,22 +2345,22 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { void * pvRTS; PSCTS pCTS; void * pvTxDataHd; - UINT uDuration; - UINT cbReqCount; + unsigned int uDuration; + unsigned int cbReqCount; PS802_11Header pMACHeader; - UINT cbHeaderSize; - UINT cbFrameBodySize; + unsigned int cbHeaderSize; + unsigned int cbFrameBodySize; BOOL bNeedACK; BOOL bIsPSPOLL = FALSE; PSTxBufHead pTxBufHead; - UINT cbFrameSize; - UINT cbIVlen = 0; - UINT cbICVlen = 0; - UINT cbMIClen = 0; - UINT cbFCSlen = 4; - UINT uPadding = 0; + unsigned int cbFrameSize; + unsigned int cbIVlen = 0; + unsigned int cbICVlen = 0; + unsigned int cbMIClen = 0; + unsigned int cbFCSlen = 4; + unsigned int uPadding = 0; WORD wTxBufSize; - UINT cbMacHdLen; + unsigned int cbMacHdLen; SEthernetHeader sEthHeader; void * pvRrvTime; void * pMICHDR; @@ -2663,8 +2663,8 @@ CMD_STATUS csBeacon_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { BYTE byPktType; PBYTE pbyBuffer = (PBYTE)pDevice->tx_beacon_bufs; - UINT cbFrameSize = pPacket->cbMPDULen + WLAN_FCS_LEN; - UINT cbHeaderSize = 0; + unsigned int cbFrameSize = pPacket->cbMPDULen + WLAN_FCS_LEN; + unsigned int cbHeaderSize = 0; WORD wTxBufSize = sizeof(STxShortBufHead); PSTxShortBufHead pTxBufHead = (PSTxShortBufHead) pbyBuffer; PSTxDataHead_ab pTxDataHead = (PSTxDataHead_ab) (pbyBuffer + wTxBufSize); @@ -2736,24 +2736,24 @@ CMD_STATUS csBeacon_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { -UINT +unsigned int cbGetFragCount ( PSDevice pDevice, PSKeyItem pTransmitKey, - UINT cbFrameBodySize, + unsigned int cbFrameBodySize, PSEthernetHeader psEthHeader ) { - UINT cbMACHdLen; - UINT cbFrameSize; - UINT cbFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS - UINT cbFragPayloadSize; - UINT cbLastFragPayloadSize; - UINT cbIVlen = 0; - UINT cbICVlen = 0; - UINT cbMIClen = 0; - UINT cbFCSlen = 4; - UINT uMACfragNum = 1; + unsigned int cbMACHdLen; + unsigned int cbFrameSize; + unsigned int cbFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS + unsigned int cbFragPayloadSize; + unsigned int cbLastFragPayloadSize; + unsigned int cbIVlen = 0; + unsigned int cbICVlen = 0; + unsigned int cbMIClen = 0; + unsigned int cbFCSlen = 4; + unsigned int uMACfragNum = 1; BOOL bNeedACK; @@ -2826,7 +2826,7 @@ cbGetFragCount ( void -vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, UINT cbMPDULen) { +vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, unsigned int cbMPDULen) { PSTxDesc pFrstTD; BYTE byPktType; @@ -2834,35 +2834,35 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, UINT cbMPDU void * pvRTS; void * pvCTS; void * pvTxDataHd; - UINT uDuration; - UINT cbReqCount; + unsigned int uDuration; + unsigned int cbReqCount; PS802_11Header pMACHeader; - UINT cbHeaderSize; - UINT cbFrameBodySize; + unsigned int cbHeaderSize; + unsigned int cbFrameBodySize; BOOL bNeedACK; BOOL bIsPSPOLL = FALSE; PSTxBufHead pTxBufHead; - UINT cbFrameSize; - UINT cbIVlen = 0; - UINT cbICVlen = 0; - UINT cbMIClen = 0; - UINT cbFCSlen = 4; - UINT uPadding = 0; - UINT cbMICHDR = 0; - UINT uLength = 0; + unsigned int cbFrameSize; + unsigned int cbIVlen = 0; + unsigned int cbICVlen = 0; + unsigned int cbMIClen = 0; + unsigned int cbFCSlen = 4; + unsigned int uPadding = 0; + unsigned int cbMICHDR = 0; + unsigned int uLength = 0; DWORD dwMICKey0, dwMICKey1; DWORD dwMIC_Priority; PDWORD pdwMIC_L; PDWORD pdwMIC_R; WORD wTxBufSize; - UINT cbMacHdLen; + unsigned int cbMacHdLen; SEthernetHeader sEthHeader; void * pvRrvTime; void * pMICHDR; PSMgmtObject pMgmt = pDevice->pMgmt; WORD wCurrentRate = RATE_1M; PUWLAN_80211HDR p80211Header; - UINT uNodeIndex = 0; + unsigned int uNodeIndex = 0; BOOL bNodeExist = FALSE; SKeyItem STempKey; PSKeyItem pTransmitKey = NULL; @@ -2870,7 +2870,7 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, UINT cbMPDU PBYTE pbyPayloadHead; PBYTE pbyMacHdr; - UINT cbExtSuppRate = 0; + unsigned int cbExtSuppRate = 0; // PWLAN_IE pItem; diff --git a/drivers/staging/vt6655/rxtx.h b/drivers/staging/vt6655/rxtx.h index b008fc23adb9..e2754071317e 100644 --- a/drivers/staging/vt6655/rxtx.h +++ b/drivers/staging/vt6655/rxtx.h @@ -44,7 +44,7 @@ void vGenerateMACHeader( PSDevice pDevice, DWORD dwTxBufferAddr, PBYTE pbySkbData, - UINT cbPacketSize, + unsigned int cbPacketSize, BOOL bDMA0Used, PUINT pcbHeadSize, PUINT pcbAppendPayload @@ -53,7 +53,7 @@ void vGenerateMACHeader( void vProcessRxMACHeader ( PSDevice pDevice, DWORD dwRxBufferAddr, - UINT cbPacketSize, + unsigned int cbPacketSize, BOOL bIsWEP, PUINT pcbHeadSize ); @@ -68,16 +68,16 @@ vGenerateMACHeader ( PSEthernetHeader psEthHeader, BOOL bNeedEncrypt, WORD wFragType, - UINT uDMAIdx, - UINT uFragIdx + unsigned int uDMAIdx, + unsigned int uFragIdx ); -UINT +unsigned int cbGetFragCount( PSDevice pDevice, PSKeyItem pTransmitKey, - UINT cbFrameBodySize, + unsigned int cbFrameBodySize, PSEthernetHeader psEthHeader ); @@ -88,19 +88,19 @@ vGenerateFIFOHeader ( BYTE byPktTyp, PBYTE pbyTxBufferAddr, BOOL bNeedEncrypt, - UINT cbPayloadSize, - UINT uDMAIdx, + unsigned int cbPayloadSize, + unsigned int uDMAIdx, PSTxDesc pHeadTD, PSEthernetHeader psEthHeader, PBYTE pPacket, PSKeyItem pTransmitKey, - UINT uNodeIndex, + unsigned int uNodeIndex, PUINT puMACfragNum, PUINT pcbHeaderSize ); -void vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, UINT cbMPDULen); +void vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, unsigned int cbMPDULen); CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket); CMD_STATUS csBeacon_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket); diff --git a/drivers/staging/vt6655/tcrc.c b/drivers/staging/vt6655/tcrc.c index 5f0c74763f87..d13e8e1ccd96 100644 --- a/drivers/staging/vt6655/tcrc.c +++ b/drivers/staging/vt6655/tcrc.c @@ -132,7 +132,7 @@ static const DWORD s_adwCrc32Table[256] = { * Return Value: CRC-32 * -*/ -DWORD CRCdwCrc32 (PBYTE pbyData, UINT cbByte, DWORD dwCrcSeed) +DWORD CRCdwCrc32 (PBYTE pbyData, unsigned int cbByte, DWORD dwCrcSeed) { DWORD dwCrc; @@ -164,7 +164,7 @@ DWORD CRCdwCrc32 (PBYTE pbyData, UINT cbByte, DWORD dwCrcSeed) * Return Value: CRC-32 * -*/ -DWORD CRCdwGetCrc32 (PBYTE pbyData, UINT cbByte) +DWORD CRCdwGetCrc32 (PBYTE pbyData, unsigned int cbByte) { return ~CRCdwCrc32(pbyData, cbByte, 0xFFFFFFFFL); } @@ -190,7 +190,7 @@ DWORD CRCdwGetCrc32 (PBYTE pbyData, UINT cbByte) * Return Value: CRC-32 * -*/ -DWORD CRCdwGetCrc32Ex(PBYTE pbyData, UINT cbByte, DWORD dwPreCRC) +DWORD CRCdwGetCrc32Ex(PBYTE pbyData, unsigned int cbByte, DWORD dwPreCRC) { return CRCdwCrc32(pbyData, cbByte, dwPreCRC); } diff --git a/drivers/staging/vt6655/tcrc.h b/drivers/staging/vt6655/tcrc.h index 5faa48b0a748..17581b2d6a0c 100644 --- a/drivers/staging/vt6655/tcrc.h +++ b/drivers/staging/vt6655/tcrc.h @@ -43,9 +43,9 @@ /*--------------------- Export Functions --------------------------*/ -DWORD CRCdwCrc32(PBYTE pbyData, UINT cbByte, DWORD dwCrcSeed); -DWORD CRCdwGetCrc32(PBYTE pbyData, UINT cbByte); -DWORD CRCdwGetCrc32Ex(PBYTE pbyData, UINT cbByte, DWORD dwPreCRC); +DWORD CRCdwCrc32(PBYTE pbyData, unsigned int cbByte, DWORD dwCrcSeed); +DWORD CRCdwGetCrc32(PBYTE pbyData, unsigned int cbByte); +DWORD CRCdwGetCrc32Ex(PBYTE pbyData, unsigned int cbByte, DWORD dwPreCRC); #endif // __TCRC_H__ diff --git a/drivers/staging/vt6655/tether.c b/drivers/staging/vt6655/tether.c index d8ba67395cb1..150647db1529 100644 --- a/drivers/staging/vt6655/tether.c +++ b/drivers/staging/vt6655/tether.c @@ -96,7 +96,7 @@ BYTE ETHbyGetHashIndexByCrc32 (PBYTE pbyMultiAddr) * Return Value: TRUE if ok; FALSE if error. * */ -BOOL ETHbIsBufferCrc32Ok (PBYTE pbyBuffer, UINT cbFrameLength) +BOOL ETHbIsBufferCrc32Ok (PBYTE pbyBuffer, unsigned int cbFrameLength) { DWORD dwCRC; diff --git a/drivers/staging/vt6655/tether.h b/drivers/staging/vt6655/tether.h index d0183a25e651..4a9d20287d7c 100644 --- a/drivers/staging/vt6655/tether.h +++ b/drivers/staging/vt6655/tether.h @@ -195,7 +195,7 @@ S802_11Header, *PS802_11Header; BYTE ETHbyGetHashIndexByCrc32(PBYTE pbyMultiAddr); //BYTE ETHbyGetHashIndexByCrc(PBYTE pbyMultiAddr); -BOOL ETHbIsBufferCrc32Ok(PBYTE pbyBuffer, UINT cbFrameLength); +BOOL ETHbIsBufferCrc32Ok(PBYTE pbyBuffer, unsigned int cbFrameLength); #endif // __TETHER_H__ diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h index eaf77d5348e4..23533a7d2990 100644 --- a/drivers/staging/vt6655/ttype.h +++ b/drivers/staging/vt6655/ttype.h @@ -68,7 +68,6 @@ typedef int BOOL; * but it doesn't matter if they're signed or unsigned. */ -typedef unsigned int UINT; typedef unsigned long ULONG; typedef unsigned long long ULONGLONG; //64 bit diff --git a/drivers/staging/vt6655/vntwifi.c b/drivers/staging/vt6655/vntwifi.c index 680c4962cd33..21a9111e91ed 100644 --- a/drivers/staging/vt6655/vntwifi.c +++ b/drivers/staging/vt6655/vntwifi.c @@ -103,7 +103,7 @@ VNTWIFIvSetIBSSParameter ( void *pMgmtHandle, WORD wBeaconPeriod, WORD wATIMWindow, - UINT uChannel + unsigned int uChannel ) { PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; @@ -150,7 +150,7 @@ VNTWIFIpGetCurrentSSID ( * Return Value: current Channel. * -*/ -UINT +unsigned int VNTWIFIpGetCurrentChannel ( void *pMgmtHandle ) @@ -210,7 +210,7 @@ VNTWIFIbyGetMaxSupportRate ( { BYTE byMaxSupportRate = RATE_1M; BYTE bySupportRate = RATE_1M; - UINT ii = 0; + unsigned int ii = 0; if (pSupportRateIEs) { for (ii = 0; ii < pSupportRateIEs->len; ii++) { @@ -257,7 +257,7 @@ VNTWIFIbyGetACKTxRate ( { BYTE byMaxAckRate; BYTE byBasicRate; - UINT ii; + unsigned int ii; if (byRxDataRate <= RATE_11M) { byMaxAckRate = RATE_1M; @@ -431,10 +431,10 @@ VNTWIFIvQueryBSSList ( void **pvFirstBSS ) { - UINT ii = 0; + unsigned int ii = 0; PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; PKnownBSS pBSS = NULL; - UINT uCount = 0; + unsigned int uCount = 0; *pvFirstBSS = NULL; @@ -504,8 +504,8 @@ VNTWIFIvUpdateNodeTxCounter( ) { PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - UINT uNodeIndex = 0; - UINT ii; + unsigned int uNodeIndex = 0; + unsigned int ii; if ((pMgmt->eCurrMode == WMAC_MODE_IBSS_STA) || (pMgmt->eCurrMode == WMAC_MODE_ESS_AP)) { @@ -540,7 +540,7 @@ VNTWIFIvGetTxRate( ) { PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; - UINT uNodeIndex = 0; + unsigned int uNodeIndex = 0; WORD wTxDataRate = RATE_1M; BYTE byACKRate = RATE_1M; BYTE byCCKBasicRate = RATE_1M; @@ -626,7 +626,7 @@ VNTWIFIbInit( { PSMgmtObject pMgmt = NULL; - UINT ii; + unsigned int ii; pMgmt = (PSMgmtObject)kmalloc(sizeof(SMgmtObject), (int)GFP_ATOMIC); diff --git a/drivers/staging/vt6655/vntwifi.h b/drivers/staging/vt6655/vntwifi.h index c91dfd79adca..683a6acef94c 100644 --- a/drivers/staging/vt6655/vntwifi.h +++ b/drivers/staging/vt6655/vntwifi.h @@ -145,7 +145,7 @@ VNTWIFIvSetIBSSParameter ( void *pMgmtHandle, WORD wBeaconPeriod, WORD wATIMWindow, - UINT uChannel + unsigned int uChannel ); void @@ -159,7 +159,7 @@ VNTWIFIpGetCurrentSSID( void *pMgmtHandle ); -UINT +unsigned int VNTWIFIpGetCurrentChannel( void *pMgmtHandle ); diff --git a/drivers/staging/vt6655/wcmd.c b/drivers/staging/vt6655/wcmd.c index c2bf287961a9..517cad9fbed2 100644 --- a/drivers/staging/vt6655/wcmd.c +++ b/drivers/staging/vt6655/wcmd.c @@ -216,7 +216,7 @@ s_vProbeChannel( PBYTE pbyRate; PSTxMgmtPacket pTxPacket; PSMgmtObject pMgmt = pDevice->pMgmt; - UINT ii; + unsigned int ii; if (pDevice->eCurrentPHYType == PHY_TYPE_11A) { @@ -320,7 +320,7 @@ s_MgrMakeProbeRequest( void vCommandTimerWait( void *hDeviceContext, - UINT MSecond + unsigned int MSecond ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -329,7 +329,7 @@ vCommandTimerWait( pDevice->sTimerCommand.data = (ULONG)pDevice; pDevice->sTimerCommand.function = (TimerFunction)vCommandTimer; // RUN_AT :1 msec ~= (HZ/1024) - pDevice->sTimerCommand.expires = (UINT)RUN_AT((MSecond * HZ) >> 10); + pDevice->sTimerCommand.expires = (unsigned int)RUN_AT((MSecond * HZ) >> 10); add_timer(&pDevice->sTimerCommand); return; } @@ -347,7 +347,7 @@ vCommandTimer ( PWLAN_IE_SSID pItemSSID; PWLAN_IE_SSID pItemSSIDCurr; CMD_STATUS Status; - UINT ii; + unsigned int ii; BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; struct sk_buff *skb; @@ -1065,8 +1065,8 @@ BOOL bClearBSSID_SCAN ( ) { PSDevice pDevice = (PSDevice)hDeviceContext; - UINT uCmdDequeueIdx = pDevice->uCmdDequeueIdx; - UINT ii; + unsigned int uCmdDequeueIdx = pDevice->uCmdDequeueIdx; + unsigned int ii; if ((pDevice->cbFreeCmdQueue < CMD_Q_SIZE) && (uCmdDequeueIdx != pDevice->uCmdEnqueueIdx)) { for (ii = 0; ii < (CMD_Q_SIZE - pDevice->cbFreeCmdQueue); ii ++) { diff --git a/drivers/staging/vt6655/wcmd.h b/drivers/staging/vt6655/wcmd.h index c3c418089513..0063b9945504 100644 --- a/drivers/staging/vt6655/wcmd.h +++ b/drivers/staging/vt6655/wcmd.h @@ -133,7 +133,7 @@ bScheduleCommand( void vCommandTimerWait( void *hDeviceContext, - UINT MSecond + unsigned int MSecond ); #ifdef TxInSleep void diff --git a/drivers/staging/vt6655/wctl.c b/drivers/staging/vt6655/wctl.c index e9c3a6e57a0d..3e0d0eba73f9 100644 --- a/drivers/staging/vt6655/wctl.c +++ b/drivers/staging/vt6655/wctl.c @@ -68,8 +68,8 @@ BOOL WCTLbIsDuplicate (PSCache pCache, PS802_11Header pMACHeader) { - UINT uIndex; - UINT ii; + unsigned int uIndex; + unsigned int ii; PSCacheEntry pCacheEntry; if (IS_FC_RETRY(pMACHeader)) { @@ -108,9 +108,9 @@ BOOL WCTLbIsDuplicate (PSCache pCache, PS802_11Header pMACHeader) * Return Value: index number in Defragment Database * */ -UINT WCTLuSearchDFCB (PSDevice pDevice, PS802_11Header pMACHeader) +unsigned int WCTLuSearchDFCB (PSDevice pDevice, PS802_11Header pMACHeader) { -UINT ii; +unsigned int ii; for(ii=0;iicbDFCB;ii++) { if ((pDevice->sRxDFCB[ii].bInUse == TRUE) && @@ -138,9 +138,9 @@ UINT ii; * Return Value: index number in Defragment Database * */ -UINT WCTLuInsertDFCB (PSDevice pDevice, PS802_11Header pMACHeader) +unsigned int WCTLuInsertDFCB (PSDevice pDevice, PS802_11Header pMACHeader) { -UINT ii; +unsigned int ii; if (pDevice->cbFreeDFCB == 0) return(pDevice->cbDFCB); @@ -175,9 +175,9 @@ UINT ii; * Return Value: TRUE if it is valid fragment packet and we have resource to defragment; otherwise FALSE * */ -BOOL WCTLbHandleFragment (PSDevice pDevice, PS802_11Header pMACHeader, UINT cbFrameLength, BOOL bWEP, BOOL bExtIV) +BOOL WCTLbHandleFragment (PSDevice pDevice, PS802_11Header pMACHeader, unsigned int cbFrameLength, BOOL bWEP, BOOL bExtIV) { -UINT uHeaderSize; +unsigned int uHeaderSize; if (bWEP == TRUE) { diff --git a/drivers/staging/vt6655/wctl.h b/drivers/staging/vt6655/wctl.h index a1ac4791bfd3..f5255b1de338 100644 --- a/drivers/staging/vt6655/wctl.h +++ b/drivers/staging/vt6655/wctl.h @@ -98,9 +98,10 @@ /*--------------------- Export Functions --------------------------*/ BOOL WCTLbIsDuplicate(PSCache pCache, PS802_11Header pMACHeader); -BOOL WCTLbHandleFragment(PSDevice pDevice, PS802_11Header pMACHeader, UINT cbFrameLength, BOOL bWEP, BOOL bExtIV); -UINT WCTLuSearchDFCB(PSDevice pDevice, PS802_11Header pMACHeader); -UINT WCTLuInsertDFCB(PSDevice pDevice, PS802_11Header pMACHeader); +BOOL WCTLbHandleFragment(PSDevice pDevice, PS802_11Header pMACHeader, + unsigned int cbFrameLength, BOOL bWEP, BOOL bExtIV); +unsigned int WCTLuSearchDFCB(PSDevice pDevice, PS802_11Header pMACHeader); +unsigned int WCTLuInsertDFCB(PSDevice pDevice, PS802_11Header pMACHeader); #endif // __WCTL_H__ diff --git a/drivers/staging/vt6655/wmgr.c b/drivers/staging/vt6655/wmgr.c index d9980f17055b..093ccd3163e3 100644 --- a/drivers/staging/vt6655/wmgr.c +++ b/drivers/staging/vt6655/wmgr.c @@ -118,7 +118,7 @@ s_vMgrRxAssocRequest( PSDevice pDevice, PSMgmtObject pMgmt, PSRxMgmtPacket pRxPacket, - UINT uNodeIndex + unsigned int uNodeIndex ); static @@ -242,7 +242,7 @@ s_MgrMakeBeacon( PSMgmtObject pMgmt, WORD wCurrCapInfo, WORD wCurrBeaconPeriod, - UINT uCurrChannel, + unsigned int uCurrChannel, WORD wCurrATIMWinodw, PWLAN_IE_SSID pCurrSSID, PBYTE pCurrBSSID, @@ -287,7 +287,7 @@ s_MgrMakeProbeResponse( PSMgmtObject pMgmt, WORD wCurrCapInfo, WORD wCurrBeaconPeriod, - UINT uCurrChannel, + unsigned int uCurrChannel, WORD wCurrATIMWinodw, PBYTE pDstAddr, PWLAN_IE_SSID pCurrSSID, @@ -310,7 +310,7 @@ static void s_vMgrSynchBSS ( PSDevice pDevice, - UINT uBSSMode, + unsigned int uBSSMode, PKnownBSS pCurr, PCMD_STATUS pStatus ); @@ -683,7 +683,7 @@ s_vMgrRxAssocRequest( PSDevice pDevice, PSMgmtObject pMgmt, PSRxMgmtPacket pRxPacket, - UINT uNodeIndex + unsigned int uNodeIndex ) { WLAN_FR_ASSOCREQ sFrame; @@ -691,7 +691,7 @@ s_vMgrRxAssocRequest( PSTxMgmtPacket pTxPacket; WORD wAssocStatus = 0; WORD wAssocAID = 0; - UINT uRateLen = WLAN_RATES_MAXLEN; + unsigned int uRateLen = WLAN_RATES_MAXLEN; BYTE abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; BYTE abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; @@ -845,7 +845,7 @@ s_vMgrRxReAssocRequest( PSDevice pDevice, PSMgmtObject pMgmt, PSRxMgmtPacket pRxPacket, - UINT uNodeIndex + unsigned int uNodeIndex ) { WLAN_FR_REASSOCREQ sFrame; @@ -853,7 +853,7 @@ s_vMgrRxReAssocRequest( PSTxMgmtPacket pTxPacket; WORD wAssocStatus = 0; WORD wAssocAID = 0; - UINT uRateLen = WLAN_RATES_MAXLEN; + unsigned int uRateLen = WLAN_RATES_MAXLEN; BYTE abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; BYTE abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; @@ -1331,7 +1331,7 @@ s_vMgrRxAuthenSequence_1( ) { PSTxMgmtPacket pTxPacket = NULL; - UINT uNodeIndex; + unsigned int uNodeIndex; WLAN_FR_AUTHEN sFrame; PSKeyItem pTransmitKey; @@ -1539,8 +1539,8 @@ s_vMgrRxAuthenSequence_3( ) { PSTxMgmtPacket pTxPacket = NULL; - UINT uStatusCode = 0 ; - UINT uNodeIndex = 0; + unsigned int uStatusCode = 0 ; + unsigned int uNodeIndex = 0; WLAN_FR_AUTHEN sFrame; if (!WLAN_GET_FC_ISWEP(pFrame->pHdr->sA3.wFrameCtl)) { @@ -1666,7 +1666,7 @@ s_vMgrRxDisassociation( ) { WLAN_FR_DISASSOC sFrame; - UINT uNodeIndex = 0; + unsigned int uNodeIndex = 0; // CMD_STATUS CmdStatus; viawget_wpa_header *wpahdr; @@ -1745,7 +1745,7 @@ s_vMgrRxDeauthentication( ) { WLAN_FR_DEAUTHEN sFrame; - UINT uNodeIndex = 0; + unsigned int uNodeIndex = 0; viawget_wpa_header *wpahdr; @@ -1882,17 +1882,17 @@ s_vMgrRxBeacon( BOOL bUpdateTSF = FALSE; BOOL bIsAPBeacon = FALSE; BOOL bIsChannelEqual = FALSE; - UINT uLocateByteIndex; + unsigned int uLocateByteIndex; BYTE byTIMBitOn = 0; WORD wAIDNumber = 0; - UINT uNodeIndex; + unsigned int uNodeIndex; QWORD qwTimestamp, qwLocalTSF; QWORD qwCurrTSF; WORD wStartIndex = 0; WORD wAIDIndex = 0; BYTE byCurrChannel = pRxPacket->byRxChannel; ERPObject sERP; - UINT uRateLen = WLAN_RATES_MAXLEN; + unsigned int uRateLen = WLAN_RATES_MAXLEN; BOOL bChannelHit = FALSE; BOOL bUpdatePhyParameter = FALSE; BYTE byIEChannel = 0; @@ -2397,7 +2397,7 @@ vMgrCreateOwnIBSS( BYTE byTopCCKBasicRate; BYTE byTopOFDMBasicRate; QWORD qwCurrTSF; - UINT ii; + unsigned int ii; BYTE abyRATE[] = {0x82, 0x84, 0x8B, 0x96, 0x24, 0x30, 0x48, 0x6C, 0x0C, 0x12, 0x18, 0x60}; BYTE abyCCK_RATE[] = {0x82, 0x84, 0x8B, 0x96}; BYTE abyOFDM_RATE[] = {0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; @@ -2661,11 +2661,11 @@ vMgrJoinBSSBegin( PSDevice pDevice = (PSDevice)hDeviceContext; PSMgmtObject pMgmt = pDevice->pMgmt; PKnownBSS pCurr = NULL; - UINT ii, uu; + unsigned int ii, uu; PWLAN_IE_SUPP_RATES pItemRates = NULL; PWLAN_IE_SUPP_RATES pItemExtRates = NULL; PWLAN_IE_SSID pItemSSID; - UINT uRateLen = WLAN_RATES_MAXLEN; + unsigned int uRateLen = WLAN_RATES_MAXLEN; WORD wMaxBasicRate = RATE_1M; WORD wMaxSuppRate = RATE_1M; WORD wSuppRate; @@ -2764,7 +2764,7 @@ vMgrJoinBSSBegin( uRateLen); // Stuffing Rate IE if ((pItemExtRates->len > 0) && (pItemRates->len < 8)) { - for (ii = 0; ii < (UINT)(8 - pItemRates->len); ) { + for (ii = 0; ii < (unsigned int)(8 - pItemRates->len); ) { pItemRates->abyRates[pItemRates->len + ii] = pItemExtRates->abyRates[ii]; ii ++; if (pItemExtRates->len <= ii) @@ -2923,7 +2923,7 @@ static void s_vMgrSynchBSS ( PSDevice pDevice, - UINT uBSSMode, + unsigned int uBSSMode, PKnownBSS pCurr, PCMD_STATUS pStatus ) @@ -3094,7 +3094,7 @@ s_vMgrSynchBSS ( ) { PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - // UINT ii , uSameBssidNum=0; + // unsigned int ii , uSameBssidNum=0; // for (ii = 0; ii < MAX_BSS_NUM; ii++) { // if (pMgmt->sBSSList[ii].bActive && @@ -3153,7 +3153,7 @@ s_vMgrFormatTIM( { BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; BYTE byMap; - UINT ii, jj; + unsigned int ii, jj; BOOL bStartFound = FALSE; BOOL bMulticast = FALSE; WORD wStartIndex = 0; @@ -3226,7 +3226,7 @@ s_MgrMakeBeacon( PSMgmtObject pMgmt, WORD wCurrCapInfo, WORD wCurrBeaconPeriod, - UINT uCurrChannel, + unsigned int uCurrChannel, WORD wCurrATIMWinodw, PWLAN_IE_SSID pCurrSSID, PBYTE pCurrBSSID, @@ -3238,9 +3238,9 @@ s_MgrMakeBeacon( WLAN_FR_BEACON sFrame; BYTE abyBroadcastAddr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; PBYTE pbyBuffer; - UINT uLength = 0; + unsigned int uLength = 0; PWLAN_IE_IBSS_DFS pIBSSDFS = NULL; - UINT ii; + unsigned int ii; // prepare beacon frame pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; @@ -3455,7 +3455,7 @@ s_MgrMakeProbeResponse( PSMgmtObject pMgmt, WORD wCurrCapInfo, WORD wCurrBeaconPeriod, - UINT uCurrChannel, + unsigned int uCurrChannel, WORD wCurrATIMWinodw, PBYTE pDstAddr, PWLAN_IE_SSID pCurrSSID, @@ -3468,9 +3468,9 @@ s_MgrMakeProbeResponse( PSTxMgmtPacket pTxPacket = NULL; WLAN_FR_PROBERESP sFrame; PBYTE pbyBuffer; - UINT uLength = 0; + unsigned int uLength = 0; PWLAN_IE_IBSS_DFS pIBSSDFS = NULL; - UINT ii; + unsigned int ii; pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; @@ -3799,7 +3799,7 @@ s_MgrMakeAssocRequest( } else if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) && (pMgmt->pCurrBSS != NULL)) { - UINT ii; + unsigned int ii; PWORD pwPMKID; // WPA IE @@ -4055,7 +4055,7 @@ s_MgrMakeReAssocRequest( } else if (((pMgmt->eAuthenMode == WMAC_AUTH_WPA2) || (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) && (pMgmt->pCurrBSS != NULL)) { - UINT ii; + unsigned int ii; PWORD pwPMKID; /* WPA IE */ @@ -4543,7 +4543,7 @@ vMgrRxManagePacket( { PSDevice pDevice = (PSDevice)hDeviceContext; BOOL bInScan = FALSE; - UINT uNodeIndex = 0; + unsigned int uNodeIndex = 0; NODE_STATE eNodeState = 0; CMD_STATUS Status; @@ -4816,7 +4816,7 @@ bAdd_PMKID_Candidate ( { PSDevice pDevice = (PSDevice)hDeviceContext; PPMKID_CANDIDATE pCandidateList; - UINT ii = 0; + unsigned int ii = 0; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"bAdd_PMKID_Candidate START: (%d)\n", (int)pDevice->gsPMKIDCandidate.NumCandidates); diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index 9367f478dbf6..6b807d0834f0 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -224,8 +224,8 @@ typedef enum tagWMAC_POWER_MODE { typedef struct tagSTxMgmtPacket { PUWLAN_80211HDR p80211Header; - UINT cbMPDULen; - UINT cbPayloadLen; + unsigned int cbMPDULen; + unsigned int cbPayloadLen; } STxMgmtPacket, *PSTxMgmtPacket; @@ -235,9 +235,9 @@ typedef struct tagSRxMgmtPacket { PUWLAN_80211HDR p80211Header; QWORD qwLocalTSF; - UINT cbMPDULen; - UINT cbPayloadLen; - UINT uRSSI; + unsigned int cbMPDULen; + unsigned int cbPayloadLen; + unsigned int uRSSI; BYTE bySQ; BYTE byRxRate; BYTE byRxChannel; @@ -271,7 +271,7 @@ typedef struct tagSMgmtObject // BYTE abyNewExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN]; // Current state vars - UINT uCurrChannel; + unsigned int uCurrChannel; BYTE abyCurrSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; BYTE abyCurrExtSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; BYTE abyCurrSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; @@ -284,7 +284,7 @@ typedef struct tagSMgmtObject BYTE byERPContext; CMD_STATE eCommandState; - UINT uScanChannel; + unsigned int uScanChannel; // Desire joinning BSS vars BYTE abyDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; @@ -294,22 +294,22 @@ typedef struct tagSMgmtObject //BYTE abyAdHocSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; WORD wIBSSBeaconPeriod; WORD wIBSSATIMWindow; - UINT uIBSSChannel; + unsigned int uIBSSChannel; BYTE abyIBSSSuppRates[WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1]; BYTE byAPBBType; BYTE abyWPAIE[MAX_WPA_IE_LEN]; WORD wWPAIELen; - UINT uAssocCount; + unsigned int uAssocCount; BOOL bMoreData; // Scan state vars WMAC_SCAN_STATE eScanState; WMAC_SCAN_TYPE eScanType; - UINT uScanStartCh; - UINT uScanEndCh; + unsigned int uScanStartCh; + unsigned int uScanEndCh; WORD wScanSteps; - UINT uScanBSSType; + unsigned int uScanBSSType; // Desire scannig vars BYTE abyScanSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; BYTE abyScanBSSID[WLAN_BSSID_LEN]; @@ -338,8 +338,8 @@ typedef struct tagSMgmtObject BYTE abyPSTxMap[MAX_NODE_NUM + 1]; // management command related - UINT uCmdBusy; - UINT uCmdHostAPBusy; + unsigned int uCmdBusy; + unsigned int uCmdHostAPBusy; // management packet pool PBYTE pbyMgmtPacketPool; @@ -381,7 +381,7 @@ typedef struct tagSMgmtObject BOOL bSwitchChannel; BYTE byNewChannel; PWLAN_IE_MEASURE_REP pCurrMeasureEIDRep; - UINT uLengthOfRepEIDs; + unsigned int uLengthOfRepEIDs; BYTE abyCurrentMSRReq[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN]; BYTE abyCurrentMSRRep[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN]; BYTE abyIECountry[WLAN_A3FR_MAXLEN]; diff --git a/drivers/staging/vt6655/wpa2.c b/drivers/staging/vt6655/wpa2.c index 7a42a0aad7d2..caa32b752c9f 100644 --- a/drivers/staging/vt6655/wpa2.c +++ b/drivers/staging/vt6655/wpa2.c @@ -261,7 +261,7 @@ WPA2vParseRSN ( * Return Value: length of IEs. * -*/ -UINT +unsigned int WPA2uSetIEs( void *pMgmtHandle, PWLAN_IE_RSN pRSNIEs @@ -269,7 +269,7 @@ WPA2uSetIEs( { PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle; PBYTE pbyBuffer = NULL; - UINT ii = 0; + unsigned int ii = 0; PWORD pwPMKID = NULL; if (pRSNIEs == NULL) { diff --git a/drivers/staging/vt6655/wpa2.h b/drivers/staging/vt6655/wpa2.h index 7200db37f430..8ad1eeaec70f 100644 --- a/drivers/staging/vt6655/wpa2.h +++ b/drivers/staging/vt6655/wpa2.h @@ -69,7 +69,7 @@ WPA2vParseRSN ( PWLAN_IE_RSN pRSN ); -UINT +unsigned int WPA2uSetIEs( void *pMgmtHandle, PWLAN_IE_RSN pRSNIEs diff --git a/drivers/staging/vt6655/wroute.c b/drivers/staging/vt6655/wroute.c index bf92fb9908fe..648ae1aa2b18 100644 --- a/drivers/staging/vt6655/wroute.c +++ b/drivers/staging/vt6655/wroute.c @@ -65,18 +65,18 @@ static int msglevel =MSG_LEVEL_INFO; * Return Value: TRUE if packet duplicate; otherwise FALSE * */ -BOOL ROUTEbRelay (PSDevice pDevice, PBYTE pbySkbData, UINT uDataLen, UINT uNodeIndex) +BOOL ROUTEbRelay (PSDevice pDevice, PBYTE pbySkbData, unsigned int uDataLen, unsigned int uNodeIndex) { PSMgmtObject pMgmt = pDevice->pMgmt; PSTxDesc pHeadTD, pLastTD; - UINT cbFrameBodySize; - UINT uMACfragNum; + unsigned int cbFrameBodySize; + unsigned int uMACfragNum; BYTE byPktType; BOOL bNeedEncryption = FALSE; SKeyItem STempKey; PSKeyItem pTransmitKey = NULL; - UINT cbHeaderSize; - UINT ii; + unsigned int cbHeaderSize; + unsigned int ii; PBYTE pbyBSSID; diff --git a/drivers/staging/vt6655/wroute.h b/drivers/staging/vt6655/wroute.h index 295cdc5b8e9d..199d31153d8e 100644 --- a/drivers/staging/vt6655/wroute.h +++ b/drivers/staging/vt6655/wroute.h @@ -39,7 +39,7 @@ /*--------------------- Export Functions --------------------------*/ -BOOL ROUTEbRelay (PSDevice pDevice, PBYTE pbySkbData, UINT uDataLen, UINT uNodeIndex); +BOOL ROUTEbRelay (PSDevice pDevice, PBYTE pbySkbData, unsigned int uDataLen, unsigned int uNodeIndex); #endif // __WROUTE_H__ From e3fd16d0819e3b316a4fe316e5f32032df61e9db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Wed, 2 Jun 2010 09:52:02 -0700 Subject: [PATCH 061/523] Staging: vt6655: remove custom ULONG typedef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/baseband.c | 10 +++++----- drivers/staging/vt6655/bssdb.c | 6 +++--- drivers/staging/vt6655/bssdb.h | 2 +- drivers/staging/vt6655/card.h | 2 +- drivers/staging/vt6655/device.h | 28 ++++++++++++++-------------- drivers/staging/vt6655/device_main.c | 13 +++++++------ drivers/staging/vt6655/ioctl.c | 2 +- drivers/staging/vt6655/ioctl.h | 2 +- drivers/staging/vt6655/key.c | 6 +++--- drivers/staging/vt6655/key.h | 8 ++++---- drivers/staging/vt6655/mib.h | 20 ++++++++++---------- drivers/staging/vt6655/ttype.h | 1 - drivers/staging/vt6655/upc.h | 2 +- drivers/staging/vt6655/vntwifi.c | 2 +- drivers/staging/vt6655/vntwifi.h | 2 +- drivers/staging/vt6655/wcmd.c | 6 +++--- drivers/staging/vt6655/wmgr.c | 6 +++--- drivers/staging/vt6655/wmgr.h | 14 +++++++------- drivers/staging/vt6655/wpa2.h | 2 +- 19 files changed, 67 insertions(+), 67 deletions(-) diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index 2fe91b87666a..c772c2901641 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -1719,7 +1719,7 @@ const WORD awcFrameTime[MAX_RATE] = /*--------------------- Static Functions --------------------------*/ static -ULONG +unsigned long s_ulGetRatio(PSDevice pDevice); static @@ -2651,12 +2651,12 @@ BBvExitDeepSleep (DWORD_PTR dwIoBase, BYTE byLocalID) static -ULONG +unsigned long s_ulGetRatio (PSDevice pDevice) { -ULONG ulRatio = 0; -ULONG ulMaxPacket; -ULONG ulPacketNum; +unsigned long ulRatio = 0; +unsigned long ulMaxPacket; +unsigned long ulPacketNum; //This is a thousand-ratio ulMaxPacket = pDevice->uNumSQ3[RATE_54M]; diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c index e919b2954a52..d16d799636a3 100644 --- a/drivers/staging/vt6655/bssdb.c +++ b/drivers/staging/vt6655/bssdb.c @@ -1680,9 +1680,9 @@ void s_uCalculateLinkQual( ) { PSDevice pDevice = (PSDevice)hDeviceContext; - ULONG TxOkRatio, TxCnt; - ULONG RxOkRatio,RxCnt; - ULONG RssiRatio; + unsigned long TxOkRatio, TxCnt; + unsigned long RxOkRatio,RxCnt; + unsigned long RssiRatio; long ldBm; TxCnt = pDevice->scStatistic.TxNoRetryOkCount + diff --git a/drivers/staging/vt6655/bssdb.h b/drivers/staging/vt6655/bssdb.h index c7283d208dfb..6da5685440f8 100644 --- a/drivers/staging/vt6655/bssdb.h +++ b/drivers/staging/vt6655/bssdb.h @@ -205,7 +205,7 @@ typedef struct tagKnownNodeDB { BOOL bPSEnable; BOOL bRxPSPoll; BYTE byAuthSequence; - ULONG ulLastRxJiffer; + unsigned long ulLastRxJiffer; BYTE bySuppRate; DWORD dwFlags; WORD wEnQueueCnt; diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index f2f79407f4ab..40271a1f1873 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -99,7 +99,7 @@ void CARDvUpdateNextTBTT(DWORD_PTR dwIoBase, QWORD qwTSF, WORD wBeaconInterval); BOOL CARDbGetCurrentTSF(DWORD_PTR dwIoBase, PQWORD pqwCurrTSF); QWORD CARDqGetNextTBTT(QWORD qwTSF, WORD wBeaconInterval); QWORD CARDqGetTSFOffset(BYTE byRxRate, QWORD qwTSF1, QWORD qwTSF2); -BOOL CARDbSetTxPower(void *pDeviceHandler, ULONG ulTxPower); +BOOL CARDbSetTxPower(void *pDeviceHandler, unsigned long ulTxPower); BYTE CARDbyGetPktType(void *pDeviceHandler); void CARDvSafeResetTx(void *pDeviceHandler); void CARDvSafeResetRx(void *pDeviceHandler); diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 1685fb98d2fd..736af6e49a8e 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -250,7 +250,7 @@ typedef enum _NDIS_802_11_STATUS_TYPE //Added new types for PMKID Candidate lists. typedef struct _PMKID_CANDIDATE { NDIS_802_11_MAC_ADDRESS BSSID; - ULONG Flags; + unsigned long Flags; } PMKID_CANDIDATE, *PPMKID_CANDIDATE; @@ -261,15 +261,15 @@ typedef struct _BSSID_INFO } BSSID_INFO, *PBSSID_INFO; typedef struct tagSPMKID { - ULONG Length; - ULONG BSSIDInfoCount; + unsigned long Length; + unsigned long BSSIDInfoCount; BSSID_INFO BSSIDInfo[MAX_BSSIDINFO_4_PMKID]; } SPMKID, *PSPMKID; typedef struct tagSPMKIDCandidateEvent { NDIS_802_11_STATUS_TYPE StatusType; - ULONG Version; // Version of the structure - ULONG NumCandidates; // No. of pmkid candidates + unsigned long Version; // Version of the structure + unsigned long NumCandidates; // No. of pmkid candidates PMKID_CANDIDATE CandidateList[MAX_PMKIDLIST]; } SPMKIDCandidateEvent, *PSPMKIDCandidateEvent; @@ -618,7 +618,7 @@ typedef struct __device_info { //WOW BYTE abyIPAddr[4]; - ULONG ulTxPower; + unsigned long ulTxPower; NDIS_802_11_WEP_STATUS eEncryptionStatus; BOOL bTransmitKey; //2007-0925-01by MikeLiu @@ -712,7 +712,7 @@ typedef struct __device_info { struct timer_list sTimerCommand; #ifdef TxInSleep struct timer_list sTimerTxData; - ULONG nTxDataTimeCout; + unsigned long nTxDataTimeCout; BOOL fTxDataInSleep; BOOL IsTxDataTrigger; #endif @@ -728,18 +728,18 @@ typedef struct __device_info { BOOL bDiversityRegCtlON; BOOL bDiversityEnable; - ULONG ulDiversityNValue; - ULONG ulDiversityMValue; + unsigned long ulDiversityNValue; + unsigned long ulDiversityMValue; BYTE byTMax; BYTE byTMax2; BYTE byTMax3; - ULONG ulSQ3TH; + unsigned long ulSQ3TH; // ANT diversity - ULONG uDiversityCnt; + unsigned long uDiversityCnt; BYTE byAntennaState; - ULONG ulRatio_State0; - ULONG ulRatio_State1; + unsigned long ulRatio_State0; + unsigned long ulRatio_State1; //SQ3 functions for antenna diversity struct timer_list TimerSQ3Tmax1; @@ -747,7 +747,7 @@ typedef struct __device_info { struct timer_list TimerSQ3Tmax3; - ULONG uNumSQ3[MAX_RATE]; + unsigned long uNumSQ3[MAX_RATE]; WORD wAntDiversityMaxRate; diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index c8ae43aba80e..e3c2ba758b2e 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -588,7 +588,7 @@ static void device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) pDevice->ulDiversityMValue = 100*16;//SROMbyReadEmbedded(pDevice->PortOffset, 0x52); pDevice->byTMax = 1;//SROMbyReadEmbedded(pDevice->PortOffset, 0x53); pDevice->byTMax2 = 4;//SROMbyReadEmbedded(pDevice->PortOffset, 0x54); - pDevice->ulSQ3TH = 0;//(ULONG) SROMbyReadEmbedded(pDevice->PortOffset, 0x55); + pDevice->ulSQ3TH = 0;//(unsigned long) SROMbyReadEmbedded(pDevice->PortOffset, 0x55); pDevice->byTMax3 = 64;//SROMbyReadEmbedded(pDevice->PortOffset, 0x56); if (byValue == (EEP_ANTENNA_AUX | EEP_ANTENNA_MAIN)) { @@ -851,17 +851,17 @@ else CARDbRadioPowerOn(pDevice); static void device_init_diversity_timer(PSDevice pDevice) { init_timer(&pDevice->TimerSQ3Tmax1); - pDevice->TimerSQ3Tmax1.data = (ULONG)pDevice; + pDevice->TimerSQ3Tmax1.data = (unsigned long) pDevice; pDevice->TimerSQ3Tmax1.function = (TimerFunction)TimerSQ3CallBack; pDevice->TimerSQ3Tmax1.expires = RUN_AT(HZ); init_timer(&pDevice->TimerSQ3Tmax2); - pDevice->TimerSQ3Tmax2.data = (ULONG)pDevice; + pDevice->TimerSQ3Tmax2.data = (unsigned long) pDevice; pDevice->TimerSQ3Tmax2.function = (TimerFunction)TimerSQ3CallBack; pDevice->TimerSQ3Tmax2.expires = RUN_AT(HZ); init_timer(&pDevice->TimerSQ3Tmax3); - pDevice->TimerSQ3Tmax3.data = (ULONG)pDevice; + pDevice->TimerSQ3Tmax3.data = (unsigned long) pDevice; pDevice->TimerSQ3Tmax3.function = (TimerFunction)TimerState1CallBack; pDevice->TimerSQ3Tmax3.expires = RUN_AT(HZ); @@ -1112,10 +1112,11 @@ static void device_print_info(PSDevice pDevice) DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "%s: %s\n",dev->name, get_chip_name(pDevice->chip_id)); DBG_PRT(MSG_LEVEL_INFO, KERN_INFO "%s: MAC=%pM", dev->name, dev->dev_addr); #ifdef IO_MAP - DBG_PRT(MSG_LEVEL_INFO, KERN_INFO" IO=0x%lx ",(ULONG) pDevice->ioaddr); + DBG_PRT(MSG_LEVEL_INFO, KERN_INFO" IO=0x%lx ",(unsigned long) pDevice->ioaddr); DBG_PRT(MSG_LEVEL_INFO, KERN_INFO" IRQ=%d \n", pDevice->dev->irq); #else - DBG_PRT(MSG_LEVEL_INFO, KERN_INFO" IO=0x%lx Mem=0x%lx ",(ULONG) pDevice->ioaddr,(ULONG) pDevice->PortOffset); + DBG_PRT(MSG_LEVEL_INFO, KERN_INFO" IO=0x%lx Mem=0x%lx ", + (unsigned long) pDevice->ioaddr,(unsigned long) pDevice->PortOffset); DBG_PRT(MSG_LEVEL_INFO, KERN_INFO" IRQ=%d \n", pDevice->dev->irq); #endif diff --git a/drivers/staging/vt6655/ioctl.c b/drivers/staging/vt6655/ioctl.c index b7049938c30a..6118a3cb02e4 100644 --- a/drivers/staging/vt6655/ioctl.c +++ b/drivers/staging/vt6655/ioctl.c @@ -719,7 +719,7 @@ vConfigWEPKey ( PSDevice pDevice, DWORD dwKeyIndex, PBYTE pbyKey, - ULONG uKeyLength + unsigned long uKeyLength ) { int ii; diff --git a/drivers/staging/vt6655/ioctl.h b/drivers/staging/vt6655/ioctl.h index 0d10c2a923c6..4a30e271294f 100644 --- a/drivers/staging/vt6655/ioctl.h +++ b/drivers/staging/vt6655/ioctl.h @@ -47,7 +47,7 @@ void vConfigWEPKey ( PSDevice pDevice, DWORD dwKeyIndex, PBYTE pbyKey, - ULONG uKeyLength + unsigned long uKeyLength ); */ diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c index da5def3214b3..141d249541c2 100644 --- a/drivers/staging/vt6655/key.c +++ b/drivers/staging/vt6655/key.c @@ -193,7 +193,7 @@ BOOL KeybSetKey ( PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyIndex, - ULONG uKeyLength, + unsigned long uKeyLength, PQWORD pKeyRSC, PBYTE pbyKey, BYTE byKeyDecMode, @@ -634,7 +634,7 @@ BOOL KeybCheckPairewiseKey ( BOOL KeybSetDefaultKey ( PSKeyManagement pTable, DWORD dwKeyIndex, - ULONG uKeyLength, + unsigned long uKeyLength, PQWORD pKeyRSC, PBYTE pbyKey, BYTE byKeyDecMode, @@ -741,7 +741,7 @@ BOOL KeybSetDefaultKey ( BOOL KeybSetAllGroupKey ( PSKeyManagement pTable, DWORD dwKeyIndex, - ULONG uKeyLength, + unsigned long uKeyLength, PQWORD pKeyRSC, PBYTE pbyKey, BYTE byKeyDecMode, diff --git a/drivers/staging/vt6655/key.h b/drivers/staging/vt6655/key.h index 39403d93aeb1..8ba8b2752ce6 100644 --- a/drivers/staging/vt6655/key.h +++ b/drivers/staging/vt6655/key.h @@ -58,7 +58,7 @@ typedef struct tagSKeyItem { BOOL bKeyValid; - ULONG uKeyLength; + unsigned long uKeyLength; BYTE abyKey[MAX_KEY_LEN]; QWORD KeyRSC; DWORD dwTSC47_16; @@ -114,7 +114,7 @@ BOOL KeybSetKey( PSKeyManagement pTable, PBYTE pbyBSSID, DWORD dwKeyIndex, - ULONG uKeyLength, + unsigned long uKeyLength, PQWORD pKeyRSC, PBYTE pbyKey, BYTE byKeyDecMode, @@ -125,7 +125,7 @@ BOOL KeybSetKey( BOOL KeybSetDefaultKey( PSKeyManagement pTable, DWORD dwKeyIndex, - ULONG uKeyLength, + unsigned long uKeyLength, PQWORD pKeyRSC, PBYTE pbyKey, BYTE byKeyDecMode, @@ -172,7 +172,7 @@ void KeyvRemoveAllWEPKey( BOOL KeybSetAllGroupKey ( PSKeyManagement pTable, DWORD dwKeyIndex, - ULONG uKeyLength, + unsigned long uKeyLength, PQWORD pKeyRSC, PBYTE pbyKey, BYTE byKeyDecMode, diff --git a/drivers/staging/vt6655/mib.h b/drivers/staging/vt6655/mib.h index ffd5fb1d39d5..9f3f52114b56 100644 --- a/drivers/staging/vt6655/mib.h +++ b/drivers/staging/vt6655/mib.h @@ -39,7 +39,7 @@ // typedef struct tagSDot11Counters { - ULONG Length; // Length of structure + unsigned long Length; // Length of structure ULONGLONG TransmittedFragmentCount; ULONGLONG MulticastTransmittedFrameCount; ULONGLONG FailedCount; @@ -138,7 +138,7 @@ typedef struct tagSRmonCounter { // Custom counter // typedef struct tagSCustomCounters { - ULONG Length; + unsigned long Length; ULONGLONG ullTsrAllOK; @@ -177,7 +177,7 @@ typedef struct tagSCustomCounters { // Custom counter // typedef struct tagSISRCounters { - ULONG Length; + unsigned long Length; DWORD dwIsrTx0OK; DWORD dwIsrAC0TxOK; @@ -324,15 +324,15 @@ typedef struct tagSStatCounter { #ifdef Calcu_LinkQual //Tx count: - ULONG TxNoRetryOkCount; //success tx no retry ! - ULONG TxRetryOkCount; //success tx but retry ! - ULONG TxFailCount; //fail tx ? + unsigned long TxNoRetryOkCount; //success tx no retry ! + unsigned long TxRetryOkCount; //success tx but retry ! + unsigned long TxFailCount; //fail tx ? //Rx count: - ULONG RxOkCnt; //success rx ! - ULONG RxFcsErrCnt; //fail rx ? + unsigned long RxOkCnt; //success rx ! + unsigned long RxFcsErrCnt; //fail rx ? //statistic - ULONG SignalStren; - ULONG LinkQuality; + unsigned long SignalStren; + unsigned long LinkQuality; #endif } SStatCounter, *PSStatCounter; diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h index 23533a7d2990..950fb097e460 100644 --- a/drivers/staging/vt6655/ttype.h +++ b/drivers/staging/vt6655/ttype.h @@ -68,7 +68,6 @@ typedef int BOOL; * but it doesn't matter if they're signed or unsigned. */ -typedef unsigned long ULONG; typedef unsigned long long ULONGLONG; //64 bit diff --git a/drivers/staging/vt6655/upc.h b/drivers/staging/vt6655/upc.h index acd1b661490d..78a950cbf00d 100644 --- a/drivers/staging/vt6655/upc.h +++ b/drivers/staging/vt6655/upc.h @@ -141,7 +141,7 @@ #define PCAvDelayByIO(uDelayUnit) { \ BYTE byData; \ - ULONG ii; \ + unsigned long ii; \ \ if (uDelayUnit <= 50) { \ udelay(uDelayUnit); \ diff --git a/drivers/staging/vt6655/vntwifi.c b/drivers/staging/vt6655/vntwifi.c index 21a9111e91ed..22069057ac0a 100644 --- a/drivers/staging/vt6655/vntwifi.c +++ b/drivers/staging/vt6655/vntwifi.c @@ -665,7 +665,7 @@ VNTWIFIbInit( BOOL VNTWIFIbSetPMKIDCache ( void *pMgmtObject, - ULONG ulCount, + unsigned long ulCount, void *pPMKIDInfo ) { diff --git a/drivers/staging/vt6655/vntwifi.h b/drivers/staging/vt6655/vntwifi.h index 683a6acef94c..fc1a4f152491 100644 --- a/drivers/staging/vt6655/vntwifi.h +++ b/drivers/staging/vt6655/vntwifi.h @@ -265,7 +265,7 @@ VNTWIFIbyGetKeyCypher( BOOL VNTWIFIbSetPMKIDCache ( void *pMgmtObject, - ULONG ulCount, + unsigned long ulCount, void *pPMKIDInfo ); diff --git a/drivers/staging/vt6655/wcmd.c b/drivers/staging/vt6655/wcmd.c index 517cad9fbed2..9aae07709e34 100644 --- a/drivers/staging/vt6655/wcmd.c +++ b/drivers/staging/vt6655/wcmd.c @@ -326,7 +326,7 @@ vCommandTimerWait( PSDevice pDevice = (PSDevice)hDeviceContext; init_timer(&pDevice->sTimerCommand); - pDevice->sTimerCommand.data = (ULONG)pDevice; + pDevice->sTimerCommand.data = (unsigned long) pDevice; pDevice->sTimerCommand.function = (TimerFunction)vCommandTimer; // RUN_AT :1 msec ~= (HZ/1024) pDevice->sTimerCommand.expires = (unsigned int)RUN_AT((MSecond * HZ) >> 10); @@ -723,7 +723,7 @@ printk("chester-abyDesireSSID=%s\n",((PWLAN_IE_SSID)pMgmt->abyDesireSSID)->abySS // printk("Re-initial TxDataTimer****\n"); del_timer(&pDevice->sTimerTxData); init_timer(&pDevice->sTimerTxData); - pDevice->sTimerTxData.data = (ULONG)pDevice; + pDevice->sTimerTxData.data = (unsigned long) pDevice; pDevice->sTimerTxData.function = (TimerFunction)BSSvSecondTxData; pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback pDevice->fTxDataInSleep = FALSE; @@ -1092,7 +1092,7 @@ vResetCommandTimer( del_timer(&pDevice->sTimerCommand); //init timer init_timer(&pDevice->sTimerCommand); - pDevice->sTimerCommand.data = (ULONG)pDevice; + pDevice->sTimerCommand.data = (unsigned long) pDevice; pDevice->sTimerCommand.function = (TimerFunction)vCommandTimer; pDevice->sTimerCommand.expires = RUN_AT(HZ); pDevice->cbFreeCmdQueue = CMD_Q_SIZE; diff --git a/drivers/staging/vt6655/wmgr.c b/drivers/staging/vt6655/wmgr.c index 093ccd3163e3..41f520afea11 100644 --- a/drivers/staging/vt6655/wmgr.c +++ b/drivers/staging/vt6655/wmgr.c @@ -393,18 +393,18 @@ vMgrTimerInit( init_timer(&pMgmt->sTimerSecondCallback); - pMgmt->sTimerSecondCallback.data = (ULONG)pDevice; + pMgmt->sTimerSecondCallback.data = (unsigned long) pDevice; pMgmt->sTimerSecondCallback.function = (TimerFunction)BSSvSecondCallBack; pMgmt->sTimerSecondCallback.expires = RUN_AT(HZ); init_timer(&pDevice->sTimerCommand); - pDevice->sTimerCommand.data = (ULONG)pDevice; + pDevice->sTimerCommand.data = (unsigned long) pDevice; pDevice->sTimerCommand.function = (TimerFunction)vCommandTimer; pDevice->sTimerCommand.expires = RUN_AT(HZ); #ifdef TxInSleep init_timer(&pDevice->sTimerTxData); - pDevice->sTimerTxData.data = (ULONG)pDevice; + pDevice->sTimerTxData.data = (unsigned long) pDevice; pDevice->sTimerTxData.function = (TimerFunction)BSSvSecondTxData; pDevice->sTimerTxData.expires = RUN_AT(10*HZ); //10s callback pDevice->fTxDataInSleep = FALSE; diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index 6b807d0834f0..a08403e3c610 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -83,7 +83,7 @@ /*--------------------- Export Types ------------------------------*/ #define timer_expire(timer,next_tick) mod_timer(&timer, RUN_AT(next_tick)) -typedef void (*TimerFunction)(ULONG); +typedef void (*TimerFunction)(unsigned long); //+++ NDIS related @@ -105,15 +105,15 @@ typedef struct _NDIS_802_11_AI_RESFI typedef struct _NDIS_802_11_ASSOCIATION_INFORMATION { - ULONG Length; + unsigned long Length; unsigned short AvailableRequestFixedIEs; NDIS_802_11_AI_REQFI RequestFixedIEs; - ULONG RequestIELength; - ULONG OffsetRequestIEs; + unsigned long RequestIELength; + unsigned long OffsetRequestIEs; unsigned short AvailableResponseFixedIEs; NDIS_802_11_AI_RESFI ResponseFixedIEs; - ULONG ResponseIELength; - ULONG OffsetResponseIEs; + unsigned long ResponseIELength; + unsigned long OffsetResponseIEs; } NDIS_802_11_ASSOCIATION_INFORMATION, *PNDIS_802_11_ASSOCIATION_INFORMATION; @@ -122,7 +122,7 @@ typedef struct tagSAssocInfo { NDIS_802_11_ASSOCIATION_INFORMATION AssocInfo; BYTE abyIEs[WLAN_BEACON_FR_MAXLEN+WLAN_BEACON_FR_MAXLEN]; // store ReqIEs set by OID_802_11_ASSOCIATION_INFORMATION - ULONG RequestIELength; + unsigned long RequestIELength; BYTE abyReqIEs[WLAN_BEACON_FR_MAXLEN]; } SAssocInfo, *PSAssocInfo; //--- diff --git a/drivers/staging/vt6655/wpa2.h b/drivers/staging/vt6655/wpa2.h index 8ad1eeaec70f..b6b3768350a2 100644 --- a/drivers/staging/vt6655/wpa2.h +++ b/drivers/staging/vt6655/wpa2.h @@ -45,7 +45,7 @@ typedef struct tagsPMKIDInfo { } PMKIDInfo, *PPMKIDInfo; typedef struct tagSPMKIDCache { - ULONG BSSIDInfoCount; + unsigned long BSSIDInfoCount; PMKIDInfo BSSIDInfo[MAX_PMKID_CACHE]; } SPMKIDCache, *PSPMKIDCache; From b2e876b6089160e5ecaed859eb1b87cd4913793e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Wed, 2 Jun 2010 09:52:03 -0700 Subject: [PATCH 062/523] Staging: vt6655: remove custom ULONGLONG typedef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/bssdb.h | 2 +- drivers/staging/vt6655/dpc.c | 4 +- drivers/staging/vt6655/mib.c | 30 ++++---- drivers/staging/vt6655/mib.h | 128 ++++++++++++++++---------------- drivers/staging/vt6655/ttype.h | 4 - drivers/staging/vt6655/wpactl.h | 2 +- 6 files changed, 83 insertions(+), 87 deletions(-) diff --git a/drivers/staging/vt6655/bssdb.h b/drivers/staging/vt6655/bssdb.h index 6da5685440f8..d1d947879197 100644 --- a/drivers/staging/vt6655/bssdb.h +++ b/drivers/staging/vt6655/bssdb.h @@ -211,7 +211,7 @@ typedef struct tagKnownNodeDB { WORD wEnQueueCnt; BOOL bOnFly; - ULONGLONG KeyRSC; + unsigned long long KeyRSC; BYTE byKeyIndex; DWORD dwKeyIndex; BYTE byCipherSuite; diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index 8fa87dd5c43b..286461ca4e56 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -919,9 +919,9 @@ device_receive_frame ( if (bIsWEP) { WORD wLocalTSC15_0 = 0; DWORD dwLocalTSC47_16 = 0; - ULONGLONG RSC = 0; + unsigned long long RSC = 0; // endian issues - RSC = *((ULONGLONG *) &(pKey->KeyRSC)); + RSC = *((unsigned long long *) &(pKey->KeyRSC)); wLocalTSC15_0 = (WORD) RSC; dwLocalTSC47_16 = (DWORD) (RSC>>16); diff --git a/drivers/staging/vt6655/mib.c b/drivers/staging/vt6655/mib.c index e6cab78de0f4..d34ebd31efcb 100644 --- a/drivers/staging/vt6655/mib.c +++ b/drivers/staging/vt6655/mib.c @@ -194,15 +194,15 @@ void STAvUpdateRDStatCounter (PSStatCounter pStatistic, // update counters in case that successful transmit if (byRSR & RSR_ADDRBROAD) { pStatistic->ullRxBroadcastFrames++; - pStatistic->ullRxBroadcastBytes += (ULONGLONG)cbFrameLength; + pStatistic->ullRxBroadcastBytes += (unsigned long long) cbFrameLength; } else if (byRSR & RSR_ADDRMULTI) { pStatistic->ullRxMulticastFrames++; - pStatistic->ullRxMulticastBytes += (ULONGLONG)cbFrameLength; + pStatistic->ullRxMulticastBytes += (unsigned long long) cbFrameLength; } else { pStatistic->ullRxDirectedFrames++; - pStatistic->ullRxDirectedBytes += (ULONGLONG)cbFrameLength; + pStatistic->ullRxDirectedBytes += (unsigned long long) cbFrameLength; } } } @@ -473,15 +473,15 @@ STAvUpdateTDStatCounter ( // update counters in case that successful transmit if (is_broadcast_ether_addr(pbyDestAddr)) { pStatistic->ullTxBroadcastFrames[uIdx]++; - pStatistic->ullTxBroadcastBytes[uIdx] += (ULONGLONG)cbFrameLength; + pStatistic->ullTxBroadcastBytes[uIdx] += (unsigned long long) cbFrameLength; } else if (is_multicast_ether_addr(pbyDestAddr)) { pStatistic->ullTxMulticastFrames[uIdx]++; - pStatistic->ullTxMulticastBytes[uIdx] += (ULONGLONG)cbFrameLength; + pStatistic->ullTxMulticastBytes[uIdx] += (unsigned long long) cbFrameLength; } else { pStatistic->ullTxDirectedFrames[uIdx]++; - pStatistic->ullTxDirectedBytes[uIdx] += (ULONGLONG)cbFrameLength; + pStatistic->ullTxDirectedBytes[uIdx] += (unsigned long long) cbFrameLength; } } else { @@ -559,21 +559,21 @@ STAvUpdate802_11Counter( ) { //p802_11Counter->TransmittedFragmentCount - p802_11Counter->MulticastTransmittedFrameCount = (ULONGLONG) (pStatistic->dwTsrBroadcast[TYPE_AC0DMA] + + p802_11Counter->MulticastTransmittedFrameCount = (unsigned long long) (pStatistic->dwTsrBroadcast[TYPE_AC0DMA] + pStatistic->dwTsrBroadcast[TYPE_TXDMA0] + pStatistic->dwTsrMulticast[TYPE_AC0DMA] + pStatistic->dwTsrMulticast[TYPE_TXDMA0]); - p802_11Counter->FailedCount = (ULONGLONG) (pStatistic->dwTsrErr[TYPE_AC0DMA] + pStatistic->dwTsrErr[TYPE_TXDMA0]); - p802_11Counter->RetryCount = (ULONGLONG) (pStatistic->dwTsrRetry[TYPE_AC0DMA] + pStatistic->dwTsrRetry[TYPE_TXDMA0]); - p802_11Counter->MultipleRetryCount = (ULONGLONG) (pStatistic->dwTsrMoreThanOnceRetry[TYPE_AC0DMA] + + p802_11Counter->FailedCount = (unsigned long long) (pStatistic->dwTsrErr[TYPE_AC0DMA] + pStatistic->dwTsrErr[TYPE_TXDMA0]); + p802_11Counter->RetryCount = (unsigned long long) (pStatistic->dwTsrRetry[TYPE_AC0DMA] + pStatistic->dwTsrRetry[TYPE_TXDMA0]); + p802_11Counter->MultipleRetryCount = (unsigned long long) (pStatistic->dwTsrMoreThanOnceRetry[TYPE_AC0DMA] + pStatistic->dwTsrMoreThanOnceRetry[TYPE_TXDMA0]); //p802_11Counter->FrameDuplicateCount - p802_11Counter->RTSSuccessCount += (ULONGLONG) (dwCounter & 0x000000ff); - p802_11Counter->RTSFailureCount += (ULONGLONG) ((dwCounter & 0x0000ff00) >> 8); - p802_11Counter->ACKFailureCount += (ULONGLONG) ((dwCounter & 0x00ff0000) >> 16); - p802_11Counter->FCSErrorCount += (ULONGLONG) ((dwCounter & 0xff000000) >> 24); + p802_11Counter->RTSSuccessCount += (unsigned long long) (dwCounter & 0x000000ff); + p802_11Counter->RTSFailureCount += (unsigned long long) ((dwCounter & 0x0000ff00) >> 8); + p802_11Counter->ACKFailureCount += (unsigned long long) ((dwCounter & 0x00ff0000) >> 16); + p802_11Counter->FCSErrorCount += (unsigned long long) ((dwCounter & 0xff000000) >> 24); //p802_11Counter->ReceivedFragmentCount - p802_11Counter->MulticastReceivedFrameCount = (ULONGLONG) (pStatistic->dwRsrBroadcast + + p802_11Counter->MulticastReceivedFrameCount = (unsigned long long) (pStatistic->dwRsrBroadcast + pStatistic->dwRsrMulticast); } diff --git a/drivers/staging/vt6655/mib.h b/drivers/staging/vt6655/mib.h index 9f3f52114b56..1540b27faf70 100644 --- a/drivers/staging/vt6655/mib.h +++ b/drivers/staging/vt6655/mib.h @@ -40,31 +40,31 @@ typedef struct tagSDot11Counters { unsigned long Length; // Length of structure - ULONGLONG TransmittedFragmentCount; - ULONGLONG MulticastTransmittedFrameCount; - ULONGLONG FailedCount; - ULONGLONG RetryCount; - ULONGLONG MultipleRetryCount; - ULONGLONG RTSSuccessCount; - ULONGLONG RTSFailureCount; - ULONGLONG ACKFailureCount; - ULONGLONG FrameDuplicateCount; - ULONGLONG ReceivedFragmentCount; - ULONGLONG MulticastReceivedFrameCount; - ULONGLONG FCSErrorCount; - ULONGLONG TKIPLocalMICFailures; - ULONGLONG TKIPRemoteMICFailures; - ULONGLONG TKIPICVErrors; - ULONGLONG TKIPCounterMeasuresInvoked; - ULONGLONG TKIPReplays; - ULONGLONG CCMPFormatErrors; - ULONGLONG CCMPReplays; - ULONGLONG CCMPDecryptErrors; - ULONGLONG FourWayHandshakeFailures; -// ULONGLONG WEPUndecryptableCount; -// ULONGLONG WEPICVErrorCount; -// ULONGLONG DecryptSuccessCount; -// ULONGLONG DecryptFailureCount; + unsigned long long TransmittedFragmentCount; + unsigned long long MulticastTransmittedFrameCount; + unsigned long long FailedCount; + unsigned long long RetryCount; + unsigned long long MultipleRetryCount; + unsigned long long RTSSuccessCount; + unsigned long long RTSFailureCount; + unsigned long long ACKFailureCount; + unsigned long long FrameDuplicateCount; + unsigned long long ReceivedFragmentCount; + unsigned long long MulticastReceivedFrameCount; + unsigned long long FCSErrorCount; + unsigned long long TKIPLocalMICFailures; + unsigned long long TKIPRemoteMICFailures; + unsigned long long TKIPICVErrors; + unsigned long long TKIPCounterMeasuresInvoked; + unsigned long long TKIPReplays; + unsigned long long CCMPFormatErrors; + unsigned long long CCMPReplays; + unsigned long long CCMPDecryptErrors; + unsigned long long FourWayHandshakeFailures; +// unsigned long long WEPUndecryptableCount; +// unsigned long long WEPICVErrorCount; +// unsigned long long DecryptSuccessCount; +// unsigned long long DecryptFailureCount; } SDot11Counters, *PSDot11Counters; @@ -140,35 +140,35 @@ typedef struct tagSRmonCounter { typedef struct tagSCustomCounters { unsigned long Length; - ULONGLONG ullTsrAllOK; + unsigned long long ullTsrAllOK; - ULONGLONG ullRsr11M; - ULONGLONG ullRsr5M; - ULONGLONG ullRsr2M; - ULONGLONG ullRsr1M; + unsigned long long ullRsr11M; + unsigned long long ullRsr5M; + unsigned long long ullRsr2M; + unsigned long long ullRsr1M; - ULONGLONG ullRsr11MCRCOk; - ULONGLONG ullRsr5MCRCOk; - ULONGLONG ullRsr2MCRCOk; - ULONGLONG ullRsr1MCRCOk; + unsigned long long ullRsr11MCRCOk; + unsigned long long ullRsr5MCRCOk; + unsigned long long ullRsr2MCRCOk; + unsigned long long ullRsr1MCRCOk; - ULONGLONG ullRsr54M; - ULONGLONG ullRsr48M; - ULONGLONG ullRsr36M; - ULONGLONG ullRsr24M; - ULONGLONG ullRsr18M; - ULONGLONG ullRsr12M; - ULONGLONG ullRsr9M; - ULONGLONG ullRsr6M; + unsigned long long ullRsr54M; + unsigned long long ullRsr48M; + unsigned long long ullRsr36M; + unsigned long long ullRsr24M; + unsigned long long ullRsr18M; + unsigned long long ullRsr12M; + unsigned long long ullRsr9M; + unsigned long long ullRsr6M; - ULONGLONG ullRsr54MCRCOk; - ULONGLONG ullRsr48MCRCOk; - ULONGLONG ullRsr36MCRCOk; - ULONGLONG ullRsr24MCRCOk; - ULONGLONG ullRsr18MCRCOk; - ULONGLONG ullRsr12MCRCOk; - ULONGLONG ullRsr9MCRCOk; - ULONGLONG ullRsr6MCRCOk; + unsigned long long ullRsr54MCRCOk; + unsigned long long ullRsr48MCRCOk; + unsigned long long ullRsr36MCRCOk; + unsigned long long ullRsr24MCRCOk; + unsigned long long ullRsr18MCRCOk; + unsigned long long ullRsr12MCRCOk; + unsigned long long ullRsr9MCRCOk; + unsigned long long ullRsr6MCRCOk; } SCustomCounters, *PSCustomCounters; @@ -251,15 +251,15 @@ typedef struct tagSStatCounter { DWORD dwRsrMulticast; DWORD dwRsrDirected; // 64-bit OID - ULONGLONG ullRsrOK; + unsigned long long ullRsrOK; // for some optional OIDs (64 bits) and DMI support - ULONGLONG ullRxBroadcastBytes; - ULONGLONG ullRxMulticastBytes; - ULONGLONG ullRxDirectedBytes; - ULONGLONG ullRxBroadcastFrames; - ULONGLONG ullRxMulticastFrames; - ULONGLONG ullRxDirectedFrames; + unsigned long long ullRxBroadcastBytes; + unsigned long long ullRxMulticastBytes; + unsigned long long ullRxDirectedBytes; + unsigned long long ullRxBroadcastFrames; + unsigned long long ullRxMulticastFrames; + unsigned long long ullRxDirectedFrames; DWORD dwRsrRxFragment; DWORD dwRsrRxFrmLen64; @@ -304,15 +304,15 @@ typedef struct tagSStatCounter { unsigned int idxRxErrorDesc[TYPE_MAXRD]; // index for rx data error RD // 64-bit OID - ULONGLONG ullTsrOK[TYPE_MAXTD]; + unsigned long long ullTsrOK[TYPE_MAXTD]; // for some optional OIDs (64 bits) and DMI support - ULONGLONG ullTxBroadcastFrames[TYPE_MAXTD]; - ULONGLONG ullTxMulticastFrames[TYPE_MAXTD]; - ULONGLONG ullTxDirectedFrames[TYPE_MAXTD]; - ULONGLONG ullTxBroadcastBytes[TYPE_MAXTD]; - ULONGLONG ullTxMulticastBytes[TYPE_MAXTD]; - ULONGLONG ullTxDirectedBytes[TYPE_MAXTD]; + unsigned long long ullTxBroadcastFrames[TYPE_MAXTD]; + unsigned long long ullTxMulticastFrames[TYPE_MAXTD]; + unsigned long long ullTxDirectedFrames[TYPE_MAXTD]; + unsigned long long ullTxBroadcastBytes[TYPE_MAXTD]; + unsigned long long ullTxMulticastBytes[TYPE_MAXTD]; + unsigned long long ullTxDirectedBytes[TYPE_MAXTD]; // DWORD dwTxRetryCount[8]; // diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h index 950fb097e460..f97a3eeed9a1 100644 --- a/drivers/staging/vt6655/ttype.h +++ b/drivers/staging/vt6655/ttype.h @@ -68,10 +68,6 @@ typedef int BOOL; * but it doesn't matter if they're signed or unsigned. */ -typedef unsigned long long ULONGLONG; //64 bit - - - typedef unsigned char BYTE; // 8-bit typedef unsigned short WORD; // 16-bit typedef unsigned long DWORD; // 32-bit diff --git a/drivers/staging/vt6655/wpactl.h b/drivers/staging/vt6655/wpactl.h index b0d92d51a2a6..52bc7e3dbb48 100644 --- a/drivers/staging/vt6655/wpactl.h +++ b/drivers/staging/vt6655/wpactl.h @@ -54,7 +54,7 @@ typedef enum { KEY_MGMT_802_1X, KEY_MGMT_CCKM,KEY_MGMT_PSK, KEY_MGMT_NONE, -typedef ULONGLONG NDIS_802_11_KEY_RSC; +typedef unsigned long long NDIS_802_11_KEY_RSC; /*--------------------- Export Classes ----------------------------*/ From 2989e96f17f2dcbd73aee37856899c2885df0686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Sat, 5 Jun 2010 15:13:47 -0700 Subject: [PATCH 063/523] Staging: vt6655: remove PBYTE typedef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use unsigned char * instead. Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/80211hdr.h | 4 +- drivers/staging/vt6655/80211mgr.c | 34 ++-- drivers/staging/vt6655/80211mgr.h | 24 +-- drivers/staging/vt6655/IEEE11h.c | 6 +- drivers/staging/vt6655/aes_ccmp.c | 6 +- drivers/staging/vt6655/aes_ccmp.h | 2 +- drivers/staging/vt6655/baseband.c | 8 +- drivers/staging/vt6655/baseband.h | 8 +- drivers/staging/vt6655/bssdb.c | 26 +-- drivers/staging/vt6655/bssdb.h | 16 +- drivers/staging/vt6655/card.c | 28 +-- drivers/staging/vt6655/card.h | 18 +- drivers/staging/vt6655/datarate.c | 4 +- drivers/staging/vt6655/datarate.h | 4 +- drivers/staging/vt6655/desc.h | 2 +- drivers/staging/vt6655/device.h | 10 +- drivers/staging/vt6655/device_main.c | 22 +-- drivers/staging/vt6655/dpc.c | 106 ++++++------ drivers/staging/vt6655/hostap.c | 4 +- drivers/staging/vt6655/ioctl.c | 4 +- drivers/staging/vt6655/ioctl.h | 2 +- drivers/staging/vt6655/iwctl.c | 2 +- drivers/staging/vt6655/key.c | 16 +- drivers/staging/vt6655/key.h | 16 +- drivers/staging/vt6655/mac.c | 20 +-- drivers/staging/vt6655/mac.h | 24 +-- drivers/staging/vt6655/mib.c | 12 +- drivers/staging/vt6655/mib.h | 8 +- drivers/staging/vt6655/michael.c | 2 +- drivers/staging/vt6655/michael.h | 2 +- drivers/staging/vt6655/power.c | 4 +- drivers/staging/vt6655/rc4.c | 10 +- drivers/staging/vt6655/rc4.h | 4 +- drivers/staging/vt6655/rxtx.c | 250 +++++++++++++-------------- drivers/staging/vt6655/rxtx.h | 10 +- drivers/staging/vt6655/srom.c | 12 +- drivers/staging/vt6655/srom.h | 8 +- drivers/staging/vt6655/tcrc.c | 6 +- drivers/staging/vt6655/tcrc.h | 6 +- drivers/staging/vt6655/tether.c | 4 +- drivers/staging/vt6655/tether.h | 6 +- drivers/staging/vt6655/tkip.c | 6 +- drivers/staging/vt6655/tkip.h | 6 +- drivers/staging/vt6655/ttype.h | 2 - drivers/staging/vt6655/upc.h | 4 +- drivers/staging/vt6655/vntwifi.c | 16 +- drivers/staging/vt6655/vntwifi.h | 14 +- drivers/staging/vt6655/wcmd.c | 12 +- drivers/staging/vt6655/wcmd.h | 2 +- drivers/staging/vt6655/wctl.c | 4 +- drivers/staging/vt6655/wmgr.c | 140 +++++++-------- drivers/staging/vt6655/wmgr.h | 10 +- drivers/staging/vt6655/wpa.c | 4 +- drivers/staging/vt6655/wpa2.c | 6 +- drivers/staging/vt6655/wpactl.c | 12 +- drivers/staging/vt6655/wroute.c | 6 +- drivers/staging/vt6655/wroute.h | 2 +- 57 files changed, 503 insertions(+), 503 deletions(-) diff --git a/drivers/staging/vt6655/80211hdr.h b/drivers/staging/vt6655/80211hdr.h index b7b170e19aa2..5d8e4c64df9a 100644 --- a/drivers/staging/vt6655/80211hdr.h +++ b/drivers/staging/vt6655/80211hdr.h @@ -282,8 +282,8 @@ #define WLAN_MGMT_GET_TIM_OFFSET(b) (((b) & ~BIT0) >> 1) /* 3-Addr & 4-Addr */ -#define WLAN_HDR_A3_DATA_PTR(p) (((PBYTE)(p)) + WLAN_HDR_ADDR3_LEN) -#define WLAN_HDR_A4_DATA_PTR(p) (((PBYTE)(p)) + WLAN_HDR_ADDR4_LEN) +#define WLAN_HDR_A3_DATA_PTR(p) (((unsigned char *)(p)) + WLAN_HDR_ADDR3_LEN) +#define WLAN_HDR_A4_DATA_PTR(p) (((unsigned char *)(p)) + WLAN_HDR_ADDR4_LEN) /* IEEE ADDR */ #define IEEE_ADDR_UNIVERSAL 0x02 diff --git a/drivers/staging/vt6655/80211mgr.c b/drivers/staging/vt6655/80211mgr.c index 38697c862489..9fbced855059 100644 --- a/drivers/staging/vt6655/80211mgr.c +++ b/drivers/staging/vt6655/80211mgr.c @@ -139,9 +139,9 @@ vMgrDecodeBeacon( + WLAN_BEACON_OFF_CAPINFO); // Information elements - pItem = (PWLAN_IE)((PBYTE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))) + pItem = (PWLAN_IE)((unsigned char *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))) + WLAN_BEACON_OFF_SSID); - while( ((PBYTE)pItem) < (pFrame->pBuf + pFrame->len) ){ + while( ((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len) ){ switch (pItem->byElementID) { case WLAN_EID_SSID: @@ -223,7 +223,7 @@ vMgrDecodeBeacon( break; } - pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len); + pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len); } return; @@ -386,7 +386,7 @@ vMgrDecodeAssocRequest( pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCREQ_OFF_SSID); - while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) { + while (((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) { switch (pItem->byElementID){ case WLAN_EID_SSID: if (pFrame->pSSID == NULL) @@ -418,7 +418,7 @@ vMgrDecodeAssocRequest( pItem->byElementID); break; } - pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len); + pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len); } return; } @@ -488,9 +488,10 @@ vMgrDecodeAssocResponse( + WLAN_ASSOCRESP_OFF_SUPP_RATES); pItem = (PWLAN_IE)(pFrame->pSuppRates); - pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len); + pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len); - if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) { + if ((((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) && + (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) { pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pFrame->pExtSuppRates=[%p].\n", pItem); } @@ -564,7 +565,7 @@ vMgrDecodeReassocRequest( pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCREQ_OFF_SSID); - while(((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) { + while(((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) { switch (pItem->byElementID){ case WLAN_EID_SSID: @@ -597,7 +598,7 @@ vMgrDecodeReassocRequest( pItem->byElementID); break; } - pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len); + pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len); } return; } @@ -649,7 +650,7 @@ vMgrDecodeProbeRequest( // Information elements pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))); - while( ((PBYTE)pItem) < (pFrame->pBuf + pFrame->len) ) { + while( ((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len) ) { switch (pItem->byElementID) { case WLAN_EID_SSID: @@ -672,7 +673,7 @@ vMgrDecodeProbeRequest( break; } - pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len); + pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len); } return; } @@ -746,7 +747,7 @@ vMgrDecodeProbeResponse( pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_SSID); - while( ((PBYTE)pItem) < (pFrame->pBuf + pFrame->len) ) { + while( ((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len) ) { switch (pItem->byElementID) { case WLAN_EID_SSID: if (pFrame->pSSID == NULL) @@ -821,7 +822,7 @@ vMgrDecodeProbeResponse( break; } - pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len); + pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len); } return; } @@ -890,7 +891,7 @@ vMgrDecodeAuthen( pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_CHALLENGE); - if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_CHALLENGE)) { + if ((((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_CHALLENGE)) { pFrame->pChallenge = (PWLAN_IE_CHALLENGE)pItem; } @@ -1017,9 +1018,10 @@ vMgrDecodeReassocResponse( + WLAN_REASSOCRESP_OFF_SUPP_RATES); pItem = (PWLAN_IE)(pFrame->pSuppRates); - pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len); + pItem = (PWLAN_IE)(((unsigned char *)pItem) + 2 + pItem->len); - if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) { + if ((((unsigned char *)pItem) < (pFrame->pBuf + pFrame->len)) && + (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) { pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; } return; diff --git a/drivers/staging/vt6655/80211mgr.h b/drivers/staging/vt6655/80211mgr.h index b6ee8220f1f6..bb58ed0ba3a3 100644 --- a/drivers/staging/vt6655/80211mgr.h +++ b/drivers/staging/vt6655/80211mgr.h @@ -497,7 +497,7 @@ typedef struct tagWLAN_FR_MGMT { unsigned int uType; unsigned int len; - PBYTE pBuf; + unsigned char *pBuf; PUWLAN_80211HDR pHdr; } WLAN_FR_MGMT, *PWLAN_FR_MGMT; @@ -507,7 +507,7 @@ typedef struct tagWLAN_FR_BEACON { unsigned int uType; unsigned int len; - PBYTE pBuf; + unsigned char *pBuf; PUWLAN_80211HDR pHdr; // fixed fields PQWORD pqwTimestamp; @@ -539,7 +539,7 @@ typedef struct tagWLAN_FR_IBSSATIM { unsigned int uType; unsigned int len; - PBYTE pBuf; + unsigned char *pBuf; PUWLAN_80211HDR pHdr; // fixed fields @@ -553,7 +553,7 @@ typedef struct tagWLAN_FR_DISASSOC { unsigned int uType; unsigned int len; - PBYTE pBuf; + unsigned char *pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ PWORD pwReason; @@ -566,7 +566,7 @@ typedef struct tagWLAN_FR_ASSOCREQ { unsigned int uType; unsigned int len; - PBYTE pBuf; + unsigned char *pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ PWORD pwCapInfo; @@ -587,7 +587,7 @@ typedef struct tagWLAN_FR_ASSOCRESP { unsigned int uType; unsigned int len; - PBYTE pBuf; + unsigned char *pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ PWORD pwCapInfo; @@ -604,7 +604,7 @@ typedef struct tagWLAN_FR_REASSOCREQ { unsigned int uType; unsigned int len; - PBYTE pBuf; + unsigned char *pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ @@ -626,7 +626,7 @@ typedef struct tagWLAN_FR_REASSOCRESP { unsigned int uType; unsigned int len; - PBYTE pBuf; + unsigned char *pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ PWORD pwCapInfo; @@ -643,7 +643,7 @@ typedef struct tagWLAN_FR_PROBEREQ { unsigned int uType; unsigned int len; - PBYTE pBuf; + unsigned char *pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ /*-- info elements ----------*/ @@ -658,7 +658,7 @@ typedef struct tagWLAN_FR_PROBERESP { unsigned int uType; unsigned int len; - PBYTE pBuf; + unsigned char *pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ PQWORD pqwTimestamp; @@ -687,7 +687,7 @@ typedef struct tagWLAN_FR_AUTHEN { unsigned int uType; unsigned int len; - PBYTE pBuf; + unsigned char *pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ PWORD pwAuthAlgorithm; @@ -703,7 +703,7 @@ typedef struct tagWLAN_FR_DEAUTHEN { unsigned int uType; unsigned int len; - PBYTE pBuf; + unsigned char *pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ PWORD pwReason; diff --git a/drivers/staging/vt6655/IEEE11h.c b/drivers/staging/vt6655/IEEE11h.c index 55e66e9e0dde..7576289c4902 100644 --- a/drivers/staging/vt6655/IEEE11h.c +++ b/drivers/staging/vt6655/IEEE11h.c @@ -125,9 +125,9 @@ static BOOL s_bRxTPCReq(PSMgmtObject pMgmt, PWLAN_FRAME_TPCREQ pTPCReq, BYTE byR pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); - pFrame = (PWLAN_FRAME_TPCREP)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pFrame = (PWLAN_FRAME_TPCREP)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); pFrame->Header.wFrameCtl = ( WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT) | WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_ACTION) @@ -276,7 +276,7 @@ BOOL IEEE11hbMSRRepTx ( pTxPacket = (PSTxMgmtPacket)pMgmt->abyCurrentMSRRep; memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); pMSRRep->Header.wFrameCtl = ( WLAN_SET_FC_FTYPE(WLAN_FTYPE_MGMT) | diff --git a/drivers/staging/vt6655/aes_ccmp.c b/drivers/staging/vt6655/aes_ccmp.c index fef1b91c2925..f148356cdfc5 100644 --- a/drivers/staging/vt6655/aes_ccmp.c +++ b/drivers/staging/vt6655/aes_ccmp.c @@ -243,7 +243,7 @@ BYTE abyRoundKey[16]; * Return Value: MIC compare result * */ -BOOL AESbGenCCMP(PBYTE pbyRxKey, PBYTE pbyFrame, WORD wFrameSize) +BOOL AESbGenCCMP(unsigned char *pbyRxKey, unsigned char *pbyFrame, WORD wFrameSize) { BYTE abyNonce[13]; BYTE MIC_IV[16]; @@ -256,8 +256,8 @@ BYTE abyPlainText[16]; BYTE abyLastCipher[16]; PS802_11Header pMACHeader = (PS802_11Header) pbyFrame; -PBYTE pbyIV; -PBYTE pbyPayload; +unsigned char *pbyIV; +unsigned char *pbyPayload; WORD wHLen = 22; WORD wPayloadSize = wFrameSize - 8 - 8 - 4 - WLAN_HDR_ADDR3_LEN;//8 is IV, 8 is MIC, 4 is CRC BOOL bA4 = FALSE; diff --git a/drivers/staging/vt6655/aes_ccmp.h b/drivers/staging/vt6655/aes_ccmp.h index f2ba1d5aa1e5..2909e5b79a57 100644 --- a/drivers/staging/vt6655/aes_ccmp.h +++ b/drivers/staging/vt6655/aes_ccmp.h @@ -41,6 +41,6 @@ /*--------------------- Export Variables --------------------------*/ /*--------------------- Export Functions --------------------------*/ -BOOL AESbGenCCMP(PBYTE pbyRxKey, PBYTE pbyFrame, WORD wFrameSize); +BOOL AESbGenCCMP(unsigned char *pbyRxKey, unsigned char *pbyFrame, WORD wFrameSize); #endif //__AES_H__ diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index c772c2901641..f96a33787d1e 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -1850,8 +1850,8 @@ BBvCaculateParameter ( WORD wRate, BYTE byPacketType, PWORD pwPhyLen, - PBYTE pbyPhySrv, - PBYTE pbyPhySgn + unsigned char *pbyPhySrv, + unsigned char *pbyPhySgn ) { unsigned int cbBitCount; @@ -2015,7 +2015,7 @@ BBvCaculateParameter ( * Return Value: TRUE if succeeded; FALSE if failed. * */ -BOOL BBbReadEmbeded (DWORD_PTR dwIoBase, BYTE byBBAddr, PBYTE pbyData) +BOOL BBbReadEmbeded (DWORD_PTR dwIoBase, BYTE byBBAddr, unsigned char *pbyData) { WORD ww; BYTE byValue; @@ -2321,7 +2321,7 @@ BOOL BBbVT3253Init (PSDevice pDevice) * Return Value: none * */ -void BBvReadAllRegs (DWORD_PTR dwIoBase, PBYTE pbyBBRegs) +void BBvReadAllRegs (DWORD_PTR dwIoBase, unsigned char *pbyBBRegs) { int ii; BYTE byBase = 1; diff --git a/drivers/staging/vt6655/baseband.h b/drivers/staging/vt6655/baseband.h index 3372546662d9..616dab6f3ac1 100644 --- a/drivers/staging/vt6655/baseband.h +++ b/drivers/staging/vt6655/baseband.h @@ -133,14 +133,14 @@ BBvCaculateParameter ( WORD wRate, BYTE byPacketType, PWORD pwPhyLen, - PBYTE pbyPhySrv, - PBYTE pbyPhySgn + unsigned char *pbyPhySrv, + unsigned char *pbyPhySgn ); -BOOL BBbReadEmbeded(DWORD_PTR dwIoBase, BYTE byBBAddr, PBYTE pbyData); +BOOL BBbReadEmbeded(DWORD_PTR dwIoBase, BYTE byBBAddr, unsigned char *pbyData); BOOL BBbWriteEmbeded(DWORD_PTR dwIoBase, BYTE byBBAddr, BYTE byData); -void BBvReadAllRegs(DWORD_PTR dwIoBase, PBYTE pbyBBRegs); +void BBvReadAllRegs(DWORD_PTR dwIoBase, unsigned char *pbyBBRegs); void BBvLoopbackOn(PSDevice pDevice); void BBvLoopbackOff(PSDevice pDevice); void BBvSetShortSlotTime(PSDevice pDevice); diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c index d16d799636a3..76e81362fc17 100644 --- a/drivers/staging/vt6655/bssdb.c +++ b/drivers/staging/vt6655/bssdb.c @@ -126,14 +126,14 @@ void s_vCheckPreEDThreshold( PKnownBSS BSSpSearchBSSList( void *hDeviceContext, - PBYTE pbyDesireBSSID, - PBYTE pbyDesireSSID, + unsigned char *pbyDesireBSSID, + unsigned char *pbyDesireSSID, CARD_PHY_TYPE ePhyType ) { PSDevice pDevice = (PSDevice)hDeviceContext; PSMgmtObject pMgmt = pDevice->pMgmt; - PBYTE pbyBSSID = NULL; + unsigned char *pbyBSSID = NULL; PWLAN_IE_SSID pSSID = NULL; PKnownBSS pCurrBSS = NULL; PKnownBSS pSelect = NULL; @@ -326,7 +326,7 @@ BSSvClearBSSList( PKnownBSS BSSpAddrIsInBSSList( void *hDeviceContext, - PBYTE abyBSSID, + unsigned char *abyBSSID, PWLAN_IE_SSID pSSID ) { @@ -369,7 +369,7 @@ BSSpAddrIsInBSSList( BOOL BSSbInsertToBSSList ( void *hDeviceContext, - PBYTE abyBSSIDAddr, + unsigned char *abyBSSIDAddr, QWORD qwTimestamp, WORD wBeaconInterval, WORD wCapInfo, @@ -383,7 +383,7 @@ BSSbInsertToBSSList ( PWLAN_IE_COUNTRY pIE_Country, PWLAN_IE_QUIET pIE_Quiet, unsigned int uIELength, - PBYTE pbyIEs, + unsigned char *pbyIEs, void *pRxPacketContext ) { @@ -470,7 +470,7 @@ BSSbInsertToBSSList ( if (pRSNWPA != NULL) { unsigned int uLen = pRSNWPA->len + 2; - if (uLen <= (uIELength - (unsigned int)(ULONG_PTR)((PBYTE)pRSNWPA - pbyIEs))) { + if (uLen <= (uIELength - (unsigned int)(ULONG_PTR)((unsigned char *)pRSNWPA - pbyIEs))) { pBSSList->wWPALen = uLen; memcpy(pBSSList->byWPAIE, pRSNWPA, uLen); WPA_ParseRSN(pBSSList, pRSNWPA); @@ -481,7 +481,7 @@ BSSbInsertToBSSList ( if (pRSN != NULL) { unsigned int uLen = pRSN->len + 2; - if (uLen <= (uIELength - (unsigned int)(ULONG_PTR)((PBYTE)pRSN - pbyIEs))) { + if (uLen <= (uIELength - (unsigned int)(ULONG_PTR)((unsigned char *)pRSN - pbyIEs))) { pBSSList->wRSNLen = uLen; memcpy(pBSSList->byRSNIE, pRSN, uLen); WPA2vParseRSN(pBSSList, pRSN); @@ -601,7 +601,7 @@ BSSbUpdateToBSSList ( PWLAN_IE_QUIET pIE_Quiet, PKnownBSS pBSSList, unsigned int uIELength, - PBYTE pbyIEs, + unsigned char *pbyIEs, void *pRxPacketContext ) { @@ -671,7 +671,7 @@ BSSbUpdateToBSSList ( if (pRSNWPA != NULL) { unsigned int uLen = pRSNWPA->len + 2; - if (uLen <= (uIELength - (unsigned int)(ULONG_PTR)((PBYTE)pRSNWPA - pbyIEs))) { + if (uLen <= (uIELength - (unsigned int)(ULONG_PTR)((unsigned char *)pRSNWPA - pbyIEs))) { pBSSList->wWPALen = uLen; memcpy(pBSSList->byWPAIE, pRSNWPA, uLen); WPA_ParseRSN(pBSSList, pRSNWPA); @@ -682,7 +682,7 @@ BSSbUpdateToBSSList ( if (pRSN != NULL) { unsigned int uLen = pRSN->len + 2; - if (uLen <= (uIELength - (unsigned int)(ULONG_PTR)((PBYTE)pRSN - pbyIEs))) { + if (uLen <= (uIELength - (unsigned int)(ULONG_PTR)((unsigned char *)pRSN - pbyIEs))) { pBSSList->wRSNLen = uLen; memcpy(pBSSList->byRSNIE, pRSN, uLen); WPA2vParseRSN(pBSSList, pRSN); @@ -765,7 +765,7 @@ BSSbUpdateToBSSList ( BOOL BSSDBbIsSTAInNodeDB( void *pMgmtObject, - PBYTE abyDstAddr, + unsigned char *abyDstAddr, PUINT puNodeIndex ) { @@ -1393,7 +1393,7 @@ BSSvUpdateNodeTxCounter( void *hDeviceContext, BYTE byTsr0, BYTE byTsr1, - PBYTE pbyBuffer, + unsigned char *pbyBuffer, unsigned int uFIFOHeaderSize ) { diff --git a/drivers/staging/vt6655/bssdb.h b/drivers/staging/vt6655/bssdb.h index d1d947879197..ac6473a05ba3 100644 --- a/drivers/staging/vt6655/bssdb.h +++ b/drivers/staging/vt6655/bssdb.h @@ -245,15 +245,15 @@ typedef struct tagKnownNodeDB { PKnownBSS BSSpSearchBSSList( void *hDeviceContext, - PBYTE pbyDesireBSSID, - PBYTE pbyDesireSSID, + unsigned char *pbyDesireBSSID, + unsigned char *pbyDesireSSID, CARD_PHY_TYPE ePhyType ); PKnownBSS BSSpAddrIsInBSSList( void *hDeviceContext, - PBYTE abyBSSID, + unsigned char *abyBSSID, PWLAN_IE_SSID pSSID ); @@ -266,7 +266,7 @@ BSSvClearBSSList( BOOL BSSbInsertToBSSList( void *hDeviceContext, - PBYTE abyBSSIDAddr, + unsigned char *abyBSSIDAddr, QWORD qwTimestamp, WORD wBeaconInterval, WORD wCapInfo, @@ -280,7 +280,7 @@ BSSbInsertToBSSList( PWLAN_IE_COUNTRY pIE_Country, PWLAN_IE_QUIET pIE_Quiet, unsigned int uIELength, - PBYTE pbyIEs, + unsigned char *pbyIEs, void *pRxPacketContext ); @@ -303,7 +303,7 @@ BSSbUpdateToBSSList( PWLAN_IE_QUIET pIE_Quiet, PKnownBSS pBSSList, unsigned int uIELength, - PBYTE pbyIEs, + unsigned char *pbyIEs, void *pRxPacketContext ); @@ -311,7 +311,7 @@ BSSbUpdateToBSSList( BOOL BSSDBbIsSTAInNodeDB( void *hDeviceContext, - PBYTE abyDstAddr, + unsigned char *abyDstAddr, PUINT puNodeIndex ); @@ -341,7 +341,7 @@ BSSvUpdateNodeTxCounter( void *hDeviceContext, BYTE byTsr0, BYTE byTsr1, - PBYTE pbyBuffer, + unsigned char *pbyBuffer, unsigned int uFIFOHeaderSize ); diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 439bb0c4ca68..5ce98a07c554 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -427,8 +427,8 @@ void s_vCaculateOFDMRParameter( BYTE byRate, CARD_PHY_TYPE ePHYType, - PBYTE pbyTxRate, - PBYTE pbyRsvTime + unsigned char *pbyTxRate, + unsigned char *pbyRsvTime ); @@ -499,8 +499,8 @@ void s_vCaculateOFDMRParameter ( BYTE byRate, CARD_PHY_TYPE ePHYType, - PBYTE pbyTxRate, - PBYTE pbyRsvTime + unsigned char *pbyTxRate, + unsigned char *pbyRsvTime ) { switch (byRate) { @@ -1296,7 +1296,7 @@ BOOL CARDbStartTxPacket (void *pDeviceHandler, CARD_PKT_TYPE ePktType) * Return Value: TRUE if success; FALSE if failed. * */ -BOOL CARDbSetBSSID(void *pDeviceHandler, PBYTE pbyBSSID, CARD_OP_MODE eOPMode) +BOOL CARDbSetBSSID(void *pDeviceHandler, unsigned char *pbyBSSID, CARD_OP_MODE eOPMode) { PSDevice pDevice = (PSDevice) pDeviceHandler; @@ -1522,7 +1522,7 @@ MACvRegBitsOff(pDevice->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); //LED issue -BOOL CARDbRemoveKey (void *pDeviceHandler, PBYTE pbyBSSID) +BOOL CARDbRemoveKey (void *pDeviceHandler, unsigned char *pbyBSSID) { PSDevice pDevice = (PSDevice) pDeviceHandler; @@ -1550,7 +1550,7 @@ BOOL CARDbRemoveKey (void *pDeviceHandler, PBYTE pbyBSSID) BOOL CARDbAdd_PMKID_Candidate ( void *pDeviceHandler, - PBYTE pbyBSSID, + unsigned char *pbyBSSID, BOOL bRSNCapExist, WORD wRSNCap ) @@ -2129,8 +2129,8 @@ CARDvSetPowerConstraint ( void CARDvGetPowerCapability ( void *pDeviceHandler, - PBYTE pbyMinPower, - PBYTE pbyMaxPower + unsigned char *pbyMinPower, + unsigned char *pbyMaxPower ) { PSDevice pDevice = (PSDevice) pDeviceHandler; @@ -2165,14 +2165,14 @@ CARDvGetPowerCapability ( BYTE CARDbySetSupportChannels ( void *pDeviceHandler, - PBYTE pbyIEs + unsigned char *pbyIEs ) { PSDevice pDevice = (PSDevice) pDeviceHandler; unsigned int ii; BYTE byCount; PWLAN_IE_SUPP_CH pIE = (PWLAN_IE_SUPP_CH) pbyIEs; - PBYTE pbyChTupple; + unsigned char *pbyChTupple; BYTE byLen = 0; @@ -2267,7 +2267,7 @@ CARDbyGetTransmitPower ( BOOL CARDbChannelGetList ( unsigned int uCountryCodeIdx, - PBYTE pbyChannelTable + unsigned char *pbyChannelTable ) { if (uCountryCodeIdx >= CCODE_MAX) { @@ -2308,8 +2308,8 @@ BOOL CARDbGetChannelMapInfo( void *pDeviceHandler, unsigned int uChannelIndex, - PBYTE pbyChannelNumber, - PBYTE pbyMap + unsigned char *pbyChannelNumber, + unsigned char *pbyMap ) { // PSDevice pDevice = (PSDevice) pDeviceHandler; diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index 40271a1f1873..034394d46dc8 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -116,7 +116,7 @@ BOOL CARDbUpdateTSF(void *pDeviceHandler, BYTE byRxRate, QWORD qwBSSTimestamp, Q BOOL CARDbStopTxPacket(void *pDeviceHandler, CARD_PKT_TYPE ePktType); BOOL CARDbStartTxPacket(void *pDeviceHandler, CARD_PKT_TYPE ePktType); BOOL CARDbSetBeaconPeriod(void *pDeviceHandler, WORD wBeaconInterval); -BOOL CARDbSetBSSID(void *pDeviceHandler, PBYTE pbyBSSID, CARD_OP_MODE eOPMode); +BOOL CARDbSetBSSID(void *pDeviceHandler, unsigned char *pbyBSSID, CARD_OP_MODE eOPMode); BOOL CARDbPowerDown( @@ -129,12 +129,12 @@ BOOL CARDbSetTxDataRate( ); -BOOL CARDbRemoveKey (void *pDeviceHandler, PBYTE pbyBSSID); +BOOL CARDbRemoveKey (void *pDeviceHandler, unsigned char *pbyBSSID); BOOL CARDbAdd_PMKID_Candidate ( void *pDeviceHandler, - PBYTE pbyBSSID, + unsigned char *pbyBSSID, BOOL bRSNCapExist, WORD wRSNCap ); @@ -195,14 +195,14 @@ CARDvSetPowerConstraint ( void CARDvGetPowerCapability ( void *pDeviceHandler, - PBYTE pbyMinPower, - PBYTE pbyMaxPower + unsigned char *pbyMinPower, + unsigned char *pbyMaxPower ); BYTE CARDbySetSupportChannels ( void *pDeviceHandler, - PBYTE pbyIEs + unsigned char *pbyIEs ); char @@ -213,7 +213,7 @@ CARDbyGetTransmitPower ( BOOL CARDbChannelGetList ( unsigned int uCountryCodeIdx, - PBYTE pbyChannelTable + unsigned char *pbyChannelTable ); void @@ -226,8 +226,8 @@ BOOL CARDbGetChannelMapInfo( void *pDeviceHandler, unsigned int uChannelIndex, - PBYTE pbyChannelNumber, - PBYTE pbyMap + unsigned char *pbyChannelNumber, + unsigned char *pbyMap ); void diff --git a/drivers/staging/vt6655/datarate.c b/drivers/staging/vt6655/datarate.c index ecec01ea0807..e1ab30079c03 100644 --- a/drivers/staging/vt6655/datarate.c +++ b/drivers/staging/vt6655/datarate.c @@ -203,8 +203,8 @@ RATEvParseMaxRate ( PWORD pwMaxBasicRate, PWORD pwMaxSuppRate, PWORD pwSuppRate, - PBYTE pbyTopCCKRate, - PBYTE pbyTopOFDMRate + unsigned char *pbyTopCCKRate, + unsigned char *pbyTopOFDMRate ) { PSDevice pDevice = (PSDevice) pDeviceHandler; diff --git a/drivers/staging/vt6655/datarate.h b/drivers/staging/vt6655/datarate.h index 760d464890c7..2cb3b5097a5c 100644 --- a/drivers/staging/vt6655/datarate.h +++ b/drivers/staging/vt6655/datarate.h @@ -63,8 +63,8 @@ RATEvParseMaxRate( PWORD pwMaxBasicRate, PWORD pwMaxSuppRate, PWORD pwSuppRate, - PBYTE pbyTopCCKRate, - PBYTE pbyTopOFDMRate + unsigned char *pbyTopCCKRate, + unsigned char *pbyTopOFDMRate ); void diff --git a/drivers/staging/vt6655/desc.h b/drivers/staging/vt6655/desc.h index a16d2e0049dc..9894d9e2e28f 100644 --- a/drivers/staging/vt6655/desc.h +++ b/drivers/staging/vt6655/desc.h @@ -350,7 +350,7 @@ STDES1; typedef struct tagDEVICE_TD_INFO{ struct sk_buff* skb; - PBYTE buf; + unsigned char *buf; dma_addr_t skb_dma; dma_addr_t buf_dma; dma_addr_t curr_desc; diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 736af6e49a8e..56e05f0fa963 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -324,7 +324,7 @@ typedef struct tagSDeFragControlBlock BYTE abyAddr2[ETH_ALEN]; unsigned int uLifetime; struct sk_buff* skb; - PBYTE pbyRxBuffer; + unsigned char *pbyRxBuffer; unsigned int cbFrameLength; BOOL bInUse; } SDeFragControlBlock, *PSDeFragControlBlock; @@ -417,9 +417,9 @@ typedef struct __device_info { dma_addr_t tx_bufs_dma1; dma_addr_t tx_beacon_dma; - PBYTE tx0_bufs; - PBYTE tx1_bufs; - PBYTE tx_beacon_bufs; + unsigned char *tx0_bufs; + unsigned char *tx1_bufs; + unsigned char *tx_beacon_bufs; CHIP_TYPE chip_id; @@ -507,7 +507,7 @@ typedef struct __device_info { BYTE byTxAntennaMode; BOOL bTxRxAntInv; - PBYTE pbyTmpBuff; + unsigned char *pbyTmpBuff; unsigned int uSIFS; //Current SIFS unsigned int uDIFS; //Current DIFS unsigned int uEIFS; //Current EIFS diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index e3c2ba758b2e..ecc362d3fdd9 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1699,13 +1699,13 @@ static int device_tx_srv(PSDevice pDevice, unsigned int uIdx) { STAvUpdateTDStatCounter(&pDevice->scStatistic, byTsr0, byTsr1, - (PBYTE)(pTD->pTDInfo->buf + uFIFOHeaderSize), + (unsigned char *)(pTD->pTDInfo->buf + uFIFOHeaderSize), uFrameSize, uIdx); BSSvUpdateNodeTxCounter(pDevice, byTsr0, byTsr1, - (PBYTE)(pTD->pTDInfo->buf), + (unsigned char *)(pTD->pTDInfo->buf), uFIFOHeaderSize ); @@ -1756,7 +1756,7 @@ static int device_tx_srv(PSDevice pDevice, unsigned int uIdx) { BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; skb = pTD->pTDInfo->skb; - if (BSSDBbIsSTAInNodeDB(pMgmt, (PBYTE)(skb->data), &uNodeIndex)) { + if (BSSDBbIsSTAInNodeDB(pMgmt, (unsigned char *)(skb->data), &uNodeIndex)) { if (pMgmt->sNodeDBTable[uNodeIndex].bPSEnable) { skb_queue_tail(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue, skb); pMgmt->sNodeDBTable[uNodeIndex].wEnQueueCnt++; @@ -2084,7 +2084,7 @@ device_release_WPADEV(pDevice); static int device_dma0_tx_80211(struct sk_buff *skb, struct net_device *dev) { PSDevice pDevice=netdev_priv(dev); - PBYTE pbMPDU; + unsigned char *pbMPDU; unsigned int cbMPDULen = 0; @@ -2154,7 +2154,7 @@ BOOL device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, unsigned int uNodeI pHeadTD->m_td1TD1.byTCR = (TCR_EDP|TCR_STP); - memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)(skb->data), ETH_HLEN); + memcpy(pDevice->sTxEthHeader.abyDstAddr, (unsigned char *)(skb->data), ETH_HLEN); cbFrameBodySize = skb->len - ETH_HLEN; // 802.1H @@ -2228,7 +2228,7 @@ BOOL device_dma0_xmit(PSDevice pDevice, struct sk_buff *skb, unsigned int uNodeI } vGenerateFIFOHeader(pDevice, byPktType, pDevice->pbyTmpBuff, bNeedEncryption, cbFrameBodySize, TYPE_TXDMA0, pHeadTD, - &pDevice->sTxEthHeader, (PBYTE)skb->data, pTransmitKey, uNodeIndex, + &pDevice->sTxEthHeader, (unsigned char *)skb->data, pTransmitKey, uNodeIndex, &uMACfragNum, &cbHeaderSize ); @@ -2284,7 +2284,7 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { unsigned int ii; BOOL bTKIP_UseGTK = FALSE; BOOL bNeedDeAuth = FALSE; - PBYTE pbyBSSID; + unsigned char *pbyBSSID; BOOL bNodeExist = FALSE; @@ -2309,7 +2309,7 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { spin_unlock_irq(&pDevice->lock); return 0; } - if (is_multicast_ether_addr((PBYTE)(skb->data))) { + if (is_multicast_ether_addr((unsigned char *)(skb->data))) { uNodeIndex = 0; bNodeExist = TRUE; if (pMgmt->sNodeDBTable[0].bPSEnable) { @@ -2321,7 +2321,7 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { return 0; } }else { - if (BSSDBbIsSTAInNodeDB(pMgmt, (PBYTE)(skb->data), &uNodeIndex)) { + if (BSSDBbIsSTAInNodeDB(pMgmt, (unsigned char *)(skb->data), &uNodeIndex)) { if (pMgmt->sNodeDBTable[uNodeIndex].bPSEnable) { skb_queue_tail(&pMgmt->sNodeDBTable[uNodeIndex].sTxPSQueue, skb); pMgmt->sNodeDBTable[uNodeIndex].wEnQueueCnt++; @@ -2358,7 +2358,7 @@ static int device_xmit(struct sk_buff *skb, struct net_device *dev) { pHeadTD->m_td1TD1.byTCR = (TCR_EDP|TCR_STP); - memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)(skb->data), ETH_HLEN); + memcpy(pDevice->sTxEthHeader.abyDstAddr, (unsigned char *)(skb->data), ETH_HLEN); cbFrameBodySize = skb->len - ETH_HLEN; // 802.1H if (ntohs(pDevice->sTxEthHeader.wType) > ETH_DATA_LEN) { @@ -2586,7 +2586,7 @@ pDevice->byTopCCKBasicRate,pDevice->byTopOFDMBasicRate); #endif vGenerateFIFOHeader(pDevice, byPktType, pDevice->pbyTmpBuff, bNeedEncryption, cbFrameBodySize, TYPE_AC0DMA, pHeadTD, - &pDevice->sTxEthHeader, (PBYTE)skb->data, pTransmitKey, uNodeIndex, + &pDevice->sTxEthHeader, (unsigned char *)skb->data, pTransmitKey, uNodeIndex, &uMACfragNum, &cbHeaderSize ); diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index 286461ca4e56..723f8466bd61 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -82,7 +82,7 @@ static BYTE s_byGetRateIdx(BYTE byRate); static void s_vGetDASA( - PBYTE pbyRxBufferAddr, + unsigned char *pbyRxBufferAddr, PUINT pcbHeaderSize, PSEthernetHeader psEthHeader ); @@ -91,7 +91,7 @@ static void s_vProcessRxMACHeader ( PSDevice pDevice, - PBYTE pbyRxBufferAddr, + unsigned char *pbyRxBufferAddr, unsigned int cbPacketSize, BOOL bIsWEP, BOOL bExtIV, @@ -100,7 +100,7 @@ s_vProcessRxMACHeader ( static BOOL s_bAPModeRxCtl( PSDevice pDevice, - PBYTE pbyFrame, + unsigned char *pbyFrame, int iSANodeIndex ); @@ -118,10 +118,10 @@ static BOOL s_bAPModeRxData ( static BOOL s_bHandleRxEncryption( PSDevice pDevice, - PBYTE pbyFrame, + unsigned char *pbyFrame, unsigned int FrameSize, - PBYTE pbyRsr, - PBYTE pbyNewRsr, + unsigned char *pbyRsr, + unsigned char *pbyNewRsr, PSKeyItem *pKeyOut, int * pbExtIV, PWORD pwRxTSC15_0, @@ -131,12 +131,12 @@ static BOOL s_bHandleRxEncryption( static BOOL s_bHostWepRxEncryption( PSDevice pDevice, - PBYTE pbyFrame, + unsigned char *pbyFrame, unsigned int FrameSize, - PBYTE pbyRsr, + unsigned char *pbyRsr, BOOL bOnFly, PSKeyItem pKey, - PBYTE pbyNewRsr, + unsigned char *pbyNewRsr, int * pbExtIV, PWORD pwRxTSC15_0, PDWORD pdwRxTSC47_16 @@ -166,14 +166,14 @@ static void s_vProcessRxMACHeader ( PSDevice pDevice, - PBYTE pbyRxBufferAddr, + unsigned char *pbyRxBufferAddr, unsigned int cbPacketSize, BOOL bIsWEP, BOOL bExtIV, PUINT pcbHeadSize ) { - PBYTE pbyRxBuffer; + unsigned char *pbyRxBuffer; unsigned int cbHeaderSize = 0; PWORD pwType; PS802_11Header pMACHeader; @@ -182,7 +182,7 @@ s_vProcessRxMACHeader ( pMACHeader = (PS802_11Header) (pbyRxBufferAddr + cbHeaderSize); - s_vGetDASA((PBYTE)pMACHeader, &cbHeaderSize, &pDevice->sRxEthHeader); + s_vGetDASA((unsigned char *)pMACHeader, &cbHeaderSize, &pDevice->sRxEthHeader); if (bIsWEP) { if (bExtIV) { @@ -197,7 +197,7 @@ s_vProcessRxMACHeader ( cbHeaderSize += WLAN_HDR_ADDR3_LEN; }; - pbyRxBuffer = (PBYTE) (pbyRxBufferAddr + cbHeaderSize); + pbyRxBuffer = (unsigned char *) (pbyRxBufferAddr + cbHeaderSize); if (!compare_ether_addr(pbyRxBuffer, &pDevice->abySNAP_Bridgetunnel[0])) { cbHeaderSize += 6; } @@ -237,7 +237,7 @@ s_vProcessRxMACHeader ( } cbHeaderSize -= (ETH_ALEN * 2); - pbyRxBuffer = (PBYTE) (pbyRxBufferAddr + cbHeaderSize); + pbyRxBuffer = (unsigned char *) (pbyRxBufferAddr + cbHeaderSize); for(ii=0;iisRxEthHeader.abyDstAddr[ii]; for(ii=0;iipMgmt; PSRxMgmtPacket pRxPacket = &(pDevice->pMgmt->sRxPacket); PS802_11Header p802_11Header; - PBYTE pbyRsr; - PBYTE pbyNewRsr; - PBYTE pbyRSSI; + unsigned char *pbyRsr; + unsigned char *pbyNewRsr; + unsigned char *pbyRSSI; PQWORD pqwTSFTime; PWORD pwFrameSize; - PBYTE pbyFrame; + unsigned char *pbyFrame; BOOL bDeFragRx = FALSE; BOOL bIsWEP = FALSE; unsigned int cbHeaderOffset; @@ -365,9 +365,9 @@ device_receive_frame ( unsigned int ii; unsigned int cbIVOffset; BOOL bExtIV = FALSE; - PBYTE pbyRxSts; - PBYTE pbyRxRate; - PBYTE pbySQ; + unsigned char *pbyRxSts; + unsigned char *pbyRxRate; + unsigned char *pbySQ; unsigned int cbHeaderSize; PSKeyItem pKey = NULL; WORD wRxTSC15_0 = 0; @@ -402,14 +402,14 @@ device_receive_frame ( return FALSE; } - pbyRxSts = (PBYTE) (skb->data); - pbyRxRate = (PBYTE) (skb->data + 1); - pbyRsr = (PBYTE) (skb->data + FrameSize - 1); - pbyRSSI = (PBYTE) (skb->data + FrameSize - 2); - pbyNewRsr = (PBYTE) (skb->data + FrameSize - 3); - pbySQ = (PBYTE) (skb->data + FrameSize - 4); + pbyRxSts = (unsigned char *) (skb->data); + pbyRxRate = (unsigned char *) (skb->data + 1); + pbyRsr = (unsigned char *) (skb->data + FrameSize - 1); + pbyRSSI = (unsigned char *) (skb->data + FrameSize - 2); + pbyNewRsr = (unsigned char *) (skb->data + FrameSize - 3); + pbySQ = (unsigned char *) (skb->data + FrameSize - 4); pqwTSFTime = (PQWORD) (skb->data + FrameSize - 12); - pbyFrame = (PBYTE)(skb->data + 4); + pbyFrame = (unsigned char *)(skb->data + 4); // get packet size FrameSize = cpu_to_le16(*pwFrameSize); @@ -431,7 +431,7 @@ device_receive_frame ( #endif - pMACHeader=(PS802_11Header)((PBYTE) (skb->data)+8); + pMACHeader=(PS802_11Header)((unsigned char *) (skb->data)+8); //PLICE_DEBUG<- if (pDevice->bMeasureInProgress == TRUE) { if ((*pbyRsr & RSR_CRCOK) != 0) { @@ -475,14 +475,14 @@ device_receive_frame ( s_vGetDASA(skb->data+4, &cbHeaderSize, &pDevice->sRxEthHeader); // filter packet send from myself - if (!compare_ether_addr((PBYTE)&(pDevice->sRxEthHeader.abySrcAddr[0]), pDevice->abyCurrentNetAddr)) + if (!compare_ether_addr((unsigned char *)&(pDevice->sRxEthHeader.abySrcAddr[0]), pDevice->abyCurrentNetAddr)) return FALSE; if ((pMgmt->eCurrMode == WMAC_MODE_ESS_AP) || (pMgmt->eCurrMode == WMAC_MODE_IBSS_STA)) { if (IS_CTL_PSPOLL(pbyFrame) || !IS_TYPE_CONTROL(pbyFrame)) { p802_11Header = (PS802_11Header) (pbyFrame); // get SA NodeIndex - if (BSSDBbIsSTAInNodeDB(pMgmt, (PBYTE)(p802_11Header->abyAddr2), &iSANodeIndex)) { + if (BSSDBbIsSTAInNodeDB(pMgmt, (unsigned char *)(p802_11Header->abyAddr2), &iSANodeIndex)) { pMgmt->sNodeDBTable[iSANodeIndex].ulLastRxJiffer = jiffies; pMgmt->sNodeDBTable[iSANodeIndex].uInActiveCount = 0; } @@ -594,8 +594,8 @@ device_receive_frame ( // Handle Control & Manage Frame if (IS_TYPE_MGMT((skb->data+4))) { - PBYTE pbyData1; - PBYTE pbyData2; + unsigned char *pbyData1; + unsigned char *pbyData2; pRxPacket->p80211Header = (PUWLAN_80211HDR)(skb->data+4); pRxPacket->cbMPDULen = FrameSize; @@ -827,11 +827,11 @@ device_receive_frame ( } MIC_vInit(dwMICKey0, dwMICKey1); - MIC_vAppend((PBYTE)&(pDevice->sRxEthHeader.abyDstAddr[0]), 12); + MIC_vAppend((unsigned char *)&(pDevice->sRxEthHeader.abyDstAddr[0]), 12); dwMIC_Priority = 0; - MIC_vAppend((PBYTE)&dwMIC_Priority, 4); + MIC_vAppend((unsigned char *)&dwMIC_Priority, 4); // 4 is Rcv buffer header, 24 is MAC Header, and 8 is IV and Ext IV. - MIC_vAppend((PBYTE)(skb->data + 4 + WLAN_HDR_ADDR3_LEN + 8), + MIC_vAppend((unsigned char *)(skb->data + 4 + WLAN_HDR_ADDR3_LEN + 8), FrameSize - WLAN_HDR_ADDR3_LEN - 8); MIC_vGetMIC(&dwLocalMIC_L, &dwLocalMIC_R); MIC_vUnInit(); @@ -963,7 +963,7 @@ device_receive_frame ( } - s_vProcessRxMACHeader(pDevice, (PBYTE)(skb->data+4), FrameSize, bIsWEP, bExtIV, &cbHeaderOffset); + s_vProcessRxMACHeader(pDevice, (unsigned char *)(skb->data+4), FrameSize, bIsWEP, bExtIV, &cbHeaderOffset); FrameSize -= cbHeaderOffset; cbHeaderOffset += 4; // 4 is Rcv buffer header @@ -1040,7 +1040,7 @@ device_receive_frame ( static BOOL s_bAPModeRxCtl ( PSDevice pDevice, - PBYTE pbyFrame, + unsigned char *pbyFrame, int iSANodeIndex ) { @@ -1063,7 +1063,7 @@ static BOOL s_bAPModeRxCtl ( // reason = (6) class 2 received from nonauth sta vMgrDeAuthenBeginSta(pDevice, pMgmt, - (PBYTE)(p802_11Header->abyAddr2), + (unsigned char *)(p802_11Header->abyAddr2), (WLAN_MGMT_REASON_CLASS2_NONAUTH), &Status ); @@ -1075,7 +1075,7 @@ static BOOL s_bAPModeRxCtl ( // reason = (7) class 3 received from nonassoc sta vMgrDisassocBeginSta(pDevice, pMgmt, - (PBYTE)(p802_11Header->abyAddr2), + (unsigned char *)(p802_11Header->abyAddr2), (WLAN_MGMT_REASON_CLASS3_NONASSOC), &Status ); @@ -1122,7 +1122,7 @@ static BOOL s_bAPModeRxCtl ( else { vMgrDeAuthenBeginSta(pDevice, pMgmt, - (PBYTE)(p802_11Header->abyAddr2), + (unsigned char *)(p802_11Header->abyAddr2), (WLAN_MGMT_REASON_CLASS2_NONAUTH), &Status ); @@ -1164,10 +1164,10 @@ static BOOL s_bAPModeRxCtl ( static BOOL s_bHandleRxEncryption ( PSDevice pDevice, - PBYTE pbyFrame, + unsigned char *pbyFrame, unsigned int FrameSize, - PBYTE pbyRsr, - PBYTE pbyNewRsr, + unsigned char *pbyRsr, + unsigned char *pbyNewRsr, PSKeyItem *pKeyOut, int * pbExtIV, PWORD pwRxTSC15_0, @@ -1175,7 +1175,7 @@ static BOOL s_bHandleRxEncryption ( ) { unsigned int PayloadLen = FrameSize; - PBYTE pbyIV; + unsigned char *pbyIV; BYTE byKeyIdx; PSKeyItem pKey = NULL; BYTE byDecMode = KEY_CTL_WEP; @@ -1310,19 +1310,19 @@ static BOOL s_bHandleRxEncryption ( static BOOL s_bHostWepRxEncryption ( PSDevice pDevice, - PBYTE pbyFrame, + unsigned char *pbyFrame, unsigned int FrameSize, - PBYTE pbyRsr, + unsigned char *pbyRsr, BOOL bOnFly, PSKeyItem pKey, - PBYTE pbyNewRsr, + unsigned char *pbyNewRsr, int * pbExtIV, PWORD pwRxTSC15_0, PDWORD pdwRxTSC47_16 ) { unsigned int PayloadLen = FrameSize; - PBYTE pbyIV; + unsigned char *pbyIV; BYTE byKeyIdx; BYTE byDecMode = KEY_CTL_WEP; PS802_11Header pMACHeader; @@ -1460,7 +1460,7 @@ static BOOL s_bAPModeRxData ( if (FrameSize > CB_MAX_BUF_SIZE) return FALSE; // check DA - if(is_multicast_ether_addr((PBYTE)(skb->data+cbHeaderOffset))) { + if(is_multicast_ether_addr((unsigned char *)(skb->data+cbHeaderOffset))) { if (pMgmt->sNodeDBTable[0].bPSEnable) { skbcpy = dev_alloc_skb((int)pDevice->rx_buf_sz); @@ -1486,7 +1486,7 @@ static BOOL s_bAPModeRxData ( } else { // check if relay - if (BSSDBbIsSTAInNodeDB(pMgmt, (PBYTE)(skb->data+cbHeaderOffset), &iDANodeIndex)) { + if (BSSDBbIsSTAInNodeDB(pMgmt, (unsigned char *)(skb->data+cbHeaderOffset), &iDANodeIndex)) { if (pMgmt->sNodeDBTable[iDANodeIndex].eNodeState >= NODE_ASSOC) { if (pMgmt->sNodeDBTable[iDANodeIndex].bPSEnable) { // queue this skb until next PS tx, and then release. @@ -1515,7 +1515,7 @@ static BOOL s_bAPModeRxData ( iDANodeIndex = 0; if ((pDevice->uAssocCount > 1) && (iDANodeIndex >= 0)) { - ROUTEbRelay(pDevice, (PBYTE)(skb->data + cbHeaderOffset), FrameSize, (unsigned int)iDANodeIndex); + ROUTEbRelay(pDevice, (unsigned char *)(skb->data + cbHeaderOffset), FrameSize, (unsigned int)iDANodeIndex); } if (bRelayOnly) diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c index 01429d1a95b5..8faeb6e8a2f3 100644 --- a/drivers/staging/vt6655/hostap.c +++ b/drivers/staging/vt6655/hostap.c @@ -580,7 +580,7 @@ static int hostap_set_encryption(PSDevice pDevice, dwKeyIndex & ~(USE_KEYRSC), param->u.crypt.key_len, (PQWORD) &(KeyRSC), - (PBYTE)abyKey, + (unsigned char *)abyKey, KEY_CTL_WEP, pDevice->PortOffset, pDevice->byLocalID) == TRUE) { @@ -649,7 +649,7 @@ static int hostap_set_encryption(PSDevice pDevice, dwKeyIndex, param->u.crypt.key_len, (PQWORD) &(KeyRSC), - (PBYTE)abyKey, + (unsigned char *)abyKey, byKeyDecMode, pDevice->PortOffset, pDevice->byLocalID) == TRUE) { diff --git a/drivers/staging/vt6655/ioctl.c b/drivers/staging/vt6655/ioctl.c index 6118a3cb02e4..cc4f4c1b4cc0 100644 --- a/drivers/staging/vt6655/ioctl.c +++ b/drivers/staging/vt6655/ioctl.c @@ -257,7 +257,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) { dwKeyIndex, sWEPCmd.auWepKeyLength[ii], NULL, - (PBYTE)&sWEPCmd.abyWepKey[ii][0], + (unsigned char *)&sWEPCmd.abyWepKey[ii][0], KEY_CTL_WEP, pDevice->PortOffset, pDevice->byLocalID); @@ -718,7 +718,7 @@ void vConfigWEPKey ( PSDevice pDevice, DWORD dwKeyIndex, - PBYTE pbyKey, + unsigned char *pbyKey, unsigned long uKeyLength ) { diff --git a/drivers/staging/vt6655/ioctl.h b/drivers/staging/vt6655/ioctl.h index 4a30e271294f..0de2324d15da 100644 --- a/drivers/staging/vt6655/ioctl.h +++ b/drivers/staging/vt6655/ioctl.h @@ -46,7 +46,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq); void vConfigWEPKey ( PSDevice pDevice, DWORD dwKeyIndex, - PBYTE pbyKey, + unsigned char *pbyKey, unsigned long uKeyLength ); */ diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c index 74c0b9afd658..a2b2bc5d4341 100644 --- a/drivers/staging/vt6655/iwctl.c +++ b/drivers/staging/vt6655/iwctl.c @@ -2096,7 +2096,7 @@ int iwctl_siwmlme(struct net_device *dev, switch(mlme->cmd){ case IW_MLME_DEAUTH: //this command seems to be not complete,please test it --einsnliu - //bScheduleCommand((void *) pDevice, WLAN_CMD_DEAUTH, (PBYTE)&reason); + //bScheduleCommand((void *) pDevice, WLAN_CMD_DEAUTH, (unsigned char *)&reason); break; case IW_MLME_DISASSOC: if(pDevice->bLinkPass == TRUE){ diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c index 141d249541c2..add139f18662 100644 --- a/drivers/staging/vt6655/key.c +++ b/drivers/staging/vt6655/key.c @@ -133,7 +133,7 @@ void KeyvInitTable (PSKeyManagement pTable, DWORD_PTR dwIoBase) */ BOOL KeybGetKey ( PSKeyManagement pTable, - PBYTE pbyBSSID, + unsigned char *pbyBSSID, DWORD dwKeyIndex, PSKeyItem *pKey ) @@ -191,11 +191,11 @@ BOOL KeybGetKey ( */ BOOL KeybSetKey ( PSKeyManagement pTable, - PBYTE pbyBSSID, + unsigned char *pbyBSSID, DWORD dwKeyIndex, unsigned long uKeyLength, PQWORD pKeyRSC, - PBYTE pbyKey, + unsigned char *pbyKey, BYTE byKeyDecMode, DWORD_PTR dwIoBase, BYTE byLocalID @@ -364,7 +364,7 @@ BOOL KeybSetKey ( */ BOOL KeybRemoveKey ( PSKeyManagement pTable, - PBYTE pbyBSSID, + unsigned char *pbyBSSID, DWORD dwKeyIndex, DWORD_PTR dwIoBase ) @@ -437,7 +437,7 @@ BOOL KeybRemoveKey ( */ BOOL KeybRemoveAllKey ( PSKeyManagement pTable, - PBYTE pbyBSSID, + unsigned char *pbyBSSID, DWORD_PTR dwIoBase ) { @@ -519,7 +519,7 @@ void KeyvRemoveAllWEPKey ( */ BOOL KeybGetTransmitKey ( PSKeyManagement pTable, - PBYTE pbyBSSID, + unsigned char *pbyBSSID, DWORD dwKeyType, PSKeyItem *pKey ) @@ -636,7 +636,7 @@ BOOL KeybSetDefaultKey ( DWORD dwKeyIndex, unsigned long uKeyLength, PQWORD pKeyRSC, - PBYTE pbyKey, + unsigned char *pbyKey, BYTE byKeyDecMode, DWORD_PTR dwIoBase, BYTE byLocalID @@ -743,7 +743,7 @@ BOOL KeybSetAllGroupKey ( DWORD dwKeyIndex, unsigned long uKeyLength, PQWORD pKeyRSC, - PBYTE pbyKey, + unsigned char *pbyKey, BYTE byKeyDecMode, DWORD_PTR dwIoBase, BYTE byLocalID diff --git a/drivers/staging/vt6655/key.h b/drivers/staging/vt6655/key.h index 8ba8b2752ce6..e8a74b469efc 100644 --- a/drivers/staging/vt6655/key.h +++ b/drivers/staging/vt6655/key.h @@ -105,18 +105,18 @@ void KeyvInitTable(PSKeyManagement pTable, DWORD_PTR dwIoBase); BOOL KeybGetKey( PSKeyManagement pTable, - PBYTE pbyBSSID, + unsigned char *pbyBSSID, DWORD dwKeyIndex, PSKeyItem *pKey ); BOOL KeybSetKey( PSKeyManagement pTable, - PBYTE pbyBSSID, + unsigned char *pbyBSSID, DWORD dwKeyIndex, unsigned long uKeyLength, PQWORD pKeyRSC, - PBYTE pbyKey, + unsigned char *pbyKey, BYTE byKeyDecMode, DWORD_PTR dwIoBase, BYTE byLocalID @@ -127,7 +127,7 @@ BOOL KeybSetDefaultKey( DWORD dwKeyIndex, unsigned long uKeyLength, PQWORD pKeyRSC, - PBYTE pbyKey, + unsigned char *pbyKey, BYTE byKeyDecMode, DWORD_PTR dwIoBase, BYTE byLocalID @@ -135,14 +135,14 @@ BOOL KeybSetDefaultKey( BOOL KeybRemoveKey( PSKeyManagement pTable, - PBYTE pbyBSSID, + unsigned char *pbyBSSID, DWORD dwKeyIndex, DWORD_PTR dwIoBase ); BOOL KeybGetTransmitKey( PSKeyManagement pTable, - PBYTE pbyBSSID, + unsigned char *pbyBSSID, DWORD dwKeyType, PSKeyItem *pKey ); @@ -154,7 +154,7 @@ BOOL KeybCheckPairewiseKey( BOOL KeybRemoveAllKey( PSKeyManagement pTable, - PBYTE pbyBSSID, + unsigned char *pbyBSSID, DWORD_PTR dwIoBase ); @@ -174,7 +174,7 @@ BOOL KeybSetAllGroupKey ( DWORD dwKeyIndex, unsigned long uKeyLength, PQWORD pKeyRSC, - PBYTE pbyKey, + unsigned char *pbyKey, BYTE byKeyDecMode, DWORD_PTR dwIoBase, BYTE byLocalID diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c index f4acb2f3213f..9d54b421f770 100644 --- a/drivers/staging/vt6655/mac.c +++ b/drivers/staging/vt6655/mac.c @@ -103,7 +103,7 @@ static int msglevel =MSG_LEVEL_INFO; * Return Value: none * */ -void MACvReadAllRegs (DWORD_PTR dwIoBase, PBYTE pbyMacRegs) +void MACvReadAllRegs (DWORD_PTR dwIoBase, unsigned char *pbyMacRegs) { int ii; @@ -342,7 +342,7 @@ void MACvSetRxThreshold (DWORD_PTR dwIoBase, BYTE byThreshold) * Return Value: none * */ -void MACvGetRxThreshold (DWORD_PTR dwIoBase, PBYTE pbyThreshold) +void MACvGetRxThreshold (DWORD_PTR dwIoBase, unsigned char *pbyThreshold) { // get FCR0 VNSvInPortB(dwIoBase + MAC_REG_FCR0, pbyThreshold); @@ -388,7 +388,7 @@ void MACvSetTxThreshold (DWORD_PTR dwIoBase, BYTE byThreshold) * Return Value: none * */ -void MACvGetTxThreshold (DWORD_PTR dwIoBase, PBYTE pbyThreshold) +void MACvGetTxThreshold (DWORD_PTR dwIoBase, unsigned char *pbyThreshold) { // get FCR0 VNSvInPortB(dwIoBase + MAC_REG_FCR0, pbyThreshold); @@ -434,7 +434,7 @@ void MACvSetDmaLength (DWORD_PTR dwIoBase, BYTE byDmaLength) * Return Value: none * */ -void MACvGetDmaLength (DWORD_PTR dwIoBase, PBYTE pbyDmaLength) +void MACvGetDmaLength (DWORD_PTR dwIoBase, unsigned char *pbyDmaLength) { // get FCR0 VNSvInPortB(dwIoBase + MAC_REG_FCR0, pbyDmaLength); @@ -474,7 +474,7 @@ void MACvSetShortRetryLimit (DWORD_PTR dwIoBase, BYTE byRetryLimit) * Return Value: none * */ -void MACvGetShortRetryLimit (DWORD_PTR dwIoBase, PBYTE pbyRetryLimit) +void MACvGetShortRetryLimit (DWORD_PTR dwIoBase, unsigned char *pbyRetryLimit) { // get SRT VNSvInPortB(dwIoBase + MAC_REG_SRT, pbyRetryLimit); @@ -513,7 +513,7 @@ void MACvSetLongRetryLimit (DWORD_PTR dwIoBase, BYTE byRetryLimit) * Return Value: none * */ -void MACvGetLongRetryLimit (DWORD_PTR dwIoBase, PBYTE pbyRetryLimit) +void MACvGetLongRetryLimit (DWORD_PTR dwIoBase, unsigned char *pbyRetryLimit) { // get LRT VNSvInPortB(dwIoBase + MAC_REG_LRT, pbyRetryLimit); @@ -643,7 +643,7 @@ void MACvSetPacketFilter (DWORD_PTR dwIoBase, WORD wFilterType) * Return Value: none * */ -void MACvSaveContext (DWORD_PTR dwIoBase, PBYTE pbyCxtBuf) +void MACvSaveContext (DWORD_PTR dwIoBase, unsigned char *pbyCxtBuf) { int ii; @@ -676,7 +676,7 @@ void MACvSaveContext (DWORD_PTR dwIoBase, PBYTE pbyCxtBuf) * Return Value: none * */ -void MACvRestoreContext (DWORD_PTR dwIoBase, PBYTE pbyCxtBuf) +void MACvRestoreContext (DWORD_PTR dwIoBase, unsigned char *pbyCxtBuf) { int ii; @@ -728,7 +728,7 @@ void MACvRestoreContext (DWORD_PTR dwIoBase, PBYTE pbyCxtBuf) * Return Value: TRUE if all values are the same; otherwise FALSE * */ -BOOL MACbCompareContext (DWORD_PTR dwIoBase, PBYTE pbyCxtBuf) +BOOL MACbCompareContext (DWORD_PTR dwIoBase, unsigned char *pbyCxtBuf) { DWORD dwData; @@ -1456,7 +1456,7 @@ BOOL MACbPSWakeup (DWORD_PTR dwIoBase) */ void MACvSetKeyEntry (DWORD_PTR dwIoBase, WORD wKeyCtl, unsigned int uEntryIdx, - unsigned int uKeyIdx, PBYTE pbyAddr, PDWORD pdwKey, BYTE byLocalID) + unsigned int uKeyIdx, unsigned char *pbyAddr, PDWORD pdwKey, BYTE byLocalID) { WORD wOffset; DWORD dwData; diff --git a/drivers/staging/vt6655/mac.h b/drivers/staging/vt6655/mac.h index 88a440398734..24e9b7ae6e15 100644 --- a/drivers/staging/vt6655/mac.h +++ b/drivers/staging/vt6655/mac.h @@ -765,7 +765,7 @@ { \ VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 1); \ VNSvInPortB(dwIoBase + MAC_REG_BSSID0, \ - (PBYTE)pbyEtherAddr); \ + (unsigned char *)pbyEtherAddr); \ VNSvInPortB(dwIoBase + MAC_REG_BSSID0 + 1, \ pbyEtherAddr + 1); \ VNSvInPortB(dwIoBase + MAC_REG_BSSID0 + 2, \ @@ -801,7 +801,7 @@ { \ VNSvOutPortB(dwIoBase + MAC_REG_PAGE1SEL, 1); \ VNSvInPortB(dwIoBase + MAC_REG_PAR0, \ - (PBYTE)pbyEtherAddr); \ + (unsigned char *)pbyEtherAddr); \ VNSvInPortB(dwIoBase + MAC_REG_PAR0 + 1, \ pbyEtherAddr + 1); \ VNSvInPortB(dwIoBase + MAC_REG_PAR0 + 2, \ @@ -1075,7 +1075,7 @@ /*--------------------- Export Functions --------------------------*/ extern WORD TxRate_iwconfig;//2008-5-8 by chester -void MACvReadAllRegs(DWORD_PTR dwIoBase, PBYTE pbyMacRegs); +void MACvReadAllRegs(DWORD_PTR dwIoBase, unsigned char *pbyMacRegs); BOOL MACbIsRegBitsOn(DWORD_PTR dwIoBase, BYTE byRegOfs, BYTE byTestBits); BOOL MACbIsRegBitsOff(DWORD_PTR dwIoBase, BYTE byRegOfs, BYTE byTestBits); @@ -1088,28 +1088,28 @@ void MACvSetMultiAddrByHash(DWORD_PTR dwIoBase, BYTE byHashIdx); void MACvResetMultiAddrByHash(DWORD_PTR dwIoBase, BYTE byHashIdx); void MACvSetRxThreshold(DWORD_PTR dwIoBase, BYTE byThreshold); -void MACvGetRxThreshold(DWORD_PTR dwIoBase, PBYTE pbyThreshold); +void MACvGetRxThreshold(DWORD_PTR dwIoBase, unsigned char *pbyThreshold); void MACvSetTxThreshold(DWORD_PTR dwIoBase, BYTE byThreshold); -void MACvGetTxThreshold(DWORD_PTR dwIoBase, PBYTE pbyThreshold); +void MACvGetTxThreshold(DWORD_PTR dwIoBase, unsigned char *pbyThreshold); void MACvSetDmaLength(DWORD_PTR dwIoBase, BYTE byDmaLength); -void MACvGetDmaLength(DWORD_PTR dwIoBase, PBYTE pbyDmaLength); +void MACvGetDmaLength(DWORD_PTR dwIoBase, unsigned char *pbyDmaLength); void MACvSetShortRetryLimit(DWORD_PTR dwIoBase, BYTE byRetryLimit); -void MACvGetShortRetryLimit(DWORD_PTR dwIoBase, PBYTE pbyRetryLimit); +void MACvGetShortRetryLimit(DWORD_PTR dwIoBase, unsigned char *pbyRetryLimit); void MACvSetLongRetryLimit(DWORD_PTR dwIoBase, BYTE byRetryLimit); -void MACvGetLongRetryLimit(DWORD_PTR dwIoBase, PBYTE pbyRetryLimit); +void MACvGetLongRetryLimit(DWORD_PTR dwIoBase, unsigned char *pbyRetryLimit); void MACvSetLoopbackMode(DWORD_PTR dwIoBase, BYTE byLoopbackMode); BOOL MACbIsInLoopbackMode(DWORD_PTR dwIoBase); void MACvSetPacketFilter(DWORD_PTR dwIoBase, WORD wFilterType); -void MACvSaveContext(DWORD_PTR dwIoBase, PBYTE pbyCxtBuf); -void MACvRestoreContext(DWORD_PTR dwIoBase, PBYTE pbyCxtBuf); -BOOL MACbCompareContext(DWORD_PTR dwIoBase, PBYTE pbyCxtBuf); +void MACvSaveContext(DWORD_PTR dwIoBase, unsigned char *pbyCxtBuf); +void MACvRestoreContext(DWORD_PTR dwIoBase, unsigned char *pbyCxtBuf); +BOOL MACbCompareContext(DWORD_PTR dwIoBase, unsigned char *pbyCxtBuf); BOOL MACbSoftwareReset(DWORD_PTR dwIoBase); BOOL MACbSafeSoftwareReset(DWORD_PTR dwIoBase); @@ -1140,7 +1140,7 @@ BOOL MACbFlushSYNCFifo(DWORD_PTR dwIoBase); BOOL MACbPSWakeup(DWORD_PTR dwIoBase); void MACvSetKeyEntry(DWORD_PTR dwIoBase, WORD wKeyCtl, unsigned int uEntryIdx, - unsigned int uKeyIdx, PBYTE pbyAddr, PDWORD pdwKey, BYTE byLocalID); + unsigned int uKeyIdx, unsigned char *pbyAddr, PDWORD pdwKey, BYTE byLocalID); void MACvDisableKeyEntry(DWORD_PTR dwIoBase, unsigned int uEntryIdx); void MACvSetDefaultKeyEntry(DWORD_PTR dwIoBase, unsigned int uKeyLen, unsigned int uKeyIdx, PDWORD pdwKey, BYTE byLocalID); diff --git a/drivers/staging/vt6655/mib.c b/drivers/staging/vt6655/mib.c index d34ebd31efcb..867d8d261927 100644 --- a/drivers/staging/vt6655/mib.c +++ b/drivers/staging/vt6655/mib.c @@ -178,7 +178,7 @@ void STAvUpdateIsrStatCounter (PSStatCounter pStatistic, DWORD dwIsr) */ void STAvUpdateRDStatCounter (PSStatCounter pStatistic, BYTE byRSR, BYTE byNewRSR, BYTE byRxRate, - PBYTE pbyBuffer, unsigned int cbFrameLength) + unsigned char *pbyBuffer, unsigned int cbFrameLength) { //need change PS802_11Header pHeader = (PS802_11Header)pbyBuffer; @@ -392,7 +392,7 @@ STAvUpdateRDStatCounterEx ( BYTE byRSR, BYTE byNewRSR, BYTE byRxRate, - PBYTE pbyBuffer, + unsigned char *pbyBuffer, unsigned int cbFrameLength ) { @@ -408,7 +408,7 @@ STAvUpdateRDStatCounterEx ( // rx length pStatistic->dwCntRxFrmLength = cbFrameLength; // rx pattern, we just see 10 bytes for sample - memcpy(pStatistic->abyCntRxPattern, (PBYTE)pbyBuffer, 10); + memcpy(pStatistic->abyCntRxPattern, (unsigned char *)pbyBuffer, 10); } @@ -434,13 +434,13 @@ STAvUpdateTDStatCounter ( PSStatCounter pStatistic, BYTE byTSR0, BYTE byTSR1, - PBYTE pbyBuffer, + unsigned char *pbyBuffer, unsigned int cbFrameLength, unsigned int uIdx ) { PWLAN_80211HDR_A4 pHeader; - PBYTE pbyDestAddr; + unsigned char *pbyDestAddr; BYTE byTSR0_NCR = byTSR0 & TSR0_NCR; @@ -522,7 +522,7 @@ STAvUpdateTDStatCounter ( void STAvUpdateTDStatCounterEx ( PSStatCounter pStatistic, - PBYTE pbyBuffer, + unsigned char *pbyBuffer, DWORD cbFrameLength ) { diff --git a/drivers/staging/vt6655/mib.h b/drivers/staging/vt6655/mib.h index 1540b27faf70..35bb7c48eff7 100644 --- a/drivers/staging/vt6655/mib.h +++ b/drivers/staging/vt6655/mib.h @@ -348,18 +348,18 @@ void STAvUpdateIsrStatCounter(PSStatCounter pStatistic, DWORD dwIsr); void STAvUpdateRDStatCounter(PSStatCounter pStatistic, BYTE byRSR, BYTE byNewRSR, BYTE byRxRate, - PBYTE pbyBuffer, unsigned int cbFrameLength); + unsigned char *pbyBuffer, unsigned int cbFrameLength); void STAvUpdateRDStatCounterEx(PSStatCounter pStatistic, BYTE byRSR, BYTE byNewRsr, BYTE byRxRate, - PBYTE pbyBuffer, unsigned int cbFrameLength); + unsigned char *pbyBuffer, unsigned int cbFrameLength); void STAvUpdateTDStatCounter(PSStatCounter pStatistic, BYTE byTSR0, BYTE byTSR1, - PBYTE pbyBuffer, unsigned int cbFrameLength, unsigned int uIdx); + unsigned char *pbyBuffer, unsigned int cbFrameLength, unsigned int uIdx); void STAvUpdateTDStatCounterEx( PSStatCounter pStatistic, - PBYTE pbyBuffer, + unsigned char *pbyBuffer, DWORD cbFrameLength ); diff --git a/drivers/staging/vt6655/michael.c b/drivers/staging/vt6655/michael.c index 3a92257bd3e8..2a346307f4db 100644 --- a/drivers/staging/vt6655/michael.c +++ b/drivers/staging/vt6655/michael.c @@ -149,7 +149,7 @@ void MIC_vUnInit (void) s_vClear(); } -void MIC_vAppend (PBYTE src, unsigned int nBytes) +void MIC_vAppend (unsigned char *src, unsigned int nBytes) { // This is simple while (nBytes > 0) diff --git a/drivers/staging/vt6655/michael.h b/drivers/staging/vt6655/michael.h index c1584a0ce7a1..ecb2912939c6 100644 --- a/drivers/staging/vt6655/michael.h +++ b/drivers/staging/vt6655/michael.h @@ -40,7 +40,7 @@ void MIC_vInit(DWORD dwK0, DWORD dwK1); void MIC_vUnInit(void); // Append bytes to the message to be MICed -void MIC_vAppend(PBYTE src, unsigned int nBytes); +void MIC_vAppend(unsigned char *src, unsigned int nBytes); // Get the MIC result. Destination should accept 8 bytes of result. // This also resets the message to empty. diff --git a/drivers/staging/vt6655/power.c b/drivers/staging/vt6655/power.c index d4e076513f63..a2491d3d0a8a 100644 --- a/drivers/staging/vt6655/power.c +++ b/drivers/staging/vt6655/power.c @@ -262,7 +262,7 @@ PSvSendPSPOLL( memset(pMgmt->pbyPSPacketPool, 0, sizeof(STxMgmtPacket) + WLAN_HDR_ADDR2_LEN); pTxPacket = (PSTxMgmtPacket)pMgmt->pbyPSPacketPool; - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); pTxPacket->p80211Header->sA2.wFrameCtl = cpu_to_le16( ( WLAN_SET_FC_FTYPE(WLAN_TYPE_CTL) | @@ -329,7 +329,7 @@ PSbSendNullPacket( memset(pMgmt->pbyPSPacketPool, 0, sizeof(STxMgmtPacket) + WLAN_NULLDATA_FR_MAXLEN); pTxPacket = (PSTxMgmtPacket)pMgmt->pbyPSPacketPool; - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); if (pDevice->bEnablePSMode) { diff --git a/drivers/staging/vt6655/rc4.c b/drivers/staging/vt6655/rc4.c index 0d641ffefc99..783fdff6d63a 100644 --- a/drivers/staging/vt6655/rc4.c +++ b/drivers/staging/vt6655/rc4.c @@ -32,12 +32,12 @@ #include "rc4.h" -void rc4_init(PRC4Ext pRC4, PBYTE pbyKey, unsigned int cbKey_len) +void rc4_init(PRC4Ext pRC4, unsigned char *pbyKey, unsigned int cbKey_len) { unsigned int ust1, ust2; unsigned int keyindex; unsigned int stateindex; - PBYTE pbyst; + unsigned char *pbyst; unsigned int idx; pbyst = pRC4->abystate; @@ -63,7 +63,7 @@ unsigned int rc4_byte(PRC4Ext pRC4) unsigned int ux; unsigned int uy; unsigned int ustx, usty; - PBYTE pbyst; + unsigned char *pbyst; pbyst = pRC4->abystate; ux = (pRC4->ux + 1) & 0xff; @@ -78,8 +78,8 @@ unsigned int rc4_byte(PRC4Ext pRC4) return pbyst[(ustx + usty) & 0xff]; } -void rc4_encrypt(PRC4Ext pRC4, PBYTE pbyDest, - PBYTE pbySrc, unsigned int cbData_len) +void rc4_encrypt(PRC4Ext pRC4, unsigned char *pbyDest, + unsigned char *pbySrc, unsigned int cbData_len) { unsigned int ii; for (ii = 0; ii < cbData_len; ii++) diff --git a/drivers/staging/vt6655/rc4.h b/drivers/staging/vt6655/rc4.h index a40030461c12..c94eea27ac85 100644 --- a/drivers/staging/vt6655/rc4.h +++ b/drivers/staging/vt6655/rc4.h @@ -40,8 +40,8 @@ typedef struct { BYTE abystate[256]; } RC4Ext, *PRC4Ext; -void rc4_init(PRC4Ext pRC4, PBYTE pbyKey, unsigned int cbKey_len); +void rc4_init(PRC4Ext pRC4, unsigned char *pbyKey, unsigned int cbKey_len); unsigned int rc4_byte(PRC4Ext pRC4); -void rc4_encrypt(PRC4Ext pRC4, PBYTE pbyDest, PBYTE pbySrc, unsigned int cbData_len); +void rc4_encrypt(PRC4Ext pRC4, unsigned char *pbyDest, unsigned char *pbySrc, unsigned int cbData_len); #endif //__RC4_H__ diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 271a4ab94886..32725dadf855 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -118,12 +118,12 @@ static void s_vFillTxKey( PSDevice pDevice, - PBYTE pbyBuf, - PBYTE pbyIVHead, + unsigned char *pbyBuf, + unsigned char *pbyIVHead, PSKeyItem pTransmitKey, - PBYTE pbyHdrBuf, + unsigned char *pbyHdrBuf, WORD wPayloadLen, - PBYTE pMICHDR + unsigned char *pMICHDR ); @@ -162,7 +162,7 @@ s_vGenerateTxParameter( static void s_vFillFragParameter( PSDevice pDevice, - PBYTE pbyBuffer, + unsigned char *pbyBuffer, unsigned int uTxType, void * pvtdCurr, WORD wFragType, @@ -175,12 +175,12 @@ unsigned int s_cbFillTxBufHead ( PSDevice pDevice, BYTE byPktType, - PBYTE pbyTxBufferAddr, + unsigned char *pbyTxBufferAddr, unsigned int cbFrameBodySize, unsigned int uDMAIdx, PSTxDesc pHeadTD, PSEthernetHeader psEthHeader, - PBYTE pPacket, + unsigned char *pPacket, BOOL bNeedEncrypt, PSKeyItem pTransmitKey, unsigned int uNodeIndex, @@ -213,16 +213,16 @@ static void s_vFillTxKey ( PSDevice pDevice, - PBYTE pbyBuf, - PBYTE pbyIVHead, + unsigned char *pbyBuf, + unsigned char *pbyIVHead, PSKeyItem pTransmitKey, - PBYTE pbyHdrBuf, + unsigned char *pbyHdrBuf, WORD wPayloadLen, - PBYTE pMICHDR + unsigned char *pMICHDR ) { PDWORD pdwIV = (PDWORD) pbyIVHead; - PDWORD pdwExtIV = (PDWORD) ((PBYTE)pbyIVHead+4); + PDWORD pdwExtIV = (PDWORD) ((unsigned char *)pbyIVHead+4); WORD wValue; PS802_11Header pMACHeader = (PS802_11Header)pbyHdrBuf; DWORD dwRevIVCounter; @@ -240,13 +240,13 @@ s_vFillTxKey ( if (pTransmitKey->byCipherSuite == KEY_CTL_WEP) { if (pTransmitKey->uKeyLength == WLAN_WEP232_KEYLEN ){ - memcpy(pDevice->abyPRNG, (PBYTE)&(dwRevIVCounter), 3); + memcpy(pDevice->abyPRNG, (unsigned char *)&(dwRevIVCounter), 3); memcpy(pDevice->abyPRNG+3, pTransmitKey->abyKey, pTransmitKey->uKeyLength); } else { - memcpy(pbyBuf, (PBYTE)&(dwRevIVCounter), 3); + memcpy(pbyBuf, (unsigned char *)&(dwRevIVCounter), 3); memcpy(pbyBuf+3, pTransmitKey->abyKey, pTransmitKey->uKeyLength); if(pTransmitKey->uKeyLength == WLAN_WEP40_KEYLEN) { - memcpy(pbyBuf+8, (PBYTE)&(dwRevIVCounter), 3); + memcpy(pbyBuf+8, (unsigned char *)&(dwRevIVCounter), 3); memcpy(pbyBuf+11, pTransmitKey->abyKey, pTransmitKey->uKeyLength); } memcpy(pDevice->abyPRNG, pbyBuf, 16); @@ -291,26 +291,26 @@ s_vFillTxKey ( //Fill MICHDR0 *pMICHDR = 0x59; - *((PBYTE)(pMICHDR+1)) = 0; // TxPriority + *((unsigned char *)(pMICHDR+1)) = 0; // TxPriority memcpy(pMICHDR+2, &(pMACHeader->abyAddr2[0]), 6); - *((PBYTE)(pMICHDR+8)) = HIBYTE(HIWORD(pTransmitKey->dwTSC47_16)); - *((PBYTE)(pMICHDR+9)) = LOBYTE(HIWORD(pTransmitKey->dwTSC47_16)); - *((PBYTE)(pMICHDR+10)) = HIBYTE(LOWORD(pTransmitKey->dwTSC47_16)); - *((PBYTE)(pMICHDR+11)) = LOBYTE(LOWORD(pTransmitKey->dwTSC47_16)); - *((PBYTE)(pMICHDR+12)) = HIBYTE(pTransmitKey->wTSC15_0); - *((PBYTE)(pMICHDR+13)) = LOBYTE(pTransmitKey->wTSC15_0); - *((PBYTE)(pMICHDR+14)) = HIBYTE(wPayloadLen); - *((PBYTE)(pMICHDR+15)) = LOBYTE(wPayloadLen); + *((unsigned char *)(pMICHDR+8)) = HIBYTE(HIWORD(pTransmitKey->dwTSC47_16)); + *((unsigned char *)(pMICHDR+9)) = LOBYTE(HIWORD(pTransmitKey->dwTSC47_16)); + *((unsigned char *)(pMICHDR+10)) = HIBYTE(LOWORD(pTransmitKey->dwTSC47_16)); + *((unsigned char *)(pMICHDR+11)) = LOBYTE(LOWORD(pTransmitKey->dwTSC47_16)); + *((unsigned char *)(pMICHDR+12)) = HIBYTE(pTransmitKey->wTSC15_0); + *((unsigned char *)(pMICHDR+13)) = LOBYTE(pTransmitKey->wTSC15_0); + *((unsigned char *)(pMICHDR+14)) = HIBYTE(wPayloadLen); + *((unsigned char *)(pMICHDR+15)) = LOBYTE(wPayloadLen); //Fill MICHDR1 - *((PBYTE)(pMICHDR+16)) = 0; // HLEN[15:8] + *((unsigned char *)(pMICHDR+16)) = 0; // HLEN[15:8] if (pDevice->bLongHeader) { - *((PBYTE)(pMICHDR+17)) = 28; // HLEN[7:0] + *((unsigned char *)(pMICHDR+17)) = 28; // HLEN[7:0] } else { - *((PBYTE)(pMICHDR+17)) = 22; // HLEN[7:0] + *((unsigned char *)(pMICHDR+17)) = 22; // HLEN[7:0] } wValue = cpu_to_le16(pMACHeader->wFrameCtl & 0xC78F); - memcpy(pMICHDR+18, (PBYTE)&wValue, 2); // MSKFRACTL + memcpy(pMICHDR+18, (unsigned char *)&wValue, 2); // MSKFRACTL memcpy(pMICHDR+20, &(pMACHeader->abyAddr1[0]), 6); memcpy(pMICHDR+26, &(pMACHeader->abyAddr2[0]), 6); @@ -319,7 +319,7 @@ s_vFillTxKey ( wValue = pMACHeader->wSeqCtl; wValue &= 0x000F; wValue = cpu_to_le16(wValue); - memcpy(pMICHDR+38, (PBYTE)&wValue, 2); // MSKSEQCTL + memcpy(pMICHDR+38, (unsigned char *)&wValue, 2); // MSKSEQCTL if (pDevice->bLongHeader) { memcpy(pMICHDR+40, &(pMACHeader->abyAddr4[0]), 6); } @@ -332,7 +332,7 @@ void s_vSWencryption ( PSDevice pDevice, PSKeyItem pTransmitKey, - PBYTE pbyPayloadHead, + unsigned char *pbyPayloadHead, WORD wPayloadSize ) { @@ -745,11 +745,11 @@ s_uFillDataHead ( PSTxDataHead_g pBuf = (PSTxDataHead_g)pTxDataHead; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, - (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_a), (PBYTE)&(pBuf->bySignalField_a) + (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_a), (unsigned char *)&(pBuf->bySignalField_a) ); pBuf->wTransmitLength_a = cpu_to_le16(wLen); BBvCaculateParameter(pDevice, cbFrameLength, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b) + (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_b), (unsigned char *)&(pBuf->bySignalField_b) ); pBuf->wTransmitLength_b = cpu_to_le16(wLen); //Get Duration and TimeStamp @@ -771,11 +771,11 @@ s_uFillDataHead ( PSTxDataHead_g_FB pBuf = (PSTxDataHead_g_FB)pTxDataHead; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, - (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_a), (PBYTE)&(pBuf->bySignalField_a) + (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_a), (unsigned char *)&(pBuf->bySignalField_a) ); pBuf->wTransmitLength_a = cpu_to_le16(wLen); BBvCaculateParameter(pDevice, cbFrameLength, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b) + (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_b), (unsigned char *)&(pBuf->bySignalField_b) ); pBuf->wTransmitLength_b = cpu_to_le16(wLen); //Get Duration and TimeStamp @@ -800,7 +800,7 @@ s_uFillDataHead ( PSTxDataHead_a_FB pBuf = (PSTxDataHead_a_FB)pTxDataHead; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, - (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField) + (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField), (unsigned char *)&(pBuf->bySignalField) ); pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration and TimeStampOff @@ -817,7 +817,7 @@ s_uFillDataHead ( PSTxDataHead_ab pBuf = (PSTxDataHead_ab)pTxDataHead; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, - (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField) + (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField), (unsigned char *)&(pBuf->bySignalField) ); pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration and TimeStampOff @@ -835,7 +835,7 @@ s_uFillDataHead ( PSTxDataHead_ab pBuf = (PSTxDataHead_ab)pTxDataHead; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, - (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField) + (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField), (unsigned char *)&(pBuf->bySignalField) ); pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration and TimeStampOff @@ -883,11 +883,11 @@ s_vFillRTSHead ( PSRTS_g pBuf = (PSRTS_g)pvRTS; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b) + (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_b), (unsigned char *)&(pBuf->bySignalField_b) ); pBuf->wTransmitLength_b = cpu_to_le16(wLen); BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, - (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_a), (PBYTE)&(pBuf->bySignalField_a) + (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_a), (unsigned char *)&(pBuf->bySignalField_a) ); pBuf->wTransmitLength_a = cpu_to_le16(wLen); //Get Duration @@ -916,11 +916,11 @@ s_vFillRTSHead ( PSRTS_g_FB pBuf = (PSRTS_g_FB)pvRTS; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b) + (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_b), (unsigned char *)&(pBuf->bySignalField_b) ); pBuf->wTransmitLength_b = cpu_to_le16(wLen); BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, - (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_a), (PBYTE)&(pBuf->bySignalField_a) + (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_a), (unsigned char *)&(pBuf->bySignalField_a) ); pBuf->wTransmitLength_a = cpu_to_le16(wLen); @@ -958,7 +958,7 @@ s_vFillRTSHead ( PSRTS_ab pBuf = (PSRTS_ab)pvRTS; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, - (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField) + (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField), (unsigned char *)&(pBuf->bySignalField) ); pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration @@ -987,7 +987,7 @@ s_vFillRTSHead ( PSRTS_a_FB pBuf = (PSRTS_a_FB)pvRTS; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, - (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField) + (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField), (unsigned char *)&(pBuf->bySignalField) ); pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration @@ -1017,7 +1017,7 @@ s_vFillRTSHead ( PSRTS_ab pBuf = (PSRTS_ab)pvRTS; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField), (PBYTE)&(pBuf->bySignalField) + (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField), (unsigned char *)&(pBuf->bySignalField) ); pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration @@ -1077,7 +1077,7 @@ s_vFillCTSHead ( PSCTS_FB pBuf = (PSCTS_FB)pvCTS; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, uCTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b) + (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_b), (unsigned char *)&(pBuf->bySignalField_b) ); @@ -1104,7 +1104,7 @@ s_vFillCTSHead ( PSCTS pBuf = (PSCTS)pvCTS; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, uCTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (PWORD)&(wLen), (PBYTE)&(pBuf->byServiceField_b), (PBYTE)&(pBuf->bySignalField_b) + (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_b), (unsigned char *)&(pBuf->bySignalField_b) ); pBuf->wTransmitLength_b = cpu_to_le16(wLen); //Get CTSDuration_ba @@ -1263,7 +1263,7 @@ s_vGenerateTxParameter ( //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_vGenerateTxParameter END.\n"); } /* - PBYTE pbyBuffer,//point to pTxBufHead + unsigned char *pbyBuffer,//point to pTxBufHead WORD wFragType,//00:Non-Frag, 01:Start, 02:Mid, 03:Last unsigned int cbFragmentSize,//Hdr+payoad+FCS */ @@ -1271,7 +1271,7 @@ static void s_vFillFragParameter( PSDevice pDevice, - PBYTE pbyBuffer, + unsigned char *pbyBuffer, unsigned int uTxType, void * pvtdCurr, WORD wFragType, @@ -1320,12 +1320,12 @@ unsigned int s_cbFillTxBufHead ( PSDevice pDevice, BYTE byPktType, - PBYTE pbyTxBufferAddr, + unsigned char *pbyTxBufferAddr, unsigned int cbFrameBodySize, unsigned int uDMAIdx, PSTxDesc pHeadTD, PSEthernetHeader psEthHeader, - PBYTE pPacket, + unsigned char *pPacket, BOOL bNeedEncrypt, PSKeyItem pTransmitKey, unsigned int uNodeIndex, @@ -1339,12 +1339,12 @@ s_cbFillTxBufHead ( unsigned int cbLastFragmentSize; //Hdr+(IV)+payoad+(MIC)+(ICV)+FCS unsigned int cbLastFragPayloadSize; unsigned int uFragIdx; - PBYTE pbyPayloadHead; - PBYTE pbyIVHead; - PBYTE pbyMacHdr; + unsigned char *pbyPayloadHead; + unsigned char *pbyIVHead; + unsigned char *pbyMacHdr; WORD wFragType; //00:Non-Frag, 01:Start, 10:Mid, 11:Last unsigned int uDuration; - PBYTE pbyBuffer; + unsigned char *pbyBuffer; // unsigned int uKeyEntryIdx = NUM_KEY_ENTRY+1; // BYTE byKeySel = 0xFF; unsigned int cbIVlen = 0; @@ -1371,7 +1371,7 @@ s_cbFillTxBufHead ( BOOL bNeedACK; BOOL bRTS; BOOL bIsAdhoc; - PBYTE pbyType; + unsigned char *pbyType; PSTxDesc ptdCurr; PSTxBufHead psTxBufHd = (PSTxBufHead) pbyTxBufferAddr; // unsigned int tmpDescIdx; @@ -1562,17 +1562,17 @@ s_cbFillTxBufHead ( } // DO Software Michael MIC_vInit(dwMICKey0, dwMICKey1); - MIC_vAppend((PBYTE)&(psEthHeader->abyDstAddr[0]), 12); + MIC_vAppend((unsigned char *)&(psEthHeader->abyDstAddr[0]), 12); dwMIC_Priority = 0; - MIC_vAppend((PBYTE)&dwMIC_Priority, 4); + MIC_vAppend((unsigned char *)&dwMIC_Priority, 4); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC KEY: %lX, %lX\n", dwMICKey0, dwMICKey1); } /////////////////////////////////////////////////////////////////// - pbyMacHdr = (PBYTE)(pbyTxBufferAddr + cbHeaderLength); - pbyPayloadHead = (PBYTE)(pbyMacHdr + cbMACHdLen + uPadding + cbIVlen); - pbyIVHead = (PBYTE)(pbyMacHdr + cbMACHdLen + uPadding); + pbyMacHdr = (unsigned char *)(pbyTxBufferAddr + cbHeaderLength); + pbyPayloadHead = (unsigned char *)(pbyMacHdr + cbMACHdLen + uPadding + cbIVlen); + pbyIVHead = (unsigned char *)(pbyMacHdr + cbMACHdLen + uPadding); if ((cbFrameSize > pDevice->wFragmentationThreshold) && (bNeedACK == TRUE) && (bIsWEP256 == FALSE)) { // Fragmentation @@ -1611,8 +1611,8 @@ s_cbFillTxBufHead ( if (bNeedEncrypt == TRUE) { //Fill TXKEY - s_vFillTxKey(pDevice, (PBYTE)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey, - pbyMacHdr, (WORD)cbFragPayloadSize, (PBYTE)pMICHDR); + s_vFillTxKey(pDevice, (unsigned char *)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey, + pbyMacHdr, (WORD)cbFragPayloadSize, (unsigned char *)pMICHDR); //Fill IV(ExtIV,RSNHDR) if (pDevice->bEnableHostWEP) { pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; @@ -1625,12 +1625,12 @@ s_cbFillTxBufHead ( if (ntohs(psEthHeader->wType) > ETH_DATA_LEN) { if ((psEthHeader->wType == TYPE_PKT_IPX) || (psEthHeader->wType == cpu_to_le16(0xF380))) { - memcpy((PBYTE) (pbyPayloadHead), &pDevice->abySNAP_Bridgetunnel[0], 6); + memcpy((unsigned char *) (pbyPayloadHead), &pDevice->abySNAP_Bridgetunnel[0], 6); } else { - memcpy((PBYTE) (pbyPayloadHead), &pDevice->abySNAP_RFC1042[0], 6); + memcpy((unsigned char *) (pbyPayloadHead), &pDevice->abySNAP_RFC1042[0], 6); } - pbyType = (PBYTE) (pbyPayloadHead + 6); + pbyType = (unsigned char *) (pbyPayloadHead + 6); memcpy(pbyType, &(psEthHeader->wType), sizeof(WORD)); cb802_1_H_len = 8; } @@ -1641,15 +1641,15 @@ s_cbFillTxBufHead ( //--------------------------- //Fill MICHDR //if (pDevice->bAES) { - // s_vFillMICHDR(pDevice, (PBYTE)pMICHDR, pbyMacHdr, (WORD)cbFragPayloadSize); + // s_vFillMICHDR(pDevice, (unsigned char *)pMICHDR, pbyMacHdr, (WORD)cbFragPayloadSize); //} //cbReqCount += s_uDoEncryption(pDevice, psEthHeader, (void *)psTxBufHd, byKeySel, // pbyPayloadHead, (WORD)cbFragPayloadSize, uDMAIdx); - //pbyBuffer = (PBYTE)pDevice->aamTxBuf[uDMAIdx][uDescIdx].pbyVAddr; - pbyBuffer = (PBYTE)pHeadTD->pTDInfo->buf; + //pbyBuffer = (unsigned char *)pDevice->aamTxBuf[uDMAIdx][uDescIdx].pbyVAddr; + pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf; uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cb802_1_H_len; //copy TxBufferHeader + MacHeader to desc @@ -1716,8 +1716,8 @@ s_cbFillTxBufHead ( if (bNeedEncrypt == TRUE) { //Fill TXKEY - s_vFillTxKey(pDevice, (PBYTE)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey, - pbyMacHdr, (WORD)cbLastFragPayloadSize, (PBYTE)pMICHDR); + s_vFillTxKey(pDevice, (unsigned char *)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey, + pbyMacHdr, (WORD)cbLastFragPayloadSize, (unsigned char *)pMICHDR); if (pDevice->bEnableHostWEP) { pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; @@ -1734,8 +1734,8 @@ s_cbFillTxBufHead ( - pbyBuffer = (PBYTE)pHeadTD->pTDInfo->buf; - //pbyBuffer = (PBYTE)pDevice->aamTxBuf[uDMAIdx][tmpDescIdx].pbyVAddr; + pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf; + //pbyBuffer = (unsigned char *)pDevice->aamTxBuf[uDMAIdx][tmpDescIdx].pbyVAddr; uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen; @@ -1766,23 +1766,23 @@ s_cbFillTxBufHead ( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Last MIC:%lX, %lX\n", *pdwMIC_L, *pdwMIC_R); } else { if (uMICFragLen >= 4) { - memcpy((pbyBuffer + uLength), ((PBYTE)&dwSafeMIC_R + (uMICFragLen - 4)), + memcpy((pbyBuffer + uLength), ((unsigned char *)&dwSafeMIC_R + (uMICFragLen - 4)), (cbMIClen - uMICFragLen)); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"LAST: uMICFragLen >= 4: %X, %d\n", - *(PBYTE)((PBYTE)&dwSafeMIC_R + (uMICFragLen - 4)), + *(unsigned char *)((unsigned char *)&dwSafeMIC_R + (uMICFragLen - 4)), (cbMIClen - uMICFragLen)); } else { - memcpy((pbyBuffer + uLength), ((PBYTE)&dwSafeMIC_L + uMICFragLen), + memcpy((pbyBuffer + uLength), ((unsigned char *)&dwSafeMIC_L + uMICFragLen), (4 - uMICFragLen)); memcpy((pbyBuffer + uLength + (4 - uMICFragLen)), &dwSafeMIC_R, 4); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"LAST: uMICFragLen < 4: %X, %d\n", - *(PBYTE)((PBYTE)&dwSafeMIC_R + uMICFragLen - 4), + *(unsigned char *)((unsigned char *)&dwSafeMIC_R + uMICFragLen - 4), (cbMIClen - uMICFragLen)); } /* for (ii = 0; ii < cbLastFragPayloadSize + 8 + 24; ii++) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *((PBYTE)((pbyBuffer + uLength) + ii - 8 - 24))); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *((unsigned char *)((pbyBuffer + uLength) + ii - 8 - 24))); } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n\n"); */ @@ -1847,8 +1847,8 @@ s_cbFillTxBufHead ( if (bNeedEncrypt == TRUE) { //Fill TXKEY - s_vFillTxKey(pDevice, (PBYTE)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey, - pbyMacHdr, (WORD)cbFragPayloadSize, (PBYTE)pMICHDR); + s_vFillTxKey(pDevice, (unsigned char *)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey, + pbyMacHdr, (WORD)cbFragPayloadSize, (unsigned char *)pMICHDR); if (pDevice->bEnableHostWEP) { pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; @@ -1862,14 +1862,14 @@ s_cbFillTxBufHead ( //--------------------------- //Fill MICHDR //if (pDevice->bAES) { - // s_vFillMICHDR(pDevice, (PBYTE)pMICHDR, pbyMacHdr, (WORD)cbFragPayloadSize); + // s_vFillMICHDR(pDevice, (unsigned char *)pMICHDR, pbyMacHdr, (WORD)cbFragPayloadSize); //} //cbReqCount += s_uDoEncryption(pDevice, psEthHeader, (void *)psTxBufHd, byKeySel, // pbyPayloadHead, (WORD)cbFragPayloadSize, uDMAIdx); - pbyBuffer = (PBYTE)pHeadTD->pTDInfo->buf; - //pbyBuffer = (PBYTE)pDevice->aamTxBuf[uDMAIdx][tmpDescIdx].pbyVAddr; + pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf; + //pbyBuffer = (unsigned char *)pDevice->aamTxBuf[uDMAIdx][tmpDescIdx].pbyVAddr; uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen; @@ -1906,7 +1906,7 @@ s_cbFillTxBufHead ( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Fill MIC in Middle frag [%d]\n", uMICFragLen); /* for (ii = 0; ii < uMICFragLen; ii++) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *((PBYTE)((pbyBuffer + uLength + uTmpLen) + ii))); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *((unsigned char *)((pbyBuffer + uLength + uTmpLen) + ii))); } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); */ @@ -1915,7 +1915,7 @@ s_cbFillTxBufHead ( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Middle frag len: %d\n", uTmpLen); /* for (ii = 0; ii < uTmpLen; ii++) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *((PBYTE)((pbyBuffer + uLength) + ii))); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *((unsigned char *)((pbyBuffer + uLength) + ii))); } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n\n"); */ @@ -1976,8 +1976,8 @@ s_cbFillTxBufHead ( if (bNeedEncrypt == TRUE) { //Fill TXKEY - s_vFillTxKey(pDevice, (PBYTE)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey, - pbyMacHdr, (WORD)cbFrameBodySize, (PBYTE)pMICHDR); + s_vFillTxKey(pDevice, (unsigned char *)(psTxBufHd->adwTxKey), pbyIVHead, pTransmitKey, + pbyMacHdr, (WORD)cbFrameBodySize, (unsigned char *)pMICHDR); if (pDevice->bEnableHostWEP) { pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; @@ -1989,12 +1989,12 @@ s_cbFillTxBufHead ( if (ntohs(psEthHeader->wType) > ETH_DATA_LEN) { if ((psEthHeader->wType == TYPE_PKT_IPX) || (psEthHeader->wType == cpu_to_le16(0xF380))) { - memcpy((PBYTE) (pbyPayloadHead), &pDevice->abySNAP_Bridgetunnel[0], 6); + memcpy((unsigned char *) (pbyPayloadHead), &pDevice->abySNAP_Bridgetunnel[0], 6); } else { - memcpy((PBYTE) (pbyPayloadHead), &pDevice->abySNAP_RFC1042[0], 6); + memcpy((unsigned char *) (pbyPayloadHead), &pDevice->abySNAP_RFC1042[0], 6); } - pbyType = (PBYTE) (pbyPayloadHead + 6); + pbyType = (unsigned char *) (pbyPayloadHead + 6); memcpy(pbyType, &(psEthHeader->wType), sizeof(WORD)); cb802_1_H_len = 8; } @@ -2006,11 +2006,11 @@ s_cbFillTxBufHead ( //Fill MICHDR //if (pDevice->bAES) { // DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Fill MICHDR...\n"); - // s_vFillMICHDR(pDevice, (PBYTE)pMICHDR, pbyMacHdr, (WORD)cbFrameBodySize); + // s_vFillMICHDR(pDevice, (unsigned char *)pMICHDR, pbyMacHdr, (WORD)cbFrameBodySize); //} - pbyBuffer = (PBYTE)pHeadTD->pTDInfo->buf; - //pbyBuffer = (PBYTE)pDevice->aamTxBuf[uDMAIdx][uDescIdx].pbyVAddr; + pbyBuffer = (unsigned char *)pHeadTD->pTDInfo->buf; + //pbyBuffer = (unsigned char *)pDevice->aamTxBuf[uDMAIdx][uDescIdx].pbyVAddr; uLength = cbHeaderLength + cbMACHdLen + uPadding + cbIVlen + cb802_1_H_len; @@ -2028,7 +2028,7 @@ s_cbFillTxBufHead ( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Length:%d, %d\n", cbFrameBodySize - cb802_1_H_len, uLength); /* for (ii = 0; ii < (cbFrameBodySize - cb802_1_H_len); ii++) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *((PBYTE)((pbyBuffer + uLength) + ii))); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *((unsigned char *)((pbyBuffer + uLength) + ii))); } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); */ @@ -2053,7 +2053,7 @@ s_cbFillTxBufHead ( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC:%lx, %lx\n", *pdwMIC_L, *pdwMIC_R); /* for (ii = 0; ii < 8; ii++) { - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *(((PBYTE)(pdwMIC_L) + ii))); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"%02x ", *(((unsigned char *)(pdwMIC_L) + ii))); } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"\n"); */ @@ -2097,13 +2097,13 @@ void vGenerateFIFOHeader ( PSDevice pDevice, BYTE byPktType, - PBYTE pbyTxBufferAddr, + unsigned char *pbyTxBufferAddr, BOOL bNeedEncrypt, unsigned int cbPayloadSize, unsigned int uDMAIdx, PSTxDesc pHeadTD, PSEthernetHeader psEthHeader, - PBYTE pPacket, + unsigned char *pPacket, PSKeyItem pTransmitKey, unsigned int uNodeIndex, PUINT puMACfragNum, @@ -2267,7 +2267,7 @@ vGenerateFIFOHeader ( void vGenerateMACHeader ( PSDevice pDevice, - PBYTE pbyBufferAddr, + unsigned char *pbyBufferAddr, WORD wDuration, PSEthernetHeader psEthHeader, BOOL bNeedEncrypt, @@ -2341,7 +2341,7 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { PSTxDesc pFrstTD; BYTE byPktType; - PBYTE pbyTxBufferAddr; + unsigned char *pbyTxBufferAddr; void * pvRTS; PSCTS pCTS; void * pvTxDataHd; @@ -2373,7 +2373,7 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { } pFrstTD = pDevice->apCurrTD[TYPE_TXDMA0]; - pbyTxBufferAddr = (PBYTE)pFrstTD->pTDInfo->buf; + pbyTxBufferAddr = (unsigned char *)pFrstTD->pTDInfo->buf; cbFrameBodySize = pPacket->cbPayloadLen; pTxBufHead = (PSTxBufHead) pbyTxBufferAddr; wTxBufSize = sizeof(STxBufHead); @@ -2539,17 +2539,17 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + cbFrameBodySize; if (WLAN_GET_FC_ISWEP(pPacket->p80211Header->sA4.wFrameCtl) != 0) { - PBYTE pbyIVHead; - PBYTE pbyPayloadHead; - PBYTE pbyBSSID; + unsigned char *pbyIVHead; + unsigned char *pbyPayloadHead; + unsigned char *pbyBSSID; PSKeyItem pTransmitKey = NULL; - pbyIVHead = (PBYTE)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding); - pbyPayloadHead = (PBYTE)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding + cbIVlen); + pbyIVHead = (unsigned char *)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding); + pbyPayloadHead = (unsigned char *)(pbyTxBufferAddr + cbHeaderSize + cbMacHdLen + uPadding + cbIVlen); //Fill TXKEY //Kyle: Need fix: TKIP and AES did't encryt Mnt Packet. - //s_vFillTxKey(pDevice, (PBYTE)pTxBufHead->adwTxKey, NULL); + //s_vFillTxKey(pDevice, (unsigned char *)pTxBufHead->adwTxKey, NULL); //Fill IV(ExtIV,RSNHDR) //s_vFillPrePayload(pDevice, pbyIVHead, NULL); @@ -2558,7 +2558,7 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { //--------------------------- //Fill MICHDR //if (pDevice->bAES) { - // s_vFillMICHDR(pDevice, (PBYTE)pMICHDR, (PBYTE)pMACHeader, (WORD)cbFrameBodySize); + // s_vFillMICHDR(pDevice, (unsigned char *)pMICHDR, (unsigned char *)pMACHeader, (WORD)cbFrameBodySize); //} do { if ((pDevice->eOPMode == OP_MODE_INFRASTRUCTURE) && @@ -2586,11 +2586,11 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { } } while(FALSE); //Fill TXKEY - s_vFillTxKey(pDevice, (PBYTE)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey, - (PBYTE)pMACHeader, (WORD)cbFrameBodySize, NULL); + s_vFillTxKey(pDevice, (unsigned char *)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey, + (unsigned char *)pMACHeader, (WORD)cbFrameBodySize, NULL); memcpy(pMACHeader, pPacket->p80211Header, cbMacHdLen); - memcpy(pbyPayloadHead, ((PBYTE)(pPacket->p80211Header) + cbMacHdLen), + memcpy(pbyPayloadHead, ((unsigned char *)(pPacket->p80211Header) + cbMacHdLen), cbFrameBodySize); } else { @@ -2662,7 +2662,7 @@ CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { CMD_STATUS csBeacon_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { BYTE byPktType; - PBYTE pbyBuffer = (PBYTE)pDevice->tx_beacon_bufs; + unsigned char *pbyBuffer = (unsigned char *)pDevice->tx_beacon_bufs; unsigned int cbFrameSize = pPacket->cbMPDULen + WLAN_FCS_LEN; unsigned int cbHeaderSize = 0; WORD wTxBufSize = sizeof(STxShortBufHead); @@ -2703,7 +2703,7 @@ CMD_STATUS csBeacon_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { } BBvCaculateParameter(pDevice, cbFrameSize, wCurrentRate, byPktType, - (PWORD)&(wLen), (PBYTE)&(pTxDataHead->byServiceField), (PBYTE)&(pTxDataHead->bySignalField) + (PWORD)&(wLen), (unsigned char *)&(pTxDataHead->byServiceField), (unsigned char *)&(pTxDataHead->bySignalField) ); pTxDataHead->wTransmitLength = cpu_to_le16(wLen); //Get TimeStampOff @@ -2826,11 +2826,11 @@ cbGetFragCount ( void -vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, unsigned int cbMPDULen) { +vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, unsigned char *pbMPDU, unsigned int cbMPDULen) { PSTxDesc pFrstTD; BYTE byPktType; - PBYTE pbyTxBufferAddr; + unsigned char *pbyTxBufferAddr; void * pvRTS; void * pvCTS; void * pvTxDataHd; @@ -2866,9 +2866,9 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, unsigned in BOOL bNodeExist = FALSE; SKeyItem STempKey; PSKeyItem pTransmitKey = NULL; - PBYTE pbyIVHead; - PBYTE pbyPayloadHead; - PBYTE pbyMacHdr; + unsigned char *pbyIVHead; + unsigned char *pbyPayloadHead; + unsigned char *pbyMacHdr; unsigned int cbExtSuppRate = 0; // PWLAN_IE pItem; @@ -2886,7 +2886,7 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, unsigned in pFrstTD = pDevice->apCurrTD[TYPE_TXDMA0]; - pbyTxBufferAddr = (PBYTE)pFrstTD->pTDInfo->buf; + pbyTxBufferAddr = (unsigned char *)pFrstTD->pTDInfo->buf; pTxBufHead = (PSTxBufHead) pbyTxBufferAddr; wTxBufSize = sizeof(STxBufHead); memset(pTxBufHead, 0, wTxBufSize); @@ -2948,7 +2948,7 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, unsigned in } else { if (pDevice->bEnableHostWEP) { - if (BSSDBbIsSTAInNodeDB(pDevice->pMgmt, (PBYTE)(p80211Header->sA3.abyAddr1), &uNodeIndex)) + if (BSSDBbIsSTAInNodeDB(pDevice->pMgmt, (unsigned char *)(p80211Header->sA3.abyAddr1), &uNodeIndex)) bNodeExist = TRUE; }; bNeedACK = TRUE; @@ -3082,9 +3082,9 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, unsigned in cbReqCount = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen + (cbFrameBodySize + cbMIClen) + cbExtSuppRate; - pbyMacHdr = (PBYTE)(pbyTxBufferAddr + cbHeaderSize); - pbyPayloadHead = (PBYTE)(pbyMacHdr + cbMacHdLen + uPadding + cbIVlen); - pbyIVHead = (PBYTE)(pbyMacHdr + cbMacHdLen + uPadding); + pbyMacHdr = (unsigned char *)(pbyTxBufferAddr + cbHeaderSize); + pbyPayloadHead = (unsigned char *)(pbyMacHdr + cbMacHdLen + uPadding + cbIVlen); + pbyIVHead = (unsigned char *)(pbyMacHdr + cbMacHdLen + uPadding); // Copy the Packet into a tx Buffer memcpy(pbyMacHdr, pbMPDU, cbMacHdLen); @@ -3132,9 +3132,9 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, unsigned in // DO Software Michael MIC_vInit(dwMICKey0, dwMICKey1); - MIC_vAppend((PBYTE)&(sEthHeader.abyDstAddr[0]), 12); + MIC_vAppend((unsigned char *)&(sEthHeader.abyDstAddr[0]), 12); dwMIC_Priority = 0; - MIC_vAppend((PBYTE)&dwMIC_Priority, 4); + MIC_vAppend((unsigned char *)&dwMIC_Priority, 4); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"DMA0_tx_8021:MIC KEY: %lX, %lX\n", dwMICKey0, dwMICKey1); uLength = cbHeaderSize + cbMacHdLen + uPadding + cbIVlen; @@ -3160,8 +3160,8 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, unsigned in } - s_vFillTxKey(pDevice, (PBYTE)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey, - pbyMacHdr, (WORD)cbFrameBodySize, (PBYTE)pMICHDR); + s_vFillTxKey(pDevice, (unsigned char *)(pTxBufHead->adwTxKey), pbyIVHead, pTransmitKey, + pbyMacHdr, (WORD)cbFrameBodySize, (unsigned char *)pMICHDR); if (pDevice->bEnableHostWEP) { pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16 = pTransmitKey->dwTSC47_16; diff --git a/drivers/staging/vt6655/rxtx.h b/drivers/staging/vt6655/rxtx.h index e2754071317e..1e5e31f77ca0 100644 --- a/drivers/staging/vt6655/rxtx.h +++ b/drivers/staging/vt6655/rxtx.h @@ -43,7 +43,7 @@ void vGenerateMACHeader( PSDevice pDevice, DWORD dwTxBufferAddr, - PBYTE pbySkbData, + unsigned char *pbySkbData, unsigned int cbPacketSize, BOOL bDMA0Used, PUINT pcbHeadSize, @@ -63,7 +63,7 @@ void vProcessRxMACHeader ( void vGenerateMACHeader ( PSDevice pDevice, - PBYTE pbyBufferAddr, + unsigned char *pbyBufferAddr, WORD wDuration, PSEthernetHeader psEthHeader, BOOL bNeedEncrypt, @@ -86,13 +86,13 @@ void vGenerateFIFOHeader ( PSDevice pDevice, BYTE byPktTyp, - PBYTE pbyTxBufferAddr, + unsigned char *pbyTxBufferAddr, BOOL bNeedEncrypt, unsigned int cbPayloadSize, unsigned int uDMAIdx, PSTxDesc pHeadTD, PSEthernetHeader psEthHeader, - PBYTE pPacket, + unsigned char *pPacket, PSKeyItem pTransmitKey, unsigned int uNodeIndex, PUINT puMACfragNum, @@ -100,7 +100,7 @@ vGenerateFIFOHeader ( ); -void vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, PBYTE pbMPDU, unsigned int cbMPDULen); +void vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, unsigned char *pbMPDU, unsigned int cbMPDULen); CMD_STATUS csMgmt_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket); CMD_STATUS csBeacon_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket); diff --git a/drivers/staging/vt6655/srom.c b/drivers/staging/vt6655/srom.c index 418575fdc2c0..cd4895ea45f6 100644 --- a/drivers/staging/vt6655/srom.c +++ b/drivers/staging/vt6655/srom.c @@ -266,7 +266,7 @@ BOOL SROMbIsRegBitsOff(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byTestBits) * Return Value: none * */ -void SROMvReadAllContents(DWORD_PTR dwIoBase, PBYTE pbyEepromRegs) +void SROMvReadAllContents(DWORD_PTR dwIoBase, unsigned char *pbyEepromRegs) { int ii; @@ -291,7 +291,7 @@ void SROMvReadAllContents(DWORD_PTR dwIoBase, PBYTE pbyEepromRegs) * Return Value: none * */ -void SROMvWriteAllContents(DWORD_PTR dwIoBase, PBYTE pbyEepromRegs) +void SROMvWriteAllContents(DWORD_PTR dwIoBase, unsigned char *pbyEepromRegs) { int ii; @@ -315,7 +315,7 @@ void SROMvWriteAllContents(DWORD_PTR dwIoBase, PBYTE pbyEepromRegs) * Return Value: none * */ -void SROMvReadEtherAddress(DWORD_PTR dwIoBase, PBYTE pbyEtherAddress) +void SROMvReadEtherAddress(DWORD_PTR dwIoBase, unsigned char *pbyEtherAddress) { BYTE ii; @@ -340,7 +340,7 @@ void SROMvReadEtherAddress(DWORD_PTR dwIoBase, PBYTE pbyEtherAddress) * Return Value: none * */ -void SROMvWriteEtherAddress(DWORD_PTR dwIoBase, PBYTE pbyEtherAddress) +void SROMvWriteEtherAddress(DWORD_PTR dwIoBase, unsigned char *pbyEtherAddress) { BYTE ii; @@ -366,9 +366,9 @@ void SROMvWriteEtherAddress(DWORD_PTR dwIoBase, PBYTE pbyEtherAddress) */ void SROMvReadSubSysVenId(DWORD_PTR dwIoBase, PDWORD pdwSubSysVenId) { - PBYTE pbyData; + unsigned char *pbyData; - pbyData = (PBYTE)pdwSubSysVenId; + pbyData = (unsigned char *)pdwSubSysVenId; /* sub vendor */ *pbyData = SROMbyReadEmbedded(dwIoBase, 6); *(pbyData+1) = SROMbyReadEmbedded(dwIoBase, 7); diff --git a/drivers/staging/vt6655/srom.h b/drivers/staging/vt6655/srom.h index dbb3f5efe979..d51791491751 100644 --- a/drivers/staging/vt6655/srom.h +++ b/drivers/staging/vt6655/srom.h @@ -144,11 +144,11 @@ void SROMvRegBitsOff(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byBits); BOOL SROMbIsRegBitsOn(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byTestBits); BOOL SROMbIsRegBitsOff(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byTestBits); -void SROMvReadAllContents(DWORD_PTR dwIoBase, PBYTE pbyEepromRegs); -void SROMvWriteAllContents(DWORD_PTR dwIoBase, PBYTE pbyEepromRegs); +void SROMvReadAllContents(DWORD_PTR dwIoBase, unsigned char *pbyEepromRegs); +void SROMvWriteAllContents(DWORD_PTR dwIoBase, unsigned char *pbyEepromRegs); -void SROMvReadEtherAddress(DWORD_PTR dwIoBase, PBYTE pbyEtherAddress); -void SROMvWriteEtherAddress(DWORD_PTR dwIoBase, PBYTE pbyEtherAddress); +void SROMvReadEtherAddress(DWORD_PTR dwIoBase, unsigned char *pbyEtherAddress); +void SROMvWriteEtherAddress(DWORD_PTR dwIoBase, unsigned char *pbyEtherAddress); void SROMvReadSubSysVenId(DWORD_PTR dwIoBase, PDWORD pdwSubSysVenId); diff --git a/drivers/staging/vt6655/tcrc.c b/drivers/staging/vt6655/tcrc.c index d13e8e1ccd96..d48777a8e4b6 100644 --- a/drivers/staging/vt6655/tcrc.c +++ b/drivers/staging/vt6655/tcrc.c @@ -132,7 +132,7 @@ static const DWORD s_adwCrc32Table[256] = { * Return Value: CRC-32 * -*/ -DWORD CRCdwCrc32 (PBYTE pbyData, unsigned int cbByte, DWORD dwCrcSeed) +DWORD CRCdwCrc32 (unsigned char *pbyData, unsigned int cbByte, DWORD dwCrcSeed) { DWORD dwCrc; @@ -164,7 +164,7 @@ DWORD CRCdwCrc32 (PBYTE pbyData, unsigned int cbByte, DWORD dwCrcSeed) * Return Value: CRC-32 * -*/ -DWORD CRCdwGetCrc32 (PBYTE pbyData, unsigned int cbByte) +DWORD CRCdwGetCrc32 (unsigned char *pbyData, unsigned int cbByte) { return ~CRCdwCrc32(pbyData, cbByte, 0xFFFFFFFFL); } @@ -190,7 +190,7 @@ DWORD CRCdwGetCrc32 (PBYTE pbyData, unsigned int cbByte) * Return Value: CRC-32 * -*/ -DWORD CRCdwGetCrc32Ex(PBYTE pbyData, unsigned int cbByte, DWORD dwPreCRC) +DWORD CRCdwGetCrc32Ex(unsigned char *pbyData, unsigned int cbByte, DWORD dwPreCRC) { return CRCdwCrc32(pbyData, cbByte, dwPreCRC); } diff --git a/drivers/staging/vt6655/tcrc.h b/drivers/staging/vt6655/tcrc.h index 17581b2d6a0c..7d5cd89ed432 100644 --- a/drivers/staging/vt6655/tcrc.h +++ b/drivers/staging/vt6655/tcrc.h @@ -43,9 +43,9 @@ /*--------------------- Export Functions --------------------------*/ -DWORD CRCdwCrc32(PBYTE pbyData, unsigned int cbByte, DWORD dwCrcSeed); -DWORD CRCdwGetCrc32(PBYTE pbyData, unsigned int cbByte); -DWORD CRCdwGetCrc32Ex(PBYTE pbyData, unsigned int cbByte, DWORD dwPreCRC); +DWORD CRCdwCrc32(unsigned char *pbyData, unsigned int cbByte, DWORD dwCrcSeed); +DWORD CRCdwGetCrc32(unsigned char *pbyData, unsigned int cbByte); +DWORD CRCdwGetCrc32Ex(unsigned char *pbyData, unsigned int cbByte, DWORD dwPreCRC); #endif // __TCRC_H__ diff --git a/drivers/staging/vt6655/tether.c b/drivers/staging/vt6655/tether.c index 150647db1529..baf373931b6c 100644 --- a/drivers/staging/vt6655/tether.c +++ b/drivers/staging/vt6655/tether.c @@ -61,7 +61,7 @@ * Return Value: Hash value * */ -BYTE ETHbyGetHashIndexByCrc32 (PBYTE pbyMultiAddr) +BYTE ETHbyGetHashIndexByCrc32 (unsigned char *pbyMultiAddr) { int ii; BYTE byTmpHash; @@ -96,7 +96,7 @@ BYTE ETHbyGetHashIndexByCrc32 (PBYTE pbyMultiAddr) * Return Value: TRUE if ok; FALSE if error. * */ -BOOL ETHbIsBufferCrc32Ok (PBYTE pbyBuffer, unsigned int cbFrameLength) +BOOL ETHbIsBufferCrc32Ok (unsigned char *pbyBuffer, unsigned int cbFrameLength) { DWORD dwCRC; diff --git a/drivers/staging/vt6655/tether.h b/drivers/staging/vt6655/tether.h index 4a9d20287d7c..5d90cd8da8af 100644 --- a/drivers/staging/vt6655/tether.h +++ b/drivers/staging/vt6655/tether.h @@ -193,9 +193,9 @@ S802_11Header, *PS802_11Header; /*--------------------- Export Functions --------------------------*/ -BYTE ETHbyGetHashIndexByCrc32(PBYTE pbyMultiAddr); -//BYTE ETHbyGetHashIndexByCrc(PBYTE pbyMultiAddr); -BOOL ETHbIsBufferCrc32Ok(PBYTE pbyBuffer, unsigned int cbFrameLength); +BYTE ETHbyGetHashIndexByCrc32(unsigned char *pbyMultiAddr); +//BYTE ETHbyGetHashIndexByCrc(unsigned char *pbyMultiAddr); +BOOL ETHbIsBufferCrc32Ok(unsigned char *pbyBuffer, unsigned int cbFrameLength); #endif // __TETHER_H__ diff --git a/drivers/staging/vt6655/tkip.c b/drivers/staging/vt6655/tkip.c index f83af5913aa6..569c911193c2 100644 --- a/drivers/staging/vt6655/tkip.c +++ b/drivers/staging/vt6655/tkip.c @@ -184,11 +184,11 @@ unsigned int rotr1(unsigned int a) * */ void TKIPvMixKey( - PBYTE pbyTKey, - PBYTE pbyTA, + unsigned char *pbyTKey, + unsigned char *pbyTA, WORD wTSC15_0, DWORD dwTSC47_16, - PBYTE pbyRC4Key + unsigned char *pbyRC4Key ) { unsigned int p1k[5]; diff --git a/drivers/staging/vt6655/tkip.h b/drivers/staging/vt6655/tkip.h index 3dfa7f5ee7ec..cdadf66746f7 100644 --- a/drivers/staging/vt6655/tkip.h +++ b/drivers/staging/vt6655/tkip.h @@ -47,11 +47,11 @@ /*--------------------- Export Functions --------------------------*/ void TKIPvMixKey( - PBYTE pbyTKey, - PBYTE pbyTA, + unsigned char *pbyTKey, + unsigned char *pbyTA, WORD wTSC15_0, DWORD dwTSC47_16, - PBYTE pbyRC4Key + unsigned char *pbyRC4Key ); #endif // __TKIP_H__ diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h index f97a3eeed9a1..6fe184fb77d6 100644 --- a/drivers/staging/vt6655/ttype.h +++ b/drivers/staging/vt6655/ttype.h @@ -92,8 +92,6 @@ typedef unsigned long DWORD_PTR; // 32-bit // boolean pointer typedef unsigned int * PUINT; -typedef BYTE * PBYTE; - typedef WORD * PWORD; typedef DWORD * PDWORD; diff --git a/drivers/staging/vt6655/upc.h b/drivers/staging/vt6655/upc.h index 78a950cbf00d..c12d028d5ec1 100644 --- a/drivers/staging/vt6655/upc.h +++ b/drivers/staging/vt6655/upc.h @@ -76,7 +76,7 @@ #define VNSvInPortB(dwIOAddress, pbyData) { \ - volatile BYTE* pbyAddr = ((PBYTE)(dwIOAddress)); \ + volatile BYTE* pbyAddr = ((unsigned char *)(dwIOAddress)); \ *(pbyData) = readb(pbyAddr); \ } @@ -93,7 +93,7 @@ #define VNSvOutPortB(dwIOAddress, byData) { \ - volatile BYTE* pbyAddr = ((PBYTE)(dwIOAddress)); \ + volatile BYTE* pbyAddr = ((unsigned char *)(dwIOAddress)); \ writeb((BYTE)byData, pbyAddr); \ } diff --git a/drivers/staging/vt6655/vntwifi.c b/drivers/staging/vt6655/vntwifi.c index 22069057ac0a..88c0ad420a41 100644 --- a/drivers/staging/vt6655/vntwifi.c +++ b/drivers/staging/vt6655/vntwifi.c @@ -497,10 +497,10 @@ VNTWIFIvGetNextBSS ( void VNTWIFIvUpdateNodeTxCounter( void *pMgmtHandle, - PBYTE pbyDestAddress, + unsigned char *pbyDestAddress, BOOL bTxOk, WORD wRate, - PBYTE pbyTxFailCount + unsigned char *pbyTxFailCount ) { PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; @@ -532,11 +532,11 @@ VNTWIFIvUpdateNodeTxCounter( void VNTWIFIvGetTxRate( void *pMgmtHandle, - PBYTE pbyDestAddress, + unsigned char *pbyDestAddress, PWORD pwTxDataRate, - PBYTE pbyACKRate, - PBYTE pbyCCKBasicRate, - PBYTE pbyOFDMBasicRate + unsigned char *pbyACKRate, + unsigned char *pbyCCKBasicRate, + unsigned char *pbyOFDMBasicRate ) { PSMgmtObject pMgmt = (PSMgmtObject)pMgmtHandle; @@ -721,11 +721,11 @@ VNTWIFIbMeasureReport( BYTE byReportMode, BYTE byBasicMap, BYTE byCCAFraction, - PBYTE pbyRPIs + unsigned char *pbyRPIs ) { PSMgmtObject pMgmt = (PSMgmtObject) pMgmtObject; - PBYTE pbyCurrentEID = (PBYTE) (pMgmt->pCurrMeasureEIDRep); + unsigned char *pbyCurrentEID = (unsigned char *) (pMgmt->pCurrMeasureEIDRep); //spin_lock_irq(&pDevice->lock); if ((pvMeasureEID != NULL) && diff --git a/drivers/staging/vt6655/vntwifi.h b/drivers/staging/vt6655/vntwifi.h index fc1a4f152491..6d14161e6de4 100644 --- a/drivers/staging/vt6655/vntwifi.h +++ b/drivers/staging/vt6655/vntwifi.h @@ -229,21 +229,21 @@ VNTWIFIvGetNextBSS ( void VNTWIFIvUpdateNodeTxCounter( void *pMgmtHandle, - PBYTE pbyDestAddress, + unsigned char *pbyDestAddress, BOOL bTxOk, WORD wRate, - PBYTE pbyTxFailCount + unsigned char *pbyTxFailCount ); void VNTWIFIvGetTxRate( void *pMgmtHandle, - PBYTE pbyDestAddress, + unsigned char *pbyDestAddress, PWORD pwTxDataRate, - PBYTE pbyACKRate, - PBYTE pbyCCKBasicRate, - PBYTE pbyOFDMBasicRate + unsigned char *pbyACKRate, + unsigned char *pbyCCKBasicRate, + unsigned char *pbyOFDMBasicRate ); /* BOOL @@ -294,7 +294,7 @@ VNTWIFIbMeasureReport( BYTE byReportMode, BYTE byBasicMap, BYTE byCCAFraction, - PBYTE pbyRPIs + unsigned char *pbyRPIs ); BOOL diff --git a/drivers/staging/vt6655/wcmd.c b/drivers/staging/vt6655/wcmd.c index 9aae07709e34..4e7b457cb9a9 100644 --- a/drivers/staging/vt6655/wcmd.c +++ b/drivers/staging/vt6655/wcmd.c @@ -77,7 +77,7 @@ PSTxMgmtPacket s_MgrMakeProbeRequest( PSDevice pDevice, PSMgmtObject pMgmt, - PBYTE pScanBSSID, + unsigned char *pScanBSSID, PWLAN_IE_SSID pSSID, PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates @@ -213,7 +213,7 @@ s_vProbeChannel( //6M, 9M, 12M, 48M BYTE abyCurrSuppRatesA[] = {WLAN_EID_SUPP_RATES, 8, 0x0C, 0x12, 0x18, 0x24, 0x30, 0x48, 0x60, 0x6C}; BYTE abyCurrSuppRatesB[] = {WLAN_EID_SUPP_RATES, 4, 0x02, 0x04, 0x0B, 0x16}; - PBYTE pbyRate; + unsigned char *pbyRate; PSTxMgmtPacket pTxPacket; PSMgmtObject pMgmt = pDevice->pMgmt; unsigned int ii; @@ -269,7 +269,7 @@ PSTxMgmtPacket s_MgrMakeProbeRequest( PSDevice pDevice, PSMgmtObject pMgmt, - PBYTE pScanBSSID, + unsigned char *pScanBSSID, PWLAN_IE_SSID pSSID, PWLAN_IE_SUPP_RATES pCurrRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates @@ -282,8 +282,8 @@ s_MgrMakeProbeRequest( pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_PROBEREQ_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); - sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); + sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; sFrame.len = WLAN_PROBEREQ_FR_MAXLEN; vMgrEncodeProbeRequest(&sFrame); sFrame.pHdr->sA3.wFrameCtl = cpu_to_le16( @@ -982,7 +982,7 @@ s_bCommandComplete ( BOOL bScheduleCommand ( void *hDeviceContext, CMD_CODE eCommand, - PBYTE pbyItem0 + unsigned char *pbyItem0 ) { PSDevice pDevice = (PSDevice)hDeviceContext; diff --git a/drivers/staging/vt6655/wcmd.h b/drivers/staging/vt6655/wcmd.h index 0063b9945504..3eb5d75c6b55 100644 --- a/drivers/staging/vt6655/wcmd.h +++ b/drivers/staging/vt6655/wcmd.h @@ -127,7 +127,7 @@ BOOL bScheduleCommand( void *hDeviceContext, CMD_CODE eCommand, - PBYTE pbyItem0 + unsigned char *pbyItem0 ); void diff --git a/drivers/staging/vt6655/wctl.c b/drivers/staging/vt6655/wctl.c index 3e0d0eba73f9..8a37b769e8ae 100644 --- a/drivers/staging/vt6655/wctl.c +++ b/drivers/staging/vt6655/wctl.c @@ -205,7 +205,7 @@ unsigned int uHeaderSize; } } // reserve 4 byte to match MAC RX Buffer - pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer = (PBYTE) (pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].skb->data + 4); + pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer = (unsigned char *) (pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].skb->data + 4); memcpy(pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer, pMACHeader, cbFrameLength); pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength = cbFrameLength; pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer += cbFrameLength; @@ -220,7 +220,7 @@ unsigned int uHeaderSize; (pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum == (pMACHeader->wSeqCtl & 0x000F)) && ((pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength + cbFrameLength - uHeaderSize) < 2346)) { - memcpy(pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer, ((PBYTE) (pMACHeader) + uHeaderSize), (cbFrameLength - uHeaderSize)); + memcpy(pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer, ((unsigned char *) (pMACHeader) + uHeaderSize), (cbFrameLength - uHeaderSize)); pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].cbFrameLength += (cbFrameLength - uHeaderSize); pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].pbyRxBuffer += (cbFrameLength - uHeaderSize); pDevice->sRxDFCB[pDevice->uCurrentDFCBIdx].wFragNum++; diff --git a/drivers/staging/vt6655/wmgr.c b/drivers/staging/vt6655/wmgr.c index 41f520afea11..3994ed21d4fa 100644 --- a/drivers/staging/vt6655/wmgr.c +++ b/drivers/staging/vt6655/wmgr.c @@ -104,7 +104,7 @@ PSTxMgmtPacket s_MgrMakeAssocRequest( PSDevice pDevice, PSMgmtObject pMgmt, - PBYTE pDAddr, + unsigned char *pDAddr, WORD wCurrCapInfo, WORD wListenInterval, PWLAN_IE_SSID pCurrSSID, @@ -126,7 +126,7 @@ PSTxMgmtPacket s_MgrMakeReAssocRequest( PSDevice pDevice, PSMgmtObject pMgmt, - PBYTE pDAddr, + unsigned char *pDAddr, WORD wCurrCapInfo, WORD wListenInterval, PWLAN_IE_SSID pCurrSSID, @@ -245,7 +245,7 @@ s_MgrMakeBeacon( unsigned int uCurrChannel, WORD wCurrATIMWinodw, PWLAN_IE_SSID pCurrSSID, - PBYTE pCurrBSSID, + unsigned char *pCurrBSSID, PWLAN_IE_SUPP_RATES pCurrSuppRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates ); @@ -260,7 +260,7 @@ s_MgrMakeAssocResponse( WORD wCurrCapInfo, WORD wAssocStatus, WORD wAssocAID, - PBYTE pDstAddr, + unsigned char *pDstAddr, PWLAN_IE_SUPP_RATES pCurrSuppRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates ); @@ -274,7 +274,7 @@ s_MgrMakeReAssocResponse( WORD wCurrCapInfo, WORD wAssocStatus, WORD wAssocAID, - PBYTE pDstAddr, + unsigned char *pDstAddr, PWLAN_IE_SUPP_RATES pCurrSuppRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates ); @@ -289,9 +289,9 @@ s_MgrMakeProbeResponse( WORD wCurrBeaconPeriod, unsigned int uCurrChannel, WORD wCurrATIMWinodw, - PBYTE pDstAddr, + unsigned char *pDstAddr, PWLAN_IE_SSID pCurrSSID, - PBYTE pCurrBSSID, + unsigned char *pCurrBSSID, PWLAN_IE_SUPP_RATES pCurrSuppRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates, BYTE byPHYType @@ -320,8 +320,8 @@ static BOOL s_bCipherMatch ( PKnownBSS pBSSNode, NDIS_802_11_ENCRYPTION_STATUS EncStatus, - PBYTE pbyCCSPK, - PBYTE pbyCCSGK + unsigned char *pbyCCSPK, + unsigned char *pbyCCSGK ); static void Encyption_Rebuild( @@ -619,7 +619,7 @@ void vMgrDisassocBeginSta( void *hDeviceContext, PSMgmtObject pMgmt, - PBYTE abyDestAddress, + unsigned char *abyDestAddress, WORD wReason, PCMD_STATUS pStatus ) @@ -630,10 +630,10 @@ vMgrDisassocBeginSta( pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_DISASSOC_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); // Setup the sFrame structure - sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; + sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; sFrame.len = WLAN_DISASSOC_FR_MAXLEN; // format fixed field frame structure @@ -708,7 +708,7 @@ s_vMgrRxAssocRequest( memset(abyCurrSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1); memset(abyCurrExtSuppRates, 0, WLAN_IEHDR_LEN + WLAN_RATES_MAXLEN + 1); sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (PBYTE)pRxPacket->p80211Header; + sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; vMgrDecodeAssocRequest(&sFrame); @@ -866,7 +866,7 @@ s_vMgrRxReAssocRequest( //decode the frame memset(&sFrame, 0, sizeof(WLAN_FR_REASSOCREQ)); sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (PBYTE)pRxPacket->p80211Header; + sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; vMgrDecodeReassocRequest(&sFrame); if (pMgmt->sNodeDBTable[uNodeIndex].eNodeState >= NODE_AUTH) { @@ -1000,7 +1000,7 @@ s_vMgrRxAssocResponse( { WLAN_FR_ASSOCRESP sFrame; PWLAN_IE_SSID pItemSSID; - PBYTE pbyIEs; + unsigned char *pbyIEs; viawget_wpa_header *wpahdr; @@ -1009,7 +1009,7 @@ s_vMgrRxAssocResponse( pMgmt->eCurrState == WMAC_STATE_ASSOC) { sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (PBYTE)pRxPacket->p80211Header; + sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; // decode the frame vMgrDecodeAssocResponse(&sFrame); if ((sFrame.pwCapInfo == 0) || @@ -1163,8 +1163,8 @@ vMgrAuthenBeginSta( pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); - sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); + sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; sFrame.len = WLAN_AUTHEN_FR_MAXLEN; vMgrEncodeAuthen(&sFrame); /* insert values */ @@ -1212,7 +1212,7 @@ void vMgrDeAuthenBeginSta( void *hDeviceContext, PSMgmtObject pMgmt, - PBYTE abyDestAddress, + unsigned char *abyDestAddress, WORD wReason, PCMD_STATUS pStatus ) @@ -1224,8 +1224,8 @@ vMgrDeAuthenBeginSta( pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_DEAUTHEN_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); - sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); + sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; sFrame.len = WLAN_DEAUTHEN_FR_MAXLEN; vMgrEncodeDeauthen(&sFrame); /* insert values */ @@ -1282,7 +1282,7 @@ s_vMgrRxAuthentication( // decode the frame sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (PBYTE)pRxPacket->p80211Header; + sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; vMgrDecodeAuthen(&sFrame); switch (cpu_to_le16((*(sFrame.pwAuthSequence )))){ case 1: @@ -1353,8 +1353,8 @@ s_vMgrRxAuthenSequence_1( // send auth reply pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); - sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); + sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; sFrame.len = WLAN_AUTHEN_FR_MAXLEN; // format buffer structure vMgrEncodeAuthen(&sFrame); @@ -1466,8 +1466,8 @@ s_vMgrRxAuthenSequence_2( if (cpu_to_le16((*(pFrame->pwStatus))) == WLAN_MGMT_STATUS_SUCCESS) { pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); - sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); + sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; sFrame.len = WLAN_AUTHEN_FR_MAXLEN; // format buffer structure vMgrEncodeAuthen(&sFrame); @@ -1573,8 +1573,8 @@ reply: // send auth reply pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_AUTHEN_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); - sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); + sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; sFrame.len = WLAN_AUTHEN_FR_MAXLEN; // format buffer structure vMgrEncodeAuthen(&sFrame); @@ -1674,7 +1674,7 @@ s_vMgrRxDisassociation( // if is acting an AP.. // a STA is leaving this BSS.. sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (PBYTE)pRxPacket->p80211Header; + sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; if (BSSDBbIsSTAInNodeDB(pMgmt, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex)) { BSSvRemoveOneNode(pDevice, uNodeIndex); } @@ -1684,7 +1684,7 @@ s_vMgrRxDisassociation( } else if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA ){ sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (PBYTE)pRxPacket->p80211Header; + sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; vMgrDecodeDisassociation(&sFrame); DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "AP disassociated me, reason=%d.\n", cpu_to_le16(*(sFrame.pwReason))); //TODO: do something let upper layer know or @@ -1754,7 +1754,7 @@ s_vMgrRxDeauthentication( // if is acting an AP.. // a STA is leaving this BSS.. sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (PBYTE)pRxPacket->p80211Header; + sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; if (BSSDBbIsSTAInNodeDB(pMgmt, pRxPacket->p80211Header->sA3.abyAddr2, &uNodeIndex)) { BSSvRemoveOneNode(pDevice, uNodeIndex); } @@ -1765,7 +1765,7 @@ s_vMgrRxDeauthentication( else { if (pMgmt->eCurrMode == WMAC_MODE_ESS_STA ) { sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (PBYTE)pRxPacket->p80211Header; + sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; vMgrDecodeDeauthen(&sFrame); DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO "AP deauthed me, reason=%d.\n", cpu_to_le16((*(sFrame.pwReason)))); // TODO: update BSS list for specific BSSID if pre-authentication case @@ -1900,7 +1900,7 @@ s_vMgrRxBeacon( memset(&sFrame, 0, sizeof(WLAN_FR_BEACON)); sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (PBYTE)pRxPacket->p80211Header; + sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; // decode the beacon frame vMgrDecodeBeacon(&sFrame); @@ -3229,7 +3229,7 @@ s_MgrMakeBeacon( unsigned int uCurrChannel, WORD wCurrATIMWinodw, PWLAN_IE_SSID pCurrSSID, - PBYTE pCurrBSSID, + unsigned char *pCurrBSSID, PWLAN_IE_SUPP_RATES pCurrSuppRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates ) @@ -3237,7 +3237,7 @@ s_MgrMakeBeacon( PSTxMgmtPacket pTxPacket = NULL; WLAN_FR_BEACON sFrame; BYTE abyBroadcastAddr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - PBYTE pbyBuffer; + unsigned char *pbyBuffer; unsigned int uLength = 0; PWLAN_IE_IBSS_DFS pIBSSDFS = NULL; unsigned int ii; @@ -3245,9 +3245,9 @@ s_MgrMakeBeacon( // prepare beacon frame pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_BEACON_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); // Setup the sFrame structure. - sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; + sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; sFrame.len = WLAN_BEACON_FR_MAXLEN; vMgrEncodeBeacon(&sFrame); // Setup the header @@ -3342,7 +3342,7 @@ s_MgrMakeBeacon( if ((pMgmt->b11hEnable == TRUE) && (pMgmt->eCurrentPHYMode == PHY_TYPE_11A)) { // Country IE - pbyBuffer = (PBYTE)(sFrame.pBuf + sFrame.len); + pbyBuffer = (unsigned char *)(sFrame.pBuf + sFrame.len); CARDvSetCountryIE(pMgmt->pAdapter, pbyBuffer); CARDvSetCountryInfo(pMgmt->pAdapter, PHY_TYPE_11A, pbyBuffer); uLength += ((PWLAN_IE_COUNTRY) pbyBuffer)->len + WLAN_IEHDR_LEN; @@ -3457,9 +3457,9 @@ s_MgrMakeProbeResponse( WORD wCurrBeaconPeriod, unsigned int uCurrChannel, WORD wCurrATIMWinodw, - PBYTE pDstAddr, + unsigned char *pDstAddr, PWLAN_IE_SSID pCurrSSID, - PBYTE pCurrBSSID, + unsigned char *pCurrBSSID, PWLAN_IE_SUPP_RATES pCurrSuppRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates, BYTE byPHYType @@ -3467,7 +3467,7 @@ s_MgrMakeProbeResponse( { PSTxMgmtPacket pTxPacket = NULL; WLAN_FR_PROBERESP sFrame; - PBYTE pbyBuffer; + unsigned char *pbyBuffer; unsigned int uLength = 0; PWLAN_IE_IBSS_DFS pIBSSDFS = NULL; unsigned int ii; @@ -3475,9 +3475,9 @@ s_MgrMakeProbeResponse( pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_PROBERESP_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); // Setup the sFrame structure. - sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; + sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; sFrame.len = WLAN_PROBERESP_FR_MAXLEN; vMgrEncodeProbeResponse(&sFrame); // Setup the header @@ -3546,7 +3546,7 @@ s_MgrMakeProbeResponse( if ((pMgmt->b11hEnable == TRUE) && (pMgmt->eCurrentPHYMode == PHY_TYPE_11A)) { // Country IE - pbyBuffer = (PBYTE)(sFrame.pBuf + sFrame.len); + pbyBuffer = (unsigned char *)(sFrame.pBuf + sFrame.len); CARDvSetCountryIE(pMgmt->pAdapter, pbyBuffer); CARDvSetCountryInfo(pMgmt->pAdapter, PHY_TYPE_11A, pbyBuffer); uLength += ((PWLAN_IE_COUNTRY) pbyBuffer)->len + WLAN_IEHDR_LEN; @@ -3642,7 +3642,7 @@ PSTxMgmtPacket s_MgrMakeAssocRequest( PSDevice pDevice, PSMgmtObject pMgmt, - PBYTE pDAddr, + unsigned char *pDAddr, WORD wCurrCapInfo, WORD wListenInterval, PWLAN_IE_SSID pCurrSSID, @@ -3652,15 +3652,15 @@ s_MgrMakeAssocRequest( { PSTxMgmtPacket pTxPacket = NULL; WLAN_FR_ASSOCREQ sFrame; - PBYTE pbyIEs; - PBYTE pbyRSN; + unsigned char *pbyIEs; + unsigned char *pbyRSN; pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_ASSOCREQ_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); // Setup the sFrame structure. - sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; + sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; sFrame.len = WLAN_ASSOCREQ_FR_MAXLEN; // format fixed field frame structure vMgrEncodeAssocRequest(&sFrame); @@ -3722,7 +3722,7 @@ s_MgrMakeAssocRequest( } if (sFrame.pCurrSuppCh == NULL) { sFrame.pCurrSuppCh = (PWLAN_IE_SUPP_CH)(sFrame.pBuf + sFrame.len); - sFrame.len += CARDbySetSupportChannels(pMgmt->pAdapter,(PBYTE)sFrame.pCurrSuppCh); + sFrame.len += CARDbySetSupportChannels(pMgmt->pAdapter,(unsigned char *)sFrame.pCurrSuppCh); } } @@ -3765,7 +3765,7 @@ s_MgrMakeAssocRequest( sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_NONE; } // Auth Key Management Suite - pbyRSN = (PBYTE)(sFrame.pBuf + sFrame.len + 2 + sFrame.pRSNWPA->len); + pbyRSN = (unsigned char *)(sFrame.pBuf + sFrame.len + 2 + sFrame.pRSNWPA->len); *pbyRSN++=0x01; *pbyRSN++=0x00; *pbyRSN++=0x00; @@ -3917,7 +3917,7 @@ PSTxMgmtPacket s_MgrMakeReAssocRequest( PSDevice pDevice, PSMgmtObject pMgmt, - PBYTE pDAddr, + unsigned char *pDAddr, WORD wCurrCapInfo, WORD wListenInterval, PWLAN_IE_SSID pCurrSSID, @@ -3927,15 +3927,15 @@ s_MgrMakeReAssocRequest( { PSTxMgmtPacket pTxPacket = NULL; WLAN_FR_REASSOCREQ sFrame; - PBYTE pbyIEs; - PBYTE pbyRSN; + unsigned char *pbyIEs; + unsigned char *pbyRSN; pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; memset( pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_REASSOCREQ_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); /* Setup the sFrame structure. */ - sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; + sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; sFrame.len = WLAN_REASSOCREQ_FR_MAXLEN; // format fixed field frame structure @@ -4024,7 +4024,7 @@ s_MgrMakeReAssocRequest( sFrame.pRSNWPA->PKSList[0].abyOUI[3] = WPA_NONE; } // Auth Key Management Suite - pbyRSN = (PBYTE)(sFrame.pBuf + sFrame.len + 2 + sFrame.pRSNWPA->len); + pbyRSN = (unsigned char *)(sFrame.pBuf + sFrame.len + 2 + sFrame.pRSNWPA->len); *pbyRSN++=0x01; *pbyRSN++=0x00; *pbyRSN++=0x00; @@ -4172,7 +4172,7 @@ s_MgrMakeAssocResponse( WORD wCurrCapInfo, WORD wAssocStatus, WORD wAssocAID, - PBYTE pDstAddr, + unsigned char *pDstAddr, PWLAN_IE_SUPP_RATES pCurrSuppRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates ) @@ -4183,9 +4183,9 @@ s_MgrMakeAssocResponse( pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_ASSOCREQ_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); // Setup the sFrame structure - sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; + sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; sFrame.len = WLAN_REASSOCRESP_FR_MAXLEN; vMgrEncodeAssocResponse(&sFrame); // Setup the header @@ -4246,7 +4246,7 @@ s_MgrMakeReAssocResponse( WORD wCurrCapInfo, WORD wAssocStatus, WORD wAssocAID, - PBYTE pDstAddr, + unsigned char *pDstAddr, PWLAN_IE_SUPP_RATES pCurrSuppRates, PWLAN_IE_SUPP_RATES pCurrExtSuppRates ) @@ -4257,9 +4257,9 @@ s_MgrMakeReAssocResponse( pTxPacket = (PSTxMgmtPacket)pMgmt->pbyMgmtPacketPool; memset(pTxPacket, 0, sizeof(STxMgmtPacket) + WLAN_ASSOCREQ_FR_MAXLEN); - pTxPacket->p80211Header = (PUWLAN_80211HDR)((PBYTE)pTxPacket + sizeof(STxMgmtPacket)); + pTxPacket->p80211Header = (PUWLAN_80211HDR)((unsigned char *)pTxPacket + sizeof(STxMgmtPacket)); // Setup the sFrame structure - sFrame.pBuf = (PBYTE)pTxPacket->p80211Header; + sFrame.pBuf = (unsigned char *)pTxPacket->p80211Header; sFrame.len = WLAN_REASSOCRESP_FR_MAXLEN; vMgrEncodeReassocResponse(&sFrame); // Setup the header @@ -4331,7 +4331,7 @@ s_vMgrRxProbeResponse( memset(&sFrame, 0, sizeof(WLAN_FR_PROBERESP)); // decode the frame sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (PBYTE)pRxPacket->p80211Header; + sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; vMgrDecodeProbeResponse(&sFrame); if ((sFrame.pqwTimestamp == 0) || @@ -4458,7 +4458,7 @@ s_vMgrRxProbeRequest( memset(&sFrame, 0, sizeof(WLAN_FR_PROBEREQ)); // decode the frame sFrame.len = pRxPacket->cbMPDULen; - sFrame.pBuf = (PBYTE)pRxPacket->p80211Header; + sFrame.pBuf = (unsigned char *)pRxPacket->p80211Header; vMgrDecodeProbeRequest(&sFrame); /* DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Probe request rx:MAC addr:%02x-%02x-%02x=%02x-%02x-%02x \n", @@ -4495,7 +4495,7 @@ s_vMgrRxProbeRequest( 0, sFrame.pHdr->sA3.abyAddr2, (PWLAN_IE_SSID)pMgmt->abyCurrSSID, - (PBYTE)pMgmt->abyCurrBSSID, + (unsigned char *)pMgmt->abyCurrBSSID, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates, byPHYType @@ -4708,7 +4708,7 @@ bMgrPrepareBeaconToSend( pMgmt->uCurrChannel, pMgmt->wCurrATIMWindow, //0, (PWLAN_IE_SSID)pMgmt->abyCurrSSID, - (PBYTE)pMgmt->abyCurrBSSID, + (unsigned char *)pMgmt->abyCurrBSSID, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrSuppRates, (PWLAN_IE_SUPP_RATES)pMgmt->abyCurrExtSuppRates ); @@ -4810,7 +4810,7 @@ s_vMgrLogStatus( BOOL bAdd_PMKID_Candidate ( void *hDeviceContext, - PBYTE pbyBSSID, + unsigned char *pbyBSSID, PSRSNCapObject psRSNCapObj ) { @@ -4885,8 +4885,8 @@ static BOOL s_bCipherMatch ( PKnownBSS pBSSNode, NDIS_802_11_ENCRYPTION_STATUS EncStatus, - PBYTE pbyCCSPK, - PBYTE pbyCCSGK + unsigned char *pbyCCSPK, + unsigned char *pbyCCSGK ) { BYTE byMulticastCipher = KEY_CTL_INVALID; diff --git a/drivers/staging/vt6655/wmgr.h b/drivers/staging/vt6655/wmgr.h index a08403e3c610..748706fcaef7 100644 --- a/drivers/staging/vt6655/wmgr.h +++ b/drivers/staging/vt6655/wmgr.h @@ -332,7 +332,7 @@ typedef struct tagSMgmtObject WORD wListenInterval; WORD wCountToWakeUp; BOOL bInTIMWake; - PBYTE pbyPSPacketPool; + unsigned char *pbyPSPacketPool; BYTE byPSPacketPool[sizeof(STxMgmtPacket) + WLAN_NULLDATA_FR_MAXLEN]; BOOL bRxBeaconInTBTTWake; BYTE abyPSTxMap[MAX_NODE_NUM + 1]; @@ -342,7 +342,7 @@ typedef struct tagSMgmtObject unsigned int uCmdHostAPBusy; // management packet pool - PBYTE pbyMgmtPacketPool; + unsigned char *pbyMgmtPacketPool; BYTE byMgmtPacketPool[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN]; @@ -432,7 +432,7 @@ void vMgrDisassocBeginSta( void *hDeviceContext, PSMgmtObject pMgmt, - PBYTE abyDestAddress, + unsigned char *abyDestAddress, WORD wReason, PCMD_STATUS pStatus ); @@ -475,7 +475,7 @@ void vMgrDeAuthenBeginSta( void *hDeviceContext, PSMgmtObject pMgmt, - PBYTE abyDestAddress, + unsigned char *abyDestAddress, WORD wReason, PCMD_STATUS pStatus ); @@ -490,7 +490,7 @@ bMgrPrepareBeaconToSend( BOOL bAdd_PMKID_Candidate ( void *hDeviceContext, - PBYTE pbyBSSID, + unsigned char *pbyBSSID, PSRSNCapObject psRSNCapObj ); diff --git a/drivers/staging/vt6655/wpa.c b/drivers/staging/vt6655/wpa.c index da5c814e200e..d3b54c514026 100644 --- a/drivers/staging/vt6655/wpa.c +++ b/drivers/staging/vt6655/wpa.c @@ -112,7 +112,7 @@ WPA_ParseRSN ( { PWLAN_IE_RSN_AUTH pIE_RSN_Auth = NULL; int i, j, m, n = 0; - PBYTE pbyCaps; + unsigned char *pbyCaps; WPA_ClearRSN(pBSSList); @@ -207,7 +207,7 @@ WPA_ParseRSN ( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"14+4+(m+n)*4: %d\n", 14+4+(m+n)*4); if(pRSN->len+2 >= 14+4+(m+n)*4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*m)+AKC(2)+AKS(4*n)+Cap(2) - pbyCaps = (PBYTE)pIE_RSN_Auth->AuthKSList[n].abyOUI; + pbyCaps = (unsigned char *)pIE_RSN_Auth->AuthKSList[n].abyOUI; pBSSList->byDefaultK_as_PK = (*pbyCaps) & WPA_GROUPFLAG; pBSSList->byReplayIdx = 2 << ((*pbyCaps >> WPA_REPLAYBITSSHIFT) & WPA_REPLAYBITS); pBSSList->sRSNCapObj.bRSNCapExist = TRUE; diff --git a/drivers/staging/vt6655/wpa2.c b/drivers/staging/vt6655/wpa2.c index caa32b752c9f..e77fb08c9cf7 100644 --- a/drivers/staging/vt6655/wpa2.c +++ b/drivers/staging/vt6655/wpa2.c @@ -115,7 +115,7 @@ WPA2vParseRSN ( { int i, j; WORD m = 0, n = 0; - PBYTE pbyOUI; + unsigned char *pbyOUI; BOOL bUseGK = FALSE; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"WPA2_ParseRSN: [%d]\n", pRSN->len); @@ -268,7 +268,7 @@ WPA2uSetIEs( ) { PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle; - PBYTE pbyBuffer = NULL; + unsigned char *pbyBuffer = NULL; unsigned int ii = 0; PWORD pwPMKID = NULL; @@ -279,7 +279,7 @@ WPA2uSetIEs( (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) && (pMgmt->pCurrBSS != NULL)) { /* WPA2 IE */ - pbyBuffer = (PBYTE) pRSNIEs; + pbyBuffer = (unsigned char *) pRSNIEs; pRSNIEs->byElementID = WLAN_EID_RSN; pRSNIEs->len = 6; //Version(2)+GK(4) pRSNIEs->wVersion = 1; diff --git a/drivers/staging/vt6655/wpactl.c b/drivers/staging/vt6655/wpactl.c index 4adc2f05be14..714364388c55 100644 --- a/drivers/staging/vt6655/wpactl.c +++ b/drivers/staging/vt6655/wpactl.c @@ -359,7 +359,7 @@ spin_lock_irq(&pDevice->lock); dwKeyIndex, param->u.wpa_key.key_len, (PQWORD) &(KeyRSC), - (PBYTE)abyKey, + (unsigned char *)abyKey, byKeyDecMode, pDevice->PortOffset, pDevice->byLocalID) == TRUE) && @@ -367,7 +367,7 @@ spin_lock_irq(&pDevice->lock); dwKeyIndex, param->u.wpa_key.key_len, (PQWORD) &(KeyRSC), - (PBYTE)abyKey, + (unsigned char *)abyKey, byKeyDecMode, pDevice->PortOffset, pDevice->byLocalID) == TRUE) ) { @@ -400,7 +400,7 @@ spin_lock_irq(&pDevice->lock); dwKeyIndex, param->u.wpa_key.key_len, (PQWORD) &(KeyRSC), - (PBYTE)abyKey, + (unsigned char *)abyKey, byKeyDecMode, pDevice->PortOffset, pDevice->byLocalID) == TRUE) { @@ -613,13 +613,13 @@ static int wpa_get_scan(PSDevice pDevice, PSMgmtObject pMgmt = pDevice->pMgmt; PWLAN_IE_SSID pItemSSID; PKnownBSS pBSS; - PBYTE pBuf; + unsigned char *pBuf; int ret = 0; u16 count = 0; u16 ii, jj; #if 1 - PBYTE ptempBSS; + unsigned char *ptempBSS; @@ -713,7 +713,7 @@ static int wpa_get_scan(PSDevice pDevice, scan_buf->rsn_ie_len = pBSS->wRSNLen; memcpy(scan_buf->rsn_ie, pBSS->byRSNIE, pBSS->wRSNLen); } - scan_buf = (struct viawget_scan_result *)((PBYTE)scan_buf + sizeof(struct viawget_scan_result)); + scan_buf = (struct viawget_scan_result *)((unsigned char *)scan_buf + sizeof(struct viawget_scan_result)); jj ++; } } diff --git a/drivers/staging/vt6655/wroute.c b/drivers/staging/vt6655/wroute.c index 648ae1aa2b18..6d02cea7b41d 100644 --- a/drivers/staging/vt6655/wroute.c +++ b/drivers/staging/vt6655/wroute.c @@ -65,7 +65,7 @@ static int msglevel =MSG_LEVEL_INFO; * Return Value: TRUE if packet duplicate; otherwise FALSE * */ -BOOL ROUTEbRelay (PSDevice pDevice, PBYTE pbySkbData, unsigned int uDataLen, unsigned int uNodeIndex) +BOOL ROUTEbRelay (PSDevice pDevice, unsigned char *pbySkbData, unsigned int uDataLen, unsigned int uNodeIndex) { PSMgmtObject pMgmt = pDevice->pMgmt; PSTxDesc pHeadTD, pLastTD; @@ -77,7 +77,7 @@ BOOL ROUTEbRelay (PSDevice pDevice, PBYTE pbySkbData, unsigned int uDataLen, uns PSKeyItem pTransmitKey = NULL; unsigned int cbHeaderSize; unsigned int ii; - PBYTE pbyBSSID; + unsigned char *pbyBSSID; @@ -91,7 +91,7 @@ BOOL ROUTEbRelay (PSDevice pDevice, PBYTE pbySkbData, unsigned int uDataLen, uns pHeadTD->m_td1TD1.byTCR = (TCR_EDP|TCR_STP); - memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)pbySkbData, ETH_HLEN); + memcpy(pDevice->sTxEthHeader.abyDstAddr, (unsigned char *)pbySkbData, ETH_HLEN); cbFrameBodySize = uDataLen - ETH_HLEN; diff --git a/drivers/staging/vt6655/wroute.h b/drivers/staging/vt6655/wroute.h index 199d31153d8e..79f3014ab000 100644 --- a/drivers/staging/vt6655/wroute.h +++ b/drivers/staging/vt6655/wroute.h @@ -39,7 +39,7 @@ /*--------------------- Export Functions --------------------------*/ -BOOL ROUTEbRelay (PSDevice pDevice, PBYTE pbySkbData, unsigned int uDataLen, unsigned int uNodeIndex); +BOOL ROUTEbRelay (PSDevice pDevice, unsigned char *pbySkbData, unsigned int uDataLen, unsigned int uNodeIndex); #endif // __WROUTE_H__ From 15df6c2b922de3088203ad90347a30d31ccca67e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Sat, 5 Jun 2010 15:13:48 -0700 Subject: [PATCH 064/523] Staging: vt6655: remove PWORD typedef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use unsigned short * instead. Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/80211mgr.c | 76 ++++++++++++++-------------- drivers/staging/vt6655/80211mgr.h | 38 +++++++------- drivers/staging/vt6655/aes_ccmp.c | 4 +- drivers/staging/vt6655/baseband.c | 2 +- drivers/staging/vt6655/baseband.h | 2 +- drivers/staging/vt6655/bssdb.c | 18 +++---- drivers/staging/vt6655/bssdb.h | 2 +- drivers/staging/vt6655/card.c | 2 +- drivers/staging/vt6655/datarate.c | 6 +-- drivers/staging/vt6655/datarate.h | 6 +-- drivers/staging/vt6655/device_main.c | 2 +- drivers/staging/vt6655/dpc.c | 32 ++++++------ drivers/staging/vt6655/rxtx.c | 34 ++++++------- drivers/staging/vt6655/ttype.h | 2 - drivers/staging/vt6655/upc.h | 4 +- drivers/staging/vt6655/vntwifi.c | 2 +- drivers/staging/vt6655/vntwifi.h | 2 +- drivers/staging/vt6655/wcmd.c | 2 +- drivers/staging/vt6655/wmgr.c | 12 ++--- drivers/staging/vt6655/wpa.c | 2 +- drivers/staging/vt6655/wpa2.c | 14 ++--- 21 files changed, 131 insertions(+), 133 deletions(-) diff --git a/drivers/staging/vt6655/80211mgr.c b/drivers/staging/vt6655/80211mgr.c index 9fbced855059..9156a0bacdd2 100644 --- a/drivers/staging/vt6655/80211mgr.c +++ b/drivers/staging/vt6655/80211mgr.c @@ -99,9 +99,9 @@ vMgrEncodeBeacon( // Fixed Fields pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_BEACON_OFF_TS); - pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwBeaconInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_BEACON_OFF_BCN_INT); - pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_BEACON_OFF_CAPINFO); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_BEACON_OFF_SSID; @@ -133,9 +133,9 @@ vMgrDecodeBeacon( // Fixed Fields pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_BEACON_OFF_TS); - pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwBeaconInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_BEACON_OFF_BCN_INT); - pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_BEACON_OFF_CAPINFO); // Information elements @@ -296,7 +296,7 @@ vMgrEncodeDisassociation( // Fixed Fields - pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwReason = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_DISASSOC_OFF_REASON); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DISASSOC_OFF_REASON + sizeof(*(pFrame->pwReason)); @@ -323,7 +323,7 @@ vMgrDecodeDisassociation( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; // Fixed Fields - pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwReason = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_DISASSOC_OFF_REASON); return; @@ -348,9 +348,9 @@ vMgrEncodeAssocRequest( { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; // Fixed Fields - pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCREQ_OFF_CAP_INFO); - pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwListenInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCREQ_OFF_LISTEN_INT); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCREQ_OFF_LISTEN_INT + sizeof(*(pFrame->pwListenInterval)); return; @@ -377,9 +377,9 @@ vMgrDecodeAssocRequest( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; // Fixed Fields - pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCREQ_OFF_CAP_INFO); - pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwListenInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCREQ_OFF_LISTEN_INT); // Information elements @@ -442,11 +442,11 @@ vMgrEncodeAssocResponse( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; // Fixed Fields - pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCRESP_OFF_CAP_INFO); - pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCRESP_OFF_STATUS); - pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwAid = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCRESP_OFF_AID); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_ASSOCRESP_OFF_AID + sizeof(*(pFrame->pwAid)); @@ -476,11 +476,11 @@ vMgrDecodeAssocResponse( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; // Fixed Fields - pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCRESP_OFF_CAP_INFO); - pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCRESP_OFF_STATUS); - pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwAid = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCRESP_OFF_AID); // Information elements @@ -521,9 +521,9 @@ vMgrEncodeReassocRequest( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; // Fixed Fields - pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCREQ_OFF_CAP_INFO); - pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwListenInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCREQ_OFF_LISTEN_INT); pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCREQ_OFF_CURR_AP); @@ -554,9 +554,9 @@ vMgrDecodeReassocRequest( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; // Fixed Fields - pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCREQ_OFF_CAP_INFO); - pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwListenInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCREQ_OFF_LISTEN_INT); pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCREQ_OFF_CURR_AP); @@ -701,9 +701,9 @@ vMgrEncodeProbeResponse( // Fixed Fields pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_TS); - pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwBeaconInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_BCN_INT); - pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_CAP_INFO); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_PROBERESP_OFF_CAP_INFO + @@ -738,9 +738,9 @@ vMgrDecodeProbeResponse( // Fixed Fields pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_TS); - pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwBeaconInterval = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_BCN_INT); - pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_CAP_INFO); // Information elements @@ -847,11 +847,11 @@ vMgrEncodeAuthen( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; // Fixed Fields - pFrame->pwAuthAlgorithm = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwAuthAlgorithm = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_AUTH_ALG); - pFrame->pwAuthSequence = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwAuthSequence = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_AUTH_SEQ); - pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_STATUS); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_AUTHEN_OFF_STATUS + sizeof(*(pFrame->pwStatus)); @@ -880,11 +880,11 @@ vMgrDecodeAuthen( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; // Fixed Fields - pFrame->pwAuthAlgorithm = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwAuthAlgorithm = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_AUTH_ALG); - pFrame->pwAuthSequence = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwAuthSequence = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_AUTH_SEQ); - pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_STATUS); // Information elements @@ -918,7 +918,7 @@ vMgrEncodeDeauthen( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; // Fixed Fields - pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwReason = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_DEAUTHEN_OFF_REASON); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DEAUTHEN_OFF_REASON + sizeof(*(pFrame->pwReason)); @@ -945,7 +945,7 @@ vMgrDecodeDeauthen( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; // Fixed Fields - pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwReason = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_DEAUTHEN_OFF_REASON); return; @@ -971,11 +971,11 @@ vMgrEncodeReassocResponse( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; // Fixed Fields - pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCRESP_OFF_CAP_INFO); - pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCRESP_OFF_STATUS); - pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwAid = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCRESP_OFF_AID); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCRESP_OFF_AID + sizeof(*(pFrame->pwAid)); @@ -1006,11 +1006,11 @@ vMgrDecodeReassocResponse( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; // Fixed Fields - pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwCapInfo = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCRESP_OFF_CAP_INFO); - pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwStatus = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCRESP_OFF_STATUS); - pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + pFrame->pwAid = (unsigned short *)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCRESP_OFF_AID); //Information elements diff --git a/drivers/staging/vt6655/80211mgr.h b/drivers/staging/vt6655/80211mgr.h index bb58ed0ba3a3..a11e6633a3c6 100644 --- a/drivers/staging/vt6655/80211mgr.h +++ b/drivers/staging/vt6655/80211mgr.h @@ -511,8 +511,8 @@ typedef struct tagWLAN_FR_BEACON { PUWLAN_80211HDR pHdr; // fixed fields PQWORD pqwTimestamp; - PWORD pwBeaconInterval; - PWORD pwCapInfo; + unsigned short *pwBeaconInterval; + unsigned short *pwCapInfo; /*-- info elements ----------*/ PWLAN_IE_SSID pSSID; PWLAN_IE_SUPP_RATES pSuppRates; @@ -556,7 +556,7 @@ typedef struct tagWLAN_FR_DISASSOC { unsigned char *pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ - PWORD pwReason; + unsigned short *pwReason; /*-- info elements ----------*/ } WLAN_FR_DISASSOC, *PWLAN_FR_DISASSOC; @@ -569,8 +569,8 @@ typedef struct tagWLAN_FR_ASSOCREQ { unsigned char *pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ - PWORD pwCapInfo; - PWORD pwListenInterval; + unsigned short *pwCapInfo; + unsigned short *pwListenInterval; /*-- info elements ----------*/ PWLAN_IE_SSID pSSID; PWLAN_IE_SUPP_RATES pSuppRates; @@ -590,9 +590,9 @@ typedef struct tagWLAN_FR_ASSOCRESP { unsigned char *pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ - PWORD pwCapInfo; - PWORD pwStatus; - PWORD pwAid; + unsigned short *pwCapInfo; + unsigned short *pwStatus; + unsigned short *pwAid; /*-- info elements ----------*/ PWLAN_IE_SUPP_RATES pSuppRates; PWLAN_IE_SUPP_RATES pExtSuppRates; @@ -608,8 +608,8 @@ typedef struct tagWLAN_FR_REASSOCREQ { PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ - PWORD pwCapInfo; - PWORD pwListenInterval; + unsigned short *pwCapInfo; + unsigned short *pwListenInterval; PIEEE_ADDR pAddrCurrAP; /*-- info elements ----------*/ @@ -629,9 +629,9 @@ typedef struct tagWLAN_FR_REASSOCRESP { unsigned char *pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ - PWORD pwCapInfo; - PWORD pwStatus; - PWORD pwAid; + unsigned short *pwCapInfo; + unsigned short *pwStatus; + unsigned short *pwAid; /*-- info elements ----------*/ PWLAN_IE_SUPP_RATES pSuppRates; PWLAN_IE_SUPP_RATES pExtSuppRates; @@ -662,8 +662,8 @@ typedef struct tagWLAN_FR_PROBERESP { PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ PQWORD pqwTimestamp; - PWORD pwBeaconInterval; - PWORD pwCapInfo; + unsigned short *pwBeaconInterval; + unsigned short *pwCapInfo; /*-- info elements ----------*/ PWLAN_IE_SSID pSSID; PWLAN_IE_SUPP_RATES pSuppRates; @@ -690,9 +690,9 @@ typedef struct tagWLAN_FR_AUTHEN { unsigned char *pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ - PWORD pwAuthAlgorithm; - PWORD pwAuthSequence; - PWORD pwStatus; + unsigned short *pwAuthAlgorithm; + unsigned short *pwAuthSequence; + unsigned short *pwStatus; /*-- info elements ----------*/ PWLAN_IE_CHALLENGE pChallenge; @@ -706,7 +706,7 @@ typedef struct tagWLAN_FR_DEAUTHEN { unsigned char *pBuf; PUWLAN_80211HDR pHdr; /*-- fixed fields -----------*/ - PWORD pwReason; + unsigned short *pwReason; /*-- info elements ----------*/ diff --git a/drivers/staging/vt6655/aes_ccmp.c b/drivers/staging/vt6655/aes_ccmp.c index f148356cdfc5..a77a104a69cb 100644 --- a/drivers/staging/vt6655/aes_ccmp.c +++ b/drivers/staging/vt6655/aes_ccmp.c @@ -267,8 +267,8 @@ int ii,jj,kk; pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN; - if ( WLAN_GET_FC_TODS(*(PWORD)pbyFrame) && - WLAN_GET_FC_FROMDS(*(PWORD)pbyFrame) ) { + if ( WLAN_GET_FC_TODS(*(unsigned short *)pbyFrame) && + WLAN_GET_FC_FROMDS(*(unsigned short *)pbyFrame) ) { bA4 = TRUE; pbyIV += 6; // 6 is 802.11 address4 wHLen += 6; diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index f96a33787d1e..87c66e20d929 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -1849,7 +1849,7 @@ BBvCaculateParameter ( unsigned int cbFrameLength, WORD wRate, BYTE byPacketType, - PWORD pwPhyLen, + unsigned short *pwPhyLen, unsigned char *pbyPhySrv, unsigned char *pbyPhySgn ) diff --git a/drivers/staging/vt6655/baseband.h b/drivers/staging/vt6655/baseband.h index 616dab6f3ac1..eb0368ad850f 100644 --- a/drivers/staging/vt6655/baseband.h +++ b/drivers/staging/vt6655/baseband.h @@ -132,7 +132,7 @@ BBvCaculateParameter ( unsigned int cbFrameLength, WORD wRate, BYTE byPacketType, - PWORD pwPhyLen, + unsigned short *pwPhyLen, unsigned char *pbyPhySrv, unsigned char *pbyPhySgn ); diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c index 76e81362fc17..ddfc97cabd64 100644 --- a/drivers/staging/vt6655/bssdb.c +++ b/drivers/staging/vt6655/bssdb.c @@ -542,8 +542,8 @@ BSSbInsertToBSSList ( TRUE, pQuiet->byQuietCount, pQuiet->byQuietPeriod, - *((PWORD)pQuiet->abyQuietDuration), - *((PWORD)pQuiet->abyQuietOffset) + *((unsigned short *)pQuiet->abyQuietDuration), + *((unsigned short *)pQuiet->abyQuietOffset) ); } else { pQuiet = (PWLAN_IE_QUIET)pIE_Quiet; @@ -551,8 +551,8 @@ BSSbInsertToBSSList ( FALSE, pQuiet->byQuietCount, pQuiet->byQuietPeriod, - *((PWORD)pQuiet->abyQuietDuration), - *((PWORD)pQuiet->abyQuietOffset) + *((unsigned short *)pQuiet->abyQuietDuration), + *((unsigned short *)pQuiet->abyQuietOffset) ); } } @@ -719,8 +719,8 @@ BSSbUpdateToBSSList ( TRUE, pQuiet->byQuietCount, pQuiet->byQuietPeriod, - *((PWORD)pQuiet->abyQuietDuration), - *((PWORD)pQuiet->abyQuietOffset) + *((unsigned short *)pQuiet->abyQuietDuration), + *((unsigned short *)pQuiet->abyQuietOffset) ); } else { pQuiet = (PWLAN_IE_QUIET)pIE_Quiet; @@ -728,8 +728,8 @@ BSSbUpdateToBSSList ( FALSE, pQuiet->byQuietCount, pQuiet->byQuietPeriod, - *((PWORD)pQuiet->abyQuietDuration), - *((PWORD)pQuiet->abyQuietOffset) + *((unsigned short *)pQuiet->abyQuietDuration), + *((unsigned short *)pQuiet->abyQuietOffset) ); } } @@ -898,7 +898,7 @@ BSSvRemoveOneNode( void BSSvUpdateAPNode( void *hDeviceContext, - PWORD pwCapInfo, + unsigned short *pwCapInfo, PWLAN_IE_SUPP_RATES pSuppRates, PWLAN_IE_SUPP_RATES pExtSuppRates ) diff --git a/drivers/staging/vt6655/bssdb.h b/drivers/staging/vt6655/bssdb.h index ac6473a05ba3..9f197c3bb57f 100644 --- a/drivers/staging/vt6655/bssdb.h +++ b/drivers/staging/vt6655/bssdb.h @@ -324,7 +324,7 @@ BSSvCreateOneNode( void BSSvUpdateAPNode( void *hDeviceContext, - PWORD pwCapInfo, + unsigned short *pwCapInfo, PWLAN_IE_SUPP_RATES pItemRates, PWLAN_IE_SUPP_RATES pExtSuppRates ); diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 5ce98a07c554..6cc0c3db53ac 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -1748,7 +1748,7 @@ CARDbStartMeasure ( if (pDevice->byLocalID > REV_ID_VT3253_B1) { HIDWORD(qwStartTSF) = HIDWORD(*((PQWORD) (pDevice->pCurrMeasureEID->sReq.abyStartTime))); LODWORD(qwStartTSF) = LODWORD(*((PQWORD) (pDevice->pCurrMeasureEID->sReq.abyStartTime))); - wDuration = *((PWORD) (pDevice->pCurrMeasureEID->sReq.abyDuration)); + wDuration = *((unsigned short *) (pDevice->pCurrMeasureEID->sReq.abyDuration)); wDuration += 1; // 1 TU for channel switching if ((LODWORD(qwStartTSF) == 0) && (HIDWORD(qwStartTSF) == 0)) { diff --git a/drivers/staging/vt6655/datarate.c b/drivers/staging/vt6655/datarate.c index e1ab30079c03..4be933c0ad04 100644 --- a/drivers/staging/vt6655/datarate.c +++ b/drivers/staging/vt6655/datarate.c @@ -200,9 +200,9 @@ RATEvParseMaxRate ( PWLAN_IE_SUPP_RATES pItemRates, PWLAN_IE_SUPP_RATES pItemExtRates, BOOL bUpdateBasicRate, - PWORD pwMaxBasicRate, - PWORD pwMaxSuppRate, - PWORD pwSuppRate, + unsigned short *pwMaxBasicRate, + unsigned short *pwMaxSuppRate, + unsigned short *pwSuppRate, unsigned char *pbyTopCCKRate, unsigned char *pbyTopOFDMRate ) diff --git a/drivers/staging/vt6655/datarate.h b/drivers/staging/vt6655/datarate.h index 2cb3b5097a5c..dc4baed51d49 100644 --- a/drivers/staging/vt6655/datarate.h +++ b/drivers/staging/vt6655/datarate.h @@ -60,9 +60,9 @@ RATEvParseMaxRate( PWLAN_IE_SUPP_RATES pItemRates, PWLAN_IE_SUPP_RATES pItemExtRates, BOOL bUpdateBasicRate, - PWORD pwMaxBasicRate, - PWORD pwMaxSuppRate, - PWORD pwSuppRate, + unsigned short *pwMaxBasicRate, + unsigned short *pwMaxSuppRate, + unsigned short *pwSuppRate, unsigned char *pbyTopCCKRate, unsigned char *pbyTopOFDMRate ); diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index ecc362d3fdd9..f1af517b74b3 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -487,7 +487,7 @@ static void s_vCompleteCurrentMeasure (PSDevice pDevice, BYTE byResult) for(ii=1;ii<8;ii++) { pDevice->dwRPIs[ii] *= 255; - dwDuration |= *((PWORD) (pDevice->pCurrMeasureEID->sReq.abyDuration)); + dwDuration |= *((unsigned short *) (pDevice->pCurrMeasureEID->sReq.abyDuration)); dwDuration <<= 10; pDevice->dwRPIs[ii] /= dwDuration; pDevice->abyRPIs[ii] = (BYTE) pDevice->dwRPIs[ii]; diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index 723f8466bd61..98bc2552fa00 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -124,7 +124,7 @@ static BOOL s_bHandleRxEncryption( unsigned char *pbyNewRsr, PSKeyItem *pKeyOut, int * pbExtIV, - PWORD pwRxTSC15_0, + unsigned short *pwRxTSC15_0, PDWORD pdwRxTSC47_16 ); @@ -138,7 +138,7 @@ static BOOL s_bHostWepRxEncryption( PSKeyItem pKey, unsigned char *pbyNewRsr, int * pbExtIV, - PWORD pwRxTSC15_0, + unsigned short *pwRxTSC15_0, PDWORD pdwRxTSC47_16 ); @@ -175,7 +175,7 @@ s_vProcessRxMACHeader ( { unsigned char *pbyRxBuffer; unsigned int cbHeaderSize = 0; - PWORD pwType; + unsigned short *pwType; PS802_11Header pMACHeader; int ii; @@ -203,12 +203,12 @@ s_vProcessRxMACHeader ( } else if (!compare_ether_addr(pbyRxBuffer, &pDevice->abySNAP_RFC1042[0])) { cbHeaderSize += 6; - pwType = (PWORD) (pbyRxBufferAddr + cbHeaderSize); + pwType = (unsigned short *) (pbyRxBufferAddr + cbHeaderSize); if ((*pwType!= TYPE_PKT_IPX) && (*pwType != cpu_to_le16(0xF380))) { } else { cbHeaderSize -= 8; - pwType = (PWORD) (pbyRxBufferAddr + cbHeaderSize); + pwType = (unsigned short *) (pbyRxBufferAddr + cbHeaderSize); if (bIsWEP) { if (bExtIV) { *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 8); // 8 is IV&ExtIV @@ -223,7 +223,7 @@ s_vProcessRxMACHeader ( } else { cbHeaderSize -= 2; - pwType = (PWORD) (pbyRxBufferAddr + cbHeaderSize); + pwType = (unsigned short *) (pbyRxBufferAddr + cbHeaderSize); if (bIsWEP) { if (bExtIV) { *pwType = htons(cbPacketSize - WLAN_HDR_ADDR3_LEN - 8); // 8 is IV&ExtIV @@ -353,7 +353,7 @@ device_receive_frame ( unsigned char *pbyNewRsr; unsigned char *pbyRSSI; PQWORD pqwTSFTime; - PWORD pwFrameSize; + unsigned short *pwFrameSize; unsigned char *pbyFrame; BOOL bDeFragRx = FALSE; BOOL bIsWEP = FALSE; @@ -391,7 +391,7 @@ device_receive_frame ( pDevice->rx_buf_sz, PCI_DMA_FROMDEVICE); #endif //PLICE_DEBUG<- - pwFrameSize = (PWORD)(skb->data + 2); + pwFrameSize = (unsigned short *)(skb->data + 2); FrameSize = cpu_to_le16(pCurrRD->m_rd1RD1.wReqCount) - cpu_to_le16(pCurrRD->m_rd0RD0.wResCount); // Max: 2312Payload + 30HD +4CRC + 2Padding + 4Len + 8TSF + 4RSR @@ -1170,7 +1170,7 @@ static BOOL s_bHandleRxEncryption ( unsigned char *pbyNewRsr, PSKeyItem *pKeyOut, int * pbExtIV, - PWORD pwRxTSC15_0, + unsigned short *pwRxTSC15_0, PDWORD pdwRxTSC47_16 ) { @@ -1186,8 +1186,8 @@ static BOOL s_bHandleRxEncryption ( *pdwRxTSC47_16 = 0; pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN; - if ( WLAN_GET_FC_TODS(*(PWORD)pbyFrame) && - WLAN_GET_FC_FROMDS(*(PWORD)pbyFrame) ) { + if ( WLAN_GET_FC_TODS(*(unsigned short *)pbyFrame) && + WLAN_GET_FC_FROMDS(*(unsigned short *)pbyFrame) ) { pbyIV += 6; // 6 is 802.11 address4 PayloadLen -= 6; } @@ -1280,7 +1280,7 @@ static BOOL s_bHandleRxEncryption ( if (byDecMode == KEY_CTL_TKIP) { *pwRxTSC15_0 = cpu_to_le16(MAKEWORD(*(pbyIV+2), *pbyIV)); } else { - *pwRxTSC15_0 = cpu_to_le16(*(PWORD)pbyIV); + *pwRxTSC15_0 = cpu_to_le16(*(unsigned short *)pbyIV); } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TSC0_15: %x\n", *pwRxTSC15_0); @@ -1317,7 +1317,7 @@ static BOOL s_bHostWepRxEncryption ( PSKeyItem pKey, unsigned char *pbyNewRsr, int * pbExtIV, - PWORD pwRxTSC15_0, + unsigned short *pwRxTSC15_0, PDWORD pdwRxTSC47_16 ) { @@ -1333,8 +1333,8 @@ static BOOL s_bHostWepRxEncryption ( *pdwRxTSC47_16 = 0; pbyIV = pbyFrame + WLAN_HDR_ADDR3_LEN; - if ( WLAN_GET_FC_TODS(*(PWORD)pbyFrame) && - WLAN_GET_FC_FROMDS(*(PWORD)pbyFrame) ) { + if ( WLAN_GET_FC_TODS(*(unsigned short *)pbyFrame) && + WLAN_GET_FC_FROMDS(*(unsigned short *)pbyFrame) ) { pbyIV += 6; // 6 is 802.11 address4 PayloadLen -= 6; } @@ -1391,7 +1391,7 @@ static BOOL s_bHostWepRxEncryption ( if (byDecMode == KEY_CTL_TKIP) { *pwRxTSC15_0 = cpu_to_le16(MAKEWORD(*(pbyIV+2), *pbyIV)); } else { - *pwRxTSC15_0 = cpu_to_le16(*(PWORD)pbyIV); + *pwRxTSC15_0 = cpu_to_le16(*(unsigned short *)pbyIV); } DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"TSC0_15: %x\n", *pwRxTSC15_0); diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 32725dadf855..f3051b10c136 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -745,11 +745,11 @@ s_uFillDataHead ( PSTxDataHead_g pBuf = (PSTxDataHead_g)pTxDataHead; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, - (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_a), (unsigned char *)&(pBuf->bySignalField_a) + (unsigned short *)&(wLen), (unsigned char *)&(pBuf->byServiceField_a), (unsigned char *)&(pBuf->bySignalField_a) ); pBuf->wTransmitLength_a = cpu_to_le16(wLen); BBvCaculateParameter(pDevice, cbFrameLength, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_b), (unsigned char *)&(pBuf->bySignalField_b) + (unsigned short *)&(wLen), (unsigned char *)&(pBuf->byServiceField_b), (unsigned char *)&(pBuf->bySignalField_b) ); pBuf->wTransmitLength_b = cpu_to_le16(wLen); //Get Duration and TimeStamp @@ -771,11 +771,11 @@ s_uFillDataHead ( PSTxDataHead_g_FB pBuf = (PSTxDataHead_g_FB)pTxDataHead; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, - (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_a), (unsigned char *)&(pBuf->bySignalField_a) + (unsigned short *)&(wLen), (unsigned char *)&(pBuf->byServiceField_a), (unsigned char *)&(pBuf->bySignalField_a) ); pBuf->wTransmitLength_a = cpu_to_le16(wLen); BBvCaculateParameter(pDevice, cbFrameLength, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_b), (unsigned char *)&(pBuf->bySignalField_b) + (unsigned short *)&(wLen), (unsigned char *)&(pBuf->byServiceField_b), (unsigned char *)&(pBuf->bySignalField_b) ); pBuf->wTransmitLength_b = cpu_to_le16(wLen); //Get Duration and TimeStamp @@ -800,7 +800,7 @@ s_uFillDataHead ( PSTxDataHead_a_FB pBuf = (PSTxDataHead_a_FB)pTxDataHead; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, - (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField), (unsigned char *)&(pBuf->bySignalField) + (unsigned short *)&(wLen), (unsigned char *)&(pBuf->byServiceField), (unsigned char *)&(pBuf->bySignalField) ); pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration and TimeStampOff @@ -817,7 +817,7 @@ s_uFillDataHead ( PSTxDataHead_ab pBuf = (PSTxDataHead_ab)pTxDataHead; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, - (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField), (unsigned char *)&(pBuf->bySignalField) + (unsigned short *)&(wLen), (unsigned char *)&(pBuf->byServiceField), (unsigned char *)&(pBuf->bySignalField) ); pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration and TimeStampOff @@ -835,7 +835,7 @@ s_uFillDataHead ( PSTxDataHead_ab pBuf = (PSTxDataHead_ab)pTxDataHead; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, cbFrameLength, wCurrentRate, byPktType, - (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField), (unsigned char *)&(pBuf->bySignalField) + (unsigned short *)&(wLen), (unsigned char *)&(pBuf->byServiceField), (unsigned char *)&(pBuf->bySignalField) ); pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration and TimeStampOff @@ -883,11 +883,11 @@ s_vFillRTSHead ( PSRTS_g pBuf = (PSRTS_g)pvRTS; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_b), (unsigned char *)&(pBuf->bySignalField_b) + (unsigned short *)&(wLen), (unsigned char *)&(pBuf->byServiceField_b), (unsigned char *)&(pBuf->bySignalField_b) ); pBuf->wTransmitLength_b = cpu_to_le16(wLen); BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, - (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_a), (unsigned char *)&(pBuf->bySignalField_a) + (unsigned short *)&(wLen), (unsigned char *)&(pBuf->byServiceField_a), (unsigned char *)&(pBuf->bySignalField_a) ); pBuf->wTransmitLength_a = cpu_to_le16(wLen); //Get Duration @@ -916,11 +916,11 @@ s_vFillRTSHead ( PSRTS_g_FB pBuf = (PSRTS_g_FB)pvRTS; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_b), (unsigned char *)&(pBuf->bySignalField_b) + (unsigned short *)&(wLen), (unsigned char *)&(pBuf->byServiceField_b), (unsigned char *)&(pBuf->bySignalField_b) ); pBuf->wTransmitLength_b = cpu_to_le16(wLen); BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, - (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_a), (unsigned char *)&(pBuf->bySignalField_a) + (unsigned short *)&(wLen), (unsigned char *)&(pBuf->byServiceField_a), (unsigned char *)&(pBuf->bySignalField_a) ); pBuf->wTransmitLength_a = cpu_to_le16(wLen); @@ -958,7 +958,7 @@ s_vFillRTSHead ( PSRTS_ab pBuf = (PSRTS_ab)pvRTS; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, - (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField), (unsigned char *)&(pBuf->bySignalField) + (unsigned short *)&(wLen), (unsigned char *)&(pBuf->byServiceField), (unsigned char *)&(pBuf->bySignalField) ); pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration @@ -987,7 +987,7 @@ s_vFillRTSHead ( PSRTS_a_FB pBuf = (PSRTS_a_FB)pvRTS; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopOFDMBasicRate, byPktType, - (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField), (unsigned char *)&(pBuf->bySignalField) + (unsigned short *)&(wLen), (unsigned char *)&(pBuf->byServiceField), (unsigned char *)&(pBuf->bySignalField) ); pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration @@ -1017,7 +1017,7 @@ s_vFillRTSHead ( PSRTS_ab pBuf = (PSRTS_ab)pvRTS; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, uRTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField), (unsigned char *)&(pBuf->bySignalField) + (unsigned short *)&(wLen), (unsigned char *)&(pBuf->byServiceField), (unsigned char *)&(pBuf->bySignalField) ); pBuf->wTransmitLength = cpu_to_le16(wLen); //Get Duration @@ -1077,7 +1077,7 @@ s_vFillCTSHead ( PSCTS_FB pBuf = (PSCTS_FB)pvCTS; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, uCTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_b), (unsigned char *)&(pBuf->bySignalField_b) + (unsigned short *)&(wLen), (unsigned char *)&(pBuf->byServiceField_b), (unsigned char *)&(pBuf->bySignalField_b) ); @@ -1104,7 +1104,7 @@ s_vFillCTSHead ( PSCTS pBuf = (PSCTS)pvCTS; //Get SignalField,ServiceField,Length BBvCaculateParameter(pDevice, uCTSFrameLen, pDevice->byTopCCKBasicRate, PK_TYPE_11B, - (PWORD)&(wLen), (unsigned char *)&(pBuf->byServiceField_b), (unsigned char *)&(pBuf->bySignalField_b) + (unsigned short *)&(wLen), (unsigned char *)&(pBuf->byServiceField_b), (unsigned char *)&(pBuf->bySignalField_b) ); pBuf->wTransmitLength_b = cpu_to_le16(wLen); //Get CTSDuration_ba @@ -2703,7 +2703,7 @@ CMD_STATUS csBeacon_xmit(PSDevice pDevice, PSTxMgmtPacket pPacket) { } BBvCaculateParameter(pDevice, cbFrameSize, wCurrentRate, byPktType, - (PWORD)&(wLen), (unsigned char *)&(pTxDataHead->byServiceField), (unsigned char *)&(pTxDataHead->bySignalField) + (unsigned short *)&(wLen), (unsigned char *)&(pTxDataHead->byServiceField), (unsigned char *)&(pTxDataHead->bySignalField) ); pTxDataHead->wTransmitLength = cpu_to_le16(wLen); //Get TimeStampOff diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h index 6fe184fb77d6..660bc5b20894 100644 --- a/drivers/staging/vt6655/ttype.h +++ b/drivers/staging/vt6655/ttype.h @@ -92,8 +92,6 @@ typedef unsigned long DWORD_PTR; // 32-bit // boolean pointer typedef unsigned int * PUINT; -typedef WORD * PWORD; - typedef DWORD * PDWORD; typedef QWORD * PQWORD; diff --git a/drivers/staging/vt6655/upc.h b/drivers/staging/vt6655/upc.h index c12d028d5ec1..ecf683feca39 100644 --- a/drivers/staging/vt6655/upc.h +++ b/drivers/staging/vt6655/upc.h @@ -82,7 +82,7 @@ #define VNSvInPortW(dwIOAddress, pwData) { \ - volatile WORD* pwAddr = ((PWORD)(dwIOAddress)); \ + volatile WORD* pwAddr = ((unsigned short *)(dwIOAddress)); \ *(pwData) = readw(pwAddr); \ } @@ -99,7 +99,7 @@ #define VNSvOutPortW(dwIOAddress, wData) { \ - volatile WORD* pwAddr = ((PWORD)(dwIOAddress)); \ + volatile WORD* pwAddr = ((unsigned short *)(dwIOAddress)); \ writew((WORD)wData, pwAddr); \ } diff --git a/drivers/staging/vt6655/vntwifi.c b/drivers/staging/vt6655/vntwifi.c index 88c0ad420a41..ce60f7c7f8b4 100644 --- a/drivers/staging/vt6655/vntwifi.c +++ b/drivers/staging/vt6655/vntwifi.c @@ -533,7 +533,7 @@ void VNTWIFIvGetTxRate( void *pMgmtHandle, unsigned char *pbyDestAddress, - PWORD pwTxDataRate, + unsigned short *pwTxDataRate, unsigned char *pbyACKRate, unsigned char *pbyCCKBasicRate, unsigned char *pbyOFDMBasicRate diff --git a/drivers/staging/vt6655/vntwifi.h b/drivers/staging/vt6655/vntwifi.h index 6d14161e6de4..724cd4c9b6bc 100644 --- a/drivers/staging/vt6655/vntwifi.h +++ b/drivers/staging/vt6655/vntwifi.h @@ -240,7 +240,7 @@ void VNTWIFIvGetTxRate( void *pMgmtHandle, unsigned char *pbyDestAddress, - PWORD pwTxDataRate, + unsigned short *pwTxDataRate, unsigned char *pbyACKRate, unsigned char *pbyCCKBasicRate, unsigned char *pbyOFDMBasicRate diff --git a/drivers/staging/vt6655/wcmd.c b/drivers/staging/vt6655/wcmd.c index 4e7b457cb9a9..1eb4f6b596f9 100644 --- a/drivers/staging/vt6655/wcmd.c +++ b/drivers/staging/vt6655/wcmd.c @@ -1014,7 +1014,7 @@ BOOL bScheduleCommand ( break; /* case WLAN_CMD_DEAUTH: - pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].wDeAuthenReason = *((PWORD)pbyItem0); + pDevice->eCmdQueue[pDevice->uCmdEnqueueIdx].wDeAuthenReason = *((unsigned short *)pbyItem0); break; */ diff --git a/drivers/staging/vt6655/wmgr.c b/drivers/staging/vt6655/wmgr.c index 3994ed21d4fa..231a3e70436e 100644 --- a/drivers/staging/vt6655/wmgr.c +++ b/drivers/staging/vt6655/wmgr.c @@ -3329,11 +3329,11 @@ s_MgrMakeBeacon( // Pairwise Key Cipher Suite sFrame.pRSNWPA->wPKCount = 0; // Auth Key Management Suite - *((PWORD)(sFrame.pBuf + sFrame.len + sFrame.pRSNWPA->len))=0; + *((unsigned short *)(sFrame.pBuf + sFrame.len + sFrame.pRSNWPA->len))=0; sFrame.pRSNWPA->len +=2; // RSN Capabilites - *((PWORD)(sFrame.pBuf + sFrame.len + sFrame.pRSNWPA->len))=0; + *((unsigned short *)(sFrame.pBuf + sFrame.len + sFrame.pRSNWPA->len))=0; sFrame.pRSNWPA->len +=2; sFrame.len += sFrame.pRSNWPA->len + WLAN_IEHDR_LEN; } @@ -3800,7 +3800,7 @@ s_MgrMakeAssocRequest( (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) && (pMgmt->pCurrBSS != NULL)) { unsigned int ii; - PWORD pwPMKID; + unsigned short *pwPMKID; // WPA IE sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len); @@ -3865,7 +3865,7 @@ s_MgrMakeAssocRequest( if ((pDevice->gsPMKID.BSSIDInfoCount > 0) && (pDevice->bRoaming == TRUE) && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) { // RSN PMKID pbyRSN = &sFrame.pRSN->abyRSN[18]; - pwPMKID = (PWORD)pbyRSN; // Point to PMKID count + pwPMKID = (unsigned short *)pbyRSN; // Point to PMKID count *pwPMKID = 0; // Initialize PMKID count pbyRSN += 2; // Point to PMKID list for (ii = 0; ii < pDevice->gsPMKID.BSSIDInfoCount; ii++) { @@ -4056,7 +4056,7 @@ s_MgrMakeReAssocRequest( (pMgmt->eAuthenMode == WMAC_AUTH_WPA2PSK)) && (pMgmt->pCurrBSS != NULL)) { unsigned int ii; - PWORD pwPMKID; + unsigned short *pwPMKID; /* WPA IE */ sFrame.pRSN = (PWLAN_IE_RSN)(sFrame.pBuf + sFrame.len); @@ -4121,7 +4121,7 @@ s_MgrMakeReAssocRequest( if ((pDevice->gsPMKID.BSSIDInfoCount > 0) && (pDevice->bRoaming == TRUE) && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) { // RSN PMKID pbyRSN = &sFrame.pRSN->abyRSN[18]; - pwPMKID = (PWORD)pbyRSN; // Point to PMKID count + pwPMKID = (unsigned short *)pbyRSN; // Point to PMKID count *pwPMKID = 0; // Initialize PMKID count pbyRSN += 2; // Point to PMKID list for (ii = 0; ii < pDevice->gsPMKID.BSSIDInfoCount; ii++) { diff --git a/drivers/staging/vt6655/wpa.c b/drivers/staging/vt6655/wpa.c index d3b54c514026..4f81364dffea 100644 --- a/drivers/staging/vt6655/wpa.c +++ b/drivers/staging/vt6655/wpa.c @@ -211,7 +211,7 @@ WPA_ParseRSN ( pBSSList->byDefaultK_as_PK = (*pbyCaps) & WPA_GROUPFLAG; pBSSList->byReplayIdx = 2 << ((*pbyCaps >> WPA_REPLAYBITSSHIFT) & WPA_REPLAYBITS); pBSSList->sRSNCapObj.bRSNCapExist = TRUE; - pBSSList->sRSNCapObj.wRSNCap = *(PWORD)pbyCaps; + pBSSList->sRSNCapObj.wRSNCap = *(unsigned short *)pbyCaps; //DBG_PRN_GRP14(("pbyCaps: %X\n", *pbyCaps)); //DBG_PRN_GRP14(("byDefaultK_as_PK: %X\n", pBSSList->byDefaultK_as_PK)); //DBG_PRN_GRP14(("byReplayIdx: %X\n", pBSSList->byReplayIdx)); diff --git a/drivers/staging/vt6655/wpa2.c b/drivers/staging/vt6655/wpa2.c index e77fb08c9cf7..c4387de67c4d 100644 --- a/drivers/staging/vt6655/wpa2.c +++ b/drivers/staging/vt6655/wpa2.c @@ -164,7 +164,7 @@ WPA2vParseRSN ( } if (pRSN->len >= 8) { // ver(2) + GK(4) + PK count(2) - pBSSNode->wCSSPKCount = *((PWORD) &(pRSN->abyRSN[4])); + pBSSNode->wCSSPKCount = *((unsigned short *) &(pRSN->abyRSN[4])); j = 0; pbyOUI = &(pRSN->abyRSN[6]); @@ -213,10 +213,10 @@ WPA2vParseRSN ( DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wCSSPKCount: %d\n", pBSSNode->wCSSPKCount); } - m = *((PWORD) &(pRSN->abyRSN[4])); + m = *((unsigned short *) &(pRSN->abyRSN[4])); if (pRSN->len >= 10+m*4) { // ver(2) + GK(4) + PK count(2) + PKS(4*m) + AKMSS count(2) - pBSSNode->wAKMSSAuthCount = *((PWORD) &(pRSN->abyRSN[6+4*m]));; + pBSSNode->wAKMSSAuthCount = *((unsigned short *) &(pRSN->abyRSN[6+4*m]));; j = 0; pbyOUI = &(pRSN->abyRSN[8+4*m]); for (i = 0; (i < pBSSNode->wAKMSSAuthCount) && (j < sizeof(pBSSNode->abyAKMSSAuthType)/sizeof(BYTE)); i++) { @@ -235,10 +235,10 @@ WPA2vParseRSN ( pBSSNode->wAKMSSAuthCount = (WORD)j; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wAKMSSAuthCount: %d\n", pBSSNode->wAKMSSAuthCount); - n = *((PWORD) &(pRSN->abyRSN[6+4*m]));; + n = *((unsigned short *) &(pRSN->abyRSN[6+4*m]));; if (pRSN->len >= 12+4*m+4*n) { // ver(2)+GK(4)+PKCnt(2)+PKS(4*m)+AKMSSCnt(2)+AKMSS(4*n)+Cap(2) pBSSNode->sRSNCapObj.bRSNCapExist = TRUE; - pBSSNode->sRSNCapObj.wRSNCap = *((PWORD) &(pRSN->abyRSN[8+4*m+4*n])); + pBSSNode->sRSNCapObj.wRSNCap = *((unsigned short *) &(pRSN->abyRSN[8+4*m+4*n])); } } //ignore PMKID lists bcs only (Re)Assocrequest has this field @@ -270,7 +270,7 @@ WPA2uSetIEs( PSMgmtObject pMgmt = (PSMgmtObject) pMgmtHandle; unsigned char *pbyBuffer = NULL; unsigned int ii = 0; - PWORD pwPMKID = NULL; + unsigned short *pwPMKID = NULL; if (pRSNIEs == NULL) { return(0); @@ -342,7 +342,7 @@ WPA2uSetIEs( (pMgmt->bRoaming == TRUE) && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) { // RSN PMKID - pwPMKID = (PWORD)(&pRSNIEs->abyRSN[18]); // Point to PMKID count + pwPMKID = (unsigned short *)(&pRSNIEs->abyRSN[18]); // Point to PMKID count *pwPMKID = 0; // Initialize PMKID count pbyBuffer = &pRSNIEs->abyRSN[20]; // Point to PMKID list for (ii = 0; ii < pMgmt->gsPMKIDCache.BSSIDInfoCount; ii++) { From 9d828c458f77043ddd9626ee0cfa688dda99c0eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Sat, 5 Jun 2010 15:13:49 -0700 Subject: [PATCH 065/523] Staging: vt6655: remove PDWORD typedef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use unsigned long * instead. Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/aes_ccmp.c | 12 ++++---- drivers/staging/vt6655/dpc.c | 36 +++++++++++----------- drivers/staging/vt6655/ioctl.c | 2 +- drivers/staging/vt6655/key.c | 8 ++--- drivers/staging/vt6655/mac.c | 24 +++++++-------- drivers/staging/vt6655/mac.h | 18 +++++------ drivers/staging/vt6655/michael.c | 2 +- drivers/staging/vt6655/michael.h | 2 +- drivers/staging/vt6655/rxtx.c | 50 +++++++++++++++---------------- drivers/staging/vt6655/srom.c | 2 +- drivers/staging/vt6655/srom.h | 2 +- drivers/staging/vt6655/tether.c | 2 +- drivers/staging/vt6655/ttype.h | 2 -- drivers/staging/vt6655/upc.h | 4 +-- 14 files changed, 82 insertions(+), 84 deletions(-) diff --git a/drivers/staging/vt6655/aes_ccmp.c b/drivers/staging/vt6655/aes_ccmp.c index a77a104a69cb..ae5c0e4f13ab 100644 --- a/drivers/staging/vt6655/aes_ccmp.c +++ b/drivers/staging/vt6655/aes_ccmp.c @@ -112,9 +112,9 @@ BYTE dot3_table[256] = { void xor_128(BYTE *a, BYTE *b, BYTE *out) { -PDWORD dwPtrA = (PDWORD) a; -PDWORD dwPtrB = (PDWORD) b; -PDWORD dwPtrOut =(PDWORD) out; +unsigned long *dwPtrA = (unsigned long *) a; +unsigned long *dwPtrB = (unsigned long *) b; +unsigned long *dwPtrOut =(unsigned long *) out; (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++); (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++); @@ -125,9 +125,9 @@ PDWORD dwPtrOut =(PDWORD) out; void xor_32(BYTE *a, BYTE *b, BYTE *out) { -PDWORD dwPtrA = (PDWORD) a; -PDWORD dwPtrB = (PDWORD) b; -PDWORD dwPtrOut =(PDWORD) out; +unsigned long *dwPtrA = (unsigned long *) a; +unsigned long *dwPtrB = (unsigned long *) b; +unsigned long *dwPtrOut =(unsigned long *) out; (*dwPtrOut++) = (*dwPtrA++) ^ (*dwPtrB++); } diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index 98bc2552fa00..3f3f83a83191 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -125,7 +125,7 @@ static BOOL s_bHandleRxEncryption( PSKeyItem *pKeyOut, int * pbExtIV, unsigned short *pwRxTSC15_0, - PDWORD pdwRxTSC47_16 + unsigned long *pdwRxTSC47_16 ); static BOOL s_bHostWepRxEncryption( @@ -139,7 +139,7 @@ static BOOL s_bHostWepRxEncryption( unsigned char *pbyNewRsr, int * pbExtIV, unsigned short *pwRxTSC15_0, - PDWORD pdwRxTSC47_16 + unsigned long *pdwRxTSC47_16 ); @@ -800,8 +800,8 @@ device_receive_frame ( // Soft MIC if ((pKey != NULL) && (pKey->byCipherSuite == KEY_CTL_TKIP)) { if (bIsWEP) { - PDWORD pdwMIC_L; - PDWORD pdwMIC_R; + unsigned long *pdwMIC_L; + unsigned long *pdwMIC_R; DWORD dwMIC_Priority; DWORD dwMICKey0 = 0, dwMICKey1 = 0; DWORD dwLocalMIC_L = 0; @@ -810,19 +810,19 @@ device_receive_frame ( if (pMgmt->eCurrMode == WMAC_MODE_ESS_AP) { - dwMICKey0 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[24])); - dwMICKey1 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[28])); + dwMICKey0 = cpu_to_le32(*(unsigned long *)(&pKey->abyKey[24])); + dwMICKey1 = cpu_to_le32(*(unsigned long *)(&pKey->abyKey[28])); } else { if (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { - dwMICKey0 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[16])); - dwMICKey1 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[20])); + dwMICKey0 = cpu_to_le32(*(unsigned long *)(&pKey->abyKey[16])); + dwMICKey1 = cpu_to_le32(*(unsigned long *)(&pKey->abyKey[20])); } else if ((pKey->dwKeyIndex & BIT28) == 0) { - dwMICKey0 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[16])); - dwMICKey1 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[20])); + dwMICKey0 = cpu_to_le32(*(unsigned long *)(&pKey->abyKey[16])); + dwMICKey1 = cpu_to_le32(*(unsigned long *)(&pKey->abyKey[20])); } else { - dwMICKey0 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[24])); - dwMICKey1 = cpu_to_le32(*(PDWORD)(&pKey->abyKey[28])); + dwMICKey0 = cpu_to_le32(*(unsigned long *)(&pKey->abyKey[24])); + dwMICKey1 = cpu_to_le32(*(unsigned long *)(&pKey->abyKey[28])); } } @@ -836,8 +836,8 @@ device_receive_frame ( MIC_vGetMIC(&dwLocalMIC_L, &dwLocalMIC_R); MIC_vUnInit(); - pdwMIC_L = (PDWORD)(skb->data + 4 + FrameSize); - pdwMIC_R = (PDWORD)(skb->data + 4 + FrameSize + 4); + pdwMIC_L = (unsigned long *)(skb->data + 4 + FrameSize); + pdwMIC_R = (unsigned long *)(skb->data + 4 + FrameSize + 4); //DBG_PRN_GRP12(("RxL: %lx, RxR: %lx\n", *pdwMIC_L, *pdwMIC_R)); //DBG_PRN_GRP12(("LocalL: %lx, LocalR: %lx\n", dwLocalMIC_L, dwLocalMIC_R)); //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"dwMICKey0= %lx,dwMICKey1= %lx \n", dwMICKey0, dwMICKey1); @@ -1171,7 +1171,7 @@ static BOOL s_bHandleRxEncryption ( PSKeyItem *pKeyOut, int * pbExtIV, unsigned short *pwRxTSC15_0, - PDWORD pdwRxTSC47_16 + unsigned long *pdwRxTSC47_16 ) { unsigned int PayloadLen = FrameSize; @@ -1275,7 +1275,7 @@ static BOOL s_bHandleRxEncryption ( // TKIP/AES PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); // 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc - *pdwRxTSC47_16 = cpu_to_le32(*(PDWORD)(pbyIV + 4)); + *pdwRxTSC47_16 = cpu_to_le32(*(unsigned long *)(pbyIV + 4)); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ExtIV: %lx\n",*pdwRxTSC47_16); if (byDecMode == KEY_CTL_TKIP) { *pwRxTSC15_0 = cpu_to_le16(MAKEWORD(*(pbyIV+2), *pbyIV)); @@ -1318,7 +1318,7 @@ static BOOL s_bHostWepRxEncryption ( unsigned char *pbyNewRsr, int * pbExtIV, unsigned short *pwRxTSC15_0, - PDWORD pdwRxTSC47_16 + unsigned long *pdwRxTSC47_16 ) { unsigned int PayloadLen = FrameSize; @@ -1385,7 +1385,7 @@ static BOOL s_bHostWepRxEncryption ( // TKIP/AES PayloadLen -= (WLAN_HDR_ADDR3_LEN + 8 + 4); // 24 is 802.11 header, 8 is IV&ExtIV, 4 is crc - *pdwRxTSC47_16 = cpu_to_le32(*(PDWORD)(pbyIV + 4)); + *pdwRxTSC47_16 = cpu_to_le32(*(unsigned long *)(pbyIV + 4)); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ExtIV: %lx\n",*pdwRxTSC47_16); if (byDecMode == KEY_CTL_TKIP) { diff --git a/drivers/staging/vt6655/ioctl.c b/drivers/staging/vt6655/ioctl.c index cc4f4c1b4cc0..210ad80a329f 100644 --- a/drivers/staging/vt6655/ioctl.c +++ b/drivers/staging/vt6655/ioctl.c @@ -732,7 +732,7 @@ vConfigWEPKey ( pDevice->auWepKeyLength[dwKeyIndex] = uKeyLength; MACvSetDefaultKeyEntry(pDevice->PortOffset, uKeyLength, dwKeyIndex, - (PDWORD) &(pDevice->abyWepKey[dwKeyIndex][0]), pDevice->byLocalID); + (unsigned long *) &(pDevice->abyWepKey[dwKeyIndex][0]), pDevice->byLocalID); if (pDevice->eEncryptionStatus < Ndis802_11EncryptionNotSupported) { for(ii=0; iiabyKey[15] |= 0x80; } - MACvSetKeyEntry(dwIoBase, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pbyBSSID, (PDWORD)pKey->abyKey, byLocalID); + MACvSetKeyEntry(dwIoBase, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pbyBSSID, (unsigned long *)pKey->abyKey, byLocalID); if ((dwKeyIndex & USE_KEYRSC) == 0) { // RSC set by NIC @@ -317,7 +317,7 @@ BOOL KeybSetKey ( if (uKeyLength == WLAN_WEP104_KEYLEN) pKey->abyKey[15] |= 0x80; } - MACvSetKeyEntry(dwIoBase, pTable->KeyTable[j].wKeyCtl, j, uKeyIdx, pbyBSSID, (PDWORD)pKey->abyKey, byLocalID); + MACvSetKeyEntry(dwIoBase, pTable->KeyTable[j].wKeyCtl, j, uKeyIdx, pbyBSSID, (unsigned long *)pKey->abyKey, byLocalID); if ((dwKeyIndex & USE_KEYRSC) == 0) { // RSC set by NIC @@ -693,7 +693,7 @@ BOOL KeybSetDefaultKey ( if (uKeyLength == WLAN_WEP104_KEYLEN) pKey->abyKey[15] |= 0x80; } - MACvSetKeyEntry(dwIoBase, pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl, MAX_KEY_TABLE-1, uKeyIdx, pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID, (PDWORD)pKey->abyKey, byLocalID); + MACvSetKeyEntry(dwIoBase, pTable->KeyTable[MAX_KEY_TABLE-1].wKeyCtl, MAX_KEY_TABLE-1, uKeyIdx, pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID, (unsigned long *)pKey->abyKey, byLocalID); if ((dwKeyIndex & USE_KEYRSC) == 0) { // RSC set by NIC @@ -792,7 +792,7 @@ BOOL KeybSetAllGroupKey ( if (uKeyLength == WLAN_WEP104_KEYLEN) pKey->abyKey[15] |= 0x80; } - MACvSetKeyEntry(dwIoBase, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pTable->KeyTable[i].abyBSSID, (PDWORD)pKey->abyKey, byLocalID); + MACvSetKeyEntry(dwIoBase, pTable->KeyTable[i].wKeyCtl, i, uKeyIdx, pTable->KeyTable[i].abyBSSID, (unsigned long *)pKey->abyKey, byLocalID); if ((dwKeyIndex & USE_KEYRSC) == 0) { // RSC set by NIC diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c index 9d54b421f770..9ec1248bbf98 100644 --- a/drivers/staging/vt6655/mac.c +++ b/drivers/staging/vt6655/mac.c @@ -703,14 +703,14 @@ void MACvRestoreContext (DWORD_PTR dwIoBase, unsigned char *pbyCxtBuf) } // restore CURR_RX_DESC_ADDR, CURR_TX_DESC_ADDR - VNSvOutPortD(dwIoBase + MAC_REG_TXDMAPTR0, *(PDWORD)(pbyCxtBuf + MAC_REG_TXDMAPTR0)); - VNSvOutPortD(dwIoBase + MAC_REG_AC0DMAPTR, *(PDWORD)(pbyCxtBuf + MAC_REG_AC0DMAPTR)); - VNSvOutPortD(dwIoBase + MAC_REG_BCNDMAPTR, *(PDWORD)(pbyCxtBuf + MAC_REG_BCNDMAPTR)); + VNSvOutPortD(dwIoBase + MAC_REG_TXDMAPTR0, *(unsigned long *)(pbyCxtBuf + MAC_REG_TXDMAPTR0)); + VNSvOutPortD(dwIoBase + MAC_REG_AC0DMAPTR, *(unsigned long *)(pbyCxtBuf + MAC_REG_AC0DMAPTR)); + VNSvOutPortD(dwIoBase + MAC_REG_BCNDMAPTR, *(unsigned long *)(pbyCxtBuf + MAC_REG_BCNDMAPTR)); - VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR0, *(PDWORD)(pbyCxtBuf + MAC_REG_RXDMAPTR0)); + VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR0, *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR0)); - VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR1, *(PDWORD)(pbyCxtBuf + MAC_REG_RXDMAPTR1)); + VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR1, *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR1)); } @@ -737,22 +737,22 @@ BOOL MACbCompareContext (DWORD_PTR dwIoBase, unsigned char *pbyCxtBuf) // compare CURR_RX_DESC_ADDR, CURR_TX_DESC_ADDR VNSvInPortD(dwIoBase + MAC_REG_TXDMAPTR0, &dwData); - if (dwData != *(PDWORD)(pbyCxtBuf + MAC_REG_TXDMAPTR0)) { + if (dwData != *(unsigned long *)(pbyCxtBuf + MAC_REG_TXDMAPTR0)) { return FALSE; } VNSvInPortD(dwIoBase + MAC_REG_AC0DMAPTR, &dwData); - if (dwData != *(PDWORD)(pbyCxtBuf + MAC_REG_AC0DMAPTR)) { + if (dwData != *(unsigned long *)(pbyCxtBuf + MAC_REG_AC0DMAPTR)) { return FALSE; } VNSvInPortD(dwIoBase + MAC_REG_RXDMAPTR0, &dwData); - if (dwData != *(PDWORD)(pbyCxtBuf + MAC_REG_RXDMAPTR0)) { + if (dwData != *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR0)) { return FALSE; } VNSvInPortD(dwIoBase + MAC_REG_RXDMAPTR1, &dwData); - if (dwData != *(PDWORD)(pbyCxtBuf + MAC_REG_RXDMAPTR1)) { + if (dwData != *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR1)) { return FALSE; } @@ -1456,7 +1456,7 @@ BOOL MACbPSWakeup (DWORD_PTR dwIoBase) */ void MACvSetKeyEntry (DWORD_PTR dwIoBase, WORD wKeyCtl, unsigned int uEntryIdx, - unsigned int uKeyIdx, unsigned char *pbyAddr, PDWORD pdwKey, BYTE byLocalID) + unsigned int uKeyIdx, unsigned char *pbyAddr, unsigned long *pdwKey, BYTE byLocalID) { WORD wOffset; DWORD dwData; @@ -1551,7 +1551,7 @@ WORD wOffset; */ void MACvSetDefaultKeyEntry (DWORD_PTR dwIoBase, unsigned int uKeyLen, - unsigned int uKeyIdx, PDWORD pdwKey, BYTE byLocalID) + unsigned int uKeyIdx, unsigned long *pdwKey, BYTE byLocalID) { WORD wOffset; DWORD dwData; @@ -1667,7 +1667,7 @@ DWORD dwData; * */ void MACvSetDefaultTKIPKeyEntry (DWORD_PTR dwIoBase, unsigned int uKeyLen, - unsigned int uKeyIdx, PDWORD pdwKey, BYTE byLocalID) + unsigned int uKeyIdx, unsigned long *pdwKey, BYTE byLocalID) { WORD wOffset; DWORD dwData; diff --git a/drivers/staging/vt6655/mac.h b/drivers/staging/vt6655/mac.h index 24e9b7ae6e15..0ded9a6d46d0 100644 --- a/drivers/staging/vt6655/mac.h +++ b/drivers/staging/vt6655/mac.h @@ -714,37 +714,37 @@ #define MACvGetCurrRx0DescAddr(dwIoBase, pdwCurrDescAddr) \ { \ VNSvInPortD(dwIoBase + MAC_REG_RXDMAPTR0, \ - (PDWORD)pdwCurrDescAddr); \ + (unsigned long *)pdwCurrDescAddr); \ } #define MACvGetCurrRx1DescAddr(dwIoBase, pdwCurrDescAddr) \ { \ VNSvInPortD(dwIoBase + MAC_REG_RXDMAPTR1, \ - (PDWORD)pdwCurrDescAddr); \ + (unsigned long *)pdwCurrDescAddr); \ } #define MACvGetCurrTx0DescAddr(dwIoBase, pdwCurrDescAddr) \ { \ VNSvInPortD(dwIoBase + MAC_REG_TXDMAPTR0, \ - (PDWORD)pdwCurrDescAddr); \ + (unsigned long *)pdwCurrDescAddr); \ } #define MACvGetCurrAC0DescAddr(dwIoBase, pdwCurrDescAddr) \ { \ VNSvInPortD(dwIoBase + MAC_REG_AC0DMAPTR, \ - (PDWORD)pdwCurrDescAddr); \ + (unsigned long *)pdwCurrDescAddr); \ } #define MACvGetCurrSyncDescAddr(dwIoBase, pdwCurrDescAddr) \ { \ VNSvInPortD(dwIoBase + MAC_REG_SYNCDMAPTR, \ - (PDWORD)pdwCurrDescAddr); \ + (unsigned long *)pdwCurrDescAddr); \ } #define MACvGetCurrATIMDescAddr(dwIoBase, pdwCurrDescAddr) \ { \ VNSvInPortD(dwIoBase + MAC_REG_ATIMDMAPTR, \ - (PDWORD)pdwCurrDescAddr); \ + (unsigned long *)pdwCurrDescAddr); \ } \ // set the chip with current BCN tx descriptor address @@ -1140,14 +1140,14 @@ BOOL MACbFlushSYNCFifo(DWORD_PTR dwIoBase); BOOL MACbPSWakeup(DWORD_PTR dwIoBase); void MACvSetKeyEntry(DWORD_PTR dwIoBase, WORD wKeyCtl, unsigned int uEntryIdx, - unsigned int uKeyIdx, unsigned char *pbyAddr, PDWORD pdwKey, BYTE byLocalID); + unsigned int uKeyIdx, unsigned char *pbyAddr, unsigned long *pdwKey, BYTE byLocalID); void MACvDisableKeyEntry(DWORD_PTR dwIoBase, unsigned int uEntryIdx); void MACvSetDefaultKeyEntry(DWORD_PTR dwIoBase, unsigned int uKeyLen, - unsigned int uKeyIdx, PDWORD pdwKey, BYTE byLocalID); + unsigned int uKeyIdx, unsigned long *pdwKey, BYTE byLocalID); //void MACvEnableDefaultKey(DWORD_PTR dwIoBase, BYTE byLocalID); void MACvDisableDefaultKey(DWORD_PTR dwIoBase); void MACvSetDefaultTKIPKeyEntry(DWORD_PTR dwIoBase, unsigned int uKeyLen, - unsigned int uKeyIdx, PDWORD pdwKey, BYTE byLocalID); + unsigned int uKeyIdx, unsigned long *pdwKey, BYTE byLocalID); void MACvSetDefaultKeyCtl(DWORD_PTR dwIoBase, WORD wKeyCtl, unsigned int uEntryIdx, BYTE byLocalID); #endif // __MAC_H__ diff --git a/drivers/staging/vt6655/michael.c b/drivers/staging/vt6655/michael.c index 2a346307f4db..74c66b56498e 100644 --- a/drivers/staging/vt6655/michael.c +++ b/drivers/staging/vt6655/michael.c @@ -159,7 +159,7 @@ void MIC_vAppend (unsigned char *src, unsigned int nBytes) } } -void MIC_vGetMIC (PDWORD pdwL, PDWORD pdwR) +void MIC_vGetMIC (unsigned long *pdwL, unsigned long *pdwR) { // Append the minimum padding s_vAppendByte(0x5a); diff --git a/drivers/staging/vt6655/michael.h b/drivers/staging/vt6655/michael.h index ecb2912939c6..be399494aaa4 100644 --- a/drivers/staging/vt6655/michael.h +++ b/drivers/staging/vt6655/michael.h @@ -44,7 +44,7 @@ void MIC_vAppend(unsigned char *src, unsigned int nBytes); // Get the MIC result. Destination should accept 8 bytes of result. // This also resets the message to empty. -void MIC_vGetMIC(PDWORD pdwL, PDWORD pdwR); +void MIC_vGetMIC(unsigned long *pdwL, unsigned long *pdwR); /*--------------------- Export Macros ------------------------------*/ diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index f3051b10c136..478c140be11c 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -221,8 +221,8 @@ s_vFillTxKey ( unsigned char *pMICHDR ) { - PDWORD pdwIV = (PDWORD) pbyIVHead; - PDWORD pdwExtIV = (PDWORD) ((unsigned char *)pbyIVHead+4); + unsigned long *pdwIV = (unsigned long *) pbyIVHead; + unsigned long *pdwExtIV = (unsigned long *) ((unsigned char *)pbyIVHead+4); WORD wValue; PS802_11Header pMACHeader = (PS802_11Header)pbyHdrBuf; DWORD dwRevIVCounter; @@ -338,7 +338,7 @@ s_vSWencryption ( { unsigned int cbICVlen = 4; DWORD dwICV = 0xFFFFFFFFL; - PDWORD pdwICV; + unsigned long *pdwICV; if (pTransmitKey == NULL) return; @@ -347,7 +347,7 @@ s_vSWencryption ( //======================================================================= // Append ICV after payload dwICV = CRCdwGetCrc32Ex(pbyPayloadHead, wPayloadSize, dwICV);//ICV(Payload) - pdwICV = (PDWORD)(pbyPayloadHead + wPayloadSize); + pdwICV = (unsigned long *)(pbyPayloadHead + wPayloadSize); // finally, we must invert dwCRC to get the correct answer *pdwICV = cpu_to_le32(~dwICV); // RC4 encryption @@ -358,7 +358,7 @@ s_vSWencryption ( //======================================================================= //Append ICV after payload dwICV = CRCdwGetCrc32Ex(pbyPayloadHead, wPayloadSize, dwICV);//ICV(Payload) - pdwICV = (PDWORD)(pbyPayloadHead + wPayloadSize); + pdwICV = (unsigned long *)(pbyPayloadHead + wPayloadSize); // finally, we must invert dwCRC to get the correct answer *pdwICV = cpu_to_le32(~dwICV); // RC4 encryption @@ -1359,8 +1359,8 @@ s_cbFillTxBufHead ( unsigned int cbMICHDR = 0; DWORD dwMICKey0, dwMICKey1; DWORD dwMIC_Priority; - PDWORD pdwMIC_L; - PDWORD pdwMIC_R; + unsigned long *pdwMIC_L; + unsigned long *pdwMIC_R; DWORD dwSafeMIC_L, dwSafeMIC_R; //Fix "Last Frag Size" < "MIC length". BOOL bMIC2Frag = FALSE; unsigned int uMICFragLen = 0; @@ -1549,16 +1549,16 @@ s_cbFillTxBufHead ( ////////////////////////////////////////////////////////////////// if ((bNeedEncrypt == TRUE) && (pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { if (pDevice->pMgmt->eAuthenMode == WMAC_AUTH_WPANONE) { - dwMICKey0 = *(PDWORD)(&pTransmitKey->abyKey[16]); - dwMICKey1 = *(PDWORD)(&pTransmitKey->abyKey[20]); + dwMICKey0 = *(unsigned long *)(&pTransmitKey->abyKey[16]); + dwMICKey1 = *(unsigned long *)(&pTransmitKey->abyKey[20]); } else if ((pTransmitKey->dwKeyIndex & AUTHENTICATOR_KEY) != 0) { - dwMICKey0 = *(PDWORD)(&pTransmitKey->abyKey[16]); - dwMICKey1 = *(PDWORD)(&pTransmitKey->abyKey[20]); + dwMICKey0 = *(unsigned long *)(&pTransmitKey->abyKey[16]); + dwMICKey1 = *(unsigned long *)(&pTransmitKey->abyKey[20]); } else { - dwMICKey0 = *(PDWORD)(&pTransmitKey->abyKey[24]); - dwMICKey1 = *(PDWORD)(&pTransmitKey->abyKey[28]); + dwMICKey0 = *(unsigned long *)(&pTransmitKey->abyKey[24]); + dwMICKey1 = *(unsigned long *)(&pTransmitKey->abyKey[28]); } // DO Software Michael MIC_vInit(dwMICKey0, dwMICKey1); @@ -1760,8 +1760,8 @@ s_cbFillTxBufHead ( if (bMIC2Frag == FALSE) { if (uTmpLen != 0) MIC_vAppend((pbyBuffer + uLength), uTmpLen); - pdwMIC_L = (PDWORD)(pbyBuffer + uLength + uTmpLen); - pdwMIC_R = (PDWORD)(pbyBuffer + uLength + uTmpLen + 4); + pdwMIC_L = (unsigned long *)(pbyBuffer + uLength + uTmpLen); + pdwMIC_R = (unsigned long *)(pbyBuffer + uLength + uTmpLen + 4); MIC_vGetMIC(pdwMIC_L, pdwMIC_R); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Last MIC:%lX, %lX\n", *pdwMIC_L, *pdwMIC_R); } else { @@ -1895,8 +1895,8 @@ s_cbFillTxBufHead ( uMICFragLen = cbFragPayloadSize - uTmpLen; ASSERT(uMICFragLen < cbMIClen); - pdwMIC_L = (PDWORD)(pbyBuffer + uLength + uTmpLen); - pdwMIC_R = (PDWORD)(pbyBuffer + uLength + uTmpLen + 4); + pdwMIC_L = (unsigned long *)(pbyBuffer + uLength + uTmpLen); + pdwMIC_R = (unsigned long *)(pbyBuffer + uLength + uTmpLen + 4); MIC_vGetMIC(pdwMIC_L, pdwMIC_R); dwSafeMIC_L = *pdwMIC_L; dwSafeMIC_R = *pdwMIC_R; @@ -2035,8 +2035,8 @@ s_cbFillTxBufHead ( MIC_vAppend((pbyBuffer + uLength - cb802_1_H_len), cbFrameBodySize); - pdwMIC_L = (PDWORD)(pbyBuffer + uLength - cb802_1_H_len + cbFrameBodySize); - pdwMIC_R = (PDWORD)(pbyBuffer + uLength - cb802_1_H_len + cbFrameBodySize + 4); + pdwMIC_L = (unsigned long *)(pbyBuffer + uLength - cb802_1_H_len + cbFrameBodySize); + pdwMIC_R = (unsigned long *)(pbyBuffer + uLength - cb802_1_H_len + cbFrameBodySize + 4); MIC_vGetMIC(pdwMIC_L, pdwMIC_R); MIC_vUnInit(); @@ -2852,8 +2852,8 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, unsigned char *pbMPDU, un unsigned int uLength = 0; DWORD dwMICKey0, dwMICKey1; DWORD dwMIC_Priority; - PDWORD pdwMIC_L; - PDWORD pdwMIC_R; + unsigned long *pdwMIC_L; + unsigned long *pdwMIC_R; WORD wTxBufSize; unsigned int cbMacHdLen; SEthernetHeader sEthHeader; @@ -3127,8 +3127,8 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, unsigned char *pbMPDU, un if ((pTransmitKey != NULL) && (pTransmitKey->byCipherSuite == KEY_CTL_TKIP)) { - dwMICKey0 = *(PDWORD)(&pTransmitKey->abyKey[16]); - dwMICKey1 = *(PDWORD)(&pTransmitKey->abyKey[20]); + dwMICKey0 = *(unsigned long *)(&pTransmitKey->abyKey[16]); + dwMICKey1 = *(unsigned long *)(&pTransmitKey->abyKey[20]); // DO Software Michael MIC_vInit(dwMICKey0, dwMICKey1); @@ -3141,8 +3141,8 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb, unsigned char *pbMPDU, un MIC_vAppend((pbyTxBufferAddr + uLength), cbFrameBodySize); - pdwMIC_L = (PDWORD)(pbyTxBufferAddr + uLength + cbFrameBodySize); - pdwMIC_R = (PDWORD)(pbyTxBufferAddr + uLength + cbFrameBodySize + 4); + pdwMIC_L = (unsigned long *)(pbyTxBufferAddr + uLength + cbFrameBodySize); + pdwMIC_R = (unsigned long *)(pbyTxBufferAddr + uLength + cbFrameBodySize + 4); MIC_vGetMIC(pdwMIC_L, pdwMIC_R); MIC_vUnInit(); diff --git a/drivers/staging/vt6655/srom.c b/drivers/staging/vt6655/srom.c index cd4895ea45f6..26f7a9ca60aa 100644 --- a/drivers/staging/vt6655/srom.c +++ b/drivers/staging/vt6655/srom.c @@ -364,7 +364,7 @@ void SROMvWriteEtherAddress(DWORD_PTR dwIoBase, unsigned char *pbyEtherAddress) * Return Value: none * */ -void SROMvReadSubSysVenId(DWORD_PTR dwIoBase, PDWORD pdwSubSysVenId) +void SROMvReadSubSysVenId(DWORD_PTR dwIoBase, unsigned long *pdwSubSysVenId) { unsigned char *pbyData; diff --git a/drivers/staging/vt6655/srom.h b/drivers/staging/vt6655/srom.h index d51791491751..53e3f596a33f 100644 --- a/drivers/staging/vt6655/srom.h +++ b/drivers/staging/vt6655/srom.h @@ -150,7 +150,7 @@ void SROMvWriteAllContents(DWORD_PTR dwIoBase, unsigned char *pbyEepromRegs); void SROMvReadEtherAddress(DWORD_PTR dwIoBase, unsigned char *pbyEtherAddress); void SROMvWriteEtherAddress(DWORD_PTR dwIoBase, unsigned char *pbyEtherAddress); -void SROMvReadSubSysVenId(DWORD_PTR dwIoBase, PDWORD pdwSubSysVenId); +void SROMvReadSubSysVenId(DWORD_PTR dwIoBase, unsigned long *pdwSubSysVenId); BOOL SROMbAutoLoad (DWORD_PTR dwIoBase); diff --git a/drivers/staging/vt6655/tether.c b/drivers/staging/vt6655/tether.c index baf373931b6c..f654a718279a 100644 --- a/drivers/staging/vt6655/tether.c +++ b/drivers/staging/vt6655/tether.c @@ -101,7 +101,7 @@ BOOL ETHbIsBufferCrc32Ok (unsigned char *pbyBuffer, unsigned int cbFrameLength) DWORD dwCRC; dwCRC = CRCdwGetCrc32(pbyBuffer, cbFrameLength - 4); - if (cpu_to_le32(*((PDWORD)(pbyBuffer + cbFrameLength - 4))) != dwCRC) { + if (cpu_to_le32(*((unsigned long *)(pbyBuffer + cbFrameLength - 4))) != dwCRC) { return FALSE; } return TRUE; diff --git a/drivers/staging/vt6655/ttype.h b/drivers/staging/vt6655/ttype.h index 660bc5b20894..aaad1dbd957d 100644 --- a/drivers/staging/vt6655/ttype.h +++ b/drivers/staging/vt6655/ttype.h @@ -92,8 +92,6 @@ typedef unsigned long DWORD_PTR; // 32-bit // boolean pointer typedef unsigned int * PUINT; -typedef DWORD * PDWORD; - typedef QWORD * PQWORD; #endif // __TTYPE_H__ diff --git a/drivers/staging/vt6655/upc.h b/drivers/staging/vt6655/upc.h index ecf683feca39..7abd231c4d57 100644 --- a/drivers/staging/vt6655/upc.h +++ b/drivers/staging/vt6655/upc.h @@ -87,7 +87,7 @@ } #define VNSvInPortD(dwIOAddress, pdwData) { \ - volatile DWORD* pdwAddr = ((PDWORD)(dwIOAddress)); \ + volatile DWORD* pdwAddr = ((unsigned long *)(dwIOAddress)); \ *(pdwData) = readl(pdwAddr); \ } @@ -104,7 +104,7 @@ } #define VNSvOutPortD(dwIOAddress, dwData) { \ - volatile DWORD* pdwAddr = ((PDWORD)(dwIOAddress)); \ + volatile DWORD* pdwAddr = ((unsigned long *)(dwIOAddress)); \ writel((DWORD)dwData, pdwAddr); \ } From cf160bc9269fecba0a10e9957e8591fcc293dddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Thu, 3 Jun 2010 09:15:54 -0700 Subject: [PATCH 066/523] Staging: vt6655: include linux/ headers instead of asm/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 56e05f0fa963..9e236f745ce5 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -48,10 +48,10 @@ #include #include #include -#include +#include #include //#include -#include +#include #include #include #include From afb97d9a265f6001411df43d3ea523338c73c83f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 18 Jun 2010 10:30:21 -0700 Subject: [PATCH 067/523] Staging: vt6655: fix up U32 conversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 902d2411298a6e0b8a473a0163aa4bf6d5c8a073 converted U32 to u32 which you would think would be just fine. Unfortunatly, it seems that VIA only builds their code on a 32bit processor (which makes sense if you think about it), but this doesn't work on x86-64. So fix up the few places where this really wanted to be an unsigned long width. Cc: Charles Clément Cc: Forest Bond , Cc: Andres More Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device.h | 2 +- drivers/staging/vt6655/iwctl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 9e236f745ce5..bad32562a7fb 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -423,7 +423,7 @@ typedef struct __device_info { CHIP_TYPE chip_id; - u32 PortOffset; + unsigned long PortOffset; DWORD dwIsr; u32 memaddr; u32 ioaddr; diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c index a2b2bc5d4341..f3545071151c 100644 --- a/drivers/staging/vt6655/iwctl.c +++ b/drivers/staging/vt6655/iwctl.c @@ -116,7 +116,7 @@ struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev) pDevice->wstats.discard.nwid = 0; pDevice->wstats.discard.code = 0; pDevice->wstats.discard.fragment = 0; - pDevice->wstats.discard.retries = (u32)pDevice->scStatistic.dwTsrErr; + pDevice->wstats.discard.retries = (unsigned long)pDevice->scStatistic.dwTsrErr; pDevice->wstats.discard.misc = 0; pDevice->wstats.miss.beacon = 0; From 33d33e42b647095b01b1223c7b88718584129d2e Mon Sep 17 00:00:00 2001 From: Andres More Date: Wed, 19 May 2010 23:50:00 -0300 Subject: [PATCH 068/523] Staging: vt6656: code cleanup, fixed 'for' statements Resolved checkpatch findings, but some long lines warnings. ERROR: space required before the open parenthesis '(' ERROR: spaces required around that Signed-off-by: Andres More Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/bssdb.c | 70 +++++++++++++++++-------------- drivers/staging/vt6656/card.c | 7 ++-- drivers/staging/vt6656/channel.c | 45 ++++++++++---------- drivers/staging/vt6656/datarate.c | 10 ++--- drivers/staging/vt6656/dpc.c | 9 ++-- drivers/staging/vt6656/ioctl.c | 6 +-- drivers/staging/vt6656/iwctl.c | 24 +++++------ drivers/staging/vt6656/key.c | 22 ++++------ drivers/staging/vt6656/mac.c | 4 +- drivers/staging/vt6656/main_usb.c | 30 ++++++------- drivers/staging/vt6656/michael.c | 4 +- drivers/staging/vt6656/wctl.c | 21 +++++----- drivers/staging/vt6656/wmgr.c | 58 ++++++++++++------------- drivers/staging/vt6656/wpa.c | 6 ++- drivers/staging/vt6656/wpactl.c | 5 +-- 15 files changed, 161 insertions(+), 160 deletions(-) diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c index 36ed61b595ca..8d4b6633b96b 100644 --- a/drivers/staging/vt6656/bssdb.c +++ b/drivers/staging/vt6656/bssdb.c @@ -699,12 +699,14 @@ BOOL BSSbUpdateToBSSList(void *hDeviceContext, pBSSList->byRSSIStatCnt %= RSSI_STAT_COUNT; pBSSList->ldBmAverage[pBSSList->byRSSIStatCnt] = ldBm; ldBmSum = 0; - for(ii=0, jj=0;iildBmAverage[ii] != 0) { - pBSSList->ldBmMAX = max(pBSSList->ldBmAverage[ii], ldBm); - ldBmSum += pBSSList->ldBmAverage[ii]; - jj++; - } + for (ii = 0, jj = 0; ii < RSSI_STAT_COUNT; ii++) { + if (pBSSList->ldBmAverage[ii] != 0) { + pBSSList->ldBmMAX = + max(pBSSList->ldBmAverage[ii], ldBm); + ldBmSum += + pBSSList->ldBmAverage[ii]; + jj++; + } } pBSSList->ldBmAverRange = ldBmSum /jj; } @@ -1422,21 +1424,25 @@ void BSSvUpdateNodeTxCounter(void *hDeviceContext, (wRate < RATE_18M) ) { pMgmt->sNodeDBTable[0].uTxFail[wRate]+=byTxRetry; } else if (byFallBack == AUTO_FB_0) { - for(ii=0;iisNodeDBTable[0].uTxFail[wFallBackRate]++; - } + for (ii = 0; ii < byTxRetry; ii++) { + if (ii < 5) + wFallBackRate = + awHWRetry0[wRate-RATE_18M][ii]; + else + wFallBackRate = + awHWRetry0[wRate-RATE_18M][4]; + pMgmt->sNodeDBTable[0].uTxFail[wFallBackRate]++; + } } else if (byFallBack == AUTO_FB_1) { - for(ii=0;iisNodeDBTable[0].uTxFail[wFallBackRate]++; - } + for (ii = 0; ii < byTxRetry; ii++) { + if (ii < 5) + wFallBackRate = + awHWRetry1[wRate-RATE_18M][ii]; + else + wFallBackRate = + awHWRetry1[wRate-RATE_18M][4]; + pMgmt->sNodeDBTable[0].uTxFail[wFallBackRate]++; + } } } }; @@ -1476,21 +1482,23 @@ void BSSvUpdateNodeTxCounter(void *hDeviceContext, (wRate < RATE_18M) ) { pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wRate]+=byTxRetry; } else if (byFallBack == AUTO_FB_0) { - for(ii=0;iisNodeDBTable[uNodeIndex].uTxFail[wFallBackRate]++; + for (ii = 0; ii < byTxRetry; ii++) { + if (ii < 5) + wFallBackRate = + awHWRetry0[wRate-RATE_18M][ii]; + else + wFallBackRate = + awHWRetry0[wRate-RATE_18M][4]; + pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wFallBackRate]++; } } else if (byFallBack == AUTO_FB_1) { - for(ii=0;iisNodeDBTable[uNodeIndex].uTxFail[wFallBackRate]++; - } + pMgmt->sNodeDBTable[uNodeIndex].uTxFail[wFallBackRate]++; + } } } }; diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index fe4ec913ffea..35bf4fda330d 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -457,12 +457,11 @@ void CARDvSetRSPINF(void *pDeviceHandler, BYTE byBBType) abyData[14] = abySignal[3]; abyData[15] = abyServ[3]; - for(i=0;i<9;i++) { - abyData[16+i*2] = abyTxRate[i]; - abyData[16+i*2+1] = abyRsvTime[i]; + for (i = 0; i < 9; i++) { + abyData[16+i*2] = abyTxRate[i]; + abyData[16+i*2+1] = abyRsvTime[i]; } - CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE, MAC_REG_RSPINF_B_1, diff --git a/drivers/staging/vt6656/channel.c b/drivers/staging/vt6656/channel.c index f49b6e133394..6ad03e492edb 100644 --- a/drivers/staging/vt6656/channel.c +++ b/drivers/staging/vt6656/channel.c @@ -441,11 +441,10 @@ void CHvInitChannelTable(void *pDeviceHandler) { PSDevice pDevice = (PSDevice) pDeviceHandler; BOOL bMultiBand = FALSE; - unsigned int ii; + unsigned int ii; - for(ii=1;ii<=CB_MAX_CHANNEL;ii++) { - sChannelTbl[ii].bValid = FALSE; - } + for (ii = 1; ii <= CB_MAX_CHANNEL; ii++) + sChannelTbl[ii].bValid = FALSE; switch (pDevice->byRFType) { case RF_AL2230: @@ -464,43 +463,43 @@ void CHvInitChannelTable(void *pDeviceHandler) if ((pDevice->dwDiagRefCount != 0) || (pDevice->b11hEable == TRUE)) { if (bMultiBand == TRUE) { - for(ii=0;iiabyRegPwr[ii+1] = pDevice->abyOFDMDefaultPwr[ii+1]; //pDevice->abyLocalPwr[ii+1] = pDevice->abyOFDMDefaultPwr[ii+1]; - } - for(ii=0;iiabyRegPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1]; //pDevice->abyLocalPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1]; - } + } } else { - for(ii=0;iiabyRegPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1]; //pDevice->abyLocalPwr[ii+1] = pDevice->abyCCKDefaultPwr[ii+1]; - } + } } } else if (pDevice->byZoneType <= CCODE_MAX) { if (bMultiBand == TRUE) { - for(ii=0;iibyZoneType].bChannelIdxList[ii] != 0) { - sChannelTbl[ii+1].bValid = TRUE; + for (ii = 0; ii < CB_MAX_CHANNEL; ii++) { + if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) { + sChannelTbl[ii+1].bValid = TRUE; //pDevice->abyRegPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii]; //pDevice->abyLocalPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii]; - } - } + } + } } else { - for(ii=0;iibyZoneType].bChannelIdxList[ii] != 0) { - sChannelTbl[ii+1].bValid = TRUE; + for (ii = 0; ii < CB_MAX_CHANNEL_24G; ii++) { + if (ChannelRuleTab[pDevice->byZoneType].bChannelIdxList[ii] != 0) { + sChannelTbl[ii+1].bValid = TRUE; //pDevice->abyRegPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii]; //pDevice->abyLocalPwr[ii+1] = ChannelRuleTab[pDevice->byZoneType].byPower[ii]; - } - } + } + } } } DBG_PRT(MSG_LEVEL_NOTICE, KERN_INFO"Zone=[%d][%c][%c]!!\n",pDevice->byZoneType,ChannelRuleTab[pDevice->byZoneType].chCountryCode[0],ChannelRuleTab[pDevice->byZoneType].chCountryCode[1]); - for(ii=0;iiabyRegPwr[ii+1] == 0) { pDevice->abyRegPwr[ii+1] = pDevice->abyOFDMDefaultPwr[ii+1]; diff --git a/drivers/staging/vt6656/datarate.c b/drivers/staging/vt6656/datarate.c index 2e183ddbfd0e..51dc540da2fb 100644 --- a/drivers/staging/vt6656/datarate.c +++ b/drivers/staging/vt6656/datarate.c @@ -72,7 +72,7 @@ void s_vResetCounter(PKnownNodeDB psNodeDBTable) BYTE ii; // clear statistic counter for auto_rate - for(ii=0;ii<=MAX_RATE;ii++) { + for (ii = 0; ii <= MAX_RATE; ii++) { psNodeDBTable->uTxOk[ii] = 0; psNodeDBTable->uTxFail[ii] = 0; } @@ -337,7 +337,7 @@ DWORD dwTxDiff = 0; psNodeDBTable->uTimeCount = 0; } - for(ii=0;iiwSuppRate & (0x0001<wTxDataRate;ii++) { + for (ii = 0; ii <= psNodeDBTable->wTxDataRate; ii++) { if ( (psNodeDBTable->uTxOk[ii] != 0) || (psNodeDBTable->uTxFail[ii] != 0) ) { dwThroughputTbl[ii] *= psNodeDBTable->uTxOk[ii]; @@ -362,7 +362,7 @@ DWORD dwTxDiff = 0; dwThroughput = dwThroughputTbl[psNodeDBTable->wTxDataRate]; wIdxDownRate = psNodeDBTable->wTxDataRate; - for(ii = psNodeDBTable->wTxDataRate; ii > 0;) { + for (ii = psNodeDBTable->wTxDataRate; ii > 0;) { ii--; if ( (dwThroughputTbl[ii] > dwThroughput) && (bAutoRate[ii]==TRUE) ) { @@ -400,7 +400,7 @@ long ldBm; return; } - for(ii=0;iiwSuppRate & (0x0001<pCurrBSS->byRSSIStatCnt++; pMgmt->pCurrBSS->byRSSIStatCnt %= RSSI_STAT_COUNT; pMgmt->pCurrBSS->ldBmAverage[pMgmt->pCurrBSS->byRSSIStatCnt] = ldBm; - for(ii=0;iipCurrBSS->ldBmAverage[ii] != 0) { - pMgmt->pCurrBSS->ldBmMAX = max(pMgmt->pCurrBSS->ldBmAverage[ii], ldBm); - } + for (ii = 0; ii < RSSI_STAT_COUNT; ii++) { + if (pMgmt->pCurrBSS->ldBmAverage[ii] != 0) { + pMgmt->pCurrBSS->ldBmMAX = + max(pMgmt->pCurrBSS->ldBmAverage[ii], ldBm); + } } } */ diff --git a/drivers/staging/vt6656/ioctl.c b/drivers/staging/vt6656/ioctl.c index 19a84b66b097..7c32125fbd51 100644 --- a/drivers/staging/vt6656/ioctl.c +++ b/drivers/staging/vt6656/ioctl.c @@ -232,10 +232,10 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) { pDevice->bEncryptionEnable = FALSE; pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; spin_lock_irq(&pDevice->lock); - for(uu=0;uulock); - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable. \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "WEP function disable.\n"); break; } diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index fa40522d4a9a..8f28dbb8de53 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -653,7 +653,7 @@ int iwctl_giwrange(struct net_device *dev, // Should be based on cap_rid.country to give only // what the current card support k = 0; - for(i = 0; i < 14; i++) { + for (i = 0; i < 14; i++) { range->freq[k].i = i + 1; // List index range->freq[k].m = frequency_list[i] * 100000; range->freq[k++].e = 1; // Values in table in MHz -> * 10^5 * 10 @@ -669,7 +669,7 @@ int iwctl_giwrange(struct net_device *dev, range->max_qual.noise = 0; range->sensitivity = 255; - for(i = 0 ; i < 13 ; i++) { + for (i = 0 ; i < 13 ; i++) { range->bitrate[i] = abySupportedRates[i] * 500000; if(range->bitrate[i] == 0) break; @@ -1057,7 +1057,7 @@ int iwctl_siwrate(struct net_device *dev, u8 normvalue = (u8) (wrq->value/500000); // Check if rate is valid - for(i = 0 ; i < 13 ; i++) { + for (i = 0 ; i < 13 ; i++) { if(normvalue == abySupportedRates[i]) { brate = i; break; @@ -1067,7 +1067,7 @@ int iwctl_siwrate(struct net_device *dev, // -1 designed the max rate (mostly auto mode) if(wrq->value == -1) { // Get the highest available rate - for(i = 0 ; i < 13 ; i++) { + for (i = 0 ; i < 13 ; i++) { if(abySupportedRates[i] == 0) break; } @@ -1405,8 +1405,8 @@ int iwctl_siwencode(struct net_device *dev, pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; if (pDevice->flags & DEVICE_FLAGS_OPENED) { spin_lock_irq(&pDevice->lock); - for(uu=0;uulock); } } @@ -1935,14 +1935,14 @@ printk("param->u.wpa_key.set_tx =%d\n",param->u.wpa_key.set_tx); printk("param->u.wpa_key.key_index =%d\n",param->u.wpa_key.key_index); printk("param->u.wpa_key.key_len =%d\n",param->u.wpa_key.key_len); printk("param->u.wpa_key.key ="); -for(ii=0;iiu.wpa_key.key_len;ii++) - printk("%02x:",param->u.wpa_key.key[ii]); - printk("\n"); +for (ii = 0; ii < param->u.wpa_key.key_len; ii++) + printk(KERN_DEBUG "%02x:", param->u.wpa_key.key[ii]); +printk("\n"); printk("param->u.wpa_key.seq_len =%d\n",param->u.wpa_key.seq_len); printk("param->u.wpa_key.seq ="); -for(ii=0;iiu.wpa_key.seq_len;ii++) - printk("%02x:",param->u.wpa_key.seq[ii]); - printk("\n"); +for (ii = 0; ii < param->u.wpa_key.seq_len; ii++) + printk(KERN_DEBUG "%02x:", param->u.wpa_key.seq[ii]); +printk("\n"); printk("...........\n"); #endif diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c index b0890c181e7d..6a77ce35e708 100644 --- a/drivers/staging/vt6656/key.c +++ b/drivers/staging/vt6656/key.c @@ -485,9 +485,9 @@ BOOL KeybRemoveAllKey( if ((pTable->KeyTable[i].bInUse == TRUE) && IS_ETH_ADDRESS_EQUAL(pTable->KeyTable[i].abyBSSID,pbyBSSID)) { pTable->KeyTable[i].PairwiseKey.bKeyValid = FALSE; - for(u=0;uKeyTable[i].GroupKey[u].bKeyValid = FALSE; - } + for (u = 0; u < MAX_GROUP_KEY; u++) + pTable->KeyTable[i].GroupKey[u].bKeyValid = FALSE; + pTable->KeyTable[i].dwGTKeyIndex = 0; s_vCheckKeyTableValid(pDevice, pTable); return (TRUE); @@ -531,19 +531,13 @@ void KeyvRemoveWEPKey( return; } -void KeyvRemoveAllWEPKey( - void *pDeviceHandler, - PSKeyManagement pTable - ) +void KeyvRemoveAllWEPKey(void *pDeviceHandler, PSKeyManagement pTable) { - PSDevice pDevice = (PSDevice) pDeviceHandler; - - int i; - - for(i=0;i>8); pbyData[6] = (BYTE)(dwData2>>16); pbyData[7] = (BYTE)(dwData2>>24); - for(ii=8;ii<24;ii++) - pbyData[ii] = *pbyKey++; + for (ii = 8; ii < 24; ii++) + pbyData[ii] = *pbyKey++; CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_SETKEY, diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 098b0455e325..804047d4a448 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -407,8 +407,8 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) sInitCmd.byInitClass = (BYTE)InitType; sInitCmd.bExistSWNetAddr = (BYTE) pDevice->bExistSWNetAddr; - for(ii=0;ii<6;ii++) - sInitCmd.bySWNetAddr[ii] = pDevice->abyCurrentNetAddr[ii]; + for (ii = 0; ii < 6; ii++) + sInitCmd.bySWNetAddr[ii] = pDevice->abyCurrentNetAddr[ii]; sInitCmd.byShortRetryLimit = pDevice->byShortRetryLimit; sInitCmd.byLongRetryLimit = pDevice->byLongRetryLimit; @@ -487,10 +487,10 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) if(((pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Japan) || (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] == ZoneType_Europe))&& (pDevice->byOriginalZonetype == ZoneType_USA)) { - for(ii=11;ii<14;ii++) { - pDevice->abyCCKPwrTbl[ii] = pDevice->abyCCKPwrTbl[10]; - pDevice->abyOFDMPwrTbl[ii] = pDevice->abyOFDMPwrTbl[10]; - } + for (ii = 11; ii < 14; ii++) { + pDevice->abyCCKPwrTbl[ii] = pDevice->abyCCKPwrTbl[10]; + pDevice->abyOFDMPwrTbl[ii] = pDevice->abyOFDMPwrTbl[10]; + } } //{{ RobertYu: 20041124 @@ -1234,10 +1234,10 @@ device_release_WPADEV(pDevice); pMgmt->bShareKeyAlgorithm = FALSE; pDevice->bEncryptionEnable = FALSE; pDevice->eEncryptionStatus = Ndis802_11EncryptionDisabled; - spin_lock_irq(&pDevice->lock); - for(uu=0;uulock); + for (uu = 0; uu < MAX_KEY_TABLE; uu++) MACvDisableKeyEntry(pDevice,uu); - spin_unlock_irq(&pDevice->lock); + spin_unlock_irq(&pDevice->lock); if ((pDevice->flags & DEVICE_FLAGS_UNPLUG) == FALSE) { MACbShutdown(pDevice); @@ -1447,12 +1447,12 @@ static int Config_FileGetParameter(unsigned char *string, return FALSE; //check if current config line is marked by "#" ?? -for(ii=1;;ii++) { - if(memcmp(start_p-ii,"\n",1)==0) - break; - if(memcmp(start_p-ii,"#",1)==0) - return FALSE; -} + for (ii = 1; ; ii++) { + if (memcmp(start_p - ii, "\n", 1) == 0) + break; + if (memcmp(start_p - ii, "#", 1) == 0) + return FALSE; + } //find target string end point end_p = kstrstr(start_p,"\n"); diff --git a/drivers/staging/vt6656/michael.c b/drivers/staging/vt6656/michael.c index 671a8cf33e23..4d419814f27f 100644 --- a/drivers/staging/vt6656/michael.c +++ b/drivers/staging/vt6656/michael.c @@ -74,7 +74,7 @@ static DWORD s_dwGetUINT32 (BYTE * p) { DWORD res = 0; unsigned int i; - for(i=0; i<4; i++ ) + for (i = 0; i < 4; i++) res |= (*p++) << (8*i); return res; } @@ -83,7 +83,7 @@ static void s_vPutUINT32(BYTE *p, DWORD val) // Convert from DWORD to BYTE[] in a portable way { unsigned int i; - for(i=0; i<4; i++ ) { + for (i = 0; i < 4; i++) { *p++ = (BYTE) (val & 0xff); val >>= 8; } diff --git a/drivers/staging/vt6656/wctl.c b/drivers/staging/vt6656/wctl.c index 857ce0bc00a4..0a41bbe24e6c 100644 --- a/drivers/staging/vt6656/wctl.c +++ b/drivers/staging/vt6656/wctl.c @@ -111,22 +111,21 @@ BOOL WCTLbIsDuplicate (PSCache pCache, PS802_11Header pMACHeader) * Return Value: index number in Defragment Database * */ + unsigned int WCTLuSearchDFCB(PSDevice pDevice, PS802_11Header pMACHeader) { unsigned int ii; - for(ii=0;iicbDFCB;ii++) { - if ((pDevice->sRxDFCB[ii].bInUse == TRUE) && - (IS_ETH_ADDRESS_EQUAL (&(pDevice->sRxDFCB[ii].abyAddr2[0]), &(pMACHeader->abyAddr2[0]))) - ) { - // - return(ii); - } - } - return(pDevice->cbDFCB); + for (ii = 0; ii < pDevice->cbDFCB; ii++) { + if ((pDevice->sRxDFCB[ii].bInUse == TRUE) && + (IS_ETH_ADDRESS_EQUAL(&(pDevice->sRxDFCB[ii].abyAddr2[0]), + &(pMACHeader->abyAddr2[0])))) { + return ii; + } + } + return pDevice->cbDFCB; } - /* * Description: * Insert received fragment packet in Defragment Database @@ -147,7 +146,7 @@ unsigned int WCTLuInsertDFCB(PSDevice pDevice, PS802_11Header pMACHeader) if (pDevice->cbFreeDFCB == 0) return(pDevice->cbDFCB); - for(ii=0;iicbDFCB;ii++) { + for (ii = 0; ii < pDevice->cbDFCB; ii++) { if (pDevice->sRxDFCB[ii].bInUse == FALSE) { pDevice->cbFreeDFCB--; pDevice->sRxDFCB[ii].uLifetime = pDevice->dwMaxReceiveLifetime; diff --git a/drivers/staging/vt6656/wmgr.c b/drivers/staging/vt6656/wmgr.c index 93c15f0580fe..2bca1589ddb1 100644 --- a/drivers/staging/vt6656/wmgr.c +++ b/drivers/staging/vt6656/wmgr.c @@ -353,9 +353,9 @@ void vMgrObjectInit(void *hDeviceContext) pMgmt->pbyPSPacketPool = &pMgmt->byPSPacketPool[0]; pMgmt->pbyMgmtPacketPool = &pMgmt->byMgmtPacketPool[0]; pMgmt->uCurrChannel = pDevice->uChannel; - for(ii=0;iiabyDesireBSSID[ii] = 0xFF; - } + for (ii = 0; ii < WLAN_BSSID_LEN; ii++) + pMgmt->abyDesireBSSID[ii] = 0xFF; + pMgmt->sAssocInfo.AssocInfo.Length = sizeof(NDIS_802_11_ASSOCIATION_INFORMATION); //memset(pMgmt->abyDesireSSID, 0, WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN +1); pMgmt->byCSSPK = KEY_CTL_NONE; @@ -4795,21 +4795,21 @@ s_bCipherMatch ( byMulticastCipher = KEY_CTL_INVALID; } - // check Pairwise Key Cipher - for(i=0;iwCSSPKCount;i++) { - if ((pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_WEP40) || - (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_WEP104)) { - // this should not happen as defined 802.11i - byCipherMask |= 0x01; - } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_TKIP) { - byCipherMask |= 0x02; - } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_CCMP) { - byCipherMask |= 0x04; - } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_USE_GROUP) { - // use group key only ignore all others - byCipherMask = 0; - i = pBSSNode->wCSSPKCount; - } + /* check Pairwise Key Cipher */ + for (i = 0; i < pBSSNode->wCSSPKCount; i++) { + if ((pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_WEP40) || + (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_WEP104)) { + /* this should not happen as defined 802.11i */ + byCipherMask |= 0x01; + } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_TKIP) { + byCipherMask |= 0x02; + } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_CCMP) { + byCipherMask |= 0x04; + } else if (pBSSNode->abyCSSPK[i] == WLAN_11i_CSS_USE_GROUP) { + /* use group key only ignore all others */ + byCipherMask = 0; + i = pBSSNode->wCSSPKCount; + } } } else if ((WLAN_GET_CAP_INFO_PRIVACY(pBSSNode->wCapInfo) != 0) && @@ -4828,17 +4828,17 @@ s_bCipherMatch ( byMulticastCipher = KEY_CTL_INVALID; } - // check Pairwise Key Cipher - for(i=0;iwPKCount;i++) { - if (pBSSNode->abyPKType[i] == WPA_TKIP) { - byCipherMask |= 0x02; - } else if (pBSSNode->abyPKType[i] == WPA_AESCCMP) { - byCipherMask |= 0x04; - } else if (pBSSNode->abyPKType[i] == WPA_NONE) { - // use group key only ignore all others - byCipherMask = 0; - i = pBSSNode->wPKCount; - } + /* check Pairwise Key Cipher */ + for (i = 0; i < pBSSNode->wPKCount; i++) { + if (pBSSNode->abyPKType[i] == WPA_TKIP) { + byCipherMask |= 0x02; + } else if (pBSSNode->abyPKType[i] == WPA_AESCCMP) { + byCipherMask |= 0x04; + } else if (pBSSNode->abyPKType[i] == WPA_NONE) { + /* use group key only ignore all others */ + byCipherMask = 0; + i = pBSSNode->wPKCount; + } } } diff --git a/drivers/staging/vt6656/wpa.c b/drivers/staging/vt6656/wpa.c index 1fa6c9b88ed3..f492778ee8b6 100644 --- a/drivers/staging/vt6656/wpa.c +++ b/drivers/staging/vt6656/wpa.c @@ -148,7 +148,8 @@ WPA_ParseRSN ( { j = 0; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wPKCount: %d, sizeof(pBSSList->abyPKType): %zu\n", pRSN->wPKCount, sizeof(pBSSList->abyPKType)); - for(i = 0; (i < pRSN->wPKCount) && (j < sizeof(pBSSList->abyPKType)/sizeof(BYTE)); i++) { + for (i = 0; (i < pRSN->wPKCount) && + (j < sizeof(pBSSList->abyPKType)/sizeof(BYTE)); i++) { if(pRSN->len >= 12+i*4+4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*i) if ( !memcmp(pRSN->PKSList[i].abyOUI, abyOUI00, 4)) pBSSList->abyPKType[j++] = WPA_NONE; @@ -180,7 +181,8 @@ WPA_ParseRSN ( j = 0; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"wAuthCount: %d, sizeof(pBSSList->abyAuthType): %zu\n", pIE_RSN_Auth->wAuthCount, sizeof(pBSSList->abyAuthType)); - for(i = 0; (i < pIE_RSN_Auth->wAuthCount) && (j < sizeof(pBSSList->abyAuthType)/sizeof(BYTE)); i++) { + for (i = 0; (i < pIE_RSN_Auth->wAuthCount) && + (j < sizeof(pBSSList->abyAuthType)/sizeof(BYTE)); i++) { if(pRSN->len >= 14+4+(m+i)*4) { //oui1(4)+ver(2)+GKS(4)+PKSCnt(2)+PKS(4*m)+AKC(2)+AKS(4*i) if ( !memcmp(pIE_RSN_Auth->AuthKSList[i].abyOUI, abyOUI01, 4)) pBSSList->abyAuthType[j++] = WPA_AUTH_IEEE802_1X; diff --git a/drivers/staging/vt6656/wpactl.c b/drivers/staging/vt6656/wpactl.c index 961f583368a1..c886722a54bc 100644 --- a/drivers/staging/vt6656/wpactl.c +++ b/drivers/staging/vt6656/wpactl.c @@ -186,7 +186,6 @@ int wpa_set_wpadev(PSDevice pDevice, int val) return wpa_release_wpadev(pDevice); } - /* * Description: * Set WPA algorithm & keys @@ -647,9 +646,9 @@ static int wpa_get_scan(PSDevice pDevice, for (ii = 0; ii < MAX_BSS_NUM; ii++) { - for(jj=0;jjsBSSList[jj].bActive!=TRUE) || + if ((pMgmt->sBSSList[jj].bActive != TRUE) || ((pMgmt->sBSSList[jj].uRSSI>pMgmt->sBSSList[jj+1].uRSSI) &&(pMgmt->sBSSList[jj+1].bActive!=FALSE))) { From d9d1ccb51f60cc211e0aa8d132bc3487053b2b1d Mon Sep 17 00:00:00 2001 From: Andres More Date: Wed, 26 May 2010 20:00:36 -0300 Subject: [PATCH 069/523] Staging: vt6656: code cleanup, resolved checkpatch findings in headers Resolved whitespace-related checkpatch findings in .h files Signed-off-by: Andres More Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/80211mgr.h | 31 ++++------- drivers/staging/vt6656/baseband.h | 19 +++---- drivers/staging/vt6656/bssdb.h | 8 +-- drivers/staging/vt6656/channel.h | 12 ++--- drivers/staging/vt6656/control.h | 14 +++-- drivers/staging/vt6656/desc.h | 79 +++++++++++++---------------- drivers/staging/vt6656/device.h | 42 +++++---------- drivers/staging/vt6656/device_cfg.h | 16 ++---- drivers/staging/vt6656/int.h | 2 +- drivers/staging/vt6656/iocmd.h | 14 ++--- drivers/staging/vt6656/iowpa.h | 47 +++++++---------- drivers/staging/vt6656/iwctl.h | 4 +- drivers/staging/vt6656/mac.h | 8 +-- drivers/staging/vt6656/mib.h | 14 ++--- drivers/staging/vt6656/michael.h | 6 +-- drivers/staging/vt6656/rf.h | 19 ++----- drivers/staging/vt6656/rndis.h | 2 +- drivers/staging/vt6656/tether.h | 6 +-- drivers/staging/vt6656/ttype.h | 2 +- drivers/staging/vt6656/wmgr.h | 2 +- drivers/staging/vt6656/wpa2.h | 18 ++----- 21 files changed, 136 insertions(+), 229 deletions(-) diff --git a/drivers/staging/vt6656/80211mgr.h b/drivers/staging/vt6656/80211mgr.h index c140a957d9df..7f939e3bf175 100644 --- a/drivers/staging/vt6656/80211mgr.h +++ b/drivers/staging/vt6656/80211mgr.h @@ -222,46 +222,39 @@ #define MEASURE_MODE_INCAPABLE 0x02 #define MEASURE_MODE_REFUSED 0x04 - - /*--------------------- Export Classes ----------------------------*/ /*--------------------- Export Variables --------------------------*/ /*--------------------- Export Types ------------------------------*/ - // Information Element Types #pragma pack(1) typedef struct tagWLAN_IE { BYTE byElementID; BYTE len; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) WLAN_IE, *PWLAN_IE; - // Service Set Identity (SSID) #pragma pack(1) typedef struct tagWLAN_IE_SSID { BYTE byElementID; BYTE len; BYTE abySSID[1]; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) WLAN_IE_SSID, *PWLAN_IE_SSID; - // Supported Rates #pragma pack(1) typedef struct tagWLAN_IE_SUPP_RATES { BYTE byElementID; BYTE len; BYTE abyRates[1]; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) WLAN_IE_SUPP_RATES, *PWLAN_IE_SUPP_RATES; - - // FH Parameter Set #pragma pack(1) typedef struct _WLAN_IE_FH_PARMS { @@ -279,10 +272,9 @@ typedef struct tagWLAN_IE_DS_PARMS { BYTE byElementID; BYTE len; BYTE byCurrChannel; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) WLAN_IE_DS_PARMS, *PWLAN_IE_DS_PARMS; - // CF Parameter Set #pragma pack(1) typedef struct tagWLAN_IE_CF_PARMS { @@ -292,10 +284,9 @@ typedef struct tagWLAN_IE_CF_PARMS { BYTE byCFPPeriod; WORD wCFPMaxDuration; WORD wCFPDurRemaining; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) WLAN_IE_CF_PARMS, *PWLAN_IE_CF_PARMS; - // TIM #pragma pack(1) typedef struct tagWLAN_IE_TIM { @@ -305,30 +296,27 @@ typedef struct tagWLAN_IE_TIM { BYTE byDTIMPeriod; BYTE byBitMapCtl; BYTE byVirtBitMap[1]; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) WLAN_IE_TIM, *PWLAN_IE_TIM; - // IBSS Parameter Set #pragma pack(1) typedef struct tagWLAN_IE_IBSS_PARMS { BYTE byElementID; BYTE len; WORD wATIMWindow; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) WLAN_IE_IBSS_PARMS, *PWLAN_IE_IBSS_PARMS; - // Challenge Text #pragma pack(1) typedef struct tagWLAN_IE_CHALLENGE { BYTE byElementID; BYTE len; BYTE abyChallenge[1]; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) WLAN_IE_CHALLENGE, *PWLAN_IE_CHALLENGE; - #pragma pack(1) typedef struct tagWLAN_IE_RSN_EXT { BYTE byElementID; @@ -391,10 +379,9 @@ typedef struct tagWLAN_IE_ERP { BYTE byElementID; BYTE len; BYTE byContext; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) WLAN_IE_ERP, *PWLAN_IE_ERP; - #pragma pack(1) typedef struct _MEASEURE_REQ { BYTE byChannel; diff --git a/drivers/staging/vt6656/baseband.h b/drivers/staging/vt6656/baseband.h index bc4633d5fead..8db8cd07d5f5 100644 --- a/drivers/staging/vt6656/baseband.h +++ b/drivers/staging/vt6656/baseband.h @@ -104,16 +104,13 @@ BBuGetFrameTime( WORD wRate ); -void -BBvCaculateParameter ( - PSDevice pDevice, - unsigned int cbFrameLength, - WORD wRate, - BYTE byPacketType, - PWORD pwPhyLen, - PBYTE pbyPhySrv, - PBYTE pbyPhySgn - ); +void BBvCaculateParameter(PSDevice pDevice, + unsigned int cbFrameLength, + WORD wRate, + BYTE byPacketType, + PWORD pwPhyLen, + PBYTE pbyPhySrv, + PBYTE pbyPhySgn); // timer for antenna diversity @@ -128,7 +125,7 @@ void BBvSoftwareReset(PSDevice pDevice); void BBvSetShortSlotTime(PSDevice pDevice); void BBvSetVGAGainOffset(PSDevice pDevice, BYTE byData); void BBvSetAntennaMode(PSDevice pDevice, BYTE byAntennaMode); -BOOL BBbVT3184Init (PSDevice pDevice); +BOOL BBbVT3184Init(PSDevice pDevice); void BBvSetDeepSleep(PSDevice pDevice); void BBvExitDeepSleep(PSDevice pDevice); void BBvUpdatePreEDThreshold( diff --git a/drivers/staging/vt6656/bssdb.h b/drivers/staging/vt6656/bssdb.h index 9686d8600d63..c3aaefec93e3 100644 --- a/drivers/staging/vt6656/bssdb.h +++ b/drivers/staging/vt6656/bssdb.h @@ -40,7 +40,7 @@ #define MAX_NODE_NUM 64 #define MAX_BSS_NUM 42 -#define LOST_BEACON_COUNT 10 // 10 sec, XP defined +#define LOST_BEACON_COUNT 10 /* 10 sec, XP defined */ #define MAX_PS_TX_BUF 32 // sta max power saving tx buf #define ADHOC_LOST_BEACON_COUNT 30 // 30 sec, beacon lost for adhoc only #define MAX_INACTIVE_COUNT 300 // 300 sec, inactive STA node refresh @@ -83,13 +83,13 @@ typedef struct tagSERPObject { BOOL bERPExist; BYTE byERP; -}ERPObject, *PERPObject; +} ERPObject, *PERPObject; typedef struct tagSRSNCapObject { BOOL bRSNCapExist; WORD wRSNCap; -}SRSNCapObject, *PSRSNCapObject; +} SRSNCapObject, *PSRSNCapObject; // BSS info(AP) #pragma pack(1) @@ -153,7 +153,7 @@ typedef struct tagKnownBSS { SRSNCapObject sRSNCapObj; BYTE abyIEs[1024]; // don't move this field !! -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) KnownBSS , *PKnownBSS; diff --git a/drivers/staging/vt6656/channel.h b/drivers/staging/vt6656/channel.h index 91c2ffc6f1f0..e7b3c1231825 100644 --- a/drivers/staging/vt6656/channel.h +++ b/drivers/staging/vt6656/channel.h @@ -35,23 +35,21 @@ /*--------------------- Export Definitions -------------------------*/ /*--------------------- Export Classes ----------------------------*/ + typedef struct tagSChannelTblElement { BYTE byChannelNumber; unsigned int uFrequency; BOOL bValid; -}SChannelTblElement, *PSChannelTblElement; +} SChannelTblElement, *PSChannelTblElement; /*--------------------- Export Variables --------------------------*/ /*--------------------- Export Functions --------------------------*/ + BOOL ChannelValid(unsigned int CountryCode, unsigned int ChannelNum); void CHvInitChannelTable(void *pDeviceHandler); BYTE CHbyGetChannelMapping(BYTE byChannelNumber); -BOOL -CHvChannelGetList ( - unsigned int uCountryCodeIdx, - PBYTE pbyChannelTable - ); +BOOL CHvChannelGetList(unsigned int uCountryCodeIdx, PBYTE pbyChannelTable); -#endif /* _REGULATE_H_ */ +#endif /* _CHANNEL_H_ */ diff --git a/drivers/staging/vt6656/control.h b/drivers/staging/vt6656/control.h index 146b450e13d0..bbe610fd8b5a 100644 --- a/drivers/staging/vt6656/control.h +++ b/drivers/staging/vt6656/control.h @@ -36,16 +36,14 @@ /*--------------------- Export Definitions -------------------------*/ +#define CONTROLnsRequestOut(Device, Request, Value, Index, Length, Buffer) \ + PIPEnsControlOut(Device, Request, Value, Index, Length, Buffer) -#define CONTROLnsRequestOut( Device,Request,Value,Index,Length,Buffer) \ - PIPEnsControlOut( Device,Request,Value,Index,Length,Buffer) - -#define CONTROLnsRequestOutAsyn( Device,Request,Value,Index,Length,Buffer) \ - PIPEnsControlOutAsyn( Device,Request,Value,Index,Length,Buffer) - -#define CONTROLnsRequestIn( Device,Request,Value,Index,Length,Buffer) \ - PIPEnsControlIn( Device,Request,Value,Index,Length,Buffer) +#define CONTROLnsRequestOutAsyn(Device, Request, Value, Index, Length, Buffer) \ + PIPEnsControlOutAsyn(Device, Request, Value, Index, Length, Buffer) +#define CONTROLnsRequestIn(Device, Request, Value, Index, Length, Buffer) \ + PIPEnsControlIn(Device, Request, Value, Index, Length, Buffer) /*--------------------- Export Classes ----------------------------*/ diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index 07f794ec6db2..767112b3c4a9 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -51,7 +51,6 @@ #define MAX_INTERRUPT_SIZE 32 - #define RX_BLOCKS 64 // form 0x60 to 0xA0 #define TX_BLOCKS 32 // from 0xA0 to 0xC0 @@ -63,8 +62,6 @@ #define CB_RD_NUM 64 // default # of RD #define CB_TD_NUM 64 // default # of TD - - // // Bits in the RSR register // @@ -87,7 +84,6 @@ #define NEWRSR_BCNHITAID 0x02 // 0000 0010 #define NEWRSR_BCNHITAID0 0x01 // 0000 0001 - // // Bits in the TSR register // @@ -96,17 +92,13 @@ #define TSR_ACKDATA 0x02 // 0000 0010 #define TSR_VALID 0x01 // 0000 0001 - #define CB_PROTOCOL_RESERVED_SECTION 16 - - // if retrys excess 15 times , tx will abort, and // if tx fifo underflow, tx will fail // we should try to resend it #define CB_MAX_TX_ABORT_RETRY 3 - #define FIFOCTL_AUTO_FB_1 0x1000 // 0001 0000 0000 0000 #define FIFOCTL_AUTO_FB_0 0x0800 // 0000 1000 0000 0000 #define FIFOCTL_GRPACK 0x0400 // 0000 0100 0000 0000 @@ -137,7 +129,6 @@ #define FRAGCTL_STAFRAG 0x0001 // 0000 0000 0000 0001 #define FRAGCTL_NONFRAG 0x0000 // 0000 0000 0000 0000 - //#define TYPE_AC0DMA 0 //#define TYPE_TXDMA0 1 #define TYPE_TXDMA0 0 @@ -152,8 +143,6 @@ #define TYPE_RXDMA1 1 #define TYPE_MAXRD 2 - - // TD_INFO flags control bit #define TD_FLAGS_NETIF_SKB 0x01 // check if need release skb #define TD_FLAGS_PRIV_SKB 0x02 // check if called from private skb(hostap) @@ -162,7 +151,6 @@ /*--------------------- Export Types ------------------------------*/ - // // RsvTime buffer header // @@ -173,8 +161,9 @@ typedef struct tagSRrvTime_gRTS { WORD wReserved; WORD wTxRrvTime_b; WORD wTxRrvTime_a; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) SRrvTime_gRTS, *PSRrvTime_gRTS; + typedef const SRrvTime_gRTS *PCSRrvTime_gRTS; typedef struct tagSRrvTime_gCTS { @@ -182,22 +171,25 @@ typedef struct tagSRrvTime_gCTS { WORD wReserved; WORD wTxRrvTime_b; WORD wTxRrvTime_a; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) SRrvTime_gCTS, *PSRrvTime_gCTS; + typedef const SRrvTime_gCTS *PCSRrvTime_gCTS; typedef struct tagSRrvTime_ab { WORD wRTSTxRrvTime; WORD wTxRrvTime; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) SRrvTime_ab, *PSRrvTime_ab; + typedef const SRrvTime_ab *PCSRrvTime_ab; typedef struct tagSRrvTime_atim { WORD wCTSTxRrvTime_ba; WORD wTxRrvTime_a; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) SRrvTime_atim, *PSRrvTime_atim; + typedef const SRrvTime_atim *PCSRrvTime_atim; // @@ -208,8 +200,9 @@ typedef struct tagSRTSData { WORD wDurationID; BYTE abyRA[ETH_ALEN]; BYTE abyTA[ETH_ALEN]; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) SRTSData, *PSRTSData; + typedef const SRTSData *PCSRTSData; typedef struct tagSRTS_g { @@ -224,11 +217,10 @@ typedef struct tagSRTS_g { WORD wDuration_bb; WORD wReserved; SRTSData Data; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) SRTS_g, *PSRTS_g; typedef const SRTS_g *PCSRTS_g; - typedef struct tagSRTS_g_FB { BYTE bySignalField_b; BYTE byServiceField_b; @@ -245,10 +237,10 @@ typedef struct tagSRTS_g_FB { WORD wRTSDuration_ba_f1; WORD wRTSDuration_aa_f1; SRTSData Data; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) SRTS_g_FB, *PSRTS_g_FB; -typedef const SRTS_g_FB *PCSRTS_g_FB; +typedef const SRTS_g_FB *PCSRTS_g_FB; typedef struct tagSRTS_ab { BYTE bySignalField; @@ -257,10 +249,10 @@ typedef struct tagSRTS_ab { WORD wDuration; WORD wReserved; SRTSData Data; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) SRTS_ab, *PSRTS_ab; -typedef const SRTS_ab *PCSRTS_ab; +typedef const SRTS_ab *PCSRTS_ab; typedef struct tagSRTS_a_FB { BYTE bySignalField; @@ -271,8 +263,9 @@ typedef struct tagSRTS_a_FB { WORD wRTSDuration_f0; WORD wRTSDuration_f1; SRTSData Data; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) SRTS_a_FB, *PSRTS_a_FB; + typedef const SRTS_a_FB *PCSRTS_a_FB; @@ -284,7 +277,7 @@ typedef struct tagSCTSData { WORD wDurationID; BYTE abyRA[ETH_ALEN]; WORD wReserved; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) SCTSData, *PSCTSData; typedef struct tagSCTS { @@ -294,8 +287,9 @@ typedef struct tagSCTS { WORD wDuration_ba; WORD wReserved; SCTSData Data; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) SCTS, *PSCTS; + typedef const SCTS *PCSCTS; typedef struct tagSCTS_FB { @@ -307,10 +301,10 @@ typedef struct tagSCTS_FB { WORD wCTSDuration_ba_f0; WORD wCTSDuration_ba_f1; SCTSData Data; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) SCTS_FB, *PSCTS_FB; -typedef const SCTS_FB *PCSCTS_FB; +typedef const SCTS_FB *PCSCTS_FB; // // Tx FIFO header @@ -321,14 +315,14 @@ typedef struct tagSTxBufHead { WORD wTimeStamp; WORD wFragCtl; WORD wReserved; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) STxBufHead, *PSTxBufHead; typedef const STxBufHead *PCSTxBufHead; typedef struct tagSTxShortBufHead { WORD wFIFOCtl; WORD wTimeStamp; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) STxShortBufHead, *PSTxShortBufHead; typedef const STxShortBufHead *PCSTxShortBufHead; @@ -346,8 +340,9 @@ typedef struct tagSTxDataHead_g { WORD wDuration_a; WORD wTimeStampOff_b; WORD wTimeStampOff_a; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) STxDataHead_g, *PSTxDataHead_g; + typedef const STxDataHead_g *PCSTxDataHead_g; typedef struct tagSTxDataHead_g_FB { @@ -363,22 +358,20 @@ typedef struct tagSTxDataHead_g_FB { WORD wDuration_a_f1; WORD wTimeStampOff_b; WORD wTimeStampOff_a; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) STxDataHead_g_FB, *PSTxDataHead_g_FB; typedef const STxDataHead_g_FB *PCSTxDataHead_g_FB; - typedef struct tagSTxDataHead_ab { BYTE bySignalField; BYTE byServiceField; WORD wTransmitLength; WORD wDuration; WORD wTimeStampOff; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) STxDataHead_ab, *PSTxDataHead_ab; typedef const STxDataHead_ab *PCSTxDataHead_ab; - typedef struct tagSTxDataHead_a_FB { BYTE bySignalField; BYTE byServiceField; @@ -387,7 +380,7 @@ typedef struct tagSTxDataHead_a_FB { WORD wTimeStampOff; WORD wDuration_f0; WORD wDuration_f1; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) STxDataHead_a_FB, *PSTxDataHead_a_FB; typedef const STxDataHead_a_FB *PCSTxDataHead_a_FB; @@ -398,23 +391,23 @@ typedef struct tagSMICHDRHead { DWORD adwHDR0[4]; DWORD adwHDR1[4]; DWORD adwHDR2[4]; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) SMICHDRHead, *PSMICHDRHead; + typedef const SMICHDRHead *PCSMICHDRHead; typedef struct tagSBEACONCtl { DWORD BufReady : 1; - DWORD TSF : 15; - DWORD BufLen : 11; + DWORD TSF : 15; + DWORD BufLen : 11; DWORD Reserved : 5; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) SBEACONCtl; - typedef struct tagSSecretKey { DWORD dwLowDword; BYTE byHighByte; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) SSecretKey; typedef struct tagSKeyEntry { @@ -426,7 +419,7 @@ typedef struct tagSKeyEntry { DWORD dwKey2[4]; DWORD dwKey3[4]; DWORD dwKey4[4]; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) SKeyEntry; /*--------------------- Export Macros ------------------------------*/ diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index ef9fd97d3ca7..0bd8a9d21c16 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -109,7 +109,6 @@ #define MAX_MULTICAST_ADDRESS_NUM 32 #define MULTICAST_ADDRESS_LIST_SIZE (MAX_MULTICAST_ADDRESS_NUM * ETH_ALEN) - //#define OP_MODE_INFRASTRUCTURE 0 //#define OP_MODE_ADHOC 1 //#define OP_MODE_AP 2 @@ -130,8 +129,6 @@ #define KEYSEL_TKIP 2 #define KEYSEL_CCMP 3 - - #define AUTO_FB_NONE 0 #define AUTO_FB_0 1 #define AUTO_FB_1 2 @@ -162,8 +159,6 @@ #define BB_VGA_LEVEL 4 #define BB_VGA_CHANGE_THRESHOLD 3 - - #ifndef RUN_AT #define RUN_AT(x) (jiffies+(x)) #endif @@ -175,24 +170,23 @@ /*--------------------- Export Types ------------------------------*/ -#define DBG_PRT(l, p, args...) {if (l<=msglevel) printk( p ,##args);} -#define PRINT_K(p, args...) {if (PRIVATE_Message) printk( p ,##args);} +#define DBG_PRT(l, p, args...) { if (l <= msglevel) printk(p, ##args); } +#define PRINT_K(p, args...) { if (PRIVATE_Message) printk(p, ##args); } typedef enum __device_msg_level { - MSG_LEVEL_ERR=0, //Errors that will cause abnormal operation. - MSG_LEVEL_NOTICE=1, //Some errors need users to be notified. - MSG_LEVEL_INFO=2, //Normal message. - MSG_LEVEL_VERBOSE=3, //Will report all trival errors. - MSG_LEVEL_DEBUG=4 //Only for debug purpose. + MSG_LEVEL_ERR = 0, /* Errors causing abnormal operation */ + MSG_LEVEL_NOTICE = 1, /* Errors needing user notification */ + MSG_LEVEL_INFO = 2, /* Normal message. */ + MSG_LEVEL_VERBOSE = 3, /* Will report all trival errors. */ + MSG_LEVEL_DEBUG = 4 /* Only for debug purpose. */ } DEVICE_MSG_LEVEL, *PDEVICE_MSG_LEVEL; typedef enum __device_init_type { - DEVICE_INIT_COLD=0, // cold init - DEVICE_INIT_RESET, // reset init or Dx to D0 power remain init - DEVICE_INIT_DXPL // Dx to D0 power lost init + DEVICE_INIT_COLD = 0, /* cold init */ + DEVICE_INIT_RESET, /* reset init or Dx to D0 power remain */ + DEVICE_INIT_DXPL /* Dx to D0 power lost init */ } DEVICE_INIT_TYPE, *PDEVICE_INIT_TYPE; - //USB // @@ -203,9 +197,6 @@ typedef enum _CONTEXT_TYPE { CONTEXT_MGMT_PACKET } CONTEXT_TYPE; - - - // RCB (Receive Control Block) typedef struct _RCB { @@ -219,7 +210,6 @@ typedef struct _RCB } RCB, *PRCB; - // used to track bulk out irps typedef struct _USB_SEND_CONTEXT { void *pDevice; @@ -233,7 +223,6 @@ typedef struct _USB_SEND_CONTEXT { unsigned char Data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS]; } USB_SEND_CONTEXT, *PUSB_SEND_CONTEXT; - /* structure got from configuration file as user-desired default settings */ typedef struct _DEFAULT_CONFIG { signed int ZoneType; @@ -254,12 +243,10 @@ typedef struct { BOOL bInUse; } INT_BUFFER, *PINT_BUFFER; - - //0:11A 1:11B 2:11G typedef enum _VIA_BB_TYPE { - BB_TYPE_11A=0, + BB_TYPE_11A = 0, BB_TYPE_11B, BB_TYPE_11G } VIA_BB_TYPE, *PVIA_BB_TYPE; @@ -267,22 +254,19 @@ typedef enum _VIA_BB_TYPE //0:11a,1:11b,2:11gb(only CCK in BasicRate),3:11ga(OFDM in Basic Rate) typedef enum _VIA_PKT_TYPE { - PK_TYPE_11A=0, + PK_TYPE_11A = 0, PK_TYPE_11B, PK_TYPE_11GB, PK_TYPE_11GA } VIA_PKT_TYPE, *PVIA_PKT_TYPE; - - - //++ NDIS related #define NDIS_STATUS int #define NTSTATUS int typedef enum __DEVICE_NDIS_STATUS { - STATUS_SUCCESS=0, + STATUS_SUCCESS = 0, STATUS_FAILURE, STATUS_RESOURCES, STATUS_PENDING, diff --git a/drivers/staging/vt6656/device_cfg.h b/drivers/staging/vt6656/device_cfg.h index c816901882ad..a0b82169dad3 100644 --- a/drivers/staging/vt6656/device_cfg.h +++ b/drivers/staging/vt6656/device_cfg.h @@ -77,25 +77,20 @@ struct _version { //Max: 2378=2312Payload + 30HD +4CRC + 2Padding + 4Len + 8TSF + 4RSR #define PKT_BUF_SZ 2390 - #define MAX_UINTS 8 #define OPTION_DEFAULT { [0 ... MAX_UINTS-1] = -1} - - -typedef enum _chip_type{ - VT3184=1 +typedef enum _chip_type { + VT3184 = 1 } CHIP_TYPE, *PCHIP_TYPE; - - #ifdef VIAWET_DEBUG #define ASSERT(x) { \ if (!(x)) { \ - printk(KERN_ERR "assertion %s failed: file %s line %d\n", #x,\ + printk(KERN_ERR "assertion %s failed: file %s line %d\n", #x, \ __FUNCTION__, __LINE__);\ - *(int*) 0=0;\ - }\ + *(int *) 0 = 0; \ + } \ } #define DBG_PORT80(value) outb(value, 0x80) #else @@ -103,5 +98,4 @@ typedef enum _chip_type{ #define DBG_PORT80(value) #endif - #endif diff --git a/drivers/staging/vt6656/int.h b/drivers/staging/vt6656/int.h index cdf355130de7..d32ba351bc45 100644 --- a/drivers/staging/vt6656/int.h +++ b/drivers/staging/vt6656/int.h @@ -57,7 +57,7 @@ typedef struct tagSINTData { BYTE byACKFail; BYTE byFCSErr; BYTE abySW[2]; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) SINTData, *PSINTData; diff --git a/drivers/staging/vt6656/iocmd.h b/drivers/staging/vt6656/iocmd.h index fbba1d53e49d..ec55eb0a74cf 100644 --- a/drivers/staging/vt6656/iocmd.h +++ b/drivers/staging/vt6656/iocmd.h @@ -70,10 +70,10 @@ typedef enum tagWMAC_CMD { } WMAC_CMD, *PWMAC_CMD; typedef enum tagWZONETYPE { - ZoneType_USA=0, - ZoneType_Japan=1, - ZoneType_Europe=2 -}WZONETYPE; + ZoneType_USA = 0, + ZoneType_Japan = 1, + ZoneType_Europe = 2 +} WZONETYPE; #define ADHOC 0 #define INFRA 1 @@ -83,9 +83,9 @@ typedef enum tagWZONETYPE { #define ADHOC_STARTED 1 #define ADHOC_JOINTED 2 -#define PHY80211a 0 -#define PHY80211b 1 -#define PHY80211g 2 +#define PHY80211a 0 +#define PHY80211b 1 +#define PHY80211g 2 #define SSID_ID 0 #define SSID_MAXLEN 32 diff --git a/drivers/staging/vt6656/iowpa.h b/drivers/staging/vt6656/iowpa.h index da03edcbacb0..959c8868f6e2 100644 --- a/drivers/staging/vt6656/iowpa.h +++ b/drivers/staging/vt6656/iowpa.h @@ -31,10 +31,8 @@ /*--------------------- Export Definitions -------------------------*/ - #define WPA_IE_LEN 64 - //WPA related /* typedef enum { WPA_ALG_NONE, WPA_ALG_WEP, WPA_ALG_TKIP, WPA_ALG_CCMP } wpa_alg; @@ -54,7 +52,7 @@ enum { VIAWGET_SET_DROP_UNENCRYPT = 7, VIAWGET_SET_DEAUTHENTICATE = 8, VIAWGET_SET_ASSOCIATE = 9, - VIAWGET_SET_DISASSOCIATE= 10 + VIAWGET_SET_DISASSOCIATE = 10 }; @@ -76,8 +74,6 @@ typedef struct viawget_wpa_header { u16 resp_ie_len; } viawget_wpa_header; - - struct viawget_wpa_param { u32 cmd; u8 addr[6]; @@ -86,43 +82,37 @@ struct viawget_wpa_param { u8 len; u8 data[0]; } generic_elem; - struct { - u8 bssid[6]; + u8 bssid[6]; u8 ssid[32]; u8 ssid_len; - u8 *wpa_ie; - u16 wpa_ie_len; - int pairwise_suite; - int group_suite; - int key_mgmt_suite; - int auth_alg; - int mode; - u8 roam_dbm; //DavidWang + u8 *wpa_ie; + u16 wpa_ie_len; + int pairwise_suite; + int group_suite; + int key_mgmt_suite; + int auth_alg; + int mode; + u8 roam_dbm; } wpa_associate; - struct { - int alg_name; - u16 key_index; - u16 set_tx; - u8 *seq; - u16 seq_len; - u8 *key; - u16 key_len; + int alg_name; + u16 key_index; + u16 set_tx; + u8 *seq; + u16 seq_len; + u8 *key; + u16 key_len; } wpa_key; - struct { u8 ssid_len; u8 ssid[32]; } scan_req; - struct { u16 scan_count; u8 *buf; } scan_results; - } u; - }; #pragma pack(1) @@ -142,15 +132,12 @@ struct viawget_scan_result { int maxrate; }; - /*--------------------- Export Classes ----------------------------*/ /*--------------------- Export Variables --------------------------*/ - /*--------------------- Export Types ------------------------------*/ - /*--------------------- Export Functions --------------------------*/ #endif /* __IOWPA_H__ */ diff --git a/drivers/staging/vt6656/iwctl.h b/drivers/staging/vt6656/iwctl.h index df9a4cf3baac..d601e9220219 100644 --- a/drivers/staging/vt6656/iwctl.h +++ b/drivers/staging/vt6656/iwctl.h @@ -33,15 +33,13 @@ /*--------------------- Export Definitions -------------------------*/ - /*--------------------- Export Classes ----------------------------*/ /*--------------------- Export Variables --------------------------*/ /*--------------------- Export Functions --------------------------*/ -struct iw_statistics *iwctl_get_wireless_stats (struct net_device *dev); - +struct iw_statistics *iwctl_get_wireless_stats(struct net_device *dev); int iwctl_siwap(struct net_device *dev, struct iw_request_info *info, diff --git a/drivers/staging/vt6656/mac.h b/drivers/staging/vt6656/mac.h index 775c70928ec7..491ff5ecd04b 100644 --- a/drivers/staging/vt6656/mac.h +++ b/drivers/staging/vt6656/mac.h @@ -420,11 +420,11 @@ /*--------------------- Export Functions --------------------------*/ -void MACvSetMultiAddrByHash (PSDevice pDevice, BYTE byHashIdx); +void MACvSetMultiAddrByHash(PSDevice pDevice, BYTE byHashIdx); void MACvWriteMultiAddr(PSDevice pDevice, unsigned int uByteIdx, BYTE byData); -BOOL MACbShutdown(PSDevice pDevice);; -void MACvSetBBType(PSDevice pDevice,BYTE byType); -void MACvSetMISCFifo (PSDevice pDevice, WORD wOffset, DWORD dwData); +BOOL MACbShutdown(PSDevice pDevice); +void MACvSetBBType(PSDevice pDevice, BYTE byType); +void MACvSetMISCFifo(PSDevice pDevice, WORD wOffset, DWORD dwData); void MACvDisableKeyEntry(PSDevice pDevice, unsigned int uEntryIdx); void MACvSetKeyEntry(PSDevice pDevice, WORD wKeyCtl, unsigned int uEntryIdx, unsigned int uKeyIdx, PBYTE pbyAddr, PDWORD pdwKey); diff --git a/drivers/staging/vt6656/mib.h b/drivers/staging/vt6656/mib.h index 0455ec9d327d..050dd9c05d5c 100644 --- a/drivers/staging/vt6656/mib.h +++ b/drivers/staging/vt6656/mib.h @@ -381,7 +381,9 @@ typedef struct tagSStatCounter { void STAvClearAllCounter(PSStatCounter pStatistic); -void STAvUpdateIsrStatCounter (PSStatCounter pStatistic, BYTE byIsr0, BYTE byIsr1); +void STAvUpdateIsrStatCounter(PSStatCounter pStatistic, + BYTE byIsr0, + BYTE byIsr1); void STAvUpdateRDStatCounter(PSStatCounter pStatistic, BYTE byRSR, BYTE byNewRSR, BYTE byRxSts, @@ -393,14 +395,8 @@ void STAvUpdateRDStatCounterEx(PSStatCounter pStatistic, BYTE byRxRate, PBYTE pbyBuffer, unsigned int cbFrameLength); -void -STAvUpdateTDStatCounter ( - PSStatCounter pStatistic, - BYTE byPktNum, - BYTE byRate, - BYTE byTSR - ); - +void STAvUpdateTDStatCounter(PSStatCounter pStatistic, BYTE byPktNum, + BYTE byRate, BYTE byTSR); void STAvUpdate802_11Counter( diff --git a/drivers/staging/vt6656/michael.h b/drivers/staging/vt6656/michael.h index 3ab60928ef35..81351f506232 100644 --- a/drivers/staging/vt6656/michael.h +++ b/drivers/staging/vt6656/michael.h @@ -49,8 +49,8 @@ void MIC_vGetMIC(PDWORD pdwL, PDWORD pdwR); /*--------------------- Export Macros ------------------------------*/ // Rotation functions on 32 bit values -#define ROL32( A, n ) \ - ( ((A) << (n)) | ( ((A)>>(32-(n))) & ( (1UL << (n)) - 1 ) ) ) -#define ROR32( A, n ) ROL32( (A), 32-(n) ) +#define ROL32(A, n) \ + (((A) << (n)) | (((A)>>(32-(n))) & ((1UL << (n)) - 1))) +#define ROR32(A, n) ROL32((A), 32-(n)) #endif /* __MICHAEL_H__ */ diff --git a/drivers/staging/vt6656/rf.h b/drivers/staging/vt6656/rf.h index d4f8b94132b9..f5ba8fd7f816 100644 --- a/drivers/staging/vt6656/rf.h +++ b/drivers/staging/vt6656/rf.h @@ -64,11 +64,7 @@ extern const BYTE RFaby11aChannelIndex[200]; /*--------------------- Export Functions --------------------------*/ BOOL IFRFbWriteEmbeded(PSDevice pDevice, DWORD dwData); -BOOL RFbSetPower ( - PSDevice pDevice, - unsigned int uRATE, - unsigned int uCH - ); +BOOL RFbSetPower(PSDevice pDevice, unsigned int uRATE, unsigned int uCH); BOOL RFbRawSetPower( PSDevice pDevice, @@ -76,17 +72,8 @@ BOOL RFbRawSetPower( unsigned int uRATE ); -void -RFvRSSITodBm ( - PSDevice pDevice, - BYTE byCurrRSSI, - long * pldBm - ); - -void -RFbRFTableDownload ( - PSDevice pDevice - ); +void RFvRSSITodBm(PSDevice pDevice, BYTE byCurrRSSI, long *pldBm); +void RFbRFTableDownload(PSDevice pDevice); BOOL s_bVT3226D0_11bLoCurrentAdjust( PSDevice pDevice, diff --git a/drivers/staging/vt6656/rndis.h b/drivers/staging/vt6656/rndis.h index ac842dd13a68..fccf7e98eb68 100644 --- a/drivers/staging/vt6656/rndis.h +++ b/drivers/staging/vt6656/rndis.h @@ -152,7 +152,7 @@ typedef struct _CMD_CHANGE_BBTYPE /*--------------------- Export Macros -------------------------*/ -#define EXCH_WORD(w) ( (WORD)((WORD)(w)<<8) | (WORD)((WORD)(w)>>8) ) +#define EXCH_WORD(w) ((WORD)((WORD)(w)<<8) | (WORD)((WORD)(w)>>8)) /*--------------------- Export Variables --------------------------*/ diff --git a/drivers/staging/vt6656/tether.h b/drivers/staging/vt6656/tether.h index d63586d5cdb2..819aaf7c00e3 100644 --- a/drivers/staging/vt6656/tether.h +++ b/drivers/staging/vt6656/tether.h @@ -168,7 +168,7 @@ typedef struct tagSEthernetHeader { BYTE abyDstAddr[ETH_ALEN]; BYTE abySrcAddr[ETH_ALEN]; WORD wType; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) SEthernetHeader, *PSEthernetHeader; @@ -179,7 +179,7 @@ typedef struct tagS802_3Header { BYTE abyDstAddr[ETH_ALEN]; BYTE abySrcAddr[ETH_ALEN]; WORD wLen; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) S802_3Header, *PS802_3Header; // @@ -193,7 +193,7 @@ typedef struct tagS802_11Header { BYTE abyAddr3[ETH_ALEN]; WORD wSeqCtl; BYTE abyAddr4[ETH_ALEN]; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) S802_11Header, *PS802_11Header; /*--------------------- Export Macros ------------------------------*/ diff --git a/drivers/staging/vt6656/ttype.h b/drivers/staging/vt6656/ttype.h index c27f9858e2e9..3ffcd7f790de 100644 --- a/drivers/staging/vt6656/ttype.h +++ b/drivers/staging/vt6656/ttype.h @@ -58,7 +58,7 @@ typedef int BOOL; #endif //2007-0809-01by MikeLiu -#ifndef update_BssList +#ifndef update_BssList #define update_BssList #endif diff --git a/drivers/staging/vt6656/wmgr.h b/drivers/staging/vt6656/wmgr.h index 1e5b916aea1d..a7ea49107225 100644 --- a/drivers/staging/vt6656/wmgr.h +++ b/drivers/staging/vt6656/wmgr.h @@ -82,7 +82,7 @@ /*--------------------- Export Types ------------------------------*/ //mike define: make timer to expire after desired times -#define timer_expire(timer,next_tick) mod_timer(&timer, RUN_AT(next_tick)) +#define timer_expire(timer, next_tick) mod_timer(&timer, RUN_AT(next_tick)) typedef void (*TimerFunction)(unsigned long); diff --git a/drivers/staging/vt6656/wpa2.h b/drivers/staging/vt6656/wpa2.h index 429a910a5c50..46c295905b48 100644 --- a/drivers/staging/vt6656/wpa2.h +++ b/drivers/staging/vt6656/wpa2.h @@ -58,21 +58,9 @@ typedef struct tagSPMKIDCache { /*--------------------- Export Functions --------------------------*/ -void -WPA2_ClearRSN ( - PKnownBSS pBSSNode - ); +void WPA2_ClearRSN(PKnownBSS pBSSNode); +void WPA2vParseRSN(PKnownBSS pBSSNode, PWLAN_IE_RSN pRSN); -void -WPA2vParseRSN ( - PKnownBSS pBSSNode, - PWLAN_IE_RSN pRSN - ); - -unsigned int -WPA2uSetIEs( - void *pMgmtHandle, - PWLAN_IE_RSN pRSNIEs - ); +unsigned int WPA2uSetIEs(void *pMgmtHandle, PWLAN_IE_RSN pRSNIEs); #endif /* __WPA2_H__ */ From d500648ef675d9abfc02ffb96b09141bc9f76dba Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Fri, 21 May 2010 19:08:14 -0300 Subject: [PATCH 070/523] Staging: vt6656: fix up built-in compilation together with rt2870 Fix this build error: drivers/staging/vt6656/built-in.o: In function `rotr1': (.text+0x1a878): multiple definition of `rotr1' drivers/staging/rt2870/built-in.o:(.text+0x106c2): first defined here drivers/staging/vt6656/built-in.o: In function `tkip_sbox': (.text+0x1a848): multiple definition of `tkip_sbox' drivers/staging/rt2870/built-in.o:(.text+0x10697): first defined here drivers/staging/vt6656/built-in.o: In function `xor_32': (.text+0x1ec24): multiple definition of `xor_32' drivers/staging/rt2870/built-in.o:(.text+0x111c4): first defined here drivers/staging/vt6656/built-in.o: In function `xor_128': (.text+0x1ec00): multiple definition of `xor_128' drivers/staging/rt2870/built-in.o:(.text+0x111dd): first defined here Signed-off-by: Otavio Salvador Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/aes_ccmp.c | 4 ++-- drivers/staging/vt6656/tkip.c | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vt6656/aes_ccmp.c b/drivers/staging/vt6656/aes_ccmp.c index b3d367b9bdc6..f7a3b8f8da70 100644 --- a/drivers/staging/vt6656/aes_ccmp.c +++ b/drivers/staging/vt6656/aes_ccmp.c @@ -106,7 +106,7 @@ BYTE dot3_table[256] = { /*--------------------- Export Functions --------------------------*/ -void xor_128(BYTE *a, BYTE *b, BYTE *out) +static void xor_128(BYTE *a, BYTE *b, BYTE *out) { PDWORD dwPtrA = (PDWORD) a; PDWORD dwPtrB = (PDWORD) b; @@ -119,7 +119,7 @@ void xor_128(BYTE *a, BYTE *b, BYTE *out) } -void xor_32(BYTE *a, BYTE *b, BYTE *out) +static void xor_32(BYTE *a, BYTE *b, BYTE *out) { PDWORD dwPtrA = (PDWORD) a; PDWORD dwPtrB = (PDWORD) b; diff --git a/drivers/staging/vt6656/tkip.c b/drivers/staging/vt6656/tkip.c index f83af5913aa6..a6bd533f9577 100644 --- a/drivers/staging/vt6656/tkip.c +++ b/drivers/staging/vt6656/tkip.c @@ -129,8 +129,6 @@ const BYTE TKIP_Sbox_Upper[256] = { //STKIPKeyManagement sTKIPKeyTable[MAX_TKIP_KEY]; /*--------------------- Static Functions --------------------------*/ -unsigned int tkip_sbox(unsigned int index); -unsigned int rotr1(unsigned int a); /*--------------------- Export Variables --------------------------*/ @@ -139,7 +137,7 @@ unsigned int rotr1(unsigned int a); /* Returns a 16 bit value from a 64K entry table. The Table */ /* is synthesized from two 256 entry byte wide tables. */ /************************************************************/ -unsigned int tkip_sbox(unsigned int index) +static unsigned int tkip_sbox(unsigned int index) { unsigned int index_low; unsigned int index_high; @@ -155,7 +153,7 @@ unsigned int tkip_sbox(unsigned int index) }; -unsigned int rotr1(unsigned int a) +static unsigned int rotr1(unsigned int a) { unsigned int b; From 2555cd9f9331a3a2ba79bd7263c7f334895d9cfa Mon Sep 17 00:00:00 2001 From: Timofey Trofimov Date: Sat, 22 May 2010 20:42:54 +0400 Subject: [PATCH 071/523] Staging: vt6656: fix coding style issues in 80211mgr.c This is a patch to the 80211mgr.c file that fixes up warnings found by the checkpatch.pl tool Signed-off-by: Timofey Trofimov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/80211mgr.c | 476 +++++++++++++++--------------- 1 file changed, 232 insertions(+), 244 deletions(-) diff --git a/drivers/staging/vt6656/80211mgr.c b/drivers/staging/vt6656/80211mgr.c index f24dc55e68f1..723601951bb7 100644 --- a/drivers/staging/vt6656/80211mgr.c +++ b/drivers/staging/vt6656/80211mgr.c @@ -67,8 +67,8 @@ /*--------------------- Static Variables --------------------------*/ -static int msglevel =MSG_LEVEL_INFO; -//static int msglevel =MSG_LEVEL_DEBUG; +static int msglevel = MSG_LEVEL_INFO; +/*static int msglevel =MSG_LEVEL_DEBUG;*/ /*--------------------- Static Functions --------------------------*/ @@ -96,7 +96,7 @@ vMgrEncodeBeacon( { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Fixed Fields + /* Fixed Fields */ pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_BEACON_OFF_TS); pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) @@ -130,7 +130,7 @@ vMgrDecodeBeacon( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Fixed Fields + /* Fixed Fields */ pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_BEACON_OFF_TS); pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) @@ -138,88 +138,87 @@ vMgrDecodeBeacon( pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_BEACON_OFF_CAPINFO); - // Information elements + /* Information elements */ pItem = (PWLAN_IE)((PBYTE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))) + WLAN_BEACON_OFF_SSID); - while( ((PBYTE)pItem) < (pFrame->pBuf + pFrame->len) ){ + while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) { switch (pItem->byElementID) { - case WLAN_EID_SSID: - if (pFrame->pSSID == NULL) - pFrame->pSSID = (PWLAN_IE_SSID)pItem; - break; - case WLAN_EID_SUPP_RATES: - if (pFrame->pSuppRates == NULL) - pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem; - break; - case WLAN_EID_FH_PARMS: - //pFrame->pFHParms = (PWLAN_IE_FH_PARMS)pItem; - break; - case WLAN_EID_DS_PARMS: - if (pFrame->pDSParms == NULL) - pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem; - break; - case WLAN_EID_CF_PARMS: - if (pFrame->pCFParms == NULL) - pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem; - break; - case WLAN_EID_IBSS_PARMS: - if (pFrame->pIBSSParms == NULL) - pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem; - break; - case WLAN_EID_TIM: - if (pFrame->pTIM == NULL) - pFrame->pTIM = (PWLAN_IE_TIM)pItem; - break; + case WLAN_EID_SSID: + if (pFrame->pSSID == NULL) + pFrame->pSSID = (PWLAN_IE_SSID)pItem; + break; + case WLAN_EID_SUPP_RATES: + if (pFrame->pSuppRates == NULL) + pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem; + break; + case WLAN_EID_FH_PARMS: + /* pFrame->pFHParms = (PWLAN_IE_FH_PARMS)pItem; */ + break; + case WLAN_EID_DS_PARMS: + if (pFrame->pDSParms == NULL) + pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem; + break; + case WLAN_EID_CF_PARMS: + if (pFrame->pCFParms == NULL) + pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem; + break; + case WLAN_EID_IBSS_PARMS: + if (pFrame->pIBSSParms == NULL) + pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem; + break; + case WLAN_EID_TIM: + if (pFrame->pTIM == NULL) + pFrame->pTIM = (PWLAN_IE_TIM)pItem; + break; - case WLAN_EID_RSN: - if (pFrame->pRSN == NULL) { - pFrame->pRSN = (PWLAN_IE_RSN)pItem; - } - break; - case WLAN_EID_RSN_WPA: - if (pFrame->pRSNWPA == NULL) { - if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE) - pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem; - } - break; + case WLAN_EID_RSN: + if (pFrame->pRSN == NULL) + pFrame->pRSN = (PWLAN_IE_RSN)pItem; + break; + case WLAN_EID_RSN_WPA: + if (pFrame->pRSNWPA == NULL) { + if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE) + pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem; + } + break; - case WLAN_EID_ERP: - if (pFrame->pERP == NULL) - pFrame->pERP = (PWLAN_IE_ERP)pItem; - break; - case WLAN_EID_EXTSUPP_RATES: - if (pFrame->pExtSuppRates == NULL) - pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; - break; + case WLAN_EID_ERP: + if (pFrame->pERP == NULL) + pFrame->pERP = (PWLAN_IE_ERP)pItem; + break; + case WLAN_EID_EXTSUPP_RATES: + if (pFrame->pExtSuppRates == NULL) + pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; + break; - case WLAN_EID_COUNTRY: //7 - if (pFrame->pIE_Country == NULL) - pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem; - break; + case WLAN_EID_COUNTRY: /* 7 */ + if (pFrame->pIE_Country == NULL) + pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem; + break; - case WLAN_EID_PWR_CONSTRAINT: //32 - if (pFrame->pIE_PowerConstraint == NULL) - pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem; - break; + case WLAN_EID_PWR_CONSTRAINT: /* 32 */ + if (pFrame->pIE_PowerConstraint == NULL) + pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem; + break; - case WLAN_EID_CH_SWITCH: //37 - if (pFrame->pIE_CHSW == NULL) - pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem; - break; + case WLAN_EID_CH_SWITCH: /* 37 */ + if (pFrame->pIE_CHSW == NULL) + pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem; + break; - case WLAN_EID_QUIET: //40 - if (pFrame->pIE_Quiet == NULL) - pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem; - break; + case WLAN_EID_QUIET: /* 40 */ + if (pFrame->pIE_Quiet == NULL) + pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem; + break; - case WLAN_EID_IBSS_DFS: - if (pFrame->pIE_IBSSDFS == NULL) - pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem; - break; + case WLAN_EID_IBSS_DFS: + if (pFrame->pIE_IBSSDFS == NULL) + pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem; + break; - default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in beacon decode.\n", pItem->byElementID); + default: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in beacon decode.\n", pItem->byElementID); break; } @@ -295,7 +294,7 @@ vMgrEncodeDisassociation( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Fixed Fields + /* Fixed Fields */ pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_DISASSOC_OFF_REASON); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DISASSOC_OFF_REASON + sizeof(*(pFrame->pwReason)); @@ -322,7 +321,7 @@ vMgrDecodeDisassociation( { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Fixed Fields + /* Fixed Fields */ pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_DISASSOC_OFF_REASON); @@ -347,7 +346,7 @@ vMgrEncodeAssocRequest( ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Fixed Fields + /* Fixed Fields */ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCREQ_OFF_CAP_INFO); pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) @@ -376,47 +375,46 @@ vMgrDecodeAssocRequest( PWLAN_IE pItem; pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Fixed Fields + /* Fixed Fields */ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCREQ_OFF_CAP_INFO); pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCREQ_OFF_LISTEN_INT); - // Information elements + /* Information elements */ pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCREQ_OFF_SSID); while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) { - switch (pItem->byElementID){ - case WLAN_EID_SSID: - if (pFrame->pSSID == NULL) - pFrame->pSSID = (PWLAN_IE_SSID)pItem; - break; - case WLAN_EID_SUPP_RATES: - if (pFrame->pSuppRates == NULL) - pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem; - break; + switch (pItem->byElementID) { + case WLAN_EID_SSID: + if (pFrame->pSSID == NULL) + pFrame->pSSID = (PWLAN_IE_SSID)pItem; + break; + case WLAN_EID_SUPP_RATES: + if (pFrame->pSuppRates == NULL) + pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem; + break; - case WLAN_EID_RSN: - if (pFrame->pRSN == NULL) { - pFrame->pRSN = (PWLAN_IE_RSN)pItem; - } - break; - case WLAN_EID_RSN_WPA: - if (pFrame->pRSNWPA == NULL) { - if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE) - pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem; - } - break; - case WLAN_EID_EXTSUPP_RATES: - if (pFrame->pExtSuppRates == NULL) - pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; - break; + case WLAN_EID_RSN: + if (pFrame->pRSN == NULL) + pFrame->pRSN = (PWLAN_IE_RSN)pItem; + break; + case WLAN_EID_RSN_WPA: + if (pFrame->pRSNWPA == NULL) { + if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE) + pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem; + } + break; + case WLAN_EID_EXTSUPP_RATES: + if (pFrame->pExtSuppRates == NULL) + pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; + break; - default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in assocreq decode.\n", - pItem->byElementID); - break; + default: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in assocreq decode.\n", + pItem->byElementID); + break; } pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len); } @@ -441,7 +439,7 @@ vMgrEncodeAssocResponse( { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Fixed Fields + /* Fixed Fields */ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCRESP_OFF_CAP_INFO); pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) @@ -475,7 +473,7 @@ vMgrDecodeAssocResponse( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Fixed Fields + /* Fixed Fields */ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCRESP_OFF_CAP_INFO); pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) @@ -483,7 +481,7 @@ vMgrDecodeAssocResponse( pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCRESP_OFF_AID); - // Information elements + /* Information elements */ pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_ASSOCRESP_OFF_SUPP_RATES); @@ -493,8 +491,7 @@ vMgrDecodeAssocResponse( if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) { pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "pFrame->pExtSuppRates=[%p].\n", pItem); - } - else { + } else { pFrame->pExtSuppRates = NULL; } return; @@ -519,7 +516,7 @@ vMgrEncodeReassocRequest( { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Fixed Fields + /* Fixed Fields */ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCREQ_OFF_CAP_INFO); pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) @@ -552,7 +549,7 @@ vMgrDecodeReassocRequest( PWLAN_IE pItem; pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Fixed Fields + /* Fixed Fields */ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCREQ_OFF_CAP_INFO); pFrame->pwListenInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) @@ -560,42 +557,41 @@ vMgrDecodeReassocRequest( pFrame->pAddrCurrAP = (PIEEE_ADDR)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCREQ_OFF_CURR_AP); - // Information elements + /* Information elements */ pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCREQ_OFF_SSID); - while(((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) { + while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) { - switch (pItem->byElementID){ - case WLAN_EID_SSID: - if (pFrame->pSSID == NULL) - pFrame->pSSID = (PWLAN_IE_SSID)pItem; - break; - case WLAN_EID_SUPP_RATES: - if (pFrame->pSuppRates == NULL) - pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem; - break; + switch (pItem->byElementID) { + case WLAN_EID_SSID: + if (pFrame->pSSID == NULL) + pFrame->pSSID = (PWLAN_IE_SSID)pItem; + break; + case WLAN_EID_SUPP_RATES: + if (pFrame->pSuppRates == NULL) + pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem; + break; - case WLAN_EID_RSN: - if (pFrame->pRSN == NULL) { - pFrame->pRSN = (PWLAN_IE_RSN)pItem; - } - break; - case WLAN_EID_RSN_WPA: - if (pFrame->pRSNWPA == NULL) { - if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE) - pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem; - } - break; + case WLAN_EID_RSN: + if (pFrame->pRSN == NULL) + pFrame->pRSN = (PWLAN_IE_RSN)pItem; + break; + case WLAN_EID_RSN_WPA: + if (pFrame->pRSNWPA == NULL) { + if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE) + pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem; + } + break; - case WLAN_EID_EXTSUPP_RATES: - if (pFrame->pExtSuppRates == NULL) - pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; - break; - default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in reassocreq decode.\n", - pItem->byElementID); - break; + case WLAN_EID_EXTSUPP_RATES: + if (pFrame->pExtSuppRates == NULL) + pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; + break; + default: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Unrecognized EID=%dd in reassocreq decode.\n", + pItem->byElementID); + break; } pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len); } @@ -646,30 +642,30 @@ vMgrDecodeProbeRequest( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Information elements + /* Information elements */ pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3))); - while( ((PBYTE)pItem) < (pFrame->pBuf + pFrame->len) ) { + while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) { switch (pItem->byElementID) { - case WLAN_EID_SSID: - if (pFrame->pSSID == NULL) - pFrame->pSSID = (PWLAN_IE_SSID)pItem; - break; + case WLAN_EID_SSID: + if (pFrame->pSSID == NULL) + pFrame->pSSID = (PWLAN_IE_SSID)pItem; + break; - case WLAN_EID_SUPP_RATES: - if (pFrame->pSuppRates == NULL) - pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem; - break; + case WLAN_EID_SUPP_RATES: + if (pFrame->pSuppRates == NULL) + pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem; + break; - case WLAN_EID_EXTSUPP_RATES: - if (pFrame->pExtSuppRates == NULL) - pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; - break; + case WLAN_EID_EXTSUPP_RATES: + if (pFrame->pExtSuppRates == NULL) + pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; + break; - default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in probereq\n", pItem->byElementID); - break; + default: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in probereq\n", pItem->byElementID); + break; } pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len); @@ -697,7 +693,7 @@ vMgrEncodeProbeResponse( { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Fixed Fields + /* Fixed Fields */ pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_TS); pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) @@ -734,7 +730,7 @@ vMgrDecodeProbeResponse( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Fixed Fields + /* Fixed Fields */ pFrame->pqwTimestamp = (PQWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_TS); pFrame->pwBeaconInterval = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) @@ -742,83 +738,82 @@ vMgrDecodeProbeResponse( pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_CAP_INFO); - // Information elements + /* Information elements */ pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_PROBERESP_OFF_SSID); - while( ((PBYTE)pItem) < (pFrame->pBuf + pFrame->len) ) { + while (((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) { switch (pItem->byElementID) { - case WLAN_EID_SSID: - if (pFrame->pSSID == NULL) + case WLAN_EID_SSID: + if (pFrame->pSSID == NULL) pFrame->pSSID = (PWLAN_IE_SSID)pItem; - break; - case WLAN_EID_SUPP_RATES: - if (pFrame->pSuppRates == NULL) + break; + case WLAN_EID_SUPP_RATES: + if (pFrame->pSuppRates == NULL) pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)pItem; - break; - case WLAN_EID_FH_PARMS: - break; - case WLAN_EID_DS_PARMS: - if (pFrame->pDSParms == NULL) - pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem; - break; - case WLAN_EID_CF_PARMS: - if (pFrame->pCFParms == NULL) - pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem; - break; - case WLAN_EID_IBSS_PARMS: - if (pFrame->pIBSSParms == NULL) - pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem; - break; + break; + case WLAN_EID_FH_PARMS: + break; + case WLAN_EID_DS_PARMS: + if (pFrame->pDSParms == NULL) + pFrame->pDSParms = (PWLAN_IE_DS_PARMS)pItem; + break; + case WLAN_EID_CF_PARMS: + if (pFrame->pCFParms == NULL) + pFrame->pCFParms = (PWLAN_IE_CF_PARMS)pItem; + break; + case WLAN_EID_IBSS_PARMS: + if (pFrame->pIBSSParms == NULL) + pFrame->pIBSSParms = (PWLAN_IE_IBSS_PARMS)pItem; + break; - case WLAN_EID_RSN: - if (pFrame->pRSN == NULL) { - pFrame->pRSN = (PWLAN_IE_RSN)pItem; - } - break; - case WLAN_EID_RSN_WPA: - if (pFrame->pRSNWPA == NULL) { - if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE) - pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem; - } - break; - case WLAN_EID_ERP: - if (pFrame->pERP == NULL) - pFrame->pERP = (PWLAN_IE_ERP)pItem; - break; - case WLAN_EID_EXTSUPP_RATES: - if (pFrame->pExtSuppRates == NULL) - pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; - break; + case WLAN_EID_RSN: + if (pFrame->pRSN == NULL) + pFrame->pRSN = (PWLAN_IE_RSN)pItem; + break; + case WLAN_EID_RSN_WPA: + if (pFrame->pRSNWPA == NULL) { + if (WPAb_Is_RSN((PWLAN_IE_RSN_EXT)pItem) == TRUE) + pFrame->pRSNWPA = (PWLAN_IE_RSN_EXT)pItem; + } + break; + case WLAN_EID_ERP: + if (pFrame->pERP == NULL) + pFrame->pERP = (PWLAN_IE_ERP)pItem; + break; + case WLAN_EID_EXTSUPP_RATES: + if (pFrame->pExtSuppRates == NULL) + pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; + break; - case WLAN_EID_COUNTRY: //7 - if (pFrame->pIE_Country == NULL) - pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem; - break; + case WLAN_EID_COUNTRY: /* 7 */ + if (pFrame->pIE_Country == NULL) + pFrame->pIE_Country = (PWLAN_IE_COUNTRY)pItem; + break; - case WLAN_EID_PWR_CONSTRAINT: //32 - if (pFrame->pIE_PowerConstraint == NULL) - pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem; - break; + case WLAN_EID_PWR_CONSTRAINT: /* 32 */ + if (pFrame->pIE_PowerConstraint == NULL) + pFrame->pIE_PowerConstraint = (PWLAN_IE_PW_CONST)pItem; + break; - case WLAN_EID_CH_SWITCH: //37 - if (pFrame->pIE_CHSW == NULL) - pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem; - break; + case WLAN_EID_CH_SWITCH: /* 37 */ + if (pFrame->pIE_CHSW == NULL) + pFrame->pIE_CHSW = (PWLAN_IE_CH_SW)pItem; + break; - case WLAN_EID_QUIET: //40 - if (pFrame->pIE_Quiet == NULL) - pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem; - break; + case WLAN_EID_QUIET: /* 40 */ + if (pFrame->pIE_Quiet == NULL) + pFrame->pIE_Quiet = (PWLAN_IE_QUIET)pItem; + break; - case WLAN_EID_IBSS_DFS: - if (pFrame->pIE_IBSSDFS == NULL) - pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem; - break; + case WLAN_EID_IBSS_DFS: + if (pFrame->pIE_IBSSDFS == NULL) + pFrame->pIE_IBSSDFS = (PWLAN_IE_IBSS_DFS)pItem; + break; - default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in proberesp\n", pItem->byElementID); - break; + default: + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Bad EID=%dd in proberesp\n", pItem->byElementID); + break; } pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len); @@ -845,7 +840,7 @@ vMgrEncodeAuthen( { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Fixed Fields + /* Fixed Fields */ pFrame->pwAuthAlgorithm = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_AUTH_ALG); pFrame->pwAuthSequence = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) @@ -853,7 +848,6 @@ vMgrEncodeAuthen( pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_STATUS); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_AUTHEN_OFF_STATUS + sizeof(*(pFrame->pwStatus)); - return; } @@ -878,7 +872,7 @@ vMgrDecodeAuthen( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Fixed Fields + /* Fixed Fields */ pFrame->pwAuthAlgorithm = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_AUTH_ALG); pFrame->pwAuthSequence = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) @@ -886,14 +880,12 @@ vMgrDecodeAuthen( pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_STATUS); - // Information elements + /* Information elements */ pItem = (PWLAN_IE)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_AUTHEN_OFF_CHALLENGE); - if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_CHALLENGE)) { + if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_CHALLENGE)) pFrame->pChallenge = (PWLAN_IE_CHALLENGE)pItem; - } - return; } @@ -916,11 +908,10 @@ vMgrEncodeDeauthen( { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Fixed Fields + /* Fixed Fields */ pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_DEAUTHEN_OFF_REASON); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_DEAUTHEN_OFF_REASON + sizeof(*(pFrame->pwReason)); - return; } @@ -943,10 +934,9 @@ vMgrDecodeDeauthen( { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Fixed Fields + /* Fixed Fields */ pFrame->pwReason = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_DEAUTHEN_OFF_REASON); - return; } @@ -969,7 +959,7 @@ vMgrEncodeReassocResponse( { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Fixed Fields + /* Fixed Fields */ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCRESP_OFF_CAP_INFO); pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) @@ -978,7 +968,6 @@ vMgrEncodeReassocResponse( + WLAN_REASSOCRESP_OFF_AID); pFrame->len = WLAN_HDR_ADDR3_LEN + WLAN_REASSOCRESP_OFF_AID + sizeof(*(pFrame->pwAid)); - return; } @@ -1004,7 +993,7 @@ vMgrDecodeReassocResponse( pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; - // Fixed Fields + /* Fixed Fields */ pFrame->pwCapInfo = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCRESP_OFF_CAP_INFO); pFrame->pwStatus = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) @@ -1012,15 +1001,14 @@ vMgrDecodeReassocResponse( pFrame->pwAid = (PWORD)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCRESP_OFF_AID); - //Information elements + /* Information elements */ pFrame->pSuppRates = (PWLAN_IE_SUPP_RATES)(WLAN_HDR_A3_DATA_PTR(&(pFrame->pHdr->sA3)) + WLAN_REASSOCRESP_OFF_SUPP_RATES); pItem = (PWLAN_IE)(pFrame->pSuppRates); pItem = (PWLAN_IE)(((PBYTE)pItem) + 2 + pItem->len); - if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) { + if ((((PBYTE)pItem) < (pFrame->pBuf + pFrame->len)) && (pItem->byElementID == WLAN_EID_EXTSUPP_RATES)) pFrame->pExtSuppRates = (PWLAN_IE_SUPP_RATES)pItem; - } return; } From 0d74395177b38db079caf57b5d27c3cc0ee59ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Fri, 11 Jun 2010 12:17:04 +0200 Subject: [PATCH 072/523] Staging: vt665*: fix typos concerning "management" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Uwe Kleine-König Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/80211mgr.h | 2 +- drivers/staging/vt6656/80211mgr.c | 2 +- drivers/staging/vt6656/80211mgr.h | 2 +- drivers/staging/vt6656/power.c | 2 +- drivers/staging/vt6656/power.h | 2 +- drivers/staging/vt6656/wmgr.h | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/vt6655/80211mgr.h b/drivers/staging/vt6655/80211mgr.h index a11e6633a3c6..bebb5d6b5936 100644 --- a/drivers/staging/vt6655/80211mgr.h +++ b/drivers/staging/vt6655/80211mgr.h @@ -19,7 +19,7 @@ * * File: 80211mgr.h * - * Purpose: 802.11 managment frames pre-defines. + * Purpose: 802.11 management frames pre-defines. * * * Author: Lyndon Chen diff --git a/drivers/staging/vt6656/80211mgr.c b/drivers/staging/vt6656/80211mgr.c index 723601951bb7..fceec4999c36 100644 --- a/drivers/staging/vt6656/80211mgr.c +++ b/drivers/staging/vt6656/80211mgr.c @@ -18,7 +18,7 @@ * * File: 80211mgr.c * - * Purpose: Handles the 802.11 managment support functions + * Purpose: Handles the 802.11 management support functions * * Author: Lyndon Chen * diff --git a/drivers/staging/vt6656/80211mgr.h b/drivers/staging/vt6656/80211mgr.h index 7f939e3bf175..3d57f793986d 100644 --- a/drivers/staging/vt6656/80211mgr.h +++ b/drivers/staging/vt6656/80211mgr.h @@ -19,7 +19,7 @@ * * File: 80211mgr.h * - * Purpose: 802.11 managment frames pre-defines. + * Purpose: 802.11 management frames pre-defines. * * * Author: Lyndon Chen diff --git a/drivers/staging/vt6656/power.c b/drivers/staging/vt6656/power.c index 766c5be6fd22..5ff15bf59c5b 100644 --- a/drivers/staging/vt6656/power.c +++ b/drivers/staging/vt6656/power.c @@ -19,7 +19,7 @@ * * File: power.c * - * Purpose: Handles 802.11 power managment functions + * Purpose: Handles 802.11 power management functions * * Author: Lyndon Chen * diff --git a/drivers/staging/vt6656/power.h b/drivers/staging/vt6656/power.h index 50792bb8c978..41bffe528b44 100644 --- a/drivers/staging/vt6656/power.h +++ b/drivers/staging/vt6656/power.h @@ -18,7 +18,7 @@ * * File: power.h * - * Purpose: Handles 802.11 power managment functions + * Purpose: Handles 802.11 power management functions * * Author: Lyndon Chen * diff --git a/drivers/staging/vt6656/wmgr.h b/drivers/staging/vt6656/wmgr.h index a7ea49107225..9aa9de399cbf 100644 --- a/drivers/staging/vt6656/wmgr.h +++ b/drivers/staging/vt6656/wmgr.h @@ -343,11 +343,11 @@ typedef struct tagSMgmtObject BOOL bRxBeaconInTBTTWake; BYTE abyPSTxMap[MAX_NODE_NUM + 1]; - // managment command related + // management command related unsigned int uCmdBusy; unsigned int uCmdHostAPBusy; - // managment packet pool + // management packet pool PBYTE pbyMgmtPacketPool; BYTE byMgmtPacketPool[sizeof(STxMgmtPacket) + WLAN_A3FR_MAXLEN]; From 013a468c4504738856d67118492ce7b7fff53a48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Cl=C3=A9ment?= Date: Tue, 15 Jun 2010 10:39:24 -0700 Subject: [PATCH 073/523] Staging: vt6655: struct pci_driver cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename driver struct and callbacks to vt6655_* instead of device_* and add __devinit/__devexit directives. Signed-off-by: Charles Clément Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 38 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index f1af517b74b3..bd27a959add0 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -26,9 +26,9 @@ * * Functions: * - * device_found1 - module initial (insmod) driver entry - * device_remove1 - module remove entry - * device_init_info - device structure resource allocation function + * vt6655_probe - module initial (insmod) driver entry + * vt6655_remove - module remove entry + * vt6655_init_info - device structure resource allocation function * device_free_info - device structure resource free function * device_get_pci_info - get allocated pci io/mem resource * device_print_info - print out resource @@ -284,7 +284,7 @@ static CHIP_INFO chip_info_table[]= { {0,NULL} }; -DEFINE_PCI_DEVICE_TABLE(device_id_table) = { +DEFINE_PCI_DEVICE_TABLE(vt6655_pci_id_table) = { { PCI_VDEVICE(VIA, 0x3253), (kernel_ulong_t)chip_info_table}, { 0, } }; @@ -292,8 +292,8 @@ DEFINE_PCI_DEVICE_TABLE(device_id_table) = { /*--------------------- Static Functions --------------------------*/ -static int device_found1(struct pci_dev *pcid, const struct pci_device_id *ent); -static BOOL device_init_info(struct pci_dev* pcid, PSDevice* ppDevice, PCHIP_INFO); +static int vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent); +static BOOL vt6655_init_info(struct pci_dev* pcid, PSDevice* ppDevice, PCHIP_INFO); static void device_free_info(PSDevice pDevice); static BOOL device_get_pci_info(PSDevice, struct pci_dev* pcid); static void device_print_info(PSDevice pDevice); @@ -358,7 +358,7 @@ static char* get_chip_name(int chip_id) { return chip_info_table[i].name; } -static void device_remove1(struct pci_dev *pcid) +static void __devexit vt6655_remove(struct pci_dev *pcid) { PSDevice pDevice=pci_get_drvdata(pcid); @@ -915,8 +915,8 @@ static const struct net_device_ops device_netdev_ops = { -static int -device_found1(struct pci_dev *pcid, const struct pci_device_id *ent) +static int __devinit +vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent) { static BOOL bFirst = TRUE; struct net_device* dev = NULL; @@ -948,7 +948,7 @@ device_found1(struct pci_dev *pcid, const struct pci_device_id *ent) bFirst=FALSE; } - if (!device_init_info(pcid, &pDevice, pChip_info)) { + if (!vt6655_init_info(pcid, &pDevice, pChip_info)) { return -ENOMEM; } pDevice->dev = dev; @@ -1122,7 +1122,7 @@ static void device_print_info(PSDevice pDevice) } -static BOOL device_init_info(struct pci_dev* pcid, PSDevice* ppDevice, +static BOOL __devinit vt6655_init_info(struct pci_dev* pcid, PSDevice* ppDevice, PCHIP_INFO pChip_info) { PSDevice p; @@ -3601,20 +3601,20 @@ static int ethtool_ioctl(struct net_device *dev, void *useraddr) /*------------------------------------------------------------------*/ -MODULE_DEVICE_TABLE(pci, device_id_table); +MODULE_DEVICE_TABLE(pci, vt6655_pci_id_table); static struct pci_driver device_driver = { name: DEVICE_NAME, - id_table: device_id_table, - probe: device_found1, - remove: device_remove1, + id_table: vt6655_pci_id_table, + probe: vt6655_probe, + remove: vt6655_remove, #ifdef CONFIG_PM suspend: viawget_suspend, resume: viawget_resume, #endif }; -static int __init device_init_module(void) +static int __init vt6655_init_module(void) { int ret; @@ -3630,7 +3630,7 @@ static int __init device_init_module(void) return ret; } -static void __exit device_cleanup_module(void) +static void __exit vt6655_cleanup_module(void) { @@ -3641,8 +3641,8 @@ static void __exit device_cleanup_module(void) } -module_init(device_init_module); -module_exit(device_cleanup_module); +module_init(vt6655_init_module); +module_exit(vt6655_cleanup_module); #ifdef CONFIG_PM From 702422bd2d3f44e454a97ca7054edde84cc18126 Mon Sep 17 00:00:00 2001 From: "R.M. Thomas" Date: Fri, 18 Jun 2010 12:29:49 -0700 Subject: [PATCH 074/523] Staging: easycap: add easycap driver This adds the easycap USB video adapter driver to the staging directory. Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 + drivers/staging/easycap/Kconfig | 16 + drivers/staging/easycap/Makefile | 13 + drivers/staging/easycap/README | 130 + drivers/staging/easycap/easycap.h | 632 +++ drivers/staging/easycap/easycap_debug.h | 27 + drivers/staging/easycap/easycap_ioctl.c | 2651 ++++++++++++ drivers/staging/easycap/easycap_ioctl.h | 29 + drivers/staging/easycap/easycap_low.c | 1057 +++++ drivers/staging/easycap/easycap_main.c | 4342 ++++++++++++++++++++ drivers/staging/easycap/easycap_settings.c | 489 +++ drivers/staging/easycap/easycap_sound.c | 973 +++++ drivers/staging/easycap/easycap_sound.h | 30 + drivers/staging/easycap/easycap_standard.h | 27 + drivers/staging/easycap/easycap_testcard.c | 392 ++ 16 files changed, 10811 insertions(+) create mode 100644 drivers/staging/easycap/Kconfig create mode 100644 drivers/staging/easycap/Makefile create mode 100644 drivers/staging/easycap/README create mode 100644 drivers/staging/easycap/easycap.h create mode 100644 drivers/staging/easycap/easycap_debug.h create mode 100644 drivers/staging/easycap/easycap_ioctl.c create mode 100644 drivers/staging/easycap/easycap_ioctl.h create mode 100644 drivers/staging/easycap/easycap_low.c create mode 100644 drivers/staging/easycap/easycap_main.c create mode 100644 drivers/staging/easycap/easycap_settings.c create mode 100644 drivers/staging/easycap/easycap_sound.c create mode 100644 drivers/staging/easycap/easycap_sound.h create mode 100644 drivers/staging/easycap/easycap_standard.h create mode 100644 drivers/staging/easycap/easycap_testcard.c diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 2faff9697467..d5b827ccecf8 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -149,5 +149,7 @@ source "drivers/staging/mrst-touchscreen/Kconfig" source "drivers/staging/msm/Kconfig" +source "drivers/staging/easycap/Kconfig" + endif # !STAGING_EXCLUDE_BUILD endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 6d21710d3311..2c14f89387be 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -55,3 +55,4 @@ obj-$(CONFIG_ADIS16255) += adis16255/ obj-$(CONFIG_FB_XGI) += xgifb/ obj-$(CONFIG_TOUCHSCREEN_MRSTOUCH) += mrst-touchscreen/ obj-$(CONFIG_MSM_STAGING) += msm/ +obj-$(CONFIG_EASYCAP) += easycap/ diff --git a/drivers/staging/easycap/Kconfig b/drivers/staging/easycap/Kconfig new file mode 100644 index 000000000000..9bff7cf74f01 --- /dev/null +++ b/drivers/staging/easycap/Kconfig @@ -0,0 +1,16 @@ +config EASYCAP + tristate "EasyCAP USB ID 05e1:0408 support" + + ---help--- + This is an integrated audio/video driver for EasyCAP cards with + USB ID 05e1:0408. It supports two hardware variants: + + * EasyCAP USB 2.0 Video Adapter with Audio, Model DC60, + having input cables labelled CVBS, S-VIDEO, AUDIO(L), AUDIO(R) + + * EasyCAP002 4-Channel USB 2.0 DVR, having input cables labelled + 1, 2, 3, 4 and an unlabelled input cable for a microphone. + + To compile this driver as a module, choose M here: the + module will be called easycap + diff --git a/drivers/staging/easycap/Makefile b/drivers/staging/easycap/Makefile new file mode 100644 index 000000000000..d93bd6b70a4b --- /dev/null +++ b/drivers/staging/easycap/Makefile @@ -0,0 +1,13 @@ + +obj-$(CONFIG_EASYCAP) += easycap.o + +easycap-objs := easycap_main.o easycap_low.o easycap_sound.o +easycap-objs += easycap_ioctl.o easycap_settings.o +easycap-objs += easycap_testcard.o + +EXTRA_CFLAGS += -Wall +# Impose all or none of the following: +EXTRA_CFLAGS += -DEASYCAP_IS_VIDEODEV_CLIENT +EXTRA_CFLAGS += -DEASYCAP_NEEDS_V4L2_DEVICE_H +EXTRA_CFLAGS += -DEASYCAP_NEEDS_V4L2_FOPS + diff --git a/drivers/staging/easycap/README b/drivers/staging/easycap/README new file mode 100644 index 000000000000..3775481f05e8 --- /dev/null +++ b/drivers/staging/easycap/README @@ -0,0 +1,130 @@ + + *********************************************************** + * EasyCAP USB 2.0 Video Adapter with Audio, Model DC60 * + * and * + * EasyCAP002 4-Channel USB 2.0 DVR * + *********************************************************** + Mike Thomas + + + +SUPPORTED HARDWARE +------------------ + +This driver is intended for use with hardware having USB ID 05e1:0408. +Two kinds of EasyCAP have this USB ID, namely: + + * EasyCAP USB 2.0 Video Adapter with Audio, Model DC60, + having input cables labelled CVBS, S-VIDEO, AUDIO(L), AUDIO(R) + + * EasyCAP002 4-Channel USB 2.0 DVR, having input cables labelled + 1, 2, 3, 4 and an unlabelled input cable for a microphone. + + +BUILD OPTIONS AND DEPENDENCIES +------------------------------ + +If the parameter EASYCAP_IS_VIDEODEV_CLIENT is undefined during compilation +the built module is entirely independent of the videodev module, and when +the EasyCAP is physically plugged into a USB port the special files +/dev/easycap0 and /dev/easysnd1 are created as video and sound sources +respectively. + +If the parameter EASYCAP_IS_VIDEODEV_CLIENT is defined during compilation +the built easycap module is configured to register with the videodev module, +in which case the special files created when the EasyCAP is plugged in are +/dev/video0 and /dev/easysnd0. Use of the easycap module as a client of +the videodev module has received very little testing as of June 2010. + + +KNOWN BUILD PROBLEMS +-------------------- + +(1) Recent gcc versions may generate the message: + + warning: the frame size of .... bytes is larger than 1024 bytes + +This warning can be suppressed by specifying in the Makefile: + + EXTRA_CFLAGS += -Wframe-larger-than=8192 + +but it would be preferable to remove the cause of the warning. + + +KNOWN RUNTIME ISSUES +-------------------- + +(1) Randomly (maybe 5 to 10% of occasions) the driver fails to produce any +output at start-up. Closing mplayer (or whatever the user program is) and +restarting it restores normal performance without any other remedial action +being necessary. The reason for this is not known. + +(2) Intentionally, this driver will not stream material which is unambiguously +identified by the hardware as copy-protected. The video output will freeze +within about a minute when this situation arises. + +(3) The controls for luminance, contrast, saturation, hue and volume may not +always work properly. + +(4) Reduced-resolution S-Video seems to suffer from moire artefacts. No +attempt has yet been made to rememdy this. + + +SUPPORTED TV STANDARDS AND RESOLUTIONS +-------------------------------------- + +The following TV standards are natively supported by the hardware and are +usable as (for example) the "norm=" parameter in the mplayer command: + + PAL_BGHIN, NTSC_N_443, + PAL_Nc, NTSC_N, + SECAM, NTSC_M, NTSC_M_JP, + PAL_60, NTSC_443, + PAL_M. + +The available picture sizes are: + + at 25 frames per second: 720x576, 704x576, 640x480, 360x288, 320x240; + at 30 frames per second: 720x480, 640x480, 360x240, 320x240; + + +WHAT'S TESTED AND WHAT'S NOT +---------------------------- + +This driver is known to work with mplayer, mencoder, tvtime and sufficiently +recent versions of vlc. An interface to ffmpeg is implemented, but serious +audio-video synchronization problems remain. + +The driver is designed to support all the TV standards accepted by the +hardware, but as yet it has actually been tested on only a few of these. + +I have been unable to test and calibrate the S-video input myself because I +do not possess any equipment with S-video output. + +This driver does not understand the V4L1 IOCTL commands, so programs such +as camorama are not compatible. There are reports that the driver does +work with sufficiently recent (V4L2) versions of zoneminder, but I have not +attempted to confirm this myself. + + +UDEV RULES +---------- + +In order that the special files /dev/easycap0 and /dev/easysnd1 are created +with conveniently relaxed permissions when the EasyCAP is plugged in, a file +is preferably to be provided in directory /etc/udev/rules.d with content: + +ACTION!="add|change", GOTO="easycap_rules_end" +ATTRS{idVendor}=="05e1", ATTRS{idProduct}=="0408", \ + MODE="0666", OWNER="root", GROUP="root" +LABEL="easycap_rules_end" + + +ACKNOWLEGEMENTS AND REFERENCES +------------------------------ +This driver makes use of information contained in the Syntek Semicon DC-1125 +Driver, presently maintained at http://sourceforge.net/projects/syntekdriver/ +by Nicolas Vivien. Particularly useful has been a patch to the latter driver +provided by Ivor Hewitt in January 2009. The NTSC implementation is taken +from the work of Ben Trask. + diff --git a/drivers/staging/easycap/easycap.h b/drivers/staging/easycap/easycap.h new file mode 100644 index 000000000000..83ae2fb6db7c --- /dev/null +++ b/drivers/staging/easycap/easycap.h @@ -0,0 +1,632 @@ +/***************************************************************************** +* * +* easycap.h * +* * +*****************************************************************************/ +/* + * + * Copyright (C) 2010 R.M. Thomas + * + * + * This 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. + * + * The software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * +*/ +/*****************************************************************************/ +/*---------------------------------------------------------------------------*/ +/* + * THE FOLLOWING PARAMETERS ARE UNDEFINED: + * + * EASYCAP_DEBUG + * EASYCAP_IS_VIDEODEV_CLIENT + * EASYCAP_NEEDS_USBVIDEO_H + * EASYCAP_NEEDS_V4L2_DEVICE_H + * EASYCAP_NEEDS_V4L2_FOPS + * + * IF REQUIRED THEY MUST BE EXTERNALLY DEFINED, FOR EXAMPLE AS COMPILER + * OPTIONS. + */ +/*---------------------------------------------------------------------------*/ + +#if (!defined(EASYCAP_H)) +#define EASYCAP_H + +#if defined(EASYCAP_DEBUG) +#if (9 < EASYCAP_DEBUG) +#error Debug levels 0 to 9 are okay.\ + To achieve higher levels, remove this trap manually from easycap.h +#endif +#endif /*EASYCAP_DEBUG*/ +/*---------------------------------------------------------------------------*/ +/* + * THESE ARE FOR MAINTENANCE ONLY - NORMALLY UNDEFINED: + */ +/*---------------------------------------------------------------------------*/ +#undef PREFER_NTSC +#undef EASYCAP_TESTCARD +#undef EASYCAP_TESTTONE +#undef LOCKFRAME +#undef NOREADBACK +#undef AUDIOTIME +/*---------------------------------------------------------------------------*/ +/* + * + * DEFINE BRIDGER TO ACTIVATE THE ROUTINE FOR BRIDGING VIDEOTAPE DROPOUTS. + * + * *** UNDER DEVELOPMENT/TESTING - NOT READY YET!*** + * + */ +/*---------------------------------------------------------------------------*/ +#undef BRIDGER +/*---------------------------------------------------------------------------*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ +#if defined(EASYCAP_IS_VIDEODEV_CLIENT) +#if (!defined(__OLD_VIDIOC_)) +#define __OLD_VIDIOC_ +#endif /* !defined(__OLD_VIDIOC_) */ + +#include + +#if defined(EASYCAP_NEEDS_V4L2_DEVICE_H) +#include +#endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/ +#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + +#if (!defined(__OLD_VIDIOC_)) +#define __OLD_VIDIOC_ +#endif /* !defined(__OLD_VIDIOC_) */ +#include + +#include + +#if defined(EASYCAP_NEEDS_USBVIDEO_H) +#include +#endif /*EASYCAP_NEEDS_USBVIDEO_H*/ + +#if (!defined(PAGE_SIZE)) +#error "PAGE_SIZE not defined" +#endif + +#define STRINGIZE_AGAIN(x) #x +#define STRINGIZE(x) STRINGIZE_AGAIN(x) + +/*---------------------------------------------------------------------------*/ +/* VENDOR, PRODUCT: Syntek Semiconductor Co., Ltd + * + * EITHER EasyCAP USB 2.0 Video Adapter with Audio, Model No. DC60 + * with input cabling: AUDIO(L), AUDIO(R), CVBS, S-VIDEO. + * + * OR EasyCAP 4CHANNEL USB 2.0 DVR, Model No. EasyCAP002 + * with input cabling: MICROPHONE, CVBS1, CVBS2, CVBS3, CVBS4. + */ +/*---------------------------------------------------------------------------*/ +#define USB_EASYCAP_VENDOR_ID 0x05e1 +#define USB_EASYCAP_PRODUCT_ID 0x0408 + +#define EASYCAP_DRIVER_VERSION "0.8" +#define EASYCAP_DRIVER_DESCRIPTION "easycapdc60" + +#define USB_SKEL_MINOR_BASE 192 +#define VIDEO_DEVICE_MANY 8 + +/*---------------------------------------------------------------------------*/ +/* + * DEFAULT LUMINANCE, CONTRAST, SATURATION AND HUE + */ +/*---------------------------------------------------------------------------*/ +#define SAA_0A_DEFAULT 0x7F +#define SAA_0B_DEFAULT 0x3F +#define SAA_0C_DEFAULT 0x2F +#define SAA_0D_DEFAULT 0x00 +/*---------------------------------------------------------------------------*/ +/* + * VIDEO STREAMING PARAMETERS: + * USB 2.0 PROVIDES FOR HIGH-BANDWIDTH ENDPOINTS WITH AN UPPER LIMIT + * OF 3072 BYTES PER MICROFRAME for wMaxPacketSize. + */ +/*---------------------------------------------------------------------------*/ +#define VIDEO_ISOC_BUFFER_MANY 16 +#define VIDEO_ISOC_ORDER 3 +#define VIDEO_ISOC_FRAMESPERDESC ((unsigned int) 1 << VIDEO_ISOC_ORDER) +#define USB_2_0_MAXPACKETSIZE 3072 +#if (USB_2_0_MAXPACKETSIZE > PAGE_SIZE) +#error video_isoc_buffer[.] will not be big enough +#endif +/*---------------------------------------------------------------------------*/ +/* + * VIDEO BUFFERS + */ +/*---------------------------------------------------------------------------*/ +#define FIELD_BUFFER_SIZE (203 * PAGE_SIZE) +#define FRAME_BUFFER_SIZE (405 * PAGE_SIZE) +#define FIELD_BUFFER_MANY 4 +#define FRAME_BUFFER_MANY 6 +/*---------------------------------------------------------------------------*/ +/* + * AUDIO STREAMING PARAMETERS + */ +/*---------------------------------------------------------------------------*/ +#define AUDIO_ISOC_BUFFER_MANY 16 +#define AUDIO_ISOC_ORDER 3 +#define AUDIO_ISOC_BUFFER_SIZE (PAGE_SIZE << AUDIO_ISOC_ORDER) +/*---------------------------------------------------------------------------*/ +/* + * AUDIO BUFFERS + */ +/*---------------------------------------------------------------------------*/ +#define AUDIO_FRAGMENT_MANY 32 +/*---------------------------------------------------------------------------*/ +/* + * STRUCTURE DEFINITIONS + */ +/*---------------------------------------------------------------------------*/ +struct data_buffer { +struct list_head list_head; +void *pgo; +void *pto; +__u16 kount; +}; +/*---------------------------------------------------------------------------*/ +struct data_urb { +struct list_head list_head; +struct urb *purb; +int isbuf; +int length; +}; +/*---------------------------------------------------------------------------*/ +/* + * easycap.ilk == 0 => CVBS+S-VIDEO HARDWARE, AUDIO wMaxPacketSize=256 + * easycap.ilk == 2 => CVBS+S-VIDEO HARDWARE, AUDIO wMaxPacketSize=9 + * easycap.ilk == 3 => FOUR-CVBS HARDWARE, AUDIO wMaxPacketSize=9 + */ +/*---------------------------------------------------------------------------*/ +struct easycap { + +int ilk; +bool microphone; + +/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ +#if defined(EASYCAP_IS_VIDEODEV_CLIENT) +struct video_device *pvideo_device; +#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + +struct usb_device *pusb_device; +struct usb_interface *pusb_interface; + +struct kref kref; + +struct mutex mutex_mmap_video[FRAME_BUFFER_MANY]; +struct mutex mutex_timeval0; +struct mutex mutex_timeval1; + +int queued[FRAME_BUFFER_MANY]; +int done[FRAME_BUFFER_MANY]; + +wait_queue_head_t wq_video; +wait_queue_head_t wq_audio; + +int input; +int polled; +int standard_offset; +int format_offset; + +int fps; +int usec; +int tolerate; +int merit[180]; + +struct timeval timeval0; +struct timeval timeval1; +struct timeval timeval2; +struct timeval timeval7; +long long int dnbydt; + +int video_interface; +int video_altsetting_on; +int video_altsetting_off; +int video_endpointnumber; +int video_isoc_maxframesize; +int video_isoc_buffer_size; +int video_isoc_framesperdesc; + +int video_isoc_streaming; +int video_isoc_sequence; +int video_idle; +int video_eof; +int video_junk; + +int fudge; + +struct data_buffer video_isoc_buffer[VIDEO_ISOC_BUFFER_MANY]; +struct data_buffer \ + field_buffer[FIELD_BUFFER_MANY][(FIELD_BUFFER_SIZE/PAGE_SIZE)]; +struct data_buffer \ + frame_buffer[FRAME_BUFFER_MANY][(FRAME_BUFFER_SIZE/PAGE_SIZE)]; + +struct list_head urb_video_head; +struct list_head *purb_video_head; + +int vma_many; + +/*---------------------------------------------------------------------------*/ +/* + * BUFFER INDICATORS + */ +/*---------------------------------------------------------------------------*/ +int field_fill; /* Field buffer being filled by easycap_complete(). */ + /* Bumped only by easycap_complete(). */ +int field_page; /* Page of field buffer page being filled by */ + /* easycap_complete(). */ +int field_read; /* Field buffer to be read by field2frame(). */ + /* Bumped only by easycap_complete(). */ +int frame_fill; /* Frame buffer being filled by field2frame(). */ + /* Bumped only by easycap_dqbuf() when */ + /* field2frame() has created a complete frame. */ +int frame_read; /* Frame buffer offered to user by DQBUF. */ + /* Set only by easycap_dqbuf() to trail frame_fill.*/ +int frame_lock; /* Flag set to 1 by DQBUF and cleared by QBUF */ +/*---------------------------------------------------------------------------*/ +/* + * IMAGE PROPERTIES + */ +/*---------------------------------------------------------------------------*/ +__u32 pixelformat; +__u32 field; +int width; +int height; +int bytesperpixel; +bool byteswaporder; +bool decimatepixel; +bool offerfields; +int frame_buffer_used; +int frame_buffer_many; +int videofieldamount; + +int brightness; +int contrast; +int saturation; +int hue; + +int allocation_video_urb; +int allocation_video_page; +int allocation_video_struct; +int registered_video; +/*---------------------------------------------------------------------------*/ +/* + * SOUND PROPERTIES + */ +/*---------------------------------------------------------------------------*/ +int audio_interface; +int audio_altsetting_on; +int audio_altsetting_off; +int audio_endpointnumber; +int audio_isoc_maxframesize; +int audio_isoc_buffer_size; +int audio_isoc_framesperdesc; + +int audio_isoc_streaming; +int audio_idle; +int audio_eof; +int volume; +int mute; + +struct data_buffer audio_isoc_buffer[AUDIO_ISOC_BUFFER_MANY]; + +struct list_head urb_audio_head; +struct list_head *purb_audio_head; +/*---------------------------------------------------------------------------*/ +/* + * BUFFER INDICATORS + */ +/*---------------------------------------------------------------------------*/ +int audio_fill; /* Audio buffer being filled by easysnd_complete(). */ + /* Bumped only by easysnd_complete(). */ +int audio_read; /* Audio buffer page being read by easysnd_read(). */ + /* Set by easysnd_read() to trail audio_fill by */ + /* one fragment. */ +/*---------------------------------------------------------------------------*/ +/* + * SOUND PROPERTIES + */ +/*---------------------------------------------------------------------------*/ + +int audio_buffer_many; + +int allocation_audio_urb; +int allocation_audio_page; +int allocation_audio_struct; +int registered_audio; + +long long int audio_sample; +long long int audio_niveau; +long long int audio_square; + +struct data_buffer audio_buffer[]; +}; +/*---------------------------------------------------------------------------*/ +struct easycap_standard { +__u16 mask; +struct v4l2_standard v4l2_standard; +}; +struct easycap_format { +__u16 mask; +char name[128]; +struct v4l2_format v4l2_format; +}; +/*---------------------------------------------------------------------------*/ +/* + * VIDEO FUNCTION PROTOTYPES + */ +/*---------------------------------------------------------------------------*/ +void easycap_complete(struct urb *); +int easycap_open(struct inode *, struct file *); +int easycap_release(struct inode *, struct file *); +int easycap_ioctl(struct inode *, struct file *, \ + unsigned int, unsigned long); + +/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ +#if defined(EASYCAP_IS_VIDEODEV_CLIENT) +int easycap_open_noinode(struct file *); +int easycap_release_noinode(struct file *); +long easycap_ioctl_noinode(struct file *, \ + unsigned int, unsigned long); +int videodev_release(struct video_device *); +#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + +unsigned int easycap_poll(struct file *, poll_table *); +int easycap_mmap(struct file *, struct vm_area_struct *); +int easycap_usb_probe(struct usb_interface *, \ + const struct usb_device_id *); +void easycap_usb_disconnect(struct usb_interface *); +void easycap_delete(struct kref *); + +void easycap_vma_open(struct vm_area_struct *); +void easycap_vma_close(struct vm_area_struct *); +int easycap_vma_fault(struct vm_area_struct *, struct vm_fault *); +int easycap_dqbuf(struct easycap *, int); +int submit_video_urbs(struct easycap *); +int kill_video_urbs(struct easycap *); +int field2frame(struct easycap *); +int redaub(struct easycap *, void *, void *, \ + int, int, __u8, __u8, bool); +void debrief(struct easycap *); +void sayreadonly(struct easycap *); +void easycap_testcard(struct easycap *, int); +int explain_ioctl(__u32); +int explain_cid(__u32); +int fillin_formats(void); +int adjust_standard(struct easycap *, v4l2_std_id); +int adjust_format(struct easycap *, __u32, __u32, __u32, \ + int, bool); +int adjust_brightness(struct easycap *, int); +int adjust_contrast(struct easycap *, int); +int adjust_saturation(struct easycap *, int); +int adjust_hue(struct easycap *, int); +int adjust_volume(struct easycap *, int); +/*---------------------------------------------------------------------------*/ +/* + * AUDIO FUNCTION PROTOTYPES + */ +/*---------------------------------------------------------------------------*/ +void easysnd_complete(struct urb *); +ssize_t easysnd_read(struct file *, char __user *, size_t, loff_t *); +int easysnd_open(struct inode *, struct file *); +int easysnd_release(struct inode *, struct file *); +int easysnd_ioctl(struct inode *, struct file *, \ + unsigned int, unsigned long); +unsigned int easysnd_poll(struct file *, poll_table *); +void easysnd_delete(struct kref *); +int submit_audio_urbs(struct easycap *); +int kill_audio_urbs(struct easycap *); +void easysnd_testtone(struct easycap *, int); +int audio_setup(struct easycap *); +/*---------------------------------------------------------------------------*/ +/* + * LOW-LEVEL FUNCTION PROTOTYPES + */ +/*---------------------------------------------------------------------------*/ +int audio_gainget(struct usb_device *); +int audio_gainset(struct usb_device *, __s8); + +int set_interface(struct usb_device *, __u16); +int wakeup_device(struct usb_device *); +int confirm_resolution(struct usb_device *); +int confirm_stream(struct usb_device *); + +int setup_stk(struct usb_device *); +int setup_saa(struct usb_device *); +int setup_vt(struct usb_device *); +int check_stk(struct usb_device *); +int check_saa(struct usb_device *); +int ready_saa(struct usb_device *); +int merit_saa(struct usb_device *); +int check_vt(struct usb_device *); +int select_input(struct usb_device *, int, int); +int set_resolution(struct usb_device *, \ + __u16, __u16, __u16, __u16); + +int read_saa(struct usb_device *, __u16); +int read_stk(struct usb_device *, __u32); +int write_saa(struct usb_device *, __u16, __u16); +int wait_i2c(struct usb_device *); +int write_000(struct usb_device *, __u16, __u16); +int start_100(struct usb_device *); +int stop_100(struct usb_device *); +int write_300(struct usb_device *); +int read_vt(struct usb_device *, __u16); +int write_vt(struct usb_device *, __u16, __u16); + +int set2to78(struct usb_device *); +int set2to93(struct usb_device *); + +int regset(struct usb_device *, __u16, __u16); +int regget(struct usb_device *, __u16, void *); +/*---------------------------------------------------------------------------*/ +struct signed_div_result { +long long int quotient; +unsigned long long int remainder; +} signed_div(long long int, long long int); +/*---------------------------------------------------------------------------*/ +/* + * IT IS ESSENTIAL THAT EVEN-NUMBERED STANDARDS ARE 25 FRAMES PER SECOND, + * ODD-NUMBERED STANDARDS ARE 30 FRAMES PER SECOND. + * THE NUMBERING OF STANDARDS MUST NOT BE CHANGED WITHOUT DUE CARE. NOT + * ONLY MUST THE PARAMETER + * STANDARD_MANY + * BE CHANGED TO CORRESPOND TO THE NEW NUMBER OF STANDARDS, BUT ALSO THE + * NUMBERING MUST REMAIN AN UNBROKEN ASCENDING SEQUENCE: DUMMY STANDARDS + * MAY NEED TO BE ADDED. APPROPRIATE CHANGES WILL ALWAYS BE REQUIRED IN + * ROUTINE fillin_formats() AND POSSIBLY ELSEWHERE. BEWARE. + */ +/*---------------------------------------------------------------------------*/ +#define PAL_BGHIN 0 +#define PAL_Nc 2 +#define SECAM 4 +#define NTSC_N 6 +#define NTSC_N_443 8 +#define NTSC_M 1 +#define NTSC_443 3 +#define NTSC_M_JP 5 +#define PAL_60 7 +#define PAL_M 9 +#define STANDARD_MANY 10 +/*---------------------------------------------------------------------------*/ +/* + * ENUMS + */ +/*---------------------------------------------------------------------------*/ +enum { +AT_720x576, +AT_704x576, +AT_640x480, +AT_720x480, +AT_360x288, +AT_320x240, +AT_360x240, +RESOLUTION_MANY +}; +enum { +FMT_UYVY, +FMT_YUY2, +FMT_RGB24, +FMT_RGB32, +FMT_BGR24, +FMT_BGR32, +PIXELFORMAT_MANY +}; +enum { +FIELD_NONE, +FIELD_INTERLACED, +FIELD_ALTERNATE, +INTERLACE_MANY +}; +#define SETTINGS_MANY (STANDARD_MANY * \ + RESOLUTION_MANY * \ + 2 * \ + PIXELFORMAT_MANY * \ + INTERLACE_MANY) +/*---------------------------------------------------------------------------*/ +/* + * MACROS + */ +/*---------------------------------------------------------------------------*/ +#define GET(X, Y, Z) do { \ + int rc; \ + *(Z) = (__u16)0; \ + rc = regget(X, Y, Z); \ + if (0 > rc) { \ + JOT(8, ":-(%i\n", __LINE__); return(rc); \ + } \ +} while (0) + +#define SET(X, Y, Z) do { \ + int rc; \ + rc = regset(X, Y, Z); \ + if (0 > rc) { \ + JOT(8, ":-(%i\n", __LINE__); return(rc); \ + } \ +} while (0) +/*---------------------------------------------------------------------------*/ + +#define SAY(format, args...) do { \ + printk(KERN_DEBUG "easycap: %s: " format, __func__, ##args); \ +} while (0) + + +#if defined(EASYCAP_DEBUG) +#define JOT(n, format, args...) do { \ + if (n <= easycap_debug) { \ + printk(KERN_DEBUG "easycap: %s: " format, __func__, ##args); \ + } \ +} while (0) +#else +#define JOT(n, format, args...) do {} while (0) +#endif /*EASYCAP_DEBUG*/ + +#define POUT JOT(8, ":-(in file %s line %4i\n", __FILE__, __LINE__) + +#define MICROSECONDS(X, Y) \ + ((1000000*((long long int)(X.tv_sec - Y.tv_sec))) + \ + (long long int)(X.tv_usec - Y.tv_usec)) + +/*---------------------------------------------------------------------------*/ +/* + * (unsigned char *)P pointer to next byte pair + * (long int *)X pointer to accumulating count + * (long int *)Y pointer to accumulating sum + * (long long int *)Z pointer to accumulating sum of squares + */ +/*---------------------------------------------------------------------------*/ +#define SUMMER(P, X, Y, Z) do { \ + unsigned char *p; \ + unsigned int u0, u1, u2; \ + long int s; \ + p = (unsigned char *)(P); \ + u0 = (unsigned int) (*p); \ + u1 = (unsigned int) (*(p + 1)); \ + u2 = (unsigned int) ((u1 << 8) | u0); \ + if (0x8000 & u2) \ + s = -(long int)(0x7FFF & (~u2)); \ + else \ + s = (long int)(0x7FFF & u2); \ + *((X)) += (long int) 1; \ + *((Y)) += (long int) s; \ + *((Z)) += ((long long int)(s) * (long long int)(s)); \ +} while (0) +/*---------------------------------------------------------------------------*/ + +#endif /*EASYCAP_H*/ diff --git a/drivers/staging/easycap/easycap_debug.h b/drivers/staging/easycap/easycap_debug.h new file mode 100644 index 000000000000..1d10d7ea7d68 --- /dev/null +++ b/drivers/staging/easycap/easycap_debug.h @@ -0,0 +1,27 @@ +/***************************************************************************** +* * +* easycap_debug.h * +* * +*****************************************************************************/ +/* + * + * Copyright (C) 2010 R.M. Thomas + * + * + * This 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. + * + * The software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * +*/ +/*****************************************************************************/ +extern int easycap_debug; diff --git a/drivers/staging/easycap/easycap_ioctl.c b/drivers/staging/easycap/easycap_ioctl.c new file mode 100644 index 000000000000..f71cd9eaeb6b --- /dev/null +++ b/drivers/staging/easycap/easycap_ioctl.c @@ -0,0 +1,2651 @@ +/****************************************************************************** +* * +* easycap_ioctl.c * +* * +******************************************************************************/ +/* + * + * Copyright (C) 2010 R.M. Thomas + * + * + * This 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. + * + * The software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * +*/ +/*****************************************************************************/ + +#include "easycap.h" +#include "easycap_debug.h" +#include "easycap_standard.h" +#include "easycap_ioctl.h" + +/*--------------------------------------------------------------------------*/ +/* + * UNLESS THERE IS A PREMATURE ERROR RETURN THIS ROUTINE UPDATES THE + * FOLLOWING: + * peasycap->standard_offset + * peasycap->fps + * peasycap->usec + * peasycap->tolerate + */ +/*---------------------------------------------------------------------------*/ +int adjust_standard(struct easycap *peasycap, v4l2_std_id std_id) +{ +struct easycap_standard *peasycap_standard; +__u16 reg, set; +int ir, rc, need; +unsigned int itwas, isnow; + +if ((struct usb_device *)NULL == peasycap->pusb_device) { + SAY("ERROR: peasycap->pusb_device is NULL\n"); + return -EFAULT; +} +peasycap_standard = &easycap_standard[0]; +while (0xFFFF != peasycap_standard->mask) { + if (std_id & peasycap_standard->v4l2_standard.id) + break; + peasycap_standard++; +} +if (0xFFFF == peasycap_standard->mask) { + SAY("ERROR: 0x%08X=std_id: standard not found\n", \ + (unsigned int)std_id); + return -EINVAL; +} +SAY("user requests standard: %s\n", \ + &(peasycap_standard->v4l2_standard.name[0])); +if (peasycap->standard_offset == \ + (int)(peasycap_standard - &easycap_standard[0])) { + SAY("requested standard already in effect\n"); + return 0; +} +peasycap->standard_offset = (int)(peasycap_standard - &easycap_standard[0]); +peasycap->fps = peasycap_standard->v4l2_standard.frameperiod.denominator / \ + peasycap_standard->v4l2_standard.frameperiod.numerator; +if (!peasycap->fps) { + SAY("MISTAKE: frames-per-second is zero\n"); + return -EFAULT; +} +JOT(8, "%i frames-per-second\n", peasycap->fps); +peasycap->usec = 1000000 / (2 * peasycap->fps); +peasycap->tolerate = 1000 * (25 / peasycap->fps); + +kill_video_urbs(peasycap); + +/*--------------------------------------------------------------------------*/ +/* + * SAA7113H DATASHEET PAGE 44, TABLE 42 + */ +/*--------------------------------------------------------------------------*/ +need = 0; itwas = 0; reg = 0x00; set = 0x00; +switch (peasycap_standard->mask & 0x000F) { +case NTSC_M_JP: { + reg = 0x0A; set = 0x95; + ir = read_saa(peasycap->pusb_device, reg); + if (0 > ir) + SAY("ERROR: cannot read SAA register 0x%02X\n", reg); + else + itwas = (unsigned int)ir; + + + set2to78(peasycap->pusb_device); + + + rc = write_saa(peasycap->pusb_device, reg, set); + if (0 != rc) + SAY("ERROR: failed to set SAA register " \ + "0x%02X to 0x%02X for JP standard\n", reg, set); + else { + isnow = (unsigned int)read_saa(peasycap->pusb_device, reg); + if (0 > ir) + JOT(8, "SAA register 0x%02X changed " \ + "to 0x%02X\n", reg, isnow); + else + JOT(8, "SAA register 0x%02X changed " \ + "from 0x%02X to 0x%02X\n", reg, itwas, isnow); + + set2to78(peasycap->pusb_device); + + } + + reg = 0x0B; set = 0x48; + ir = read_saa(peasycap->pusb_device, reg); + if (0 > ir) + SAY("ERROR: cannot read SAA register 0x%02X\n", reg); + else + itwas = (unsigned int)ir; + + set2to78(peasycap->pusb_device); + + rc = write_saa(peasycap->pusb_device, reg, set); + if (0 != rc) + SAY("ERROR: failed to set SAA register 0x%02X to 0x%02X " \ + "for JP standard\n", reg, set); + else { + isnow = (unsigned int)read_saa(peasycap->pusb_device, reg); + if (0 > ir) + JOT(8, "SAA register 0x%02X changed " \ + "to 0x%02X\n", reg, isnow); + else + JOT(8, "SAA register 0x%02X changed " \ + "from 0x%02X to 0x%02X\n", reg, itwas, isnow); + + set2to78(peasycap->pusb_device); + + } +/*--------------------------------------------------------------------------*/ +/* + * NOTE: NO break HERE: RUN ON TO NEXT CASE + */ +/*--------------------------------------------------------------------------*/ +} +case NTSC_M: +case PAL_BGHIN: { + reg = 0x0E; set = 0x01; need = 1; break; +} +case NTSC_N_443: +case PAL_60: { + reg = 0x0E; set = 0x11; need = 1; break; +} +case NTSC_443: +case PAL_Nc: { + reg = 0x0E; set = 0x21; need = 1; break; +} +case NTSC_N: +case PAL_M: { + reg = 0x0E; set = 0x31; need = 1; break; +} +case SECAM: { + reg = 0x0E; set = 0x51; need = 1; break; +} +default: + break; +} +/*--------------------------------------------------------------------------*/ +if (need) { + ir = read_saa(peasycap->pusb_device, reg); + if (0 > ir) + SAY("ERROR: failed to read SAA register 0x%02X\n", reg); + else + itwas = (unsigned int)ir; + + set2to78(peasycap->pusb_device); + + rc = write_saa(peasycap->pusb_device, reg, set); + if (0 != write_saa(peasycap->pusb_device, reg, set)) { + SAY("ERROR: failed to set SAA register " \ + "0x%02X to 0x%02X for table 42\n", reg, set); + } else { + isnow = (unsigned int)read_saa(peasycap->pusb_device, reg); + if (0 > ir) + JOT(8, "SAA register 0x%02X changed " \ + "to 0x%02X\n", reg, isnow); + else + JOT(8, "SAA register 0x%02X changed " \ + "from 0x%02X to 0x%02X\n", reg, itwas, isnow); + } +} +/*--------------------------------------------------------------------------*/ +/* + * SAA7113H DATASHEET PAGE 41 + */ +/*--------------------------------------------------------------------------*/ +reg = 0x08; +ir = read_saa(peasycap->pusb_device, reg); +if (0 > ir) + SAY("ERROR: failed to read SAA register 0x%02X " \ + "so cannot reset\n", reg); +else { + itwas = (unsigned int)ir; + if (peasycap_standard->mask & 0x0001) + set = itwas | 0x40 ; + else + set = itwas & ~0x40 ; + +set2to78(peasycap->pusb_device); + +rc = write_saa(peasycap->pusb_device, reg, set); +if (0 != rc) + SAY("ERROR: failed to set SAA register 0x%02X to 0x%02X\n", reg, set); +else { + isnow = (unsigned int)read_saa(peasycap->pusb_device, reg); + if (0 > ir) + JOT(8, "SAA register 0x%02X changed to 0x%02X\n", reg, isnow); + else + JOT(8, "SAA register 0x%02X changed " \ + "from 0x%02X to 0x%02X\n", reg, itwas, isnow); + } +} +/*--------------------------------------------------------------------------*/ +/* + * SAA7113H DATASHEET PAGE 51, TABLE 57 + */ +/*---------------------------------------------------------------------------*/ +reg = 0x40; +ir = read_saa(peasycap->pusb_device, reg); +if (0 > ir) + SAY("ERROR: failed to read SAA register 0x%02X " \ + "so cannot reset\n", reg); +else { + itwas = (unsigned int)ir; + if (peasycap_standard->mask & 0x0001) + set = itwas | 0x80 ; + else + set = itwas & ~0x80 ; + +set2to78(peasycap->pusb_device); + +rc = write_saa(peasycap->pusb_device, reg, set); +if (0 != rc) + SAY("ERROR: failed to set SAA register 0x%02X to 0x%02X\n", reg, set); +else { + isnow = (unsigned int)read_saa(peasycap->pusb_device, reg); + if (0 > ir) + JOT(8, "SAA register 0x%02X changed to 0x%02X\n", reg, isnow); + else + JOT(8, "SAA register 0x%02X changed " \ + "from 0x%02X to 0x%02X\n", reg, itwas, isnow); + } +} +/*--------------------------------------------------------------------------*/ +/* + * SAA7113H DATASHEET PAGE 53, TABLE 66 + */ +/*--------------------------------------------------------------------------*/ +reg = 0x5A; +ir = read_saa(peasycap->pusb_device, reg); +if (0 > ir) + SAY("ERROR: failed to read SAA register 0x%02X but continuing\n", reg); + itwas = (unsigned int)ir; + if (peasycap_standard->mask & 0x0001) + set = 0x0A ; + else + set = 0x07 ; + + set2to78(peasycap->pusb_device); + + if (0 != write_saa(peasycap->pusb_device, reg, set)) + SAY("ERROR: failed to set SAA register 0x%02X to 0x%02X\n", \ + reg, set); + else { + isnow = (unsigned int)read_saa(peasycap->pusb_device, reg); + if (0 > ir) + JOT(8, "SAA register 0x%02X changed " + "to 0x%02X\n", reg, isnow); + else + JOT(8, "SAA register 0x%02X changed " + "from 0x%02X to 0x%02X\n", reg, itwas, isnow); + } + if (0 != check_saa(peasycap->pusb_device)) + SAY("ERROR: check_saa() failed\n"); +return 0; +} +/*****************************************************************************/ +/*--------------------------------------------------------------------------*/ +/* + * THE ALGORITHM FOR RESPONDING TO THE VIDIO_S_FMT IOCTL DEPENDS ON THE + * CURRENT VALUE OF peasycap->standard_offset. + * PROVIDED THE ARGUMENT try IS false AND THERE IS NO PREMATURE ERROR RETURN + * THIS ROUTINE UPDATES THE FOLLOWING: + * peasycap->format_offset + * peasycap->pixelformat + * peasycap->field + * peasycap->height + * peasycap->width + * peasycap->bytesperpixel + * peasycap->byteswaporder + * peasycap->decimatepixel + * peasycap->frame_buffer_used + * peasycap->videofieldamount + * peasycap->offerfields + * + * IF SUCCESSFUL THE FUNCTION RETURNS THE OFFSET IN easycap_format[] + * IDENTIFYING THE FORMAT WHICH IS TO RETURNED TO THE USER. + * ERRORS RETURN A NEGATIVE NUMBER. + */ +/*--------------------------------------------------------------------------*/ +int adjust_format(struct easycap *peasycap, \ + __u32 width, __u32 height, __u32 pixelformat, int field, bool try) +{ +struct easycap_format *peasycap_format, *peasycap_best_format; +__u16 mask; +struct usb_device *p; +int miss, multiplier, best; +char bf[5], *pc; +__u32 uc; + +if ((struct easycap *)NULL == peasycap) { + SAY("ERROR: peasycap is NULL\n"); + return -EFAULT; +} +p = peasycap->pusb_device; +if ((struct usb_device *)NULL == p) { + SAY("ERROR: peaycap->pusb_device is NULL\n"); + return -EFAULT; +} +pc = &bf[0]; +uc = pixelformat; memcpy((void *)pc, (void *)(&uc), 4); bf[4] = 0; +mask = easycap_standard[peasycap->standard_offset].mask; +SAY("sought: %ix%i,%s(0x%08X),%i=field,0x%02X=std mask\n", \ + width, height, pc, pixelformat, field, mask); +if (V4L2_FIELD_ANY == field) { + field = V4L2_FIELD_INTERLACED; + SAY("prefer: V4L2_FIELD_INTERLACED=field, was V4L2_FIELD_ANY\n"); +} +peasycap_best_format = (struct easycap_format *)NULL; +peasycap_format = &easycap_format[0]; +while (0 != peasycap_format->v4l2_format.fmt.pix.width) { + JOT(16, ".> %i %i 0x%08X %ix%i\n", \ + peasycap_format->mask & 0x01, + peasycap_format->v4l2_format.fmt.pix.field, + peasycap_format->v4l2_format.fmt.pix.pixelformat, + peasycap_format->v4l2_format.fmt.pix.width, + peasycap_format->v4l2_format.fmt.pix.height); + + if (((peasycap_format->mask & 0x0F) == (mask & 0x0F)) && \ + (peasycap_format->v4l2_format.fmt.pix.field == field) && \ + (peasycap_format->v4l2_format.fmt.pix.pixelformat == \ + pixelformat) && \ + (peasycap_format->v4l2_format.fmt.pix.width == width) && \ + (peasycap_format->v4l2_format.fmt.pix.height == height)) { + peasycap_best_format = peasycap_format; + break; + } + peasycap_format++; +} +if (0 == peasycap_format->v4l2_format.fmt.pix.width) { + SAY("cannot do: %ix%i with standard mask 0x%02X\n", \ + width, height, mask); + peasycap_format = &easycap_format[0]; best = -1; + while (0 != peasycap_format->v4l2_format.fmt.pix.width) { + if (((peasycap_format->mask & 0x0F) == (mask & 0x0F)) && \ + (peasycap_format->v4l2_format.fmt.pix\ + .field == field) && \ + (peasycap_format->v4l2_format.fmt.pix\ + .pixelformat == pixelformat)) { + miss = abs(peasycap_format->\ + v4l2_format.fmt.pix.width - width); + if ((best > miss) || (best < 0)) { + best = miss; + peasycap_best_format = peasycap_format; + if (!miss) + break; + } + } + peasycap_format++; + } + if (-1 == best) { + SAY("cannot do %ix... with standard mask 0x%02X\n", \ + width, mask); + SAY("cannot do ...x%i with standard mask 0x%02X\n", \ + height, mask); + SAY(" %ix%i unmatched\n", width, height); + return peasycap->format_offset; + } +} +if ((struct easycap_format *)NULL == peasycap_best_format) { + SAY("MISTAKE: peasycap_best_format is NULL"); + return -EINVAL; +} +peasycap_format = peasycap_best_format; + +/*...........................................................................*/ +if (true == try) + return (int)(peasycap_best_format - &easycap_format[0]); +/*...........................................................................*/ + +if (false != try) { + SAY("MISTAKE: true==try where is should be false\n"); + return -EINVAL; +} +SAY("actioning: %ix%i %s\n", \ + peasycap_format->v4l2_format.fmt.pix.width, \ + peasycap_format->v4l2_format.fmt.pix.height, + &peasycap_format->name[0]); +peasycap->height = peasycap_format->v4l2_format.fmt.pix.height; +peasycap->width = peasycap_format->v4l2_format.fmt.pix.width; +peasycap->pixelformat = peasycap_format->v4l2_format.fmt.pix.pixelformat; +peasycap->field = peasycap_format->v4l2_format.fmt.pix.field; +peasycap->format_offset = (int)(peasycap_format - &easycap_format[0]); +peasycap->bytesperpixel = (0x00F0 & peasycap_format->mask) >> 4 ; +if (0x0100 & peasycap_format->mask) + peasycap->byteswaporder = true; +else + peasycap->byteswaporder = false; +if (0x0800 & peasycap_format->mask) + peasycap->decimatepixel = true; +else + peasycap->decimatepixel = false; +if (0x1000 & peasycap_format->mask) + peasycap->offerfields = true; +else + peasycap->offerfields = false; +if (true == peasycap->decimatepixel) + multiplier = 2; +else + multiplier = 1; +peasycap->videofieldamount = multiplier * peasycap->width * \ + multiplier * peasycap->height; +peasycap->frame_buffer_used = peasycap->bytesperpixel * \ + peasycap->width * peasycap->height; + +if (true == peasycap->offerfields) { + SAY("WARNING: %i=peasycap->field is untested: " \ + "please report problems\n", peasycap->field); + + +/* + * FIXME ---- THIS IS UNTESTED, MAY BE (AND PROBABLY IS) INCORRECT: + * + * peasycap->frame_buffer_used = peasycap->frame_buffer_used / 2; + * + * SO DO NOT RISK IT YET. + * + */ + + + +} + +kill_video_urbs(peasycap); + +/*---------------------------------------------------------------------------*/ +/* + * PAL + */ +/*---------------------------------------------------------------------------*/ +if (0 == (0x01 & peasycap_format->mask)) { + if (((720 == peasycap_format->v4l2_format.fmt.pix.width) && \ + (576 == \ + peasycap_format->v4l2_format.fmt.pix.height)) || \ + ((360 == \ + peasycap_format->v4l2_format.fmt.pix.width) && \ + (288 == \ + peasycap_format->v4l2_format.fmt.pix.height))) { + if (0 != set_resolution(p, 0x0000, 0x0001, 0x05A0, 0x0121)) { + SAY("ERROR: set_resolution() failed\n"); + return -EINVAL; + } + } else if ((704 == peasycap_format->v4l2_format.fmt.pix.width) && \ + (576 == peasycap_format->v4l2_format.fmt.pix.height)) { + if (0 != set_resolution(p, 0x0004, 0x0001, 0x0584, 0x0121)) { + SAY("ERROR: set_resolution() failed\n"); + return -EINVAL; + } + } else if (((640 == peasycap_format->v4l2_format.fmt.pix.width) && \ + (480 == \ + peasycap_format->v4l2_format.fmt.pix.height)) || \ + ((320 == \ + peasycap_format->v4l2_format.fmt.pix.width) && \ + (240 == \ + peasycap_format->v4l2_format.fmt.pix.height))) { + if (0 != set_resolution(p, 0x0014, 0x0020, 0x0514, 0x0110)) { + SAY("ERROR: set_resolution() failed\n"); + return -EINVAL; + } + } else { + SAY("MISTAKE: bad format, cannot set resolution\n"); + return -EINVAL; + } +/*---------------------------------------------------------------------------*/ +/* + * NTSC + */ +/*---------------------------------------------------------------------------*/ +} else { + if (((720 == peasycap_format->v4l2_format.fmt.pix.width) && \ + (480 == \ + peasycap_format->v4l2_format.fmt.pix.height)) || \ + ((360 == \ + peasycap_format->v4l2_format.fmt.pix.width) && \ + (240 == \ + peasycap_format->v4l2_format.fmt.pix.height))) { + if (0 != set_resolution(p, 0x0000, 0x0003, 0x05A0, 0x00F3)) { + SAY("ERROR: set_resolution() failed\n"); + return -EINVAL; + } + } else if (((640 == peasycap_format->v4l2_format.fmt.pix.width) && \ + (480 == \ + peasycap_format->v4l2_format.fmt.pix.height)) || \ + ((320 == \ + peasycap_format->v4l2_format.fmt.pix.width) && \ + (240 == \ + peasycap_format->v4l2_format.fmt.pix.height))) { + if (0 != set_resolution(p, 0x0014, 0x0003, 0x0514, 0x00F3)) { + SAY("ERROR: set_resolution() failed\n"); + return -EINVAL; + } + } else { + SAY("MISTAKE: bad format, cannot set resolution\n"); + return -EINVAL; + } +} +/*---------------------------------------------------------------------------*/ + +check_stk(peasycap->pusb_device); + +return (int)(peasycap_best_format - &easycap_format[0]); +} +/*****************************************************************************/ +int adjust_brightness(struct easycap *peasycap, int value) +{ +unsigned int mood; +int i1; + +if ((struct usb_device *)NULL == peasycap->pusb_device) { + SAY("ERROR: peasycap->pusb_device is NULL\n"); + return -EFAULT; +} +i1 = 0; +while (0xFFFFFFFF != easycap_control[i1].id) { + if (V4L2_CID_BRIGHTNESS == easycap_control[i1].id) { + if ((easycap_control[i1].minimum > value) || \ + (easycap_control[i1].maximum < value)) + value = easycap_control[i1].default_value; + peasycap->brightness = value; + mood = 0x00FF & (unsigned int)peasycap->brightness; + + set2to78(peasycap->pusb_device); + + if (!write_saa(peasycap->pusb_device, 0x0A, mood)) { + SAY("adjusting brightness to 0x%02X\n", mood); + return 0; + } else { + SAY("WARNING: failed to adjust brightness " \ + "to 0x%02X\n", mood); + return -ENOENT; + } + + set2to78(peasycap->pusb_device); + + break; + } + i1++; +} +SAY("WARNING: failed to adjust brightness: control not found\n"); +return -ENOENT; +} +/*****************************************************************************/ +int adjust_contrast(struct easycap *peasycap, int value) +{ +unsigned int mood; +int i1; + +if ((struct usb_device *)NULL == peasycap->pusb_device) { + SAY("ERROR: peasycap->pusb_device is NULL\n"); + return -EFAULT; +} +i1 = 0; +while (0xFFFFFFFF != easycap_control[i1].id) { + if (V4L2_CID_CONTRAST == easycap_control[i1].id) { + if ((easycap_control[i1].minimum > value) || \ + (easycap_control[i1].maximum < value)) + value = easycap_control[i1].default_value; + peasycap->contrast = value; + mood = 0x00FF & (unsigned int) (peasycap->contrast - 128); + + set2to78(peasycap->pusb_device); + + if (!write_saa(peasycap->pusb_device, 0x0B, mood)) { + SAY("adjusting contrast to 0x%02X\n", mood); + return 0; + } else { + SAY("WARNING: failed to adjust contrast to " \ + "0x%02X\n", mood); + return -ENOENT; + } + + set2to78(peasycap->pusb_device); + + break; + } + i1++; +} +SAY("WARNING: failed to adjust contrast: control not found\n"); +return -ENOENT; +} +/*****************************************************************************/ +int adjust_saturation(struct easycap *peasycap, int value) +{ +unsigned int mood; +int i1; + +if ((struct usb_device *)NULL == peasycap->pusb_device) { + SAY("ERROR: peasycap->pusb_device is NULL\n"); + return -EFAULT; +} +i1 = 0; +while (0xFFFFFFFF != easycap_control[i1].id) { + if (V4L2_CID_SATURATION == easycap_control[i1].id) { + if ((easycap_control[i1].minimum > value) || \ + (easycap_control[i1].maximum < value)) + value = easycap_control[i1].default_value; + peasycap->saturation = value; + mood = 0x00FF & (unsigned int) (peasycap->saturation - 128); + + set2to78(peasycap->pusb_device); + + if (!write_saa(peasycap->pusb_device, 0x0C, mood)) { + SAY("adjusting saturation to 0x%02X\n", mood); + return 0; + } else { + SAY("WARNING: failed to adjust saturation to " \ + "0x%02X\n", mood); + return -ENOENT; + } + break; + + set2to78(peasycap->pusb_device); + + } + i1++; +} +SAY("WARNING: failed to adjust saturation: control not found\n"); +return -ENOENT; +} +/*****************************************************************************/ +int adjust_hue(struct easycap *peasycap, int value) +{ +unsigned int mood; +int i1, i2; + +if ((struct usb_device *)NULL == peasycap->pusb_device) { + SAY("ERROR: peasycap->pusb_device is NULL\n"); + return -EFAULT; +} +i1 = 0; +while (0xFFFFFFFF != easycap_control[i1].id) { + if (V4L2_CID_HUE == easycap_control[i1].id) { + if ((easycap_control[i1].minimum > value) || \ + (easycap_control[i1].maximum < value)) + value = easycap_control[i1].default_value; + peasycap->hue = value; + i2 = peasycap->hue - 128; + mood = 0x00FF & ((int) i2); + + set2to78(peasycap->pusb_device); + + if (!write_saa(peasycap->pusb_device, 0x0D, mood)) { + SAY("adjusting hue to 0x%02X\n", mood); + return 0; + } else { + SAY("WARNING: failed to adjust hue to 0x%02X\n", mood); + return -ENOENT; + } + + set2to78(peasycap->pusb_device); + + break; + } + i1++; +} +SAY("WARNING: failed to adjust hue: control not found\n"); +return -ENOENT; +} +/*****************************************************************************/ +int adjust_volume(struct easycap *peasycap, int value) +{ +__s8 mood; +int i1; + +if ((struct usb_device *)NULL == peasycap->pusb_device) { + SAY("ERROR: peasycap->pusb_device is NULL\n"); + return -EFAULT; +} +i1 = 0; +while (0xFFFFFFFF != easycap_control[i1].id) { + if (V4L2_CID_AUDIO_VOLUME == easycap_control[i1].id) { + if ((easycap_control[i1].minimum > value) || \ + (easycap_control[i1].maximum < value)) + value = easycap_control[i1].default_value; + peasycap->volume = value; + mood = (16 > peasycap->volume) ? 16 : \ + ((31 < peasycap->volume) ? 31 : \ + (__s8) peasycap->volume); + if (!audio_gainset(peasycap->pusb_device, mood)) { + SAY("adjusting volume to 0x%01X\n", mood); + return 0; + } else { + SAY("WARNING: failed to adjust volume to " \ + "0x%1X\n", mood); + return -ENOENT; + } + break; + } +i1++; +} +SAY("WARNING: failed to adjust volume: control not found\n"); +return -ENOENT; +} +/*****************************************************************************/ +/*---------------------------------------------------------------------------*/ +/* + * AN ALTERNATIVE METHOD OF MUTING MIGHT SEEM TO BE: + * usb_set_interface(peasycap->pusb_device, \ + * peasycap->audio_interface, \ + * peasycap->audio_altsetting_off); + * HOWEVER, AFTER THIS COMMAND IS ISSUED ALL SUBSEQUENT URBS RECEIVE STATUS + * -ESHUTDOWN. THE HANDLER ROUTINE easysnd_complete() DECLINES TO RESUBMIT + * THE URB AND THE PIPELINE COLLAPSES IRRETRIEVABLY. BEWARE. + */ +/*---------------------------------------------------------------------------*/ +int adjust_mute(struct easycap *peasycap, int value) +{ +int i1; + +if ((struct usb_device *)NULL == peasycap->pusb_device) { + SAY("ERROR: peasycap->pusb_device is NULL\n"); + return -EFAULT; +} +i1 = 0; +while (0xFFFFFFFF != easycap_control[i1].id) { + if (V4L2_CID_AUDIO_MUTE == easycap_control[i1].id) { + peasycap->mute = value; + switch (peasycap->mute) { + case 1: { + peasycap->audio_idle = 1; + peasycap->timeval0.tv_sec = 0; + SAY("adjusting mute: %i=peasycap->audio_idle\n", \ + peasycap->audio_idle); + return 0; + } + default: { + peasycap->audio_idle = 0; + SAY("adjusting mute: %i=peasycap->audio_idle\n", \ + peasycap->audio_idle); + return 0; + } + } + break; + } + i1++; +} +SAY("WARNING: failed to adjust mute: control not found\n"); +return -ENOENT; +} +/****************************************************************************/ +/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ +#if defined(EASYCAP_IS_VIDEODEV_CLIENT) +long +easycap_ioctl_noinode(struct file *file, unsigned int cmd, unsigned long arg)\ + { + return easycap_ioctl((struct inode *)NULL, file, cmd, arg); +} +#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ +/*--------------------------------------------------------------------------*/ +int easycap_ioctl(struct inode *inode, struct file *file, \ + unsigned int cmd, unsigned long arg) +{ +static struct easycap *peasycap; +static struct usb_device *p; +static __u32 isequence; + +peasycap = (struct easycap *)file->private_data; +if (NULL == peasycap) { + SAY("ERROR: peasycap is NULL\n"); + return -1; +} +p = peasycap->pusb_device; +if ((struct usb_device *)NULL == p) { + SAY("ERROR: peasycap->pusb_device is NULL\n"); + return -EFAULT; +} +/*---------------------------------------------------------------------------*/ +/* + * MOST OF THE VARIABLES DECLARED static IN THE case{} BLOCKS BELOW ARE SO + * DECLARED SIMPLY TO AVOID A COMPILER WARNING OF THE KIND: + * easycap_ioctl.c: warning: + * the frame size of ... bytes is larger than 1024 bytes + */ +/*---------------------------------------------------------------------------*/ +switch (cmd) { +case VIDIOC_QUERYCAP: { + static struct v4l2_capability v4l2_capability; + static char version[16], *p1, *p2; + static int i, rc, k[3]; + static long lng; + + JOT(8, "VIDIOC_QUERYCAP\n"); + + if (16 <= strlen(EASYCAP_DRIVER_VERSION)) { + SAY("ERROR: bad driver version string\n"); return -EINVAL; + } + strcpy(&version[0], EASYCAP_DRIVER_VERSION); + for (i = 0; i < 3; i++) + k[i] = 0; + p2 = &version[0]; i = 0; + while (*p2) { + p1 = p2; + while (*p2 && ('.' != *p2)) + p2++; + if (*p2) + *p2++ = 0; + if (3 > i) { + rc = (int) strict_strtol(p1, 10, &lng); + if (0 != rc) { + SAY("ERROR: %i=strict_strtol(%s,.,,)\n", \ + rc, p1); + return -EINVAL; + } + k[i] = (int)lng; + } + i++; + } + + memset(&v4l2_capability, 0, sizeof(struct v4l2_capability)); + strlcpy(&v4l2_capability.driver[0], "easycap", \ + sizeof(v4l2_capability.driver)); + + v4l2_capability.capabilities = \ + V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | \ + V4L2_CAP_AUDIO | V4L2_CAP_READWRITE; + + v4l2_capability.version = KERNEL_VERSION(k[0], k[1], k[2]); + JOT(8, "v4l2_capability.version=(%i,%i,%i)\n", k[0], k[1], k[2]); + + strlcpy(&v4l2_capability.card[0], "EasyCAP DC60", \ + sizeof(v4l2_capability.card)); + + if (usb_make_path(peasycap->pusb_device, &v4l2_capability.bus_info[0],\ + sizeof(v4l2_capability.bus_info)) < 0) { + strlcpy(&v4l2_capability.bus_info[0], "EasyCAP bus_info", \ + sizeof(v4l2_capability.bus_info)); + JOT(8, "%s=v4l2_capability.bus_info\n", \ + &v4l2_capability.bus_info[0]); + } + if (0 != copy_to_user((void __user *)arg, &v4l2_capability, \ + sizeof(struct v4l2_capability))) { + POUT; + return -EFAULT; + } + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_ENUMINPUT: { + static struct v4l2_input v4l2_input; + static __u32 index; + + JOT(8, "VIDIOC_ENUMINPUT\n"); + + if (0 != copy_from_user(&v4l2_input, (void __user *)arg, \ + sizeof(struct v4l2_input))) { + POUT; + return -EFAULT; + } + + index = v4l2_input.index; + memset(&v4l2_input, 0, sizeof(struct v4l2_input)); + + switch (index) { + case 0: { + v4l2_input.index = index; + strcpy(&v4l2_input.name[0], "CVBS0"); + v4l2_input.type = V4L2_INPUT_TYPE_CAMERA; + v4l2_input.audioset = 0x01; + v4l2_input.tuner = 0; + v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM | \ + V4L2_STD_NTSC ; + v4l2_input.status = 0; + JOT(8, "%i=index: %s\n", index, &v4l2_input.name[0]); + break; + } + case 1: { + v4l2_input.index = index; + strcpy(&v4l2_input.name[0], "CVBS1"); + v4l2_input.type = V4L2_INPUT_TYPE_CAMERA; + v4l2_input.audioset = 0x01; + v4l2_input.tuner = 0; + v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM | \ + V4L2_STD_NTSC ; + v4l2_input.status = 0; + JOT(8, "%i=index: %s\n", index, &v4l2_input.name[0]); + break; + } + case 2: { + v4l2_input.index = index; + strcpy(&v4l2_input.name[0], "CVBS2"); + v4l2_input.type = V4L2_INPUT_TYPE_CAMERA; + v4l2_input.audioset = 0x01; + v4l2_input.tuner = 0; + v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM | \ + V4L2_STD_NTSC ; + v4l2_input.status = 0; + JOT(8, "%i=index: %s\n", index, &v4l2_input.name[0]); + break; + } + case 3: { + v4l2_input.index = index; + strcpy(&v4l2_input.name[0], "CVBS3"); + v4l2_input.type = V4L2_INPUT_TYPE_CAMERA; + v4l2_input.audioset = 0x01; + v4l2_input.tuner = 0; + v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM | \ + V4L2_STD_NTSC ; + v4l2_input.status = 0; + JOT(8, "%i=index: %s\n", index, &v4l2_input.name[0]); + break; + } + case 4: { + v4l2_input.index = index; + strcpy(&v4l2_input.name[0], "CVBS4"); + v4l2_input.type = V4L2_INPUT_TYPE_CAMERA; + v4l2_input.audioset = 0x01; + v4l2_input.tuner = 0; + v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM | \ + V4L2_STD_NTSC ; + v4l2_input.status = 0; + JOT(8, "%i=index: %s\n", index, &v4l2_input.name[0]); + break; + } + case 5: { + v4l2_input.index = index; + strcpy(&v4l2_input.name[0], "S-VIDEO"); + v4l2_input.type = V4L2_INPUT_TYPE_CAMERA; + v4l2_input.audioset = 0x01; + v4l2_input.tuner = 0; + v4l2_input.std = V4L2_STD_PAL | V4L2_STD_SECAM | \ + V4L2_STD_NTSC ; + v4l2_input.status = 0; + JOT(8, "%i=index: %s\n", index, &v4l2_input.name[0]); + break; + } + default: { + JOT(8, "%i=index: exhausts inputs\n", index); + return -EINVAL; + } + } + + if (0 != copy_to_user((void __user *)arg, &v4l2_input, \ + sizeof(struct v4l2_input))) { + POUT; + return -EFAULT; + } + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_G_INPUT: { + static __u32 index; + + JOT(8, "VIDIOC_G_INPUT\n"); + index = (__u32)peasycap->input; + JOT(8, "user is told: %i\n", index); + if (0 != copy_to_user((void __user *)arg, &index, sizeof(__u32))) { + POUT; + return -EFAULT; + } + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_S_INPUT: + { + static __u32 index; + + JOT(8, "VIDIOC_S_INPUT\n"); + + if (0 != copy_from_user(&index, (void __user *)arg, sizeof(__u32))) { + POUT; + return -EFAULT; + } + + JOT(8, "user requests input %i\n", index); + + if ((int)index == peasycap->input) { + SAY("requested input already in effect\n"); + break; + } + + if ((0 > index) || (5 < index)) { + JOT(8, "ERROR: bad requested input: %i\n", index); + return -EINVAL; + } + peasycap->input = (int)index; + + select_input(peasycap->pusb_device, peasycap->input, 9); + + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_ENUMAUDIO: { + JOT(8, "VIDIOC_ENUMAUDIO\n"); + return -EINVAL; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_ENUMAUDOUT: { + static struct v4l2_audioout v4l2_audioout; + + JOT(8, "VIDIOC_ENUMAUDOUT\n"); + + if (0 != copy_from_user(&v4l2_audioout, (void __user *)arg, \ + sizeof(struct v4l2_audioout))) { + POUT; + return -EFAULT; + } + + if (0 != v4l2_audioout.index) + return -EINVAL; + memset(&v4l2_audioout, 0, sizeof(struct v4l2_audioout)); + v4l2_audioout.index = 0; + strcpy(&v4l2_audioout.name[0], "Soundtrack"); + + if (0 != copy_to_user((void __user *)arg, &v4l2_audioout, \ + sizeof(struct v4l2_audioout))) { + POUT; + return -EFAULT; + } + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_QUERYCTRL: { + static int i1; + static struct v4l2_queryctrl v4l2_queryctrl; + + JOT(8, "VIDIOC_QUERYCTRL\n"); + + if (0 != copy_from_user(&v4l2_queryctrl, (void __user *)arg, \ + sizeof(struct v4l2_queryctrl))) { + POUT; + return -EFAULT; + } + + i1 = 0; + while (0xFFFFFFFF != easycap_control[i1].id) { + if (easycap_control[i1].id == v4l2_queryctrl.id) { + JOT(8, "VIDIOC_QUERYCTRL %s=easycap_control[%i]" \ + ".name\n", &easycap_control[i1].name[0], i1); + memcpy(&v4l2_queryctrl, &easycap_control[i1], \ + sizeof(struct v4l2_queryctrl)); + break; + } + i1++; + } + if (0xFFFFFFFF == easycap_control[i1].id) { + JOT(8, "%i=index: exhausts controls\n", i1); + return -EINVAL; + } + if (0 != copy_to_user((void __user *)arg, &v4l2_queryctrl, \ + sizeof(struct v4l2_queryctrl))) { + POUT; + return -EFAULT; + } + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_QUERYMENU: { + JOT(8, "VIDIOC_QUERYMENU unsupported\n"); + return -EINVAL; + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_G_CTRL: { + static struct v4l2_control v4l2_control; + + JOT(8, "VIDIOC_G_CTRL\n"); + + if (0 != copy_from_user(&v4l2_control, (void __user *)arg, \ + sizeof(struct v4l2_control))) { + POUT; + return -EFAULT; + } + + switch (v4l2_control.id) { + case V4L2_CID_BRIGHTNESS: { + v4l2_control.value = peasycap->brightness; + JOT(8, "user enquires brightness: %i\n", v4l2_control.value); + break; + } + case V4L2_CID_CONTRAST: { + v4l2_control.value = peasycap->contrast; + JOT(8, "user enquires contrast: %i\n", v4l2_control.value); + break; + } + case V4L2_CID_SATURATION: { + v4l2_control.value = peasycap->saturation; + JOT(8, "user enquires saturation: %i\n", v4l2_control.value); + break; + } + case V4L2_CID_HUE: { + v4l2_control.value = peasycap->hue; + JOT(8, "user enquires hue: %i\n", v4l2_control.value); + break; + } + case V4L2_CID_AUDIO_VOLUME: { + v4l2_control.value = peasycap->volume; + JOT(8, "user enquires volume: %i\n", v4l2_control.value); + break; + } + case V4L2_CID_AUDIO_MUTE: { + if (1 == peasycap->mute) + v4l2_control.value = true; + else + v4l2_control.value = false; + JOT(8, "user enquires mute: %i\n", v4l2_control.value); + break; + } + default: { + SAY("ERROR: unknown V4L2 control: 0x%08X=id\n", \ + v4l2_control.id); + explain_cid(v4l2_control.id); + return -EINVAL; + } + } + if (0 != copy_to_user((void __user *)arg, &v4l2_control, \ + sizeof(struct v4l2_control))) { + POUT; + return -EFAULT; + } + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +#if defined(VIDIOC_S_CTRL_OLD) +case VIDIOC_S_CTRL_OLD: { + JOT(8, "VIDIOC_S_CTRL_OLD required at least for xawtv\n"); +} +#endif /*VIDIOC_S_CTRL_OLD*/ +case VIDIOC_S_CTRL: + { + static struct v4l2_control v4l2_control; + + JOT(8, "VIDIOC_S_CTRL\n"); + + if (0 != copy_from_user(&v4l2_control, (void __user *)arg, \ + sizeof(struct v4l2_control))) { + POUT; + return -EFAULT; + } + + switch (v4l2_control.id) { + case V4L2_CID_BRIGHTNESS: { + JOT(8, "user requests brightness %i\n", v4l2_control.value); + if (0 != adjust_brightness(peasycap, v4l2_control.value)) + ; + break; + } + case V4L2_CID_CONTRAST: { + JOT(8, "user requests contrast %i\n", v4l2_control.value); + if (0 != adjust_contrast(peasycap, v4l2_control.value)) + ; + break; + } + case V4L2_CID_SATURATION: { + JOT(8, "user requests saturation %i\n", v4l2_control.value); + if (0 != adjust_saturation(peasycap, v4l2_control.value)) + ; + break; + } + case V4L2_CID_HUE: { + JOT(8, "user requests hue %i\n", v4l2_control.value); + if (0 != adjust_hue(peasycap, v4l2_control.value)) + ; + break; + } + case V4L2_CID_AUDIO_VOLUME: { + JOT(8, "user requests volume %i\n", v4l2_control.value); + if (0 != adjust_volume(peasycap, v4l2_control.value)) + ; + break; + } + case V4L2_CID_AUDIO_MUTE: { + int mute; + + JOT(8, "user requests mute %i\n", v4l2_control.value); + if (true == v4l2_control.value) + mute = 1; + else + mute = 0; + + if (0 != adjust_mute(peasycap, mute)) + SAY("WARNING: failed to adjust mute to %i\n", mute); + break; + } + default: { + SAY("ERROR: unknown V4L2 control: 0x%08X=id\n", \ + v4l2_control.id); + explain_cid(v4l2_control.id); + return -EINVAL; + } + } + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_S_EXT_CTRLS: { + JOT(8, "VIDIOC_S_EXT_CTRLS unsupported\n"); + return -EINVAL; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_ENUM_FMT: { + static __u32 index; + static struct v4l2_fmtdesc v4l2_fmtdesc; + + JOT(8, "VIDIOC_ENUM_FMT\n"); + + if (0 != copy_from_user(&v4l2_fmtdesc, (void __user *)arg, \ + sizeof(struct v4l2_fmtdesc))) { + POUT; + return -EFAULT; + } + + index = v4l2_fmtdesc.index; + memset(&v4l2_fmtdesc, 0, sizeof(struct v4l2_fmtdesc)); + + v4l2_fmtdesc.index = index; + v4l2_fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + switch (index) { + case 0: { + v4l2_fmtdesc.flags = 0; + strcpy(&v4l2_fmtdesc.description[0], "uyvy"); + v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_UYVY; + JOT(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]); + break; + } + case 1: { + v4l2_fmtdesc.flags = 0; + strcpy(&v4l2_fmtdesc.description[0], "yuy2"); + v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_YUYV; + JOT(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]); + break; + } + case 2: { + v4l2_fmtdesc.flags = 0; + strcpy(&v4l2_fmtdesc.description[0], "rgb24"); + v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_RGB24; + JOT(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]); + break; + } + case 3: { + v4l2_fmtdesc.flags = 0; + strcpy(&v4l2_fmtdesc.description[0], "rgb32"); + v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_RGB32; + JOT(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]); + break; + } + case 4: { + v4l2_fmtdesc.flags = 0; + strcpy(&v4l2_fmtdesc.description[0], "bgr24"); + v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_BGR24; + JOT(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]); + break; + } + case 5: { + v4l2_fmtdesc.flags = 0; + strcpy(&v4l2_fmtdesc.description[0], "bgr32"); + v4l2_fmtdesc.pixelformat = V4L2_PIX_FMT_BGR32; + JOT(8, "%i=index: %s\n", index, &v4l2_fmtdesc.description[0]); + break; + } + default: { + JOT(8, "%i=index: exhausts formats\n", index); + return -EINVAL; + } + } + if (0 != copy_to_user((void __user *)arg, &v4l2_fmtdesc, \ + sizeof(struct v4l2_fmtdesc))) { + POUT; + return -EFAULT; + } + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_ENUM_FRAMESIZES: { + JOT(8, "VIDIOC_ENUM_FRAMESIZES unsupported\n"); + return -EINVAL; +} +case VIDIOC_ENUM_FRAMEINTERVALS: { + JOT(8, "VIDIOC_ENUM_FRAME_INTERVALS unsupported\n"); + return -EINVAL; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_G_FMT: { + static struct v4l2_format v4l2_format; + static struct v4l2_pix_format v4l2_pix_format; + + JOT(8, "VIDIOC_G_FMT\n"); + + if (0 != copy_from_user(&v4l2_format, (void __user *)arg, \ + sizeof(struct v4l2_format))) { + POUT; + return -EFAULT; + } + + if (v4l2_format.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { + POUT; + return -EINVAL; + } + + memset(&v4l2_pix_format, 0, sizeof(struct v4l2_pix_format)); + v4l2_format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + memcpy(&(v4l2_format.fmt.pix), \ + &(easycap_format[peasycap->format_offset]\ + .v4l2_format.fmt.pix), sizeof(v4l2_pix_format)); + JOT(8, "user is told: %s\n", \ + &easycap_format[peasycap->format_offset].name[0]); + + if (0 != copy_to_user((void __user *)arg, &v4l2_format, \ + sizeof(struct v4l2_format))) { + POUT; + return -EFAULT; + } + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_TRY_FMT: +case VIDIOC_S_FMT: { + static struct v4l2_format v4l2_format; + static struct v4l2_pix_format v4l2_pix_format; + static bool try; + static int best_format; + + if (VIDIOC_TRY_FMT == cmd) { + JOT(8, "VIDIOC_TRY_FMT\n"); + try = true; + } else { + JOT(8, "VIDIOC_S_FMT\n"); + try = false; + } + + if (0 != copy_from_user(&v4l2_format, (void __user *)arg, \ + sizeof(struct v4l2_format))) { + POUT; + return -EFAULT; + } + + best_format = adjust_format(peasycap, \ + v4l2_format.fmt.pix.width, \ + v4l2_format.fmt.pix.height, \ + v4l2_format.fmt.pix.pixelformat, \ + v4l2_format.fmt.pix.field, \ + try); + if (0 > best_format) { + JOT(8, "WARNING: adjust_format() returned %i\n", best_format); + return -ENOENT; + } +/*...........................................................................*/ + memset(&v4l2_pix_format, 0, sizeof(struct v4l2_pix_format)); + v4l2_format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + + memcpy(&(v4l2_format.fmt.pix), &(easycap_format[best_format]\ + .v4l2_format.fmt.pix), sizeof(v4l2_pix_format)); + JOT(8, "user is told: %s\n", &easycap_format[best_format].name[0]); + + if (0 != copy_to_user((void __user *)arg, &v4l2_format, \ + sizeof(struct v4l2_format))) { + POUT; + return -EFAULT; + } + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_CROPCAP: { + static struct v4l2_cropcap v4l2_cropcap; + + JOT(8, "VIDIOC_CROPCAP\n"); + + if (0 != copy_from_user(&v4l2_cropcap, (void __user *)arg, \ + sizeof(struct v4l2_cropcap))) { + POUT; + return -EFAULT; + } + + if (v4l2_cropcap.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + JOT(8, "v4l2_cropcap.type != V4L2_BUF_TYPE_VIDEO_CAPTURE\n"); + + memset(&v4l2_cropcap, 0, sizeof(struct v4l2_cropcap)); + v4l2_cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + v4l2_cropcap.bounds.left = 0; + v4l2_cropcap.bounds.top = 0; + v4l2_cropcap.bounds.width = peasycap->width; + v4l2_cropcap.bounds.height = peasycap->height; + v4l2_cropcap.defrect.left = 0; + v4l2_cropcap.defrect.top = 0; + v4l2_cropcap.defrect.width = peasycap->width; + v4l2_cropcap.defrect.height = peasycap->height; + v4l2_cropcap.pixelaspect.numerator = 1; + v4l2_cropcap.pixelaspect.denominator = 1; + + JOT(8, "user is told: %ix%i\n", peasycap->width, peasycap->height); + + if (0 != copy_to_user((void __user *)arg, &v4l2_cropcap, \ + sizeof(struct v4l2_cropcap))) { + POUT; + return -EFAULT; + } + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_G_CROP: +case VIDIOC_S_CROP: { + JOT(8, "VIDIOC_G_CROP|VIDIOC_S_CROP unsupported\n"); + return -EINVAL; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_QUERYSTD: { + JOT(8, "VIDIOC_QUERYSTD: " \ + "EasyCAP is incapable of detecting standard\n"); + return -EINVAL; + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +/*---------------------------------------------------------------------------*/ +/* + * THE MANIPULATIONS INVOLVING last0,last1,last2,last3 CONSTITUTE A WORKAROUND + * FOR WHAT APPEARS TO BE A BUG IN 64-BIT mplayer. + * NOT NEEDED, BUT HOPEFULLY HARMLESS, FOR 32-BIT mplayer. + */ +/*---------------------------------------------------------------------------*/ +case VIDIOC_ENUMSTD: { + static int last0 = -1, last1 = -1, last2 = -1, last3 = -1; + static struct v4l2_standard v4l2_standard; + static __u32 index; + static struct easycap_standard *peasycap_standard; + + JOT(8, "VIDIOC_ENUMSTD\n"); + + if (0 != copy_from_user(&v4l2_standard, (void __user *)arg, \ + sizeof(struct v4l2_standard))) { + POUT; + return -EFAULT; + } + index = v4l2_standard.index; + + last3 = last2; last2 = last1; last1 = last0; last0 = index; + if ((index == last3) && (index == last2) && \ + (index == last1) && (index == last0)) { + index++; + last3 = last2; last2 = last1; last1 = last0; last0 = index; + } + + memset(&v4l2_standard, 0, sizeof(struct v4l2_standard)); + + peasycap_standard = &easycap_standard[0]; + while (0xFFFF != peasycap_standard->mask) { + if ((int)(peasycap_standard - &easycap_standard[0]) == index) + break; + peasycap_standard++; + } + if (0xFFFF == peasycap_standard->mask) { + JOT(8, "%i=index: exhausts standards\n", index); + return -EINVAL; + } + JOT(8, "%i=index: %s\n", index, \ + &(peasycap_standard->v4l2_standard.name[0])); + peasycap_standard->v4l2_standard.index = index; + v4l2_standard.index = index; + + if (0 != copy_to_user((void __user *)arg, \ + &(peasycap_standard->v4l2_standard), \ + sizeof(struct v4l2_standard))) { + POUT; + return -EFAULT; + } + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_G_STD: { + static v4l2_std_id std_id; + static struct easycap_standard *peasycap_standard; + + JOT(8, "VIDIOC_G_STD\n"); + + if (0 != copy_from_user(&std_id, (void __user *)arg, \ + sizeof(v4l2_std_id))) { + POUT; + return -EFAULT; + } + + peasycap_standard = &easycap_standard[peasycap->standard_offset]; + std_id = peasycap_standard->v4l2_standard.id; + + JOT(8, "user is told: %s\n", \ + &peasycap_standard->v4l2_standard.name[0]); + + if (0 != copy_to_user((void __user *)arg, &std_id, \ + sizeof(v4l2_std_id))) { + POUT; + return -EFAULT; + } + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_S_STD: { + static v4l2_std_id std_id; + static int rc; + + JOT(8, "VIDIOC_S_STD\n"); + + if (0 != copy_from_user(&std_id, (void __user *)arg, \ + sizeof(v4l2_std_id))) { + POUT; + return -EFAULT; + } + + rc = adjust_standard(peasycap, std_id); + if (0 > rc) { + JOT(8, "WARNING: adjust_standard() returned %i\n", rc); + return -ENOENT; + } + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_REQBUFS: { + static int nbuffers; + static struct v4l2_requestbuffers v4l2_requestbuffers; + + JOT(8, "VIDIOC_REQBUFS\n"); + + if (0 != copy_from_user(&v4l2_requestbuffers, (void __user *)arg, \ + sizeof(struct v4l2_requestbuffers))) { + POUT; + return -EFAULT; + } + + if (v4l2_requestbuffers.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + if (v4l2_requestbuffers.memory != V4L2_MEMORY_MMAP) { + POUT; + return -EINVAL; + } + nbuffers = v4l2_requestbuffers.count; + JOT(8, " User requests %i buffers ...\n", nbuffers); + if (nbuffers < 2) + nbuffers = 2; + if (nbuffers > FRAME_BUFFER_MANY) + nbuffers = FRAME_BUFFER_MANY; + if (v4l2_requestbuffers.count == nbuffers) { + JOT(8, " ... agree to %i buffers\n", \ + nbuffers); + } else { + JOT(8, " ... insist on %i buffers\n", \ + nbuffers); + v4l2_requestbuffers.count = nbuffers; + } + peasycap->frame_buffer_many = nbuffers; + + if (0 != copy_to_user((void __user *)arg, &v4l2_requestbuffers, \ + sizeof(struct v4l2_requestbuffers))) { + POUT; + return -EFAULT; + } + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_QUERYBUF: { + static __u32 index; + static struct v4l2_buffer v4l2_buffer; + + JOT(8, "VIDIOC_QUERYBUF\n"); + + if (peasycap->video_eof) { + JOT(8, "returning -1 because %i=video_eof\n", \ + peasycap->video_eof); + return -1; + } + + if (0 != copy_from_user(&v4l2_buffer, (void __user *)arg, \ + sizeof(struct v4l2_buffer))) { + POUT; + return -EFAULT; + } + + if (v4l2_buffer.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + index = v4l2_buffer.index; + if (index < 0 || index >= peasycap->frame_buffer_many) + return -EINVAL; + memset(&v4l2_buffer, 0, sizeof(struct v4l2_buffer)); + v4l2_buffer.index = index; + v4l2_buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + v4l2_buffer.bytesused = peasycap->frame_buffer_used; + v4l2_buffer.flags = V4L2_BUF_FLAG_MAPPED | \ + peasycap->done[index] | \ + peasycap->queued[index]; + v4l2_buffer.field = peasycap->field; + v4l2_buffer.memory = V4L2_MEMORY_MMAP; + v4l2_buffer.m.offset = index * FRAME_BUFFER_SIZE; + v4l2_buffer.length = FRAME_BUFFER_SIZE; + + JOT(16, " %10i=index\n", v4l2_buffer.index); + JOT(16, " 0x%08X=type\n", v4l2_buffer.type); + JOT(16, " %10i=bytesused\n", v4l2_buffer.bytesused); + JOT(16, " 0x%08X=flags\n", v4l2_buffer.flags); + JOT(16, " %10i=field\n", v4l2_buffer.field); + JOT(16, " %10li=timestamp.tv_usec\n", \ + (long)v4l2_buffer.timestamp.tv_usec); + JOT(16, " %10i=sequence\n", v4l2_buffer.sequence); + JOT(16, " 0x%08X=memory\n", v4l2_buffer.memory); + JOT(16, " %10i=m.offset\n", v4l2_buffer.m.offset); + JOT(16, " %10i=length\n", v4l2_buffer.length); + + if (0 != copy_to_user((void __user *)arg, &v4l2_buffer, \ + sizeof(struct v4l2_buffer))) { + POUT; + return -EFAULT; + } + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_QBUF: { + static struct v4l2_buffer v4l2_buffer; + + JOT(8, "VIDIOC_QBUF\n"); + + if (0 != copy_from_user(&v4l2_buffer, (void __user *)arg, \ + sizeof(struct v4l2_buffer))) { + POUT; + return -EFAULT; + } + + if (v4l2_buffer.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + if (v4l2_buffer.memory != V4L2_MEMORY_MMAP) + return -EINVAL; + if (v4l2_buffer.index < 0 || \ + (v4l2_buffer.index >= peasycap->frame_buffer_many)) + return -EINVAL; + v4l2_buffer.flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_QUEUED; + + peasycap->done[v4l2_buffer.index] = 0; + peasycap->queued[v4l2_buffer.index] = V4L2_BUF_FLAG_QUEUED; + + if (0 != copy_to_user((void __user *)arg, &v4l2_buffer, \ + sizeof(struct v4l2_buffer))) { + POUT; + return -EFAULT; + } + + JOT(8, "..... user queueing frame buffer %i\n", \ + (int)v4l2_buffer.index); + + peasycap->frame_lock = 0; + + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_DQBUF: + { +#if defined(AUDIOTIME) + static struct signed_div_result sdr; + static long long int above, below, dnbydt, fudge, sll; + static unsigned long long int ull; + static struct timeval timeval0; + struct timeval timeval1; +#endif /*AUDIOTIME*/ + static struct timeval timeval, timeval2; + static int i, j; + static struct v4l2_buffer v4l2_buffer; + + JOT(8, "VIDIOC_DQBUF\n"); + + if ((peasycap->video_idle) || (peasycap->video_eof)) { + JOT(8, "returning -EIO because " \ + "%i=video_idle %i=video_eof\n", \ + peasycap->video_idle, peasycap->video_eof); + return -EIO; + } + + if (0 != copy_from_user(&v4l2_buffer, (void __user *)arg, \ + sizeof(struct v4l2_buffer))) { + POUT; + return -EFAULT; + } + + if (v4l2_buffer.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + + if (!peasycap->video_isoc_streaming) { + JOT(16, "returning -EIO because video urbs not streaming\n"); + return -EIO; + } +/*---------------------------------------------------------------------------*/ +/* + * IF THE USER HAS PREVIOUSLY CALLED easycap_poll(), AS DETERMINED BY FINDING + * THE FLAG peasycap->polled SET, THERE MUST BE NO FURTHER WAIT HERE. IN THIS + * CASE, JUST CHOOSE THE FRAME INDICATED BY peasycap->frame_read + */ +/*---------------------------------------------------------------------------*/ + + if (!peasycap->polled) { + if (-EIO == easycap_dqbuf(peasycap, 0)) + return -EIO; + } else { + if (peasycap->video_eof) + return -EIO; + } + if (V4L2_BUF_FLAG_DONE != peasycap->done[peasycap->frame_read]) { + SAY("ERROR: V4L2_BUF_FLAG_DONE != 0x%08X\n", \ + peasycap->done[peasycap->frame_read]); + } + peasycap->polled = 0; + + if (!(isequence % 10)) { + for (i = 0; i < 179; i++) + peasycap->merit[i] = peasycap->merit[i+1]; + peasycap->merit[179] = merit_saa(peasycap->pusb_device); + j = 0; + for (i = 0; i < 180; i++) + j += peasycap->merit[i]; + if (90 < j) { + SAY("easycap driver shutting down " \ + "on condition blue\n"); + peasycap->video_eof = 1; peasycap->audio_eof = 1; + } + } + + v4l2_buffer.index = peasycap->frame_read; + v4l2_buffer.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + v4l2_buffer.bytesused = peasycap->frame_buffer_used; + v4l2_buffer.flags = V4L2_BUF_FLAG_MAPPED | V4L2_BUF_FLAG_DONE; + v4l2_buffer.field = peasycap->field; + if (V4L2_FIELD_ALTERNATE == v4l2_buffer.field) + v4l2_buffer.field = \ + 0x000F & (peasycap->\ + frame_buffer[peasycap->frame_read][0].kount); + do_gettimeofday(&timeval); + timeval2 = timeval; + +#if defined(AUDIOTIME) + if (!peasycap->timeval0.tv_sec) { + timeval0 = timeval; + timeval1 = timeval; + timeval2 = timeval; + dnbydt = 192000; + + if (mutex_lock_interruptible(&(peasycap->mutex_timeval0))) + return -ERESTARTSYS; + peasycap->timeval0 = timeval0; + mutex_unlock(&(peasycap->mutex_timeval0)); + } else { + if (mutex_lock_interruptible(&(peasycap->mutex_timeval1))) + return -ERESTARTSYS; + dnbydt = peasycap->dnbydt; + timeval1 = peasycap->timeval1; + mutex_unlock(&(peasycap->mutex_timeval1)); + above = dnbydt * MICROSECONDS(timeval, timeval1); + below = 192000; + sdr = signed_div(above, below); + + above = sdr.quotient + timeval1.tv_usec - 350000; + + below = 1000000; + sdr = signed_div(above, below); + timeval2.tv_usec = sdr.remainder; + timeval2.tv_sec = timeval1.tv_sec + sdr.quotient; + } + if (!(isequence % 500)) { + fudge = ((long long int)(1000000)) * \ + ((long long int)(timeval.tv_sec - \ + timeval2.tv_sec)) + \ + (long long int)(timeval.tv_usec - \ + timeval2.tv_usec); + sdr = signed_div(fudge, 1000); + sll = sdr.quotient; + ull = sdr.remainder; + + SAY("%5lli.%-3lli=ms timestamp fudge\n", sll, ull); + } +#endif /*AUDIOTIME*/ + + v4l2_buffer.timestamp = timeval2; + v4l2_buffer.sequence = isequence++; + v4l2_buffer.memory = V4L2_MEMORY_MMAP; + v4l2_buffer.m.offset = v4l2_buffer.index * FRAME_BUFFER_SIZE; + v4l2_buffer.length = FRAME_BUFFER_SIZE; + + JOT(16, " %10i=index\n", v4l2_buffer.index); + JOT(16, " 0x%08X=type\n", v4l2_buffer.type); + JOT(16, " %10i=bytesused\n", v4l2_buffer.bytesused); + JOT(16, " 0x%08X=flags\n", v4l2_buffer.flags); + JOT(16, " %10i=field\n", v4l2_buffer.field); + JOT(16, " %10li=timestamp.tv_usec\n", \ + (long)v4l2_buffer.timestamp.tv_usec); + JOT(16, " %10i=sequence\n", v4l2_buffer.sequence); + JOT(16, " 0x%08X=memory\n", v4l2_buffer.memory); + JOT(16, " %10i=m.offset\n", v4l2_buffer.m.offset); + JOT(16, " %10i=length\n", v4l2_buffer.length); + + if (0 != copy_to_user((void __user *)arg, &v4l2_buffer, \ + sizeof(struct v4l2_buffer))) { + POUT; + return -EFAULT; + } + + JOT(8, "..... user is offered frame buffer %i\n", \ + peasycap->frame_read); + peasycap->frame_lock = 1; + if (peasycap->frame_read == peasycap->frame_fill) { + if (peasycap->frame_lock) { + JOT(8, "ERROR: filling frame buffer " \ + "while offered to user\n"); + } + } + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +/*---------------------------------------------------------------------------*/ +/* + * AUDIO URBS HAVE ALREADY BEEN SUBMITTED WHEN THIS COMMAND IS RECEIVED; + * VIDEO URBS HAVE NOT. + */ +/*---------------------------------------------------------------------------*/ +case VIDIOC_STREAMON: { + static int i; + + JOT(8, "VIDIOC_STREAMON\n"); + + isequence = 0; + for (i = 0; i < 180; i++) + peasycap->merit[i] = 0; + if ((struct usb_device *)NULL == peasycap->pusb_device) { + SAY("ERROR: peasycap->pusb_device is NULL\n"); + return -EFAULT; + } + submit_video_urbs(peasycap); + peasycap->video_idle = 0; + peasycap->audio_idle = 0; + peasycap->video_eof = 0; + peasycap->audio_eof = 0; + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_STREAMOFF: { + JOT(8, "VIDIOC_STREAMOFF\n"); + + if ((struct usb_device *)NULL == peasycap->pusb_device) { + SAY("ERROR: peasycap->pusb_device is NULL\n"); + return -EFAULT; + } + + peasycap->video_idle = 1; + peasycap->audio_idle = 1; peasycap->timeval0.tv_sec = 0; +/*---------------------------------------------------------------------------*/ +/* + * IF THE WAIT QUEUES ARE NOT CLEARED IN RESPONSE TO THE STREAMOFF COMMAND + * THE USERSPACE PROGRAM, E.G. mplayer, MAY HANG ON EXIT. BEWARE. + */ +/*---------------------------------------------------------------------------*/ + JOT(8, "calling wake_up on wq_video and wq_audio\n"); + wake_up_interruptible(&(peasycap->wq_video)); + wake_up_interruptible(&(peasycap->wq_audio)); +/*---------------------------------------------------------------------------*/ + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_G_PARM: { + static struct v4l2_streamparm v4l2_streamparm; + + JOT(8, "VIDIOC_G_PARM\n"); + + if (0 != copy_from_user(&v4l2_streamparm, (void __user *)arg, \ + sizeof(struct v4l2_streamparm))) { + POUT; + return -EFAULT; + } + + if (v4l2_streamparm.type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { + POUT; + return -EINVAL; + } + v4l2_streamparm.parm.capture.capability = 0; + v4l2_streamparm.parm.capture.capturemode = 0; + v4l2_streamparm.parm.capture.timeperframe.numerator = 1; + v4l2_streamparm.parm.capture.timeperframe.denominator = 30; + v4l2_streamparm.parm.capture.readbuffers = peasycap->frame_buffer_many; + v4l2_streamparm.parm.capture.extendedmode = 0; + if (0 != copy_to_user((void __user *)arg, &v4l2_streamparm, \ + sizeof(struct v4l2_streamparm))) { + POUT; + return -EFAULT; + } + break; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_S_PARM: { + JOT(8, "VIDIOC_S_PARM unsupported\n"); + return -EINVAL; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_G_AUDIO: { + JOT(8, "VIDIOC_G_AUDIO unsupported\n"); + return -EINVAL; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_S_AUDIO: { + JOT(8, "VIDIOC_S_AUDIO unsupported\n"); + return -EINVAL; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_S_TUNER: { + JOT(8, "VIDIOC_S_TUNER unsupported\n"); + return -EINVAL; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_G_FBUF: +case VIDIOC_S_FBUF: +case VIDIOC_OVERLAY: { + JOT(8, "VIDIOC_G_FBUF|VIDIOC_S_FBUF|VIDIOC_OVERLAY unsupported\n"); + return -EINVAL; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +case VIDIOC_G_TUNER: { + JOT(8, "VIDIOC_G_TUNER unsupported\n"); + return -EINVAL; +} +case VIDIOC_G_FREQUENCY: +case VIDIOC_S_FREQUENCY: { + JOT(8, "VIDIOC_G_FREQUENCY|VIDIOC_S_FREQUENCY unsupported\n"); + return -EINVAL; +} +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +default: { + JOT(8, "ERROR: unrecognized V4L2 IOCTL command: 0x%08X\n", cmd); + explain_ioctl(cmd); + POUT; + return -ENOIOCTLCMD; +} +} +return 0; +} +/****************************************************************************/ +/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ +#if defined(EASYCAP_IS_VIDEODEV_CLIENT) +long +easysnd_ioctl_noinode(struct file *file, unsigned int cmd, unsigned long arg) +{ + return easysnd_ioctl((struct inode *)NULL, file, cmd, arg); +} +#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ +/*--------------------------------------------------------------------------*/ +int easysnd_ioctl(struct inode *inode, struct file *file, \ + unsigned int cmd, unsigned long arg) +{ +struct easycap *peasycap; +struct usb_device *p; + +peasycap = (struct easycap *)file->private_data; +if (NULL == peasycap) { + SAY("ERROR: peasycap is NULL.\n"); + return -1; +} +p = peasycap->pusb_device; +/*---------------------------------------------------------------------------*/ +switch (cmd) { +case SNDCTL_DSP_GETCAPS: { + int caps; + JOT(8, "SNDCTL_DSP_GETCAPS\n"); + + if (true == peasycap->microphone) + caps = 0x02400000; + else + caps = 0x04400000; + + if (0 != copy_to_user((void __user *)arg, &caps, sizeof(int))) + return -EFAULT; + break; +} +case SNDCTL_DSP_GETFMTS: { + int incoming; + JOT(8, "SNDCTL_DSP_GETFMTS\n"); + + if (true == peasycap->microphone) + incoming = AFMT_S16_LE; + else + incoming = AFMT_S16_LE; + + if (0 != copy_to_user((void __user *)arg, &incoming, sizeof(int))) + return -EFAULT; + break; +} +case SNDCTL_DSP_SETFMT: { + int incoming, outgoing; + JOT(8, "SNDCTL_DSP_SETFMT\n"); + if (0 != copy_from_user(&incoming, (void __user *)arg, sizeof(int))) + return -EFAULT; + JOT(8, "........... %i=incoming\n", incoming); + + if (true == peasycap->microphone) + outgoing = AFMT_S16_LE; + else + outgoing = AFMT_S16_LE; + + if (incoming != outgoing) { + JOT(8, "........... %i=outgoing\n", outgoing); + JOT(8, " cf. %i=AFMT_S16_LE\n", AFMT_S16_LE); + JOT(8, " cf. %i=AFMT_U8\n", AFMT_U8); + if (0 != copy_to_user((void __user *)arg, &outgoing, \ + sizeof(int))) + return -EFAULT; + return -EINVAL ; + } + break; +} +case SNDCTL_DSP_STEREO: { + int incoming; + JOT(8, "SNDCTL_DSP_STEREO\n"); + if (0 != copy_from_user(&incoming, (void __user *)arg, sizeof(int))) + return -EFAULT; + JOT(8, "........... %i=incoming\n", incoming); + + if (true == peasycap->microphone) + incoming = 0; + else + incoming = 1; + + if (0 != copy_to_user((void __user *)arg, &incoming, sizeof(int))) + return -EFAULT; + break; +} +case SNDCTL_DSP_SPEED: { + int incoming; + JOT(8, "SNDCTL_DSP_SPEED\n"); + if (0 != copy_from_user(&incoming, (void __user *)arg, sizeof(int))) + return -EFAULT; + JOT(8, "........... %i=incoming\n", incoming); + + if (true == peasycap->microphone) + incoming = 8000; + else + incoming = 48000; + + if (0 != copy_to_user((void __user *)arg, &incoming, sizeof(int))) + return -EFAULT; + break; +} +case SNDCTL_DSP_GETTRIGGER: { + int incoming; + JOT(8, "SNDCTL_DSP_GETTRIGGER\n"); + if (0 != copy_from_user(&incoming, (void __user *)arg, sizeof(int))) + return -EFAULT; + JOT(8, "........... %i=incoming\n", incoming); + + incoming = PCM_ENABLE_INPUT; + if (0 != copy_to_user((void __user *)arg, &incoming, sizeof(int))) + return -EFAULT; + break; +} +case SNDCTL_DSP_SETTRIGGER: { + int incoming; + JOT(8, "SNDCTL_DSP_SETTRIGGER\n"); + if (0 != copy_from_user(&incoming, (void __user *)arg, sizeof(int))) + return -EFAULT; + JOT(8, "........... %i=incoming\n", incoming); + JOT(8, "........... cf 0x%x=PCM_ENABLE_INPUT " \ + "0x%x=PCM_ENABLE_OUTPUT\n", \ + PCM_ENABLE_INPUT, PCM_ENABLE_OUTPUT); + ; + ; + ; + ; + break; +} +case SNDCTL_DSP_GETBLKSIZE: { + int incoming; + JOT(8, "SNDCTL_DSP_GETBLKSIZE\n"); + if (0 != copy_from_user(&incoming, (void __user *)arg, sizeof(int))) + return -EFAULT; + JOT(8, "........... %i=incoming\n", incoming); + incoming = audio_bytes_per_fragment; + if (0 != copy_to_user((void __user *)arg, &incoming, sizeof(int))) + return -EFAULT; + break; +} +case SNDCTL_DSP_GETISPACE: { + struct audio_buf_info audio_buf_info; + + JOT(8, "SNDCTL_DSP_GETISPACE\n"); + + audio_buf_info.bytes = audio_bytes_per_fragment; + audio_buf_info.fragments = 1; + audio_buf_info.fragsize = 0; + audio_buf_info.fragstotal = 0; + + if (0 != copy_to_user((void __user *)arg, &audio_buf_info, \ + sizeof(int))) + return -EFAULT; + break; +} +default: { + JOT(8, "ERROR: unrecognized DSP IOCTL command: 0x%08X\n", cmd); + POUT; + return -ENOIOCTLCMD; +} +} +return 0; +} +/*****************************************************************************/ +int explain_ioctl(__u32 wot) +{ +int k; +/*---------------------------------------------------------------------------*/ +/* + * THE DATA FOR THE ARRAY mess BELOW WERE CONSTRUCTED BY RUNNING THE FOLLOWING + * SHELL SCRIPT: + * # + * cat /usr/src/linux-headers-`uname -r`/include/linux/videodev2.h | \ + * grep "^#define VIDIOC_" - | grep -v "_OLD" - | \ + * sed -e "s,_IO.*$,,;p" | sed -e "N;s,\n,, " | \ + * sed -e "s/^#define / {/;s/#define /, \"/;s/$/\"},/" | \ + * sed -e "s, ,,g;s, ,,g" >ioctl.tmp + * echo "{0xFFFFFFFF,\"\"}" >>ioctl.tmp + * exit 0 + * # + * AND REINSTATING THE EXCISED "_OLD" CASES WERE LATER MANUALLY. + * + * THE DATA FOR THE ARRAY mess1 BELOW WERE CONSTRUCTED BY RUNNING THE FOLLOWING + * SHELL SCRIPT: + * cat /usr/src/linux-headers-`uname -r`/include/linux/videodev.h | \ + * grep "^#define VIDIOC" - | grep -v "_OLD" - | \ + * sed -e "s,_IO.*$,,;p" | sed -e "N;s,\n,, " | \ + * sed -e "s/^#define / {/;s/#define /, \"/;s/$/\"},/" | \ + * sed -e "s, ,,g;s, ,,g" >ioctl.tmp + * echo "{0xFFFFFFFF,\"\"}" >>ioctl.tmp + * exit 0 + * # + */ +/*---------------------------------------------------------------------------*/ +static struct mess { + __u32 command; + char name[64]; +} mess[] = { +#if defined(VIDIOC_QUERYCAP) +{VIDIOC_QUERYCAP, "VIDIOC_QUERYCAP"}, +#endif +#if defined(VIDIOC_RESERVED) +{VIDIOC_RESERVED, "VIDIOC_RESERVED"}, +#endif +#if defined(VIDIOC_ENUM_FMT) +{VIDIOC_ENUM_FMT, "VIDIOC_ENUM_FMT"}, +#endif +#if defined(VIDIOC_G_FMT) +{VIDIOC_G_FMT, "VIDIOC_G_FMT"}, +#endif +#if defined(VIDIOC_S_FMT) +{VIDIOC_S_FMT, "VIDIOC_S_FMT"}, +#endif +#if defined(VIDIOC_REQBUFS) +{VIDIOC_REQBUFS, "VIDIOC_REQBUFS"}, +#endif +#if defined(VIDIOC_QUERYBUF) +{VIDIOC_QUERYBUF, "VIDIOC_QUERYBUF"}, +#endif +#if defined(VIDIOC_G_FBUF) +{VIDIOC_G_FBUF, "VIDIOC_G_FBUF"}, +#endif +#if defined(VIDIOC_S_FBUF) +{VIDIOC_S_FBUF, "VIDIOC_S_FBUF"}, +#endif +#if defined(VIDIOC_OVERLAY) +{VIDIOC_OVERLAY, "VIDIOC_OVERLAY"}, +#endif +#if defined(VIDIOC_QBUF) +{VIDIOC_QBUF, "VIDIOC_QBUF"}, +#endif +#if defined(VIDIOC_DQBUF) +{VIDIOC_DQBUF, "VIDIOC_DQBUF"}, +#endif +#if defined(VIDIOC_STREAMON) +{VIDIOC_STREAMON, "VIDIOC_STREAMON"}, +#endif +#if defined(VIDIOC_STREAMOFF) +{VIDIOC_STREAMOFF, "VIDIOC_STREAMOFF"}, +#endif +#if defined(VIDIOC_G_PARM) +{VIDIOC_G_PARM, "VIDIOC_G_PARM"}, +#endif +#if defined(VIDIOC_S_PARM) +{VIDIOC_S_PARM, "VIDIOC_S_PARM"}, +#endif +#if defined(VIDIOC_G_STD) +{VIDIOC_G_STD, "VIDIOC_G_STD"}, +#endif +#if defined(VIDIOC_S_STD) +{VIDIOC_S_STD, "VIDIOC_S_STD"}, +#endif +#if defined(VIDIOC_ENUMSTD) +{VIDIOC_ENUMSTD, "VIDIOC_ENUMSTD"}, +#endif +#if defined(VIDIOC_ENUMINPUT) +{VIDIOC_ENUMINPUT, "VIDIOC_ENUMINPUT"}, +#endif +#if defined(VIDIOC_G_CTRL) +{VIDIOC_G_CTRL, "VIDIOC_G_CTRL"}, +#endif +#if defined(VIDIOC_S_CTRL) +{VIDIOC_S_CTRL, "VIDIOC_S_CTRL"}, +#endif +#if defined(VIDIOC_G_TUNER) +{VIDIOC_G_TUNER, "VIDIOC_G_TUNER"}, +#endif +#if defined(VIDIOC_S_TUNER) +{VIDIOC_S_TUNER, "VIDIOC_S_TUNER"}, +#endif +#if defined(VIDIOC_G_AUDIO) +{VIDIOC_G_AUDIO, "VIDIOC_G_AUDIO"}, +#endif +#if defined(VIDIOC_S_AUDIO) +{VIDIOC_S_AUDIO, "VIDIOC_S_AUDIO"}, +#endif +#if defined(VIDIOC_QUERYCTRL) +{VIDIOC_QUERYCTRL, "VIDIOC_QUERYCTRL"}, +#endif +#if defined(VIDIOC_QUERYMENU) +{VIDIOC_QUERYMENU, "VIDIOC_QUERYMENU"}, +#endif +#if defined(VIDIOC_G_INPUT) +{VIDIOC_G_INPUT, "VIDIOC_G_INPUT"}, +#endif +#if defined(VIDIOC_S_INPUT) +{VIDIOC_S_INPUT, "VIDIOC_S_INPUT"}, +#endif +#if defined(VIDIOC_G_OUTPUT) +{VIDIOC_G_OUTPUT, "VIDIOC_G_OUTPUT"}, +#endif +#if defined(VIDIOC_S_OUTPUT) +{VIDIOC_S_OUTPUT, "VIDIOC_S_OUTPUT"}, +#endif +#if defined(VIDIOC_ENUMOUTPUT) +{VIDIOC_ENUMOUTPUT, "VIDIOC_ENUMOUTPUT"}, +#endif +#if defined(VIDIOC_G_AUDOUT) +{VIDIOC_G_AUDOUT, "VIDIOC_G_AUDOUT"}, +#endif +#if defined(VIDIOC_S_AUDOUT) +{VIDIOC_S_AUDOUT, "VIDIOC_S_AUDOUT"}, +#endif +#if defined(VIDIOC_G_MODULATOR) +{VIDIOC_G_MODULATOR, "VIDIOC_G_MODULATOR"}, +#endif +#if defined(VIDIOC_S_MODULATOR) +{VIDIOC_S_MODULATOR, "VIDIOC_S_MODULATOR"}, +#endif +#if defined(VIDIOC_G_FREQUENCY) +{VIDIOC_G_FREQUENCY, "VIDIOC_G_FREQUENCY"}, +#endif +#if defined(VIDIOC_S_FREQUENCY) +{VIDIOC_S_FREQUENCY, "VIDIOC_S_FREQUENCY"}, +#endif +#if defined(VIDIOC_CROPCAP) +{VIDIOC_CROPCAP, "VIDIOC_CROPCAP"}, +#endif +#if defined(VIDIOC_G_CROP) +{VIDIOC_G_CROP, "VIDIOC_G_CROP"}, +#endif +#if defined(VIDIOC_S_CROP) +{VIDIOC_S_CROP, "VIDIOC_S_CROP"}, +#endif +#if defined(VIDIOC_G_JPEGCOMP) +{VIDIOC_G_JPEGCOMP, "VIDIOC_G_JPEGCOMP"}, +#endif +#if defined(VIDIOC_S_JPEGCOMP) +{VIDIOC_S_JPEGCOMP, "VIDIOC_S_JPEGCOMP"}, +#endif +#if defined(VIDIOC_QUERYSTD) +{VIDIOC_QUERYSTD, "VIDIOC_QUERYSTD"}, +#endif +#if defined(VIDIOC_TRY_FMT) +{VIDIOC_TRY_FMT, "VIDIOC_TRY_FMT"}, +#endif +#if defined(VIDIOC_ENUMAUDIO) +{VIDIOC_ENUMAUDIO, "VIDIOC_ENUMAUDIO"}, +#endif +#if defined(VIDIOC_ENUMAUDOUT) +{VIDIOC_ENUMAUDOUT, "VIDIOC_ENUMAUDOUT"}, +#endif +#if defined(VIDIOC_G_PRIORITY) +{VIDIOC_G_PRIORITY, "VIDIOC_G_PRIORITY"}, +#endif +#if defined(VIDIOC_S_PRIORITY) +{VIDIOC_S_PRIORITY, "VIDIOC_S_PRIORITY"}, +#endif +#if defined(VIDIOC_G_SLICED_VBI_CAP) +{VIDIOC_G_SLICED_VBI_CAP, "VIDIOC_G_SLICED_VBI_CAP"}, +#endif +#if defined(VIDIOC_LOG_STATUS) +{VIDIOC_LOG_STATUS, "VIDIOC_LOG_STATUS"}, +#endif +#if defined(VIDIOC_G_EXT_CTRLS) +{VIDIOC_G_EXT_CTRLS, "VIDIOC_G_EXT_CTRLS"}, +#endif +#if defined(VIDIOC_S_EXT_CTRLS) +{VIDIOC_S_EXT_CTRLS, "VIDIOC_S_EXT_CTRLS"}, +#endif +#if defined(VIDIOC_TRY_EXT_CTRLS) +{VIDIOC_TRY_EXT_CTRLS, "VIDIOC_TRY_EXT_CTRLS"}, +#endif +#if defined(VIDIOC_ENUM_FRAMESIZES) +{VIDIOC_ENUM_FRAMESIZES, "VIDIOC_ENUM_FRAMESIZES"}, +#endif +#if defined(VIDIOC_ENUM_FRAMEINTERVALS) +{VIDIOC_ENUM_FRAMEINTERVALS, "VIDIOC_ENUM_FRAMEINTERVALS"}, +#endif +#if defined(VIDIOC_G_ENC_INDEX) +{VIDIOC_G_ENC_INDEX, "VIDIOC_G_ENC_INDEX"}, +#endif +#if defined(VIDIOC_ENCODER_CMD) +{VIDIOC_ENCODER_CMD, "VIDIOC_ENCODER_CMD"}, +#endif +#if defined(VIDIOC_TRY_ENCODER_CMD) +{VIDIOC_TRY_ENCODER_CMD, "VIDIOC_TRY_ENCODER_CMD"}, +#endif +#if defined(VIDIOC_G_CHIP_IDENT) +{VIDIOC_G_CHIP_IDENT, "VIDIOC_G_CHIP_IDENT"}, +#endif + +#if defined(VIDIOC_OVERLAY_OLD) +{VIDIOC_OVERLAY_OLD, "VIDIOC_OVERLAY_OLD"}, +#endif +#if defined(VIDIOC_S_PARM_OLD) +{VIDIOC_S_PARM_OLD, "VIDIOC_S_PARM_OLD"}, +#endif +#if defined(VIDIOC_S_CTRL_OLD) +{VIDIOC_S_CTRL_OLD, "VIDIOC_S_CTRL_OLD"}, +#endif +#if defined(VIDIOC_G_AUDIO_OLD) +{VIDIOC_G_AUDIO_OLD, "VIDIOC_G_AUDIO_OLD"}, +#endif +#if defined(VIDIOC_G_AUDOUT_OLD) +{VIDIOC_G_AUDOUT_OLD, "VIDIOC_G_AUDOUT_OLD"}, +#endif +#if defined(VIDIOC_CROPCAP_OLD) +{VIDIOC_CROPCAP_OLD, "VIDIOC_CROPCAP_OLD"}, +#endif +{0xFFFFFFFF, ""} +}; + +static struct mess mess1[] = \ +{ +#if defined(VIDIOCGCAP) +{VIDIOCGCAP, "VIDIOCGCAP"}, +#endif +#if defined(VIDIOCGCHAN) +{VIDIOCGCHAN, "VIDIOCGCHAN"}, +#endif +#if defined(VIDIOCSCHAN) +{VIDIOCSCHAN, "VIDIOCSCHAN"}, +#endif +#if defined(VIDIOCGTUNER) +{VIDIOCGTUNER, "VIDIOCGTUNER"}, +#endif +#if defined(VIDIOCSTUNER) +{VIDIOCSTUNER, "VIDIOCSTUNER"}, +#endif +#if defined(VIDIOCGPICT) +{VIDIOCGPICT, "VIDIOCGPICT"}, +#endif +#if defined(VIDIOCSPICT) +{VIDIOCSPICT, "VIDIOCSPICT"}, +#endif +#if defined(VIDIOCCAPTURE) +{VIDIOCCAPTURE, "VIDIOCCAPTURE"}, +#endif +#if defined(VIDIOCGWIN) +{VIDIOCGWIN, "VIDIOCGWIN"}, +#endif +#if defined(VIDIOCSWIN) +{VIDIOCSWIN, "VIDIOCSWIN"}, +#endif +#if defined(VIDIOCGFBUF) +{VIDIOCGFBUF, "VIDIOCGFBUF"}, +#endif +#if defined(VIDIOCSFBUF) +{VIDIOCSFBUF, "VIDIOCSFBUF"}, +#endif +#if defined(VIDIOCKEY) +{VIDIOCKEY, "VIDIOCKEY"}, +#endif +#if defined(VIDIOCGFREQ) +{VIDIOCGFREQ, "VIDIOCGFREQ"}, +#endif +#if defined(VIDIOCSFREQ) +{VIDIOCSFREQ, "VIDIOCSFREQ"}, +#endif +#if defined(VIDIOCGAUDIO) +{VIDIOCGAUDIO, "VIDIOCGAUDIO"}, +#endif +#if defined(VIDIOCSAUDIO) +{VIDIOCSAUDIO, "VIDIOCSAUDIO"}, +#endif +#if defined(VIDIOCSYNC) +{VIDIOCSYNC, "VIDIOCSYNC"}, +#endif +#if defined(VIDIOCMCAPTURE) +{VIDIOCMCAPTURE, "VIDIOCMCAPTURE"}, +#endif +#if defined(VIDIOCGMBUF) +{VIDIOCGMBUF, "VIDIOCGMBUF"}, +#endif +#if defined(VIDIOCGUNIT) +{VIDIOCGUNIT, "VIDIOCGUNIT"}, +#endif +#if defined(VIDIOCGCAPTURE) +{VIDIOCGCAPTURE, "VIDIOCGCAPTURE"}, +#endif +#if defined(VIDIOCSCAPTURE) +{VIDIOCSCAPTURE, "VIDIOCSCAPTURE"}, +#endif +#if defined(VIDIOCSPLAYMODE) +{VIDIOCSPLAYMODE, "VIDIOCSPLAYMODE"}, +#endif +#if defined(VIDIOCSWRITEMODE) +{VIDIOCSWRITEMODE, "VIDIOCSWRITEMODE"}, +#endif +#if defined(VIDIOCGPLAYINFO) +{VIDIOCGPLAYINFO, "VIDIOCGPLAYINFO"}, +#endif +#if defined(VIDIOCSMICROCODE) +{VIDIOCSMICROCODE, "VIDIOCSMICROCODE"}, +#endif +{0xFFFFFFFF, ""} +}; + +k = 0; +while (mess[k].name[0]) { + if (wot == mess[k].command) { + JOT(8, "ioctl 0x%08X is %s\n", \ + mess[k].command, &mess[k].name[0]); + return 0; + } + k++; +} +JOT(8, "ioctl 0x%08X is not in videodev2.h\n", wot); + +k = 0; +while (mess1[k].name[0]) { + if (wot == mess1[k].command) { + JOT(8, "ioctl 0x%08X is %s (V4L1)\n", \ + mess1[k].command, &mess1[k].name[0]); + return 0; + } + k++; +} +JOT(8, "ioctl 0x%08X is not in videodev.h\n", wot); +return -1; +} +/*****************************************************************************/ +int explain_cid(__u32 wot) +{ +int k; +/*---------------------------------------------------------------------------*/ +/* + * THE DATA FOR THE ARRAY mess BELOW WERE CONSTRUCTED BY RUNNING THE FOLLOWING + * SHELL SCRIPT: + * # + * cat /usr/src/linux-headers-`uname -r`/include/linux/videodev2.h | \ + * grep "^#define V4L2_CID_" | \ + * sed -e "s,(.*$,,;p" | sed -e "N;s,\n,, " | \ + * sed -e "s/^#define / {/;s/#define /, \"/;s/$/\"},/" | \ + * sed -e "s, ,,g;s, ,,g" | grep -v "_BASE" | grep -v "MPEG" >cid.tmp + * echo "{0xFFFFFFFF,\"\"}" >>cid.tmp + * exit 0 + * # + */ +/*---------------------------------------------------------------------------*/ +static struct mess +{ +__u32 command; +char name[64]; +} mess[] = { +#if defined(V4L2_CID_USER_CLASS) +{V4L2_CID_USER_CLASS, "V4L2_CID_USER_CLASS"}, +#endif +#if defined(V4L2_CID_BRIGHTNESS) +{V4L2_CID_BRIGHTNESS, "V4L2_CID_BRIGHTNESS"}, +#endif +#if defined(V4L2_CID_CONTRAST) +{V4L2_CID_CONTRAST, "V4L2_CID_CONTRAST"}, +#endif +#if defined(V4L2_CID_SATURATION) +{V4L2_CID_SATURATION, "V4L2_CID_SATURATION"}, +#endif +#if defined(V4L2_CID_HUE) +{V4L2_CID_HUE, "V4L2_CID_HUE"}, +#endif +#if defined(V4L2_CID_AUDIO_VOLUME) +{V4L2_CID_AUDIO_VOLUME, "V4L2_CID_AUDIO_VOLUME"}, +#endif +#if defined(V4L2_CID_AUDIO_BALANCE) +{V4L2_CID_AUDIO_BALANCE, "V4L2_CID_AUDIO_BALANCE"}, +#endif +#if defined(V4L2_CID_AUDIO_BASS) +{V4L2_CID_AUDIO_BASS, "V4L2_CID_AUDIO_BASS"}, +#endif +#if defined(V4L2_CID_AUDIO_TREBLE) +{V4L2_CID_AUDIO_TREBLE, "V4L2_CID_AUDIO_TREBLE"}, +#endif +#if defined(V4L2_CID_AUDIO_MUTE) +{V4L2_CID_AUDIO_MUTE, "V4L2_CID_AUDIO_MUTE"}, +#endif +#if defined(V4L2_CID_AUDIO_LOUDNESS) +{V4L2_CID_AUDIO_LOUDNESS, "V4L2_CID_AUDIO_LOUDNESS"}, +#endif +#if defined(V4L2_CID_BLACK_LEVEL) +{V4L2_CID_BLACK_LEVEL, "V4L2_CID_BLACK_LEVEL"}, +#endif +#if defined(V4L2_CID_AUTO_WHITE_BALANCE) +{V4L2_CID_AUTO_WHITE_BALANCE, "V4L2_CID_AUTO_WHITE_BALANCE"}, +#endif +#if defined(V4L2_CID_DO_WHITE_BALANCE) +{V4L2_CID_DO_WHITE_BALANCE, "V4L2_CID_DO_WHITE_BALANCE"}, +#endif +#if defined(V4L2_CID_RED_BALANCE) +{V4L2_CID_RED_BALANCE, "V4L2_CID_RED_BALANCE"}, +#endif +#if defined(V4L2_CID_BLUE_BALANCE) +{V4L2_CID_BLUE_BALANCE, "V4L2_CID_BLUE_BALANCE"}, +#endif +#if defined(V4L2_CID_GAMMA) +{V4L2_CID_GAMMA, "V4L2_CID_GAMMA"}, +#endif +#if defined(V4L2_CID_WHITENESS) +{V4L2_CID_WHITENESS, "V4L2_CID_WHITENESS"}, +#endif +#if defined(V4L2_CID_EXPOSURE) +{V4L2_CID_EXPOSURE, "V4L2_CID_EXPOSURE"}, +#endif +#if defined(V4L2_CID_AUTOGAIN) +{V4L2_CID_AUTOGAIN, "V4L2_CID_AUTOGAIN"}, +#endif +#if defined(V4L2_CID_GAIN) +{V4L2_CID_GAIN, "V4L2_CID_GAIN"}, +#endif +#if defined(V4L2_CID_HFLIP) +{V4L2_CID_HFLIP, "V4L2_CID_HFLIP"}, +#endif +#if defined(V4L2_CID_VFLIP) +{V4L2_CID_VFLIP, "V4L2_CID_VFLIP"}, +#endif +#if defined(V4L2_CID_HCENTER) +{V4L2_CID_HCENTER, "V4L2_CID_HCENTER"}, +#endif +#if defined(V4L2_CID_VCENTER) +{V4L2_CID_VCENTER, "V4L2_CID_VCENTER"}, +#endif +#if defined(V4L2_CID_POWER_LINE_FREQUENCY) +{V4L2_CID_POWER_LINE_FREQUENCY, "V4L2_CID_POWER_LINE_FREQUENCY"}, +#endif +#if defined(V4L2_CID_HUE_AUTO) +{V4L2_CID_HUE_AUTO, "V4L2_CID_HUE_AUTO"}, +#endif +#if defined(V4L2_CID_WHITE_BALANCE_TEMPERATURE) +{V4L2_CID_WHITE_BALANCE_TEMPERATURE, "V4L2_CID_WHITE_BALANCE_TEMPERATURE"}, +#endif +#if defined(V4L2_CID_SHARPNESS) +{V4L2_CID_SHARPNESS, "V4L2_CID_SHARPNESS"}, +#endif +#if defined(V4L2_CID_BACKLIGHT_COMPENSATION) +{V4L2_CID_BACKLIGHT_COMPENSATION, "V4L2_CID_BACKLIGHT_COMPENSATION"}, +#endif +#if defined(V4L2_CID_CHROMA_AGC) +{V4L2_CID_CHROMA_AGC, "V4L2_CID_CHROMA_AGC"}, +#endif +#if defined(V4L2_CID_COLOR_KILLER) +{V4L2_CID_COLOR_KILLER, "V4L2_CID_COLOR_KILLER"}, +#endif +#if defined(V4L2_CID_LASTP1) +{V4L2_CID_LASTP1, "V4L2_CID_LASTP1"}, +#endif +#if defined(V4L2_CID_CAMERA_CLASS) +{V4L2_CID_CAMERA_CLASS, "V4L2_CID_CAMERA_CLASS"}, +#endif +#if defined(V4L2_CID_EXPOSURE_AUTO) +{V4L2_CID_EXPOSURE_AUTO, "V4L2_CID_EXPOSURE_AUTO"}, +#endif +#if defined(V4L2_CID_EXPOSURE_ABSOLUTE) +{V4L2_CID_EXPOSURE_ABSOLUTE, "V4L2_CID_EXPOSURE_ABSOLUTE"}, +#endif +#if defined(V4L2_CID_EXPOSURE_AUTO_PRIORITY) +{V4L2_CID_EXPOSURE_AUTO_PRIORITY, "V4L2_CID_EXPOSURE_AUTO_PRIORITY"}, +#endif +#if defined(V4L2_CID_PAN_RELATIVE) +{V4L2_CID_PAN_RELATIVE, "V4L2_CID_PAN_RELATIVE"}, +#endif +#if defined(V4L2_CID_TILT_RELATIVE) +{V4L2_CID_TILT_RELATIVE, "V4L2_CID_TILT_RELATIVE"}, +#endif +#if defined(V4L2_CID_PAN_RESET) +{V4L2_CID_PAN_RESET, "V4L2_CID_PAN_RESET"}, +#endif +#if defined(V4L2_CID_TILT_RESET) +{V4L2_CID_TILT_RESET, "V4L2_CID_TILT_RESET"}, +#endif +#if defined(V4L2_CID_PAN_ABSOLUTE) +{V4L2_CID_PAN_ABSOLUTE, "V4L2_CID_PAN_ABSOLUTE"}, +#endif +#if defined(V4L2_CID_TILT_ABSOLUTE) +{V4L2_CID_TILT_ABSOLUTE, "V4L2_CID_TILT_ABSOLUTE"}, +#endif +#if defined(V4L2_CID_FOCUS_ABSOLUTE) +{V4L2_CID_FOCUS_ABSOLUTE, "V4L2_CID_FOCUS_ABSOLUTE"}, +#endif +#if defined(V4L2_CID_FOCUS_RELATIVE) +{V4L2_CID_FOCUS_RELATIVE, "V4L2_CID_FOCUS_RELATIVE"}, +#endif +#if defined(V4L2_CID_FOCUS_AUTO) +{V4L2_CID_FOCUS_AUTO, "V4L2_CID_FOCUS_AUTO"}, +#endif +{0xFFFFFFFF, ""} +}; + +k = 0; +while (mess[k].name[0]) { + if (wot == mess[k].command) { + JOT(8, "ioctl 0x%08X is %s\n", \ + mess[k].command, &mess[k].name[0]); + return 0; + } + k++; +} +JOT(8, "cid 0x%08X is not in videodev2.h\n", wot); +return -1; +} +/*****************************************************************************/ diff --git a/drivers/staging/easycap/easycap_ioctl.h b/drivers/staging/easycap/easycap_ioctl.h new file mode 100644 index 000000000000..7cab0943d913 --- /dev/null +++ b/drivers/staging/easycap/easycap_ioctl.h @@ -0,0 +1,29 @@ +/***************************************************************************** +* * +* easycap_ioctl.h * +* * +*****************************************************************************/ +/* + * + * Copyright (C) 2010 R.M. Thomas + * + * + * This 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. + * + * The software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * +*/ +/*****************************************************************************/ +extern struct easycap_format easycap_format[]; +extern struct v4l2_queryctrl easycap_control[]; +extern unsigned int audio_bytes_per_fragment; diff --git a/drivers/staging/easycap/easycap_low.c b/drivers/staging/easycap/easycap_low.c new file mode 100644 index 000000000000..e7c189af1476 --- /dev/null +++ b/drivers/staging/easycap/easycap_low.c @@ -0,0 +1,1057 @@ +/***************************************************************************** +* * +* * +* easycap_low.c * +* * +* * +*****************************************************************************/ +/* + * + * Copyright (C) 2010 R.M. Thomas + * + * + * This 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. + * + * The software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * +*/ +/*****************************************************************************/ +/* + * ACKNOWLEGEMENTS AND REFERENCES + * ------------------------------ + * This driver makes use of register information contained in the Syntek + * Semicon DC-1125 driver hosted at + * http://sourceforge.net/projects/syntekdriver/. + * Particularly useful has been a patch to the latter driver provided by + * Ivor Hewitt in January 2009. The NTSC implementation is taken from the + * work of Ben Trask. +*/ +/****************************************************************************/ + +#include "easycap_debug.h" +#include "easycap.h" + +/*--------------------------------------------------------------------------*/ +const struct stk1160config { int reg; int set; } stk1160config[256] = { + {0x000, 0x0098}, + {0x002, 0x0093}, + + {0x001, 0x0003}, + {0x003, 0x0080}, + {0x00D, 0x0000}, + {0x00F, 0x0002}, + {0x018, 0x0010}, + {0x019, 0x0000}, + {0x01A, 0x0014}, + {0x01B, 0x000E}, + {0x01C, 0x0046}, + + {0x100, 0x0033}, + {0x103, 0x0000}, + {0x104, 0x0000}, + {0x105, 0x0000}, + {0x106, 0x0000}, + +#if defined(PREFER_NTSC) + +#undef OLDMARGIN +#if defined(OLDMARGIN) + {0x110, 0x0008}, +#else + {0x110, 0x0014}, +#endif /*OLDMARGIN*/ + + {0x111, 0x0000}, + {0x112, 0x0003}, + {0x113, 0x0000}, + +#if defined(OLDMARGIN) + {0x114, 0x0508}, +#else + {0x114, 0x0514}, +#endif /*OLDMARGIN*/ + + {0x115, 0x0005}, + {0x116, 0x00F3}, + {0x117, 0x0000}, + +#else /* ! PREFER_NTSC*/ + +#if defined(OLDMARGIN) + {0x110, 0x0008}, +#else + {0x110, 0x0014}, +#endif /*OLDMARGIN*/ + + {0x111, 0x0000}, + {0x112, 0x0020}, + {0x113, 0x0000}, + +#if defined(OLDMARGIN) + {0x114, 0x0508}, +#else + {0x114, 0x0514}, +#endif /*OLDMARGIN*/ + + {0x115, 0x0005}, + {0x116, 0x0110}, + {0x117, 0x0001}, + +#endif /* ! PREFER_NTSC*/ + + {0x202, 0x000F}, + {0x203, 0x004A}, + {0x2FF, 0x0000}, +/*---------------------------------------------------------------------------*/ + {0xFFF, 0xFFFF} + }; +/*--------------------------------------------------------------------------*/ +const struct saa7113config { int reg; int set; } saa7113config[256] = { + {0x01, 0x08}, + {0x02, 0x80}, + {0x03, 0x33}, + {0x04, 0x00}, + {0x05, 0x00}, + {0x06, 0xE9}, + {0x07, 0x0D}, +#if defined(PREFER_NTSC) + {0x08, 0x78}, +#else + {0x08, 0x38}, +#endif /* ! PREFER_NTSC*/ + {0x09, 0x00}, + {0x0A, SAA_0A_DEFAULT}, + {0x0B, SAA_0B_DEFAULT}, + {0x0C, SAA_0C_DEFAULT}, + {0x0D, SAA_0D_DEFAULT}, + {0x0E, 0x01}, + {0x0F, 0x36}, + {0x10, 0x00}, + {0x11, 0x0C}, + {0x12, 0xE7}, + {0x13, 0x00}, + {0x15, 0x00}, + {0x16, 0x00}, +#if defined(PREFER_NTSC) + {0x40, 0x82}, +#else + {0x40, 0x02}, +#endif /* ! PREFER_NTSC*/ + {0x41, 0xFF}, + {0x42, 0xFF}, + {0x43, 0xFF}, + {0x44, 0xFF}, + {0x45, 0xFF}, + {0x46, 0xFF}, + {0x47, 0xFF}, + {0x48, 0xFF}, + {0x49, 0xFF}, + {0x4A, 0xFF}, + {0x4B, 0xFF}, + {0x4C, 0xFF}, + {0x4D, 0xFF}, + {0x4E, 0xFF}, + {0x4F, 0xFF}, + {0x50, 0xFF}, + {0x51, 0xFF}, + {0x52, 0xFF}, + {0x53, 0xFF}, + {0x54, 0xFF}, + {0x55, 0xFF}, + {0x56, 0xFF}, + {0x57, 0xFF}, + {0x58, 0x40}, + {0x59, 0x54}, +#if defined(PREFER_NTSC) + {0x5A, 0x0A}, +#else + {0x5A, 0x07}, +#endif /* ! PREFER_NTSC*/ + {0x5B, 0x83}, + {0xFF, 0xFF} + }; +/*--------------------------------------------------------------------------*/ + +/****************************************************************************/ +int +confirm_resolution(struct usb_device *p) +{ +__u8 get0, get1, get2, get3, get4, get5, get6, get7; +GET(p, 0x0110, &get0); +GET(p, 0x0111, &get1); +GET(p, 0x0112, &get2); +GET(p, 0x0113, &get3); +GET(p, 0x0114, &get4); +GET(p, 0x0115, &get5); +GET(p, 0x0116, &get6); +GET(p, 0x0117, &get7); +JOT(8, "0x%03X, 0x%03X, " \ + "0x%03X, 0x%03X, " \ + "0x%03X, 0x%03X, " \ + "0x%03X, 0x%03X\n", \ + get0, get1, get2, get3, get4, get5, get6, get7); +JOT(8, "....cf PAL_720x526: " \ + "0x%03X, 0x%03X, " \ + "0x%03X, 0x%03X, " \ + "0x%03X, 0x%03X, " \ + "0x%03X, 0x%03X\n", \ + 0x000, 0x000, 0x001, 0x000, 0x5A0, 0x005, 0x121, 0x001); +JOT(8, "....cf PAL_704x526: " \ + "0x%03X, 0x%03X, " \ + "0x%03X, 0x%03X, " \ + "0x%03X, 0x%03X, " \ + "0x%03X, 0x%03X\n", \ + 0x004, 0x000, 0x001, 0x000, 0x584, 0x005, 0x121, 0x001); +JOT(8, "....cf VGA_640x480: " \ + "0x%03X, 0x%03X, " \ + "0x%03X, 0x%03X, " \ + "0x%03X, 0x%03X, " \ + "0x%03X, 0x%03X\n", \ + 0x008, 0x000, 0x020, 0x000, 0x508, 0x005, 0x110, 0x001); +return 0; +} +/****************************************************************************/ +int +confirm_stream(struct usb_device *p) +{ +__u16 get2; +__u8 igot; + +GET(p, 0x0100, &igot); get2 = 0x80 & igot; +if (0x80 == get2) + JOT(8, "confirm_stream: OK\n"); +else + JOT(8, "confirm_stream: STUCK\n"); +return 0; +} +/****************************************************************************/ +int +setup_stk(struct usb_device *p) +{ +int i0; + +i0 = 0; +while (0xFFF != stk1160config[i0].reg) { + SET(p, stk1160config[i0].reg, stk1160config[i0].set); + i0++; + } + +write_300(p); + +return 0; +} +/****************************************************************************/ +int +setup_saa(struct usb_device *p) +{ +int i0, ir; + + +set2to78(p); + + +i0 = 0; +while (0xFF != saa7113config[i0].reg) { + ir = write_saa(p, saa7113config[i0].reg, saa7113config[i0].set); + i0++; + } +return 0; +} +/****************************************************************************/ +int +write_000(struct usb_device *p, __u16 set2, __u16 set0) +{ +__u8 igot0, igot2; + +GET(p, 0x0002, &igot2); +GET(p, 0x0000, &igot0); +SET(p, 0x0002, set2); +SET(p, 0x0000, set0); +return 0; +} +/****************************************************************************/ +int +write_saa(struct usb_device *p, __u16 reg0, __u16 set0) +{ +SET(p, 0x200, 0x00); +SET(p, 0x204, reg0); +SET(p, 0x205, set0); +SET(p, 0x200, 0x01); +return wait_i2c(p); +} +/****************************************************************************/ +/*--------------------------------------------------------------------------*/ +/* + * REGISTER 500: SETTING VALUE TO 0x008B READS FROM VT1612A (?) + * REGISTER 500: SETTING VALUE TO 0x008C WRITES TO VT1612A + * REGISTER 502: LEAST SIGNIFICANT BYTE OF VALUE TO SET + * REGISTER 503: MOST SIGNIFICANT BYTE OF VALUE TO SET + * REGISTER 504: TARGET ADDRESS ON VT1612A + */ +/*--------------------------------------------------------------------------*/ +int +write_vt(struct usb_device *p, __u16 reg0, __u16 set0) +{ +__u8 igot; +__u16 got502, got503; +__u16 set502, set503; + +SET(p, 0x0504, reg0); +SET(p, 0x0500, 0x008B); + +GET(p, 0x0502, &igot); got502 = (0xFF & igot); +GET(p, 0x0503, &igot); got503 = (0xFF & igot); + +JOT(16, "write_vt(., 0x%04X, 0x%04X): was 0x%04X\n", \ + reg0, set0, ((got503 << 8) | got502)); + +set502 = (0x00FF & set0); +set503 = ((0xFF00 & set0) >> 8); + +SET(p, 0x0504, reg0); +SET(p, 0x0502, set502); +SET(p, 0x0503, set503); +SET(p, 0x0500, 0x008C); + +return 0; +} +/****************************************************************************/ +/*--------------------------------------------------------------------------*/ +/* + * REGISTER 500: SETTING VALUE TO 0x008B READS FROM VT1612A (?) + * REGISTER 500: SETTING VALUE TO 0x008C WRITES TO VT1612A + * REGISTER 502: LEAST SIGNIFICANT BYTE OF VALUE TO GET + * REGISTER 503: MOST SIGNIFICANT BYTE OF VALUE TO GET + * REGISTER 504: TARGET ADDRESS ON VT1612A + */ +/*--------------------------------------------------------------------------*/ +int +read_vt(struct usb_device *p, __u16 reg0) +{ +__u8 igot; +__u16 got502, got503; + +SET(p, 0x0504, reg0); +SET(p, 0x0500, 0x008B); + +GET(p, 0x0502, &igot); got502 = (0xFF & igot); +GET(p, 0x0503, &igot); got503 = (0xFF & igot); + +JOT(16, "read_vt(., 0x%04X): has 0x%04X\n", reg0, ((got503 << 8) | got502)); + +return (got503 << 8) | got502; +} +/****************************************************************************/ +/*--------------------------------------------------------------------------*/ +/* + * THESE APPEAR TO HAVE NO EFFECT ON EITHER VIDEO OR AUDIO. + */ +/*--------------------------------------------------------------------------*/ +int +write_300(struct usb_device *p) +{ +SET(p, 0x300, 0x0012); +SET(p, 0x350, 0x002D); +SET(p, 0x351, 0x0001); +SET(p, 0x352, 0x0000); +SET(p, 0x353, 0x0000); +SET(p, 0x300, 0x0080); +return 0; +} +/****************************************************************************/ +/*--------------------------------------------------------------------------*/ +/* + * NOTE: THE FOLLOWING IS NOT CHECKED: + * REGISTER 0x0F, WHICH IS INVOLVED IN CHROMINANCE AUTOMATIC GAIN CONTROL. + */ +/*--------------------------------------------------------------------------*/ +int +check_saa(struct usb_device *p) +{ +int i0, ir, rc; +i0 = 0; + +rc = 0; +while (0xFF != saa7113config[i0].reg) { + if (0x0F == saa7113config[i0].reg) { + i0++; continue; + } + + ir = read_saa(p, saa7113config[i0].reg); + if (ir != saa7113config[i0].set) { + SAY("SAA register 0x%02X has 0x%02X, expected 0x%02X\n", \ + saa7113config[i0].reg, ir, saa7113config[i0].set); + rc--; + } + i0++; +} +if (-8 > rc) + return rc; +else + return 0; +} +/****************************************************************************/ +int +merit_saa(struct usb_device *p) +{ +int rc; + +rc = read_saa(p, 0x1F); +if ((0 > rc) || (0x02 & rc)) + return 1 ; +else + return 0; +} +/****************************************************************************/ +int +ready_saa(struct usb_device *p) +{ +int j, rc; +static int max = 10; + +j = 0; +while (max > j) { + rc = read_saa(p, 0x1F); + if (0 <= rc) { + if ((1 == (0x01 & rc))&&(0 == (0x40 & rc))) + break; + } + msleep(100); j++; +} +if (max == j) + return -1; +else { + if (0x20 & rc) + JOT(8, "hardware detects 60 Hz\n"); + else + JOT(8, "hardware detects 50 Hz\n"); + if (0x80 & rc) + JOT(8, "hardware detects interlacing\n"); + else + JOT(8, "hardware detects no interlacing\n"); +} +return 0; +} +/****************************************************************************/ +/*--------------------------------------------------------------------------*/ +/* + * NOTE: THE FOLLOWING ARE NOT CHECKED: + * REGISTERS 0x000, 0x002: FUNCTIONALITY IS NOT KNOWN + * REGISTER 0x100: ACCEPT ALSO (0x80 | stk1160config[.].set) + */ +/*--------------------------------------------------------------------------*/ +int +check_stk(struct usb_device *p) +{ +int i0, ir; +i0 = 0; +while (0xFFF != stk1160config[i0].reg) { + if (0x000 == stk1160config[i0].reg) { + i0++; continue; + } + if (0x002 == stk1160config[i0].reg) { + i0++; continue; + } + + ir = read_stk(p, stk1160config[i0].reg); + + if (0x100 == stk1160config[i0].reg) { + if ((ir != (0xFF & stk1160config[i0].set)) && \ + (ir != (0x80 | (0xFF & stk1160config[i0].set))) && \ + (0xFFFF != stk1160config[i0].set)) { + SAY("STK register 0x%03X has 0x%02X, " \ + "expected 0x%02X\n", \ + stk1160config[i0].reg, ir, \ + stk1160config[i0].set); + } + i0++; continue; + } + + if ((ir != (0xFF & stk1160config[i0].set)) && \ + (0xFFFF != stk1160config[i0].set)) { + SAY("STK register 0x%03X has 0x%02X, " \ + "expected 0x%02X\n", \ + stk1160config[i0].reg, ir, \ + stk1160config[i0].set); + } + i0++; + } +return 0; +} +/****************************************************************************/ +int +read_saa(struct usb_device *p, __u16 reg0) +{ +__u8 igot; + +SET(p, 0x208, reg0); +SET(p, 0x200, 0x20); +if (0 != wait_i2c(p)) + return -1; +igot = 0; +GET(p, 0x0209, &igot); +return igot; +} +/****************************************************************************/ +int +read_stk(struct usb_device *p, __u32 reg0) +{ +__u8 igot; + +igot = 0; +GET(p, reg0, &igot); +return igot; +} +/*****************************************************************************/ +/*---------------------------------------------------------------------------*/ +/* + * HARDWARE USERSPACE INPUT NUMBER PHYSICAL INPUT DRIVER input VALUE + * + * CVBS+S-VIDEO 0 or 1 CVBS 1 + * FOUR-CVBS 0 or 1 CVBS1 1 + * FOUR-CVBS 2 CVBS2 2 + * FOUR-CVBS 3 CVBS3 3 + * FOUR-CVBS 4 CVBS4 4 + * CVBS+S-VIDEO 5 S-VIDEO 5 + * + * WHEN 5==input THE ARGUMENT mode MUST ALSO BE SUPPLIED: + * + * mode 7 => GAIN TO BE SET EXPLICITLY USING REGISTER 0x05 (UNTESTED) + * mode 9 => USE AUTOMATIC GAIN CONTROL (DEFAULT) + * +*/ +/*---------------------------------------------------------------------------*/ +int +select_input(struct usb_device *p, int input, int mode) +{ + +stop_100(p); + +msleep(20); +switch (input) { +case 0: +case 1: { + SET(p, 0x0000, 0x0098); break; +} +case 2: { + SET(p, 0x0000, 0x0090); break; +} +case 3: { + SET(p, 0x0000, 0x0088); break; +} +case 4: { + SET(p, 0x0000, 0x0080); break; +} +case 5: { + if (9 != mode) + mode = 7; + switch (mode) { + case 7: + { + if (0 != write_saa(p, 0x02, 0x87)) { + SAY("ERROR: failed to set SAA " \ + "register 0x02 for input " \ + "%i\n", input); + } + if (0 != write_saa(p, 0x05, 0xFF)) { + SAY("ERROR: failed to set SAA " \ + "register 0x05 for input " \ + "%i\n", input); + } + break; + } + case 9: + { + if (0 != write_saa(p, 0x02, 0x89)) { + SAY("ERROR: failed to set SAA " \ + "register 0x02 for input " \ + "%i\n", input); + } + if (0 != write_saa(p, 0x05, 0x00)) { + SAY("ERROR: failed to set SAA " \ + "register 0x05 for input " \ + "%i\n", input); + } + break; + } + default: + { + SAY("MISTAKE: bad mode: %i\n", mode); + return -1; + } + } + if (0 != write_saa(p, 0x04, 0x00)) { + SAY("ERROR: failed to set SAA register 0x04 " \ + "for input %i\n", input); + } + if (0 != write_saa(p, 0x09, 0x80)) { + SAY("ERROR: failed to set SAA register 0x09 " \ + "for input %i\n", input); + } + break; +} +default: + { + SAY("ERROR: bad input: %i\n", input); + return -1; +} +} +msleep(20); +SET(p, 0x0002, 0x0093); +msleep(20); + +start_100(p); + +return 0; +} +/****************************************************************************/ +int +set_resolution(struct usb_device *p, \ + __u16 set0, __u16 set1, __u16 set2, __u16 set3) +{ +__u16 u0x0111, u0x0113, u0x0115, u0x0117; + +u0x0111 = ((0xFF00 & set0) >> 8); +u0x0113 = ((0xFF00 & set1) >> 8); +u0x0115 = ((0xFF00 & set2) >> 8); +u0x0117 = ((0xFF00 & set3) >> 8); + +SET(p, 0x0110, (0x00FF & set0)); +SET(p, 0x0111, u0x0111); +SET(p, 0x0112, (0x00FF & set1)); +SET(p, 0x0113, u0x0113); +SET(p, 0x0114, (0x00FF & set2)); +SET(p, 0x0115, u0x0115); +SET(p, 0x0116, (0x00FF & set3)); +SET(p, 0x0117, u0x0117); + +return 0; +} +/****************************************************************************/ +int +start_100(struct usb_device *p) +{ +__u16 get0; +__u8 igot; + +GET(p, 0x0100, &igot); get0 = igot; +msleep(0x1f4); +SET(p, 0x0100, (0x80 | get0)); +msleep(0x1f4); +return 0; +} +/****************************************************************************/ +int +stop_100(struct usb_device *p) +{ +__u16 get0; +__u8 igot; + +GET(p, 0x0100, &igot); get0 = igot; +msleep(0x1f4); +SET(p, 0x0100, (0x7F & get0)); +msleep(0x1f4); +return 0; +} +/****************************************************************************/ +/*--------------------------------------------------------------------------*/ +/* + * FUNCTION wait_i2c() RETURNS 0 ON SUCCESS +*/ +/*--------------------------------------------------------------------------*/ +int +wait_i2c(struct usb_device *p) +{ +__u16 get0; +__u8 igot; +const int max = 4; +int k; + +for (k = 0; k < max; k++) { + GET(p, 0x0201, &igot); get0 = igot; + switch (get0) { + case 0x04: + case 0x01: { + return 0; + } + case 0x00: { + msleep(10); + continue; + } + default: { + return get0 - 1; + } + } +} +return -1; +} +/****************************************************************************/ +int +regset(struct usb_device *pusb_device, __u16 index, __u16 value) +{ +__u16 igot; +int rc0, rc1; + +if (!pusb_device) + return -EFAULT; + +rc1 = 0; igot = 0; +rc0 = usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0), \ + (__u8)0x01, \ + (__u8)(USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE), \ + (__u16)value, \ + (__u16)index, \ + (void *)NULL, \ + (__u16)0, \ + (int)500); + +#if defined(NOREADBACK) +# +#else +rc1 = usb_control_msg(pusb_device, usb_rcvctrlpipe(pusb_device, 0), \ + (__u8)0x00, \ + (__u8)(USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE), \ + (__u16)0x00, \ + (__u16)index, \ + (void *)&igot, \ + (__u16)sizeof(__u16), \ + (int)50000); +igot = 0xFF & igot; +switch (index) { +case 0x000: +case 0x500: +case 0x502: +case 0x503: +case 0x504: +case 0x506: +case 0x507: { + break; +} +case 0x204: +case 0x205: +case 0x350: +case 0x351: { + if (0 != igot) { + JOT(8, "unexpected 0x%02X for STK register 0x%03X\n", \ + igot, index); + } +break; +} +case 0x114: +case 0x116: { + if ((0xFF & value) != igot) { + JOT(8, "unexpected 0x%02X != 0x%02X " \ + "for STK register 0x%03X\n", \ + igot, value, index); + } +break; +} +case 0x200: { + if (0 == igot) + break; +} +default: { + if (value != igot) { + JOT(8, "unexpected 0x%02X != 0x%02X " \ + "for STK register 0x%03X\n", \ + igot, value, index); + } +break; +} +} +#endif /* ! NOREADBACK*/ + +return (0 > rc0) ? rc0 : rc1; +} +/*****************************************************************************/ +int +regget(struct usb_device *pusb_device, __u16 index, void *pvoid) +{ +int ir; + +if (!pusb_device) + return -EFAULT; + +ir = usb_control_msg(pusb_device, usb_rcvctrlpipe(pusb_device, 0), \ + (__u8)0x00, \ + (__u8)(USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE), \ + (__u16)0x00, \ + (__u16)index, \ + (void *)pvoid, \ + sizeof(__u8), \ + (int)50000); +return 0xFF & ir; +} +/*****************************************************************************/ +int +wakeup_device(struct usb_device *pusb_device) +{ +return usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0), \ + (__u8)USB_REQ_SET_FEATURE, \ + (__u8)(USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE), \ + USB_DEVICE_REMOTE_WAKEUP, \ + (__u16)0, \ + (void *) NULL, \ + (__u16)0, \ + (int)50000); +} +/*****************************************************************************/ +/*---------------------------------------------------------------------------*/ +/* + * IMPORTANT: + * THE MESSAGE OF TYPE (USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) + * CAUSES MUTING IF THE VALUE 0x0100 IS SENT. + * TO ENABLE AUDIO THE VALUE 0x0200 MUST BE SENT. + */ +/*---------------------------------------------------------------------------*/ +int +audio_setup(struct easycap *peasycap) +{ +struct usb_device *pusb_device; +static __u8 request = 0x01; +static __u8 requesttype = \ + (__u8)(USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE); + +static __u16 value_unmute = 0x0200; +static __u16 index = 0x0301; + +static unsigned char buffer[1]; +static __u16 length = 1; +int rc; + +if (NULL == peasycap) + return -EFAULT; + +pusb_device = peasycap->pusb_device; +if (NULL == pusb_device) + return -EFAULT; + +JOT(8, "%02X %02X %02X %02X %02X %02X %02X %02X\n", \ + requesttype, request, \ + (0x00FF & value_unmute), \ + (0xFF00 & value_unmute) >> 8, \ + (0x00FF & index), \ + (0xFF00 & index) >> 8, \ + (0x00FF & length), \ + (0xFF00 & length) >> 8); + +buffer[0] = 0x01; + +rc = usb_control_msg(pusb_device, usb_sndctrlpipe(pusb_device, 0), \ + (__u8)request, \ + (__u8)requesttype, \ + (__u16)value_unmute, \ + (__u16)index, \ + (void *)&buffer[0], \ + (__u16)length, \ + (int)50000); + +JOT(8, "0x%02X=buffer\n", *((__u8 *) &buffer[0])); +if (rc != (int)length) + SAY("ERROR: usb_control_msg returned %i\n", rc); + +/*--------------------------------------------------------------------------*/ +/* + * REGISTER 500: SETTING VALUE TO 0x0094 RESETS AUDIO CONFIGURATION ??? + * REGISTER 506: ANALOGUE AUDIO ATTENTUATOR ??? + * FOR THE CVBS+S-VIDEO HARDWARE: + * SETTING VALUE TO 0x0000 GIVES QUIET SOUND. + * THE UPPER BYTE SEEMS TO HAVE NO EFFECT. + * FOR THE FOUR-CVBS HARDWARE: + * SETTING VALUE TO 0x0000 SEEMS TO HAVE NO EFFECT. + * REGISTER 507: ANALOGUE AUDIO PREAMPLIFIER ON/OFF ??? + * FOR THE CVBS-S-VIDEO HARDWARE: + * SETTING VALUE TO 0x0001 GIVES VERY LOUD, DISTORTED SOUND. + * THE UPPER BYTE SEEMS TO HAVE NO EFFECT. + */ +/*--------------------------------------------------------------------------*/ + +SET(pusb_device, 0x0500, 0x0094); + +SET(pusb_device, 0x0500, 0x008C); + +SET(pusb_device, 0x0506, 0x0001); +SET(pusb_device, 0x0507, 0x0000); + +if (false == peasycap->microphone) { + /*-------------------------------------------------------------------*/ + /* + * SELECT AUDIO SOURCE "LINE IN" AND SET DEFAULT GAIN TO 0dB. + */ + /*-------------------------------------------------------------------*/ + write_vt(pusb_device, 0x0002, 0x8000); + write_vt(pusb_device, 0x001C, 0x8000); + + write_vt(pusb_device, 0x000E, 0x0000); + write_vt(pusb_device, 0x0010, 0x0000); + write_vt(pusb_device, 0x0012, 0x8000); + write_vt(pusb_device, 0x0016, 0x0000); + + write_vt(pusb_device, 0x001A, 0x0404); + write_vt(pusb_device, 0x0002, 0x0000); + write_vt(pusb_device, 0x001C, 0x0000); +} else { + /*-------------------------------------------------------------------*/ + /* + * SELECT AUDIO SOURCE "MIC" AND SET DEFAULT GAIN TO 0 dB. + * + * REGISTER 0x000E CAN BE SET TO PROVIDE UP TO 34.5 dB ATTENTUATION, + * BUT THIS HAS NOT PROVED NECESSARY FOR THE FEW SIGNAL SOURCES + * TESTED HITHERTO. + */ + /*-------------------------------------------------------------------*/ + write_vt(pusb_device, 0x0006, 0x8000); + write_vt(pusb_device, 0x001C, 0x8000); + + write_vt(pusb_device, 0x000E, 0x0008); + + write_vt(pusb_device, 0x0010, 0x0000); + write_vt(pusb_device, 0x0012, 0x8000); + write_vt(pusb_device, 0x0016, 0x0000); + + write_vt(pusb_device, 0x001A, 0x0000); + write_vt(pusb_device, 0x0006, 0x0000); + write_vt(pusb_device, 0x001C, 0x0000); +} + +check_vt(pusb_device); + +return 0; +} +/*****************************************************************************/ +int +check_vt(struct usb_device *pusb_device) +{ +int igot; + +igot = read_vt(pusb_device, 0x0002); +if (0 > igot) + SAY("ERROR: failed to read VT1612A register 0x02\n"); +if (0x8000 & igot) + SAY("register 0x%02X muted\n", 0x02); + +igot = read_vt(pusb_device, 0x000E); +if (0 > igot) + SAY("ERROR: failed to read VT1612A register 0x0E\n"); +if (0x8000 & igot) + SAY("register 0x%02X muted\n", 0x0E); + +igot = read_vt(pusb_device, 0x0010); +if (0 > igot) + SAY("ERROR: failed to read VT1612A register 0x10\n"); +if (0x8000 & igot) + SAY("register 0x%02X muted\n", 0x10); + +igot = read_vt(pusb_device, 0x0012); +if (0 > igot) + SAY("ERROR: failed to read VT1612A register 0x12\n"); +if (0x8000 & igot) + SAY("register 0x%02X muted\n", 0x12); + +igot = read_vt(pusb_device, 0x0016); +if (0 > igot) + SAY("ERROR: failed to read VT1612A register 0x16\n"); +if (0x8000 & igot) + SAY("register 0x%02X muted\n", 0x16); + +igot = read_vt(pusb_device, 0x001A); +if (0 > igot) + SAY("ERROR: failed to read VT1612A register 0x1A\n"); +if (0x8000 & igot) + SAY("register 0x%02X muted\n", 0x1A); + +igot = read_vt(pusb_device, 0x001C); +if (0 > igot) + SAY("ERROR: failed to read VT1612A register 0x1C\n"); +if (0x8000 & igot) + SAY("register 0x%02X muted\n", 0x1C); + +return 0; +} +/*****************************************************************************/ +/*---------------------------------------------------------------------------*/ +/* + * NOTE: THIS DOES INCREASE THE VOLUME DRAMATICALLY: + * audio_gainset(pusb_device, 0x000F); + * + * IF 16 loud) + loud = 16; +u8 = 0x000F & (__u8)(loud - 16); + +write_vt(pusb_device, 0x0002, 0x8000); + +igot = read_vt(pusb_device, 0x001C); +if (0 > igot) { + SAY("ERROR: failed to read VT1612A register 0x1C\n"); + mute = 0x0000; +} else + mute = 0x8000 & ((unsigned int)igot); + +JOT(8, "0x%04X=(mute|u8|(u8<<8))\n", mute | u8 | (u8 << 8)); + +write_vt(pusb_device, 0x001C, 0x8000); +write_vt(pusb_device, 0x001C, (mute | u8 | (u8 << 8))); +write_vt(pusb_device, 0x0002, 0x0000); + +return 0; +} +/*****************************************************************************/ +int +audio_gainget(struct usb_device *pusb_device) +{ +int igot; + +igot = read_vt(pusb_device, 0x001C); +if (0 > igot) + SAY("ERROR: failed to read VT1612A register 0x1C\n"); +return igot; +} +/*****************************************************************************/ +int +set2to78(struct usb_device *p) +{ +int ir; + +msleep(20); +ir = regset(p, 0x0002, 0x0078); +if (0 > ir) + SAY("ERROR: failed to set register 0x0002 to 0x0078\n"); +msleep(20); +return ir; +} +/*****************************************************************************/ +int +set2to93(struct usb_device *p) +{ +int ir; + +msleep(20); +ir = regset(p, 0x0002, 0x0093); +if (0 > ir) + SAY("ERROR: failed to set register 0x0002 to 0x0078\n"); +msleep(20); +return ir; +} +/*****************************************************************************/ diff --git a/drivers/staging/easycap/easycap_main.c b/drivers/staging/easycap/easycap_main.c new file mode 100644 index 000000000000..18259df3fe7d --- /dev/null +++ b/drivers/staging/easycap/easycap_main.c @@ -0,0 +1,4342 @@ +/****************************************************************************** +* * +* easycap_main.c * +* * +* Video driver for EasyCAP USB2.0 Video Capture Device DC60 * +* * +* * +******************************************************************************/ +/* + * + * Copyright (C) 2010 R.M. Thomas + * + * + * This 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. + * + * The software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * +*/ +/*****************************************************************************/ + +#include "easycap.h" +#include "easycap_standard.h" + +int easycap_debug; +module_param(easycap_debug, int, S_IRUGO | S_IWUSR); + +unsigned int audio_pages_per_fragment; +unsigned int audio_bytes_per_fragment; +unsigned int audio_buffer_page_many; + +/*---------------------------------------------------------------------------*/ +/* + * PARAMETERS APPLICABLE TO ENTIRE DRIVER, I.E. BOTH VIDEO AND AUDIO + */ +/*---------------------------------------------------------------------------*/ +struct usb_device_id easycap_usb_device_id_table[] = { +{ USB_DEVICE(USB_EASYCAP_VENDOR_ID, USB_EASYCAP_PRODUCT_ID) }, +{ } +}; +MODULE_DEVICE_TABLE(usb, easycap_usb_device_id_table); +struct usb_driver easycap_usb_driver = { +.name = "easycap", +.id_table = easycap_usb_device_id_table, +.probe = easycap_usb_probe, +.disconnect = easycap_usb_disconnect, +}; +/*---------------------------------------------------------------------------*/ +/* + * PARAMETERS USED WHEN REGISTERING THE VIDEO INTERFACE + * + * NOTE: SOME KERNELS IGNORE usb_class_driver.minor_base, AS MENTIONED BY + * CORBET ET AL. "LINUX DEVICE DRIVERS", 3rd EDITION, PAGE 253. + * THIS IS THE CASE FOR OpenSUSE. + */ +/*---------------------------------------------------------------------------*/ +const struct file_operations easycap_fops = { +.owner = THIS_MODULE, +.open = easycap_open, +.release = easycap_release, +.ioctl = easycap_ioctl, +.poll = easycap_poll, +.mmap = easycap_mmap, +.llseek = no_llseek, +}; +struct vm_operations_struct easycap_vm_ops = { +.open = easycap_vma_open, +.close = easycap_vma_close, +.fault = easycap_vma_fault, +}; +struct usb_class_driver easycap_class = { +.name = "usb/easycap%d", +.fops = &easycap_fops, +.minor_base = USB_SKEL_MINOR_BASE, +}; + +/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ +#if defined(EASYCAP_IS_VIDEODEV_CLIENT) +#if defined(EASYCAP_NEEDS_V4L2_FOPS) +struct v4l2_file_operations v4l2_fops = { +.owner = THIS_MODULE, +.open = easycap_open_noinode, +.release = easycap_release_noinode, +.ioctl = easycap_ioctl_noinode, +.poll = easycap_poll, +.mmap = easycap_mmap, +}; +#endif /*EASYCAP_NEEDS_V4L2_FOPS*/ +int video_device_many /*=0*/; +struct video_device *pvideo_array[VIDEO_DEVICE_MANY], *pvideo_device; +#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ + +/*--------------------------------------------------------------------------*/ +/* + * PARAMETERS USED WHEN REGISTERING THE AUDIO INTERFACE + */ +/*--------------------------------------------------------------------------*/ +const struct file_operations easysnd_fops = { +.owner = THIS_MODULE, +.open = easysnd_open, +.release = easysnd_release, +.ioctl = easysnd_ioctl, +.read = easysnd_read, +.llseek = no_llseek, +}; +struct usb_class_driver easysnd_class = { +.name = "usb/easysnd%d", +.fops = &easysnd_fops, +.minor_base = USB_SKEL_MINOR_BASE, +}; +/****************************************************************************/ +/*--------------------------------------------------------------------------*/ +/* + * IT IS NOT APPROPRIATE FOR easycap_open() TO SUBMIT THE VIDEO URBS HERE, + * BECAUSE THERE WILL ALWAYS BE SUBSEQUENT NEGOTIATION OF TV STANDARD AND + * FORMAT BY IOCTL AND IT IS INADVISABLE TO HAVE THE URBS RUNNING WHILE + * REGISTERS OF THE SA7113H ARE BEING MANIPULATED. + * + * THE SUBMISSION OF VIDEO URBS IS THEREFORE DELAYED UNTIL THE IOCTL COMMAND + * STREAMON IS RECEIVED. + */ +/*--------------------------------------------------------------------------*/ +/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ +#if defined(EASYCAP_IS_VIDEODEV_CLIENT) +int +easycap_open_noinode(struct file *file) +{ +return easycap_open((struct inode *)NULL, file); +} +#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ +int +easycap_open(struct inode *inode, struct file *file) +{ +#if (!defined(EASYCAP_IS_VIDEODEV_CLIENT)) +struct usb_interface *pusb_interface; +#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ +struct usb_device *p; +struct easycap *peasycap; +int i, k, m, rc; + +JOT(4, "\n"); +SAY("==========OPEN=========\n"); + +peasycap = (struct easycap *)NULL; +#if (!defined(EASYCAP_IS_VIDEODEV_CLIENT)) +if ((struct inode *)NULL == inode) { + SAY("ERROR: inode is NULL.\n"); + return -EFAULT; +} +pusb_interface = usb_find_interface(&easycap_usb_driver, iminor(inode)); +if (!pusb_interface) { + SAY("ERROR: pusb_interface is NULL.\n"); + return -EFAULT; +} +peasycap = usb_get_intfdata(pusb_interface); +/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ +#else +for (i = 0; i < video_device_many; i++) { + pvideo_device = pvideo_array[i]; + if ((struct video_device *)NULL != pvideo_device) { + peasycap = (struct easycap *)video_get_drvdata(pvideo_device); + break; + } +} +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ +#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ +if ((struct easycap *)NULL == peasycap) { + SAY("MISTAKE: peasycap is NULL\n"); + return -EFAULT; +} +file->private_data = peasycap; +/*---------------------------------------------------------------------------*/ +/* + * INITIALIZATION + */ +/*---------------------------------------------------------------------------*/ +JOT(4, "starting initialization\n"); + +for (k = 0; k < FRAME_BUFFER_MANY; k++) { + for (m = 0; m < FRAME_BUFFER_SIZE/PAGE_SIZE; m++) + memset(peasycap->frame_buffer[k][m].pgo, 0, PAGE_SIZE); +} +p = peasycap->pusb_device; +if ((struct usb_device *)NULL == p) { + SAY("ERROR: peasycap->pusb_device is NULL\n"); + return -EFAULT; +} else { + JOT(16, "0x%08lX=peasycap->pusb_device\n", \ + (long int)peasycap->pusb_device); +} +rc = wakeup_device(peasycap->pusb_device); +if (0 == rc) + JOT(8, "wakeup_device() OK\n"); +else { + SAY("ERROR: wakeup_device() returned %i\n", rc); + return -EFAULT; +} +rc = setup_stk(p); peasycap->input = 0; +if (0 == rc) + JOT(8, "setup_stk() OK\n"); +else { + SAY("ERROR: setup_stk() returned %i\n", rc); + return -EFAULT; +} +rc = setup_saa(p); +if (0 == rc) + JOT(8, "setup_saa() OK\n"); +else { + SAY("ERROR: setup_saa() returned %i\n", rc); + return -EFAULT; +} +rc = check_saa(p); +if (0 == rc) + JOT(8, "check_saa() OK\n"); +else if (-8 < rc) + SAY("check_saa() returned %i\n", rc); +else { + SAY("ERROR: check_saa() returned %i\n", rc); + return -EFAULT; +} +peasycap->standard_offset = -1; +/*---------------------------------------------------------------------------*/ +#if defined(PREFER_NTSC) + +rc = adjust_standard(peasycap, V4L2_STD_NTSC_M); +if (0 == rc) + JOT(8, "adjust_standard(.,NTSC_M) OK\n"); +else { + SAY("ERROR: adjust_standard(.,NTSC_M) returned %i\n", rc); + return -EFAULT; +} +rc = adjust_format(peasycap, 640, 480, V4L2_PIX_FMT_UYVY, V4L2_FIELD_NONE, \ + false); +if (0 <= rc) + JOT(8, "adjust_format(.,640,480,UYVY) OK\n"); +else { + SAY("ERROR: adjust_format(.,640,480,UYVY) returned %i\n", rc); + return -EFAULT; +} + +#else + +rc = adjust_standard(peasycap, \ + (V4L2_STD_PAL_B | V4L2_STD_PAL_G | V4L2_STD_PAL_H | \ + V4L2_STD_PAL_I | V4L2_STD_PAL_N)); +if (0 == rc) + JOT(8, "adjust_standard(.,PAL_BGHIN) OK\n"); +else { + SAY("ERROR: adjust_standard(.,PAL_BGHIN) returned %i\n", rc); + return -EFAULT; +} +rc = adjust_format(peasycap, 640, 480, V4L2_PIX_FMT_UYVY, V4L2_FIELD_NONE, \ + false); +if (0 <= rc) + JOT(8, "adjust_format(.,640,480,uyvy,false) OK\n"); +else { + SAY("ERROR: adjust_format(.,640,480,uyvy,false) returned %i\n", rc); + return -EFAULT; +} + +#endif /* !PREFER_NTSC*/ +/*---------------------------------------------------------------------------*/ +rc = adjust_brightness(peasycap, -8192); +if (0 != rc) { + SAY("ERROR: adjust_brightness(default) returned %i\n", rc); + return -EFAULT; +} +rc = adjust_contrast(peasycap, -8192); +if (0 != rc) { + SAY("ERROR: adjust_contrast(default) returned %i\n", rc); + return -EFAULT; +} +rc = adjust_saturation(peasycap, -8192); +if (0 != rc) { + SAY("ERROR: adjust_saturation(default) returned %i\n", rc); + return -EFAULT; +} +rc = adjust_hue(peasycap, -8192); +if (0 != rc) { + SAY("ERROR: adjust_hue(default) returned %i\n", rc); + return -EFAULT; +} +/*---------------------------------------------------------------------------*/ +rc = usb_set_interface(peasycap->pusb_device, peasycap->video_interface, \ + peasycap->video_altsetting_on); +if (0 == rc) + JOT(8, "usb_set_interface(.,%i,%i) OK\n", peasycap->video_interface, \ + peasycap->video_altsetting_on); +else { + SAY("ERROR: usb_set_interface() returned %i\n", rc); + return -EFAULT; +} +rc = start_100(p); +if (0 == rc) + JOT(8, "start_100() OK\n"); +else { + SAY("ERROR: start_100() returned %i\n", rc); + return -EFAULT; +} +peasycap->video_isoc_sequence = VIDEO_ISOC_BUFFER_MANY - 1; +peasycap->video_idle = 0; +peasycap->video_junk = 0; +for (i = 0; i < 180; i++) + peasycap->merit[i] = 0; +peasycap->video_eof = 0; +peasycap->audio_eof = 0; + +do_gettimeofday(&peasycap->timeval7); + +peasycap->fudge = 0; + +JOT(4, "finished initialization\n"); +return 0; +} +/*****************************************************************************/ +int +submit_video_urbs(struct easycap *peasycap) +{ +struct data_urb *pdata_urb; +struct urb *purb; +struct list_head *plist_head; +int j, isbad, m, rc; +int isbuf; + +if ((struct list_head *)NULL == peasycap->purb_video_head) { + SAY("ERROR: peasycap->urb_video_head uninitialized\n"); + return -EFAULT; +} +if ((struct usb_device *)NULL == peasycap->pusb_device) { + SAY("ERROR: peasycap->pusb_device is NULL\n"); + return -EFAULT; +} +if (!peasycap->video_isoc_streaming) { + + + + + + + + + JOT(4, "submission of all video urbs\n"); + if (0 != ready_saa(peasycap->pusb_device)) { + SAY("ERROR: not ready to capture after waiting " \ + "one second\n"); + SAY("..... continuing anyway\n"); + } + isbad = 0; m = 0; + list_for_each(plist_head, (peasycap->purb_video_head)) { + pdata_urb = list_entry(plist_head, struct data_urb, list_head); + if (NULL != pdata_urb) { + purb = pdata_urb->purb; + if (NULL != purb) { + isbuf = pdata_urb->isbuf; + purb->interval = 1; + purb->dev = peasycap->pusb_device; + purb->pipe = \ + usb_rcvisocpipe(peasycap->pusb_device,\ + peasycap->video_endpointnumber); + purb->transfer_flags = URB_ISO_ASAP; + purb->transfer_buffer = \ + peasycap->video_isoc_buffer[isbuf].pgo; + purb->transfer_buffer_length = \ + peasycap->video_isoc_buffer_size; + purb->complete = easycap_complete; + purb->context = peasycap; + purb->start_frame = 0; + purb->number_of_packets = \ + peasycap->video_isoc_framesperdesc; + + for (j = 0; j < peasycap->\ + video_isoc_framesperdesc; j++) { + purb->iso_frame_desc[j].\ + offset = j * \ + peasycap->\ + video_isoc_maxframesize; + purb->iso_frame_desc[j].\ + length = peasycap->\ + video_isoc_maxframesize; + } + + rc = usb_submit_urb(purb, GFP_KERNEL); + if (0 != rc) { + isbad++; + SAY("ERROR: usb_submit_urb() failed " \ + "for urb with rc:\n"); + switch (rc) { + case -ENOMEM: { + SAY("ENOMEM\n"); + break; + } + case -ENODEV: { + SAY("ENODEV\n"); + break; + } + case -ENXIO: { + SAY("ENXIO\n"); + break; + } + case -EINVAL: { + SAY("EINVAL\n"); + break; + } + case -EAGAIN: { + SAY("EAGAIN\n"); + break; + } + case -EFBIG: { + SAY("EFBIG\n"); + break; + } + case -EPIPE: { + SAY("EPIPE\n"); + break; + } + case -EMSGSIZE: { + SAY("EMSGSIZE\n"); + break; + } + default: { + SAY("unknown error code %i\n",\ + rc); + break; + } + } + } else { + m++; + } + } else { + isbad++; + } + } else { + isbad++; + } + } + if (isbad) { + JOT(4, "attempting cleanup instead of submitting\n"); + list_for_each(plist_head, (peasycap->purb_video_head)) { + pdata_urb = list_entry(plist_head, struct data_urb, \ + list_head); + if (NULL != pdata_urb) { + purb = pdata_urb->purb; + if (NULL != purb) + usb_kill_urb(purb); + } + } + peasycap->video_isoc_streaming = 0; + } else { + peasycap->video_isoc_streaming = 1; + JOT(4, "submitted %i video urbs\n", m); + } + + + + + + +} else { + JOT(4, "already streaming video urbs\n"); +} +return 0; +} +/*****************************************************************************/ +int +kill_video_urbs(struct easycap *peasycap) +{ +int m; +struct list_head *plist_head; +struct data_urb *pdata_urb; + +if ((struct easycap *)NULL == peasycap) { + SAY("ERROR: peasycap is NULL\n"); + return -EFAULT; +} +if (peasycap->video_isoc_streaming) { + + + + if ((struct list_head *)NULL != peasycap->purb_video_head) { + peasycap->video_isoc_streaming = 0; + JOT(4, "killing video urbs\n"); + m = 0; + list_for_each(plist_head, (peasycap->purb_video_head)) { + pdata_urb = list_entry(plist_head, struct data_urb, \ + list_head); + if ((struct data_urb *)NULL != pdata_urb) { + if ((struct urb *)NULL != pdata_urb->purb) { + usb_kill_urb(pdata_urb->purb); + m++; + } + } + } + JOT(4, "%i video urbs killed\n", m); + } else { + SAY("ERROR: peasycap->purb_video_head is NULL\n"); + return -EFAULT; + } +} else { + JOT(8, "%i=video_isoc_streaming, no video urbs killed\n", \ + peasycap->video_isoc_streaming); +} +return 0; +} +/****************************************************************************/ +/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ +#if defined(EASYCAP_IS_VIDEODEV_CLIENT) +int +easycap_release_noinode(struct file *file) +{ +return easycap_release((struct inode *)NULL, file); +} +#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ +/*--------------------------------------------------------------------------*/ +int +easycap_release(struct inode *inode, struct file *file) +{ +#if (!defined(EASYCAP_IS_VIDEODEV_CLIENT)) +struct easycap *peasycap; + +JOT(4, "\n"); + +peasycap = (struct easycap *)file->private_data; +if (NULL == peasycap) { + SAY("ERROR: peasycap is NULL.\n"); + SAY("ending unsuccessfully\n"); + return -EFAULT; +} +if (0 != kill_video_urbs(peasycap)) { + SAY("ERROR: kill_video_urbs() failed\n"); + return -EFAULT; +} +JOT(4, "ending successfully\n"); +/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ +#else +# +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ +#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ + +return 0; +} +/****************************************************************************/ +/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ +#if defined(EASYCAP_IS_VIDEODEV_CLIENT) +int +videodev_release(struct video_device *pvd) +{ +struct easycap *peasycap; +int i, j, k; + +JOT(4, "\n"); + +k = 0; +for (i = 0; i < video_device_many; i++) { + pvideo_device = pvideo_array[i]; + if ((struct video_device *)NULL != pvideo_device) { + if (pvd->minor == pvideo_device->minor) { + peasycap = (struct easycap *)\ + video_get_drvdata(pvideo_device); + if ((struct easycap *)NULL == peasycap) { + SAY("ERROR: peasycap is NULL\n"); + SAY("ending unsuccessfully\n"); + return -EFAULT; + } + if (0 != kill_video_urbs(peasycap)) { + SAY("ERROR: kill_video_urbs() failed\n"); + return -EFAULT; + } + JOT(4, "freeing video_device structure: " \ + "/dev/video%i\n", i); + kfree((void *)pvideo_device); + for (j = i; j < (VIDEO_DEVICE_MANY - 1); j++) + pvideo_array[j] = pvideo_array[j + 1]; + video_device_many--; k++; + break; + } + } +} +if (!k) { + SAY("ERROR: lost video_device structure for %i=minor\n", pvd->minor); + SAY("cannot free: may cause memory leak\n"); + SAY("ending unsuccessfully\n"); + return -EFAULT; +} + +JOT(4, "ending successfully\n"); +return 0; +} +#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ +/****************************************************************************/ +/*--------------------------------------------------------------------------*/ +/* + * THIS FUNCTION IS CALLED FROM WITHIN easycap_usb_disconnect(). + * BY THIS STAGE THE DEVICE HAS ALREADY BEEN PHYSICALLY UNPLUGGED. + * peasycap->pusb_device IS NO LONGER VALID AND SHOULD HAVE BEEN SET TO NULL. + */ +/*---------------------------------------------------------------------------*/ +void +easycap_delete(struct kref *pkref) +{ +int k, m, lost; +int allocation_video_urb, allocation_video_page, allocation_video_struct; +int allocation_audio_urb, allocation_audio_page, allocation_audio_struct; +int registered_video, registered_audio; +struct easycap *peasycap; +struct data_urb *pdata_urb; +struct list_head *plist_head, *plist_next; + +JOT(4, "\n"); + +peasycap = container_of(pkref, struct easycap, kref); +if ((struct easycap *)NULL == peasycap) { + SAY("ERROR: peasycap is NULL: cannot perform deletions\n"); + return; +} +/*---------------------------------------------------------------------------*/ +/* + * FREE VIDEO. + */ +/*---------------------------------------------------------------------------*/ +if ((struct list_head *)NULL != peasycap->purb_video_head) { + JOT(4, "freeing video urbs\n"); + m = 0; + list_for_each(plist_head, (peasycap->purb_video_head)) { + pdata_urb = list_entry(plist_head, struct data_urb, list_head); + if (NULL == pdata_urb) + JOT(4, "ERROR: pdata_urb is NULL\n"); + else { + if ((struct urb *)NULL != pdata_urb->purb) { + usb_free_urb(pdata_urb->purb); + pdata_urb->purb = (struct urb *)NULL; + peasycap->allocation_video_urb -= 1; + m++; + } + } + } + + JOT(4, "%i video urbs freed\n", m); +/*---------------------------------------------------------------------------*/ + JOT(4, "freeing video data_urb structures.\n"); + m = 0; + list_for_each_safe(plist_head, plist_next, peasycap->purb_video_head) { + pdata_urb = list_entry(plist_head, struct data_urb, list_head); + if ((struct data_urb *)NULL != pdata_urb) { + kfree(pdata_urb); pdata_urb = (struct data_urb *)NULL; + peasycap->allocation_video_struct -= \ + sizeof(struct data_urb); + m++; + } + } + JOT(4, "%i video data_urb structures freed\n", m); + JOT(4, "setting peasycap->purb_video_head=NULL\n"); + peasycap->purb_video_head = (struct list_head *)NULL; + } else { +JOT(4, "peasycap->purb_video_head is NULL\n"); +} +/*---------------------------------------------------------------------------*/ +JOT(4, "freeing video isoc buffers.\n"); +m = 0; +for (k = 0; k < VIDEO_ISOC_BUFFER_MANY; k++) { + if ((void *)NULL != peasycap->video_isoc_buffer[k].pgo) { + free_pages((unsigned long)\ + (peasycap->video_isoc_buffer[k].pgo), \ + VIDEO_ISOC_ORDER); + peasycap->video_isoc_buffer[k].pgo = (void *)NULL; + peasycap->allocation_video_page -= \ + ((unsigned int)(0x01 << VIDEO_ISOC_ORDER)); + m++; + } +} +JOT(4, "isoc video buffers freed: %i pages\n", m * (0x01 << VIDEO_ISOC_ORDER)); +/*---------------------------------------------------------------------------*/ +JOT(4, "freeing video field buffers.\n"); +lost = 0; +for (k = 0; k < FIELD_BUFFER_MANY; k++) { + for (m = 0; m < FIELD_BUFFER_SIZE/PAGE_SIZE; m++) { + if ((void *)NULL != peasycap->field_buffer[k][m].pgo) { + free_page((unsigned long)\ + (peasycap->field_buffer[k][m].pgo)); + peasycap->field_buffer[k][m].pgo = (void *)NULL; + peasycap->allocation_video_page -= 1; + lost++; + } + } +} +JOT(4, "video field buffers freed: %i pages\n", lost); +/*---------------------------------------------------------------------------*/ +JOT(4, "freeing video frame buffers.\n"); +lost = 0; +for (k = 0; k < FRAME_BUFFER_MANY; k++) { + for (m = 0; m < FRAME_BUFFER_SIZE/PAGE_SIZE; m++) { + if ((void *)NULL != peasycap->frame_buffer[k][m].pgo) { + free_page((unsigned long)\ + (peasycap->frame_buffer[k][m].pgo)); + peasycap->frame_buffer[k][m].pgo = (void *)NULL; + peasycap->allocation_video_page -= 1; + lost++; + } + } +} +JOT(4, "video frame buffers freed: %i pages\n", lost); +/*---------------------------------------------------------------------------*/ +/* + * FREE AUDIO. + */ +/*---------------------------------------------------------------------------*/ +if ((struct list_head *)NULL != peasycap->purb_audio_head) { + JOT(4, "freeing audio urbs\n"); + m = 0; + list_for_each(plist_head, (peasycap->purb_audio_head)) { + pdata_urb = list_entry(plist_head, struct data_urb, list_head); + if (NULL == pdata_urb) + JOT(4, "ERROR: pdata_urb is NULL\n"); + else { + if ((struct urb *)NULL != pdata_urb->purb) { + usb_free_urb(pdata_urb->purb); + pdata_urb->purb = (struct urb *)NULL; + peasycap->allocation_audio_urb -= 1; + m++; + } + } + } + JOT(4, "%i audio urbs freed\n", m); +/*---------------------------------------------------------------------------*/ + JOT(4, "freeing audio data_urb structures.\n"); + m = 0; + list_for_each_safe(plist_head, plist_next, peasycap->purb_audio_head) { + pdata_urb = list_entry(plist_head, struct data_urb, list_head); + if ((struct data_urb *)NULL != pdata_urb) { + kfree(pdata_urb); pdata_urb = (struct data_urb *)NULL; + peasycap->allocation_audio_struct -= \ + sizeof(struct data_urb); + m++; + } + } +JOT(4, "%i audio data_urb structures freed\n", m); +JOT(4, "setting peasycap->purb_audio_head=NULL\n"); +peasycap->purb_audio_head = (struct list_head *)NULL; +} else { +JOT(4, "peasycap->purb_audio_head is NULL\n"); +} +/*---------------------------------------------------------------------------*/ +JOT(4, "freeing audio isoc buffers.\n"); +m = 0; +for (k = 0; k < AUDIO_ISOC_BUFFER_MANY; k++) { + if ((void *)NULL != peasycap->audio_isoc_buffer[k].pgo) { + free_pages((unsigned long)\ + (peasycap->audio_isoc_buffer[k].pgo), \ + AUDIO_ISOC_ORDER); + peasycap->audio_isoc_buffer[k].pgo = (void *)NULL; + peasycap->allocation_audio_page -= \ + ((unsigned int)(0x01 << AUDIO_ISOC_ORDER)); + m++; + } +} +JOT(4, "easysnd_delete(): isoc audio buffers freed: %i pages\n", \ + m * (0x01 << AUDIO_ISOC_ORDER)); +/*---------------------------------------------------------------------------*/ +JOT(4, "freeing audio buffers.\n"); +lost = 0; +for (k = 0; k < audio_buffer_page_many; k++) { + if ((void *)NULL != peasycap->audio_buffer[k].pgo) { + free_page((unsigned long)(peasycap->audio_buffer[k].pgo)); + peasycap->audio_buffer[k].pgo = (void *)NULL; + peasycap->allocation_audio_page -= 1; + lost++; + } +} +JOT(4, "easysnd_delete(): audio buffers freed: %i pages\n", lost); +/*---------------------------------------------------------------------------*/ +JOT(4, "freeing easycap structure.\n"); +allocation_video_urb = peasycap->allocation_video_urb; +allocation_video_page = peasycap->allocation_video_page; +allocation_video_struct = peasycap->allocation_video_struct; +registered_video = peasycap->registered_video; +allocation_audio_urb = peasycap->allocation_audio_urb; +allocation_audio_page = peasycap->allocation_audio_page; +allocation_audio_struct = peasycap->allocation_audio_struct; +registered_audio = peasycap->registered_audio; +m = 0; +if ((struct easycap *)NULL != peasycap) { + kfree(peasycap); peasycap = (struct easycap *)NULL; + allocation_video_struct -= sizeof(struct easycap); + m++; +} +JOT(4, "%i easycap structure freed\n", m); +/*---------------------------------------------------------------------------*/ + +SAY("%8i= video urbs after all deletions\n", allocation_video_urb); +SAY("%8i= video pages after all deletions\n", allocation_video_page); +SAY("%8i= video structs after all deletions\n", allocation_video_struct); +SAY("%8i= video devices after all deletions\n", registered_video); +SAY("%8i= audio urbs after all deletions\n", allocation_audio_urb); +SAY("%8i= audio pages after all deletions\n", allocation_audio_page); +SAY("%8i= audio structs after all deletions\n", allocation_audio_struct); +SAY("%8i= audio devices after all deletions\n", registered_audio); + +JOT(4, "ending.\n"); +return; +} +/*****************************************************************************/ +unsigned int easycap_poll(struct file *file, poll_table *wait) +{ +struct easycap *peasycap; + +JOT(8, "\n"); + +if (NULL == ((poll_table *)wait)) + JOT(8, "WARNING: poll table pointer is NULL ... continuing\n"); +if (NULL == ((struct file *)file)) { + SAY("ERROR: file pointer is NULL\n"); + return -EFAULT; +} +peasycap = (struct easycap *)file->private_data; +if (NULL == peasycap) { + SAY("ERROR: peasycap is NULL\n"); + return -EFAULT; +} +peasycap->polled = 1; + +if (0 == easycap_dqbuf(peasycap, 0)) + return POLLIN | POLLRDNORM; +else + return POLLERR; + +} +/*****************************************************************************/ +/*---------------------------------------------------------------------------*/ +/* + * IF mode IS NONZERO THIS ROUTINE RETURNS -EAGAIN RATHER THAN BLOCKING. + */ +/*---------------------------------------------------------------------------*/ +int +easycap_dqbuf(struct easycap *peasycap, int mode) +{ +int miss, rc; + +JOT(8, "\n"); + +if (NULL == peasycap) { + SAY("ERROR: peasycap is NULL\n"); + return -EFAULT; +} +/*---------------------------------------------------------------------------*/ +/* + * WAIT FOR FIELD 0 + */ +/*---------------------------------------------------------------------------*/ +miss = 0; +if (mutex_lock_interruptible(&(peasycap->mutex_mmap_video[0]))) + return -ERESTARTSYS; +while ((peasycap->field_read == peasycap->field_fill) || \ + (0 != (0xFF00 & peasycap->field_buffer\ + [peasycap->field_read][0].kount)) || \ + (0 != (0x00FF & peasycap->field_buffer\ + [peasycap->field_read][0].kount))) { + mutex_unlock(&(peasycap->mutex_mmap_video[0])); + + if (mode) + return -EAGAIN; + + JOT(8, "first wait on wq_video, " \ + "%i=field_read %i=field_fill\n", \ + peasycap->field_read, peasycap->field_fill); + + msleep(1); + if (0 != (wait_event_interruptible(peasycap->wq_video, \ + (peasycap->video_idle || peasycap->video_eof || \ + ((peasycap->field_read != peasycap->field_fill) && \ + (0 == (0xFF00 & peasycap->field_buffer\ + [peasycap->field_read][0].kount)) && \ + (0 == (0x00FF & peasycap->field_buffer\ + [peasycap->field_read][0].kount))))))){ + SAY("aborted by signal\n"); + return -EIO; + } + if (peasycap->video_idle) { + JOT(8, "%i=peasycap->video_idle\n", peasycap->video_idle); + return -EIO; + } + if (peasycap->video_eof) { + JOT(8, "%i=peasycap->video_eof\n", peasycap->video_eof); + debrief(peasycap); + kill_video_urbs(peasycap); + return -EIO; + } +miss++; +if (mutex_lock_interruptible(&(peasycap->mutex_mmap_video[0]))) + return -ERESTARTSYS; +} +mutex_unlock(&(peasycap->mutex_mmap_video[0])); +JOT(8, "first awakening on wq_video after %i waits\n", miss); + +rc = field2frame(peasycap); +if (0 != rc) + SAY("ERROR: field2frame() returned %i\n", rc); + +if (true == peasycap->offerfields) { + peasycap->frame_read = peasycap->frame_fill; + (peasycap->frame_fill)++; + if (peasycap->frame_buffer_many <= peasycap->frame_fill) + peasycap->frame_fill = 0; + + if (0x01 & easycap_standard[peasycap->standard_offset].mask) { + peasycap->frame_buffer[peasycap->frame_read][0].kount = \ + V4L2_FIELD_BOTTOM; + } else { + peasycap->frame_buffer[peasycap->frame_read][0].kount = \ + V4L2_FIELD_TOP; + } +JOT(8, "setting: %i=peasycap->frame_read\n", peasycap->frame_read); +JOT(8, "bumped to: %i=peasycap->frame_fill\n", peasycap->frame_fill); +} +/*---------------------------------------------------------------------------*/ +/* + * WAIT FOR FIELD 1 + */ +/*---------------------------------------------------------------------------*/ +miss = 0; +if (mutex_lock_interruptible(&(peasycap->mutex_mmap_video[0]))) + return -ERESTARTSYS; +while ((peasycap->field_read == peasycap->field_fill) || \ + (0 != (0xFF00 & peasycap->field_buffer\ + [peasycap->field_read][0].kount)) || \ + (0 == (0x00FF & peasycap->field_buffer\ + [peasycap->field_read][0].kount))) { + mutex_unlock(&(peasycap->mutex_mmap_video[0])); + + if (mode) + return -EAGAIN; + + JOT(8, "second wait on wq_video, " \ + "%i=field_read %i=field_fill\n", \ + peasycap->field_read, peasycap->field_fill); + msleep(1); + if (0 != (wait_event_interruptible(peasycap->wq_video, \ + (peasycap->video_idle || peasycap->video_eof || \ + ((peasycap->field_read != peasycap->field_fill) && \ + (0 == (0xFF00 & peasycap->field_buffer\ + [peasycap->field_read][0].kount)) && \ + (0 != (0x00FF & peasycap->field_buffer\ + [peasycap->field_read][0].kount))))))){ + SAY("aborted by signal\n"); + return -EIO; + } + if (peasycap->video_idle) { + JOT(8, "%i=peasycap->video_idle\n", peasycap->video_idle); + return -EIO; + } + if (peasycap->video_eof) { + JOT(8, "%i=peasycap->video_eof\n", peasycap->video_eof); + debrief(peasycap); + kill_video_urbs(peasycap); + return -EIO; + } +miss++; +if (mutex_lock_interruptible(&(peasycap->mutex_mmap_video[0]))) + return -ERESTARTSYS; +} +mutex_unlock(&(peasycap->mutex_mmap_video[0])); +JOT(8, "second awakening on wq_video after %i waits\n", miss); + +rc = field2frame(peasycap); +if (0 != rc) + SAY("ERROR: field2frame() returned %i\n", rc); + +peasycap->frame_read = peasycap->frame_fill; +peasycap->queued[peasycap->frame_read] = 0; +peasycap->done[peasycap->frame_read] = V4L2_BUF_FLAG_DONE; + +(peasycap->frame_fill)++; +if (peasycap->frame_buffer_many <= peasycap->frame_fill) + peasycap->frame_fill = 0; + +if (0x01 & easycap_standard[peasycap->standard_offset].mask) { + peasycap->frame_buffer[peasycap->frame_read][0].kount = \ + V4L2_FIELD_TOP; +} else { + peasycap->frame_buffer[peasycap->frame_read][0].kount = \ + V4L2_FIELD_BOTTOM; +} + +JOT(8, "setting: %i=peasycap->frame_read\n", peasycap->frame_read); +JOT(8, "bumped to: %i=peasycap->frame_fill\n", peasycap->frame_fill); + +return 0; +} +/*****************************************************************************/ +/*---------------------------------------------------------------------------*/ +/* + * BY DEFINITION, odd IS true FOR THE FIELD OCCUPYING LINES 1,3,5,...,479 + * odd IS false FOR THE FIELD OCCUPYING LINES 0,2,4,...,478 + * + * WHEN BOOLEAN PARAMETER decimatepixel IS true, ONLY THE FIELD FOR WHICH + * odd==false IS TRANSFERRED TO THE FRAME BUFFER. + * + * THE BOOLEAN PARAMETER offerfields IS true ONLY WHEN THE USER PROGRAM + * CHOOSES THE OPTION V4L2_FIELD_ALTERNATE. NO USERSPACE PROGRAM TESTED + * TO DATE HAS DONE THIS. BUGS ARE LIKELY. + */ +/*---------------------------------------------------------------------------*/ +int +field2frame(struct easycap *peasycap) +{ +static struct timeval timeval0; +struct timeval timeval; +long long int above, below; +__u32 remainder; +struct signed_div_result sdr; + +void *pex, *pad; +int kex, kad, mex, mad, rex, rad, rad2; +int c2, c3, w2, w3, cz, wz; +int rc, bytesperpixel, multiplier, much, more, over, rump, caches; +__u8 mask, margin; +bool odd, isuy, decimatepixel, offerfields; + +JOT(8, "===== parity %i, field buffer %i --> frame buffer %i\n", \ + peasycap->field_buffer[peasycap->field_read][0].kount,\ + peasycap->field_read, peasycap->frame_fill); +JOT(8, "===== %i=bytesperpixel\n", peasycap->bytesperpixel); +if (true == peasycap->offerfields) + JOT(8, "===== offerfields\n"); + +/*---------------------------------------------------------------------------*/ +/* + * REJECT OR CLEAN BAD FIELDS + */ +/*---------------------------------------------------------------------------*/ +if (peasycap->field_read == peasycap->field_fill) { + SAY("ERROR: on entry, still filling field buffer %i\n", \ + peasycap->field_read); + return 0; +} +#if defined(EASYCAP_TESTCARD) +easycap_testcard(peasycap, peasycap->field_read); +#else +if (0 != (0x0400 & peasycap->field_buffer[peasycap->field_read][0].kount)) + easycap_testcard(peasycap, peasycap->field_read); +#endif /*EASYCAP_TESTCARD*/ +/*---------------------------------------------------------------------------*/ + +offerfields = peasycap->offerfields; +bytesperpixel = peasycap->bytesperpixel; +decimatepixel = peasycap->decimatepixel; + +if ((2 != bytesperpixel) && \ + (3 != bytesperpixel) && \ + (4 != bytesperpixel)) { + SAY("MISTAKE: %i=bytesperpixel\n", bytesperpixel); + return -EFAULT; +} +if (true == decimatepixel) + multiplier = 2; +else + multiplier = 1; + +w2 = 2 * multiplier * (peasycap->width); +w3 = bytesperpixel * \ + multiplier * \ + (peasycap->width); +wz = multiplier * \ + (peasycap->height) * \ + multiplier * \ + (peasycap->width); + +kex = peasycap->field_read; mex = 0; +kad = peasycap->frame_fill; mad = 0; + +pex = peasycap->field_buffer[kex][0].pgo; rex = PAGE_SIZE; +pad = peasycap->frame_buffer[kad][0].pgo; rad = PAGE_SIZE; +if (peasycap->field_buffer[kex][0].kount) + odd = true; +else + odd = false; + +if ((true == odd) && (false == offerfields) &&(false == decimatepixel)) { + JOT(8, " initial skipping %4i bytes p.%4i\n", \ + w3/multiplier, mad); + pad += (w3 / multiplier); rad -= (w3 / multiplier); +} +isuy = true; +mask = 0; rump = 0; caches = 0; + +cz = 0; +while (cz < wz) { + /*-------------------------------------------------------------------*/ + /* + ** PROCESS ONE LINE OF FRAME AT FULL RESOLUTION: + ** READ w2 BYTES FROM FIELD BUFFER, + ** WRITE w3 BYTES TO FRAME BUFFER + **/ + /*-------------------------------------------------------------------*/ + if (false == decimatepixel) { + over = w2; + do { + much = over; more = 0; margin = 0; mask = 0x00; + if (rex < much) + much = rex; + rump = 0; + + if (much % 2) { + SAY("MISTAKE: much is odd\n"); + return -EFAULT; + } + + more = (bytesperpixel * \ + much) / 2; +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + if (1 < bytesperpixel) { + if ((rad * \ + 2) < (much * \ + bytesperpixel)) { + /* + ** INJUDICIOUS ALTERATION OF THIS + ** BLOCK WILL CAUSE BREAKAGE. + ** BEWARE. + **/ + rad2 = rad + bytesperpixel - 1; + much = ((((2 * \ + rad2)/bytesperpixel)/2) * 2); + rump = ((bytesperpixel * \ + much) / 2) - rad; + more = rad; + } + mask = (__u8)rump; + margin = 0; + if (much == rex) { + mask |= 0x04; + if ((mex + 1) < FIELD_BUFFER_SIZE/ \ + PAGE_SIZE) { + margin = *((__u8 *)(peasycap->\ + field_buffer\ + [kex][mex + 1].pgo)); + } else + mask |= 0x08; + } +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + } else { + SAY("MISTAKE: %i=bytesperpixel\n", \ + bytesperpixel); + return -EFAULT; + } +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + if (rump) + caches++; + + rc = redaub(peasycap, pad, pex, much, more, \ + mask, margin, isuy); + if (0 > rc) { + SAY("ERROR: redaub() failed\n"); + return -EFAULT; + } + if (much % 4) { + if (isuy) + isuy = false; + else + isuy = true; + } + over -= much; cz += much; + pex += much; rex -= much; + if (!rex) { + mex++; + pex = peasycap->field_buffer[kex][mex].pgo; + rex = PAGE_SIZE; + } + pad += more; + rad -= more; + if (!rad) { + mad++; + pad = peasycap->frame_buffer[kad][mad].pgo; + rad = PAGE_SIZE; + if (rump) { + pad += rump; + rad -= rump; + } + } + } while (over); +/*---------------------------------------------------------------------------*/ +/* + * SKIP w3 BYTES IN TARGET FRAME BUFFER, + * UNLESS IT IS THE LAST LINE OF AN ODD FRAME + */ +/*---------------------------------------------------------------------------*/ + if (((false == odd) || (cz != wz))&&(false == offerfields)) { + over = w3; + do { + if (!rad) { + mad++; + pad = peasycap->frame_buffer\ + [kad][mad].pgo; + rad = PAGE_SIZE; + } + more = over; + if (rad < more) + more = rad; + over -= more; + pad += more; + rad -= more; + } while (over); + } +/*---------------------------------------------------------------------------*/ +/* + * PROCESS ONE LINE OF FRAME AT REDUCED RESOLUTION: + * ONLY IF false==odd, + * READ w2 BYTES FROM FIELD BUFFER, + * WRITE w3 / 2 BYTES TO FRAME BUFFER + */ +/*---------------------------------------------------------------------------*/ + } else if (false == odd) { + over = w2; + do { + much = over; more = 0; margin = 0; mask = 0x00; + if (rex < much) + much = rex; + rump = 0; + + if (much % 2) { + SAY("MISTAKE: much is odd\n"); + return -EFAULT; + } + + more = (bytesperpixel * \ + much) / 4; +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + if (1 < bytesperpixel) { + if ((rad * 4) < (much * \ + bytesperpixel)) { + /* + ** INJUDICIOUS ALTERATION OF THIS + ** BLOCK WILL CAUSE BREAKAGE. + ** BEWARE. + **/ + rad2 = rad + bytesperpixel - 1; + much = ((((2 * rad2)/bytesperpixel)/2)\ + * 4); + rump = ((bytesperpixel * \ + much) / 4) - rad; + more = rad; + } + mask = (__u8)rump; + margin = 0; + if (much == rex) { + mask |= 0x04; + if ((mex + 1) < FIELD_BUFFER_SIZE/ \ + PAGE_SIZE) { + margin = *((__u8 *)(peasycap->\ + field_buffer\ + [kex][mex + 1].pgo)); + } + else + mask |= 0x08; + } +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + } else { + SAY("MISTAKE: %i=bytesperpixel\n", \ + bytesperpixel); + return -EFAULT; + } +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + if (rump) + caches++; + + rc = redaub(peasycap, pad, pex, much, more, \ + mask, margin, isuy); + if (0 > rc) { + SAY("ERROR: redaub() failed\n"); + return -EFAULT; + } + over -= much; cz += much; + pex += much; rex -= much; + if (!rex) { + mex++; + pex = peasycap->field_buffer[kex][mex].pgo; + rex = PAGE_SIZE; + } + pad += more; + rad -= more; + if (!rad) { + mad++; + pad = peasycap->frame_buffer[kad][mad].pgo; + rad = PAGE_SIZE; + if (rump) { + pad += rump; + rad -= rump; + } + } + } while (over); +/*---------------------------------------------------------------------------*/ +/* + * OTHERWISE JUST + * READ w2 BYTES FROM FIELD BUFFER AND DISCARD THEM + */ +/*---------------------------------------------------------------------------*/ + } else { + over = w2; + do { + if (!rex) { + mex++; + pex = peasycap->field_buffer[kex][mex].pgo; + rex = PAGE_SIZE; + } + much = over; + if (rex < much) + much = rex; + over -= much; + cz += much; + pex += much; + rex -= much; + } while (over); + } +} +/*---------------------------------------------------------------------------*/ +/* + * SANITY CHECKS + */ +/*---------------------------------------------------------------------------*/ +c2 = (mex + 1)*PAGE_SIZE - rex; +if (cz != c2) + SAY("ERROR: discrepancy %i in bytes read\n", c2 - cz); +c3 = (mad + 1)*PAGE_SIZE - rad; + +if (false == decimatepixel) { + if (bytesperpixel * \ + cz != c3) \ + SAY("ERROR: discrepancy %i in bytes written\n", \ + c3 - (bytesperpixel * \ + cz)); +} else { + if (false == odd) { + if (bytesperpixel * \ + cz != (4 * c3)) + SAY("ERROR: discrepancy %i in bytes written\n", \ + (2*c3)-(bytesperpixel * \ + cz)); + } else { + if (0 != c3) + SAY("ERROR: discrepancy %i " \ + "in bytes written\n", c3); + } +} +if (rump) + SAY("ERROR: undischarged cache at end of line in frame buffer\n"); + +JOT(8, "===== field2frame(): %i bytes --> %i bytes (incl skip)\n", c2, c3); +JOT(8, "===== field2frame(): %i=mad %i=rad\n", mad, rad); + +if (true == odd) + JOT(8, "+++++ field2frame(): frame buffer %i is full\n", kad); + +if (peasycap->field_read == peasycap->field_fill) + SAY("WARNING: on exit, filling field buffer %i\n", \ + peasycap->field_read); +/*---------------------------------------------------------------------------*/ +/* + * CALCULATE VIDEO STREAMING RATE + */ +/*---------------------------------------------------------------------------*/ +do_gettimeofday(&timeval); +if (timeval0.tv_sec) { + below = ((long long int)(1000000)) * \ + ((long long int)(timeval.tv_sec - timeval0.tv_sec)) + \ + (long long int)(timeval.tv_usec - timeval0.tv_usec); + above = (long long int)1000000; + + sdr = signed_div(above, below); + above = sdr.quotient; + remainder = (__u32)sdr.remainder; + + JOT(8, "video streaming at %3lli.%03i fields per second\n", above, \ + (remainder/1000)); +} +timeval0 = timeval; + +if (caches) + JOT(8, "%i=caches\n", caches); +return 0; +} +/*****************************************************************************/ +struct signed_div_result +signed_div(long long int above, long long int below) +{ +struct signed_div_result sdr; + +if (((0 <= above) && (0 <= below)) || ((0 > above) && (0 > below))) { + sdr.remainder = (unsigned long long int) do_div(above, below); + sdr.quotient = (long long int) above; +} else { + if (0 > above) + above = -above; + if (0 > below) + below = -below; + sdr.remainder = (unsigned long long int) do_div(above, below); + sdr.quotient = -((long long int) above); +} +return sdr; +} +/*****************************************************************************/ +/*---------------------------------------------------------------------------*/ +/* + * DECIMATION AND COLOURSPACE CONVERSION. + * + * THIS ROUTINE REQUIRES THAT ALL THE DATA TO BE READ RESIDES ON ONE PAGE + * AND THAT ALL THE DATA TO BE WRITTEN RESIDES ON ONE (DIFFERENT) PAGE. + * THE CALLING ROUTINE MUST ENSURE THAT THIS REQUIREMENT IS MET, AND MUST + * ALSO ENSURE THAT much IS EVEN. + * + * much BYTES ARE READ, AT LEAST (bytesperpixel * much)/2 BYTES ARE WRITTEN + * IF THERE IS NO DECIMATION, HALF THIS AMOUNT IF THERE IS DECIMATION. + * + * mask IS ZERO WHEN NO SPECIAL BEHAVIOUR REQUIRED. OTHERWISE IT IS SET THUS: + * 0x03 & mask = number of bytes to be written to cache instead of to + * frame buffer + * 0x04 & mask => use argument margin to set the chrominance for last pixel + * 0x08 & mask => do not set the chrominance for last pixel + * + * YUV to RGB CONVERSION IS (OR SHOULD BE) ITU-R BT 601. + * + * THERE IS A LOT OF CODE REPETITION IN THIS ROUTINE IN ORDER TO AVOID + * INEFFICIENT SWITCHING INSIDE INNER LOOPS. REARRANGING THE LOGIC TO + * REDUCE CODE LENGTH WILL GENERALLY IMPAIR RUNTIME PERFORMANCE. BEWARE. + */ +/*---------------------------------------------------------------------------*/ +int +redaub(struct easycap *peasycap, void *pad, void *pex, int much, int more, \ + __u8 mask, __u8 margin, bool isuy) +{ +static __s32 ay[256], bu[256], rv[256], gu[256], gv[256]; +static __u8 cache[8], *pcache; +__u8 r, g, b, y, u, v, c, *p2, *p3, *pz, *pr; +int bytesperpixel; +bool byteswaporder, decimatepixel, last; +int j, rump; +__s32 s32; + +if (much % 2) { + SAY("MISTAKE: much is odd\n"); + return -EFAULT; +} +bytesperpixel = peasycap->bytesperpixel; +byteswaporder = peasycap->byteswaporder; +decimatepixel = peasycap->decimatepixel; + +/*---------------------------------------------------------------------------*/ +if (!bu[255]) { + for (j = 0; j < 112; j++) { + s32 = (0xFF00 & (453 * j)) >> 8; + bu[j + 128] = s32; bu[127 - j] = -s32; + s32 = (0xFF00 & (359 * j)) >> 8; + rv[j + 128] = s32; rv[127 - j] = -s32; + s32 = (0xFF00 & (88 * j)) >> 8; + gu[j + 128] = s32; gu[127 - j] = -s32; + s32 = (0xFF00 & (183 * j)) >> 8; + gv[j + 128] = s32; gv[127 - j] = -s32; + } + for (j = 0; j < 16; j++) { + bu[j] = bu[16]; rv[j] = rv[16]; + gu[j] = gu[16]; gv[j] = gv[16]; + } + for (j = 240; j < 256; j++) { + bu[j] = bu[239]; rv[j] = rv[239]; + gu[j] = gu[239]; gv[j] = gv[239]; + } + for (j = 16; j < 236; j++) + ay[j] = j; + for (j = 0; j < 16; j++) + ay[j] = ay[16]; + for (j = 236; j < 256; j++) + ay[j] = ay[235]; + JOT(8, "lookup tables are prepared\n"); +} +if ((__u8 *)NULL == pcache) + pcache = &cache[0]; +/*---------------------------------------------------------------------------*/ +/* + * TRANSFER CONTENTS OF CACHE TO THE FRAME BUFFER + */ +/*---------------------------------------------------------------------------*/ +if (!pcache) { + SAY("MISTAKE: pcache is NULL\n"); + return -EFAULT; +} + +if (pcache != &cache[0]) + JOT(16, "cache has %i bytes\n", (int)(pcache - &cache[0])); +p2 = &cache[0]; +p3 = (__u8 *)pad - (int)(pcache - &cache[0]); +while (p2 < pcache) { + *p3++ = *p2; p2++; +} +pcache = &cache[0]; +if (p3 != pad) { + SAY("MISTAKE: pointer misalignment\n"); + return -EFAULT; +} +/*---------------------------------------------------------------------------*/ +rump = (int)(0x03 & mask); +u = 0; v = 0; +p2 = (__u8 *)pex; pz = p2 + much; pr = p3 + more; last = false; +p2++; + +if (true == isuy) + u = *(p2 - 1); +else + v = *(p2 - 1); + +if (rump) + JOT(16, "%4i=much %4i=more %i=rump\n", much, more, rump); + +/*---------------------------------------------------------------------------*/ +switch (bytesperpixel) { +case 2: { + if (false == decimatepixel) { + memcpy(pad, pex, (size_t)much); + if (false == byteswaporder) + /*---------------------------------------------------*/ + /* + ** UYVY + */ + /*---------------------------------------------------*/ + return 0; + else { + /*---------------------------------------------------*/ + /* + ** YUYV + */ + /*---------------------------------------------------*/ + p3 = (__u8 *)pad; pz = p3 + much; + while (pz > p3) { + c = *p3; + *p3 = *(p3 + 1); + *(p3 + 1) = c; + p3 += 2; + } + return 0; + } + } else { + if (false == byteswaporder) { + /*---------------------------------------------------*/ + /* + ** UYVY DECIMATED + */ + /*---------------------------------------------------*/ + p2 = (__u8 *)pex; p3 = (__u8 *)pad; pz = p2 + much; + while (pz > p2) { + *p3 = *p2; + *(p3 + 1) = *(p2 + 1); + *(p3 + 2) = *(p2 + 2); + *(p3 + 3) = *(p2 + 3); + p3 += 4; p2 += 8; + } + return 0; + } else { + /*---------------------------------------------------*/ + /* + ** YUYV DECIMATED + **/ + /*---------------------------------------------------*/ + p2 = (__u8 *)pex; p3 = (__u8 *)pad; pz = p2 + much; + while (pz > p2) { + *p3 = *(p2 + 1); + *(p3 + 1) = *p2; + *(p3 + 2) = *(p2 + 3); + *(p3 + 3) = *(p2 + 2); + p3 += 4; p2 += 8; + } + return 0; + } + } + break; + } +case 3: + { + if (false == decimatepixel) { + if (false == byteswaporder) { + /*---------------------------------------------------*/ + /* + ** RGB + **/ + /*---------------------------------------------------*/ + while (pz > p2) { + if (pr <= (p3 + bytesperpixel)) + last = true; + else + last = false; + y = *p2; + if ((true == last) && (0x0C & mask)) { + if (0x04 & mask) { + if (true == isuy) + v = margin; + else + u = margin; + } else + if (0x08 & mask) + ; + } else { + if (true == isuy) + v = *(p2 + 1); + else + u = *(p2 + 1); + } + + s32 = ay[(int)y] + rv[(int)v]; + r = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + s32 = ay[(int)y] - gu[(int)u] - gv[(int)v]; + g = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + s32 = ay[(int)y] + bu[(int)u]; + b = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + + if ((true == last) && rump) { + pcache = &cache[0]; + switch (bytesperpixel - rump) { + case 1: { + *p3 = r; + *pcache++ = g; + *pcache++ = b; + break; + } + case 2: { + *p3 = r; + *(p3 + 1) = g; + *pcache++ = b; + break; + } + default: { + SAY("MISTAKE: %i=rump\n", \ + bytesperpixel - rump); + return -EFAULT; + } + } + } else { + *p3 = r; + *(p3 + 1) = g; + *(p3 + 2) = b; + } + p2 += 2; + if (true == isuy) + isuy = false; + else + isuy = true; + p3 += bytesperpixel; + } + return 0; + } else { + /*---------------------------------------------------*/ + /* + ** BGR + */ + /*---------------------------------------------------*/ + while (pz > p2) { + if (pr <= (p3 + bytesperpixel)) + last = true; + else + last = false; + y = *p2; + if ((true == last) && (0x0C & mask)) { + if (0x04 & mask) { + if (true == isuy) + v = margin; + else + u = margin; + } + else + if (0x08 & mask) + ; + } else { + if (true == isuy) + v = *(p2 + 1); + else + u = *(p2 + 1); + } + + s32 = ay[(int)y] + rv[(int)v]; + r = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + s32 = ay[(int)y] - gu[(int)u] - gv[(int)v]; + g = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + s32 = ay[(int)y] + bu[(int)u]; + b = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + + if ((true == last) && rump) { + pcache = &cache[0]; + switch (bytesperpixel - rump) { + case 1: { + *p3 = b; + *pcache++ = g; + *pcache++ = r; + break; + } + case 2: { + *p3 = b; + *(p3 + 1) = g; + *pcache++ = r; + break; + } + default: { + SAY("MISTAKE: %i=rump\n", \ + bytesperpixel - rump); + return -EFAULT; + } + } + } else { + *p3 = b; + *(p3 + 1) = g; + *(p3 + 2) = r; + } + p2 += 2; + if (true == isuy) + isuy = false; + else + isuy = true; + p3 += bytesperpixel; + } + } + return 0; + } else { + if (false == byteswaporder) { + /*---------------------------------------------------*/ + /* + ** RGB DECIMATED + */ + /*---------------------------------------------------*/ + while (pz > p2) { + if (pr <= (p3 + bytesperpixel)) + last = true; + else + last = false; + y = *p2; + if ((true == last) && (0x0C & mask)) { + if (0x04 & mask) { + if (true == isuy) + v = margin; + else + u = margin; + } else + if (0x08 & mask) + ; + } else { + if (true == isuy) + v = *(p2 + 1); + else + u = *(p2 + 1); + } + + if (true == isuy) { + s32 = ay[(int)y] + rv[(int)v]; + r = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + s32 = ay[(int)y] - gu[(int)u] - \ + gv[(int)v]; + g = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + s32 = ay[(int)y] + bu[(int)u]; + b = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + + if ((true == last) && rump) { + pcache = &cache[0]; + switch (bytesperpixel - rump) { + case 1: { + *p3 = r; + *pcache++ = g; + *pcache++ = b; + break; + } + case 2: { + *p3 = r; + *(p3 + 1) = g; + *pcache++ = b; + break; + } + default: { + SAY("MISTAKE: " \ + "%i=rump\n", \ + bytesperpixel - rump); + return -EFAULT; + } + } + } else { + *p3 = r; + *(p3 + 1) = g; + *(p3 + 2) = b; + } + isuy = false; + p3 += bytesperpixel; + } else { + isuy = true; + } + p2 += 2; + } + return 0; + } else { + /*---------------------------------------------------*/ + /* + * BGR DECIMATED + */ + /*---------------------------------------------------*/ + while (pz > p2) { + if (pr <= (p3 + bytesperpixel)) + last = true; + else + last = false; + y = *p2; + if ((true == last) && (0x0C & mask)) { + if (0x04 & mask) { + if (true == isuy) + v = margin; + else + u = margin; + } else + if (0x08 & mask) + ; + } else { + if (true == isuy) + v = *(p2 + 1); + else + u = *(p2 + 1); + } + + if (true == isuy) { + + s32 = ay[(int)y] + rv[(int)v]; + r = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + s32 = ay[(int)y] - gu[(int)u] - \ + gv[(int)v]; + g = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + s32 = ay[(int)y] + bu[(int)u]; + b = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + + if ((true == last) && rump) { + pcache = &cache[0]; + switch (bytesperpixel - rump) { + case 1: { + *p3 = b; + *pcache++ = g; + *pcache++ = r; + break; + } + case 2: { + *p3 = b; + *(p3 + 1) = g; + *pcache++ = r; + break; + } + default: { + SAY("MISTAKE: " \ + "%i=rump\n", \ + bytesperpixel - rump); + return -EFAULT; + } + } + } else { + *p3 = b; + *(p3 + 1) = g; + *(p3 + 2) = r; + } + isuy = false; + p3 += bytesperpixel; + } + else + isuy = true; + p2 += 2; + } + return 0; + } + } + break; + } +case 4: + { + if (false == decimatepixel) { + if (false == byteswaporder) { + /*---------------------------------------------------*/ + /* + ** RGBA + */ + /*---------------------------------------------------*/ + while (pz > p2) { + if (pr <= (p3 + bytesperpixel)) + last = true; + else + last = false; + y = *p2; + if ((true == last) && (0x0C & mask)) { + if (0x04 & mask) { + if (true == isuy) + v = margin; + else + u = margin; + } else + if (0x08 & mask) + ; + } else { + if (true == isuy) + v = *(p2 + 1); + else + u = *(p2 + 1); + } + + s32 = ay[(int)y] + rv[(int)v]; + r = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + s32 = ay[(int)y] - gu[(int)u] - gv[(int)v]; + g = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + s32 = ay[(int)y] + bu[(int)u]; + b = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + + if ((true == last) && rump) { + pcache = &cache[0]; + switch (bytesperpixel - rump) { + case 1: { + *p3 = r; + *pcache++ = g; + *pcache++ = b; + *pcache++ = 0; + break; + } + case 2: { + *p3 = r; + *(p3 + 1) = g; + *pcache++ = b; + *pcache++ = 0; + break; + } + case 3: { + *p3 = r; + *(p3 + 1) = g; + *(p3 + 2) = b; + *pcache++ = 0; + break; + } + default: { + SAY("MISTAKE: %i=rump\n", \ + bytesperpixel - rump); + return -EFAULT; + } + } + } else { + *p3 = r; + *(p3 + 1) = g; + *(p3 + 2) = b; + *(p3 + 3) = 0; + } + p2 += 2; + if (true == isuy) + isuy = false; + else + isuy = true; + p3 += bytesperpixel; + } + return 0; + } else { + /*---------------------------------------------------*/ + /* + ** BGRA + */ + /*---------------------------------------------------*/ + while (pz > p2) { + if (pr <= (p3 + bytesperpixel)) + last = true; + else + last = false; + y = *p2; + if ((true == last) && (0x0C & mask)) { + if (0x04 & mask) { + if (true == isuy) + v = margin; + else + u = margin; + } else + if (0x08 & mask) + ; + } else { + if (true == isuy) + v = *(p2 + 1); + else + u = *(p2 + 1); + } + + s32 = ay[(int)y] + rv[(int)v]; + r = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + s32 = ay[(int)y] - gu[(int)u] - gv[(int)v]; + g = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + s32 = ay[(int)y] + bu[(int)u]; + b = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + + if ((true == last) && rump) { + pcache = &cache[0]; + switch (bytesperpixel - rump) { + case 1: { + *p3 = b; + *pcache++ = g; + *pcache++ = r; + *pcache++ = 0; + break; + } + case 2: { + *p3 = b; + *(p3 + 1) = g; + *pcache++ = r; + *pcache++ = 0; + break; + } + case 3: { + *p3 = b; + *(p3 + 1) = g; + *(p3 + 2) = r; + *pcache++ = 0; + break; + } + default: { + SAY("MISTAKE: %i=rump\n", \ + bytesperpixel - rump); + return -EFAULT; + } + } + } else { + *p3 = b; + *(p3 + 1) = g; + *(p3 + 2) = r; + *(p3 + 3) = 0; + } + p2 += 2; + if (true == isuy) + isuy = false; + else + isuy = true; + p3 += bytesperpixel; + } + } + return 0; + } else { + if (false == byteswaporder) { + /*---------------------------------------------------*/ + /* + ** RGBA DECIMATED + */ + /*---------------------------------------------------*/ + while (pz > p2) { + if (pr <= (p3 + bytesperpixel)) + last = true; + else + last = false; + y = *p2; + if ((true == last) && (0x0C & mask)) { + if (0x04 & mask) { + if (true == isuy) + v = margin; + else + u = margin; + } else + if (0x08 & mask) + ; + } else { + if (true == isuy) + v = *(p2 + 1); + else + u = *(p2 + 1); + } + + if (true == isuy) { + + s32 = ay[(int)y] + rv[(int)v]; + r = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + s32 = ay[(int)y] - gu[(int)u] - \ + gv[(int)v]; + g = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + s32 = ay[(int)y] + bu[(int)u]; + b = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + + if ((true == last) && rump) { + pcache = &cache[0]; + switch (bytesperpixel - rump) { + case 1: { + *p3 = r; + *pcache++ = g; + *pcache++ = b; + *pcache++ = 0; + break; + } + case 2: { + *p3 = r; + *(p3 + 1) = g; + *pcache++ = b; + *pcache++ = 0; + break; + } + case 3: { + *p3 = r; + *(p3 + 1) = g; + *(p3 + 2) = b; + *pcache++ = 0; + break; + } + default: { + SAY("MISTAKE: " \ + "%i=rump\n", \ + bytesperpixel - \ + rump); + return -EFAULT; + } + } + } else { + *p3 = r; + *(p3 + 1) = g; + *(p3 + 2) = b; + *(p3 + 3) = 0; + } + isuy = false; + p3 += bytesperpixel; + } else + isuy = true; + p2 += 2; + } + return 0; + } else { + /*---------------------------------------------------*/ + /* + ** BGRA DECIMATED + */ + /*---------------------------------------------------*/ + while (pz > p2) { + if (pr <= (p3 + bytesperpixel)) + last = true; + else + last = false; + y = *p2; + if ((true == last) && (0x0C & mask)) { + if (0x04 & mask) { + if (true == isuy) + v = margin; + else + u = margin; + } else + if (0x08 & mask) + ; + } else { + if (true == isuy) + v = *(p2 + 1); + else + u = *(p2 + 1); + } + + if (true == isuy) { + s32 = ay[(int)y] + rv[(int)v]; + r = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + s32 = ay[(int)y] - gu[(int)u] - \ + gv[(int)v]; + g = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + s32 = ay[(int)y] + bu[(int)u]; + b = (255 < s32) ? 255 : ((0 > s32) ? \ + 0 : (__u8)s32); + + if ((true == last) && rump) { + pcache = &cache[0]; + switch (bytesperpixel - rump) { + case 1: { + *p3 = b; + *pcache++ = g; + *pcache++ = r; + *pcache++ = 0; + break; + } + case 2: { + *p3 = b; + *(p3 + 1) = g; + *pcache++ = r; + *pcache++ = 0; + break; + } + case 3: { + *p3 = b; + *(p3 + 1) = g; + *(p3 + 2) = r; + *pcache++ = 0; + break; + } + default: { + SAY("MISTAKE: " \ + "%i=rump\n", \ + bytesperpixel - rump); + return -EFAULT; + } + } + } else { + *p3 = b; + *(p3 + 1) = g; + *(p3 + 2) = r; + *(p3 + 3) = 0; + } + isuy = false; + p3 += bytesperpixel; + } else + isuy = true; + p2 += 2; + } + return 0; + } + } + break; + } +default: { + SAY("MISTAKE: %i=bytesperpixel\n", bytesperpixel); + return -EFAULT; + } +} +return 0; +} +/*****************************************************************************/ +void +debrief(struct easycap *peasycap) +{ +if ((struct usb_device *)NULL != peasycap->pusb_device) { + check_stk(peasycap->pusb_device); + check_saa(peasycap->pusb_device); + sayreadonly(peasycap); + SAY("%i=peasycap->field_fill\n", peasycap->field_fill); + SAY("%i=peasycap->field_read\n", peasycap->field_read); + SAY("%i=peasycap->frame_fill\n", peasycap->frame_fill); + SAY("%i=peasycap->frame_read\n", peasycap->frame_read); +} +return; +} +/*****************************************************************************/ +void +sayreadonly(struct easycap *peasycap) +{ +static int done; +int got00, got1F, got60, got61, got62; + +if ((!done) && ((struct usb_device *)NULL != peasycap->pusb_device)) { + done = 1; + got00 = read_saa(peasycap->pusb_device, 0x00); + got1F = read_saa(peasycap->pusb_device, 0x1F); + got60 = read_saa(peasycap->pusb_device, 0x60); + got61 = read_saa(peasycap->pusb_device, 0x61); + got62 = read_saa(peasycap->pusb_device, 0x62); + SAY("0x%02X=reg0x00 0x%02X=reg0x1F\n", got00, got1F); + SAY("0x%02X=reg0x60 0x%02X=reg0x61 0x%02X=reg0x62\n", \ + got60, got61, got62); +} +return; +} +/*****************************************************************************/ +/*---------------------------------------------------------------------------*/ +/* + * SEE CORBET ET AL. "LINUX DEVICE DRIVERS", 3rd EDITION, PAGES 430-434 + */ +/*---------------------------------------------------------------------------*/ +int easycap_mmap(struct file *file, struct vm_area_struct *pvma) +{ + +JOT(8, "\n"); + +pvma->vm_ops = &easycap_vm_ops; +pvma->vm_flags |= VM_RESERVED; +if (NULL != file) + pvma->vm_private_data = file->private_data; +easycap_vma_open(pvma); +return 0; +} +/*****************************************************************************/ +void +easycap_vma_open(struct vm_area_struct *pvma) +{ +struct easycap *peasycap; + +peasycap = pvma->vm_private_data; +if (NULL != peasycap) + peasycap->vma_many++; + +JOT(8, "%i=peasycap->vma_many\n", peasycap->vma_many); + +return; +} +/*****************************************************************************/ +void +easycap_vma_close(struct vm_area_struct *pvma) +{ +struct easycap *peasycap; + +peasycap = pvma->vm_private_data; +if (NULL != peasycap) { + peasycap->vma_many--; + JOT(8, "%i=peasycap->vma_many\n", peasycap->vma_many); +} +return; +} +/*****************************************************************************/ +int +easycap_vma_fault(struct vm_area_struct *pvma, struct vm_fault *pvmf) +{ +int k, m, retcode; +void *pbuf; +struct page *page; +struct easycap *peasycap; + +retcode = VM_FAULT_NOPAGE; +pbuf = (void *)NULL; +page = (struct page *)NULL; + +if (NULL == pvma) { + SAY("pvma is NULL\n"); + return retcode; +} +if (NULL == pvmf) { + SAY("pvmf is NULL\n"); + return retcode; +} + +k = (pvmf->pgoff) / (FRAME_BUFFER_SIZE/PAGE_SIZE); +m = (pvmf->pgoff) % (FRAME_BUFFER_SIZE/PAGE_SIZE); + +if (!m) + JOT(4, "%4i=k, %4i=m\n", k, m); +else + JOT(16, "%4i=k, %4i=m\n", k, m); + +if ((0 > k) || (FRAME_BUFFER_MANY <= k)) { + SAY("ERROR: buffer index %i out of range\n", k); + return retcode; +} +if ((0 > m) || (FRAME_BUFFER_SIZE/PAGE_SIZE <= m)) { + SAY("ERROR: page number %i out of range\n", m); + return retcode; +} +peasycap = pvma->vm_private_data; +if (NULL == peasycap) { + SAY("ERROR: peasycap is NULL\n"); + return retcode; +} +mutex_lock(&(peasycap->mutex_mmap_video[0])); +/*---------------------------------------------------------------------------*/ +pbuf = peasycap->frame_buffer[k][m].pgo; +if (NULL == pbuf) { + SAY("ERROR: pbuf is NULL\n"); + goto finish; +} +page = virt_to_page(pbuf); +if (NULL == page) { + SAY("ERROR: page is NULL\n"); + goto finish; +} +get_page(page); +/*---------------------------------------------------------------------------*/ +finish: +mutex_unlock(&(peasycap->mutex_mmap_video[0])); +if (NULL == page) { + SAY("ERROR: page is NULL after get_page(page)\n"); +} else { + pvmf->page = page; + retcode = VM_FAULT_MINOR; +} +return retcode; +} +/*****************************************************************************/ +/*---------------------------------------------------------------------------*/ +/* + * ON COMPLETION OF A VIDEO URB ITS DATA IS COPIED TO THE FIELD BUFFERS + * PROVIDED peasycap->video_idle IS ZER0. REGARDLESS OF THIS BEING TRUE, + * IT IS RESUBMITTED PROVIDED peasycap->video_isoc_streaming IS NOT ZERO. + * + * THIS FUNCTION IS AN INTERRUPT SERVICE ROUTINE AND MUST NOT SLEEP. + * + * INFORMATION ABOUT THE VALIDITY OF THE CONTENTS OF THE FIELD BUFFER ARE + * STORED IN THE TWO-BYTE STATUS PARAMETER + * peasycap->field_buffer[peasycap->field_fill][0].kount + * NOTICE THAT THE INFORMATION IS STORED ONLY WITH PAGE 0 OF THE FIELD BUFFER. + * + * THE LOWER BYTE CONTAINS THE FIELD PARITY BYTE FURNISHED BY THE SAA7113H + * CHIP. + * + * THE UPPER BYTE IS ZERO IF NO PROBLEMS, OTHERWISE: + * 0 != (kount & 0x8000) => AT LEAST ONE URB COMPLETED WITH ERRORS + * 0 != (kount & 0x4000) => BUFFER HAS TOO MUCH DATA + * 0 != (kount & 0x2000) => BUFFER HAS NOT ENOUGH DATA + * 0 != (kount & 0x0400) => FIELD WAS SUBMITTED BY BRIDGER ROUTINE + * 0 != (kount & 0x0200) => FIELD BUFFER NOT YET CHECKED + * 0 != (kount & 0x0100) => BUFFER HAS TWO EXTRA BYTES - WHY? + */ +/*---------------------------------------------------------------------------*/ +void +easycap_complete(struct urb *purb) +{ +static int mt; +struct easycap *peasycap; +struct data_buffer *pfield_buffer; +char errbuf[16]; +int i, more, much, leap, rc, last; +int videofieldamount; +unsigned int override; +int framestatus, framelength, frameactual, frameoffset; +__u8 *pu; +#if defined(BRIDGER) +struct timeval timeval; +long long usec; +#endif /*BRIDGER*/ + +if (NULL == purb) { + SAY("ERROR: easycap_complete(): purb is NULL\n"); + return; +} +peasycap = purb->context; +if (NULL == peasycap) { + SAY("ERROR: easycap_complete(): peasycap is NULL\n"); + return; +} + +if (peasycap->video_eof) + return; + +for (i = 0; i < VIDEO_ISOC_BUFFER_MANY; i++) + if (purb->transfer_buffer == peasycap->video_isoc_buffer[i].pgo) + break; +JOT(16, "%2i=urb\n", i); +last = peasycap->video_isoc_sequence; +if ((((VIDEO_ISOC_BUFFER_MANY - 1) == last) && \ + (0 != i)) || \ + (((VIDEO_ISOC_BUFFER_MANY - 1) != last) && \ + ((last + 1) != i))) { + SAY("ERROR: out-of-order urbs %i,%i ... continuing\n", last, i); +} +peasycap->video_isoc_sequence = i; + +if (peasycap->video_idle) { + JOT(16, "%i=video_idle %i=video_isoc_streaming\n", \ + peasycap->video_idle, peasycap->video_isoc_streaming); + if (peasycap->video_isoc_streaming) { + rc = usb_submit_urb(purb, GFP_ATOMIC); + if (0 != rc) { + SAY("ERROR: while %i=video_idle, " \ + "usb_submit_urb() failed with rc:\n", \ + peasycap->video_idle); + switch (rc) { + case -ENOMEM: { + SAY("ENOMEM\n"); + break; + } + case -ENODEV: { + SAY("ENODEV\n"); + break; + } + case -ENXIO: { + SAY("ENXIO\n"); + break; + } + case -EINVAL: { + SAY("EINVAL\n"); + break; + } + case -EAGAIN: { + SAY("EAGAIN\n"); + break; + } + case -EFBIG: { + SAY("EFBIG\n"); + break; + } + case -EPIPE: { + SAY("EPIPE\n"); + break; + } + case -EMSGSIZE: { + SAY("EMSGSIZE\n"); + break; + } + default: { + SAY("0x%08X\n", rc); + break; + } + } + } + } +return; +} +override = 0; +/*---------------------------------------------------------------------------*/ +if (FIELD_BUFFER_MANY <= peasycap->field_fill) { + SAY("ERROR: bad peasycap->field_fill\n"); + return; +} +if (purb->status) { + if ((-ESHUTDOWN == purb->status) || (-ENOENT == purb->status)) { + JOT(8, "urb status -ESHUTDOWN or -ENOENT\n"); + return; + } + + (peasycap->field_buffer[peasycap->field_fill][0].kount) |= 0x8000 ; + SAY("ERROR: bad urb status:\n"); + switch (purb->status) { + case -EINPROGRESS: { + SAY("-EINPROGRESS\n"); break; + } + case -ENOSR: { + SAY("-ENOSR\n"); break; + } + case -EPIPE: { + SAY("-EPIPE\n"); break; + } + case -EOVERFLOW: { + SAY("-EOVERFLOW\n"); break; + } + case -EPROTO: { + SAY("-EPROTO\n"); break; + } + case -EILSEQ: { + SAY("-EILSEQ\n"); break; + } + case -ETIMEDOUT: { + SAY("-ETIMEDOUT\n"); break; + } + case -EMSGSIZE: { + SAY("-EMSGSIZE\n"); break; + } + case -EOPNOTSUPP: { + SAY("-EOPNOTSUPP\n"); break; + } + case -EPFNOSUPPORT: { + SAY("-EPFNOSUPPORT\n"); break; + } + case -EAFNOSUPPORT: { + SAY("-EAFNOSUPPORT\n"); break; + } + case -EADDRINUSE: { + SAY("-EADDRINUSE\n"); break; + } + case -EADDRNOTAVAIL: { + SAY("-EADDRNOTAVAIL\n"); break; + } + case -ENOBUFS: { + SAY("-ENOBUFS\n"); break; + } + case -EISCONN: { + SAY("-EISCONN\n"); break; + } + case -ENOTCONN: { + SAY("-ENOTCONN\n"); break; + } + case -ESHUTDOWN: { + SAY("-ESHUTDOWN\n"); break; + } + case -ENOENT: { + SAY("-ENOENT\n"); break; + } + case -ECONNRESET: { + SAY("-ECONNRESET\n"); break; + } + default: { + SAY("unknown error code 0x%08X\n", purb->status); break; + } + } +/*---------------------------------------------------------------------------*/ +} else { + for (i = 0; i < purb->number_of_packets; i++) { + if (0 != purb->iso_frame_desc[i].status) { + (peasycap->field_buffer\ + [peasycap->field_fill][0].kount) |= 0x8000 ; + switch (purb->iso_frame_desc[i].status) { + case 0: { + strcpy(&errbuf[0], "OK"); break; + } + case -ENOENT: { + strcpy(&errbuf[0], "-ENOENT"); break; + } + case -EINPROGRESS: { + strcpy(&errbuf[0], "-EINPROGRESS"); break; + } + case -EPROTO: { + strcpy(&errbuf[0], "-EPROTO"); break; + } + case -EILSEQ: { + strcpy(&errbuf[0], "-EILSEQ"); break; + } + case -ETIME: { + strcpy(&errbuf[0], "-ETIME"); break; + } + case -ETIMEDOUT: { + strcpy(&errbuf[0], "-ETIMEDOUT"); break; + } + case -EPIPE: { + strcpy(&errbuf[0], "-EPIPE"); break; + } + case -ECOMM: { + strcpy(&errbuf[0], "-ECOMM"); break; + } + case -ENOSR: { + strcpy(&errbuf[0], "-ENOSR"); break; + } + case -EOVERFLOW: { + strcpy(&errbuf[0], "-EOVERFLOW"); break; + } + case -EREMOTEIO: { + strcpy(&errbuf[0], "-EREMOTEIO"); break; + } + case -ENODEV: { + strcpy(&errbuf[0], "-ENODEV"); break; + } + case -EXDEV: { + strcpy(&errbuf[0], "-EXDEV"); break; + } + case -EINVAL: { + strcpy(&errbuf[0], "-EINVAL"); break; + } + case -ECONNRESET: { + strcpy(&errbuf[0], "-ECONNRESET"); break; + } + case -ESHUTDOWN: { + strcpy(&errbuf[0], "-ESHUTDOWN"); break; + } + default: { + strcpy(&errbuf[0], "unknown error"); break; + } + } + } + framestatus = purb->iso_frame_desc[i].status; + framelength = purb->iso_frame_desc[i].length; + frameactual = purb->iso_frame_desc[i].actual_length; + frameoffset = purb->iso_frame_desc[i].offset; + + JOT(16, "frame[%2i]:" \ + "%4i=status " \ + "%4i=actual " \ + "%4i=length " \ + "%5i=offset\n", \ + i, framestatus, frameactual, framelength, frameoffset); + if (!purb->iso_frame_desc[i].status) { + more = purb->iso_frame_desc[i].actual_length; + pfield_buffer = &peasycap->field_buffer\ + [peasycap->field_fill][peasycap->field_page]; + videofieldamount = (peasycap->field_page * \ + PAGE_SIZE) + \ + (int)(pfield_buffer->pto - pfield_buffer->pgo); + if (4 == more) + mt++; + if (4 < more) { + if (mt) { + JOT(8, "%4i empty video urb frames\n", mt); + mt = 0; + } + if (FIELD_BUFFER_MANY <= peasycap->field_fill) { + SAY("ERROR: bad peasycap->field_fill\n"); + return; + } + if (FIELD_BUFFER_SIZE/PAGE_SIZE <= \ + peasycap->field_page) { + SAY("ERROR: bad peasycap->field_page\n"); + return; + } + pfield_buffer = &peasycap->field_buffer\ + [peasycap->field_fill][peasycap->field_page]; + pu = (__u8 *)(purb->transfer_buffer + \ + purb->iso_frame_desc[i].offset); + if (0x80 & *pu) + leap = 8; + else + leap = 4; +/*--------------------------------------------------------------------------*/ +/* + * EIGHT-BYTE END-OF-VIDEOFIELD MARKER. + * NOTE: A SUCCESSION OF URB FRAMES FOLLOWING THIS ARE EMPTY, + * CORRESPONDING TO THE FIELD FLYBACK (VERTICAL BLANKING) PERIOD. + * + * PROVIDED THE FIELD BUFFER CONTAINS GOOD DATA AS INDICATED BY A ZERO UPPER + * BYTE OF + * peasycap->field_buffer[peasycap->field_fill][0].kount + * THE CONTENTS OF THE FIELD BUFFER ARE OFFERED TO dqbuf(), field_read IS + * UPDATED AND field_fill IS BUMPED. IF THE FIELD BUFFER CONTAINS BAD DATA + * NOTHING IS OFFERED TO dqbuf(). + * + * THE DECISION ON WHETHER THE PARITY OF THE OFFERED FIELD BUFFER IS RIGHT + * RESTS WITH dqbuf(). + */ +/*---------------------------------------------------------------------------*/ + if ((8 == more) || override) { + if (videofieldamount > \ + peasycap->videofieldamount) { + if (2 == videofieldamount - \ + peasycap->\ + videofieldamount) + (peasycap->field_buffer\ + [peasycap->field_fill]\ + [0].kount) |= 0x0100; + else + (peasycap->field_buffer\ + [peasycap->field_fill]\ + [0].kount) |= 0x4000; + } else if (videofieldamount < \ + peasycap->\ + videofieldamount) { + (peasycap->field_buffer\ + [peasycap->field_fill]\ + [0].kount) |= 0x2000; + } + if (!(0xFF00 & peasycap->field_buffer\ + [peasycap->field_fill]\ + [0].kount)) { + (peasycap->video_junk)--; + if (-16 > peasycap->video_junk) + peasycap->video_junk = -16; + peasycap->field_read = \ + (peasycap->\ + field_fill)++; + + if (FIELD_BUFFER_MANY <= \ + peasycap->field_fill) + peasycap->field_fill = 0; + peasycap->field_page = 0; + pfield_buffer = &peasycap->\ + field_buffer\ + [peasycap->field_fill]\ + [peasycap->field_page]; + pfield_buffer->pto = \ + pfield_buffer->pgo; + + JOT(8, "bumped to: %i=peasycap->" \ + "field_fill %i=parity\n", \ + peasycap->field_fill, \ + 0x00FF & pfield_buffer->kount); + JOT(8, "field buffer %i has %i " \ + "bytes fit to be read\n", \ + peasycap->field_read, \ + videofieldamount); + JOT(8, "wakeup call to wq_video, " \ + "%i=field_read %i=field_fill "\ + "%i=parity\n", \ + peasycap->field_read, \ + peasycap->field_fill, \ + 0x00FF & peasycap->\ + field_buffer[peasycap->\ + field_read][0].kount); + wake_up_interruptible(&(peasycap->\ + wq_video)); + do_gettimeofday(&peasycap->timeval7); + } else { + peasycap->video_junk++; + JOT(8, "field buffer %i had %i " \ + "bytes, now discarded\n", \ + peasycap->field_fill, \ + videofieldamount); + + (peasycap->field_fill)++; + + if (FIELD_BUFFER_MANY <= \ + peasycap->field_fill) + peasycap->field_fill = 0; + peasycap->field_page = 0; + pfield_buffer = \ + &peasycap->field_buffer\ + [peasycap->field_fill]\ + [peasycap->field_page]; + pfield_buffer->pto = \ + pfield_buffer->pgo; + + JOT(8, "bumped to: %i=peasycap->" \ + "field_fill %i=parity\n", \ + peasycap->field_fill, \ + 0x00FF & pfield_buffer->kount); + } + if (8 == more) { + JOT(8, "end-of-field: received " \ + "parity byte 0x%02X\n", \ + (0xFF & *pu)); + if (0x40 & *pu) + pfield_buffer->kount = 0x0000; + else + pfield_buffer->kount = 0x0001; + JOT(8, "end-of-field: 0x%02X=kount\n",\ + 0xFF & pfield_buffer->kount); + } + } +/*---------------------------------------------------------------------------*/ +/* + * COPY more BYTES FROM ISOC BUFFER TO FIELD BUFFER + */ +/*---------------------------------------------------------------------------*/ + pu += leap; + more -= leap; + + if (FIELD_BUFFER_MANY <= peasycap->field_fill) { + SAY("ERROR: bad peasycap->field_fill\n"); + return; + } + if (FIELD_BUFFER_SIZE/PAGE_SIZE <= \ + peasycap->field_page) { + SAY("ERROR: bad peasycap->field_page\n"); + return; + } + pfield_buffer = &peasycap->field_buffer\ + [peasycap->field_fill][peasycap->field_page]; + while (more) { + pfield_buffer = &peasycap->field_buffer\ + [peasycap->field_fill]\ + [peasycap->field_page]; + if (PAGE_SIZE < (pfield_buffer->pto - \ + pfield_buffer->pgo)) { + SAY("ERROR: bad pfield_buffer->pto\n"); + return; + } + if (PAGE_SIZE == (pfield_buffer->pto - \ + pfield_buffer->pgo)) { + (peasycap->field_page)++; + if (FIELD_BUFFER_SIZE/PAGE_SIZE <= \ + peasycap->field_page) { + JOT(16, "wrapping peasycap->" \ + "field_page\n"); + peasycap->field_page = 0; + } + pfield_buffer = &peasycap->\ + field_buffer\ + [peasycap->field_fill]\ + [peasycap->field_page]; + pfield_buffer->pto = \ + pfield_buffer->pgo; + } + + much = PAGE_SIZE - (int)(pfield_buffer->pto - \ + pfield_buffer->pgo); + + if (much > more) + much = more; + memcpy(pfield_buffer->pto, pu, much); + pu += much; + (pfield_buffer->pto) += much; + more -= much; + } + } + } + } +} +/*---------------------------------------------------------------------------*/ +/* + * + * + * *** UNDER DEVELOPMENT/TESTING - NOT READY YET! *** + * + * + * + * VIDEOTAPES MAY HAVE BEEN MANUALLY PAUSED AND RESTARTED DURING RECORDING. + * THIS CAUSES LOSS OF SYNC, CONFUSING DOWNSTREAM USERSPACE PROGRAMS WHICH + * MAY INTERPRET THE INTERRUPTION AS A SYMPTOM OF LATENCY. TO OVERCOME THIS + * THE DRIVER BRIDGES THE HIATUS BY SENDING DUMMY VIDEO FRAMES AT ROUGHLY + * THE RIGHT TIME INTERVALS IN THE HOPE OF PERSUADING THE DOWNSTREAM USERSPACE + * PROGRAM TO RESUME NORMAL SERVICE WHEN THE INTERRUPTION IS OVER. + */ +/*---------------------------------------------------------------------------*/ +#if defined(BRIDGER) +do_gettimeofday(&timeval); +if (peasycap->timeval7.tv_sec) { + usec = 1000000*(timeval.tv_sec - peasycap->timeval7.tv_sec) + \ + (timeval.tv_usec - peasycap->timeval7.tv_usec); + if (usec > (peasycap->usec + peasycap->tolerate)) { + JOT(8, "bridging hiatus\n"); + peasycap->video_junk = 0; + peasycap->field_buffer[peasycap->field_fill][0].kount |= 0x0400; + + peasycap->field_read = (peasycap->field_fill)++; + + if (FIELD_BUFFER_MANY <= peasycap->field_fill) \ + peasycap->field_fill = 0; + peasycap->field_page = 0; + pfield_buffer = &peasycap->field_buffer\ + [peasycap->field_fill][peasycap->field_page]; + pfield_buffer->pto = pfield_buffer->pgo; + + JOT(8, "bumped to: %i=peasycap->field_fill %i=parity\n", \ + peasycap->field_fill, 0x00FF & pfield_buffer->kount); + JOT(8, "field buffer %i has %i bytes to be overwritten\n", \ + peasycap->field_read, videofieldamount); + JOT(8, "wakeup call to wq_video, " \ + "%i=field_read %i=field_fill %i=parity\n", \ + peasycap->field_read, peasycap->field_fill, \ + 0x00FF & \ + peasycap->field_buffer[peasycap->field_read][0].kount); + wake_up_interruptible(&(peasycap->wq_video)); + do_gettimeofday(&peasycap->timeval7); + } +} +#endif /*BRIDGER*/ +/*---------------------------------------------------------------------------*/ +/* + * RESUBMIT THIS URB, UNLESS A SEVERE PERSISTENT ERROR CONDITION EXISTS. + * + * IF THE WAIT QUEUES ARE NOT CLEARED IN RESPONSE TO AN ERROR CONDITION + * THE USERSPACE PROGRAM, E.G. mplayer, MAY HANG ON EXIT. BEWARE. + */ +/*---------------------------------------------------------------------------*/ +if (VIDEO_ISOC_BUFFER_MANY <= peasycap->video_junk) { + SAY("easycap driver shutting down on condition green\n"); + peasycap->video_eof = 1; + peasycap->audio_eof = 1; + peasycap->video_junk = -VIDEO_ISOC_BUFFER_MANY; + wake_up_interruptible(&(peasycap->wq_video)); + wake_up_interruptible(&(peasycap->wq_audio)); + return; +} +if (peasycap->video_isoc_streaming) { + rc = usb_submit_urb(purb, GFP_ATOMIC); + if (0 != rc) { + SAY("ERROR: while %i=video_idle, usb_submit_urb() failed " \ + "with rc:\n", peasycap->video_idle); + switch (rc) { + case -ENOMEM: { + SAY("ENOMEM\n"); break; + } + case -ENODEV: { + SAY("ENODEV\n"); break; + } + case -ENXIO: { + SAY("ENXIO\n"); break; + } + case -EINVAL: { + SAY("EINVAL\n"); break; + } + case -EAGAIN: { + SAY("EAGAIN\n"); break; + } + case -EFBIG: { + SAY("EFBIG\n"); break; + } + case -EPIPE: { + SAY("EPIPE\n"); break; + } + case -EMSGSIZE: { + SAY("EMSGSIZE\n"); break; + } + default: { + SAY("0x%08X\n", rc); break; + } + } + } +} +return; +} +/*****************************************************************************/ +/*---------------------------------------------------------------------------*/ +/* + * + * FIXME + * + * + * THIS FUNCTION ASSUMES THAT, ON EACH AND EVERY OCCASION THAT THE DEVICE IS + * PHYSICALLY PLUGGED IN, INTERFACE 0 IS PROBED FIRST. + * IF THIS IS NOT TRUE, THERE IS THE POSSIBILITY OF AN Oops. + * + * THIS HAS NEVER BEEN A PROBLEM IN PRACTICE, BUT SOMETHING SEEMS WRONG HERE. + */ +/*---------------------------------------------------------------------------*/ +int +easycap_usb_probe(struct usb_interface *pusb_interface, \ + const struct usb_device_id *id) +{ +struct usb_device *pusb_device, *pusb_device1; +struct usb_host_interface *pusb_host_interface; +struct usb_endpoint_descriptor *pepd; +struct usb_interface_descriptor *pusb_interface_descriptor; +struct usb_interface_assoc_descriptor *pusb_interface_assoc_descriptor; +struct urb *purb; +static struct easycap *peasycap /*=NULL*/; +struct data_urb *pdata_urb; +size_t wMaxPacketSize; +int ISOCwMaxPacketSize; +int BULKwMaxPacketSize; +int INTwMaxPacketSize; +int CTRLwMaxPacketSize; +__u8 bEndpointAddress; +__u8 ISOCbEndpointAddress; +__u8 INTbEndpointAddress; +int isin, i, j, k, m; +__u8 bInterfaceNumber; +__u8 bInterfaceClass; +__u8 bInterfaceSubClass; +void *pbuf; +int okalt[8], isokalt; +int okepn[8], isokepn; +int okmps[8], isokmps; +int maxpacketsize; +int rc; + +JOT(4, "\n"); + +if ((struct usb_interface *)NULL == pusb_interface) { + SAY("ERROR: pusb_interface is NULL\n"); + return -EFAULT; +} +/*---------------------------------------------------------------------------*/ +/* + * GET POINTER TO STRUCTURE usb_device + */ +/*---------------------------------------------------------------------------*/ +pusb_device1 = container_of(pusb_interface->dev.parent, \ + struct usb_device, dev); +if ((struct usb_device *)NULL == pusb_device1) { + SAY("ERROR: pusb_device1 is NULL\n"); + return -EFAULT; +} +pusb_device = usb_get_dev(pusb_device1); +if ((struct usb_device *)NULL == pusb_device) { + SAY("ERROR: pusb_device is NULL\n"); + return -EFAULT; +} +if ((unsigned long int)pusb_device1 != (unsigned long int)pusb_device) { + JOT(4, "ERROR: pusb_device1 != pusb_device\n"); + return -EFAULT; +} + +JOT(4, "bNumConfigurations=%i\n", pusb_device->descriptor.bNumConfigurations); + +/*---------------------------------------------------------------------------*/ +pusb_host_interface = pusb_interface->cur_altsetting; +if (NULL == pusb_host_interface) { + SAY("ERROR: pusb_host_interface is NULL\n"); + return -EFAULT; +} +pusb_interface_descriptor = &(pusb_host_interface->desc); +if (NULL == pusb_interface_descriptor) { + SAY("ERROR: pusb_interface_descriptor is NULL\n"); + return -EFAULT; +} +/*---------------------------------------------------------------------------*/ +/* + * GET PROPERTIES OF PROBED INTERFACE + */ +/*---------------------------------------------------------------------------*/ +bInterfaceNumber = pusb_interface_descriptor->bInterfaceNumber; +bInterfaceClass = pusb_interface_descriptor->bInterfaceClass; +bInterfaceSubClass = pusb_interface_descriptor->bInterfaceSubClass; + +JOT(4, "intf[%i]: pusb_interface->num_altsetting=%i\n", \ + bInterfaceNumber, pusb_interface->num_altsetting); +JOT(4, "intf[%i]: pusb_interface->cur_altsetting - " \ + "pusb_interface->altsetting=%li\n", bInterfaceNumber, \ + (long int)(pusb_interface->cur_altsetting - \ + pusb_interface->altsetting)); +switch (bInterfaceClass) { +case USB_CLASS_AUDIO: { + JOT(4, "intf[%i]: bInterfaceClass=0x%02X=USB_CLASS_AUDIO\n", \ + bInterfaceNumber, bInterfaceClass); break; + } +case USB_CLASS_VIDEO: { + JOT(4, "intf[%i]: bInterfaceClass=0x%02X=USB_CLASS_VIDEO\n", \ + bInterfaceNumber, bInterfaceClass); break; + } +case USB_CLASS_VENDOR_SPEC: { + JOT(4, "intf[%i]: bInterfaceClass=0x%02X=USB_CLASS_VENDOR_SPEC\n", \ + bInterfaceNumber, bInterfaceClass); break; + } +default: + break; +} +switch (bInterfaceSubClass) { +case 0x01: { + JOT(4, "intf[%i]: bInterfaceSubClass=0x%02X=AUDIOCONTROL\n", \ + bInterfaceNumber, bInterfaceSubClass); break; +} +case 0x02: { + JOT(4, "intf[%i]: bInterfaceSubClass=0x%02X=AUDIOSTREAMING\n", \ + bInterfaceNumber, bInterfaceSubClass); break; +} +case 0x03: { + JOT(4, "intf[%i]: bInterfaceSubClass=0x%02X=MIDISTREAMING\n", \ + bInterfaceNumber, bInterfaceSubClass); break; +} +default: + break; +} +/*---------------------------------------------------------------------------*/ +pusb_interface_assoc_descriptor = pusb_interface->intf_assoc; +if (NULL != pusb_interface_assoc_descriptor) { + JOT(4, "intf[%i]: bFirstInterface=0x%02X bInterfaceCount=0x%02X\n", \ + bInterfaceNumber, \ + pusb_interface_assoc_descriptor->bFirstInterface, \ + pusb_interface_assoc_descriptor->bInterfaceCount); +} else { +JOT(4, "intf[%i]: pusb_interface_assoc_descriptor is NULL\n", \ + bInterfaceNumber); +} +/*---------------------------------------------------------------------------*/ +/* + * A NEW struct easycap IS ALWAYS ALLOCATED WHEN INTERFACE 0 IS PROBED. + * IT IS NOT POSSIBLE HERE TO FREE ANY EXISTING struct easycap. THIS + * SHOULD HAVE BEEN DONE BY easycap_delete() WHEN THE DEVICE WAS PHYSICALLY + * UNPLUGGED. + */ +/*---------------------------------------------------------------------------*/ +if (0 == bInterfaceNumber) { + peasycap = kzalloc(sizeof(struct easycap), GFP_KERNEL); + if (NULL == peasycap) { + SAY("ERROR: Could not allocate peasycap\n"); + return -ENOMEM; + } else { + peasycap->allocation_video_struct = sizeof(struct easycap); + peasycap->allocation_video_page = 0; + peasycap->allocation_video_urb = 0; + peasycap->allocation_audio_struct = 0; + peasycap->allocation_audio_page = 0; + peasycap->allocation_audio_urb = 0; + } +/*---------------------------------------------------------------------------*/ +/* + * INITIALIZE THE NEW easycap STRUCTURE. + * NO PARAMETERS ARE SPECIFIED HERE REQUIRING THE SETTING OF REGISTERS. + * THAT IS DONE FIRST BY easycap_open() AND LATER BY easycap_ioctl(). + */ +/*---------------------------------------------------------------------------*/ + peasycap->pusb_device = pusb_device; + peasycap->pusb_interface = pusb_interface; + + kref_init(&peasycap->kref); + JOT(8, "intf[%i]: after kref_init(..._video) " \ + "%i=peasycap->kref.refcount.counter\n", \ + bInterfaceNumber, peasycap->kref.refcount.counter); + + init_waitqueue_head(&(peasycap->wq_video)); + init_waitqueue_head(&(peasycap->wq_audio)); + + mutex_init(&(peasycap->mutex_timeval0)); + mutex_init(&(peasycap->mutex_timeval1)); + + for (k = 0; k < FRAME_BUFFER_MANY; k++) + mutex_init(&(peasycap->mutex_mmap_video[k])); + + peasycap->ilk = 0; + peasycap->microphone = false; + + peasycap->video_interface = -1; + peasycap->video_altsetting_on = -1; + peasycap->video_altsetting_off = -1; + peasycap->video_endpointnumber = -1; + peasycap->video_isoc_maxframesize = -1; + peasycap->video_isoc_buffer_size = -1; + + peasycap->audio_interface = -1; + peasycap->audio_altsetting_on = -1; + peasycap->audio_altsetting_off = -1; + peasycap->audio_endpointnumber = -1; + peasycap->audio_isoc_maxframesize = -1; + peasycap->audio_isoc_buffer_size = -1; + + peasycap->frame_buffer_many = FRAME_BUFFER_MANY; + + if ((struct mutex *)NULL == &(peasycap->mutex_mmap_video[0])) { + SAY("ERROR: &(peasycap->mutex_mmap_video[%i]) is NULL\n", 0); + return -EFAULT; + } +/*---------------------------------------------------------------------------*/ +/* + * DYNAMICALLY FILL IN THE AVAILABLE FORMATS. + */ +/*---------------------------------------------------------------------------*/ + rc = fillin_formats(); + if (0 > rc) { + SAY("ERROR: fillin_formats() returned %i\n", rc); + return -EFAULT; + } + JOT(4, "%i formats available\n", rc); + } else { +/*---------------------------------------------------------------------------*/ + if ((struct easycap *)NULL == peasycap) { + SAY("ERROR: peasycap is NULL " \ + "when probing interface %i\n", \ + bInterfaceNumber); + return -EFAULT; + } + + JOT(8, "kref_get() with %i=peasycap->kref.refcount.counter\n", \ + (int)peasycap->kref.refcount.counter); + kref_get(&peasycap->kref); +} +/*---------------------------------------------------------------------------*/ +if ((USB_CLASS_VIDEO == bInterfaceClass) || \ + (USB_CLASS_VENDOR_SPEC == bInterfaceClass)) { + if (-1 == peasycap->video_interface) { + peasycap->video_interface = bInterfaceNumber; + JOT(4, "setting peasycap->video_interface=%i\n", \ + peasycap->video_interface); + } else { + if (peasycap->video_interface != bInterfaceNumber) { + SAY("ERROR: attempting to reset " \ + "peasycap->video_interface\n"); + SAY("...... continuing with " \ + "%i=peasycap->video_interface\n", \ + peasycap->video_interface); + } + } +} else if ((USB_CLASS_AUDIO == bInterfaceClass) && \ + (0x02 == bInterfaceSubClass)) { + if (-1 == peasycap->audio_interface) { + peasycap->audio_interface = bInterfaceNumber; + JOT(4, "setting peasycap->audio_interface=%i\n", \ + peasycap->audio_interface); + } else { + if (peasycap->audio_interface != bInterfaceNumber) { + SAY("ERROR: attempting to reset " \ + "peasycap->audio_interface\n"); + SAY("...... continuing with " \ + "%i=peasycap->audio_interface\n", \ + peasycap->audio_interface); + } + } +} +/*---------------------------------------------------------------------------*/ +/* + * INVESTIGATE ALL ALTSETTINGS. + * DONE IN DETAIL BECAUSE USB DEVICE 05e1:0408 HAS DISPARATE INCARNATIONS. + */ +/*---------------------------------------------------------------------------*/ +isokalt = 0; +isokepn = 0; +isokmps = 0; + +for (i = 0; i < pusb_interface->num_altsetting; i++) { + pusb_host_interface = &(pusb_interface->altsetting[i]); + if ((struct usb_host_interface *)NULL == pusb_host_interface) { + SAY("ERROR: pusb_host_interface is NULL\n"); + return -EFAULT; + } + pusb_interface_descriptor = &(pusb_host_interface->desc); + if ((struct usb_interface_descriptor *)NULL == \ + pusb_interface_descriptor) { + SAY("ERROR: pusb_interface_descriptor is NULL\n"); + return -EFAULT; + } + + JOT(4, "intf[%i]alt[%i]: desc.bDescriptorType=0x%02X\n", \ + bInterfaceNumber, i, pusb_interface_descriptor->bDescriptorType); + JOT(4, "intf[%i]alt[%i]: desc.bInterfaceNumber=0x%02X\n", \ + bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceNumber); + JOT(4, "intf[%i]alt[%i]: desc.bAlternateSetting=0x%02X\n", \ + bInterfaceNumber, i, pusb_interface_descriptor->bAlternateSetting); + JOT(4, "intf[%i]alt[%i]: desc.bNumEndpoints=0x%02X\n", \ + bInterfaceNumber, i, pusb_interface_descriptor->bNumEndpoints); + JOT(4, "intf[%i]alt[%i]: desc.bInterfaceClass=0x%02X\n", \ + bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceClass); + JOT(4, "intf[%i]alt[%i]: desc.bInterfaceSubClass=0x%02X\n", \ + bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceSubClass); + JOT(4, "intf[%i]alt[%i]: desc.bInterfaceProtocol=0x%02X\n", \ + bInterfaceNumber, i, pusb_interface_descriptor->bInterfaceProtocol); + JOT(4, "intf[%i]alt[%i]: desc.iInterface=0x%02X\n", \ + bInterfaceNumber, i, pusb_interface_descriptor->iInterface); + + ISOCwMaxPacketSize = -1; + BULKwMaxPacketSize = -1; + INTwMaxPacketSize = -1; + CTRLwMaxPacketSize = -1; + ISOCbEndpointAddress = 0; + INTbEndpointAddress = 0; + + if (0 == pusb_interface_descriptor->bNumEndpoints) + JOT(4, "intf[%i]alt[%i] has no endpoints\n", \ + bInterfaceNumber, i); +/*---------------------------------------------------------------------------*/ + for (j = 0; j < pusb_interface_descriptor->bNumEndpoints; j++) { + pepd = &(pusb_host_interface->endpoint[j].desc); + if ((struct usb_endpoint_descriptor *)NULL == pepd) { + SAY("ERROR: pepd is NULL.\n"); + SAY("...... skipping\n"); + continue; + } + wMaxPacketSize = le16_to_cpu(pepd->wMaxPacketSize); + bEndpointAddress = pepd->bEndpointAddress; + + JOT(4, "intf[%i]alt[%i]end[%i]: bEndpointAddress=0x%X\n", \ + bInterfaceNumber, i, j, \ + pepd->bEndpointAddress); + JOT(4, "intf[%i]alt[%i]end[%i]: bmAttributes=0x%X\n", \ + bInterfaceNumber, i, j, \ + pepd->bmAttributes); + JOT(4, "intf[%i]alt[%i]end[%i]: wMaxPacketSize=%i\n", \ + bInterfaceNumber, i, j, \ + pepd->wMaxPacketSize); + JOT(4, "intf[%i]alt[%i]end[%i]: bInterval=%i\n", + bInterfaceNumber, i, j, \ + pepd->bInterval); + + if (pepd->bEndpointAddress & USB_DIR_IN) { + JOT(4, "intf[%i]alt[%i]end[%i] is an IN endpoint\n",\ + bInterfaceNumber, i, j); + isin = 1; + } else { + JOT(4, "intf[%i]alt[%i]end[%i] is an OUT endpoint\n",\ + bInterfaceNumber, i, j); + SAY("ERROR: OUT endpoint unexpected\n"); + SAY("...... continuing\n"); + isin = 0; + } + if ((pepd->bmAttributes & \ + USB_ENDPOINT_XFERTYPE_MASK) == \ + USB_ENDPOINT_XFER_ISOC) { + JOT(4, "intf[%i]alt[%i]end[%i] is an ISOC endpoint\n",\ + bInterfaceNumber, i, j); + if (isin) { + switch (bInterfaceClass) { + case USB_CLASS_VIDEO: + case USB_CLASS_VENDOR_SPEC: { + if (!peasycap) { + SAY("MISTAKE: " \ + "peasycap is NULL\n"); + return -EFAULT; + } + if (pepd->wMaxPacketSize) { + if (8 > isokalt) { + okalt[isokalt] = i; + JOT(4,\ + "%i=okalt[%i]\n", \ + okalt[isokalt], \ + isokalt); + isokalt++; + } + if (8 > isokepn) { + okepn[isokepn] = \ + pepd->\ + bEndpointAddress & \ + 0x0F; + JOT(4,\ + "%i=okepn[%i]\n", \ + okepn[isokepn], \ + isokepn); + isokepn++; + } + if (8 > isokmps) { + okmps[isokmps] = \ + le16_to_cpu(pepd->\ + wMaxPacketSize); + JOT(4,\ + "%i=okmps[%i]\n", \ + okmps[isokmps], \ + isokmps); + isokmps++; + } + } else { + if (-1 == peasycap->\ + video_altsetting_off) { + peasycap->\ + video_altsetting_off =\ + i; + JOT(4, "%i=video_" \ + "altsetting_off " \ + "<====\n", \ + peasycap->\ + video_altsetting_off); + } else { + SAY("ERROR: peasycap" \ + "->video_altsetting_" \ + "off already set\n"); + SAY("...... " \ + "continuing with " \ + "%i=peasycap->video_" \ + "altsetting_off\n", \ + peasycap->\ + video_altsetting_off); + } + } + break; + } + case USB_CLASS_AUDIO: { + if (0x02 != bInterfaceSubClass) + break; + if (!peasycap) { + SAY("MISTAKE: " \ + "peasycap is NULL\n"); + return -EFAULT; + } + if (pepd->wMaxPacketSize) { + if (8 > isokalt) { + okalt[isokalt] = i ; + JOT(4,\ + "%i=okalt[%i]\n", \ + okalt[isokalt], \ + isokalt); + isokalt++; + } + if (8 > isokepn) { + okepn[isokepn] = \ + pepd->\ + bEndpointAddress & \ + 0x0F; + JOT(4,\ + "%i=okepn[%i]\n", \ + okepn[isokepn], \ + isokepn); + isokepn++; + } + if (8 > isokmps) { + okmps[isokmps] = \ + le16_to_cpu(pepd->\ + wMaxPacketSize); + JOT(4,\ + "%i=okmps[%i]\n",\ + okmps[isokmps], \ + isokmps); + isokmps++; + } + } else { + if (-1 == peasycap->\ + audio_altsetting_off) { + peasycap->\ + audio_altsetting_off =\ + i; + JOT(4, "%i=audio_" \ + "altsetting_off " \ + "<====\n", \ + peasycap->\ + audio_altsetting_off); + } else { + SAY("ERROR: peasycap" \ + "->audio_altsetting_" \ + "off already set\n"); + SAY("...... " \ + "continuing with " \ + "%i=peasycap->\ + audio_altsetting_" \ + "off\n", + peasycap->\ + audio_altsetting_off); + } + } + break; + } + default: + break; + } + } + } else if ((pepd->bmAttributes & \ + USB_ENDPOINT_XFERTYPE_MASK) ==\ + USB_ENDPOINT_XFER_BULK) { + JOT(4, "intf[%i]alt[%i]end[%i] is a BULK endpoint\n",\ + bInterfaceNumber, i, j); + } else if ((pepd->bmAttributes & \ + USB_ENDPOINT_XFERTYPE_MASK) ==\ + USB_ENDPOINT_XFER_INT) { + JOT(4, "intf[%i]alt[%i]end[%i] is an INT endpoint\n",\ + bInterfaceNumber, i, j); + } else { + JOT(4, "intf[%i]alt[%i]end[%i] is a CTRL endpoint\n",\ + bInterfaceNumber, i, j); + } + if (0 == pepd->wMaxPacketSize) { + JOT(4, "intf[%i]alt[%i]end[%i] " \ + "has zero packet size\n", \ + bInterfaceNumber, i, j); + } + } +} +/*---------------------------------------------------------------------------*/ +/* + * PERFORM INITIALIZATION OF THE PROBED INTERFACE + */ +/*---------------------------------------------------------------------------*/ +JOT(4, "initialization begins for interface %i\n", \ + pusb_interface_descriptor->bInterfaceNumber); +switch (bInterfaceNumber) { +/*---------------------------------------------------------------------------*/ +/* + * INTERFACE 0 IS THE VIDEO INTERFACE + */ +/*---------------------------------------------------------------------------*/ +case 0: { + if (!peasycap) { + SAY("MISTAKE: peasycap is NULL\n"); + return -EFAULT; + } + if (!isokalt) { + SAY("ERROR: no viable video_altsetting_on\n"); + return -ENOENT; + } else { + peasycap->video_altsetting_on = okalt[isokalt - 1]; + JOT(4, "%i=video_altsetting_on <====\n", \ + peasycap->video_altsetting_on); + } + if (!isokepn) { + SAY("ERROR: no viable video_endpointnumber\n"); + return -ENOENT; + } else { + peasycap->video_endpointnumber = okepn[isokepn - 1]; + JOT(4, "%i=video_endpointnumber\n", \ + peasycap->video_endpointnumber); + } + if (!isokmps) { + SAY("ERROR: no viable video_maxpacketsize\n"); + return -ENOENT; +/*---------------------------------------------------------------------------*/ +/* + * DECIDE THE VIDEO STREAMING PARAMETERS + */ +/*---------------------------------------------------------------------------*/ + } else { + maxpacketsize = okmps[isokmps - 1] - 1024; + if (USB_2_0_MAXPACKETSIZE > maxpacketsize) { + peasycap->video_isoc_maxframesize = maxpacketsize; + } else { + peasycap->video_isoc_maxframesize = \ + USB_2_0_MAXPACKETSIZE; + } + JOT(4, "%i=video_isoc_maxframesize\n", \ + peasycap->video_isoc_maxframesize); + if (0 >= peasycap->video_isoc_maxframesize) { + SAY("ERROR: bad video_isoc_maxframesize\n"); + return -ENOENT; + } + peasycap->video_isoc_framesperdesc = VIDEO_ISOC_FRAMESPERDESC; + JOT(4, "%i=video_isoc_framesperdesc\n", \ + peasycap->video_isoc_framesperdesc); + if (0 >= peasycap->video_isoc_framesperdesc) { + SAY("ERROR: bad video_isoc_framesperdesc\n"); + return -ENOENT; + } + peasycap->video_isoc_buffer_size = \ + peasycap->video_isoc_maxframesize * \ + peasycap->video_isoc_framesperdesc; + JOT(4, "%i=video_isoc_buffer_size\n", \ + peasycap->video_isoc_buffer_size); + if ((PAGE_SIZE << VIDEO_ISOC_ORDER) < \ + peasycap->video_isoc_buffer_size) { + SAY("MISTAKE: " \ + "peasycap->video_isoc_buffer_size too big\n"); + return -EFAULT; + } + } +/*---------------------------------------------------------------------------*/ + if (-1 == peasycap->video_interface) { + SAY("MISTAKE: video_interface is unset\n"); + return -EFAULT; + } + if (-1 == peasycap->video_altsetting_on) { + SAY("MISTAKE: video_altsetting_on is unset\n"); + return -EFAULT; + } + if (-1 == peasycap->video_altsetting_off) { + SAY("MISTAKE: video_interface_off is unset\n"); + return -EFAULT; + } + if (-1 == peasycap->video_endpointnumber) { + SAY("MISTAKE: video_endpointnumber is unset\n"); + return -EFAULT; + } + if (-1 == peasycap->video_isoc_maxframesize) { + SAY("MISTAKE: video_isoc_maxframesize is unset\n"); + return -EFAULT; + } + if (-1 == peasycap->video_isoc_buffer_size) { + SAY("MISTAKE: video_isoc_buffer_size is unset\n"); + return -EFAULT; + } +/*---------------------------------------------------------------------------*/ +/* + * ALLOCATE MEMORY FOR VIDEO BUFFERS. LISTS MUST BE INITIALIZED FIRST. + */ +/*---------------------------------------------------------------------------*/ + INIT_LIST_HEAD(&(peasycap->urb_video_head)); + peasycap->purb_video_head = &(peasycap->urb_video_head); +/*---------------------------------------------------------------------------*/ + JOT(4, "allocating %i frame buffers of size %li\n", \ + FRAME_BUFFER_MANY, (long int)FRAME_BUFFER_SIZE); + JOT(4, ".... each scattered over %li pages\n", \ + FRAME_BUFFER_SIZE/PAGE_SIZE); + + for (k = 0; k < FRAME_BUFFER_MANY; k++) { + for (m = 0; m < FRAME_BUFFER_SIZE/PAGE_SIZE; m++) { + if ((void *)NULL != peasycap->frame_buffer[k][m].pgo) + SAY("attempting to reallocate frame " \ + " buffers\n"); + else { + pbuf = (void *)__get_free_page(GFP_KERNEL); + if ((void *)NULL == pbuf) { + SAY("ERROR: Could not allocate frame "\ + "buffer %i page %i\n", k, m); + return -ENOMEM; + } else + peasycap->allocation_video_page += 1; + peasycap->frame_buffer[k][m].pgo = pbuf; + } + peasycap->frame_buffer[k][m].pto = \ + peasycap->frame_buffer[k][m].pgo; + } + } + + peasycap->frame_fill = 0; + peasycap->frame_read = 0; + JOT(4, "allocation of frame buffers done: %i pages\n", k * \ + m); +/*---------------------------------------------------------------------------*/ + JOT(4, "allocating %i field buffers of size %li\n", \ + FIELD_BUFFER_MANY, (long int)FIELD_BUFFER_SIZE); + JOT(4, ".... each scattered over %li pages\n", \ + FIELD_BUFFER_SIZE/PAGE_SIZE); + + for (k = 0; k < FIELD_BUFFER_MANY; k++) { + for (m = 0; m < FIELD_BUFFER_SIZE/PAGE_SIZE; m++) { + if ((void *)NULL != peasycap->field_buffer[k][m].pgo) { + SAY("ERROR: attempting to reallocate " \ + "field buffers\n"); + } else { + pbuf = (void *) __get_free_page(GFP_KERNEL); + if ((void *)NULL == pbuf) { + SAY("ERROR: Could not allocate field" \ + " buffer %i page %i\n", k, m); + return -ENOMEM; + } + else + peasycap->allocation_video_page += 1; + peasycap->field_buffer[k][m].pgo = pbuf; + } + peasycap->field_buffer[k][m].pto = \ + peasycap->field_buffer[k][m].pgo; + } + peasycap->field_buffer[k][0].kount = 0x0200; + } + peasycap->field_fill = 0; + peasycap->field_page = 0; + peasycap->field_read = 0; + JOT(4, "allocation of field buffers done: %i pages\n", k * \ + m); +/*---------------------------------------------------------------------------*/ + JOT(4, "allocating %i isoc video buffers of size %i\n", \ + VIDEO_ISOC_BUFFER_MANY, \ + peasycap->video_isoc_buffer_size); + JOT(4, ".... each occupying contiguous memory pages\n"); + + for (k = 0; k < VIDEO_ISOC_BUFFER_MANY; k++) { + pbuf = (void *)__get_free_pages(GFP_KERNEL, VIDEO_ISOC_ORDER); + if (NULL == pbuf) { + SAY("ERROR: Could not allocate isoc video buffer " \ + "%i\n", k); + return -ENOMEM; + } else + peasycap->allocation_video_page += \ + ((unsigned int)(0x01 << VIDEO_ISOC_ORDER)); + + peasycap->video_isoc_buffer[k].pgo = pbuf; + peasycap->video_isoc_buffer[k].pto = pbuf + \ + peasycap->video_isoc_buffer_size; + peasycap->video_isoc_buffer[k].kount = k; + } + JOT(4, "allocation of isoc video buffers done: %i pages\n", \ + k * (0x01 << VIDEO_ISOC_ORDER)); +/*---------------------------------------------------------------------------*/ +/* + * ALLOCATE AND INITIALIZE MULTIPLE struct urb ... + */ +/*---------------------------------------------------------------------------*/ + JOT(4, "allocating %i struct urb.\n", VIDEO_ISOC_BUFFER_MANY); + JOT(4, "using %i=peasycap->video_isoc_framesperdesc\n", \ + peasycap->video_isoc_framesperdesc); + JOT(4, "using %i=peasycap->video_isoc_maxframesize\n", \ + peasycap->video_isoc_maxframesize); + JOT(4, "using %i=peasycap->video_isoc_buffer_sizen", \ + peasycap->video_isoc_buffer_size); + + for (k = 0; k < VIDEO_ISOC_BUFFER_MANY; k++) { + purb = usb_alloc_urb(peasycap->video_isoc_framesperdesc, \ + GFP_KERNEL); + if (NULL == purb) { + SAY("ERROR: usb_alloc_urb returned NULL for buffer " \ + "%i\n", k); + return -ENOMEM; + } else + peasycap->allocation_video_urb += 1; +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + pdata_urb = kzalloc(sizeof(struct data_urb), GFP_KERNEL); + if (NULL == pdata_urb) { + SAY("ERROR: Could not allocate struct data_urb.\n"); + return -ENOMEM; + } else + peasycap->allocation_video_struct += \ + sizeof(struct data_urb); + + pdata_urb->purb = purb; + pdata_urb->isbuf = k; + pdata_urb->length = 0; + list_add_tail(&(pdata_urb->list_head), \ + peasycap->purb_video_head); +/*---------------------------------------------------------------------------*/ +/* + * ... AND INITIALIZE THEM + */ +/*---------------------------------------------------------------------------*/ + if (!k) { + JOT(4, "initializing video urbs thus:\n"); + JOT(4, " purb->interval = 1;\n"); + JOT(4, " purb->dev = peasycap->pusb_device;\n"); + JOT(4, " purb->pipe = usb_rcvisocpipe" \ + "(peasycap->pusb_device,%i);\n", \ + peasycap->video_endpointnumber); + JOT(4, " purb->transfer_flags = URB_ISO_ASAP;\n"); + JOT(4, " purb->transfer_buffer = peasycap->" \ + "video_isoc_buffer[.].pgo;\n"); + JOT(4, " purb->transfer_buffer_length = %i;\n", \ + peasycap->video_isoc_buffer_size); + JOT(4, " purb->complete = easycap_complete;\n"); + JOT(4, " purb->context = peasycap;\n"); + JOT(4, " purb->start_frame = 0;\n"); + JOT(4, " purb->number_of_packets = %i;\n", \ + peasycap->video_isoc_framesperdesc); + JOT(4, " for (j = 0; j < %i; j++)\n", \ + peasycap->video_isoc_framesperdesc); + JOT(4, " {\n"); + JOT(4, " purb->iso_frame_desc[j].offset = j*%i;\n",\ + peasycap->video_isoc_maxframesize); + JOT(4, " purb->iso_frame_desc[j].length = %i;\n", \ + peasycap->video_isoc_maxframesize); + JOT(4, " }\n"); + } + + purb->interval = 1; + purb->dev = peasycap->pusb_device; + purb->pipe = usb_rcvisocpipe(peasycap->pusb_device, \ + peasycap->video_endpointnumber); + purb->transfer_flags = URB_ISO_ASAP; + purb->transfer_buffer = peasycap->video_isoc_buffer[k].pgo; + purb->transfer_buffer_length = \ + peasycap->video_isoc_buffer_size; + purb->complete = easycap_complete; + purb->context = peasycap; + purb->start_frame = 0; + purb->number_of_packets = peasycap->video_isoc_framesperdesc; + for (j = 0; j < peasycap->video_isoc_framesperdesc; j++) { + purb->iso_frame_desc[j].offset = j * \ + peasycap->video_isoc_maxframesize; + purb->iso_frame_desc[j].length = \ + peasycap->video_isoc_maxframesize; + } + } + JOT(4, "allocation of %i struct urb done.\n", k); +/*--------------------------------------------------------------------------*/ +/* + * SAVE POINTER peasycap IN THIS INTERFACE. + */ +/*--------------------------------------------------------------------------*/ + usb_set_intfdata(pusb_interface, peasycap); +/*--------------------------------------------------------------------------*/ +/* + * THE VIDEO DEVICE CAN BE REGISTERED NOW, AS IT IS READY. + */ +/*--------------------------------------------------------------------------*/ +#if (!defined(EASYCAP_IS_VIDEODEV_CLIENT)) + if (0 != (usb_register_dev(pusb_interface, &easycap_class))) { + err("Not able to get a minor for this device"); + usb_set_intfdata(pusb_interface, NULL); + return -ENODEV; + } else + (peasycap->registered_video)++; + SAY("easycap attached to minor #%d\n", pusb_interface->minor); + break; +/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ +#else + pvideo_device = (struct video_device *)\ + kzalloc(sizeof(struct video_device), GFP_KERNEL); + if ((struct video_device *)NULL == pvideo_device) { + SAY("ERROR: Could not allocate structure video_device\n"); + return -ENOMEM; + } + if (VIDEO_DEVICE_MANY <= video_device_many) { + SAY("ERROR: Too many /dev/videos\n"); + return -ENOMEM; + } + pvideo_array[video_device_many] = pvideo_device; video_device_many++; + + strcpy(&pvideo_device->name[0], "easycapdc60"); +#if defined(EASYCAP_NEEDS_V4L2_FOPS) + pvideo_device->fops = &v4l2_fops; +#else + pvideo_device->fops = &easycap_fops; +#endif /*EASYCAP_NEEDS_V4L2_FOPS*/ + pvideo_device->minor = -1; + pvideo_device->release = (void *)(&videodev_release); + + video_set_drvdata(pvideo_device, (void *)peasycap); + + rc = video_register_device(pvideo_device, VFL_TYPE_GRABBER, -1); + if (0 != rc) { + err("Not able to register with videodev"); + videodev_release(pvideo_device); + return -ENODEV; + } else { + peasycap->pvideo_device = pvideo_device; + (peasycap->registered_video)++; + JOT(4, "registered with videodev: %i=minor\n", \ + pvideo_device->minor); + } +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ +#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ + break; +} +/*--------------------------------------------------------------------------*/ +/* + * INTERFACE 1 IS THE AUDIO CONTROL INTERFACE + * INTERFACE 2 IS THE AUDIO STREAMING INTERFACE + */ +/*--------------------------------------------------------------------------*/ +case 1: { +/*--------------------------------------------------------------------------*/ +/* + * SAVE POINTER peasycap IN INTERFACE 1 + */ +/*--------------------------------------------------------------------------*/ + usb_set_intfdata(pusb_interface, peasycap); + JOT(4, "no initialization required for interface %i\n", \ + pusb_interface_descriptor->bInterfaceNumber); + break; +} +/*--------------------------------------------------------------------------*/ +case 2: { + if (!peasycap) { + SAY("MISTAKE: peasycap is NULL\n"); + return -EFAULT; + } + if (!isokalt) { + SAY("ERROR: no viable audio_altsetting_on\n"); + return -ENOENT; + } else { + peasycap->audio_altsetting_on = okalt[isokalt - 1]; + JOT(4, "%i=audio_altsetting_on <====\n", \ + peasycap->audio_altsetting_on); + } + if (!isokepn) { + SAY("ERROR: no viable audio_endpointnumber\n"); + return -ENOENT; + } else { + peasycap->audio_endpointnumber = okepn[isokepn - 1]; + JOT(4, "%i=audio_endpointnumber\n", \ + peasycap->audio_endpointnumber); + } + if (!isokmps) { + SAY("ERROR: no viable audio_maxpacketsize\n"); + return -ENOENT; + } else { + peasycap->audio_isoc_maxframesize = okmps[isokmps - 1]; + JOT(4, "%i=audio_isoc_maxframesize\n", \ + peasycap->audio_isoc_maxframesize); + if (0 >= peasycap->audio_isoc_maxframesize) { + SAY("ERROR: bad audio_isoc_maxframesize\n"); + return -ENOENT; + } + if (9 == peasycap->audio_isoc_maxframesize) { + peasycap->ilk |= 0x02; + SAY("hardware is FOUR-CVBS\n"); + peasycap->microphone = true; + audio_pages_per_fragment = 2; + } else if (256 == peasycap->audio_isoc_maxframesize) { + peasycap->ilk &= ~0x02; + SAY("hardware is CVBS+S-VIDEO\n"); + peasycap->microphone = false; + audio_pages_per_fragment = 4; + } else { + SAY("hardware is unidentified:\n"); + SAY("%i=audio_isoc_maxframesize\n", \ + peasycap->audio_isoc_maxframesize); + return -ENOENT; + } + + audio_bytes_per_fragment = audio_pages_per_fragment * \ + PAGE_SIZE ; + audio_buffer_page_many = (AUDIO_FRAGMENT_MANY * \ + audio_pages_per_fragment); + + JOT(4, "%6i=AUDIO_FRAGMENT_MANY\n", AUDIO_FRAGMENT_MANY); + JOT(4, "%6i=audio_pages_per_fragment\n", \ + audio_pages_per_fragment); + JOT(4, "%6i=audio_bytes_per_fragment\n", \ + audio_bytes_per_fragment); + JOT(4, "%6i=audio_buffer_page_many\n", audio_buffer_page_many); + + peasycap->audio_isoc_framesperdesc = 128; + + JOT(4, "%i=audio_isoc_framesperdesc\n", \ + peasycap->audio_isoc_framesperdesc); + if (0 >= peasycap->audio_isoc_framesperdesc) { + SAY("ERROR: bad audio_isoc_framesperdesc\n"); + return -ENOENT; + } + + peasycap->audio_isoc_buffer_size = \ + peasycap->audio_isoc_maxframesize * \ + peasycap->audio_isoc_framesperdesc; + JOT(4, "%i=audio_isoc_buffer_size\n", \ + peasycap->audio_isoc_buffer_size); + if (AUDIO_ISOC_BUFFER_SIZE < \ + peasycap->audio_isoc_buffer_size) { + SAY("MISTAKE: audio_isoc_buffer_size bigger " + "than %li=AUDIO_ISOC_BUFFER_SIZE\n", \ + AUDIO_ISOC_BUFFER_SIZE); + return -EFAULT; + } + } + + if (-1 == peasycap->audio_interface) { + SAY("MISTAKE: audio_interface is unset\n"); + return -EFAULT; + } + if (-1 == peasycap->audio_altsetting_on) { + SAY("MISTAKE: audio_altsetting_on is unset\n"); + return -EFAULT; + } + if (-1 == peasycap->audio_altsetting_off) { + SAY("MISTAKE: audio_interface_off is unset\n"); + return -EFAULT; + } + if (-1 == peasycap->audio_endpointnumber) { + SAY("MISTAKE: audio_endpointnumber is unset\n"); + return -EFAULT; + } + if (-1 == peasycap->audio_isoc_maxframesize) { + SAY("MISTAKE: audio_isoc_maxframesize is unset\n"); + return -EFAULT; + } + if (-1 == peasycap->audio_isoc_buffer_size) { + SAY("MISTAKE: audio_isoc_buffer_size is unset\n"); + return -EFAULT; + } +/*---------------------------------------------------------------------------*/ +/* + * ALLOCATE MEMORY FOR AUDIO BUFFERS. LISTS MUST BE INITIALIZED FIRST. + */ +/*---------------------------------------------------------------------------*/ + INIT_LIST_HEAD(&(peasycap->urb_audio_head)); + peasycap->purb_audio_head = &(peasycap->urb_audio_head); + + JOT(4, "allocating an audio buffer\n"); + JOT(4, ".... scattered over %i pages\n", audio_buffer_page_many); + + for (k = 0; k < audio_buffer_page_many; k++) { + if ((void *)NULL != peasycap->audio_buffer[k].pgo) { + SAY("ERROR: attempting to reallocate audio buffers\n"); + } else { + pbuf = (void *) __get_free_page(GFP_KERNEL); + if ((void *)NULL == pbuf) { + SAY("ERROR: Could not allocate audio " \ + "buffer page %i\n", k); + return -ENOMEM; + } else + peasycap->allocation_audio_page += 1; + + peasycap->audio_buffer[k].pgo = pbuf; + } + peasycap->audio_buffer[k].pto = peasycap->audio_buffer[k].pgo; + } + + peasycap->audio_fill = 0; + peasycap->audio_read = 0; + JOT(4, "allocation of audio buffer done: %i pages\n", k); +/*---------------------------------------------------------------------------*/ + JOT(4, "allocating %i isoc audio buffers of size %i\n", \ + AUDIO_ISOC_BUFFER_MANY, peasycap->audio_isoc_buffer_size); + JOT(4, ".... each occupying contiguous memory pages\n"); + + for (k = 0; k < AUDIO_ISOC_BUFFER_MANY; k++) { + pbuf = (void *)__get_free_pages(GFP_KERNEL, AUDIO_ISOC_ORDER); + if (NULL == pbuf) { + SAY("ERROR: Could not allocate isoc audio buffer " \ + "%i\n", k); + return -ENOMEM; + } else + peasycap->allocation_audio_page += \ + ((unsigned int)(0x01 << AUDIO_ISOC_ORDER)); + + peasycap->audio_isoc_buffer[k].pgo = pbuf; + peasycap->audio_isoc_buffer[k].pto = pbuf + \ + peasycap->audio_isoc_buffer_size; + peasycap->audio_isoc_buffer[k].kount = k; + } + JOT(4, "allocation of isoc audio buffers done.\n"); +/*---------------------------------------------------------------------------*/ +/* + * ALLOCATE AND INITIALIZE MULTIPLE struct urb ... + */ +/*---------------------------------------------------------------------------*/ + JOT(4, "allocating %i struct urb.\n", AUDIO_ISOC_BUFFER_MANY); + JOT(4, "using %i=peasycap->audio_isoc_framesperdesc\n", \ + peasycap->audio_isoc_framesperdesc); + JOT(4, "using %i=peasycap->audio_isoc_maxframesize\n", \ + peasycap->audio_isoc_maxframesize); + JOT(4, "using %i=peasycap->audio_isoc_buffer_size\n", \ + peasycap->audio_isoc_buffer_size); + + for (k = 0; k < AUDIO_ISOC_BUFFER_MANY; k++) { + purb = usb_alloc_urb(peasycap->audio_isoc_framesperdesc, \ + GFP_KERNEL); + if (NULL == purb) { + SAY("ERROR: usb_alloc_urb returned NULL for buffer " \ + "%i\n", k); + return -ENOMEM; + } else + peasycap->allocation_audio_urb += 1 ; +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + pdata_urb = kzalloc(sizeof(struct data_urb), GFP_KERNEL); + if (NULL == pdata_urb) { + SAY("ERROR: Could not allocate struct data_urb.\n"); + return -ENOMEM; + } else + peasycap->allocation_audio_struct += \ + sizeof(struct data_urb); + + pdata_urb->purb = purb; + pdata_urb->isbuf = k; + pdata_urb->length = 0; + list_add_tail(&(pdata_urb->list_head), \ + peasycap->purb_audio_head); +/*---------------------------------------------------------------------------*/ +/* + * ... AND INITIALIZE THEM + */ +/*---------------------------------------------------------------------------*/ + if (!k) { + JOT(4, "initializing audio urbs thus:\n"); + JOT(4, " purb->interval = 1;\n"); + JOT(4, " purb->dev = peasycap->pusb_device;\n"); + JOT(4, " purb->pipe = usb_rcvisocpipe(peasycap->" \ + "pusb_device,%i);\n", \ + peasycap->audio_endpointnumber); + JOT(4, " purb->transfer_flags = URB_ISO_ASAP;\n"); + JOT(4, " purb->transfer_buffer = " \ + "peasycap->audio_isoc_buffer[.].pgo;\n"); + JOT(4, " purb->transfer_buffer_length = %i;\n", \ + peasycap->audio_isoc_buffer_size); + JOT(4, " purb->complete = easysnd_complete;\n"); + JOT(4, " purb->context = peasycap;\n"); + JOT(4, " purb->start_frame = 0;\n"); + JOT(4, " purb->number_of_packets = %i;\n", \ + peasycap->audio_isoc_framesperdesc); + JOT(4, " for (j = 0; j < %i; j++)\n", \ + peasycap->audio_isoc_framesperdesc); + JOT(4, " {\n"); + JOT(4, " purb->iso_frame_desc[j].offset = j*%i;\n",\ + peasycap->audio_isoc_maxframesize); + JOT(4, " purb->iso_frame_desc[j].length = %i;\n", \ + peasycap->audio_isoc_maxframesize); + JOT(4, " }\n"); + } + + purb->interval = 1; + purb->dev = peasycap->pusb_device; + purb->pipe = usb_rcvisocpipe(peasycap->pusb_device, \ + peasycap->audio_endpointnumber); + purb->transfer_flags = URB_ISO_ASAP; + purb->transfer_buffer = peasycap->audio_isoc_buffer[k].pgo; + purb->transfer_buffer_length = \ + peasycap->audio_isoc_buffer_size; + purb->complete = easysnd_complete; + purb->context = peasycap; + purb->start_frame = 0; + purb->number_of_packets = peasycap->audio_isoc_framesperdesc; + for (j = 0; j < peasycap->audio_isoc_framesperdesc; j++) { + purb->iso_frame_desc[j].offset = j * \ + peasycap->audio_isoc_maxframesize; + purb->iso_frame_desc[j].length = \ + peasycap->audio_isoc_maxframesize; + } + } + JOT(4, "allocation of %i struct urb done.\n", k); +/*---------------------------------------------------------------------------*/ +/* + * SAVE POINTER peasycap IN THIS INTERFACE. + */ +/*---------------------------------------------------------------------------*/ + usb_set_intfdata(pusb_interface, peasycap); +/*---------------------------------------------------------------------------*/ +/* + * THE AUDIO DEVICE CAN BE REGISTERED NOW, AS IT IS READY. + */ +/*---------------------------------------------------------------------------*/ + rc = usb_register_dev(pusb_interface, &easysnd_class); + if (0 != rc) { + err("Not able to get a minor for this device."); + usb_set_intfdata(pusb_interface, NULL); + return -ENODEV; + } else + (peasycap->registered_audio)++; +/*---------------------------------------------------------------------------*/ +/* + * LET THE USER KNOW WHAT NODE THE AUDIO DEVICE IS ATTACHED TO. + */ +/*---------------------------------------------------------------------------*/ + SAY("easysnd attached to minor #%d\n", pusb_interface->minor); + break; +} +/*---------------------------------------------------------------------------*/ +/* + * INTERFACES OTHER THAN 0, 1 AND 2 ARE UNEXPECTED + */ +/*---------------------------------------------------------------------------*/ +default: { + JOT(4, "ERROR: unexpected interface %i\n", bInterfaceNumber); + return -EINVAL; +} +} +JOT(4, "ends successfully for interface %i\n", \ + pusb_interface_descriptor->bInterfaceNumber); +return 0; +} +/*****************************************************************************/ +/*---------------------------------------------------------------------------*/ +/* + * WHEN THIS FUNCTION IS CALLED THE DEVICE HAS ALREADY BEEN PHYSICALLY + * UNPLUGGED. + * HENCE peasycap->pusb_device IS NO LONGER VALID AND MUST BE SET TO NULL. + */ +/*---------------------------------------------------------------------------*/ +void +easycap_usb_disconnect(struct usb_interface *pusb_interface) +{ +struct usb_host_interface *pusb_host_interface; +struct usb_interface_descriptor *pusb_interface_descriptor; +__u8 bInterfaceNumber; +struct easycap *peasycap; + +struct list_head *plist_head; +struct data_urb *pdata_urb; +int minor, m; + +JOT(4, "\n"); + +if ((struct usb_interface *)NULL == pusb_interface) { + JOT(4, "ERROR: pusb_interface is NULL\n"); + return; +} +pusb_host_interface = pusb_interface->cur_altsetting; +if ((struct usb_host_interface *)NULL == pusb_host_interface) { + JOT(4, "ERROR: pusb_host_interface is NULL\n"); + return; +} +pusb_interface_descriptor = &(pusb_host_interface->desc); +if ((struct usb_interface_descriptor *)NULL == pusb_interface_descriptor) { + JOT(4, "ERROR: pusb_interface_descriptor is NULL\n"); + return; +} +bInterfaceNumber = pusb_interface_descriptor->bInterfaceNumber; +minor = pusb_interface->minor; +JOT(4, "intf[%i]: minor=%i\n", bInterfaceNumber, minor); + +peasycap = usb_get_intfdata(pusb_interface); +if ((struct easycap *)NULL == peasycap) + SAY("ERROR: peasycap is NULL\n"); +else { + peasycap->pusb_device = (struct usb_device *)NULL; + switch (bInterfaceNumber) { +/*---------------------------------------------------------------------------*/ + case 0: { + if ((struct list_head *)NULL != peasycap->purb_video_head) { + JOT(4, "killing video urbs\n"); + m = 0; + list_for_each(plist_head, (peasycap->purb_video_head)) + { + pdata_urb = list_entry(plist_head, \ + struct data_urb, list_head); + if ((struct data_urb *)NULL != pdata_urb) { + if ((struct urb *)NULL != \ + pdata_urb->purb) { + usb_kill_urb(pdata_urb->purb); + m++; + } + } + } + JOT(4, "%i video urbs killed\n", m); + } else + SAY("ERROR: peasycap->purb_video_head is NULL\n"); + break; + } +/*---------------------------------------------------------------------------*/ + case 2: { + if ((struct list_head *)NULL != peasycap->purb_audio_head) { + JOT(4, "killing audio urbs\n"); + m = 0; + list_for_each(plist_head, \ + (peasycap->purb_audio_head)) { + pdata_urb = list_entry(plist_head, \ + struct data_urb, list_head); + if ((struct data_urb *)NULL != pdata_urb) { + if ((struct urb *)NULL != \ + pdata_urb->purb) { + usb_kill_urb(pdata_urb->purb); + m++; + } + } + } + JOT(4, "%i audio urbs killed\n", m); + } else + SAY("ERROR: peasycap->purb_audio_head is NULL\n"); + break; + } +/*---------------------------------------------------------------------------*/ + default: + break; + } +} +/*--------------------------------------------------------------------------*/ +/* + * DEREGISTER + */ +/*--------------------------------------------------------------------------*/ +switch (bInterfaceNumber) { +case 0: { +#if (!defined(EASYCAP_IS_VIDEODEV_CLIENT)) + if ((struct easycap *)NULL == peasycap) { + SAY("ERROR: peasycap has become NULL\n"); + } else { + lock_kernel(); + usb_deregister_dev(pusb_interface, &easycap_class); + (peasycap->registered_video)--; + + JOT(4, "intf[%i]: usb_deregister_dev()\n", bInterfaceNumber); + unlock_kernel(); + SAY("easycap detached from minor #%d\n", minor); + } +/*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/ +#else + if ((struct easycap *)NULL == peasycap) + SAY("ERROR: peasycap has become NULL\n"); + else { + lock_kernel(); + video_unregister_device(peasycap->pvideo_device); + (peasycap->registered_video)--; + unlock_kernel(); + JOT(4, "unregistered with videodev: %i=minor\n", \ + pvideo_device->minor); + } +/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/ +#endif /*EASYCAP_IS_VIDEODEV_CLIENT*/ + break; +} +case 2: { + lock_kernel(); + + usb_deregister_dev(pusb_interface, &easysnd_class); + if ((struct easycap *)NULL != peasycap) + (peasycap->registered_audio)--; + + JOT(4, "intf[%i]: usb_deregister_dev()\n", bInterfaceNumber); + unlock_kernel(); + + SAY("easysnd detached from minor #%d\n", minor); + break; +} +default: + break; +} +/*---------------------------------------------------------------------------*/ +/* + * CALL easycap_delete() IF NO REMAINING REFERENCES TO peasycap + */ +/*---------------------------------------------------------------------------*/ +if ((struct easycap *)NULL == peasycap) { + SAY("ERROR: peasycap has become NULL\n"); + SAY("cannot call kref_put()\n"); + SAY("ending unsuccessfully: may cause memory leak\n"); + return; +} +if (!peasycap->kref.refcount.counter) { + SAY("ERROR: peasycap->kref.refcount.counter is zero " \ + "so cannot call kref_put()\n"); + SAY("ending unsuccessfully: may cause memory leak\n"); + return; +} +JOT(4, "intf[%i]: kref_put() with %i=peasycap->kref.refcount.counter\n", \ + bInterfaceNumber, (int)peasycap->kref.refcount.counter); +kref_put(&peasycap->kref, easycap_delete); +JOT(4, "intf[%i]: kref_put() done.\n", bInterfaceNumber); +/*---------------------------------------------------------------------------*/ + +JOT(4, "ends\n"); +return; +} +/*****************************************************************************/ +int __init +easycap_module_init(void) +{ +int result; + +SAY("========easycap=======\n"); +JOT(4, "begins. %i=debug\n", easycap_debug); +SAY("version: " EASYCAP_DRIVER_VERSION "\n"); +/*---------------------------------------------------------------------------*/ +/* + * REGISTER THIS DRIVER WITH THE USB SUBSYTEM. + */ +/*---------------------------------------------------------------------------*/ +JOT(4, "registering driver easycap\n"); + +result = usb_register(&easycap_usb_driver); +if (0 != result) + SAY("ERROR: usb_register returned %i\n", result); + +JOT(4, "ends\n"); +return result; +} +/*****************************************************************************/ +void __exit +easycap_module_exit(void) +{ +JOT(4, "begins\n"); + +/*---------------------------------------------------------------------------*/ +/* + * DEREGISTER THIS DRIVER WITH THE USB SUBSYTEM. + */ +/*---------------------------------------------------------------------------*/ +usb_deregister(&easycap_usb_driver); + +JOT(4, "ends\n"); +} +/*****************************************************************************/ + +module_init(easycap_module_init); +module_exit(easycap_module_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("R.M. Thomas "); +MODULE_DESCRIPTION(EASYCAP_DRIVER_DESCRIPTION); +MODULE_VERSION(EASYCAP_DRIVER_VERSION); +#if defined(EASYCAP_DEBUG) +MODULE_PARM_DESC(easycap_debug, "debug: 0 (default), 1, 2,..."); +#endif /*EASYCAP_DEBUG*/ +/*****************************************************************************/ diff --git a/drivers/staging/easycap/easycap_settings.c b/drivers/staging/easycap/easycap_settings.c new file mode 100644 index 000000000000..1e4eb23885e3 --- /dev/null +++ b/drivers/staging/easycap/easycap_settings.c @@ -0,0 +1,489 @@ +/****************************************************************************** +* * +* easycap_settings.c * +* * +******************************************************************************/ +/* + * + * Copyright (C) 2010 R.M. Thomas + * + * + * This 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. + * + * The software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * +*/ +/*****************************************************************************/ + +#include "easycap.h" +#include "easycap_debug.h" + +/*---------------------------------------------------------------------------*/ +/* + * THE LEAST SIGNIFICANT BIT OF easycap_standard.mask HAS MEANING: + * 0 => 25 fps + * 1 => 30 fps + */ +/*---------------------------------------------------------------------------*/ +struct easycap_standard easycap_standard[] = { +{ +.mask = 0x000F & PAL_BGHIN , +.v4l2_standard = { + .index = PAL_BGHIN, + .id = (V4L2_STD_PAL_B | V4L2_STD_PAL_G | V4L2_STD_PAL_H | \ + V4L2_STD_PAL_I | V4L2_STD_PAL_N), + .name = "PAL_BGHIN", + .frameperiod = {1, 25}, + .framelines = 625, + .reserved = {0, 0, 0, 0} + } +}, +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +{ +.mask = 0x000F & NTSC_N_443 , +.v4l2_standard = { + .index = NTSC_N_443, + .id = V4L2_STD_UNKNOWN, + .name = "NTSC_N_443", + .frameperiod = {1, 25}, + .framelines = 480, + .reserved = {0, 0, 0, 0} +} +}, +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +{ +.mask = 0x000F & PAL_Nc , +.v4l2_standard = { + .index = PAL_Nc, + .id = V4L2_STD_PAL_Nc, + .name = "PAL_Nc", + .frameperiod = {1, 25}, + .framelines = 625, + .reserved = {0, 0, 0, 0} +} +}, +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +{ +.mask = 0x000F & NTSC_N , +.v4l2_standard = { + .index = NTSC_N, + .id = V4L2_STD_UNKNOWN, + .name = "NTSC_N", + .frameperiod = {1, 25}, + .framelines = 525, + .reserved = {0, 0, 0, 0} +} +}, +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +{ +.mask = 0x000F & SECAM , +.v4l2_standard = { + .index = SECAM, + .id = V4L2_STD_SECAM, + .name = "SECAM", + .frameperiod = {1, 25}, + .framelines = 625, + .reserved = {0, 0, 0, 0} +} +}, +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +{ +.mask = 0x000F & NTSC_M , +.v4l2_standard = { + .index = NTSC_M, + .id = V4L2_STD_NTSC_M, + .name = "NTSC_M", + .frameperiod = {1, 30}, + .framelines = 525, + .reserved = {0, 0, 0, 0} +} +}, +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +{ +.mask = 0x000F & NTSC_M_JP , +.v4l2_standard = { + .index = NTSC_M_JP, + .id = V4L2_STD_NTSC_M_JP, + .name = "NTSC_M_JP", + .frameperiod = {1, 30}, + .framelines = 525, + .reserved = {0, 0, 0, 0} +} +}, +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +{ +.mask = 0x000F & PAL_60 , +.v4l2_standard = { + .index = PAL_60, + .id = V4L2_STD_PAL_60, + .name = "PAL_60", + .frameperiod = {1, 30}, + .framelines = 525, + .reserved = {0, 0, 0, 0} +} +}, +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +{ +.mask = 0x000F & NTSC_443 , +.v4l2_standard = { + .index = NTSC_443, + .id = V4L2_STD_NTSC_443, + .name = "NTSC_443", + .frameperiod = {1, 30}, + .framelines = 525, + .reserved = {0, 0, 0, 0} +} +}, +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +{ +.mask = 0x000F & PAL_M , +.v4l2_standard = { + .index = PAL_M, + .id = V4L2_STD_PAL_M, + .name = "PAL_M", + .frameperiod = {1, 30}, + .framelines = 525, + .reserved = {0, 0, 0, 0} +} +}, +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +{ +.mask = 0xFFFF +} +}; +/*---------------------------------------------------------------------------*/ +/* + * THE 16-BIT easycap_format.mask HAS MEANING: + * (least significant) BIT 0: 0 => PAL, 25 FPS; 1 => NTSC, 30 FPS + * BITS 1-3: RESERVED FOR DIFFERENTIATING STANDARDS + * BITS 4-7: NUMBER OF BYTES PER PIXEL + * BIT 8: 0 => NATIVE BYTE ORDER; 1 => SWAPPED + * BITS 9-10: RESERVED FOR OTHER BYTE PERMUTATIONS + * BIT 11: 0 => UNDECIMATED; 1 => DECIMATED + * BIT 12: 0 => OFFER FRAMES; 1 => OFFER FIELDS + * (most significant) BITS 13-15: RESERVED FOR OTHER FIELD ORDER OPTIONS + * IT FOLLOWS THAT: + * bytesperpixel IS ((0x00F0 & easycap_format.mask) >> 4) + * byteswaporder IS true IF (0 != (0x0100 & easycap_format.mask)) + * + * decimatepixel IS true IF (0 != (0x0800 & easycap_format.mask)) + * + * offerfields IS true IF (0 != (0x1000 & easycap_format.mask)) + */ +/*---------------------------------------------------------------------------*/ + +struct easycap_format easycap_format[1 + SETTINGS_MANY]; + +int +fillin_formats(void) +{ +int i, j, k, m, n; +__u32 width, height, pixelformat, bytesperline, sizeimage; +__u32 field, colorspace; +__u16 mask1, mask2, mask3, mask4; +char name1[32], name2[32], name3[32], name4[32]; + +for (i = 0, n = 0; i < STANDARD_MANY; i++) { + mask1 = 0x0000; + switch (i) { + case PAL_BGHIN: { + mask1 = PAL_BGHIN; + strcpy(&name1[0], "PAL_BGHIN"); + colorspace = V4L2_COLORSPACE_470_SYSTEM_BG; + break; + } + case SECAM: { + mask1 = SECAM; + strcpy(&name1[0], "SECAM"); + colorspace = V4L2_COLORSPACE_470_SYSTEM_BG; + break; + } + case PAL_Nc: { + mask1 = PAL_Nc; + strcpy(&name1[0], "PAL_Nc"); + colorspace = V4L2_COLORSPACE_470_SYSTEM_BG; + break; + } + case PAL_60: { + mask1 = PAL_60; + strcpy(&name1[0], "PAL_60"); + colorspace = V4L2_COLORSPACE_470_SYSTEM_BG; + break; + } + case PAL_M: { + mask1 = PAL_M; + strcpy(&name1[0], "PAL_M"); + colorspace = V4L2_COLORSPACE_470_SYSTEM_BG; + break; + } + case NTSC_M: { + mask1 = NTSC_M; + strcpy(&name1[0], "NTSC_M"); + colorspace = V4L2_COLORSPACE_470_SYSTEM_M; + break; + } + case NTSC_443: { + mask1 = NTSC_443; + strcpy(&name1[0], "NTSC_443"); + colorspace = V4L2_COLORSPACE_470_SYSTEM_M; + break; + } + case NTSC_M_JP: { + mask1 = NTSC_M_JP; + strcpy(&name1[0], "NTSC_M_JP"); + colorspace = V4L2_COLORSPACE_470_SYSTEM_M; + break; + } + case NTSC_N: { + mask1 = NTSC_M; + strcpy(&name1[0], "NTSC_N"); + colorspace = V4L2_COLORSPACE_470_SYSTEM_M; + break; + } + case NTSC_N_443: { + mask1 = NTSC_N_443; + strcpy(&name1[0], "NTSC_N_443"); + colorspace = V4L2_COLORSPACE_470_SYSTEM_M; + break; + } + default: + return -1; + } + + for (j = 0; j < RESOLUTION_MANY; j++) { + mask2 = 0x0000; + switch (j) { + case AT_720x576: { + if (0x1 & mask1) + continue; + strcpy(&name2[0], "_AT_720x576"); + width = 720; height = 576; break; + } + case AT_704x576: { + if (0x1 & mask1) + continue; + strcpy(&name2[0], "_AT_704x576"); + width = 704; height = 576; break; + } + case AT_640x480: { + strcpy(&name2[0], "_AT_640x480"); + width = 640; height = 480; break; + } + case AT_720x480: { + if (!(0x1 & mask1)) + continue; + strcpy(&name2[0], "_AT_720x480"); + width = 720; height = 480; break; + } + case AT_360x288: { + if (0x1 & mask1) + continue; + strcpy(&name2[0], "_AT_360x288"); + width = 360; height = 288; mask2 = 0x0800; break; + } + case AT_320x240: { + strcpy(&name2[0], "_AT_320x240"); + width = 320; height = 240; mask2 = 0x0800; break; + } + case AT_360x240: { + if (!(0x1 & mask1)) + continue; + strcpy(&name2[0], "_AT_360x240"); + width = 360; height = 240; mask2 = 0x0800; break; + } + default: + return -2; + } + + for (k = 0; k < PIXELFORMAT_MANY; k++) { + mask3 = 0x0000; + switch (k) { + case FMT_UYVY: { + strcpy(&name3[0], "_" STRINGIZE(FMT_UYVY)); + pixelformat = V4L2_PIX_FMT_UYVY; + mask3 |= (0x02 << 4); + break; + } + case FMT_YUY2: { + strcpy(&name3[0], "_" STRINGIZE(FMT_YUY2)); + pixelformat = V4L2_PIX_FMT_YUYV; + mask3 |= (0x02 << 4); + mask3 |= 0x0100; + break; + } + case FMT_RGB24: { + strcpy(&name3[0], "_" STRINGIZE(FMT_RGB24)); + pixelformat = V4L2_PIX_FMT_RGB24; + mask3 |= (0x03 << 4); + break; + } + case FMT_RGB32: { + strcpy(&name3[0], "_" STRINGIZE(FMT_RGB32)); + pixelformat = V4L2_PIX_FMT_RGB32; + mask3 |= (0x04 << 4); + break; + } + case FMT_BGR24: { + strcpy(&name3[0], "_" STRINGIZE(FMT_BGR24)); + pixelformat = V4L2_PIX_FMT_BGR24; + mask3 |= (0x03 << 4); + mask3 |= 0x0100; + break; + } + case FMT_BGR32: { + strcpy(&name3[0], "_" STRINGIZE(FMT_BGR32)); + pixelformat = V4L2_PIX_FMT_BGR32; + mask3 |= (0x04 << 4); + mask3 |= 0x0100; + break; + } + default: + return -3; + } + bytesperline = width * ((mask3 & 0x00F0) >> 4); + sizeimage = bytesperline * height; + + for (m = 0; m < INTERLACE_MANY; m++) { + mask4 = 0x0000; + switch (m) { + case FIELD_NONE: { + strcpy(&name4[0], "-n"); + field = V4L2_FIELD_NONE; + break; + } + case FIELD_INTERLACED: { + strcpy(&name4[0], "-i"); + field = V4L2_FIELD_INTERLACED; + break; + } + case FIELD_ALTERNATE: { + strcpy(&name4[0], "-a"); + mask4 |= 0x1000; + field = V4L2_FIELD_ALTERNATE; + break; + } + default: + return -4; + } + if (SETTINGS_MANY <= n) + return -5; + strcpy(&easycap_format[n].name[0], &name1[0]); + strcat(&easycap_format[n].name[0], &name2[0]); + strcat(&easycap_format[n].name[0], &name3[0]); + strcat(&easycap_format[n].name[0], &name4[0]); + easycap_format[n].mask = \ + mask1 | mask2 | mask3 | mask4; + easycap_format[n].v4l2_format\ + .type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + easycap_format[n].v4l2_format\ + .fmt.pix.width = width; + easycap_format[n].v4l2_format\ + .fmt.pix.height = height; + easycap_format[n].v4l2_format\ + .fmt.pix.pixelformat = pixelformat; + easycap_format[n].v4l2_format\ + .fmt.pix.field = field; + easycap_format[n].v4l2_format\ + .fmt.pix.bytesperline = bytesperline; + easycap_format[n].v4l2_format\ + .fmt.pix.sizeimage = sizeimage; + easycap_format[n].v4l2_format\ + .fmt.pix.colorspace = colorspace; + easycap_format[n].v4l2_format\ + .fmt.pix.priv = 0; + n++; + } + } + } +} +if ((1 + SETTINGS_MANY) <= n) + return -6; +easycap_format[n].mask = 0xFFFF; +return n; +} +/*---------------------------------------------------------------------------*/ +struct v4l2_queryctrl easycap_control[] = \ + {{ +.id = V4L2_CID_BRIGHTNESS, +.type = V4L2_CTRL_TYPE_INTEGER, +.name = "Brightness", +.minimum = 0, +.maximum = 255, +.step = 1, +.default_value = SAA_0A_DEFAULT, +.flags = 0, +.reserved = {0, 0} +}, +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +{ +.id = V4L2_CID_CONTRAST, +.type = V4L2_CTRL_TYPE_INTEGER, +.name = "Contrast", +.minimum = 0, +.maximum = 255, +.step = 1, +.default_value = SAA_0B_DEFAULT + 128, +.flags = 0, +.reserved = {0, 0} +}, +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +{ +.id = V4L2_CID_SATURATION, +.type = V4L2_CTRL_TYPE_INTEGER, +.name = "Saturation", +.minimum = 0, +.maximum = 255, +.step = 1, +.default_value = SAA_0C_DEFAULT + 128, +.flags = 0, +.reserved = {0, 0} +}, +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +{ +.id = V4L2_CID_HUE, +.type = V4L2_CTRL_TYPE_INTEGER, +.name = "Hue", +.minimum = 0, +.maximum = 255, +.step = 1, +.default_value = SAA_0D_DEFAULT + 128, +.flags = 0, +.reserved = {0, 0} +}, +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +{ +.id = V4L2_CID_AUDIO_VOLUME, +.type = V4L2_CTRL_TYPE_INTEGER, +.name = "Volume", +.minimum = 0, +.maximum = 31, +.step = 1, +.default_value = 16, +.flags = 0, +.reserved = {0, 0} +}, +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +{ +.id = V4L2_CID_AUDIO_MUTE, +.type = V4L2_CTRL_TYPE_BOOLEAN, +.name = "Mute", +.default_value = true, +.flags = 0, +.reserved = {0, 0} +}, +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +{ +.id = 0xFFFFFFFF +} + }; +/*****************************************************************************/ diff --git a/drivers/staging/easycap/easycap_sound.c b/drivers/staging/easycap/easycap_sound.c new file mode 100644 index 000000000000..532c4105738a --- /dev/null +++ b/drivers/staging/easycap/easycap_sound.c @@ -0,0 +1,973 @@ +/****************************************************************************** +* * +* easycap_sound.c * +* * +* Audio driver for EasyCAP USB2.0 Video Capture Device DC60 * +* * +* * +******************************************************************************/ +/* + * + * Copyright (C) 2010 R.M. Thomas + * + * + * This 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. + * + * The software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * +*/ +/*****************************************************************************/ + +#include "easycap.h" +#include "easycap_debug.h" +#include "easycap_sound.h" + +/*****************************************************************************/ +/*---------------------------------------------------------------------------*/ +/* + * ON COMPLETION OF AN AUDIO URB ITS DATA IS COPIED TO THE AUDIO BUFFERS + * PROVIDED peasycap->audio_idle IS ZER0. REGARDLESS OF THIS BEING TRUE, + * IT IS RESUBMITTED PROVIDED peasycap->audio_isoc_streaming IS NOT ZERO. + */ +/*---------------------------------------------------------------------------*/ +void +easysnd_complete(struct urb *purb) +{ +static int mt; +struct easycap *peasycap; +struct data_buffer *paudio_buffer; +char errbuf[16]; +__u8 *p1, *p2; +__s16 s16; +int i, j, more, much, leap, rc; + +JOT(16, "\n"); + +if (NULL == purb) { + SAY("ERROR: purb is NULL\n"); + return; +} +peasycap = purb->context; +if (NULL == peasycap) { + SAY("ERROR: peasycap is NULL\n"); + return; +} +much = 0; + + +if (peasycap->audio_idle) { + JOT(16, "%i=audio_idle %i=audio_isoc_streaming\n", \ + peasycap->audio_idle, peasycap->audio_isoc_streaming); + if (peasycap->audio_isoc_streaming) { + rc = usb_submit_urb(purb, GFP_ATOMIC); + if (0 != rc) { + SAY("ERROR: while %i=audio_idle, " \ + "usb_submit_urb() failed with rc:\n", \ + peasycap->audio_idle); + switch (rc) { + case -ENOMEM: { + SAY("ENOMEM\n"); break; + } + case -ENODEV: { + SAY("ENODEV\n"); break; + } + case -ENXIO: { + SAY("ENXIO\n"); break; + } + case -EINVAL: { + SAY("EINVAL\n"); break; + } + case -EAGAIN: { + SAY("EAGAIN\n"); break; + } + case -EFBIG: { + SAY("EFBIG\n"); break; + } + case -EPIPE: { + SAY("EPIPE\n"); break; + } + case -EMSGSIZE: { + SAY("EMSGSIZE\n"); break; + } + default: { + SAY("0x%08X\n", rc); break; + } + } + } + } +return; +} +/*---------------------------------------------------------------------------*/ +if (purb->status) { + if (-ESHUTDOWN == purb->status) { + JOT(16, "immediate return because -ESHUTDOWN=purb->status\n"); + return; + } + SAY("ERROR: non-zero urb status:\n"); + switch (purb->status) { + case -EINPROGRESS: { + SAY("-EINPROGRESS\n"); break; + } + case -ENOSR: { + SAY("-ENOSR\n"); break; + } + case -EPIPE: { + SAY("-EPIPE\n"); break; + } + case -EOVERFLOW: { + SAY("-EOVERFLOW\n"); break; + } + case -EPROTO: { + SAY("-EPROTO\n"); break; + } + case -EILSEQ: { + SAY("-EILSEQ\n"); break; + } + case -ETIMEDOUT: { + SAY("-ETIMEDOUT\n"); break; + } + case -EMSGSIZE: { + SAY("-EMSGSIZE\n"); break; + } + case -EOPNOTSUPP: { + SAY("-EOPNOTSUPP\n"); break; + } + case -EPFNOSUPPORT: { + SAY("-EPFNOSUPPORT\n"); break; + } + case -EAFNOSUPPORT: { + SAY("-EAFNOSUPPORT\n"); break; + } + case -EADDRINUSE: { + SAY("-EADDRINUSE\n"); break; + } + case -EADDRNOTAVAIL: { + SAY("-EADDRNOTAVAIL\n"); break; + } + case -ENOBUFS: { + SAY("-ENOBUFS\n"); break; + } + case -EISCONN: { + SAY("-EISCONN\n"); break; + } + case -ENOTCONN: { + SAY("-ENOTCONN\n"); break; + } + case -ESHUTDOWN: { + SAY("-ESHUTDOWN\n"); break; + } + case -ENOENT: { + SAY("-ENOENT\n"); break; + } + case -ECONNRESET: { + SAY("-ECONNRESET\n"); break; + } + default: { + SAY("unknown error code 0x%08X\n", purb->status); break; + } + } +/*---------------------------------------------------------------------------*/ +/* + * RESUBMIT THIS URB AFTER AN ERROR + * + * (THIS IS DUPLICATE CODE TO REDUCE INDENTATION OF THE NO-ERROR PATH) + */ +/*---------------------------------------------------------------------------*/ + if (peasycap->audio_isoc_streaming) { + rc = usb_submit_urb(purb, GFP_ATOMIC); + if (0 != rc) { + SAY("ERROR: while %i=audio_idle, usb_submit_urb() " + "failed with rc:\n", peasycap->audio_idle); + switch (rc) { + case -ENOMEM: { + SAY("ENOMEM\n"); break; + } + case -ENODEV: { + SAY("ENODEV\n"); break; + } + case -ENXIO: { + SAY("ENXIO\n"); break; + } + case -EINVAL: { + SAY("EINVAL\n"); break; + } + case -EAGAIN: { + SAY("EAGAIN\n"); break; + } + case -EFBIG: { + SAY("EFBIG\n"); break; + } + case -EPIPE: { + SAY("EPIPE\n"); break; + } + case -EMSGSIZE: { + SAY("EMSGSIZE\n"); break; + } + default: { + SAY("0x%08X\n", rc); break; + } + } + } + } + return; +} +/*---------------------------------------------------------------------------*/ +/* + * PROCEED HERE WHEN NO ERROR + */ +/*---------------------------------------------------------------------------*/ +for (i = 0; i < purb->number_of_packets; i++) { + switch (purb->iso_frame_desc[i].status) { + case 0: { + strcpy(&errbuf[0], "OK"); break; + } + case -ENOENT: { + strcpy(&errbuf[0], "-ENOENT"); break; + } + case -EINPROGRESS: { + strcpy(&errbuf[0], "-EINPROGRESS"); break; + } + case -EPROTO: { + strcpy(&errbuf[0], "-EPROTO"); break; + } + case -EILSEQ: { + strcpy(&errbuf[0], "-EILSEQ"); break; + } + case -ETIME: { + strcpy(&errbuf[0], "-ETIME"); break; + } + case -ETIMEDOUT: { + strcpy(&errbuf[0], "-ETIMEDOUT"); break; + } + case -EPIPE: { + strcpy(&errbuf[0], "-EPIPE"); break; + } + case -ECOMM: { + strcpy(&errbuf[0], "-ECOMM"); break; + } + case -ENOSR: { + strcpy(&errbuf[0], "-ENOSR"); break; + } + case -EOVERFLOW: { + strcpy(&errbuf[0], "-EOVERFLOW"); break; + } + case -EREMOTEIO: { + strcpy(&errbuf[0], "-EREMOTEIO"); break; + } + case -ENODEV: { + strcpy(&errbuf[0], "-ENODEV"); break; + } + case -EXDEV: { + strcpy(&errbuf[0], "-EXDEV"); break; + } + case -EINVAL: { + strcpy(&errbuf[0], "-EINVAL"); break; + } + case -ECONNRESET: { + strcpy(&errbuf[0], "-ECONNRESET"); break; + } + case -ESHUTDOWN: { + strcpy(&errbuf[0], "-ESHUTDOWN"); break; + } + default: { + strcpy(&errbuf[0], "UNKNOWN"); break; + } + } + if ((!purb->iso_frame_desc[i].status) && 0) { + JOT(16, "frame[%2i]: %i=status{=%16s} " \ + "%5i=actual " \ + "%5i=length " \ + "%3i=offset\n", \ + i, purb->iso_frame_desc[i].status, &errbuf[0], + purb->iso_frame_desc[i].actual_length, + purb->iso_frame_desc[i].length, + purb->iso_frame_desc[i].offset); + } + if (!purb->iso_frame_desc[i].status) { + more = purb->iso_frame_desc[i].actual_length; + +#if defined(TESTTONE) + if (!more) + more = purb->iso_frame_desc[i].length; +#endif + + if (!more) + mt++; + else { + if (mt) { + JOT(16, "%4i empty audio urb frames\n", mt); + mt = 0; + } + + p1 = (__u8 *)(purb->transfer_buffer + \ + purb->iso_frame_desc[i].offset); + + leap = 0; + p1 += leap; + more -= leap; +/*---------------------------------------------------------------------------*/ +/* + * COPY more BYTES FROM ISOC BUFFER TO AUDIO BUFFER, + * CONVERTING 8-BIT SAMPLES TO 16-BIT SIGNED LITTLE-ENDED SAMPLES IF NECESSARY + */ +/*---------------------------------------------------------------------------*/ + while (more) { + if (0 > more) { + SAY("easysnd_complete: MISTAKE: " \ + "more is negative\n"); + return; + } + if (audio_buffer_page_many <= \ + peasycap->audio_fill) { + SAY("ERROR: bad " \ + "peasycap->audio_fill\n"); + return; + } + + paudio_buffer = &peasycap->audio_buffer\ + [peasycap->audio_fill]; + if (PAGE_SIZE < (paudio_buffer->pto - \ + paudio_buffer->pgo)) { + SAY("ERROR: bad paudio_buffer->pto\n"); + return; + } + if (PAGE_SIZE == (paudio_buffer->pto - \ + paudio_buffer->pgo)) { + +#if defined(TESTTONE) + easysnd_testtone(peasycap, \ + peasycap->audio_fill); +#endif /*TESTTONE*/ + + paudio_buffer->pto = \ + paudio_buffer->pgo; + (peasycap->audio_fill)++; + if (audio_buffer_page_many <= \ + peasycap->audio_fill) + peasycap->audio_fill = 0; + + JOT(12, "bumped peasycap->" \ + "audio_fill to %i\n", \ + peasycap->audio_fill); + + paudio_buffer = &peasycap->\ + audio_buffer\ + [peasycap->audio_fill]; + paudio_buffer->pto = \ + paudio_buffer->pgo; + + if (!(peasycap->audio_fill % \ + audio_pages_per_fragment)) { + JOT(12, "wakeup call on wq_" \ + "audio, %i=frag reading %i" \ + "=fragment fill\n", \ + (peasycap->audio_read / \ + audio_pages_per_fragment), \ + (peasycap->audio_fill / \ + audio_pages_per_fragment)); + wake_up_interruptible\ + (&(peasycap->wq_audio)); + } + } + + much = PAGE_SIZE - (int)(paudio_buffer->pto -\ + paudio_buffer->pgo); + if (much % 2) + JOT(8, "MISTAKE? much is odd\n"); + + if (false == peasycap->microphone) { + if (much > more) + much = more; + + memcpy(paudio_buffer->pto, p1, much); + p1 += much; + more -= much; + } else { + if (much > (2 * more)) + much = 2 * more; + p2 = (__u8 *)paudio_buffer->pto; + + for (j = 0; j < (much / 2); j++) { + s16 = ((int) *p1) - 128; + *p2 = (0xFF00 & s16) >> 8; + *(p2 + 1) = (0x00FF & s16); + p1++; p2 += 2; + more--; + } + } + (paudio_buffer->pto) += much; + } + } + } else { + JOT(12, "discarding audio samples because " \ + "%i=purb->iso_frame_desc[i].status\n", \ + purb->iso_frame_desc[i].status); + } +} +/*---------------------------------------------------------------------------*/ +/* + * RESUBMIT THIS URB AFTER NO ERROR + */ +/*---------------------------------------------------------------------------*/ +if (peasycap->audio_isoc_streaming) { + rc = usb_submit_urb(purb, GFP_ATOMIC); + if (0 != rc) { + SAY("ERROR: while %i=audio_idle, usb_submit_urb() failed " \ + "with rc:\n", peasycap->audio_idle); + switch (rc) { + case -ENOMEM: { + SAY("ENOMEM\n"); break; + } + case -ENODEV: { + SAY("ENODEV\n"); break; + } + case -ENXIO: { + SAY("ENXIO\n"); break; + } + case -EINVAL: { + SAY("EINVAL\n"); break; + } + case -EAGAIN: { + SAY("EAGAIN\n"); break; + } + case -EFBIG: { + SAY("EFBIG\n"); break; + } + case -EPIPE: { + SAY("EPIPE\n"); break; + } + case -EMSGSIZE: { + SAY("EMSGSIZE\n"); break; + } + default: { + SAY("0x%08X\n", rc); break; + } + } + } +} +return; +} +/*****************************************************************************/ +/*---------------------------------------------------------------------------*/ +/* + * THE AUDIO URBS ARE SUBMITTED AT THIS EARLY STAGE SO THAT IT IS POSSIBLE TO + * STREAM FROM /dev/easysnd1 WITH SIMPLE PROGRAMS SUCH AS cat WHICH DO NOT + * HAVE AN IOCTL INTERFACE. THE VIDEO URBS, BY CONTRAST, MUST BE SUBMITTED + * MUCH LATER: SEE COMMENTS IN FILE easycap_main.c. + */ +/*---------------------------------------------------------------------------*/ +int +easysnd_open(struct inode *inode, struct file *file) +{ +struct usb_interface *pusb_interface; +struct easycap *peasycap; +int subminor, rc; + +JOT(4, "begins.\n"); + +subminor = iminor(inode); + +pusb_interface = usb_find_interface(&easycap_usb_driver, subminor); +if (NULL == pusb_interface) { + SAY("ERROR: pusb_interface is NULL\n"); + SAY("ending unsuccessfully\n"); + return -1; +} +peasycap = usb_get_intfdata(pusb_interface); +if (NULL == peasycap) { + SAY("ERROR: peasycap is NULL\n"); + SAY("ending unsuccessfully\n"); + return -1; +} + +file->private_data = peasycap; + +/*---------------------------------------------------------------------------*/ +/* + * INITIALIZATION. + */ +/*---------------------------------------------------------------------------*/ +JOT(4, "starting initialization\n"); + +if ((struct usb_device *)NULL == peasycap->pusb_device) { + SAY("ERROR: peasycap->pusb_device is NULL\n"); + return -EFAULT; +} else { + JOT(16, "0x%08lX=peasycap->pusb_device\n", \ + (long int)peasycap->pusb_device); +} + +rc = audio_setup(peasycap); +if (0 <= rc) + JOT(8, "audio_setup() returned %i\n", rc); +else + JOT(8, "easysnd open(): ERROR: audio_setup() returned %i\n", rc); + +if ((struct usb_device *)NULL == peasycap->pusb_device) { + SAY("ERROR: peasycap->pusb_device has become NULL\n"); + return -EFAULT; +} +rc = adjust_volume(peasycap, -8192); +if (0 != rc) { + SAY("ERROR: adjust_volume(default) returned %i\n", rc); + return -EFAULT; +} +/*---------------------------------------------------------------------------*/ +if ((struct usb_device *)NULL == peasycap->pusb_device) { + SAY("ERROR: peasycap->pusb_device has become NULL\n"); + return -EFAULT; +} +rc = usb_set_interface(peasycap->pusb_device, peasycap->audio_interface, \ + peasycap->audio_altsetting_on); +JOT(8, "usb_set_interface(.,%i,%i) returned %i\n", peasycap->audio_interface, \ + peasycap->audio_altsetting_on, rc); + +if ((struct usb_device *)NULL == peasycap->pusb_device) { + SAY("ERROR: peasycap->pusb_device has become NULL\n"); + return -EFAULT; +} +rc = wakeup_device(peasycap->pusb_device); +if (0 == rc) + JOT(8, "wakeup_device() returned %i\n", rc); +else + JOT(8, "easysnd open(): ERROR: wakeup_device() returned %i\n", rc); + +if ((struct usb_device *)NULL == peasycap->pusb_device) { + SAY("ERROR: peasycap->pusb_device has become NULL\n"); + return -EFAULT; +} +submit_audio_urbs(peasycap); +peasycap->audio_idle = 0; + +peasycap->timeval1.tv_sec = 0; +peasycap->timeval1.tv_usec = 0; + +JOT(4, "finished initialization\n"); +return 0; +} +/*****************************************************************************/ +int +easysnd_release(struct inode *inode, struct file *file) +{ +struct easycap *peasycap; + +JOT(4, "begins\n"); + +peasycap = (struct easycap *)file->private_data; +if (NULL == peasycap) { + SAY("ERROR: peasycap is NULL.\n"); + return -EFAULT; +} +if (0 != kill_audio_urbs(peasycap)) { + SAY("ERROR: kill_audio_urbs() failed\n"); + return -EFAULT; +} +JOT(4, "ending successfully\n"); +return 0; +} +/*****************************************************************************/ +ssize_t +easysnd_read(struct file *file, char __user *puserspacebuffer, \ + size_t kount, loff_t *poff) +{ +struct timeval timeval; +static struct timeval timeval1; +static long long int audio_bytes, above, below, mean; +struct signed_div_result sdr; +unsigned char *p0; +long int kount1, more, rc, l0, lm; +int fragment; +struct easycap *peasycap; +struct data_buffer *pdata_buffer; +size_t szret; + +/*---------------------------------------------------------------------------*/ +/* + * DO A BLOCKING READ TO TRANSFER DATA TO USER SPACE. + * + ****************************************************************************** + ***** N.B. IF THIS FUNCTION RETURNS 0, NOTHING IS SEEN IN USER SPACE. ****** + ***** THIS CONDITION SIGNIFIES END-OF-FILE. ****** + ****************************************************************************** + */ +/*---------------------------------------------------------------------------*/ + +JOT(8, "===== easysnd_read(): kount=%i, *poff=%i\n", (int)kount, (int)(*poff)); + +peasycap = (struct easycap *)(file->private_data); +if (NULL == peasycap) { + SAY("ERROR in easysnd_read(): peasycap is NULL\n"); + return -EFAULT; +} +/*---------------------------------------------------------------------------*/ +if ((0 > peasycap->audio_read) || \ + (audio_buffer_page_many <= peasycap->audio_read)) { + SAY("ERROR: peasycap->audio_read out of range\n"); + return -EFAULT; +} +pdata_buffer = &peasycap->audio_buffer[peasycap->audio_read]; +if ((struct data_buffer *)NULL == pdata_buffer) { + SAY("ERROR: pdata_buffer is NULL\n"); + return -EFAULT; +} +JOT(12, "before wait, %i=frag read %i=frag fill\n", \ + (peasycap->audio_read / audio_pages_per_fragment), \ + (peasycap->audio_fill / audio_pages_per_fragment)); +fragment = (peasycap->audio_read / audio_pages_per_fragment); +while ((fragment == (peasycap->audio_fill / audio_pages_per_fragment)) || \ + (0 == (PAGE_SIZE - (pdata_buffer->pto - pdata_buffer->pgo)))) { + if (file->f_flags & O_NONBLOCK) { + JOT(16, "returning -EAGAIN as instructed\n"); + return -EAGAIN; + } + rc = wait_event_interruptible(peasycap->wq_audio, \ + (peasycap->audio_idle || peasycap->audio_eof || \ + ((fragment != (peasycap->audio_fill / \ + audio_pages_per_fragment)) && \ + (0 < (PAGE_SIZE - (pdata_buffer->pto - pdata_buffer->pgo)))))); + if (0 != rc) { + SAY("aborted by signal\n"); + return -ERESTARTSYS; + } + if (peasycap->audio_eof) { + JOT(8, "returning 0 because %i=audio_eof\n", \ + peasycap->audio_eof); + kill_audio_urbs(peasycap); + msleep(500); + return 0; + } + if (peasycap->audio_idle) { + JOT(16, "returning 0 because %i=audio_idle\n", \ + peasycap->audio_idle); + return 0; + } + if (!peasycap->audio_isoc_streaming) { + JOT(16, "returning 0 because audio urbs not streaming\n"); + return 0; + } +} +JOT(12, "after wait, %i=frag read %i=frag fill\n", \ + (peasycap->audio_read / audio_pages_per_fragment), \ + (peasycap->audio_fill / audio_pages_per_fragment)); +szret = (size_t)0; +while (fragment == (peasycap->audio_read / audio_pages_per_fragment)) { + if (NULL == pdata_buffer->pgo) { + SAY("ERROR: pdata_buffer->pgo is NULL\n"); + return -EFAULT; + } + if (NULL == pdata_buffer->pto) { + SAY("ERROR: pdata_buffer->pto is NULL\n"); + return -EFAULT; + } + kount1 = PAGE_SIZE - (pdata_buffer->pto - pdata_buffer->pgo); + if (0 > kount1) { + SAY("easysnd_read: MISTAKE: kount1 is negative\n"); + return -ERESTARTSYS; + } + if (!kount1) { + (peasycap->audio_read)++; + if (audio_buffer_page_many <= peasycap->audio_read) + peasycap->audio_read = 0; + JOT(12, "bumped peasycap->audio_read to %i\n", \ + peasycap->audio_read); + + if (fragment != (peasycap->audio_read / \ + audio_pages_per_fragment)) + break; + + if ((0 > peasycap->audio_read) || \ + (audio_buffer_page_many <= peasycap->audio_read)) { + SAY("ERROR: peasycap->audio_read out of range\n"); + return -EFAULT; + } + pdata_buffer = &peasycap->audio_buffer[peasycap->audio_read]; + if ((struct data_buffer *)NULL == pdata_buffer) { + SAY("ERROR: pdata_buffer is NULL\n"); + return -EFAULT; + } + if (NULL == pdata_buffer->pgo) { + SAY("ERROR: pdata_buffer->pgo is NULL\n"); + return -EFAULT; + } + if (NULL == pdata_buffer->pto) { + SAY("ERROR: pdata_buffer->pto is NULL\n"); + return -EFAULT; + } + kount1 = PAGE_SIZE - (pdata_buffer->pto - pdata_buffer->pgo); + } + JOT(12, "ready to send %li bytes\n", (long int) kount1); + JOT(12, "still to send %li bytes\n", (long int) kount); + more = kount1; + if (more > kount) + more = kount; + JOT(12, "agreed to send %li bytes from page %i\n", \ + more, peasycap->audio_read); + if (!more) + break; + +/*---------------------------------------------------------------------------*/ +/* + * ACCUMULATE DYNAMIC-RANGE INFORMATION + */ +/*---------------------------------------------------------------------------*/ + p0 = (unsigned char *)pdata_buffer->pgo; l0 = 0; lm = more/2; + while (l0 < lm) { + SUMMER(p0, &peasycap->audio_sample, &peasycap->audio_niveau, \ + &peasycap->audio_square); l0++; p0 += 2; + } +/*---------------------------------------------------------------------------*/ + rc = copy_to_user(puserspacebuffer, pdata_buffer->pto, more); + if (0 != rc) { + SAY("ERROR: copy_to_user() returned %li\n", rc); + return -EFAULT; + } + *poff += (loff_t)more; + szret += (size_t)more; + pdata_buffer->pto += more; + puserspacebuffer += more; + kount -= (size_t)more; +} +JOT(12, "after read, %i=frag read %i=frag fill\n", \ + (peasycap->audio_read / audio_pages_per_fragment), \ + (peasycap->audio_fill / audio_pages_per_fragment)); +if (kount < 0) { + SAY("MISTAKE: %li=kount %li=szret\n", \ + (long int)kount, (long int)szret); +} +/*---------------------------------------------------------------------------*/ +/* + * CALCULATE DYNAMIC RANGE FOR (VAPOURWARE) AUTOMATIC VOLUME CONTROL + */ +/*---------------------------------------------------------------------------*/ +if (peasycap->audio_sample) { + below = peasycap->audio_sample; + above = peasycap->audio_square; + sdr = signed_div(above, below); + above = sdr.quotient; + mean = peasycap->audio_niveau; + sdr = signed_div(mean, peasycap->audio_sample); + + JOT(12, "%8lli=mean %8lli=meansquare after %lli samples, =>\n", \ + sdr.quotient, above, peasycap->audio_sample); + + sdr = signed_div(above, 32768); + JOT(8, "audio dynamic range is roughly %lli\n", sdr.quotient); +} +/*---------------------------------------------------------------------------*/ +/* + * UPDATE THE AUDIO CLOCK + */ +/*---------------------------------------------------------------------------*/ +do_gettimeofday(&timeval); +if (!peasycap->timeval1.tv_sec) { + audio_bytes = 0; + timeval1 = timeval; + + if (mutex_lock_interruptible(&(peasycap->mutex_timeval1))) + return -ERESTARTSYS; + peasycap->timeval1 = timeval1; + mutex_unlock(&(peasycap->mutex_timeval1)); + sdr.quotient = 192000; +} else { + audio_bytes += (long long int) szret; + below = ((long long int)(1000000)) * \ + ((long long int)(timeval.tv_sec - timeval1.tv_sec)) + \ + (long long int)(timeval.tv_usec - timeval1.tv_usec); + above = 1000000 * ((long long int) audio_bytes); + + if (below) + sdr = signed_div(above, below); + else + sdr.quotient = 192000; +} +JOT(8, "audio streaming at %lli bytes/second\n", sdr.quotient); +if (mutex_lock_interruptible(&(peasycap->mutex_timeval1))) + return -ERESTARTSYS; +peasycap->dnbydt = sdr.quotient; +mutex_unlock(&(peasycap->mutex_timeval1)); + +JOT(8, "returning %li\n", (long int)szret); +return szret; +} +/*****************************************************************************/ +/*---------------------------------------------------------------------------*/ +/* + * SUBMIT ALL AUDIO URBS. + */ +/*---------------------------------------------------------------------------*/ +int +submit_audio_urbs(struct easycap *peasycap) +{ +struct data_urb *pdata_urb; +struct urb *purb; +struct list_head *plist_head; +int j, isbad, m, rc; +int isbuf; + +if ((struct list_head *)NULL == peasycap->purb_audio_head) { + SAY("ERROR: peasycap->urb_audio_head uninitialized\n"); + return -EFAULT; +} +if ((struct usb_device *)NULL == peasycap->pusb_device) { + SAY("ERROR: peasycap->pusb_device is NULL\n"); + return -EFAULT; +} +if (!peasycap->audio_isoc_streaming) { + JOT(4, "initial submission of all audio urbs\n"); + rc = usb_set_interface(peasycap->pusb_device, + peasycap->audio_interface, \ + peasycap->audio_altsetting_on); + JOT(8, "usb_set_interface(.,%i,%i) returned %i\n", \ + peasycap->audio_interface, \ + peasycap->audio_altsetting_on, rc); + + isbad = 0; m = 0; + list_for_each(plist_head, (peasycap->purb_audio_head)) { + pdata_urb = list_entry(plist_head, struct data_urb, list_head); + if (NULL != pdata_urb) { + purb = pdata_urb->purb; + if (NULL != purb) { + isbuf = pdata_urb->isbuf; + + purb->interval = 1; + purb->dev = peasycap->pusb_device; + purb->pipe = \ + usb_rcvisocpipe(peasycap->pusb_device,\ + peasycap->audio_endpointnumber); + purb->transfer_flags = URB_ISO_ASAP; + purb->transfer_buffer = \ + peasycap->audio_isoc_buffer[isbuf].pgo; + purb->transfer_buffer_length = \ + peasycap->audio_isoc_buffer_size; + purb->complete = easysnd_complete; + purb->context = peasycap; + purb->start_frame = 0; + purb->number_of_packets = \ + peasycap->audio_isoc_framesperdesc; + for (j = 0; j < peasycap->\ + audio_isoc_framesperdesc; \ + j++) { + purb->iso_frame_desc[j].offset = j * \ + peasycap->\ + audio_isoc_maxframesize; + purb->iso_frame_desc[j].length = \ + peasycap->\ + audio_isoc_maxframesize; + } + + rc = usb_submit_urb(purb, GFP_KERNEL); + if (0 != rc) { + isbad++; + SAY("ERROR: usb_submit_urb() failed" \ + " for urb with rc:\n"); + switch (rc) { + case -ENOMEM: { + SAY("ENOMEM\n"); break; + } + case -ENODEV: { + SAY("ENODEV\n"); break; + } + case -ENXIO: { + SAY("ENXIO\n"); break; + } + case -EINVAL: { + SAY("EINVAL\n"); break; + } + case -EAGAIN: { + SAY("EAGAIN\n"); break; + } + case -EFBIG: { + SAY("EFBIG\n"); break; + } + case -EPIPE: { + SAY("EPIPE\n"); break; + } + case -EMSGSIZE: { + SAY("EMSGSIZE\n"); break; + } + default: { + SAY("unknown error code %i\n",\ + rc); break; + } + } + } else { + m++; + } + } else { + isbad++; + } + } else { + isbad++; + } + } + if (isbad) { + JOT(4, "attempting cleanup instead of submitting\n"); + list_for_each(plist_head, (peasycap->purb_audio_head)) { + pdata_urb = list_entry(plist_head, struct data_urb, \ + list_head); + if (NULL != pdata_urb) { + purb = pdata_urb->purb; + if (NULL != purb) + usb_kill_urb(purb); + } + } + peasycap->audio_isoc_streaming = 0; + } else { + peasycap->audio_isoc_streaming = 1; + JOT(4, "submitted %i audio urbs\n", m); + } +} else + JOT(4, "already streaming audio urbs\n"); + +return 0; +} +/*****************************************************************************/ +/*---------------------------------------------------------------------------*/ +/* + * KILL ALL AUDIO URBS. + */ +/*---------------------------------------------------------------------------*/ +int +kill_audio_urbs(struct easycap *peasycap) +{ +int m; +struct list_head *plist_head; +struct data_urb *pdata_urb; + +if (peasycap->audio_isoc_streaming) { + if ((struct list_head *)NULL != peasycap->purb_audio_head) { + peasycap->audio_isoc_streaming = 0; + JOT(4, "killing audio urbs\n"); + m = 0; + list_for_each(plist_head, (peasycap->purb_audio_head)) { + pdata_urb = list_entry(plist_head, struct data_urb, + list_head); + if ((struct data_urb *)NULL != pdata_urb) { + if ((struct urb *)NULL != pdata_urb->purb) { + usb_kill_urb(pdata_urb->purb); + m++; + } + } + } + JOT(4, "%i audio urbs killed\n", m); + } else { + SAY("ERROR: peasycap->purb_audio_head is NULL\n"); + return -EFAULT; + } +} else { + JOT(8, "%i=audio_isoc_streaming, no audio urbs killed\n", \ + peasycap->audio_isoc_streaming); +} +return 0; +} +/*****************************************************************************/ diff --git a/drivers/staging/easycap/easycap_sound.h b/drivers/staging/easycap/easycap_sound.h new file mode 100644 index 000000000000..a6e2a9d22319 --- /dev/null +++ b/drivers/staging/easycap/easycap_sound.h @@ -0,0 +1,30 @@ +/***************************************************************************** +* * +* easycap_sound.h * +* * +*****************************************************************************/ +/* + * + * Copyright (C) 2010 R.M. Thomas + * + * + * This 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. + * + * The software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * +*/ +/*****************************************************************************/ +extern struct easycap *peasycap; +extern struct usb_driver easycap_usb_driver; +extern unsigned int audio_buffer_page_many; +extern unsigned int audio_pages_per_fragment; diff --git a/drivers/staging/easycap/easycap_standard.h b/drivers/staging/easycap/easycap_standard.h new file mode 100644 index 000000000000..cadc8d27a856 --- /dev/null +++ b/drivers/staging/easycap/easycap_standard.h @@ -0,0 +1,27 @@ +/***************************************************************************** +* * +* easycap_standard.h * +* * +*****************************************************************************/ +/* + * + * Copyright (C) 2010 R.M. Thomas + * + * + * This 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. + * + * The software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * +*/ +/*****************************************************************************/ +extern struct easycap_standard easycap_standard[]; diff --git a/drivers/staging/easycap/easycap_testcard.c b/drivers/staging/easycap/easycap_testcard.c new file mode 100644 index 000000000000..3c2ce28fab95 --- /dev/null +++ b/drivers/staging/easycap/easycap_testcard.c @@ -0,0 +1,392 @@ +/****************************************************************************** +* * +* easycap_testcard.c * +* * +******************************************************************************/ +/* + * + * Copyright (C) 2010 R.M. Thomas + * + * + * This 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. + * + * The software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * +*/ +/*****************************************************************************/ + +#include "easycap.h" +#include "easycap_debug.h" + +/*****************************************************************************/ +#define TESTCARD_BYTESPERLINE (2 * 1440) +void +easycap_testcard(struct easycap *peasycap, int field_fill) +{ +int total; +int y, u, v, r, g, b; +unsigned char uyvy[4]; + +int i1, line, k, m, n, more, much, barwidth; +unsigned char bfbar[TESTCARD_BYTESPERLINE / 8], *p1, *p2; +struct data_buffer *pfield_buffer; + +JOT(8, "%i=field_fill\n", field_fill); + +if ((TESTCARD_BYTESPERLINE / 2) < peasycap->width) { + SAY("ERROR: image is too wide\n"); + return; +} +if (peasycap->width % 16) { + SAY("ERROR: indivisible image width\n"); + return; +} + +total = 0; +barwidth = (2 * peasycap->width) / 8; + +k = field_fill; +m = 0; +n = 0; + +for (line = 0; line < (peasycap->height / 2); line++) { + for (i1 = 0; i1 < 8; i1++) { + r = (i1 * 256)/8; + g = (i1 * 256)/8; + b = (i1 * 256)/8; + + y = 299*r/1000 + 587*g/1000 + 114*b/1000 ; + u = -147*r/1000 - 289*g/1000 + 436*b/1000 ; u = u + 128; + v = 615*r/1000 - 515*g/1000 - 100*b/1000 ; v = v + 128; + + uyvy[0] = 0xFF & u ; + uyvy[1] = 0xFF & y ; + uyvy[2] = 0xFF & v ; + uyvy[3] = 0xFF & y ; + + p1 = &bfbar[0]; + while (p1 < &bfbar[barwidth]) { + *p1++ = uyvy[0] ; + *p1++ = uyvy[1] ; + *p1++ = uyvy[2] ; + *p1++ = uyvy[3] ; + total += 4; + } + + p1 = &bfbar[0]; + more = barwidth; + + while (more) { + if ((FIELD_BUFFER_SIZE/PAGE_SIZE) <= m) { + SAY("ERROR: bad m reached\n"); + return; + } + if (PAGE_SIZE < n) { + SAY("ERROR: bad n reached\n"); return; + } + + if (0 > more) { + SAY("ERROR: internal fault\n"); + return; + } + + much = PAGE_SIZE - n; + if (much > more) + much = more; + pfield_buffer = &peasycap->field_buffer[k][m]; + p2 = pfield_buffer->pgo + n; + memcpy(p2, p1, much); + + p1 += much; + n += much; + more -= much; + if (PAGE_SIZE == n) { + m++; + n = 0; + } + } + } +} + +JOT(8, "%i=total\n", total); +if (total != peasycap->width * peasycap->height) + SAY("ERROR: wrong number of bytes written: %i\n", total); +return; +} +/*****************************************************************************/ +#if defined(EASYCAP_TESTTONE) +/*----------------------------------------------------------------------------- +THE tones[] ARRAY BELOW IS THE OUTPUT OF THIS PROGRAM, +COMPILED gcc -o prog -lm prog.c +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +#include +#include + +int main(void); +int +main(void) +{ +int i1, i2, last; +double d1, d2; + +last = 1024 - 1; +d1 = 10.0*3.14159265/1024.0; +printf("int tones[2048] =\n{\n"); +for (i1 = 0; i1 <= last; i1++) + { + d2 = ((double)i1) * d1; + i2 = (int)(16384.0*sin(d2)); + + if (last != i1) + { + printf("%6i, ", i2); printf("%6i, ", i2); + if (!((i1 + 1)%5)) printf("\n"); + } + else + { + printf("%6i, ", i2); printf("%6i\n};\n", i2); + } + } +return(0); +} +-----------------------------------------------------------------------------*/ +int tones[2048] = { + 0, 0, 502, 502, 1004, 1004, 1505, 1505, 2005, 2005, + 2503, 2503, 2998, 2998, 3491, 3491, 3980, 3980, 4466, 4466, + 4948, 4948, 5424, 5424, 5896, 5896, 6362, 6362, 6822, 6822, + 7276, 7276, 7723, 7723, 8162, 8162, 8594, 8594, 9018, 9018, + 9434, 9434, 9840, 9840, 10237, 10237, 10625, 10625, 11002, 11002, + 11370, 11370, 11726, 11726, 12072, 12072, 12406, 12406, 12728, 12728, + 13038, 13038, 13337, 13337, 13622, 13622, 13895, 13895, 14155, 14155, + 14401, 14401, 14634, 14634, 14853, 14853, 15058, 15058, 15249, 15249, + 15426, 15426, 15588, 15588, 15735, 15735, 15868, 15868, 15985, 15985, + 16088, 16088, 16175, 16175, 16248, 16248, 16305, 16305, 16346, 16346, + 16372, 16372, 16383, 16383, 16379, 16379, 16359, 16359, 16323, 16323, + 16272, 16272, 16206, 16206, 16125, 16125, 16028, 16028, 15917, 15917, + 15790, 15790, 15649, 15649, 15492, 15492, 15322, 15322, 15136, 15136, + 14937, 14937, 14723, 14723, 14496, 14496, 14255, 14255, 14001, 14001, + 13733, 13733, 13452, 13452, 13159, 13159, 12854, 12854, 12536, 12536, + 12207, 12207, 11866, 11866, 11513, 11513, 11150, 11150, 10777, 10777, + 10393, 10393, 10000, 10000, 9597, 9597, 9185, 9185, 8765, 8765, + 8336, 8336, 7900, 7900, 7456, 7456, 7005, 7005, 6547, 6547, + 6083, 6083, 5614, 5614, 5139, 5139, 4659, 4659, 4175, 4175, + 3687, 3687, 3196, 3196, 2701, 2701, 2204, 2204, 1705, 1705, + 1205, 1205, 703, 703, 201, 201, -301, -301, -803, -803, + -1305, -1305, -1805, -1805, -2304, -2304, -2801, -2801, -3294, -3294, + -3785, -3785, -4272, -4272, -4756, -4756, -5234, -5234, -5708, -5708, + -6176, -6176, -6639, -6639, -7095, -7095, -7545, -7545, -7988, -7988, + -8423, -8423, -8850, -8850, -9268, -9268, -9679, -9679, -10079, -10079, +-10471, -10471, -10853, -10853, -11224, -11224, -11585, -11585, -11935, -11935, +-12273, -12273, -12600, -12600, -12916, -12916, -13219, -13219, -13510, -13510, +-13788, -13788, -14053, -14053, -14304, -14304, -14543, -14543, -14767, -14767, +-14978, -14978, -15175, -15175, -15357, -15357, -15525, -15525, -15678, -15678, +-15817, -15817, -15940, -15940, -16049, -16049, -16142, -16142, -16221, -16221, +-16284, -16284, -16331, -16331, -16364, -16364, -16381, -16381, -16382, -16382, +-16368, -16368, -16339, -16339, -16294, -16294, -16234, -16234, -16159, -16159, +-16069, -16069, -15963, -15963, -15842, -15842, -15707, -15707, -15557, -15557, +-15392, -15392, -15212, -15212, -15018, -15018, -14810, -14810, -14589, -14589, +-14353, -14353, -14104, -14104, -13842, -13842, -13566, -13566, -13278, -13278, +-12977, -12977, -12665, -12665, -12340, -12340, -12003, -12003, -11656, -11656, +-11297, -11297, -10928, -10928, -10548, -10548, -10159, -10159, -9759, -9759, + -9351, -9351, -8934, -8934, -8509, -8509, -8075, -8075, -7634, -7634, + -7186, -7186, -6731, -6731, -6269, -6269, -5802, -5802, -5329, -5329, + -4852, -4852, -4369, -4369, -3883, -3883, -3393, -3393, -2900, -2900, + -2404, -2404, -1905, -1905, -1405, -1405, -904, -904, -402, -402, + 100, 100, 603, 603, 1105, 1105, 1605, 1605, 2105, 2105, + 2602, 2602, 3097, 3097, 3589, 3589, 4078, 4078, 4563, 4563, + 5043, 5043, 5519, 5519, 5990, 5990, 6455, 6455, 6914, 6914, + 7366, 7366, 7811, 7811, 8249, 8249, 8680, 8680, 9102, 9102, + 9516, 9516, 9920, 9920, 10315, 10315, 10701, 10701, 11077, 11077, + 11442, 11442, 11796, 11796, 12139, 12139, 12471, 12471, 12791, 12791, + 13099, 13099, 13395, 13395, 13678, 13678, 13948, 13948, 14205, 14205, + 14449, 14449, 14679, 14679, 14895, 14895, 15098, 15098, 15286, 15286, + 15459, 15459, 15618, 15618, 15763, 15763, 15892, 15892, 16007, 16007, + 16107, 16107, 16191, 16191, 16260, 16260, 16314, 16314, 16353, 16353, + 16376, 16376, 16384, 16384, 16376, 16376, 16353, 16353, 16314, 16314, + 16260, 16260, 16191, 16191, 16107, 16107, 16007, 16007, 15892, 15892, + 15763, 15763, 15618, 15618, 15459, 15459, 15286, 15286, 15098, 15098, + 14895, 14895, 14679, 14679, 14449, 14449, 14205, 14205, 13948, 13948, + 13678, 13678, 13395, 13395, 13099, 13099, 12791, 12791, 12471, 12471, + 12139, 12139, 11796, 11796, 11442, 11442, 11077, 11077, 10701, 10701, + 10315, 10315, 9920, 9920, 9516, 9516, 9102, 9102, 8680, 8680, + 8249, 8249, 7811, 7811, 7366, 7366, 6914, 6914, 6455, 6455, + 5990, 5990, 5519, 5519, 5043, 5043, 4563, 4563, 4078, 4078, + 3589, 3589, 3097, 3097, 2602, 2602, 2105, 2105, 1605, 1605, + 1105, 1105, 603, 603, 100, 100, -402, -402, -904, -904, + -1405, -1405, -1905, -1905, -2404, -2404, -2900, -2900, -3393, -3393, + -3883, -3883, -4369, -4369, -4852, -4852, -5329, -5329, -5802, -5802, + -6269, -6269, -6731, -6731, -7186, -7186, -7634, -7634, -8075, -8075, + -8509, -8509, -8934, -8934, -9351, -9351, -9759, -9759, -10159, -10159, +-10548, -10548, -10928, -10928, -11297, -11297, -11656, -11656, -12003, -12003, +-12340, -12340, -12665, -12665, -12977, -12977, -13278, -13278, -13566, -13566, +-13842, -13842, -14104, -14104, -14353, -14353, -14589, -14589, -14810, -14810, +-15018, -15018, -15212, -15212, -15392, -15392, -15557, -15557, -15707, -15707, +-15842, -15842, -15963, -15963, -16069, -16069, -16159, -16159, -16234, -16234, +-16294, -16294, -16339, -16339, -16368, -16368, -16382, -16382, -16381, -16381, +-16364, -16364, -16331, -16331, -16284, -16284, -16221, -16221, -16142, -16142, +-16049, -16049, -15940, -15940, -15817, -15817, -15678, -15678, -15525, -15525, +-15357, -15357, -15175, -15175, -14978, -14978, -14767, -14767, -14543, -14543, +-14304, -14304, -14053, -14053, -13788, -13788, -13510, -13510, -13219, -13219, +-12916, -12916, -12600, -12600, -12273, -12273, -11935, -11935, -11585, -11585, +-11224, -11224, -10853, -10853, -10471, -10471, -10079, -10079, -9679, -9679, + -9268, -9268, -8850, -8850, -8423, -8423, -7988, -7988, -7545, -7545, + -7095, -7095, -6639, -6639, -6176, -6176, -5708, -5708, -5234, -5234, + -4756, -4756, -4272, -4272, -3785, -3785, -3294, -3294, -2801, -2801, + -2304, -2304, -1805, -1805, -1305, -1305, -803, -803, -301, -301, + 201, 201, 703, 703, 1205, 1205, 1705, 1705, 2204, 2204, + 2701, 2701, 3196, 3196, 3687, 3687, 4175, 4175, 4659, 4659, + 5139, 5139, 5614, 5614, 6083, 6083, 6547, 6547, 7005, 7005, + 7456, 7456, 7900, 7900, 8336, 8336, 8765, 8765, 9185, 9185, + 9597, 9597, 10000, 10000, 10393, 10393, 10777, 10777, 11150, 11150, + 11513, 11513, 11866, 11866, 12207, 12207, 12536, 12536, 12854, 12854, + 13159, 13159, 13452, 13452, 13733, 13733, 14001, 14001, 14255, 14255, + 14496, 14496, 14723, 14723, 14937, 14937, 15136, 15136, 15322, 15322, + 15492, 15492, 15649, 15649, 15790, 15790, 15917, 15917, 16028, 16028, + 16125, 16125, 16206, 16206, 16272, 16272, 16323, 16323, 16359, 16359, + 16379, 16379, 16383, 16383, 16372, 16372, 16346, 16346, 16305, 16305, + 16248, 16248, 16175, 16175, 16088, 16088, 15985, 15985, 15868, 15868, + 15735, 15735, 15588, 15588, 15426, 15426, 15249, 15249, 15058, 15058, + 14853, 14853, 14634, 14634, 14401, 14401, 14155, 14155, 13895, 13895, + 13622, 13622, 13337, 13337, 13038, 13038, 12728, 12728, 12406, 12406, + 12072, 12072, 11726, 11726, 11370, 11370, 11002, 11002, 10625, 10625, + 10237, 10237, 9840, 9840, 9434, 9434, 9018, 9018, 8594, 8594, + 8162, 8162, 7723, 7723, 7276, 7276, 6822, 6822, 6362, 6362, + 5896, 5896, 5424, 5424, 4948, 4948, 4466, 4466, 3980, 3980, + 3491, 3491, 2998, 2998, 2503, 2503, 2005, 2005, 1505, 1505, + 1004, 1004, 502, 502, 0, 0, -502, -502, -1004, -1004, + -1505, -1505, -2005, -2005, -2503, -2503, -2998, -2998, -3491, -3491, + -3980, -3980, -4466, -4466, -4948, -4948, -5424, -5424, -5896, -5896, + -6362, -6362, -6822, -6822, -7276, -7276, -7723, -7723, -8162, -8162, + -8594, -8594, -9018, -9018, -9434, -9434, -9840, -9840, -10237, -10237, +-10625, -10625, -11002, -11002, -11370, -11370, -11726, -11726, -12072, -12072, +-12406, -12406, -12728, -12728, -13038, -13038, -13337, -13337, -13622, -13622, +-13895, -13895, -14155, -14155, -14401, -14401, -14634, -14634, -14853, -14853, +-15058, -15058, -15249, -15249, -15426, -15426, -15588, -15588, -15735, -15735, +-15868, -15868, -15985, -15985, -16088, -16088, -16175, -16175, -16248, -16248, +-16305, -16305, -16346, -16346, -16372, -16372, -16383, -16383, -16379, -16379, +-16359, -16359, -16323, -16323, -16272, -16272, -16206, -16206, -16125, -16125, +-16028, -16028, -15917, -15917, -15790, -15790, -15649, -15649, -15492, -15492, +-15322, -15322, -15136, -15136, -14937, -14937, -14723, -14723, -14496, -14496, +-14255, -14255, -14001, -14001, -13733, -13733, -13452, -13452, -13159, -13159, +-12854, -12854, -12536, -12536, -12207, -12207, -11866, -11866, -11513, -11513, +-11150, -11150, -10777, -10777, -10393, -10393, -10000, -10000, -9597, -9597, + -9185, -9185, -8765, -8765, -8336, -8336, -7900, -7900, -7456, -7456, + -7005, -7005, -6547, -6547, -6083, -6083, -5614, -5614, -5139, -5139, + -4659, -4659, -4175, -4175, -3687, -3687, -3196, -3196, -2701, -2701, + -2204, -2204, -1705, -1705, -1205, -1205, -703, -703, -201, -201, + 301, 301, 803, 803, 1305, 1305, 1805, 1805, 2304, 2304, + 2801, 2801, 3294, 3294, 3785, 3785, 4272, 4272, 4756, 4756, + 5234, 5234, 5708, 5708, 6176, 6176, 6639, 6639, 7095, 7095, + 7545, 7545, 7988, 7988, 8423, 8423, 8850, 8850, 9268, 9268, + 9679, 9679, 10079, 10079, 10471, 10471, 10853, 10853, 11224, 11224, + 11585, 11585, 11935, 11935, 12273, 12273, 12600, 12600, 12916, 12916, + 13219, 13219, 13510, 13510, 13788, 13788, 14053, 14053, 14304, 14304, + 14543, 14543, 14767, 14767, 14978, 14978, 15175, 15175, 15357, 15357, + 15525, 15525, 15678, 15678, 15817, 15817, 15940, 15940, 16049, 16049, + 16142, 16142, 16221, 16221, 16284, 16284, 16331, 16331, 16364, 16364, + 16381, 16381, 16382, 16382, 16368, 16368, 16339, 16339, 16294, 16294, + 16234, 16234, 16159, 16159, 16069, 16069, 15963, 15963, 15842, 15842, + 15707, 15707, 15557, 15557, 15392, 15392, 15212, 15212, 15018, 15018, + 14810, 14810, 14589, 14589, 14353, 14353, 14104, 14104, 13842, 13842, + 13566, 13566, 13278, 13278, 12977, 12977, 12665, 12665, 12340, 12340, + 12003, 12003, 11656, 11656, 11297, 11297, 10928, 10928, 10548, 10548, + 10159, 10159, 9759, 9759, 9351, 9351, 8934, 8934, 8509, 8509, + 8075, 8075, 7634, 7634, 7186, 7186, 6731, 6731, 6269, 6269, + 5802, 5802, 5329, 5329, 4852, 4852, 4369, 4369, 3883, 3883, + 3393, 3393, 2900, 2900, 2404, 2404, 1905, 1905, 1405, 1405, + 904, 904, 402, 402, -100, -100, -603, -603, -1105, -1105, + -1605, -1605, -2105, -2105, -2602, -2602, -3097, -3097, -3589, -3589, + -4078, -4078, -4563, -4563, -5043, -5043, -5519, -5519, -5990, -5990, + -6455, -6455, -6914, -6914, -7366, -7366, -7811, -7811, -8249, -8249, + -8680, -8680, -9102, -9102, -9516, -9516, -9920, -9920, -10315, -10315, +-10701, -10701, -11077, -11077, -11442, -11442, -11796, -11796, -12139, -12139, +-12471, -12471, -12791, -12791, -13099, -13099, -13395, -13395, -13678, -13678, +-13948, -13948, -14205, -14205, -14449, -14449, -14679, -14679, -14895, -14895, +-15098, -15098, -15286, -15286, -15459, -15459, -15618, -15618, -15763, -15763, +-15892, -15892, -16007, -16007, -16107, -16107, -16191, -16191, -16260, -16260, +-16314, -16314, -16353, -16353, -16376, -16376, -16383, -16383, -16376, -16376, +-16353, -16353, -16314, -16314, -16260, -16260, -16191, -16191, -16107, -16107, +-16007, -16007, -15892, -15892, -15763, -15763, -15618, -15618, -15459, -15459, +-15286, -15286, -15098, -15098, -14895, -14895, -14679, -14679, -14449, -14449, +-14205, -14205, -13948, -13948, -13678, -13678, -13395, -13395, -13099, -13099, +-12791, -12791, -12471, -12471, -12139, -12139, -11796, -11796, -11442, -11442, +-11077, -11077, -10701, -10701, -10315, -10315, -9920, -9920, -9516, -9516, + -9102, -9102, -8680, -8680, -8249, -8249, -7811, -7811, -7366, -7366, + -6914, -6914, -6455, -6455, -5990, -5990, -5519, -5519, -5043, -5043, + -4563, -4563, -4078, -4078, -3589, -3589, -3097, -3097, -2602, -2602, + -2105, -2105, -1605, -1605, -1105, -1105, -603, -603, -100, -100, + 402, 402, 904, 904, 1405, 1405, 1905, 1905, 2404, 2404, + 2900, 2900, 3393, 3393, 3883, 3883, 4369, 4369, 4852, 4852, + 5329, 5329, 5802, 5802, 6269, 6269, 6731, 6731, 7186, 7186, + 7634, 7634, 8075, 8075, 8509, 8509, 8934, 8934, 9351, 9351, + 9759, 9759, 10159, 10159, 10548, 10548, 10928, 10928, 11297, 11297, + 11656, 11656, 12003, 12003, 12340, 12340, 12665, 12665, 12977, 12977, + 13278, 13278, 13566, 13566, 13842, 13842, 14104, 14104, 14353, 14353, + 14589, 14589, 14810, 14810, 15018, 15018, 15212, 15212, 15392, 15392, + 15557, 15557, 15707, 15707, 15842, 15842, 15963, 15963, 16069, 16069, + 16159, 16159, 16234, 16234, 16294, 16294, 16339, 16339, 16368, 16368, + 16382, 16382, 16381, 16381, 16364, 16364, 16331, 16331, 16284, 16284, + 16221, 16221, 16142, 16142, 16049, 16049, 15940, 15940, 15817, 15817, + 15678, 15678, 15525, 15525, 15357, 15357, 15175, 15175, 14978, 14978, + 14767, 14767, 14543, 14543, 14304, 14304, 14053, 14053, 13788, 13788, + 13510, 13510, 13219, 13219, 12916, 12916, 12600, 12600, 12273, 12273, + 11935, 11935, 11585, 11585, 11224, 11224, 10853, 10853, 10471, 10471, + 10079, 10079, 9679, 9679, 9268, 9268, 8850, 8850, 8423, 8423, + 7988, 7988, 7545, 7545, 7095, 7095, 6639, 6639, 6176, 6176, + 5708, 5708, 5234, 5234, 4756, 4756, 4272, 4272, 3785, 3785, + 3294, 3294, 2801, 2801, 2304, 2304, 1805, 1805, 1305, 1305, + 803, 803, 301, 301, -201, -201, -703, -703, -1205, -1205, + -1705, -1705, -2204, -2204, -2701, -2701, -3196, -3196, -3687, -3687, + -4175, -4175, -4659, -4659, -5139, -5139, -5614, -5614, -6083, -6083, + -6547, -6547, -7005, -7005, -7456, -7456, -7900, -7900, -8336, -8336, + -8765, -8765, -9185, -9185, -9597, -9597, -10000, -10000, -10393, -10393, +-10777, -10777, -11150, -11150, -11513, -11513, -11866, -11866, -12207, -12207, +-12536, -12536, -12854, -12854, -13159, -13159, -13452, -13452, -13733, -13733, +-14001, -14001, -14255, -14255, -14496, -14496, -14723, -14723, -14937, -14937, +-15136, -15136, -15322, -15322, -15492, -15492, -15649, -15649, -15790, -15790, +-15917, -15917, -16028, -16028, -16125, -16125, -16206, -16206, -16272, -16272, +-16323, -16323, -16359, -16359, -16379, -16379, -16383, -16383, -16372, -16372, +-16346, -16346, -16305, -16305, -16248, -16248, -16175, -16175, -16088, -16088, +-15985, -15985, -15868, -15868, -15735, -15735, -15588, -15588, -15426, -15426, +-15249, -15249, -15058, -15058, -14853, -14853, -14634, -14634, -14401, -14401, +-14155, -14155, -13895, -13895, -13622, -13622, -13337, -13337, -13038, -13038, +-12728, -12728, -12406, -12406, -12072, -12072, -11726, -11726, -11370, -11370, +-11002, -11002, -10625, -10625, -10237, -10237, -9840, -9840, -9434, -9434, + -9018, -9018, -8594, -8594, -8162, -8162, -7723, -7723, -7276, -7276, + -6822, -6822, -6362, -6362, -5896, -5896, -5424, -5424, -4948, -4948, + -4466, -4466, -3980, -3980, -3491, -3491, -2998, -2998, -2503, -2503, + -2005, -2005, -1505, -1505, -1004, -1004, -502, -502 +}; +/*****************************************************************************/ +void +easysnd_testtone(struct easycap *peasycap, int audio_fill) +{ +int i1; +unsigned char *p2; +struct data_buffer *paudio_buffer; + +JOT(8, "%i=audio_fill\n", audio_fill); + +paudio_buffer = &peasycap->audio_buffer[audio_fill]; + +p2 = (unsigned char *)(paudio_buffer->pgo); +for (i1 = 0; i1 < PAGE_SIZE; i1 += 4, p2 += 4) { + *p2 = (unsigned char) (0x00FF & tones[i1/2]); + *(p2 + 1) = (unsigned char)((0xFF00 & tones[i1/2]) >> 8); + *(p2 + 2) = (unsigned char) (0x00FF & tones[i1/2 + 1]); + *(p2 + 3) = (unsigned char)((0xFF00 & tones[i1/2 + 1]) >> 8); + } +return; +} +#endif /*EASYCAP_TESTTONE*/ +/*****************************************************************************/ From 4f62e69b2b346053e581b11d7374c5082833a6a9 Mon Sep 17 00:00:00 2001 From: Pavan Savoy Date: Mon, 24 May 2010 19:44:09 +0530 Subject: [PATCH 075/523] Staging: Update TI-ST's TODO Update the TODO of TI-ST to make sure it reflects current list of activities that need to be done. Also point it out to the user-space app code relevant to it. Signed-off-by: Pavan Savoy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ti-st/TODO | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/staging/ti-st/TODO b/drivers/staging/ti-st/TODO index 2c4fe583901d..26f3ae3f2dcd 100644 --- a/drivers/staging/ti-st/TODO +++ b/drivers/staging/ti-st/TODO @@ -2,9 +2,16 @@ TODO: 1. A per-device/tty port context required to support multiple devices on same platform. +Plan: Each BT, FM and GPS device would be a platform-device with its platform-data +mentioning which of the ST device it wants to attach itself onto. -2. REMOVE the sysfs entry PID passing mechanism, since there should -be a better way to request user-space to install line discipline. +There by each of the ST device which is also a platform device upon receiving +a st_register() would know whether the registration from BT/FM or GPS was intended for it. + +2. Improve upon the way requirement of line discipline is communicated to +user-space, The current user-space application which open/installs ldisc +as and when required can be found at, +http://git.omapzoom.org/?pÿatform/hardware/ti/omap3.git;aÿob;fÿ_st/uim/uim.c;ha16c2c2b5085eb54a1bbc7096d779d7594eb11;hbìlair 3. Re-view/Re-work on the locking. From b38fc2d965c3182c1855f868144a41a137e07983 Mon Sep 17 00:00:00 2001 From: Naveen Jain Date: Wed, 9 Jun 2010 03:45:32 -0500 Subject: [PATCH 076/523] Staging: ti-st: cleanup sysfs code Remove the older way of communicating with user-space daemon UIM. The older way involved creating of a new kobj and pid sysfs file under it, and sending signal using that pid. Now we communicate via rfkill to user-space UIM. Background: UIM is the user-space daemon which upon notification from ldisc driver, opens the tty, sets default baud and then installs (tiocsetd) the ldisc. Signed-off-by: Naveen Jain Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ti-st/st_kim.c | 49 +++++----------------------------- drivers/staging/ti-st/st_kim.h | 4 --- 2 files changed, 6 insertions(+), 47 deletions(-) diff --git a/drivers/staging/ti-st/st_kim.c b/drivers/staging/ti-st/st_kim.c index 98cbabba3844..cfba5f88abe1 100644 --- a/drivers/staging/ti-st/st_kim.c +++ b/drivers/staging/ti-st/st_kim.c @@ -55,7 +55,6 @@ static struct platform_driver kim_platform_driver = { }, }; -#ifndef LEGACY_RFKILL_SUPPORT static ssize_t show_pid(struct device *dev, struct device_attribute *attr, char *buf); static ssize_t store_pid(struct device *dev, struct device_attribute @@ -80,12 +79,11 @@ static struct attribute *uim_attrs[] = { static struct attribute_group uim_attr_grp = { .attrs = uim_attrs, }; -#else + static int kim_toggle_radio(void*, bool); static const struct rfkill_ops kim_rfkill_ops = { .set_block = kim_toggle_radio, }; -#endif /* LEGACY_RFKILL_SUPPORT */ /* strings to be used for rfkill entries and by * ST Core to be used for sysfs debug entry @@ -436,13 +434,11 @@ long st_kim_start(void) pr_info(" %s", __func__); do { -#ifdef LEGACY_RFKILL_SUPPORT /* TODO: this is only because rfkill sub-system * doesn't send events to user-space if the state * isn't changed */ rfkill_set_hw_state(kim_gdata->rfkill[ST_BT], 1); -#endif /* Configure BT nShutdown to HIGH state */ gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_LOW); mdelay(5); /* FIXME: a proper toggle */ @@ -450,7 +446,7 @@ long st_kim_start(void) mdelay(100); /* re-initialize the completion */ INIT_COMPLETION(kim_gdata->ldisc_installed); -#ifndef LEGACY_RFKILL_SUPPORT +#if 0 /* older way of signalling user-space UIM */ /* send signal to UIM */ err = kill_pid(find_get_pid(kim_gdata->uim_pid), SIGUSR2, 0); if (err != 0) { @@ -458,10 +454,9 @@ long st_kim_start(void) err = ST_ERR_FAILURE; continue; } -#else +#endif /* unblock and send event to UIM via /dev/rfkill */ rfkill_set_hw_state(kim_gdata->rfkill[ST_BT], 0); -#endif /* wait for ldisc to be installed */ err = wait_for_completion_timeout(&kim_gdata->ldisc_installed, msecs_to_jiffies(LDISC_TIME)); @@ -491,17 +486,16 @@ long st_kim_stop(void) long err = ST_SUCCESS; INIT_COMPLETION(kim_gdata->ldisc_installed); -#ifndef LEGACY_RFKILL_SUPPORT +#if 0 /* older way of signalling user-space UIM */ /* send signal to UIM */ err = kill_pid(find_get_pid(kim_gdata->uim_pid), SIGUSR2, 1); if (err != 0) { pr_err("sending SIGUSR2 to uim failed %ld", err); return ST_ERR_FAILURE; } -#else +#endif /* set BT rfkill to be blocked */ err = rfkill_set_hw_state(kim_gdata->rfkill[ST_BT], 1); -#endif /* wait for ldisc to be un-installed */ err = wait_for_completion_timeout(&kim_gdata->ldisc_installed, @@ -523,7 +517,6 @@ long st_kim_stop(void) /**********************************************************************/ /* functions called from subsystems */ -#ifndef LEGACY_RFKILL_SUPPORT /* called when sysfs entry is written to */ static ssize_t store_pid(struct device *dev, struct device_attribute *devattr, char *buf, size_t count) @@ -551,8 +544,6 @@ static ssize_t show_list(struct device *dev, struct device_attribute return strlen(buf); } -#else /* LEGACY_RFKILL_SUPPORT */ - /* function called from rfkill subsystem, when someone from * user space would write 0/1 on the sysfs entry * /sys/class/rfkill/rfkill0,1,3/state @@ -580,8 +571,6 @@ static int kim_toggle_radio(void *data, bool blocked) return ST_SUCCESS; } -#endif /* LEGACY_RFKILL_SUPPORT */ - void st_kim_ref(struct st_data_s **core_data) { *core_data = kim_gdata->core_data; @@ -639,30 +628,12 @@ static int kim_probe(struct platform_device *pdev) return status; } } -#ifndef LEGACY_RFKILL_SUPPORT - /* pdev to contain BT, FM and GPS enable/N-Shutdown GPIOs - * execute request_gpio, set output direction - */ - kim_gdata->kim_kobj = kobject_create_and_add("uim", NULL); - /* create the sysfs entry for UIM to put in pid */ - if (sysfs_create_group(kim_gdata->kim_kobj, &uim_attr_grp)) { - pr_err(" sysfs entry creation failed"); - kobject_put(kim_gdata->kim_kobj); - /* free requested GPIOs and fail probe */ - for (proto = ST_BT; proto < ST_MAX; proto++) { - if (gpios[proto] != -1) - gpio_free(gpios[proto]); - } - return -1; /* fail insmod */ - } - pr_info(" sysfs entry created "); -#endif /* get reference of pdev for request_firmware */ kim_gdata->kim_pdev = pdev; init_completion(&kim_gdata->kim_rcvd); init_completion(&kim_gdata->ldisc_installed); -#ifdef LEGACY_RFKILL_SUPPORT + for (proto = 0; (proto < ST_MAX) && (gpios[proto] != -1); proto++) { /* TODO: should all types be rfkill_type_bt ? */ kim_gdata->rf_protos[proto] = proto; @@ -685,7 +656,6 @@ static int kim_probe(struct platform_device *pdev) } pr_info("rfkill entry created for %ld", gpios[proto]); } -#endif return ST_SUCCESS; } @@ -701,18 +671,11 @@ static int kim_remove(struct platform_device *pdev) * nShutdown gpio from the system */ gpio_free(gpios[proto]); -#ifdef LEGACY_RFKILL_SUPPORT rfkill_unregister(kim_gdata->rfkill[proto]); rfkill_destroy(kim_gdata->rfkill[proto]); kim_gdata->rfkill[proto] = NULL; -#endif } pr_info("kim: GPIO Freed"); -#ifndef LEGACY_RFKILL_SUPPORT - /* delete the sysfs entries */ - sysfs_remove_group(kim_gdata->kim_kobj, &uim_attr_grp); - kobject_put(kim_gdata->kim_kobj); -#endif kim_gdata->kim_pdev = NULL; st_core_exit(kim_gdata->core_data); return ST_SUCCESS; diff --git a/drivers/staging/ti-st/st_kim.h b/drivers/staging/ti-st/st_kim.h index ff3270ec7847..49c42aedb456 100644 --- a/drivers/staging/ti-st/st_kim.h +++ b/drivers/staging/ti-st/st_kim.h @@ -48,7 +48,6 @@ * devices are created for the 3 gpios * that ST has requested */ -#define LEGACY_RFKILL_SUPPORT /* * header file for ST provided by KIM */ @@ -60,15 +59,12 @@ struct kim_data_s { char resp_buffer[30]; const struct firmware *fw_entry; long gpios[ST_MAX]; - struct kobject *kim_kobj; /* used by kim_int_recv to validate fw response */ unsigned long rx_state; unsigned long rx_count; struct sk_buff *rx_skb; -#ifdef LEGACY_RFKILL_SUPPORT struct rfkill *rfkill[ST_MAX]; enum proto_type rf_protos[ST_MAX]; -#endif struct st_data_s *core_data; }; From e2a53282859fab0e428a243cbe9ca8d727d9d840 Mon Sep 17 00:00:00 2001 From: Naveen Jain Date: Wed, 9 Jun 2010 03:45:33 -0500 Subject: [PATCH 077/523] Staging: ti-st: add version info to sysfs Add version information to be available under the sysfs group for kim. Signed-off-by: Naveen Jain Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ti-st/st_kim.c | 40 +++++++++++++++++++++++++++++----- drivers/staging/ti-st/st_kim.h | 11 ++++++++++ 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/drivers/staging/ti-st/st_kim.c b/drivers/staging/ti-st/st_kim.c index cfba5f88abe1..d015ad3c4600 100644 --- a/drivers/staging/ti-st/st_kim.c +++ b/drivers/staging/ti-st/st_kim.c @@ -56,12 +56,13 @@ static struct platform_driver kim_platform_driver = { }; static ssize_t show_pid(struct device *dev, struct device_attribute - *attr, char *buf); + *attr, char *buf); static ssize_t store_pid(struct device *dev, struct device_attribute - *devattr, char *buf, size_t count); + *devattr, char *buf, size_t count); static ssize_t show_list(struct device *dev, struct device_attribute - *attr, char *buf); - + *attr, char *buf); +static ssize_t show_version(struct device *dev, struct device_attribute + *attr, char *buf); /* structures specific for sysfs entries */ static struct kobj_attribute pid_attr = __ATTR(pid, 0644, (void *)show_pid, (void *)store_pid); @@ -69,10 +70,14 @@ __ATTR(pid, 0644, (void *)show_pid, (void *)store_pid); static struct kobj_attribute list_protocols = __ATTR(protocols, 0444, (void *)show_list, NULL); +static struct kobj_attribute chip_version = +__ATTR(version, 0444, (void *)show_version, NULL); + static struct attribute *uim_attrs[] = { &pid_attr.attr, /* add more debug sysfs entries */ &list_protocols.attr, + &chip_version.attr, NULL, }; @@ -251,7 +256,8 @@ static long read_local_version(char *bts_scr_name) } version = - MAKEWORD(kim_gdata->resp_buffer[13], kim_gdata->resp_buffer[14]); + MAKEWORD(kim_gdata->resp_buffer[13], + kim_gdata->resp_buffer[14]); chip = (version & 0x7C00) >> 10; min_ver = (version & 0x007F); maj_ver = (version & 0x0380) >> 7; @@ -260,6 +266,13 @@ static long read_local_version(char *bts_scr_name) maj_ver |= 0x0008; sprintf(bts_scr_name, "TIInit_%d.%d.%d.bts", chip, maj_ver, min_ver); + + /* to be accessed later via sysfs entry */ + kim_gdata->version.full = version; + kim_gdata->version.chip = chip; + kim_gdata->version.maj_ver = maj_ver; + kim_gdata->version.min_ver = min_ver; + pr_info("%s", bts_scr_name); return ST_SUCCESS; } @@ -516,6 +529,16 @@ long st_kim_stop(void) /**********************************************************************/ /* functions called from subsystems */ +/* called when sysfs entry is read from */ + +static ssize_t show_version(struct device *dev, struct device_attribute + *attr, char *buf) +{ + sprintf(buf, "%04X %d.%d.%d", kim_gdata->version.full, + kim_gdata->version.chip, kim_gdata->version.maj_ver, + kim_gdata->version.min_ver); + return strlen(buf); +} /* called when sysfs entry is written to */ static ssize_t store_pid(struct device *dev, struct device_attribute @@ -656,6 +679,12 @@ static int kim_probe(struct platform_device *pdev) } pr_info("rfkill entry created for %ld", gpios[proto]); } + + if (sysfs_create_group(&pdev->dev.kobj, &uim_attr_grp)) { + pr_err(" sysfs entry creation failed"); + return -1; + } + pr_info(" sysfs entries created "); return ST_SUCCESS; } @@ -676,6 +705,7 @@ static int kim_remove(struct platform_device *pdev) kim_gdata->rfkill[proto] = NULL; } pr_info("kim: GPIO Freed"); + sysfs_remove_group(&pdev->dev.kobj, &uim_attr_grp); kim_gdata->kim_pdev = NULL; st_core_exit(kim_gdata->core_data); return ST_SUCCESS; diff --git a/drivers/staging/ti-st/st_kim.h b/drivers/staging/ti-st/st_kim.h index 49c42aedb456..a5ea8d7c680c 100644 --- a/drivers/staging/ti-st/st_kim.h +++ b/drivers/staging/ti-st/st_kim.h @@ -48,6 +48,16 @@ * devices are created for the 3 gpios * that ST has requested */ + +/* chip version storage + */ +struct chip_version { + unsigned short full; + unsigned short chip; + unsigned short min_ver; + unsigned short maj_ver; +}; + /* * header file for ST provided by KIM */ @@ -66,6 +76,7 @@ struct kim_data_s { struct rfkill *rfkill[ST_MAX]; enum proto_type rf_protos[ST_MAX]; struct st_data_s *core_data; + struct chip_version version; }; long st_kim_start(void); From 36e574fed5578aeee0ce4c7359bc17cc0b8e0b57 Mon Sep 17 00:00:00 2001 From: Naveen Jain Date: Wed, 9 Jun 2010 07:20:40 -0500 Subject: [PATCH 078/523] Staging: ti-st: fix protocol counting Older mechanism of counting the number of protocols registered with ST was slow, in-efficient. It used to check the protocol data for NULL for each registration/unregistration. With this change, counting protocols in maintained by a single counter protos_registered. Counting protocols is not just for debug purposes Signed-off-by: Naveen Jain Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ti-st/st_core.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/staging/ti-st/st_core.c b/drivers/staging/ti-st/st_core.c index 4e93694e1c21..a49236903375 100644 --- a/drivers/staging/ti-st/st_core.c +++ b/drivers/staging/ti-st/st_core.c @@ -584,10 +584,11 @@ void kim_st_list_protocols(struct st_data_s *st_gdata, char *buf) } sprintf(buf, "%s\n", buf); #else /* limited info */ - sprintf(buf, "BT=%c\nFM=%c\nGPS=%c\n", - st_gdata->list[ST_BT] != NULL ? 'R' : 'U', - st_gdata->list[ST_FM] != NULL ? 'R' : 'U', - st_gdata->list[ST_GPS] != NULL ? 'R' : 'U'); + sprintf(buf, "[%d]\nBT=%c\nFM=%c\nGPS=%c\n", + st_gdata->protos_registered, + st_gdata->list[ST_BT] != NULL ? 'R' : 'U', + st_gdata->list[ST_FM] != NULL ? 'R' : 'U', + st_gdata->list[ST_GPS] != NULL ? 'R' : 'U'); #endif spin_unlock_irqrestore(&st_gdata->lock, flags); } @@ -630,6 +631,7 @@ long st_register(struct st_proto_s *new_proto) st_kim_chip_toggle(new_proto->type, KIM_GPIO_ACTIVE); st_gdata->list[new_proto->type] = new_proto; + st_gdata->protos_registered++; new_proto->write = st_write; set_bit(ST_REG_PENDING, &st_gdata->st_state); @@ -673,7 +675,6 @@ long st_register(struct st_proto_s *new_proto) if ((st_gdata->protos_registered != ST_EMPTY) && (test_bit(ST_REG_PENDING, &st_gdata->st_state))) { pr_info(" call reg complete callback "); - st_gdata->protos_registered++; st_reg_complete(st_gdata, ST_SUCCESS); } clear_bit(ST_REG_PENDING, &st_gdata->st_state); @@ -689,6 +690,7 @@ long st_register(struct st_proto_s *new_proto) spin_lock_irqsave(&st_gdata->lock, flags); st_gdata->list[new_proto->type] = new_proto; + st_gdata->protos_registered++; new_proto->write = st_write; spin_unlock_irqrestore(&st_gdata->lock, flags); return err; @@ -712,6 +714,7 @@ long st_register(struct st_proto_s *new_proto) break; } st_gdata->list[new_proto->type] = new_proto; + st_gdata->protos_registered++; new_proto->write = st_write; /* lock already held before entering else */ From a1dd52afa94238d361d70502b219409ea115e235 Mon Sep 17 00:00:00 2001 From: Nitin Gupta Date: Tue, 1 Jun 2010 13:31:23 +0530 Subject: [PATCH 079/523] Staging: ramzswap: Support generic I/O requests Currently, ramzwap devices (/dev/ramzswapX) can only be used as swap disks since it was hard-coded to consider only the first request in bio vector. Now, we iterate over all the segments in an incoming bio which allows us to handle all kinds of I/O requests. ramzswap devices can still handle PAGE_SIZE aligned and multiple of PAGE_SIZE sized I/O requests only. To ensure that we get always get such requests only, we set following request_queue attributes to PAGE_SIZE: - physical_block_size - logical_block_size - io_min - io_opt Note: physical and logical block sizes were already set equal to PAGE_SIZE and that seems to be sufficient to get PAGE_SIZE aligned I/O. Since we are no longer limited to handling swap requests only, the next few patches rename ramzswap to zram. So, the devices will then be called /dev/zram{0, 1, 2, ...} Usage/Examples: 1) Use as /tmp storage - mkfs.ext4 /dev/zram0 - mount /dev/zram0 /tmp 2) Use as swap: - mkswap /dev/zram0 - swapon /dev/zram0 -p 10 # give highest priority to zram0 Performance: - I/O benchamark done with 'dd' command. Details can be found here: http://code.google.com/p/compcache/wiki/zramperf Summary: - Maximum read speed (approx): - ram disk: 1200 MB/sec - zram disk: 600 MB/sec - Maximum write speed (approx): - ram disk: 500 MB/sec - zram disk: 160 MB/sec Issues: - Double caching: We can potentially waste memory by having two copies of a page -- one in page cache (uncompress) and second in the device memory (compressed). However, during reclaim, clean page cache pages are quickly freed, so this does not seem to be a big problem. - Stale data: Not all filesystems support issuing 'discard' requests to underlying block devices. So, if such filesystems are used over zram devices, we can accumulate lot of stale data in memory. Even for filesystems to do support discard (example, ext4), we need to see how effective it is. - Scalability: There is only one (per-device) de/compression buffer stats. This can lead to significant contention, especially when used for generic (non-swap) purposes. Signed-off-by: Nitin Gupta Acked-by: Pekka Enberg Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ramzswap/ramzswap_drv.c | 332 +++++++++++------------- drivers/staging/ramzswap/ramzswap_drv.h | 3 +- 2 files changed, 152 insertions(+), 183 deletions(-) diff --git a/drivers/staging/ramzswap/ramzswap_drv.c b/drivers/staging/ramzswap/ramzswap_drv.c index d14bf9129e36..7b5cc61b3d69 100644 --- a/drivers/staging/ramzswap/ramzswap_drv.c +++ b/drivers/staging/ramzswap/ramzswap_drv.c @@ -101,20 +101,6 @@ static void ramzswap_set_disksize(struct ramzswap *rzs, size_t totalram_bytes) rzs->disksize &= PAGE_MASK; } -/* - * Swap header (1st page of swap device) contains information - * about a swap file/partition. Prepare such a header for the - * given ramzswap device so that swapon can identify it as a - * swap partition. - */ -static void setup_swap_header(struct ramzswap *rzs, union swap_header *s) -{ - s->info.version = 1; - s->info.last_page = (rzs->disksize >> PAGE_SHIFT) - 1; - s->info.nr_badpages = 0; - memcpy(s->magic.magic, "SWAPSPACE2", 10); -} - static void ramzswap_ioctl_get_stats(struct ramzswap *rzs, struct ramzswap_ioctl_stats *s) { @@ -202,31 +188,22 @@ out: rzs->table[index].offset = 0; } -static int handle_zero_page(struct bio *bio) +static void handle_zero_page(struct page *page) { void *user_mem; - struct page *page = bio->bi_io_vec[0].bv_page; user_mem = kmap_atomic(page, KM_USER0); memset(user_mem, 0, PAGE_SIZE); kunmap_atomic(user_mem, KM_USER0); flush_dcache_page(page); - - set_bit(BIO_UPTODATE, &bio->bi_flags); - bio_endio(bio, 0); - return 0; } -static int handle_uncompressed_page(struct ramzswap *rzs, struct bio *bio) +static void handle_uncompressed_page(struct ramzswap *rzs, + struct page *page, u32 index) { - u32 index; - struct page *page; unsigned char *user_mem, *cmem; - page = bio->bi_io_vec[0].bv_page; - index = bio->bi_sector >> SECTORS_PER_PAGE_SHIFT; - user_mem = kmap_atomic(page, KM_USER0); cmem = kmap_atomic(rzs->table[index].page, KM_USER1) + rzs->table[index].offset; @@ -236,80 +213,72 @@ static int handle_uncompressed_page(struct ramzswap *rzs, struct bio *bio) kunmap_atomic(cmem, KM_USER1); flush_dcache_page(page); - - set_bit(BIO_UPTODATE, &bio->bi_flags); - bio_endio(bio, 0); - return 0; -} - -/* - * Called when request page is not present in ramzswap. - * This is an attempt to read before any previous write - * to this location - this happens due to readahead when - * swap device is read from user-space (e.g. during swapon) - */ -static int handle_ramzswap_fault(struct ramzswap *rzs, struct bio *bio) -{ - pr_debug("Read before write on swap device: " - "sector=%lu, size=%u, offset=%u\n", - (ulong)(bio->bi_sector), bio->bi_size, - bio->bi_io_vec[0].bv_offset); - - /* Do nothing. Just return success */ - set_bit(BIO_UPTODATE, &bio->bi_flags); - bio_endio(bio, 0); - return 0; } static int ramzswap_read(struct ramzswap *rzs, struct bio *bio) { - int ret; + + int i; u32 index; - size_t clen; - struct page *page; - struct zobj_header *zheader; - unsigned char *user_mem, *cmem; + struct bio_vec *bvec; rzs_stat64_inc(rzs, &rzs->stats.num_reads); - page = bio->bi_io_vec[0].bv_page; index = bio->bi_sector >> SECTORS_PER_PAGE_SHIFT; + bio_for_each_segment(bvec, bio, i) { + int ret; + size_t clen; + struct page *page; + struct zobj_header *zheader; + unsigned char *user_mem, *cmem; - if (rzs_test_flag(rzs, index, RZS_ZERO)) - return handle_zero_page(bio); + page = bvec->bv_page; - /* Requested page is not present in compressed area */ - if (!rzs->table[index].page) - return handle_ramzswap_fault(rzs, bio); + if (rzs_test_flag(rzs, index, RZS_ZERO)) { + handle_zero_page(page); + continue; + } - /* Page is stored uncompressed since it's incompressible */ - if (unlikely(rzs_test_flag(rzs, index, RZS_UNCOMPRESSED))) - return handle_uncompressed_page(rzs, bio); + /* Requested page is not present in compressed area */ + if (unlikely(!rzs->table[index].page)) { + pr_debug("Read before write: sector=%lu, size=%u", + (ulong)(bio->bi_sector), bio->bi_size); + /* Do nothing */ + continue; + } - user_mem = kmap_atomic(page, KM_USER0); - clen = PAGE_SIZE; + /* Page is stored uncompressed since it's incompressible */ + if (unlikely(rzs_test_flag(rzs, index, RZS_UNCOMPRESSED))) { + handle_uncompressed_page(rzs, page, index); + continue; + } - cmem = kmap_atomic(rzs->table[index].page, KM_USER1) + - rzs->table[index].offset; + user_mem = kmap_atomic(page, KM_USER0); + clen = PAGE_SIZE; - ret = lzo1x_decompress_safe( - cmem + sizeof(*zheader), - xv_get_object_size(cmem) - sizeof(*zheader), - user_mem, &clen); + cmem = kmap_atomic(rzs->table[index].page, KM_USER1) + + rzs->table[index].offset; - kunmap_atomic(user_mem, KM_USER0); - kunmap_atomic(cmem, KM_USER1); + ret = lzo1x_decompress_safe( + cmem + sizeof(*zheader), + xv_get_object_size(cmem) - sizeof(*zheader), + user_mem, &clen); - /* should NEVER happen */ - if (unlikely(ret != LZO_E_OK)) { - pr_err("Decompression failed! err=%d, page=%u\n", - ret, index); - rzs_stat64_inc(rzs, &rzs->stats.failed_reads); - goto out; + kunmap_atomic(user_mem, KM_USER0); + kunmap_atomic(cmem, KM_USER1); + + /* Should NEVER happen. Return bio error if it does. */ + if (unlikely(ret != LZO_E_OK)) { + pr_err("Decompression failed! err=%d, page=%u\n", + ret, index); + rzs_stat64_inc(rzs, &rzs->stats.failed_reads); + goto out; + } + + flush_dcache_page(page); + index++; } - flush_dcache_page(page); - set_bit(BIO_UPTODATE, &bio->bi_flags); bio_endio(bio, 0); return 0; @@ -321,108 +290,120 @@ out: static int ramzswap_write(struct ramzswap *rzs, struct bio *bio) { - int ret; - u32 offset, index; - size_t clen; - struct zobj_header *zheader; - struct page *page, *page_store; - unsigned char *user_mem, *cmem, *src; + int i; + u32 index; + struct bio_vec *bvec; rzs_stat64_inc(rzs, &rzs->stats.num_writes); - page = bio->bi_io_vec[0].bv_page; index = bio->bi_sector >> SECTORS_PER_PAGE_SHIFT; - src = rzs->compress_buffer; + bio_for_each_segment(bvec, bio, i) { + int ret; + u32 offset; + size_t clen; + struct zobj_header *zheader; + struct page *page, *page_store; + unsigned char *user_mem, *cmem, *src; - mutex_lock(&rzs->lock); + page = bvec->bv_page; + src = rzs->compress_buffer; - user_mem = kmap_atomic(page, KM_USER0); - if (page_zero_filled(user_mem)) { - kunmap_atomic(user_mem, KM_USER0); - mutex_unlock(&rzs->lock); - rzs_stat_inc(&rzs->stats.pages_zero); - rzs_set_flag(rzs, index, RZS_ZERO); + /* + * System overwrites unused sectors. Free memory associated + * with this sector now. + */ + if (rzs->table[index].page || + rzs_test_flag(rzs, index, RZS_ZERO)) + ramzswap_free_page(rzs, index); - set_bit(BIO_UPTODATE, &bio->bi_flags); - bio_endio(bio, 0); - return 0; - } + mutex_lock(&rzs->lock); - ret = lzo1x_1_compress(user_mem, PAGE_SIZE, src, &clen, - rzs->compress_workmem); - - kunmap_atomic(user_mem, KM_USER0); - - if (unlikely(ret != LZO_E_OK)) { - mutex_unlock(&rzs->lock); - pr_err("Compression failed! err=%d\n", ret); - rzs_stat64_inc(rzs, &rzs->stats.failed_writes); - goto out; - } - - /* - * Page is incompressible. Store it as-is (uncompressed) - * since we do not want to return too many swap write - * errors which has side effect of hanging the system. - */ - if (unlikely(clen > max_zpage_size)) { - clen = PAGE_SIZE; - page_store = alloc_page(GFP_NOIO | __GFP_HIGHMEM); - if (unlikely(!page_store)) { + user_mem = kmap_atomic(page, KM_USER0); + if (page_zero_filled(user_mem)) { + kunmap_atomic(user_mem, KM_USER0); mutex_unlock(&rzs->lock); - pr_info("Error allocating memory for incompressible " - "page: %u\n", index); + rzs_stat_inc(&rzs->stats.pages_zero); + rzs_set_flag(rzs, index, RZS_ZERO); + continue; + } + + ret = lzo1x_1_compress(user_mem, PAGE_SIZE, src, &clen, + rzs->compress_workmem); + + kunmap_atomic(user_mem, KM_USER0); + + if (unlikely(ret != LZO_E_OK)) { + mutex_unlock(&rzs->lock); + pr_err("Compression failed! err=%d\n", ret); rzs_stat64_inc(rzs, &rzs->stats.failed_writes); goto out; } - offset = 0; - rzs_set_flag(rzs, index, RZS_UNCOMPRESSED); - rzs_stat_inc(&rzs->stats.pages_expand); - rzs->table[index].page = page_store; - src = kmap_atomic(page, KM_USER0); - goto memstore; - } + /* + * Page is incompressible. Store it as-is (uncompressed) + * since we do not want to return too many swap write + * errors which has side effect of hanging the system. + */ + if (unlikely(clen > max_zpage_size)) { + clen = PAGE_SIZE; + page_store = alloc_page(GFP_NOIO | __GFP_HIGHMEM); + if (unlikely(!page_store)) { + mutex_unlock(&rzs->lock); + pr_info("Error allocating memory for " + "incompressible page: %u\n", index); + rzs_stat64_inc(rzs, &rzs->stats.failed_writes); + goto out; + } - if (xv_malloc(rzs->mem_pool, clen + sizeof(*zheader), - &rzs->table[index].page, &offset, - GFP_NOIO | __GFP_HIGHMEM)) { - mutex_unlock(&rzs->lock); - pr_info("Error allocating memory for compressed " - "page: %u, size=%zu\n", index, clen); - rzs_stat64_inc(rzs, &rzs->stats.failed_writes); - goto out; - } + offset = 0; + rzs_set_flag(rzs, index, RZS_UNCOMPRESSED); + rzs_stat_inc(&rzs->stats.pages_expand); + rzs->table[index].page = page_store; + src = kmap_atomic(page, KM_USER0); + goto memstore; + } + + if (xv_malloc(rzs->mem_pool, clen + sizeof(*zheader), + &rzs->table[index].page, &offset, + GFP_NOIO | __GFP_HIGHMEM)) { + mutex_unlock(&rzs->lock); + pr_info("Error allocating memory for compressed " + "page: %u, size=%zu\n", index, clen); + rzs_stat64_inc(rzs, &rzs->stats.failed_writes); + goto out; + } memstore: - rzs->table[index].offset = offset; + rzs->table[index].offset = offset; - cmem = kmap_atomic(rzs->table[index].page, KM_USER1) + - rzs->table[index].offset; + cmem = kmap_atomic(rzs->table[index].page, KM_USER1) + + rzs->table[index].offset; #if 0 - /* Back-reference needed for memory defragmentation */ - if (!rzs_test_flag(rzs, index, RZS_UNCOMPRESSED)) { - zheader = (struct zobj_header *)cmem; - zheader->table_idx = index; - cmem += sizeof(*zheader); - } + /* Back-reference needed for memory defragmentation */ + if (!rzs_test_flag(rzs, index, RZS_UNCOMPRESSED)) { + zheader = (struct zobj_header *)cmem; + zheader->table_idx = index; + cmem += sizeof(*zheader); + } #endif - memcpy(cmem, src, clen); + memcpy(cmem, src, clen); - kunmap_atomic(cmem, KM_USER1); - if (unlikely(rzs_test_flag(rzs, index, RZS_UNCOMPRESSED))) - kunmap_atomic(src, KM_USER0); + kunmap_atomic(cmem, KM_USER1); + if (unlikely(rzs_test_flag(rzs, index, RZS_UNCOMPRESSED))) + kunmap_atomic(src, KM_USER0); - /* Update stats */ - rzs->stats.compr_size += clen; - rzs_stat_inc(&rzs->stats.pages_stored); - if (clen <= PAGE_SIZE / 2) - rzs_stat_inc(&rzs->stats.good_compress); + /* Update stats */ + rzs->stats.compr_size += clen; + rzs_stat_inc(&rzs->stats.pages_stored); + if (clen <= PAGE_SIZE / 2) + rzs_stat_inc(&rzs->stats.good_compress); - mutex_unlock(&rzs->lock); + mutex_unlock(&rzs->lock); + index++; + } set_bit(BIO_UPTODATE, &bio->bi_flags); bio_endio(bio, 0); @@ -436,19 +417,17 @@ out: /* * Check if request is within bounds and page aligned. */ -static inline int valid_swap_request(struct ramzswap *rzs, struct bio *bio) +static inline int valid_io_request(struct ramzswap *rzs, struct bio *bio) { if (unlikely( (bio->bi_sector >= (rzs->disksize >> SECTOR_SHIFT)) || (bio->bi_sector & (SECTORS_PER_PAGE - 1)) || - (bio->bi_vcnt != 1) || - (bio->bi_size != PAGE_SIZE) || - (bio->bi_io_vec[0].bv_offset != 0))) { + (bio->bi_size & (PAGE_SIZE - 1)))) { return 0; } - /* swap request is valid */ + /* I/O request is valid */ return 1; } @@ -465,7 +444,7 @@ static int ramzswap_make_request(struct request_queue *queue, struct bio *bio) return 0; } - if (!valid_swap_request(rzs, bio)) { + if (!valid_io_request(rzs, bio)) { rzs_stat64_inc(rzs, &rzs->stats.invalid_io); bio_io_error(bio); return 0; @@ -531,8 +510,6 @@ static int ramzswap_ioctl_init_device(struct ramzswap *rzs) { int ret; size_t num_pages; - struct page *page; - union swap_header *swap_header; if (rzs->init_done) { pr_info("Device already initialized!\n"); @@ -566,19 +543,6 @@ static int ramzswap_ioctl_init_device(struct ramzswap *rzs) } memset(rzs->table, 0, num_pages * sizeof(*rzs->table)); - page = alloc_page(__GFP_ZERO); - if (!page) { - pr_err("Error allocating swap header page\n"); - ret = -ENOMEM; - goto fail; - } - rzs->table[0].page = page; - rzs_set_flag(rzs, 0, RZS_UNCOMPRESSED); - - swap_header = kmap(page); - setup_swap_header(rzs, swap_header); - kunmap(page); - set_capacity(rzs->disk, rzs->disksize >> SECTOR_SHIFT); /* ramzswap devices sort of resembles non-rotational disks */ @@ -689,11 +653,9 @@ void ramzswap_slot_free_notify(struct block_device *bdev, unsigned long index) rzs = bdev->bd_disk->private_data; ramzswap_free_page(rzs, index); rzs_stat64_inc(rzs, &rzs->stats.notify_free); - - return; } -static struct block_device_operations ramzswap_devops = { +static const struct block_device_operations ramzswap_devops = { .ioctl = ramzswap_ioctl, .swap_slot_free_notify = ramzswap_slot_free_notify, .owner = THIS_MODULE @@ -737,8 +699,14 @@ static int create_device(struct ramzswap *rzs, int device_id) /* Actual capacity set using RZSIO_SET_DISKSIZE_KB ioctl */ set_capacity(rzs->disk, 0); + /* + * To ensure that we always get PAGE_SIZE aligned + * and n*PAGE_SIZED sized I/O requests. + */ blk_queue_physical_block_size(rzs->disk->queue, PAGE_SIZE); blk_queue_logical_block_size(rzs->disk->queue, PAGE_SIZE); + blk_queue_io_min(rzs->disk->queue, PAGE_SIZE); + blk_queue_io_opt(rzs->disk->queue, PAGE_SIZE); add_disk(rzs->disk); diff --git a/drivers/staging/ramzswap/ramzswap_drv.h b/drivers/staging/ramzswap/ramzswap_drv.h index 63c30420df21..ad91726013bb 100644 --- a/drivers/staging/ramzswap/ramzswap_drv.h +++ b/drivers/staging/ramzswap/ramzswap_drv.h @@ -112,7 +112,8 @@ struct ramzswap { void *compress_buffer; struct table *table; spinlock_t stat64_lock; /* protect 64-bit stats */ - struct mutex lock; + struct mutex lock; /* protect compression buffers against + * concurrent writes */ struct request_queue *queue; struct gendisk *disk; int init_done; From 16a4bfb9e9dfefbd28ee170fa3e259bc88d81eb5 Mon Sep 17 00:00:00 2001 From: Nitin Gupta Date: Tue, 1 Jun 2010 13:31:24 +0530 Subject: [PATCH 080/523] Staging: Rename ramzswap files to zram Related changes: - Modify revelant Kconfig and Makefile accordingly. - Change include filenames in code. - Remove dependency on CONFIG_SWAP in Kconfig as zram usage is no longer limited to swap disks. Signed-off-by: Nitin Gupta Acked-by: Pekka Enberg Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 +- drivers/staging/Makefile | 2 +- drivers/staging/ramzswap/Kconfig | 21 -------------- drivers/staging/ramzswap/Makefile | 3 -- drivers/staging/zram/Kconfig | 28 +++++++++++++++++++ drivers/staging/zram/Makefile | 3 ++ drivers/staging/{ramzswap => zram}/xvmalloc.c | 0 drivers/staging/{ramzswap => zram}/xvmalloc.h | 0 .../staging/{ramzswap => zram}/xvmalloc_int.h | 0 .../{ramzswap/ramzswap.txt => zram/zram.txt} | 0 .../ramzswap_drv.c => zram/zram_drv.c} | 2 +- .../ramzswap_drv.h => zram/zram_drv.h} | 2 +- .../ramzswap_ioctl.h => zram/zram_ioctl.h} | 0 13 files changed, 35 insertions(+), 28 deletions(-) delete mode 100644 drivers/staging/ramzswap/Kconfig delete mode 100644 drivers/staging/ramzswap/Makefile create mode 100644 drivers/staging/zram/Kconfig create mode 100644 drivers/staging/zram/Makefile rename drivers/staging/{ramzswap => zram}/xvmalloc.c (100%) rename drivers/staging/{ramzswap => zram}/xvmalloc.h (100%) rename drivers/staging/{ramzswap => zram}/xvmalloc_int.h (100%) rename drivers/staging/{ramzswap/ramzswap.txt => zram/zram.txt} (100%) rename drivers/staging/{ramzswap/ramzswap_drv.c => zram/zram_drv.c} (99%) rename drivers/staging/{ramzswap/ramzswap_drv.h => zram/zram_drv.h} (99%) rename drivers/staging/{ramzswap/ramzswap_ioctl.h => zram/zram_ioctl.h} (100%) diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index d5b827ccecf8..cdd3ea348319 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -119,7 +119,7 @@ source "drivers/staging/sep/Kconfig" source "drivers/staging/iio/Kconfig" -source "drivers/staging/ramzswap/Kconfig" +source "drivers/staging/zram/Kconfig" source "drivers/staging/wlags49_h2/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 2c14f89387be..beceaff3dfdf 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -40,7 +40,7 @@ obj-$(CONFIG_RAR_REGISTER) += rar_register/ obj-$(CONFIG_MRST_RAR_HANDLER) += memrar/ obj-$(CONFIG_DX_SEP) += sep/ obj-$(CONFIG_IIO) += iio/ -obj-$(CONFIG_RAMZSWAP) += ramzswap/ +obj-$(CONFIG_ZRAM) += zram/ obj-$(CONFIG_WLAGS49_H2) += wlags49_h2/ obj-$(CONFIG_WLAGS49_H25) += wlags49_h25/ obj-$(CONFIG_BATMAN_ADV) += batman-adv/ diff --git a/drivers/staging/ramzswap/Kconfig b/drivers/staging/ramzswap/Kconfig deleted file mode 100644 index 127b3c6c9596..000000000000 --- a/drivers/staging/ramzswap/Kconfig +++ /dev/null @@ -1,21 +0,0 @@ -config RAMZSWAP - tristate "Compressed in-memory swap device (ramzswap)" - depends on SWAP - select LZO_COMPRESS - select LZO_DECOMPRESS - default n - help - Creates virtual block devices which can (only) be used as swap - disks. Pages swapped to these disks are compressed and stored in - memory itself. - - See ramzswap.txt for more information. - Project home: http://compcache.googlecode.com/ - -config RAMZSWAP_STATS - bool "Enable ramzswap stats" - depends on RAMZSWAP - default y - help - Enable statistics collection for ramzswap. This adds only a minimal - overhead. In unsure, say Y. diff --git a/drivers/staging/ramzswap/Makefile b/drivers/staging/ramzswap/Makefile deleted file mode 100644 index 507d7dc3b864..000000000000 --- a/drivers/staging/ramzswap/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -ramzswap-objs := ramzswap_drv.o xvmalloc.o - -obj-$(CONFIG_RAMZSWAP) += ramzswap.o diff --git a/drivers/staging/zram/Kconfig b/drivers/staging/zram/Kconfig new file mode 100644 index 000000000000..5bcfe16feb19 --- /dev/null +++ b/drivers/staging/zram/Kconfig @@ -0,0 +1,28 @@ +config ZRAM + tristate "Compressed RAM block device support" + select LZO_COMPRESS + select LZO_DECOMPRESS + default n + help + Creates virtual block devices called /dev/zramX (X = 0, 1, ...). + Pages written to these disks are compressed and stored in memory + itself. These disks allow very fast I/O and compression provides + good amounts of memory savings. + + It has several use cases, for example: /tmp storage, use as swap + disks and maybe many more. + + See zram.txt for more information. + Project home: http://compcache.googlecode.com/ + +config ZRAM_STATS + bool "Enable statistics for compressed RAM disks" + depends on ZRAM + default y + help + Enable statistics collection for compressed RAM devices. Statistics + are exported through ioctl interface, so you have to use zramconfig + program to get them. This adds only a minimal overhead. + + If unsure, say Y. + diff --git a/drivers/staging/zram/Makefile b/drivers/staging/zram/Makefile new file mode 100644 index 000000000000..b2c087aa105e --- /dev/null +++ b/drivers/staging/zram/Makefile @@ -0,0 +1,3 @@ +zram-objs := zram_drv.o xvmalloc.o + +obj-$(CONFIG_ZRAM) += zram.o diff --git a/drivers/staging/ramzswap/xvmalloc.c b/drivers/staging/zram/xvmalloc.c similarity index 100% rename from drivers/staging/ramzswap/xvmalloc.c rename to drivers/staging/zram/xvmalloc.c diff --git a/drivers/staging/ramzswap/xvmalloc.h b/drivers/staging/zram/xvmalloc.h similarity index 100% rename from drivers/staging/ramzswap/xvmalloc.h rename to drivers/staging/zram/xvmalloc.h diff --git a/drivers/staging/ramzswap/xvmalloc_int.h b/drivers/staging/zram/xvmalloc_int.h similarity index 100% rename from drivers/staging/ramzswap/xvmalloc_int.h rename to drivers/staging/zram/xvmalloc_int.h diff --git a/drivers/staging/ramzswap/ramzswap.txt b/drivers/staging/zram/zram.txt similarity index 100% rename from drivers/staging/ramzswap/ramzswap.txt rename to drivers/staging/zram/zram.txt diff --git a/drivers/staging/ramzswap/ramzswap_drv.c b/drivers/staging/zram/zram_drv.c similarity index 99% rename from drivers/staging/ramzswap/ramzswap_drv.c rename to drivers/staging/zram/zram_drv.c index 7b5cc61b3d69..e9b064c21484 100644 --- a/drivers/staging/ramzswap/ramzswap_drv.c +++ b/drivers/staging/zram/zram_drv.c @@ -30,7 +30,7 @@ #include #include -#include "ramzswap_drv.h" +#include "zram_drv.h" /* Globals */ static int ramzswap_major; diff --git a/drivers/staging/ramzswap/ramzswap_drv.h b/drivers/staging/zram/zram_drv.h similarity index 99% rename from drivers/staging/ramzswap/ramzswap_drv.h rename to drivers/staging/zram/zram_drv.h index ad91726013bb..4d2e48a23474 100644 --- a/drivers/staging/ramzswap/ramzswap_drv.h +++ b/drivers/staging/zram/zram_drv.h @@ -18,7 +18,7 @@ #include #include -#include "ramzswap_ioctl.h" +#include "zram_ioctl.h" #include "xvmalloc.h" /* diff --git a/drivers/staging/ramzswap/ramzswap_ioctl.h b/drivers/staging/zram/zram_ioctl.h similarity index 100% rename from drivers/staging/ramzswap/ramzswap_ioctl.h rename to drivers/staging/zram/zram_ioctl.h From f1e3cfff4d58767a76fe71e18bffdeed10318b4e Mon Sep 17 00:00:00 2001 From: Nitin Gupta Date: Tue, 1 Jun 2010 13:31:25 +0530 Subject: [PATCH 081/523] Staging: zram: Rename ramzswap to zram in code Automated renames in code: - rzs* -> zram* - RZS* -> ZRAM* - ramzswap* -> zram* Manual changes: - Edited comments/messages mentioning "swap" Signed-off-by: Nitin Gupta Acked-by: Pekka Enberg Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zram/zram_drv.c | 431 +++++++++++++++--------------- drivers/staging/zram/zram_drv.h | 66 +++-- drivers/staging/zram/zram_ioctl.h | 21 +- 3 files changed, 256 insertions(+), 262 deletions(-) diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c index e9b064c21484..3f778434dc9b 100644 --- a/drivers/staging/zram/zram_drv.c +++ b/drivers/staging/zram/zram_drv.c @@ -1,5 +1,5 @@ /* - * Compressed RAM based swap device + * Compressed RAM block device * * Copyright (C) 2008, 2009, 2010 Nitin Gupta * @@ -12,7 +12,7 @@ * Project home: http://compcache.googlecode.com */ -#define KMSG_COMPONENT "ramzswap" +#define KMSG_COMPONENT "zram" #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt #include @@ -26,35 +26,33 @@ #include #include #include -#include -#include #include #include "zram_drv.h" /* Globals */ -static int ramzswap_major; -static struct ramzswap *devices; +static int zram_major; +static struct zram *devices; /* Module params (documentation at end) */ static unsigned int num_devices; -static int rzs_test_flag(struct ramzswap *rzs, u32 index, - enum rzs_pageflags flag) +static int zram_test_flag(struct zram *zram, u32 index, + enum zram_pageflags flag) { - return rzs->table[index].flags & BIT(flag); + return zram->table[index].flags & BIT(flag); } -static void rzs_set_flag(struct ramzswap *rzs, u32 index, - enum rzs_pageflags flag) +static void zram_set_flag(struct zram *zram, u32 index, + enum zram_pageflags flag) { - rzs->table[index].flags |= BIT(flag); + zram->table[index].flags |= BIT(flag); } -static void rzs_clear_flag(struct ramzswap *rzs, u32 index, - enum rzs_pageflags flag) +static void zram_clear_flag(struct zram *zram, u32 index, + enum zram_pageflags flag) { - rzs->table[index].flags &= ~BIT(flag); + zram->table[index].flags &= ~BIT(flag); } static int page_zero_filled(void *ptr) @@ -72,50 +70,50 @@ static int page_zero_filled(void *ptr) return 1; } -static void ramzswap_set_disksize(struct ramzswap *rzs, size_t totalram_bytes) +static void zram_set_disksize(struct zram *zram, size_t totalram_bytes) { - if (!rzs->disksize) { + if (!zram->disksize) { pr_info( "disk size not provided. You can use disksize_kb module " "param to specify size.\nUsing default: (%u%% of RAM).\n", default_disksize_perc_ram ); - rzs->disksize = default_disksize_perc_ram * + zram->disksize = default_disksize_perc_ram * (totalram_bytes / 100); } - if (rzs->disksize > 2 * (totalram_bytes)) { + if (zram->disksize > 2 * (totalram_bytes)) { pr_info( - "There is little point creating a ramzswap of greater than " + "There is little point creating a zram of greater than " "twice the size of memory since we expect a 2:1 compression " - "ratio. Note that ramzswap uses about 0.1%% of the size of " - "the swap device when not in use so a huge ramzswap is " + "ratio. Note that zram uses about 0.1%% of the size of " + "the disk when not in use so a huge zram is " "wasteful.\n" "\tMemory Size: %zu kB\n" "\tSize you selected: %zu kB\n" "Continuing anyway ...\n", - totalram_bytes >> 10, rzs->disksize + totalram_bytes >> 10, zram->disksize ); } - rzs->disksize &= PAGE_MASK; + zram->disksize &= PAGE_MASK; } -static void ramzswap_ioctl_get_stats(struct ramzswap *rzs, - struct ramzswap_ioctl_stats *s) +static void zram_ioctl_get_stats(struct zram *zram, + struct zram_ioctl_stats *s) { - s->disksize = rzs->disksize; + s->disksize = zram->disksize; -#if defined(CONFIG_RAMZSWAP_STATS) +#if defined(CONFIG_ZRAM_STATS) { - struct ramzswap_stats *rs = &rzs->stats; + struct zram_stats *rs = &zram->stats; size_t succ_writes, mem_used; unsigned int good_compress_perc = 0, no_compress_perc = 0; - mem_used = xv_get_total_size_bytes(rzs->mem_pool) + mem_used = xv_get_total_size_bytes(zram->mem_pool) + (rs->pages_expand << PAGE_SHIFT); - succ_writes = rzs_stat64_read(rzs, &rs->num_writes) - - rzs_stat64_read(rzs, &rs->failed_writes); + succ_writes = zram_stat64_read(zram, &rs->num_writes) - + zram_stat64_read(zram, &rs->failed_writes); if (succ_writes && rs->pages_stored) { good_compress_perc = rs->good_compress * 100 @@ -124,12 +122,12 @@ static void ramzswap_ioctl_get_stats(struct ramzswap *rzs, / rs->pages_stored; } - s->num_reads = rzs_stat64_read(rzs, &rs->num_reads); - s->num_writes = rzs_stat64_read(rzs, &rs->num_writes); - s->failed_reads = rzs_stat64_read(rzs, &rs->failed_reads); - s->failed_writes = rzs_stat64_read(rzs, &rs->failed_writes); - s->invalid_io = rzs_stat64_read(rzs, &rs->invalid_io); - s->notify_free = rzs_stat64_read(rzs, &rs->notify_free); + s->num_reads = zram_stat64_read(zram, &rs->num_reads); + s->num_writes = zram_stat64_read(zram, &rs->num_writes); + s->failed_reads = zram_stat64_read(zram, &rs->failed_reads); + s->failed_writes = zram_stat64_read(zram, &rs->failed_writes); + s->invalid_io = zram_stat64_read(zram, &rs->invalid_io); + s->notify_free = zram_stat64_read(zram, &rs->notify_free); s->pages_zero = rs->pages_zero; s->good_compress_pct = good_compress_perc; @@ -141,34 +139,34 @@ static void ramzswap_ioctl_get_stats(struct ramzswap *rzs, s->compr_data_size = rs->compr_size; s->mem_used_total = mem_used; } -#endif /* CONFIG_RAMZSWAP_STATS */ +#endif /* CONFIG_ZRAM_STATS */ } -static void ramzswap_free_page(struct ramzswap *rzs, size_t index) +static void zram_free_page(struct zram *zram, size_t index) { u32 clen; void *obj; - struct page *page = rzs->table[index].page; - u32 offset = rzs->table[index].offset; + struct page *page = zram->table[index].page; + u32 offset = zram->table[index].offset; if (unlikely(!page)) { /* * No memory is allocated for zero filled pages. * Simply clear zero page flag. */ - if (rzs_test_flag(rzs, index, RZS_ZERO)) { - rzs_clear_flag(rzs, index, RZS_ZERO); - rzs_stat_dec(&rzs->stats.pages_zero); + if (zram_test_flag(zram, index, ZRAM_ZERO)) { + zram_clear_flag(zram, index, ZRAM_ZERO); + zram_stat_dec(&zram->stats.pages_zero); } return; } - if (unlikely(rzs_test_flag(rzs, index, RZS_UNCOMPRESSED))) { + if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED))) { clen = PAGE_SIZE; __free_page(page); - rzs_clear_flag(rzs, index, RZS_UNCOMPRESSED); - rzs_stat_dec(&rzs->stats.pages_expand); + zram_clear_flag(zram, index, ZRAM_UNCOMPRESSED); + zram_stat_dec(&zram->stats.pages_expand); goto out; } @@ -176,16 +174,16 @@ static void ramzswap_free_page(struct ramzswap *rzs, size_t index) clen = xv_get_object_size(obj) - sizeof(struct zobj_header); kunmap_atomic(obj, KM_USER0); - xv_free(rzs->mem_pool, page, offset); + xv_free(zram->mem_pool, page, offset); if (clen <= PAGE_SIZE / 2) - rzs_stat_dec(&rzs->stats.good_compress); + zram_stat_dec(&zram->stats.good_compress); out: - rzs->stats.compr_size -= clen; - rzs_stat_dec(&rzs->stats.pages_stored); + zram->stats.compr_size -= clen; + zram_stat_dec(&zram->stats.pages_stored); - rzs->table[index].page = NULL; - rzs->table[index].offset = 0; + zram->table[index].page = NULL; + zram->table[index].offset = 0; } static void handle_zero_page(struct page *page) @@ -199,14 +197,14 @@ static void handle_zero_page(struct page *page) flush_dcache_page(page); } -static void handle_uncompressed_page(struct ramzswap *rzs, +static void handle_uncompressed_page(struct zram *zram, struct page *page, u32 index) { unsigned char *user_mem, *cmem; user_mem = kmap_atomic(page, KM_USER0); - cmem = kmap_atomic(rzs->table[index].page, KM_USER1) + - rzs->table[index].offset; + cmem = kmap_atomic(zram->table[index].page, KM_USER1) + + zram->table[index].offset; memcpy(user_mem, cmem, PAGE_SIZE); kunmap_atomic(user_mem, KM_USER0); @@ -215,14 +213,14 @@ static void handle_uncompressed_page(struct ramzswap *rzs, flush_dcache_page(page); } -static int ramzswap_read(struct ramzswap *rzs, struct bio *bio) +static int zram_read(struct zram *zram, struct bio *bio) { int i; u32 index; struct bio_vec *bvec; - rzs_stat64_inc(rzs, &rzs->stats.num_reads); + zram_stat64_inc(zram, &zram->stats.num_reads); index = bio->bi_sector >> SECTORS_PER_PAGE_SHIFT; bio_for_each_segment(bvec, bio, i) { @@ -234,13 +232,13 @@ static int ramzswap_read(struct ramzswap *rzs, struct bio *bio) page = bvec->bv_page; - if (rzs_test_flag(rzs, index, RZS_ZERO)) { + if (zram_test_flag(zram, index, ZRAM_ZERO)) { handle_zero_page(page); continue; } /* Requested page is not present in compressed area */ - if (unlikely(!rzs->table[index].page)) { + if (unlikely(!zram->table[index].page)) { pr_debug("Read before write: sector=%lu, size=%u", (ulong)(bio->bi_sector), bio->bi_size); /* Do nothing */ @@ -248,16 +246,16 @@ static int ramzswap_read(struct ramzswap *rzs, struct bio *bio) } /* Page is stored uncompressed since it's incompressible */ - if (unlikely(rzs_test_flag(rzs, index, RZS_UNCOMPRESSED))) { - handle_uncompressed_page(rzs, page, index); + if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED))) { + handle_uncompressed_page(zram, page, index); continue; } user_mem = kmap_atomic(page, KM_USER0); clen = PAGE_SIZE; - cmem = kmap_atomic(rzs->table[index].page, KM_USER1) + - rzs->table[index].offset; + cmem = kmap_atomic(zram->table[index].page, KM_USER1) + + zram->table[index].offset; ret = lzo1x_decompress_safe( cmem + sizeof(*zheader), @@ -271,7 +269,7 @@ static int ramzswap_read(struct ramzswap *rzs, struct bio *bio) if (unlikely(ret != LZO_E_OK)) { pr_err("Decompression failed! err=%d, page=%u\n", ret, index); - rzs_stat64_inc(rzs, &rzs->stats.failed_reads); + zram_stat64_inc(zram, &zram->stats.failed_reads); goto out; } @@ -288,13 +286,13 @@ out: return 0; } -static int ramzswap_write(struct ramzswap *rzs, struct bio *bio) +static int zram_write(struct zram *zram, struct bio *bio) { int i; u32 index; struct bio_vec *bvec; - rzs_stat64_inc(rzs, &rzs->stats.num_writes); + zram_stat64_inc(zram, &zram->stats.num_writes); index = bio->bi_sector >> SECTORS_PER_PAGE_SHIFT; @@ -307,82 +305,83 @@ static int ramzswap_write(struct ramzswap *rzs, struct bio *bio) unsigned char *user_mem, *cmem, *src; page = bvec->bv_page; - src = rzs->compress_buffer; + src = zram->compress_buffer; /* * System overwrites unused sectors. Free memory associated * with this sector now. */ - if (rzs->table[index].page || - rzs_test_flag(rzs, index, RZS_ZERO)) - ramzswap_free_page(rzs, index); + if (zram->table[index].page || + zram_test_flag(zram, index, ZRAM_ZERO)) + zram_free_page(zram, index); - mutex_lock(&rzs->lock); + mutex_lock(&zram->lock); user_mem = kmap_atomic(page, KM_USER0); if (page_zero_filled(user_mem)) { kunmap_atomic(user_mem, KM_USER0); - mutex_unlock(&rzs->lock); - rzs_stat_inc(&rzs->stats.pages_zero); - rzs_set_flag(rzs, index, RZS_ZERO); + mutex_unlock(&zram->lock); + zram_stat_inc(&zram->stats.pages_zero); + zram_set_flag(zram, index, ZRAM_ZERO); continue; } ret = lzo1x_1_compress(user_mem, PAGE_SIZE, src, &clen, - rzs->compress_workmem); + zram->compress_workmem); kunmap_atomic(user_mem, KM_USER0); if (unlikely(ret != LZO_E_OK)) { - mutex_unlock(&rzs->lock); + mutex_unlock(&zram->lock); pr_err("Compression failed! err=%d\n", ret); - rzs_stat64_inc(rzs, &rzs->stats.failed_writes); + zram_stat64_inc(zram, &zram->stats.failed_writes); goto out; } /* * Page is incompressible. Store it as-is (uncompressed) - * since we do not want to return too many swap write + * since we do not want to return too many disk write * errors which has side effect of hanging the system. */ if (unlikely(clen > max_zpage_size)) { clen = PAGE_SIZE; page_store = alloc_page(GFP_NOIO | __GFP_HIGHMEM); if (unlikely(!page_store)) { - mutex_unlock(&rzs->lock); + mutex_unlock(&zram->lock); pr_info("Error allocating memory for " "incompressible page: %u\n", index); - rzs_stat64_inc(rzs, &rzs->stats.failed_writes); + zram_stat64_inc(zram, + &zram->stats.failed_writes); goto out; } offset = 0; - rzs_set_flag(rzs, index, RZS_UNCOMPRESSED); - rzs_stat_inc(&rzs->stats.pages_expand); - rzs->table[index].page = page_store; + zram_set_flag(zram, index, ZRAM_UNCOMPRESSED); + zram_stat_inc(&zram->stats.pages_expand); + zram->table[index].page = page_store; src = kmap_atomic(page, KM_USER0); goto memstore; } - if (xv_malloc(rzs->mem_pool, clen + sizeof(*zheader), - &rzs->table[index].page, &offset, + if (xv_malloc(zram->mem_pool, clen + sizeof(*zheader), + &zram->table[index].page, &offset, GFP_NOIO | __GFP_HIGHMEM)) { - mutex_unlock(&rzs->lock); + mutex_unlock(&zram->lock); pr_info("Error allocating memory for compressed " "page: %u, size=%zu\n", index, clen); - rzs_stat64_inc(rzs, &rzs->stats.failed_writes); + zram_stat64_inc(zram, &zram->stats.failed_writes); goto out; } memstore: - rzs->table[index].offset = offset; + zram->table[index].offset = offset; - cmem = kmap_atomic(rzs->table[index].page, KM_USER1) + - rzs->table[index].offset; + cmem = kmap_atomic(zram->table[index].page, KM_USER1) + + zram->table[index].offset; #if 0 /* Back-reference needed for memory defragmentation */ - if (!rzs_test_flag(rzs, index, RZS_UNCOMPRESSED)) { + if (!zram_test_flag(zram, index, ZRAM_UNCOMPRESSED)) { zheader = (struct zobj_header *)cmem; zheader->table_idx = index; cmem += sizeof(*zheader); @@ -392,16 +391,16 @@ memstore: memcpy(cmem, src, clen); kunmap_atomic(cmem, KM_USER1); - if (unlikely(rzs_test_flag(rzs, index, RZS_UNCOMPRESSED))) + if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED))) kunmap_atomic(src, KM_USER0); /* Update stats */ - rzs->stats.compr_size += clen; - rzs_stat_inc(&rzs->stats.pages_stored); + zram->stats.compr_size += clen; + zram_stat_inc(&zram->stats.pages_stored); if (clen <= PAGE_SIZE / 2) - rzs_stat_inc(&rzs->stats.good_compress); + zram_stat_inc(&zram->stats.good_compress); - mutex_unlock(&rzs->lock); + mutex_unlock(&zram->lock); index++; } @@ -417,10 +416,10 @@ out: /* * Check if request is within bounds and page aligned. */ -static inline int valid_io_request(struct ramzswap *rzs, struct bio *bio) +static inline int valid_io_request(struct zram *zram, struct bio *bio) { if (unlikely( - (bio->bi_sector >= (rzs->disksize >> SECTOR_SHIFT)) || + (bio->bi_sector >= (zram->disksize >> SECTOR_SHIFT)) || (bio->bi_sector & (SECTORS_PER_PAGE - 1)) || (bio->bi_size & (PAGE_SIZE - 1)))) { @@ -432,160 +431,160 @@ static inline int valid_io_request(struct ramzswap *rzs, struct bio *bio) } /* - * Handler function for all ramzswap I/O requests. + * Handler function for all zram I/O requests. */ -static int ramzswap_make_request(struct request_queue *queue, struct bio *bio) +static int zram_make_request(struct request_queue *queue, struct bio *bio) { int ret = 0; - struct ramzswap *rzs = queue->queuedata; + struct zram *zram = queue->queuedata; - if (unlikely(!rzs->init_done)) { + if (unlikely(!zram->init_done)) { bio_io_error(bio); return 0; } - if (!valid_io_request(rzs, bio)) { - rzs_stat64_inc(rzs, &rzs->stats.invalid_io); + if (!valid_io_request(zram, bio)) { + zram_stat64_inc(zram, &zram->stats.invalid_io); bio_io_error(bio); return 0; } switch (bio_data_dir(bio)) { case READ: - ret = ramzswap_read(rzs, bio); + ret = zram_read(zram, bio); break; case WRITE: - ret = ramzswap_write(rzs, bio); + ret = zram_write(zram, bio); break; } return ret; } -static void reset_device(struct ramzswap *rzs) +static void reset_device(struct zram *zram) { size_t index; /* Do not accept any new I/O request */ - rzs->init_done = 0; + zram->init_done = 0; /* Free various per-device buffers */ - kfree(rzs->compress_workmem); - free_pages((unsigned long)rzs->compress_buffer, 1); + kfree(zram->compress_workmem); + free_pages((unsigned long)zram->compress_buffer, 1); - rzs->compress_workmem = NULL; - rzs->compress_buffer = NULL; + zram->compress_workmem = NULL; + zram->compress_buffer = NULL; - /* Free all pages that are still in this ramzswap device */ - for (index = 0; index < rzs->disksize >> PAGE_SHIFT; index++) { + /* Free all pages that are still in this zram device */ + for (index = 0; index < zram->disksize >> PAGE_SHIFT; index++) { struct page *page; u16 offset; - page = rzs->table[index].page; - offset = rzs->table[index].offset; + page = zram->table[index].page; + offset = zram->table[index].offset; if (!page) continue; - if (unlikely(rzs_test_flag(rzs, index, RZS_UNCOMPRESSED))) + if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED))) __free_page(page); else - xv_free(rzs->mem_pool, page, offset); + xv_free(zram->mem_pool, page, offset); } - vfree(rzs->table); - rzs->table = NULL; + vfree(zram->table); + zram->table = NULL; - xv_destroy_pool(rzs->mem_pool); - rzs->mem_pool = NULL; + xv_destroy_pool(zram->mem_pool); + zram->mem_pool = NULL; /* Reset stats */ - memset(&rzs->stats, 0, sizeof(rzs->stats)); + memset(&zram->stats, 0, sizeof(zram->stats)); - rzs->disksize = 0; + zram->disksize = 0; } -static int ramzswap_ioctl_init_device(struct ramzswap *rzs) +static int zram_ioctl_init_device(struct zram *zram) { int ret; size_t num_pages; - if (rzs->init_done) { + if (zram->init_done) { pr_info("Device already initialized!\n"); return -EBUSY; } - ramzswap_set_disksize(rzs, totalram_pages << PAGE_SHIFT); + zram_set_disksize(zram, totalram_pages << PAGE_SHIFT); - rzs->compress_workmem = kzalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL); - if (!rzs->compress_workmem) { + zram->compress_workmem = kzalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL); + if (!zram->compress_workmem) { pr_err("Error allocating compressor working memory!\n"); ret = -ENOMEM; goto fail; } - rzs->compress_buffer = (void *)__get_free_pages(__GFP_ZERO, 1); - if (!rzs->compress_buffer) { + zram->compress_buffer = (void *)__get_free_pages(__GFP_ZERO, 1); + if (!zram->compress_buffer) { pr_err("Error allocating compressor buffer space\n"); ret = -ENOMEM; goto fail; } - num_pages = rzs->disksize >> PAGE_SHIFT; - rzs->table = vmalloc(num_pages * sizeof(*rzs->table)); - if (!rzs->table) { - pr_err("Error allocating ramzswap address table\n"); + num_pages = zram->disksize >> PAGE_SHIFT; + zram->table = vmalloc(num_pages * sizeof(*zram->table)); + if (!zram->table) { + pr_err("Error allocating zram address table\n"); /* To prevent accessing table entries during cleanup */ - rzs->disksize = 0; + zram->disksize = 0; ret = -ENOMEM; goto fail; } - memset(rzs->table, 0, num_pages * sizeof(*rzs->table)); + memset(zram->table, 0, num_pages * sizeof(*zram->table)); - set_capacity(rzs->disk, rzs->disksize >> SECTOR_SHIFT); + set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); - /* ramzswap devices sort of resembles non-rotational disks */ - queue_flag_set_unlocked(QUEUE_FLAG_NONROT, rzs->disk->queue); + /* zram devices sort of resembles non-rotational disks */ + queue_flag_set_unlocked(QUEUE_FLAG_NONROT, zram->disk->queue); - rzs->mem_pool = xv_create_pool(); - if (!rzs->mem_pool) { + zram->mem_pool = xv_create_pool(); + if (!zram->mem_pool) { pr_err("Error creating memory pool\n"); ret = -ENOMEM; goto fail; } - rzs->init_done = 1; + zram->init_done = 1; pr_debug("Initialization done!\n"); return 0; fail: - reset_device(rzs); + reset_device(zram); pr_err("Initialization failed: err=%d\n", ret); return ret; } -static int ramzswap_ioctl_reset_device(struct ramzswap *rzs) +static int zram_ioctl_reset_device(struct zram *zram) { - if (rzs->init_done) - reset_device(rzs); + if (zram->init_done) + reset_device(zram); return 0; } -static int ramzswap_ioctl(struct block_device *bdev, fmode_t mode, +static int zram_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) { int ret = 0; size_t disksize_kb; - struct ramzswap *rzs = bdev->bd_disk->private_data; + struct zram *zram = bdev->bd_disk->private_data; switch (cmd) { - case RZSIO_SET_DISKSIZE_KB: - if (rzs->init_done) { + case ZRAMIO_SET_DISKSIZE_KB: + if (zram->init_done) { ret = -EBUSY; goto out; } @@ -594,14 +593,14 @@ static int ramzswap_ioctl(struct block_device *bdev, fmode_t mode, ret = -EFAULT; goto out; } - rzs->disksize = disksize_kb << 10; + zram->disksize = disksize_kb << 10; pr_info("Disk size set to %zu kB\n", disksize_kb); break; - case RZSIO_GET_STATS: + case ZRAMIO_GET_STATS: { - struct ramzswap_ioctl_stats *stats; - if (!rzs->init_done) { + struct zram_ioctl_stats *stats; + if (!zram->init_done) { ret = -ENOTTY; goto out; } @@ -610,7 +609,7 @@ static int ramzswap_ioctl(struct block_device *bdev, fmode_t mode, ret = -ENOMEM; goto out; } - ramzswap_ioctl_get_stats(rzs, stats); + zram_ioctl_get_stats(zram, stats); if (copy_to_user((void *)arg, stats, sizeof(*stats))) { kfree(stats); ret = -EFAULT; @@ -619,11 +618,11 @@ static int ramzswap_ioctl(struct block_device *bdev, fmode_t mode, kfree(stats); break; } - case RZSIO_INIT: - ret = ramzswap_ioctl_init_device(rzs); + case ZRAMIO_INIT: + ret = zram_ioctl_init_device(zram); break; - case RZSIO_RESET: + case ZRAMIO_RESET: /* Do not reset an active device! */ if (bdev->bd_holders) { ret = -EBUSY; @@ -634,7 +633,7 @@ static int ramzswap_ioctl(struct block_device *bdev, fmode_t mode, if (bdev) fsync_bdev(bdev); - ret = ramzswap_ioctl_reset_device(rzs); + ret = zram_ioctl_reset_device(zram); break; default: @@ -646,88 +645,88 @@ out: return ret; } -void ramzswap_slot_free_notify(struct block_device *bdev, unsigned long index) +void zram_slot_free_notify(struct block_device *bdev, unsigned long index) { - struct ramzswap *rzs; + struct zram *zram; - rzs = bdev->bd_disk->private_data; - ramzswap_free_page(rzs, index); - rzs_stat64_inc(rzs, &rzs->stats.notify_free); + zram = bdev->bd_disk->private_data; + zram_free_page(zram, index); + zram_stat64_inc(zram, &zram->stats.notify_free); } -static const struct block_device_operations ramzswap_devops = { - .ioctl = ramzswap_ioctl, - .swap_slot_free_notify = ramzswap_slot_free_notify, +static const struct block_device_operations zram_devops = { + .ioctl = zram_ioctl, + .swap_slot_free_notify = zram_slot_free_notify, .owner = THIS_MODULE }; -static int create_device(struct ramzswap *rzs, int device_id) +static int create_device(struct zram *zram, int device_id) { int ret = 0; - mutex_init(&rzs->lock); - spin_lock_init(&rzs->stat64_lock); + mutex_init(&zram->lock); + spin_lock_init(&zram->stat64_lock); - rzs->queue = blk_alloc_queue(GFP_KERNEL); - if (!rzs->queue) { + zram->queue = blk_alloc_queue(GFP_KERNEL); + if (!zram->queue) { pr_err("Error allocating disk queue for device %d\n", device_id); ret = -ENOMEM; goto out; } - blk_queue_make_request(rzs->queue, ramzswap_make_request); - rzs->queue->queuedata = rzs; + blk_queue_make_request(zram->queue, zram_make_request); + zram->queue->queuedata = zram; /* gendisk structure */ - rzs->disk = alloc_disk(1); - if (!rzs->disk) { - blk_cleanup_queue(rzs->queue); + zram->disk = alloc_disk(1); + if (!zram->disk) { + blk_cleanup_queue(zram->queue); pr_warning("Error allocating disk structure for device %d\n", device_id); ret = -ENOMEM; goto out; } - rzs->disk->major = ramzswap_major; - rzs->disk->first_minor = device_id; - rzs->disk->fops = &ramzswap_devops; - rzs->disk->queue = rzs->queue; - rzs->disk->private_data = rzs; - snprintf(rzs->disk->disk_name, 16, "ramzswap%d", device_id); + zram->disk->major = zram_major; + zram->disk->first_minor = device_id; + zram->disk->fops = &zram_devops; + zram->disk->queue = zram->queue; + zram->disk->private_data = zram; + snprintf(zram->disk->disk_name, 16, "zram%d", device_id); - /* Actual capacity set using RZSIO_SET_DISKSIZE_KB ioctl */ - set_capacity(rzs->disk, 0); + /* Actual capacity set using ZRAMIO_SET_DISKSIZE_KB ioctl */ + set_capacity(zram->disk, 0); /* * To ensure that we always get PAGE_SIZE aligned * and n*PAGE_SIZED sized I/O requests. */ - blk_queue_physical_block_size(rzs->disk->queue, PAGE_SIZE); - blk_queue_logical_block_size(rzs->disk->queue, PAGE_SIZE); - blk_queue_io_min(rzs->disk->queue, PAGE_SIZE); - blk_queue_io_opt(rzs->disk->queue, PAGE_SIZE); + blk_queue_physical_block_size(zram->disk->queue, PAGE_SIZE); + blk_queue_logical_block_size(zram->disk->queue, PAGE_SIZE); + blk_queue_io_min(zram->disk->queue, PAGE_SIZE); + blk_queue_io_opt(zram->disk->queue, PAGE_SIZE); - add_disk(rzs->disk); + add_disk(zram->disk); - rzs->init_done = 0; + zram->init_done = 0; out: return ret; } -static void destroy_device(struct ramzswap *rzs) +static void destroy_device(struct zram *zram) { - if (rzs->disk) { - del_gendisk(rzs->disk); - put_disk(rzs->disk); + if (zram->disk) { + del_gendisk(zram->disk); + put_disk(zram->disk); } - if (rzs->queue) - blk_cleanup_queue(rzs->queue); + if (zram->queue) + blk_cleanup_queue(zram->queue); } -static int __init ramzswap_init(void) +static int __init zram_init(void) { int ret, dev_id; @@ -738,8 +737,8 @@ static int __init ramzswap_init(void) goto out; } - ramzswap_major = register_blkdev(0, "ramzswap"); - if (ramzswap_major <= 0) { + zram_major = register_blkdev(0, "zram"); + if (zram_major <= 0) { pr_warning("Unable to get major number\n"); ret = -EBUSY; goto out; @@ -752,7 +751,7 @@ static int __init ramzswap_init(void) /* Allocate the device array and initialize each one */ pr_info("Creating %u devices ...\n", num_devices); - devices = kzalloc(num_devices * sizeof(struct ramzswap), GFP_KERNEL); + devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL); if (!devices) { ret = -ENOMEM; goto unregister; @@ -770,36 +769,36 @@ free_devices: while (dev_id) destroy_device(&devices[--dev_id]); unregister: - unregister_blkdev(ramzswap_major, "ramzswap"); + unregister_blkdev(zram_major, "zram"); out: return ret; } -static void __exit ramzswap_exit(void) +static void __exit zram_exit(void) { int i; - struct ramzswap *rzs; + struct zram *zram; for (i = 0; i < num_devices; i++) { - rzs = &devices[i]; + zram = &devices[i]; - destroy_device(rzs); - if (rzs->init_done) - reset_device(rzs); + destroy_device(zram); + if (zram->init_done) + reset_device(zram); } - unregister_blkdev(ramzswap_major, "ramzswap"); + unregister_blkdev(zram_major, "zram"); kfree(devices); pr_debug("Cleanup done!\n"); } module_param(num_devices, uint, 0); -MODULE_PARM_DESC(num_devices, "Number of ramzswap devices"); +MODULE_PARM_DESC(num_devices, "Number of zram devices"); -module_init(ramzswap_init); -module_exit(ramzswap_exit); +module_init(zram_init); +module_exit(zram_exit); MODULE_LICENSE("Dual BSD/GPL"); MODULE_AUTHOR("Nitin Gupta "); -MODULE_DESCRIPTION("Compressed RAM Based Swap Device"); +MODULE_DESCRIPTION("Compressed RAM Block Device"); diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h index 4d2e48a23474..945f9740442f 100644 --- a/drivers/staging/zram/zram_drv.h +++ b/drivers/staging/zram/zram_drv.h @@ -1,5 +1,5 @@ /* - * Compressed RAM based swap device + * Compressed RAM block device * * Copyright (C) 2008, 2009, 2010 Nitin Gupta * @@ -12,8 +12,8 @@ * Project home: http://compcache.googlecode.com */ -#ifndef _RAMZSWAP_DRV_H_ -#define _RAMZSWAP_DRV_H_ +#ifndef _ZRAM_DRV_H_ +#define _ZRAM_DRV_H_ #include #include @@ -41,7 +41,7 @@ struct zobj_header { /*-- Configurable parameters */ -/* Default ramzswap disk size: 25% of total RAM */ +/* Default zram disk size: 25% of total RAM */ static const unsigned default_disksize_perc_ram = 25; /* @@ -63,23 +63,20 @@ static const unsigned max_zpage_size = PAGE_SIZE / 4 * 3; #define SECTORS_PER_PAGE_SHIFT (PAGE_SHIFT - SECTOR_SHIFT) #define SECTORS_PER_PAGE (1 << SECTORS_PER_PAGE_SHIFT) -/* Flags for ramzswap pages (table[page_no].flags) */ -enum rzs_pageflags { +/* Flags for zram pages (table[page_no].flags) */ +enum zram_pageflags { /* Page is stored uncompressed */ - RZS_UNCOMPRESSED, + ZRAM_UNCOMPRESSED, /* Page consists entirely of zeros */ - RZS_ZERO, + ZRAM_ZERO, - __NR_RZS_PAGEFLAGS, + __NR_ZRAM_PAGEFLAGS, }; /*-- Data structures */ -/* - * Allocated for each swap slot, indexed by page no. - * These table entries must fit exactly in a page. - */ +/* Allocated for each disk page */ struct table { struct page *page; u16 offset; @@ -87,17 +84,17 @@ struct table { u8 flags; } __attribute__((aligned(4))); -struct ramzswap_stats { +struct zram_stats { /* basic stats */ size_t compr_size; /* compressed size of pages stored - * needed to enforce memlimit */ /* more stats */ -#if defined(CONFIG_RAMZSWAP_STATS) +#if defined(CONFIG_ZRAM_STATS) u64 num_reads; /* failed + successful */ u64 num_writes; /* --do-- */ u64 failed_reads; /* should NEVER! happen */ u64 failed_writes; /* can happen when memory is too low */ - u64 invalid_io; /* non-swap I/O requests */ + u64 invalid_io; /* non-page-aligned I/O requests */ u64 notify_free; /* no. of swap slot free notifications */ u32 pages_zero; /* no. of zero filled pages */ u32 pages_stored; /* no. of pages currently stored */ @@ -106,7 +103,7 @@ struct ramzswap_stats { #endif }; -struct ramzswap { +struct zram { struct xv_pool *mem_pool; void *compress_workmem; void *compress_buffer; @@ -118,51 +115,50 @@ struct ramzswap { struct gendisk *disk; int init_done; /* - * This is limit on amount of *uncompressed* worth of data - * we can hold. When backing swap device is provided, it is - * set equal to device size. + * This is the limit on amount of *uncompressed* worth of data + * we can store in a disk. */ size_t disksize; /* bytes */ - struct ramzswap_stats stats; + struct zram_stats stats; }; /*-- */ /* Debugging and Stats */ -#if defined(CONFIG_RAMZSWAP_STATS) -static void rzs_stat_inc(u32 *v) +#if defined(CONFIG_ZRAM_STATS) +static void zram_stat_inc(u32 *v) { *v = *v + 1; } -static void rzs_stat_dec(u32 *v) +static void zram_stat_dec(u32 *v) { *v = *v - 1; } -static void rzs_stat64_inc(struct ramzswap *rzs, u64 *v) +static void zram_stat64_inc(struct zram *zram, u64 *v) { - spin_lock(&rzs->stat64_lock); + spin_lock(&zram->stat64_lock); *v = *v + 1; - spin_unlock(&rzs->stat64_lock); + spin_unlock(&zram->stat64_lock); } -static u64 rzs_stat64_read(struct ramzswap *rzs, u64 *v) +static u64 zram_stat64_read(struct zram *zram, u64 *v) { u64 val; - spin_lock(&rzs->stat64_lock); + spin_lock(&zram->stat64_lock); val = *v; - spin_unlock(&rzs->stat64_lock); + spin_unlock(&zram->stat64_lock); return val; } #else -#define rzs_stat_inc(v) -#define rzs_stat_dec(v) -#define rzs_stat64_inc(r, v) -#define rzs_stat64_read(r, v) -#endif /* CONFIG_RAMZSWAP_STATS */ +#define zram_stat_inc(v) +#define zram_stat_dec(v) +#define zram_stat64_inc(r, v) +#define zram_stat64_read(r, v) +#endif /* CONFIG_ZRAM_STATS */ #endif diff --git a/drivers/staging/zram/zram_ioctl.h b/drivers/staging/zram/zram_ioctl.h index db94bcb42967..5c415fa4f17b 100644 --- a/drivers/staging/zram/zram_ioctl.h +++ b/drivers/staging/zram/zram_ioctl.h @@ -1,5 +1,5 @@ /* - * Compressed RAM based swap device + * Compressed RAM block device * * Copyright (C) 2008, 2009, 2010 Nitin Gupta * @@ -12,17 +12,16 @@ * Project home: http://compcache.googlecode.com */ -#ifndef _RAMZSWAP_IOCTL_H_ -#define _RAMZSWAP_IOCTL_H_ +#ifndef _ZRAM_IOCTL_H_ +#define _ZRAM_IOCTL_H_ -struct ramzswap_ioctl_stats { - u64 disksize; /* user specified or equal to backing swap - * size (if present) */ +struct zram_ioctl_stats { + u64 disksize; /* disksize in bytes (user specifies in KB) */ u64 num_reads; /* failed + successful */ u64 num_writes; /* --do-- */ u64 failed_reads; /* should NEVER! happen */ u64 failed_writes; /* can happen when memory is too low */ - u64 invalid_io; /* non-swap I/O requests */ + u64 invalid_io; /* non-page-aligned I/O requests */ u64 notify_free; /* no. of swap slot free notifications */ u32 pages_zero; /* no. of zero filled pages */ u32 good_compress_pct; /* no. of pages with compression ratio<=50% */ @@ -34,9 +33,9 @@ struct ramzswap_ioctl_stats { u64 mem_used_total; } __attribute__ ((packed, aligned(4))); -#define RZSIO_SET_DISKSIZE_KB _IOW('z', 0, size_t) -#define RZSIO_GET_STATS _IOR('z', 1, struct ramzswap_ioctl_stats) -#define RZSIO_INIT _IO('z', 2) -#define RZSIO_RESET _IO('z', 3) +#define ZRAMIO_SET_DISKSIZE_KB _IOW('z', 0, size_t) +#define ZRAMIO_GET_STATS _IOR('z', 1, struct zram_ioctl_stats) +#define ZRAMIO_INIT _IO('z', 2) +#define ZRAMIO_RESET _IO('z', 3) #endif From 00ac9ba01d1868de1fc4645d952381966afa3ec2 Mon Sep 17 00:00:00 2001 From: Nitin Gupta Date: Tue, 1 Jun 2010 13:31:26 +0530 Subject: [PATCH 082/523] Staging: zram: Rename ramzswap to zram in documentation Related changes: - Included example to show usage as generic (non-swap) disk with ext4 filesystem. - Renamed rzscontrol to zramconfig to match with new device naming. Signed-off-by: Nitin Gupta Acked-by: Pekka Enberg Signed-off-by: Greg Kroah-Hartman --- drivers/staging/zram/zram.txt | 51 +++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/drivers/staging/zram/zram.txt b/drivers/staging/zram/zram.txt index 9694acfeb43f..520edc1bea73 100644 --- a/drivers/staging/zram/zram.txt +++ b/drivers/staging/zram/zram.txt @@ -1,46 +1,57 @@ -ramzswap: Compressed RAM based swap device -------------------------------------------- +zram: Compressed RAM based block devices +---------------------------------------- Project home: http://compcache.googlecode.com/ * Introduction -The ramzswap module creates RAM based block devices which can (only) be used as -swap disks. Pages swapped to these devices are compressed and stored in memory -itself. See project home for use cases, performance numbers and a lot more. +The zram module creates RAM based block devices: /dev/ramX (X = 0, 1, ...). +Pages written to these disks are compressed and stored in memory itself. +These disks allow very fast I/O and compression provides good amounts of +memory savings. -Individual ramzswap devices are configured and initialized using rzscontrol -userspace utility as shown in examples below. See rzscontrol man page for more -details. +See project home for use cases, performance numbers and a lot more. + +Individual zram devices are configured and initialized using zramconfig +userspace utility as shown in examples below. See zramconfig man page for +more details. * Usage -Following shows a typical sequence of steps for using ramzswap. +Following shows a typical sequence of steps for using zram. 1) Load Modules: - modprobe ramzswap num_devices=4 - This creates 4 (uninitialized) devices: /dev/ramzswap{0,1,2,3} + modprobe zram num_devices=4 + This creates 4 (uninitialized) devices: /dev/zram{0,1,2,3} (num_devices parameter is optional. Default: 1) 2) Initialize: - Use rzscontrol utility to configure and initialize individual - ramzswap devices. Example: - rzscontrol /dev/ramzswap2 --init # uses default value of disksize_kb + Use zramconfig utility to configure and initialize individual + zram devices. For example: + zramconfig /dev/zram0 --init # uses default value of disksize_kb + zramconfig /dev/zram1 --disksize_kb=102400 # 100MB /dev/zram1 - *See rzscontrol man page for more details and examples* + *See zramconfig man page for more details and examples* 3) Activate: - swapon /dev/ramzswap2 # or any other initialized ramzswap device + mkswap /dev/zram0 + swapon /dev/zram0 + + mkfs.ext4 /dev/zram1 + mount /dev/zram1 /tmp 4) Stats: - rzscontrol /dev/ramzswap2 --stats + zramconfig /dev/zram0 --stats + zramconfig /dev/zram1 --stats 5) Deactivate: - swapoff /dev/ramzswap2 + swapoff /dev/zram0 + umount /dev/zram1 6) Reset: - rzscontrol /dev/ramzswap2 --reset - (This frees all the memory allocated for this device). + zramconfig /dev/zram0 --reset + zramconfig /dev/zram1 --reset + (This frees memory allocated for the given device). Please report any problems at: From 98a62bb7bc55c239c6ecc21e2fdbfa5df7690b30 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 23 May 2010 03:00:02 -0400 Subject: [PATCH 083/523] Staging: iio: standardize kconfig/makefile spacing/style Standardize the spacing/style across the IIO build files: - comment block in Kconfigs - newlines at ends of files - trailing lines at ends of files - indent with one tab, not spaces or mixed Signed-off-by: Mike Frysinger Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/Makefile | 3 +- drivers/staging/iio/accel/Kconfig | 50 ++++++++++++++-------------- drivers/staging/iio/accel/Makefile | 3 +- drivers/staging/iio/adc/Makefile | 2 +- drivers/staging/iio/gyro/Makefile | 2 +- drivers/staging/iio/imu/Kconfig | 8 ++--- drivers/staging/iio/imu/Makefile | 3 +- drivers/staging/iio/light/Kconfig | 1 - drivers/staging/iio/trigger/Makefile | 3 +- 9 files changed, 38 insertions(+), 37 deletions(-) diff --git a/drivers/staging/iio/Makefile b/drivers/staging/iio/Makefile index 3502b39f0847..fff717e38366 100644 --- a/drivers/staging/iio/Makefile +++ b/drivers/staging/iio/Makefile @@ -14,5 +14,4 @@ obj-y += adc/ obj-y += gyro/ obj-y += imu/ obj-y += light/ - -obj-y += trigger/ \ No newline at end of file +obj-y += trigger/ diff --git a/drivers/staging/iio/accel/Kconfig b/drivers/staging/iio/accel/Kconfig index b4e57d1bc87d..5926c03be1a5 100644 --- a/drivers/staging/iio/accel/Kconfig +++ b/drivers/staging/iio/accel/Kconfig @@ -4,29 +4,29 @@ comment "Accelerometers" config ADIS16209 - tristate "Analog Devices ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer" - depends on SPI - select IIO_TRIGGER if IIO_RING_BUFFER - select IIO_SW_RING if IIO_RING_BUFFER - help - Say yes here to build support for Analog Devices adis16209 dual-axis digital inclinometer - and accelerometer. + tristate "Analog Devices ADIS16209 Dual-Axis Digital Inclinometer and Accelerometer" + depends on SPI + select IIO_TRIGGER if IIO_RING_BUFFER + select IIO_SW_RING if IIO_RING_BUFFER + help + Say yes here to build support for Analog Devices adis16209 dual-axis digital inclinometer + and accelerometer. config ADIS16220 - tristate "Analog Devices ADIS16220 Programmable Digital Vibration Sensor driver" - depends on SPI - help - Say yes here to build support for Analog Devices adis16220 programmable - digital vibration sensor. + tristate "Analog Devices ADIS16220 Programmable Digital Vibration Sensor" + depends on SPI + help + Say yes here to build support for Analog Devices adis16220 programmable + digital vibration sensor. config ADIS16240 - tristate "Analog Devices ADIS16240 Programmable Impact Sensor and Recorder" - depends on SPI - select IIO_TRIGGER if IIO_RING_BUFFER - select IIO_SW_RING if IIO_RING_BUFFER - help - Say yes here to build support for Analog Devices adis16240 programmable - impact Sensor and recorder. + tristate "Analog Devices ADIS16240 Programmable Impact Sensor and Recorder" + depends on SPI + select IIO_TRIGGER if IIO_RING_BUFFER + select IIO_SW_RING if IIO_RING_BUFFER + help + Say yes here to build support for Analog Devices adis16240 programmable + impact Sensor and recorder. config KXSD9 tristate "Kionix KXSD9 Accelerometer Driver" @@ -46,9 +46,9 @@ config LIS3L02DQ and an event interface via a character device. config SCA3000 - depends on IIO_RING_BUFFER - depends on SPI - tristate "VTI SCA3000 series accelerometers" - help - Say yes here to build support for the VTI SCA3000 series of SPI - accelerometers. These devices use a hardware ring buffer. \ No newline at end of file + depends on IIO_RING_BUFFER + depends on SPI + tristate "VTI SCA3000 series accelerometers" + help + Say yes here to build support for the VTI SCA3000 series of SPI + accelerometers. These devices use a hardware ring buffer. diff --git a/drivers/staging/iio/accel/Makefile b/drivers/staging/iio/accel/Makefile index c34b13634c2d..ff84703a16f6 100644 --- a/drivers/staging/iio/accel/Makefile +++ b/drivers/staging/iio/accel/Makefile @@ -1,6 +1,7 @@ # # Makefile for industrial I/O accelerometer drivers # + adis16209-y := adis16209_core.o adis16209-$(CONFIG_IIO_RING_BUFFER) += adis16209_ring.o adis16209_trigger.o obj-$(CONFIG_ADIS16209) += adis16209.o @@ -19,4 +20,4 @@ lis3l02dq-$(CONFIG_IIO_RING_BUFFER) += lis3l02dq_ring.o obj-$(CONFIG_LIS3L02DQ) += lis3l02dq.o sca3000-y := sca3000_core.o sca3000_ring.o -obj-$(CONFIG_SCA3000) += sca3000.o \ No newline at end of file +obj-$(CONFIG_SCA3000) += sca3000.o diff --git a/drivers/staging/iio/adc/Makefile b/drivers/staging/iio/adc/Makefile index 18c9376ecbb2..688510fd8bbb 100644 --- a/drivers/staging/iio/adc/Makefile +++ b/drivers/staging/iio/adc/Makefile @@ -1,4 +1,4 @@ - +# # Makefile for industrial I/O ADC drivers # diff --git a/drivers/staging/iio/gyro/Makefile b/drivers/staging/iio/gyro/Makefile index 6d2c547686cb..b5f0dc01122c 100644 --- a/drivers/staging/iio/gyro/Makefile +++ b/drivers/staging/iio/gyro/Makefile @@ -1,4 +1,4 @@ - +# # Makefile for digital gyroscope sensor drivers # diff --git a/drivers/staging/iio/imu/Kconfig b/drivers/staging/iio/imu/Kconfig index 6308d6faad57..48a712e74f98 100644 --- a/drivers/staging/iio/imu/Kconfig +++ b/drivers/staging/iio/imu/Kconfig @@ -24,10 +24,10 @@ config ADIS16350 config ADIS16400 tristate "Analog Devices ADIS16400/5 IMU SPI driver" - depends on SPI + depends on SPI select IIO_SW_RING select IIO_RING_BUFFER select IIO_TRIGGER - help - Say yes here to build support for Analog Devices adis16400/5 triaxial - inertial sensor with Magnetometer. \ No newline at end of file + help + Say yes here to build support for Analog Devices adis16400/5 triaxial + inertial sensor with Magnetometer. diff --git a/drivers/staging/iio/imu/Makefile b/drivers/staging/iio/imu/Makefile index 31df7359e20f..f3b450b66113 100644 --- a/drivers/staging/iio/imu/Makefile +++ b/drivers/staging/iio/imu/Makefile @@ -1,6 +1,7 @@ # # Makefile for Inertial Measurement Units # + adis16300-y := adis16300_core.o adis16300-$(CONFIG_IIO_RING_BUFFER) += adis16300_ring.o adis16300_trigger.o obj-$(CONFIG_ADIS16300) += adis16300.o @@ -11,4 +12,4 @@ obj-$(CONFIG_ADIS16350) += adis16350.o adis16400-y := adis16400_core.o adis16400-$(CONFIG_IIO_RING_BUFFER) += adis16400_ring.o adis16400_trigger.o -obj-$(CONFIG_ADIS16400) += adis16400.o \ No newline at end of file +obj-$(CONFIG_ADIS16400) += adis16400.o diff --git a/drivers/staging/iio/light/Kconfig b/drivers/staging/iio/light/Kconfig index 80cb6e590fbb..3ddc478e6182 100644 --- a/drivers/staging/iio/light/Kconfig +++ b/drivers/staging/iio/light/Kconfig @@ -12,4 +12,3 @@ config SENSORS_TSL2563 This driver can also be built as a module. If so, the module will be called tsl2563. - diff --git a/drivers/staging/iio/trigger/Makefile b/drivers/staging/iio/trigger/Makefile index e5f96d2fe64a..10aeca5e347a 100644 --- a/drivers/staging/iio/trigger/Makefile +++ b/drivers/staging/iio/trigger/Makefile @@ -1,5 +1,6 @@ # # Makefile for triggers not associated with iio-devices # + obj-$(CONFIG_IIO_PERIODIC_RTC_TRIGGER) += iio-trig-periodic-rtc.o -obj-$(CONFIG_IIO_GPIO_TRIGGER) += iio-trig-gpio.o \ No newline at end of file +obj-$(CONFIG_IIO_GPIO_TRIGGER) += iio-trig-gpio.o From c608cb012e150d5c24b400ea89000105134bd564 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 23 May 2010 03:10:30 -0400 Subject: [PATCH 084/523] Staging: iio: kill off spurious semicolons A bunch of IIO files contain spurious semicolons after function definitions and case statements and if statements. Guess people really like this thing, but kill them anyways so they'll stop spreading via copy & paste with new drivers. Signed-off-by: Mike Frysinger Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/lis3l02dq.h | 19 ++++++++++++------- drivers/staging/iio/accel/sca3000.h | 14 +++++++++----- drivers/staging/iio/accel/sca3000_core.c | 14 +++++++------- drivers/staging/iio/adc/max1363.h | 14 ++++++++------ drivers/staging/iio/adc/max1363_core.c | 4 ++-- drivers/staging/iio/adc/max1363_ring.c | 4 ++-- 6 files changed, 40 insertions(+), 29 deletions(-) diff --git a/drivers/staging/iio/accel/lis3l02dq.h b/drivers/staging/iio/accel/lis3l02dq.h index e76a97937a36..0ffa0bbdcd4f 100644 --- a/drivers/staging/iio/accel/lis3l02dq.h +++ b/drivers/staging/iio/accel/lis3l02dq.h @@ -199,11 +199,13 @@ int lis3l02dq_initialize_ring(struct iio_ring_buffer *ring); void lis3l02dq_uninitialize_ring(struct iio_ring_buffer *ring); #else /* CONFIG_IIO_RING_BUFFER */ -static inline void lis3l02dq_remove_trigger(struct iio_dev *indio_dev) {}; +static inline void lis3l02dq_remove_trigger(struct iio_dev *indio_dev) +{ +} static inline int lis3l02dq_probe_trigger(struct iio_dev *indio_dev) { return 0; -}; +} static inline ssize_t lis3l02dq_read_accel_from_ring(struct device *dev, @@ -211,18 +213,21 @@ lis3l02dq_read_accel_from_ring(struct device *dev, char *buf) { return 0; -}; +} static int lis3l02dq_configure_ring(struct iio_dev *indio_dev) { return 0; -}; +} static inline void lis3l02dq_unconfigure_ring(struct iio_dev *indio_dev) -{}; +{ +} static inline int lis3l02dq_initialize_ring(struct iio_ring_buffer *ring) { return 0; -}; -static inline void lis3l02dq_uninitialize_ring(struct iio_ring_buffer *ring) {}; +} +static inline void lis3l02dq_uninitialize_ring(struct iio_ring_buffer *ring) +{ +} #endif /* CONFIG_IIO_RING_BUFFER */ #endif /* SPI_LIS3L02DQ_H_ */ diff --git a/drivers/staging/iio/accel/sca3000.h b/drivers/staging/iio/accel/sca3000.h index e5321999b263..09d9470bb9a0 100644 --- a/drivers/staging/iio/accel/sca3000.h +++ b/drivers/staging/iio/accel/sca3000.h @@ -242,7 +242,7 @@ static inline int sca3000_11bit_convert(uint8_t msb, uint8_t lsb) val |= (val & (1 << 12)) ? 0xE000 : 0; return val; -}; +} static inline int sca3000_13bit_convert(uint8_t msb, uint8_t lsb) { @@ -253,7 +253,7 @@ static inline int sca3000_13bit_convert(uint8_t msb, uint8_t lsb) val |= (val & (1 << 12)) ? 0xE000 : 0; return val; -}; +} #ifdef CONFIG_IIO_RING_BUFFER @@ -286,15 +286,19 @@ void sca3000_unconfigure_ring(struct iio_dev *indio_dev); void sca3000_ring_int_process(u8 val, struct iio_ring_buffer *ring); #else -static inline void sca3000_register_ring_funcs(struct iio_dev *indio_dev) {}; +static inline void sca3000_register_ring_funcs(struct iio_dev *indio_dev) +{ +} static inline int sca3000_register_ring_access_and_init(struct iio_dev *indio_dev) { return 0; -}; +} -static inline void sca3000_ring_int_process(u8 val, void *ring) {}; +static inline void sca3000_ring_int_process(u8 val, void *ring) +{ +} #endif diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index d4f82c39f335..b78b6b66ffe0 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -387,7 +387,7 @@ sca3000_show_available_measurement_modes(struct device *dev, case SCA3000_OP_MODE_BYPASS: len += sprintf(buf + len, ", 1 - bypass mode"); break; - }; + } switch (st->info->option_mode_2) { case SCA3000_OP_MODE_WIDE: len += sprintf(buf + len, ", 2 - wide mode"); @@ -433,7 +433,7 @@ sca3000_show_measurement_mode(struct device *dev, case SCA3000_OP_MODE_BYPASS: len += sprintf(buf + len, "1 - bypass mode\n"); break; - }; + } break; case SCA3000_MEAS_MODE_OP_2: switch (st->info->option_mode_2) { @@ -442,7 +442,7 @@ sca3000_show_measurement_mode(struct device *dev, break; } break; - }; + } error_ret: mutex_unlock(&st->lock); @@ -559,7 +559,7 @@ static ssize_t sca3000_read_av_freq(struct device *dev, st->info->option_mode_2_freq/2, st->info->option_mode_2_freq/4); break; - }; + } kfree(rx); return len; error_ret: @@ -590,7 +590,7 @@ static inline int __sca3000_get_base_freq(struct sca3000_state *st, case SCA3000_MEAS_MODE_OP_2: *base_freq = info->option_mode_2_freq; break; - }; + } kfree(rx); error_ret: return ret; @@ -627,8 +627,8 @@ static ssize_t sca3000_read_frequency(struct device *dev, case 0x02: len = sprintf(buf, "%d\n", base_freq/4); break; - }; - kfree(rx); + } + kfree(rx); return len; error_ret_mut: mutex_unlock(&st->lock); diff --git a/drivers/staging/iio/adc/max1363.h b/drivers/staging/iio/adc/max1363.h index 72cf36709368..6da468bf7d6f 100644 --- a/drivers/staging/iio/adc/max1363.h +++ b/drivers/staging/iio/adc/max1363.h @@ -147,7 +147,7 @@ enum max1363_channels { max1363_in1min0, max1363_in3min2, max1363_in5min4, max1363_in7min6, max1363_in9min8, max1363_in11min10, - }; +}; /* This must be maintained along side the max1363_mode_table in max1363_core */ enum max1363_modes { @@ -237,25 +237,27 @@ void max1363_uninitialize_ring(struct iio_ring_buffer *ring); static inline void max1363_uninitialize_ring(struct iio_ring_buffer *ring) { -}; +} static inline int max1363_initialize_ring(struct iio_ring_buffer *ring) { return 0; -}; +} int max1363_single_channel_from_ring(long mask, struct max1363_state *st) { return -EINVAL; -}; +} static inline int max1363_register_ring_funcs_and_init(struct iio_dev *indio_dev) { return 0; -}; +} -static inline void max1363_ring_cleanup(struct iio_dev *indio_dev) {}; +static inline void max1363_ring_cleanup(struct iio_dev *indio_dev) +{ +} #endif /* CONFIG_MAX1363_RING_BUFFER */ #endif /* _MAX1363_H_ */ diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index 905f8560d31f..fc980146e2ba 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c @@ -148,7 +148,7 @@ const struct max1363_mode mask)) return &max1363_mode_table[ci->mode_list[i]]; return NULL; -}; +} static ssize_t max1363_show_precision(struct device *dev, struct device_attribute *attr, @@ -935,7 +935,7 @@ static int __devinit max1363_probe(struct i2c_client *client, if (!strcmp(max1363_chip_info_tbl[i].name, id->name)) { st->chip_info = &max1363_chip_info_tbl[i]; break; - }; + } /* Unsupported chip */ if (!st->chip_info) { dev_err(&client->dev, "%s is not supported\n", id->name); diff --git a/drivers/staging/iio/adc/max1363_ring.c b/drivers/staging/iio/adc/max1363_ring.c index 56688dc9c92f..a49b3d7aae9f 100644 --- a/drivers/staging/iio/adc/max1363_ring.c +++ b/drivers/staging/iio/adc/max1363_ring.c @@ -262,9 +262,9 @@ void max1363_ring_cleanup(struct iio_dev *indio_dev) void max1363_uninitialize_ring(struct iio_ring_buffer *ring) { iio_ring_buffer_unregister(ring); -}; +} int max1363_initialize_ring(struct iio_ring_buffer *ring) { return iio_ring_buffer_register(ring, 0); -}; +} From 1cb6c1f59431f16e46f0d07398cc789ee0a26731 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 23 May 2010 03:10:35 -0400 Subject: [PATCH 085/523] Staging: iio: pull in slab.h for kmalloc funcs These drivers use kzalloc() but don't include slab.h. They currently build though because the spi.h header will pull in slab.h for us. But rather than rely on that behavior forever, include slab.h explicitly. Signed-off-by: Mike Frysinger Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16209_core.c | 2 +- drivers/staging/iio/accel/adis16209_ring.c | 1 + drivers/staging/iio/accel/adis16220_core.c | 2 +- drivers/staging/iio/accel/adis16240_core.c | 2 +- drivers/staging/iio/accel/adis16240_ring.c | 1 + drivers/staging/iio/gyro/adis16260_core.c | 2 +- drivers/staging/iio/gyro/adis16260_ring.c | 1 + drivers/staging/iio/imu/adis16300_core.c | 2 +- drivers/staging/iio/imu/adis16300_ring.c | 1 + drivers/staging/iio/imu/adis16350_core.c | 2 +- drivers/staging/iio/imu/adis16350_ring.c | 1 + drivers/staging/iio/imu/adis16400_core.c | 2 +- drivers/staging/iio/imu/adis16400_ring.c | 1 + 13 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c index ac375c50f56f..b3acdc37e354 100644 --- a/drivers/staging/iio/accel/adis16209_core.c +++ b/drivers/staging/iio/accel/adis16209_core.c @@ -14,7 +14,7 @@ #include #include #include - +#include #include #include diff --git a/drivers/staging/iio/accel/adis16209_ring.c b/drivers/staging/iio/accel/adis16209_ring.c index 533e28574910..8959ad85bbac 100644 --- a/drivers/staging/iio/accel/adis16209_ring.c +++ b/drivers/staging/iio/accel/adis16209_ring.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c index 6de439fd1675..fefeca281cb9 100644 --- a/drivers/staging/iio/accel/adis16220_core.c +++ b/drivers/staging/iio/accel/adis16220_core.c @@ -14,7 +14,7 @@ #include #include #include - +#include #include #include diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c index 54fd6d77412f..316022f25b19 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c @@ -14,7 +14,7 @@ #include #include #include - +#include #include #include diff --git a/drivers/staging/iio/accel/adis16240_ring.c b/drivers/staging/iio/accel/adis16240_ring.c index 26b677bd84c0..490d80eafbaa 100644 --- a/drivers/staging/iio/accel/adis16240_ring.c +++ b/drivers/staging/iio/accel/adis16240_ring.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index c93f4d580fce..f0246a424739 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -14,7 +14,7 @@ #include #include #include - +#include #include #include diff --git a/drivers/staging/iio/gyro/adis16260_ring.c b/drivers/staging/iio/gyro/adis16260_ring.c index 4c4390ca6d73..2fe7f02d3a21 100644 --- a/drivers/staging/iio/gyro/adis16260_ring.c +++ b/drivers/staging/iio/gyro/adis16260_ring.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/drivers/staging/iio/imu/adis16300_core.c b/drivers/staging/iio/imu/adis16300_core.c index 5a7e5ef9bc5d..bf02fbedee9f 100644 --- a/drivers/staging/iio/imu/adis16300_core.c +++ b/drivers/staging/iio/imu/adis16300_core.c @@ -14,7 +14,7 @@ #include #include #include - +#include #include #include diff --git a/drivers/staging/iio/imu/adis16300_ring.c b/drivers/staging/iio/imu/adis16300_ring.c index 76cf8a6f3c3f..9c01994f40d4 100644 --- a/drivers/staging/iio/imu/adis16300_ring.c +++ b/drivers/staging/iio/imu/adis16300_ring.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/drivers/staging/iio/imu/adis16350_core.c b/drivers/staging/iio/imu/adis16350_core.c index 0edde73ce5c2..145966b04d4c 100644 --- a/drivers/staging/iio/imu/adis16350_core.c +++ b/drivers/staging/iio/imu/adis16350_core.c @@ -14,7 +14,7 @@ #include #include #include - +#include #include #include diff --git a/drivers/staging/iio/imu/adis16350_ring.c b/drivers/staging/iio/imu/adis16350_ring.c index 5e9716ea7c77..2a0a465a42cb 100644 --- a/drivers/staging/iio/imu/adis16350_ring.c +++ b/drivers/staging/iio/imu/adis16350_ring.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index e69e2ce47da3..8957985358d0 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -21,7 +21,7 @@ #include #include #include - +#include #include #include diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c index 5529b32bd2e3..66a91ada954a 100644 --- a/drivers/staging/iio/imu/adis16400_ring.c +++ b/drivers/staging/iio/imu/adis16400_ring.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include From de6c37ad2a602d0123699774cf4b2e3f561846bd Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Mon, 7 Jun 2010 20:54:07 +0100 Subject: [PATCH 086/523] Staging: iio: Add mailing list to the TODO file. As suggested by Charles Clement Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/TODO | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/TODO b/drivers/staging/iio/TODO index 15da0c2bb784..898cba1c939f 100644 --- a/drivers/staging/iio/TODO +++ b/drivers/staging/iio/TODO @@ -66,4 +66,4 @@ Documentation 2) Some device require indvidual docs. Contact: Jonathan Cameron . -Mailing list: LKML. +Mailing list: linux-iio@vger.kernel.org From 794e7d9df26a42b05320a92cef76cd2c150a91e6 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 16 Jun 2010 15:32:07 +0200 Subject: [PATCH 087/523] Staging: iio: add file pointer to sysfs callbacks The sysfs attribute call backs take a file pointer these days. This was added in 2c3c8bea6088 "sysfs: add struct file* to bin_attr callbacks" Signed-off-by: Dan Carpenter Cc: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16220_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c index fefeca281cb9..7daa3d72286c 100644 --- a/drivers/staging/iio/accel/adis16220_core.c +++ b/drivers/staging/iio/accel/adis16220_core.c @@ -414,7 +414,7 @@ static ssize_t adis16220_capture_buffer_read(struct adis16220_state *st, return count; } -static ssize_t adis16220_accel_bin_read(struct kobject *kobj, +static ssize_t adis16220_accel_bin_read(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, char *buf, loff_t off, @@ -438,7 +438,7 @@ static struct bin_attribute accel_bin = { .size = ADIS16220_CAPTURE_SIZE, }; -static ssize_t adis16220_adc1_bin_read(struct kobject *kobj, +static ssize_t adis16220_adc1_bin_read(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, char *buf, loff_t off, size_t count) @@ -461,7 +461,7 @@ static struct bin_attribute adc1_bin = { .size = ADIS16220_CAPTURE_SIZE, }; -static ssize_t adis16220_adc2_bin_read(struct kobject *kobj, +static ssize_t adis16220_adc2_bin_read(struct file *filp, struct kobject *kobj, struct bin_attribute *attr, char *buf, loff_t off, size_t count) From ee9a691e08360a22a8eaefb1289bc2e9cfd493a0 Mon Sep 17 00:00:00 2001 From: Barry Song <21cnbao@gmail.com> Date: Fri, 4 Jun 2010 17:19:52 +0800 Subject: [PATCH 088/523] Staging: iio: adis16300: fix some minor issues and clean-up 1. add delay between spi transfers 2. move burst read to ring function 3. clean-up Signed-off-by: Barry Song <21cnbao@gmail.com> Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/imu/adis16300.h | 6 - drivers/staging/iio/imu/adis16300_core.c | 153 ++++++++++------------- drivers/staging/iio/imu/adis16300_ring.c | 54 +++++++- 3 files changed, 118 insertions(+), 95 deletions(-) diff --git a/drivers/staging/iio/imu/adis16300.h b/drivers/staging/iio/imu/adis16300.h index 1c7ea5c840ef..b050067d502b 100644 --- a/drivers/staging/iio/imu/adis16300.h +++ b/drivers/staging/iio/imu/adis16300.h @@ -115,14 +115,8 @@ struct adis16300_state { struct mutex buf_lock; }; -int adis16300_spi_read_burst(struct device *dev, u8 *rx); - int adis16300_set_irq(struct device *dev, bool enable); -int adis16300_reset(struct device *dev); - -int adis16300_check_status(struct device *dev); - #ifdef CONFIG_IIO_RING_BUFFER /* At the moment triggers are only used for ring buffer * filling. This may change! diff --git a/drivers/staging/iio/imu/adis16300_core.c b/drivers/staging/iio/imu/adis16300_core.c index bf02fbedee9f..28667e8f26cd 100644 --- a/drivers/staging/iio/imu/adis16300_core.c +++ b/drivers/staging/iio/imu/adis16300_core.c @@ -29,10 +29,7 @@ #define DRIVER_NAME "adis16300" -/* At the moment the spi framework doesn't allow global setting of cs_change. - * It's in the likely to be added comment at the top of spi.h. - * This means that use cannot be made of spi_write etc. - */ +static int adis16300_check_status(struct device *dev); /** * adis16300_spi_write_reg_8() - write single byte to a register @@ -79,11 +76,13 @@ static int adis16300_spi_write_reg_16(struct device *dev, .bits_per_word = 8, .len = 2, .cs_change = 1, + .delay_usecs = 75, }, { .tx_buf = st->tx + 2, .bits_per_word = 8, .len = 2, .cs_change = 1, + .delay_usecs = 75, }, }; @@ -122,12 +121,14 @@ static int adis16300_spi_read_reg_16(struct device *dev, .tx_buf = st->tx, .bits_per_word = 8, .len = 2, - .cs_change = 0, + .cs_change = 1, + .delay_usecs = 75, }, { .rx_buf = st->rx, .bits_per_word = 8, .len = 2, - .cs_change = 0, + .cs_change = 1, + .delay_usecs = 75, }, }; @@ -154,54 +155,6 @@ error_ret: return ret; } -/** - * adis16300_spi_read_burst() - read all data registers - * @dev: device associated with child of actual device (iio_dev or iio_trig) - * @rx: somewhere to pass back the value read (min size is 24 bytes) - **/ -int adis16300_spi_read_burst(struct device *dev, u8 *rx) -{ - struct spi_message msg; - struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct adis16300_state *st = iio_dev_get_devdata(indio_dev); - u32 old_speed_hz = st->us->max_speed_hz; - int ret; - - struct spi_transfer xfers[] = { - { - .tx_buf = st->tx, - .bits_per_word = 8, - .len = 2, - .cs_change = 0, - }, { - .rx_buf = rx, - .bits_per_word = 8, - .len = 18, - .cs_change = 0, - }, - }; - - mutex_lock(&st->buf_lock); - st->tx[0] = ADIS16300_READ_REG(ADIS16300_GLOB_CMD); - st->tx[1] = 0; - - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - - st->us->max_speed_hz = min(ADIS16300_SPI_BURST, old_speed_hz); - spi_setup(st->us); - - ret = spi_sync(st->us, &msg); - if (ret) - dev_err(&st->us->dev, "problem when burst reading"); - - st->us->max_speed_hz = old_speed_hz; - spi_setup(st->us); - mutex_unlock(&st->buf_lock); - return ret; -} - static ssize_t adis16300_spi_read_signed(struct device *dev, struct device_attribute *attr, char *buf, @@ -240,6 +193,24 @@ static ssize_t adis16300_read_12bit_unsigned(struct device *dev, return sprintf(buf, "%u\n", val & 0x0FFF); } +static ssize_t adis16300_read_14bit_unsigned(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int ret; + u16 val = 0; + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + + ret = adis16300_spi_read_reg_16(dev, this_attr->address, &val); + if (ret) + return ret; + + if (val & ADIS16300_ERROR_ACTIVE) + adis16300_check_status(dev); + + return sprintf(buf, "%u\n", val & 0x3FFF); +} + static ssize_t adis16300_read_14bit_signed(struct device *dev, struct device_attribute *attr, char *buf) @@ -356,6 +327,18 @@ static ssize_t adis16300_write_frequency(struct device *dev, return ret ? ret : len; } +static int adis16300_reset(struct device *dev) +{ + int ret; + ret = adis16300_spi_write_reg_8(dev, + ADIS16300_GLOB_CMD, + ADIS16300_GLOB_CMD_SW_RESET); + if (ret) + dev_err(dev, "problem resetting device"); + + return ret; +} + static ssize_t adis16300_write_reset(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) @@ -371,8 +354,6 @@ static ssize_t adis16300_write_reset(struct device *dev, return -1; } - - int adis16300_set_irq(struct device *dev, bool enable) { int ret; @@ -396,18 +377,6 @@ error_ret: return ret; } -int adis16300_reset(struct device *dev) -{ - int ret; - ret = adis16300_spi_write_reg_8(dev, - ADIS16300_GLOB_CMD, - ADIS16300_GLOB_CMD_SW_RESET); - if (ret) - dev_err(dev, "problem resetting device"); - - return ret; -} - /* Power down the device */ static int adis16300_stop_device(struct device *dev) { @@ -421,7 +390,24 @@ static int adis16300_stop_device(struct device *dev) return ret; } -int adis16300_check_status(struct device *dev) +static int adis16300_self_test(struct device *dev) +{ + int ret; + ret = adis16300_spi_write_reg_16(dev, + ADIS16300_MSC_CTRL, + ADIS16300_MSC_CTRL_MEM_TEST); + if (ret) { + dev_err(dev, "problem starting self test"); + goto err_ret; + } + + adis16300_check_status(dev); + +err_ret: + return ret; +} + +static int adis16300_check_status(struct device *dev) { u16 status; int ret; @@ -483,6 +469,11 @@ static int adis16300_initial_setup(struct adis16300_state *st) } /* Do self test */ + ret = adis16300_self_test(dev); + if (ret) { + dev_err(dev, "self test failure"); + goto err_ret; + } /* Read status register to check the result */ ret = adis16300_check_status(dev); @@ -526,7 +517,7 @@ static IIO_DEV_ATTR_ACCEL_Z_OFFSET(S_IWUSR | S_IRUGO, adis16300_write_16bit, ADIS16300_ZACCL_OFF); -static IIO_DEV_ATTR_IN_NAMED_RAW(supply, adis16300_read_14bit_signed, +static IIO_DEV_ATTR_IN_NAMED_RAW(supply, adis16300_read_14bit_unsigned, ADIS16300_SUPPLY_OUT); static IIO_CONST_ATTR(in_supply_scale, "0.00242"); @@ -548,7 +539,7 @@ static IIO_DEV_ATTR_INCLI_Y(adis16300_read_13bit_signed, ADIS16300_YINCLI_OUT); static IIO_CONST_ATTR(incli_scale, "0.044 d"); -static IIO_DEV_ATTR_TEMP_RAW(adis16300_read_12bit_signed); +static IIO_DEV_ATTR_TEMP_RAW(adis16300_read_12bit_unsigned); static IIO_CONST_ATTR(temp_offset, "198.16 K"); static IIO_CONST_ATTR(temp_scale, "0.14 K"); @@ -659,15 +650,7 @@ static int __devinit adis16300_probe(struct spi_device *spi) goto error_unreg_ring_funcs; } - if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) { -#if 0 /* fixme: here we should support */ - iio_init_work_cont(&st->work_cont_thresh, - NULL, - adis16300_thresh_handler_bh_no_check, - 0, - 0, - st); -#endif + if (spi->irq) { ret = iio_register_interrupt_line(spi->irq, st->indio_dev, 0, @@ -688,10 +671,9 @@ static int __devinit adis16300_probe(struct spi_device *spi) return 0; error_remove_trigger: - if (st->indio_dev->modes & INDIO_RING_TRIGGERED) - adis16300_remove_trigger(st->indio_dev); + adis16300_remove_trigger(st->indio_dev); error_unregister_line: - if (st->indio_dev->modes & INDIO_RING_TRIGGERED) + if (spi->irq) iio_unregister_interrupt_line(st->indio_dev, 0); error_uninitialize_ring: adis16300_uninitialize_ring(st->indio_dev->ring); @@ -712,7 +694,6 @@ error_ret: return ret; } -/* fixme, confirm ordering in this function */ static int adis16300_remove(struct spi_device *spi) { int ret; @@ -726,12 +707,12 @@ static int adis16300_remove(struct spi_device *spi) flush_scheduled_work(); adis16300_remove_trigger(indio_dev); - if (spi->irq && gpio_is_valid(irq_to_gpio(spi->irq)) > 0) + if (spi->irq) iio_unregister_interrupt_line(indio_dev, 0); adis16300_uninitialize_ring(indio_dev->ring); - adis16300_unconfigure_ring(indio_dev); iio_device_unregister(indio_dev); + adis16300_unconfigure_ring(indio_dev); kfree(st->tx); kfree(st->rx); kfree(st); diff --git a/drivers/staging/iio/imu/adis16300_ring.c b/drivers/staging/iio/imu/adis16300_ring.c index 9c01994f40d4..17ceb72e0bfe 100644 --- a/drivers/staging/iio/imu/adis16300_ring.c +++ b/drivers/staging/iio/imu/adis16300_ring.c @@ -27,7 +27,7 @@ static inline u16 combine_8_to_16(u8 lower, u8 upper) return _lower | (_upper << 8); } -static IIO_SCAN_EL_C(supply, ADIS16300_SCAN_SUPPLY, IIO_SIGNED(14), +static IIO_SCAN_EL_C(supply, ADIS16300_SCAN_SUPPLY, IIO_UNSIGNED(14), ADIS16300_SUPPLY_OUT, NULL); static IIO_SCAN_EL_C(gyro_x, ADIS16300_SCAN_GYRO_X, IIO_SIGNED(14), @@ -40,9 +40,9 @@ static IIO_SCAN_EL_C(accel_y, ADIS16300_SCAN_ACC_Y, IIO_SIGNED(14), static IIO_SCAN_EL_C(accel_z, ADIS16300_SCAN_ACC_Z, IIO_SIGNED(14), ADIS16300_ZACCL_OUT, NULL); -static IIO_SCAN_EL_C(temp, ADIS16300_SCAN_TEMP, IIO_SIGNED(12), +static IIO_SCAN_EL_C(temp, ADIS16300_SCAN_TEMP, IIO_UNSIGNED(12), ADIS16300_TEMP_OUT, NULL); -static IIO_SCAN_EL_C(adc_0, ADIS16300_SCAN_ADC_0, IIO_SIGNED(12), +static IIO_SCAN_EL_C(adc_0, ADIS16300_SCAN_ADC_0, IIO_UNSIGNED(12), ADIS16300_AUX_ADC, NULL); static IIO_SCAN_EL_C(incli_x, ADIS16300_SCAN_INCLI_X, IIO_SIGNED(12), @@ -88,6 +88,54 @@ static void adis16300_poll_func_th(struct iio_dev *indio_dev) */ } +/** + * adis16300_spi_read_burst() - read all data registers + * @dev: device associated with child of actual device (iio_dev or iio_trig) + * @rx: somewhere to pass back the value read (min size is 24 bytes) + **/ +static int adis16300_spi_read_burst(struct device *dev, u8 *rx) +{ + struct spi_message msg; + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct adis16300_state *st = iio_dev_get_devdata(indio_dev); + u32 old_speed_hz = st->us->max_speed_hz; + int ret; + + struct spi_transfer xfers[] = { + { + .tx_buf = st->tx, + .bits_per_word = 8, + .len = 2, + .cs_change = 0, + }, { + .rx_buf = rx, + .bits_per_word = 8, + .len = 18, + .cs_change = 0, + }, + }; + + mutex_lock(&st->buf_lock); + st->tx[0] = ADIS16300_READ_REG(ADIS16300_GLOB_CMD); + st->tx[1] = 0; + + spi_message_init(&msg); + spi_message_add_tail(&xfers[0], &msg); + spi_message_add_tail(&xfers[1], &msg); + + st->us->max_speed_hz = ADIS16300_SPI_BURST; + spi_setup(st->us); + + ret = spi_sync(st->us, &msg); + if (ret) + dev_err(&st->us->dev, "problem when burst reading"); + + st->us->max_speed_hz = old_speed_hz; + spi_setup(st->us); + mutex_unlock(&st->buf_lock); + return ret; +} + /* Whilst this makes a lot of calls to iio_sw_ring functions - it is to device * specific to be rolled into the core. */ From 3fd66da1d529c65488a84f54d8da7bed972fd14f Mon Sep 17 00:00:00 2001 From: Barry Song <21cnbao@gmail.com> Date: Fri, 4 Jun 2010 17:19:53 +0800 Subject: [PATCH 089/523] Staging: iio: adis16400: fix some minor issues and clean-up 1. move adis16400_spi_read_burst() to adis16400_ring.c since it is only called there 2. add the lost calling to adis16400_self_test() 3. codes cleanup Signed-off-by: Barry Song <21cnbao@gmail.com> Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/imu/adis16400.h | 6 -- drivers/staging/iio/imu/adis16400_core.c | 84 ++++++------------------ drivers/staging/iio/imu/adis16400_ring.c | 48 ++++++++++++++ 3 files changed, 68 insertions(+), 70 deletions(-) diff --git a/drivers/staging/iio/imu/adis16400.h b/drivers/staging/iio/imu/adis16400.h index 5a69a7ab91ce..04bae36ed5ab 100644 --- a/drivers/staging/iio/imu/adis16400.h +++ b/drivers/staging/iio/imu/adis16400.h @@ -147,14 +147,8 @@ struct adis16400_state { struct mutex buf_lock; }; -int adis16400_spi_read_burst(struct device *dev, u8 *rx); - int adis16400_set_irq(struct device *dev, bool enable); -int adis16400_reset(struct device *dev); - -int adis16400_check_status(struct device *dev); - #ifdef CONFIG_IIO_RING_BUFFER /* At the moment triggers are only used for ring buffer * filling. This may change! diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index 8957985358d0..a668a90beb4f 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -36,6 +36,8 @@ #define DRIVER_NAME "adis16400" +static int adis16400_check_status(struct device *dev); + /* At the moment the spi framework doesn't allow global setting of cs_change. * It's in the likely to be added comment at the top of spi.h. * This means that use cannot be made of spi_write etc. @@ -161,54 +163,6 @@ error_ret: return ret; } -/** - * adis16400_spi_read_burst() - read all data registers - * @dev: device associated with child of actual device (iio_dev or iio_trig) - * @rx: somewhere to pass back the value read (min size is 24 bytes) - **/ -int adis16400_spi_read_burst(struct device *dev, u8 *rx) -{ - struct spi_message msg; - struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct adis16400_state *st = iio_dev_get_devdata(indio_dev); - u32 old_speed_hz = st->us->max_speed_hz; - int ret; - - struct spi_transfer xfers[] = { - { - .tx_buf = st->tx, - .bits_per_word = 8, - .len = 2, - .cs_change = 0, - }, { - .rx_buf = rx, - .bits_per_word = 8, - .len = 24, - .cs_change = 1, - }, - }; - - mutex_lock(&st->buf_lock); - st->tx[0] = ADIS16400_READ_REG(ADIS16400_GLOB_CMD); - st->tx[1] = 0; - - spi_message_init(&msg); - spi_message_add_tail(&xfers[0], &msg); - spi_message_add_tail(&xfers[1], &msg); - - st->us->max_speed_hz = min(ADIS16400_SPI_BURST, old_speed_hz); - spi_setup(st->us); - - ret = spi_sync(st->us, &msg); - if (ret) - dev_err(&st->us->dev, "problem when burst reading"); - - st->us->max_speed_hz = old_speed_hz; - spi_setup(st->us); - mutex_unlock(&st->buf_lock); - return ret; -} - static ssize_t adis16400_spi_read_signed(struct device *dev, struct device_attribute *attr, char *buf, @@ -277,7 +231,6 @@ static ssize_t adis16400_read_12bit_signed(struct device *dev, return ret; } - static ssize_t adis16400_write_16bit(struct device *dev, struct device_attribute *attr, const char *buf, @@ -349,6 +302,18 @@ static ssize_t adis16400_write_frequency(struct device *dev, return ret ? ret : len; } +static int adis16400_reset(struct device *dev) +{ + int ret; + ret = adis16400_spi_write_reg_8(dev, + ADIS16400_GLOB_CMD, + ADIS16400_GLOB_CMD_SW_RESET); + if (ret) + dev_err(dev, "problem resetting device"); + + return ret; +} + static ssize_t adis16400_write_reset(struct device *dev, struct device_attribute *attr, const char *buf, size_t len) @@ -364,8 +329,6 @@ static ssize_t adis16400_write_reset(struct device *dev, return -1; } - - int adis16400_set_irq(struct device *dev, bool enable) { int ret; @@ -388,18 +351,6 @@ error_ret: return ret; } -int adis16400_reset(struct device *dev) -{ - int ret; - ret = adis16400_spi_write_reg_8(dev, - ADIS16400_GLOB_CMD, - ADIS16400_GLOB_CMD_SW_RESET); - if (ret) - dev_err(dev, "problem resetting device"); - - return ret; -} - /* Power down the device */ static int adis16400_stop_device(struct device *dev) { @@ -430,7 +381,7 @@ err_ret: return ret; } -int adis16400_check_status(struct device *dev) +static int adis16400_check_status(struct device *dev) { u16 status; int ret; @@ -496,6 +447,11 @@ static int adis16400_initial_setup(struct adis16400_state *st) } /* Do self test */ + ret = adis16400_self_test(dev); + if (ret) { + dev_err(dev, "self test failure"); + goto err_ret; + } /* Read status register to check the result */ ret = adis16400_check_status(dev); diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c index 66a91ada954a..5d94cdc2ea2d 100644 --- a/drivers/staging/iio/imu/adis16400_ring.c +++ b/drivers/staging/iio/imu/adis16400_ring.c @@ -97,6 +97,54 @@ static void adis16400_poll_func_th(struct iio_dev *indio_dev) */ } +/** + * adis16400_spi_read_burst() - read all data registers + * @dev: device associated with child of actual device (iio_dev or iio_trig) + * @rx: somewhere to pass back the value read (min size is 24 bytes) + **/ +static int adis16400_spi_read_burst(struct device *dev, u8 *rx) +{ + struct spi_message msg; + struct iio_dev *indio_dev = dev_get_drvdata(dev); + struct adis16400_state *st = iio_dev_get_devdata(indio_dev); + u32 old_speed_hz = st->us->max_speed_hz; + int ret; + + struct spi_transfer xfers[] = { + { + .tx_buf = st->tx, + .bits_per_word = 8, + .len = 2, + .cs_change = 0, + }, { + .rx_buf = rx, + .bits_per_word = 8, + .len = 24, + .cs_change = 1, + }, + }; + + mutex_lock(&st->buf_lock); + st->tx[0] = ADIS16400_READ_REG(ADIS16400_GLOB_CMD); + st->tx[1] = 0; + + spi_message_init(&msg); + spi_message_add_tail(&xfers[0], &msg); + spi_message_add_tail(&xfers[1], &msg); + + st->us->max_speed_hz = min(ADIS16400_SPI_BURST, old_speed_hz); + spi_setup(st->us); + + ret = spi_sync(st->us, &msg); + if (ret) + dev_err(&st->us->dev, "problem when burst reading"); + + st->us->max_speed_hz = old_speed_hz; + spi_setup(st->us); + mutex_unlock(&st->buf_lock); + return ret; +} + /* Whilst this makes a lot of calls to iio_sw_ring functions - it is to device * specific to be rolled into the core. */ From 00ae79463e026b8bc45c93a87aadf118f04069e0 Mon Sep 17 00:00:00 2001 From: Barry Song <21cnbao@gmail.com> Date: Fri, 4 Jun 2010 17:19:54 +0800 Subject: [PATCH 090/523] Staging: iio: adis16209/220/240/350: tuning spi delay to make hardware more stable Signed-off-by: Barry Song <21cnbao@gmail.com> Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/staging/iio/accel/adis16209_core.c | 6 ++++-- drivers/staging/iio/accel/adis16220_core.c | 12 ++++++------ drivers/staging/iio/accel/adis16240_core.c | 8 ++++---- drivers/staging/iio/imu/adis16350_core.c | 8 ++++---- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c index b3acdc37e354..c696160fc2a0 100644 --- a/drivers/staging/iio/accel/adis16209_core.c +++ b/drivers/staging/iio/accel/adis16209_core.c @@ -76,11 +76,13 @@ static int adis16209_spi_write_reg_16(struct device *dev, .bits_per_word = 8, .len = 2, .cs_change = 1, + .delay_usecs = 30, }, { .tx_buf = st->tx + 2, .bits_per_word = 8, .len = 2, .cs_change = 1, + .delay_usecs = 30, }, }; @@ -120,13 +122,13 @@ static int adis16209_spi_read_reg_16(struct device *dev, .bits_per_word = 8, .len = 2, .cs_change = 1, - .delay_usecs = 20, + .delay_usecs = 30, }, { .rx_buf = st->rx, .bits_per_word = 8, .len = 2, .cs_change = 1, - .delay_usecs = 20, + .delay_usecs = 30, }, }; diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c index 7daa3d72286c..bb7d76539cd7 100644 --- a/drivers/staging/iio/accel/adis16220_core.c +++ b/drivers/staging/iio/accel/adis16220_core.c @@ -72,13 +72,13 @@ static int adis16220_spi_write_reg_16(struct device *dev, .bits_per_word = 8, .len = 2, .cs_change = 1, - .delay_usecs = 25, + .delay_usecs = 35, }, { .tx_buf = st->tx + 2, .bits_per_word = 8, .len = 2, .cs_change = 1, - .delay_usecs = 25, + .delay_usecs = 35, }, }; @@ -118,13 +118,13 @@ static int adis16220_spi_read_reg_16(struct device *dev, .bits_per_word = 8, .len = 2, .cs_change = 1, - .delay_usecs = 25, + .delay_usecs = 35, }, { .rx_buf = st->rx, .bits_per_word = 8, .len = 2, .cs_change = 1, - .delay_usecs = 25, + .delay_usecs = 35, }, }; @@ -291,9 +291,9 @@ static int adis16220_check_status(struct device *dev) if (status & ADIS16220_DIAG_STAT_FLASH_UPT) dev_err(dev, "Flash update failed\n"); if (status & ADIS16220_DIAG_STAT_POWER_HIGH) - dev_err(dev, "Power supply above 5.25V\n"); + dev_err(dev, "Power supply above 3.625V\n"); if (status & ADIS16220_DIAG_STAT_POWER_LOW) - dev_err(dev, "Power supply below 4.75V\n"); + dev_err(dev, "Power supply below 3.15V\n"); error_ret: return ret; diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c index 316022f25b19..ba336cbea809 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c @@ -74,13 +74,13 @@ static int adis16240_spi_write_reg_16(struct device *dev, .bits_per_word = 8, .len = 2, .cs_change = 1, - .delay_usecs = 25, + .delay_usecs = 35, }, { .tx_buf = st->tx + 2, .bits_per_word = 8, .len = 2, .cs_change = 1, - .delay_usecs = 25, + .delay_usecs = 35, }, }; @@ -120,13 +120,13 @@ static int adis16240_spi_read_reg_16(struct device *dev, .bits_per_word = 8, .len = 2, .cs_change = 1, - .delay_usecs = 25, + .delay_usecs = 35, }, { .rx_buf = st->rx, .bits_per_word = 8, .len = 2, .cs_change = 1, - .delay_usecs = 25, + .delay_usecs = 35, }, }; diff --git a/drivers/staging/iio/imu/adis16350_core.c b/drivers/staging/iio/imu/adis16350_core.c index 145966b04d4c..0bb19a9d12f5 100644 --- a/drivers/staging/iio/imu/adis16350_core.c +++ b/drivers/staging/iio/imu/adis16350_core.c @@ -75,13 +75,13 @@ static int adis16350_spi_write_reg_16(struct device *dev, .bits_per_word = 8, .len = 2, .cs_change = 1, - .delay_usecs = 25, + .delay_usecs = 35, }, { .tx_buf = st->tx + 2, .bits_per_word = 8, .len = 2, .cs_change = 1, - .delay_usecs = 25, + .delay_usecs = 35, }, }; @@ -121,13 +121,13 @@ static int adis16350_spi_read_reg_16(struct device *dev, .bits_per_word = 8, .len = 2, .cs_change = 1, - .delay_usecs = 25, + .delay_usecs = 35, }, { .rx_buf = st->rx, .bits_per_word = 8, .len = 2, .cs_change = 1, - .delay_usecs = 25, + .delay_usecs = 35, }, }; From e3613299b53dd35b99610d26779064965e0f091a Mon Sep 17 00:00:00 2001 From: Matthias Brugger Date: Thu, 20 May 2010 23:54:34 +0200 Subject: [PATCH 091/523] Staging: adis16255: missing spacess in log messages added Signed-off-by: Matthias Brugger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/adis16255/adis16255.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/adis16255/adis16255.c b/drivers/staging/adis16255/adis16255.c index 55d66e290f7d..c3e6a4d5f334 100644 --- a/drivers/staging/adis16255/adis16255.c +++ b/drivers/staging/adis16255/adis16255.c @@ -303,7 +303,7 @@ static int spi_adis16255_bringup(struct spi_adis16255_data *spiadis) if (status != 0) goto err; if (value != 0x0800) { - dev_warn(&spiadis->spi->dev, "Scale factor is none default" + dev_warn(&spiadis->spi->dev, "Scale factor is none default " "value (%.4x)\n", value); } @@ -338,7 +338,7 @@ static int spi_adis16255_bringup(struct spi_adis16255_data *spiadis) status = -ENODEV; goto err; } else if (value & 0x3) { - dev_warn(&spiadis->spi->dev, "Sensor voltage" + dev_warn(&spiadis->spi->dev, "Sensor voltage " "out of range.\n"); status = -ENODEV; goto err; From 45f9f018967c3fc112a03a99a8fdfad3621407a7 Mon Sep 17 00:00:00 2001 From: Nanakos Chrysostomos Date: Fri, 28 May 2010 10:54:45 +0000 Subject: [PATCH 092/523] Staging: vme: devices: vme_user.c: Fix checkpatch.pl issues. Fix resolves checkpatch.pl issues for vme_user.c file. Signed-off-by: Nanakos Chrysostomos Signed-off-by: Martyn Welch Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/devices/vme_user.c | 92 +++++++++++++------------- 1 file changed, 45 insertions(+), 47 deletions(-) diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index bc16fc070fd3..326991c7d47b 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -34,8 +34,8 @@ #include #include -#include -#include +#include +#include #include "../vme.h" #include "vme_user.h" @@ -48,19 +48,19 @@ static int bus_num; /* Currently Documentation/devices.txt defines the following for VME: * * 221 char VME bus - * 0 = /dev/bus/vme/m0 First master image - * 1 = /dev/bus/vme/m1 Second master image - * 2 = /dev/bus/vme/m2 Third master image - * 3 = /dev/bus/vme/m3 Fourth master image - * 4 = /dev/bus/vme/s0 First slave image - * 5 = /dev/bus/vme/s1 Second slave image - * 6 = /dev/bus/vme/s2 Third slave image - * 7 = /dev/bus/vme/s3 Fourth slave image - * 8 = /dev/bus/vme/ctl Control + * 0 = /dev/bus/vme/m0 First master image + * 1 = /dev/bus/vme/m1 Second master image + * 2 = /dev/bus/vme/m2 Third master image + * 3 = /dev/bus/vme/m3 Fourth master image + * 4 = /dev/bus/vme/s0 First slave image + * 5 = /dev/bus/vme/s1 Second slave image + * 6 = /dev/bus/vme/s2 Third slave image + * 7 = /dev/bus/vme/s3 Fourth slave image + * 8 = /dev/bus/vme/ctl Control * - * It is expected that all VME bus drivers will use the - * same interface. For interface documentation see - * http://www.vmelinux.org/. + * It is expected that all VME bus drivers will use the + * same interface. For interface documentation see + * http://www.vmelinux.org/. * * However the VME driver at http://www.vmelinux.org/ is rather old and doesn't * even support the tsi148 chipset (which has 8 master and 8 slave windows). @@ -137,12 +137,12 @@ static int __init vme_user_probe(struct device *, int, int); static int __exit vme_user_remove(struct device *, int, int); static struct file_operations vme_user_fops = { - .open = vme_user_open, - .release = vme_user_release, - .read = vme_user_read, - .write = vme_user_write, - .llseek = vme_user_llseek, - .unlocked_ioctl = vme_user_unlocked_ioctl, + .open = vme_user_open, + .release = vme_user_release, + .read = vme_user_read, + .write = vme_user_write, + .llseek = vme_user_llseek, + .unlocked_ioctl = vme_user_unlocked_ioctl, }; @@ -151,13 +151,13 @@ static struct file_operations vme_user_fops = { */ static void reset_counters(void) { - statistics.reads = 0; - statistics.writes = 0; - statistics.ioctls = 0; - statistics.irqs = 0; - statistics.berrs = 0; - statistics.dmaErrors = 0; - statistics.timeouts = 0; + statistics.reads = 0; + statistics.writes = 0; + statistics.ioctls = 0; + statistics.irqs = 0; + statistics.berrs = 0; + statistics.dmaErrors = 0; + statistics.timeouts = 0; } static int vme_user_open(struct inode *inode, struct file *file) @@ -216,21 +216,20 @@ static ssize_t resource_to_user(int minor, char __user *buf, size_t count, /* We copy to kernel buffer */ copied = vme_master_read(image[minor].resource, image[minor].kern_buf, count, *ppos); - if (copied < 0) { + if (copied < 0) return (int)copied; - } retval = __copy_to_user(buf, image[minor].kern_buf, (unsigned long)copied); if (retval != 0) { copied = (copied - retval); - printk("User copy failed\n"); + printk(KERN_INFO "User copy failed\n"); return -EINVAL; } } else { /* XXX Need to write this */ - printk("Currently don't support large transfers\n"); + printk(KERN_INFO "Currently don't support large transfers\n"); /* Map in pages from userspace */ /* Call vme_master_read to do the transfer */ @@ -264,7 +263,7 @@ static ssize_t resource_from_user(unsigned int minor, const char *buf, image[minor].kern_buf, copied, *ppos); } else { /* XXX Need to write this */ - printk("Currently don't support large transfers\n"); + printk(KERN_INFO "Currently don't support large transfers\n"); /* Map in pages from userspace */ /* Call vme_master_write to do the transfer */ @@ -313,7 +312,7 @@ static ssize_t buffer_from_user(unsigned int minor, const char *buf, } static ssize_t vme_user_read(struct file *file, char *buf, size_t count, - loff_t * ppos) + loff_t *ppos) { unsigned int minor = MINOR(file->f_dentry->d_inode->i_rdev); ssize_t retval; @@ -337,7 +336,7 @@ static ssize_t vme_user_read(struct file *file, char *buf, size_t count, else okcount = count; - switch (type[minor]){ + switch (type[minor]) { case MASTER_MINOR: retval = resource_to_user(minor, buf, okcount, ppos); break; @@ -380,7 +379,7 @@ static ssize_t vme_user_write(struct file *file, const char *buf, size_t count, else okcount = count; - switch (type[minor]){ + switch (type[minor]) { case MASTER_MINOR: retval = resource_from_user(minor, buf, okcount, ppos); break; @@ -571,7 +570,7 @@ vme_user_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) /* * Unallocate a previously allocated buffer */ -static void buf_unalloc (int num) +static void buf_unalloc(int num) { if (image[num].kern_buf) { #ifdef VME_DEBUG @@ -594,8 +593,8 @@ static void buf_unalloc (int num) } static struct vme_driver vme_user_driver = { - .name = driver_name, - .probe = vme_user_probe, + .name = driver_name, + .probe = vme_user_probe, .remove = vme_user_remove, }; @@ -770,16 +769,16 @@ static int __init vme_user_probe(struct device *dev, int cur_bus, int cur_slot) } /* Add sysfs Entries */ - for (i=0; i 0){ + while (i > 0) { i--; device_destroy(vme_user_sysfs_class, MKDEV(VME_MAJOR, i)); } @@ -845,9 +844,8 @@ static int __exit vme_user_remove(struct device *dev, int cur_bus, int cur_slot) int i; /* Remove sysfs Entries */ - for(i=0; i Date: Wed, 26 May 2010 17:59:11 +0200 Subject: [PATCH 093/523] Staging: vme: bridges: Add missing unlocks Add a spin_unlock and mutex_unlock missing on the error path. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression E1; @@ * spin_lock(E1,...); <+... when != E1 if (...) { ... when != E1 * return ...; } ...+> * spin_unlock(E1,...); // Signed-off-by: Julia Lawall Signed-off-by: Martyn Welch Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/bridges/vme_ca91cx42.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/vme/bridges/vme_ca91cx42.c b/drivers/staging/vme/bridges/vme_ca91cx42.c index 0f9ea58ff717..16cf53e38a74 100644 --- a/drivers/staging/vme/bridges/vme_ca91cx42.c +++ b/drivers/staging/vme/bridges/vme_ca91cx42.c @@ -900,7 +900,8 @@ unsigned int ca91cx42_master_rmw(struct vme_master_resource *image, /* Address must be 4-byte aligned */ if (pci_addr & 0x3) { dev_err(dev, "RMW Address not 4-byte aligned\n"); - return -EINVAL; + result = -EINVAL; + goto out; } /* Ensure RMW Disabled whilst configuring */ @@ -921,6 +922,7 @@ unsigned int ca91cx42_master_rmw(struct vme_master_resource *image, /* Disable RMW */ iowrite32(0, bridge->base + SCYC_CTL); +out: spin_unlock(&(image->lock)); mutex_unlock(&(bridge->vme_rmw)); From 37a18632b00f0d1627556c532f719ad5a08b369f Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Sat, 22 May 2010 10:27:02 +0200 Subject: [PATCH 094/523] Staging: dream: camera: Use memdup_user Use memdup_user when user data is immediately copied into the allocated region. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression from,to,size,flag; position p; identifier l1,l2; @@ - to = \(kmalloc@p\|kzalloc@p\)(size,flag); + to = memdup_user(from,size); if ( - to==NULL + IS_ERR(to) || ...) { <+... when != goto l1; - -ENOMEM + PTR_ERR(to) ...+> } - if (copy_from_user(to, from, size) != 0) { - <+... when != goto l2; - -EFAULT - ...+> - } // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dream/camera/msm_vfe8x.c | 45 +++++++----------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/drivers/staging/dream/camera/msm_vfe8x.c b/drivers/staging/dream/camera/msm_vfe8x.c index e61fdba62838..d87d56f914de 100644 --- a/drivers/staging/dream/camera/msm_vfe8x.c +++ b/drivers/staging/dream/camera/msm_vfe8x.c @@ -644,17 +644,10 @@ static int vfe_config(struct msm_vfe_cfg_cmd *cmd, void *data) if (!axid) return -EFAULT; - axio = - kmalloc(sizeof(struct vfe_cmd_axi_output_config), - GFP_ATOMIC); - if (!axio) - return -ENOMEM; - - if (copy_from_user(axio, (void __user *)(vfecmd.value), - sizeof(struct vfe_cmd_axi_output_config))) { - kfree(axio); - return -EFAULT; - } + axio = memdup_user((void __user *)(vfecmd.value), + sizeof(struct vfe_cmd_axi_output_config)); + if (IS_ERR(axio)) + return PTR_ERR(axio); vfe_config_axi(OUTPUT_1, axid, axio); vfe_axi_output_config(axio); @@ -669,17 +662,10 @@ static int vfe_config(struct msm_vfe_cfg_cmd *cmd, void *data) if (!axid) return -EFAULT; - axio = - kmalloc(sizeof(struct vfe_cmd_axi_output_config), - GFP_ATOMIC); - if (!axio) - return -ENOMEM; - - if (copy_from_user(axio, (void __user *)(vfecmd.value), - sizeof(struct vfe_cmd_axi_output_config))) { - kfree(axio); - return -EFAULT; - } + axio = memdup_user((void __user *)(vfecmd.value), + sizeof(struct vfe_cmd_axi_output_config)); + if (IS_ERR(axio)) + return PTR_ERR(axio); vfe_config_axi(OUTPUT_2, axid, axio); @@ -694,17 +680,10 @@ static int vfe_config(struct msm_vfe_cfg_cmd *cmd, void *data) if (!axid) return -EFAULT; - axio = - kmalloc(sizeof(struct vfe_cmd_axi_output_config), - GFP_ATOMIC); - if (!axio) - return -ENOMEM; - - if (copy_from_user(axio, (void __user *)(vfecmd.value), - sizeof(struct vfe_cmd_axi_output_config))) { - kfree(axio); - return -EFAULT; - } + axio = memdup_user((void __user *)(vfecmd.value), + sizeof(struct vfe_cmd_axi_output_config)); + if (IS_ERR(axio)) + return PTR_ERR(axio); vfe_config_axi(OUTPUT_1_AND_2, axid, axio); From 9a3dfa0555130952517b9a9c3918729495aa709a Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 25 May 2010 04:20:30 +0100 Subject: [PATCH 095/523] Staging: rtl8192su: Clean up in case of an error in module initialisation Currently various resources may be leaked in case of an error. Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192su/r8192U_core.c | 43 +++++++++++++++++++++---- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192su/r8192U_core.c b/drivers/staging/rtl8192su/r8192U_core.c index 447d6474a70c..1b4ff90f43ac 100644 --- a/drivers/staging/rtl8192su/r8192U_core.c +++ b/drivers/staging/rtl8192su/r8192U_core.c @@ -990,10 +990,11 @@ static int proc_get_stats_rx(char *page, char **start, return len; } -void rtl8192_proc_module_init(void) +int rtl8192_proc_module_init(void) { RT_TRACE(COMP_INIT, "Initializing proc filesystem"); rtl8192_proc=create_proc_entry(RTL819xU_MODULE_NAME, S_IFDIR, init_net.proc_net); + return rtl8192_proc ? 0 : -ENOMEM; } @@ -7473,35 +7474,63 @@ static int __init rtl8192_usb_module_init(void) ret = ieee80211_crypto_init(); if (ret) { printk(KERN_ERR "ieee80211_crypto_init() failed %d\n", ret); - return ret; + goto fail_crypto; } ret = ieee80211_crypto_tkip_init(); if (ret) { printk(KERN_ERR "ieee80211_crypto_tkip_init() failed %d\n", ret); - return ret; + goto fail_crypto_tkip; } ret = ieee80211_crypto_ccmp_init(); if (ret) { printk(KERN_ERR "ieee80211_crypto_ccmp_init() failed %d\n", ret); - return ret; + goto fail_crypto_ccmp; } ret = ieee80211_crypto_wep_init(); if (ret) { printk(KERN_ERR "ieee80211_crypto_wep_init() failed %d\n", ret); - return ret; + goto fail_crypto_wep; } printk(KERN_INFO "\nLinux kernel driver for RTL8192 based WLAN cards\n"); printk(KERN_INFO "Copyright (c) 2007-2008, Realsil Wlan\n"); RT_TRACE(COMP_INIT, "Initializing module"); RT_TRACE(COMP_INIT, "Wireless extensions version %d", WIRELESS_EXT); - rtl8192_proc_module_init(); - return usb_register(&rtl8192_usb_driver); + + ret = rtl8192_proc_module_init(); + if (ret) { + pr_err("rtl8192_proc_module_init() failed %d\n", ret); + goto fail_proc; + } + + ret = usb_register(&rtl8192_usb_driver); + if (ret) { + pr_err("usb_register() failed %d\n", ret); + goto fail_usb; + } + + return 0; + +fail_usb: + rtl8192_proc_module_remove(); +fail_proc: + ieee80211_crypto_wep_exit(); +fail_crypto_wep: + ieee80211_crypto_ccmp_exit(); +fail_crypto_ccmp: + ieee80211_crypto_tkip_exit(); +fail_crypto_tkip: + ieee80211_crypto_deinit(); +fail_crypto: +#ifdef CONFIG_IEEE80211_DEBUG + ieee80211_debug_exit(); +#endif + return ret; } From 41a38d9e632f7c9ec5ad8fc627567d97f4302c4a Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 25 May 2010 04:25:57 +0100 Subject: [PATCH 096/523] Staging: rtl8192su: Fix procfs code for interfaces not named wlan0 The current code creates directories in procfs named after interfaces, but doesn't handle renaming. This can result in name collisions and consequent WARNINGs. It also means that the interface name cannot reliably be used to remove the directory - in fact the current code doesn't even try, and always uses "wlan0"! Since the name of a proc_dir_entry is embedded in it, use that when removing it. Add a netdev notifier to catch interface renaming, and remove and re-add the directory at this point. Signed-off-by: Ben Hutchings --- drivers/staging/rtl8192su/r8192U_core.c | 35 ++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192su/r8192U_core.c b/drivers/staging/rtl8192su/r8192U_core.c index 1b4ff90f43ac..a076f56df7c4 100644 --- a/drivers/staging/rtl8192su/r8192U_core.c +++ b/drivers/staging/rtl8192su/r8192U_core.c @@ -27,6 +27,7 @@ #include #include #include +#include #undef LOOP_TEST #undef DUMP_RX @@ -161,6 +162,8 @@ MODULE_PARM_DESC(channels," Channel bitmask for specific locales. NYI"); static int __devinit rtl8192_usb_probe(struct usb_interface *intf, const struct usb_device_id *id); static void __devexit rtl8192_usb_disconnect(struct usb_interface *intf); +static const struct net_device_ops rtl8192_netdev_ops; +static struct notifier_block proc_netdev_notifier; static struct usb_driver rtl8192_usb_driver = { .name = RTL819xU_MODULE_NAME, /* Driver name */ @@ -992,14 +995,22 @@ static int proc_get_stats_rx(char *page, char **start, int rtl8192_proc_module_init(void) { + int ret; + RT_TRACE(COMP_INIT, "Initializing proc filesystem"); rtl8192_proc=create_proc_entry(RTL819xU_MODULE_NAME, S_IFDIR, init_net.proc_net); - return rtl8192_proc ? 0 : -ENOMEM; + if (!rtl8192_proc) + return -ENOMEM; + ret = register_netdevice_notifier(&proc_netdev_notifier); + if (ret) + remove_proc_entry(RTL819xU_MODULE_NAME, init_net.proc_net); + return ret; } void rtl8192_proc_module_remove(void) { + unregister_netdevice_notifier(&proc_netdev_notifier); remove_proc_entry(RTL819xU_MODULE_NAME, init_net.proc_net); } @@ -1027,8 +1038,7 @@ void rtl8192_proc_remove_one(struct net_device *dev) remove_proc_entry("registers-e", priv->dir_dev); // remove_proc_entry("cck-registers",priv->dir_dev); // remove_proc_entry("ofdm-registers",priv->dir_dev); - //remove_proc_entry(dev->name, rtl8192_proc); - remove_proc_entry("wlan0", rtl8192_proc); + remove_proc_entry(priv->dir_dev->name, rtl8192_proc); priv->dir_dev = NULL; } } @@ -1145,6 +1155,25 @@ void rtl8192_proc_init_one(struct net_device *dev) dev->name); } } + +static int proc_netdev_event(struct notifier_block *this, + unsigned long event, void *ptr) +{ + struct net_device *net_dev = ptr; + + if (net_dev->netdev_ops == &rtl8192_netdev_ops && + event == NETDEV_CHANGENAME) { + rtl8192_proc_remove_one(net_dev); + rtl8192_proc_init_one(net_dev); + } + + return NOTIFY_DONE; +} + +static struct notifier_block proc_netdev_notifier = { + .notifier_call = proc_netdev_event, +}; + /**************************************************************************** -----------------------------MISC STUFF------------------------- *****************************************************************************/ From 5749df14aef6d3fd7146f17e4f0c61526a53766e Mon Sep 17 00:00:00 2001 From: Jiri Kosina Date: Wed, 26 May 2010 13:39:04 +0200 Subject: [PATCH 097/523] Staging: cxt1e1: remove all code dependent on LINUX_VERSION_CODE Remove all code which is dead for in-kernel driver due to being ifdefed by LINUX_VERSION_CODE. While at it, also remove surrounding code which is commented out, or '#if 1' nops. Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/functions.c | 12 -- drivers/staging/cxt1e1/hwprobe.c | 6 - drivers/staging/cxt1e1/linux.c | 123 ----------- drivers/staging/cxt1e1/musycc.c | 204 ------------------- drivers/staging/cxt1e1/pmc93x6_eeprom.c | 4 - drivers/staging/cxt1e1/pmcc4.h | 6 - drivers/staging/cxt1e1/pmcc4_drv.c | 158 -------------- drivers/staging/cxt1e1/sbecom_inline_linux.h | 11 - 8 files changed, 524 deletions(-) diff --git a/drivers/staging/cxt1e1/functions.c b/drivers/staging/cxt1e1/functions.c index 86b498090265..23ea101d7a89 100644 --- a/drivers/staging/cxt1e1/functions.c +++ b/drivers/staging/cxt1e1/functions.c @@ -122,19 +122,7 @@ watchdog_func (unsigned long arg) pr_warning("%s: drvr not available (%x)\n", __func__, drvr_state); return; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - /* Initialize the tq entry only the first time */ - if (wd->init_tq) - { - wd->init_tq = 0; - wd->tq.routine = wd->func; - wd->tq.sync = 0; - wd->tq.data = wd->softc; - } - schedule_task (&wd->tq); -#else schedule_work (&wd->work); -#endif mod_timer (&wd->h, jiffies + wd->ticks); } diff --git a/drivers/staging/cxt1e1/hwprobe.c b/drivers/staging/cxt1e1/hwprobe.c index 4c8610293fcc..89200e7af26c 100644 --- a/drivers/staging/cxt1e1/hwprobe.c +++ b/drivers/staging/cxt1e1/hwprobe.c @@ -305,15 +305,9 @@ c4hw_attach_all (void) error_flag = 0; prep_hdw_info (); /*** scan PCI bus for all possible boards */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) while ((pdev = pci_get_device (PCI_VENDOR_ID_CONEXANT, - PCI_DEVICE_ID_CN8474, - pdev))) -#else - while ((pdev = pci_find_device (PCI_VENDOR_ID_CONEXANT, PCI_DEVICE_ID_CN8474, pdev))) -#endif { if (c4_hdw_init (pdev, found)) found++; diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c index 134e7568024b..4088347a80e6 100644 --- a/drivers/staging/cxt1e1/linux.c +++ b/drivers/staging/cxt1e1/linux.c @@ -142,10 +142,6 @@ getuserbychan (int channum) } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -#define DEV_TO_PRIV(dev) ( * (struct c4_priv **) ((hdlc_device*)(dev)+1)) -#else - char * get_hdlc_name (hdlc_device * hdlc) { @@ -154,7 +150,6 @@ get_hdlc_name (hdlc_device * hdlc) return dev->name; } -#endif static status_t @@ -167,7 +162,6 @@ mkret (int bsd) } /***************************************************************************/ -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41) #include /*** @@ -259,7 +253,6 @@ c4_wq_port_cleanup (mpi_t * pi) pi->wq_port = 0; } } -#endif /***************************************************************************/ @@ -291,48 +284,6 @@ void_open (struct net_device * ndev) } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -#if !defined(GENERIC_HDLC_VERSION) || (GENERIC_HDLC_VERSION < 4) - -/** Linux 2.4.18-19 **/ -STATIC int -chan_open (hdlc_device * hdlc) -{ - status_t ret; - - if ((ret = c4_chan_up (DEV_TO_PRIV (hdlc)->ci, DEV_TO_PRIV (hdlc)->channum))) - return -ret; - MOD_INC_USE_COUNT; - netif_start_queue (hdlc_to_dev (hdlc)); - return 0; /* no error = success */ -} - -#else - -/** Linux 2.4.20 and higher **/ -STATIC int -chan_open (struct net_device * ndev) -{ - hdlc_device *hdlc = dev_to_hdlc (ndev); - status_t ret; - - hdlc->proto = IF_PROTO_HDLC; - if ((ret = hdlc_open (hdlc))) - { - pr_info("hdlc_open failure, err %d.\n", ret); - return ret; - } - if ((ret = c4_chan_up (DEV_TO_PRIV (hdlc)->ci, DEV_TO_PRIV (hdlc)->channum))) - return -ret; - MOD_INC_USE_COUNT; - netif_start_queue (hdlc_to_dev (hdlc)); - return 0; /* no error = success */ -} -#endif - -#else - -/** Linux 2.6 **/ STATIC int chan_open (struct net_device * ndev) { @@ -351,39 +302,8 @@ chan_open (struct net_device * ndev) netif_start_queue (ndev); return 0; /* no error = success */ } -#endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -#if !defined(GENERIC_HDLC_VERSION) || (GENERIC_HDLC_VERSION < 4) - -/** Linux 2.4.18-19 **/ -STATIC void -chan_close (hdlc_device * hdlc) -{ - netif_stop_queue (hdlc_to_dev (hdlc)); - musycc_chan_down ((ci_t *) 0, DEV_TO_PRIV (hdlc)->channum); - MOD_DEC_USE_COUNT; -} -#else - -/** Linux 2.4.20 and higher **/ -STATIC int -chan_close (struct net_device * ndev) -{ - hdlc_device *hdlc = dev_to_hdlc (ndev); - - netif_stop_queue (hdlc_to_dev (hdlc)); - musycc_chan_down ((ci_t *) 0, DEV_TO_PRIV (hdlc)->channum); - hdlc_close (hdlc); - MOD_DEC_USE_COUNT; - return 0; -} -#endif - -#else - -/** Linux 2.6 **/ STATIC int chan_close (struct net_device * ndev) { @@ -396,7 +316,6 @@ chan_close (struct net_device * ndev) module_put (THIS_MODULE); return 0; } -#endif #if !defined(GENERIC_HDLC_VERSION) || (GENERIC_HDLC_VERSION < 4) @@ -435,11 +354,7 @@ chan_dev_ioctl (struct net_device * dev, struct ifreq * ifr, int cmd) STATIC int -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -chan_attach_noop (hdlc_device * hdlc, unsigned short foo_1, unsigned short foo_2) -#else chan_attach_noop (struct net_device * ndev, unsigned short foo_1, unsigned short foo_2) -#endif { return 0; /* our driver has nothing to do here, show's * over, go home */ @@ -455,16 +370,12 @@ chan_get_stats (struct net_device * ndev) struct sbecom_chan_stats *stats; int channum; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - channum = DEV_TO_PRIV (ndev)->channum; -#else { struct c4_priv *priv; priv = (struct c4_priv *) dev_to_hdlc (ndev)->priv; channum = priv->channum; } -#endif ch = c4_find_chan (channum); if (ch == NULL) @@ -527,13 +438,9 @@ c4_linux_xmit (struct sk_buff * skb, struct net_device * ndev) const struct c4_priv *priv; int rval; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - priv = DEV_TO_PRIV (ndev); -#else hdlc_device *hdlc = dev_to_hdlc (ndev); priv = hdlc->priv; -#endif rval = musycc_start_xmit (priv->ci, priv->channum, skb); return -rval; @@ -823,18 +730,10 @@ do_create_chan (struct net_device * ndev, void *data) ret = mkret (c4_new_chan (ci, cp.port, cp.channum, dev)); if (ret) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - rtnl_unlock (); /* needed due to Ioctl calling sequence */ - V7 (unregister_hdlc_device) (dev_to_hdlc (dev)); - rtnl_lock (); /* needed due to Ioctl calling sequence */ - OS_kfree (DEV_TO_PRIV (dev)); - OS_kfree (dev); -#else rtnl_unlock (); /* needed due to Ioctl calling sequence */ unregister_hdlc_device (dev); rtnl_lock (); /* needed due to Ioctl calling sequence */ free_netdev (dev); -#endif } return ret; } @@ -883,11 +782,7 @@ do_deluser (struct net_device * ndev, int lockit) const struct c4_priv *priv; int channum; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - priv = DEV_TO_PRIV (ndev); -#else priv = (struct c4_priv *) dev_to_hdlc (ndev)->priv; -#endif ci = priv->ci; channum = priv->channum; @@ -897,22 +792,12 @@ do_deluser (struct net_device * ndev, int lockit) ch->user = 0; /* will be freed, below */ } -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - if (lockit) - rtnl_unlock (); /* needed if Ioctl calling sequence */ - V7 (unregister_hdlc_device) (dev_to_hdlc (ndev)); - if (lockit) - rtnl_lock (); /* needed if Ioctl calling sequence */ - OS_kfree (DEV_TO_PRIV (ndev)); - OS_kfree (ndev); -#else if (lockit) rtnl_unlock (); /* needed if Ioctl calling sequence */ unregister_hdlc_device (ndev); if (lockit) rtnl_lock (); /* needed if Ioctl calling sequence */ free_netdev (ndev); -#endif return 0; } @@ -1339,14 +1224,6 @@ c4_mod_remove (void) module_init (c4_mod_init); module_exit (c4_mod_remove); -#ifndef SBE_INCLUDE_SYMBOLS -#ifndef CONFIG_SBE_WANC24_NCOMM -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -EXPORT_NO_SYMBOLS; -#endif -#endif -#endif - MODULE_AUTHOR ("SBE Technical Services "); MODULE_DESCRIPTION ("wanPCI-CxT1E1 Generic HDLC WAN Driver module"); #ifdef MODULE_LICENSE diff --git a/drivers/staging/cxt1e1/musycc.c b/drivers/staging/cxt1e1/musycc.c index d3f5a5b52dc3..12c76a553e0f 100644 --- a/drivers/staging/cxt1e1/musycc.c +++ b/drivers/staging/cxt1e1/musycc.c @@ -405,7 +405,6 @@ musycc_update_tx_thp (mch_t * ch) } -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41) /* * This is the workq task executed by the OS when our queue_work() is * scheduled and run. It can fire off either RX or TX ACTIVATION depending @@ -515,7 +514,6 @@ musycc_wq_chan_restart (void *arg) /* channel private structure */ #endif } } -#endif /* @@ -531,7 +529,6 @@ musycc_chan_restart (mch_t * ch) ch->channum, ch->txd_irq_srv, ch->txd_irq_srv->status); #endif -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41) /* 2.6 - find next unprocessed message, then set TX thp to it */ #ifdef RLD_RESTART_DEBUG pr_info(">> musycc_chan_restart: scheduling Chan %x workQ @ %p\n", ch->channum, &ch->ch_work); @@ -539,51 +536,9 @@ musycc_chan_restart (mch_t * ch) c4_wk_chan_restart (ch); /* work queue mechanism fires off: Ref: * musycc_wq_chan_restart () */ -#else - - - /* 2.4 - find next unprocessed message, then set TX thp to it */ -#ifdef RLD_RESTART_DEBUG - pr_info(">> musycc_chan_restart: scheduling Chan %x start_tx %x\n", ch->channum, ch->ch_start_tx); -#endif - /* restart transmission from background loop */ - ch->up->up->wd_notify = WD_NOTIFY_1TX; -#endif } -#if 0 -void -musycc_cleanup (ci_t * ci) -{ - mpi_t *pi; - int i, j; - - /* free up driver resources */ - ci->state = C_INIT; /* mark as hardware not available */ - - for (i = 0; i < ci->max_ports; i++) - { - pi = &ci->port[i]; -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41) - c4_wq_port_cleanup (pi); -#endif - for (j = 0; j < MUSYCC_NCHANS; j++) - { - if (pi->chan[j]) - OS_kfree (pi->chan[j]); /* free mch_t struct */ - } - OS_kfree (pi->regram_saved); - } -#if 0 - /* obsolete - watchdog is now static w/in ci_t */ - OS_free_watchdog (ci->wd); -#endif - OS_kfree (ci->iqd_p_saved); - OS_kfree (ci); -} -#endif - void rld_put_led (mpi_t * pi, u_int32_t ledval) { @@ -2008,37 +1963,13 @@ musycc_start_xmit (ci_t * ci, int channum, void *mem_token) atomic_add (len, &ci->tx_pending); ch->s.tx_packets++; ch->s.tx_bytes += len; -#if 0 - spin_unlock_irqrestore (&ch->ch_txlock, flags); /* allow pending - * interrupt to sneak - * thru */ -#endif - /* * If an ONR was seen, then channel requires poking to restart * transmission. */ if (ch->ch_start_tx) { -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,41) - SD_SEM_TAKE (&ci->sem_wdbusy, "_wd_"); /* only 1 thru here, per - * board */ - if ((ch->ch_start_tx == CH_START_TX_ONR) && (ch->p.chan_mode == CFG_CH_PROTO_TRANS)) - { - /* ONR restart transmission from background loop */ - ci->wd_notify = WD_NOTIFY_ONR; /* enabled global watchdog - * scan-thru */ - } else - { - /* start first transmission from background loop */ - ci->wd_notify = WD_NOTIFY_1TX; /* enabled global watchdog - * scan-thru */ - } musycc_chan_restart (ch); - SD_SEM_GIVE (&ci->sem_wdbusy); -#else - musycc_chan_restart (ch); -#endif } #ifdef SBE_WAN256T3_ENABLE wan256t3_led (ci, LED_TX, LEDV_G); @@ -2047,139 +1978,4 @@ musycc_start_xmit (ci_t * ci, int channum, void *mem_token) } -#if 0 -int -musycc_set_chan (ci_t * ci, int channum, struct sbecom_chan_param * p) -{ - mch_t *ch; - int rok = 0; - int n = 0; - - if (channum < 0 || channum >= (MUSYCC_NPORTS * MUSYCC_NCHANS)) /* sanity chk param */ - return ECHRNG; - if (!(ch = sd_find_chan (ci, channum))) - return ENOENT; - if (ch->channum != p->channum) - return EINVAL; - if (sd_line_is_ok (ch->user)) - { - rok = 1; - sd_line_is_down (ch->user); - } - if (ch->state == UP && /* bring down in current configuration */ - (ch->p.status != p->status || - ch->p.chan_mode != p->chan_mode || - ch->p.intr_mask != p->intr_mask || - ch->txd_free < ch->txd_num)) - { - if ((n = musycc_chan_down (ci, channum))) - return n; - if (ch->p.mode_56k != p->mode_56k) - { - ch->p = *p; /* copy in new parameters */ - musycc_update_timeslots (&ci->port[ch->channum / MUSYCC_NCHANS]); - } else - ch->p = *p; /* copy in new parameters */ - if ((n = musycc_chan_up (ci, channum))) - return n; - sd_enable_xmit (ch->user); /* re-enable to catch flow controlled - * channel */ - } else - { - if (ch->p.mode_56k != p->mode_56k) - { - ch->p = *p; /* copy in new parameters */ - musycc_update_timeslots (&ci->port[ch->channum / MUSYCC_NCHANS]); - } else - ch->p = *p; /* copy in new parameters */ - } - - if (rok) - sd_line_is_up (ch->user); - return 0; -} -#endif - - -int -musycc_get_chan (ci_t * ci, int channum, struct sbecom_chan_param * p) -{ - mch_t *ch; - -#if 0 - if (channum < 0 || channum >= (MUSYCC_NPORTS * MUSYCC_NCHANS)) /* sanity chk param */ - return ECHRNG; -#endif - if (!(ch = sd_find_chan (ci, channum))) - return ENOENT; - *p = ch->p; - return 0; -} - - -int -musycc_get_chan_stats (ci_t * ci, int channum, struct sbecom_chan_stats * p) -{ - mch_t *ch; - - if (channum < 0 || channum >= (MUSYCC_NPORTS * MUSYCC_NCHANS)) /* sanity chk param */ - return ECHRNG; - if (!(ch = sd_find_chan (ci, channum))) - return ENOENT; - *p = ch->s; - p->tx_pending = atomic_read (&ch->tx_pending); - return 0; -} - - - -#ifdef SBE_WAN256T3_ENABLE -int -musycc_chan_down (ci_t * ci, int channum) -{ - mch_t *ch; - mpi_t *pi; - int i, gchan; - - if (!(ch = sd_find_chan (ci, channum))) - return EINVAL; - pi = ch->up; - gchan = ch->gchan; - - /* Deactivate the channel */ - musycc_serv_req (pi, SR_CHANNEL_DEACTIVATE | SR_RX_DIRECTION | gchan); - ch->ch_start_rx = 0; - musycc_serv_req (pi, SR_CHANNEL_DEACTIVATE | SR_TX_DIRECTION | gchan); - ch->ch_start_tx = 0; - - if (ch->state == DOWN) - return 0; - ch->state = DOWN; - - pi->regram->thp[gchan] = 0; - pi->regram->tmp[gchan] = 0; - pi->regram->rhp[gchan] = 0; - pi->regram->rmp[gchan] = 0; - FLUSH_MEM_WRITE (); - for (i = 0; i < ch->txd_num; i++) - { - if (ch->mdt[i].mem_token != 0) - OS_mem_token_free (ch->mdt[i].mem_token); - } - - for (i = 0; i < ch->rxd_num; i++) - { - if (ch->mdr[i].mem_token != 0) - OS_mem_token_free (ch->mdr[i].mem_token); - } - - OS_kfree (ch->mdt); - ch->mdt = 0; - OS_kfree (ch->mdr); - ch->mdr = 0; - - return 0; -} -#endif - /*** End-of-File ***/ diff --git a/drivers/staging/cxt1e1/pmc93x6_eeprom.c b/drivers/staging/cxt1e1/pmc93x6_eeprom.c index 1c8dfb80e7d7..62b12fb45fcc 100644 --- a/drivers/staging/cxt1e1/pmc93x6_eeprom.c +++ b/drivers/staging/cxt1e1/pmc93x6_eeprom.c @@ -500,11 +500,7 @@ pmc_init_seeprom (u_int32_t addr, u_int32_t serialNum) time_t createTime; int i; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - createTime = CURRENT_TIME; -#else createTime = get_seconds (); -#endif /* use template data */ for (i = 0; i < sizeof (FLD_TYPE2); ++i) diff --git a/drivers/staging/cxt1e1/pmcc4.h b/drivers/staging/cxt1e1/pmcc4.h index 26c1f0ea72e9..e288a0a91882 100644 --- a/drivers/staging/cxt1e1/pmcc4.h +++ b/drivers/staging/cxt1e1/pmcc4.h @@ -117,12 +117,6 @@ extern "C" #include "pmcc4_private.h" -#if !(LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -char *get_hdlc_name (hdlc_device *); - -#endif - - /* * external interface */ diff --git a/drivers/staging/cxt1e1/pmcc4_drv.c b/drivers/staging/cxt1e1/pmcc4_drv.c index 333cf2687dd1..9f730e68526c 100644 --- a/drivers/staging/cxt1e1/pmcc4_drv.c +++ b/drivers/staging/cxt1e1/pmcc4_drv.c @@ -119,12 +119,10 @@ char OSSIid_pmcc4_drvc[] = #define KERN_WARN KERN_WARNING /* forward references */ -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41) status_t c4_wk_chan_init (mpi_t *, mch_t *); void c4_wq_port_cleanup (mpi_t *); status_t c4_wq_port_init (mpi_t *); -#endif int c4_loop_port (ci_t *, int, u_int8_t); status_t c4_set_port (ci_t *, int); status_t musycc_chan_down (ci_t *, int); @@ -533,145 +531,15 @@ checkPorts (ci_t * ci) STATIC void c4_watchdog (ci_t * ci) { -#if 0 - //unsigned long flags; -#endif - if (drvr_state != SBE_DRVR_AVAILABLE) { if (log_level >= LOG_MONITOR) pr_info("drvr not available (%x)\n", drvr_state); return; } -#if 0 - SD_SEM_TAKE (&ci->sem_wdbusy, "_wd_"); /* only 1 thru here, per - * board */ -#endif - ci->wdcount++; checkPorts (ci); -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,41) - if (ci->wd_notify) - { /* is there a state change to search for */ - int port, gchan; - - ci->wd_notify = 0; /* reset notification */ - for (gchan = 0; gchan < MUSYCC_NCHANS; gchan++) - { - for (port = 0; port < ci->max_port; port++) - { - mch_t *ch = ci->port[port].chan[gchan]; - - if (!ch || ci->state != C_RUNNING) /* state changed while - * acquiring semaphore */ - break; - if (ch->state == UP)/* channel must be set up */ - { -#if 0 -#ifdef RLD_TRANS_DEBUG - if (1 || log_level >= LOG_MONITOR) -#else - if (log_level >= LOG_MONITOR) -#endif - pr_info("%s: watchdog reviving Port %d Channel %d [%d] sts %x/%x, start_TX %x free %x start_RX %x\n", - ci->devname, ch->channum, port, gchan, ch->channum, - ch->p.status, ch->status, - ch->ch_start_tx, ch->txd_free, ch->ch_start_rx); -#endif - - /**********************************/ - /** check for RX restart request **/ - /**********************************/ - - if (ch->ch_start_rx && - (ch->status & RX_ENABLED)) /* requires start on - * enabled RX */ - { - ch->ch_start_rx = 0; /* we are restarting RX... */ -#ifdef RLD_TRANS_DEBUG - pr_info("++ c4_watchdog() CHAN RX ACTIVATE: chan %d\n", - ch->channum); -#endif -#ifdef RLD_RXACT_DEBUG - { - struct mdesc *md; - static int hereb4 = 7; - - if (hereb4) - { - hereb4--; - md = &ch->mdr[ch->rxix_irq_srv]; - pr_info("++ c4_watchdog[%d] CHAN RX ACTIVATE: rxix_irq_srv %d, md %p sts %x, rxpkt %lu\n", - ch->channum, ch->rxix_irq_srv, md, le32_to_cpu (md->status), ch->s.rx_packets); - musycc_dump_rxbuffer_ring (ch, 1); /* RLD DEBUG */ - } - } -#endif - musycc_serv_req (ch->up, SR_CHANNEL_ACTIVATE | SR_RX_DIRECTION | gchan); - } - /**********************************/ - /** check for TX restart request **/ - /**********************************/ - - if (ch->ch_start_tx && - (ch->status & TX_ENABLED)) /* requires start on - * enabled TX */ - { - struct mdesc *md; - - /* - * find next unprocessed message, then set TX thp to - * it - */ - musycc_update_tx_thp (ch); - -#if 0 - spin_lock_irqsave (&ch->ch_txlock, flags); -#endif - md = ch->txd_irq_srv; - if (!md) - { - pr_info("-- c4_watchdog[%d]: WARNING, starting NULL md\n", - ch->channum); - pr_info("-- chan %d txd_irq_srv %p sts %x usr_add %p sts %x, txpkt %lu\n", - ch->channum, ch->txd_irq_srv, le32_to_cpu ((struct mdesc *) (ch->txd_irq_srv)->status), - ch->txd_usr_add, le32_to_cpu ((struct mdesc *) (ch->txd_usr_add)->status), - ch->s.tx_packets); -#if 0 - spin_unlock_irqrestore (&ch->ch_txlock, flags); -#endif - } else if (md->data && ((le32_to_cpu (md->status)) & MUSYCC_TX_OWNED)) - { -#ifdef RLD_TRANS_DEBUG - pr_info("++ c4_watchdog[%d] CHAN TX ACTIVATE: start_tx %x\n", - ch->channum, ch->ch_start_tx); -#endif - ch->ch_start_tx = 0; /* we are restarting - * TX... */ -#if 0 - spin_unlock_irqrestore (&ch->ch_txlock, flags); /* allow interrupts for - * service request */ -#endif - musycc_serv_req (ch->up, SR_CHANNEL_ACTIVATE | SR_TX_DIRECTION | gchan); -#ifdef RLD_TRANS_DEBUG - if (1 || log_level >= LOG_MONITOR) -#else - if (log_level >= LOG_MONITOR) -#endif - pr_info("++ SACK[P%d/C%d] ack'd, continuing...\n", - ch->up->portnum, ch->channum); - } - } - } - } - } - } -#else ci->wd_notify = 0; -#endif -#if 0 - SD_SEM_GIVE (&ci->sem_wdbusy);/* release per-board hold */ -#endif } @@ -690,9 +558,7 @@ c4_cleanup (void) for (portnum = 0; portnum < ci->max_port; portnum++) { pi = &ci->port[portnum]; -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41) c4_wq_port_cleanup (pi); -#endif for (j = 0; j < MUSYCC_NCHANS; j++) { if (pi->chan[j]) @@ -700,10 +566,6 @@ c4_cleanup (void) } OS_kfree (pi->regram_saved); } -#if 0 - /* obsolete - watchdog is now static w/in ci_t */ - OS_free_watchdog (ci->wd); -#endif OS_kfree (ci->iqd_p_saved); OS_kfree (ci); ci = next; /* cleanup next board, if any */ @@ -1145,7 +1007,6 @@ c4_set_port (ci_t * ci, int portnum) return EBUSY; /* group needs initialization only for * first channel of a group */ -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41) { status_t ret; @@ -1153,7 +1014,6 @@ c4_set_port (ci_t * ci, int portnum) * workqueue_struct */ return (ret); } -#endif init_comet (ci, pi->cometbase, pp->port_mode, 1 /* clockmaster == true */ , pp->portP); clck = pci_read_32 ((u_int32_t *) &ci->cpldbase->mclk) & PMCC4_CPLD_MCLK_MASK; @@ -1269,14 +1129,12 @@ c4_new_chan (ci_t * ci, int portnum, int channum, void *user) spin_lock_init (&ch->ch_rxlock); spin_lock_init (&ch->ch_txlock); -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41) { status_t ret; if ((ret = c4_wk_chan_init (pi, ch))) return ret; } -#endif /* save off interface assignments which bound a board */ if (ci->first_if == 0) /* first channel registered is assumed to @@ -1705,31 +1563,23 @@ sbecom_get_brdinfo (ci_t * ci, struct sbe_brd_info * bip, u_int8_t *bsn) if (ci->first_if) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - np = (char *) hdlc_to_name (ci->first_if); -#else { struct net_device *dev; dev = (struct net_device *) ci->first_if; np = (char *) dev->name; } -#endif strncpy (bip->first_iname, np, CHNM_STRLEN - 1); } else strcpy (bip->first_iname, ""); if (ci->last_if) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - np = (char *) hdlc_to_name (ci->last_if); -#else { struct net_device *dev; dev = (struct net_device *) ci->last_if; np = (char *) dev->name; } -#endif strncpy (bip->last_iname, np, CHNM_STRLEN - 1); } else strcpy (bip->last_iname, ""); @@ -1763,11 +1613,7 @@ c4_get_iidinfo (ci_t * ci, struct sbe_iid_info * iip) if (!(dev = getuserbychan (iip->channum))) return ENOENT; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - np = (char *) hdlc_to_name (dev_to_hdlc (dev)); -#else np = dev->name; -#endif strncpy (iip->iname, np, CHNM_STRLEN - 1); return 0; } @@ -1826,11 +1672,7 @@ c4_ebus_intr_th_handler (void *devp) pci_write_32 ((u_int32_t *) &ci->reg->glcd, GCD_MAGIC | MUSYCC_GCD_INTB_DISABLE); #endif -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,4,20) - return; -#else return IRQ_RETVAL (handled); -#endif } diff --git a/drivers/staging/cxt1e1/sbecom_inline_linux.h b/drivers/staging/cxt1e1/sbecom_inline_linux.h index c65172db2ad8..5a72cb5cff42 100644 --- a/drivers/staging/cxt1e1/sbecom_inline_linux.h +++ b/drivers/staging/cxt1e1/sbecom_inline_linux.h @@ -48,9 +48,6 @@ #else #include #include -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) -#include -#endif #if defined(CONFIG_SMP) && ! defined(__SMP__) #define __SMP__ #endif @@ -60,12 +57,8 @@ #ifdef MODULE #ifdef MODVERSIONS -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -#include -#else #include #endif -#endif #include #endif #endif @@ -260,11 +253,7 @@ OS_sem_free (void *sem) struct watchdog { struct timer_list h; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - struct tq_struct tq; -#else struct work_struct work; -#endif void *softc; void (*func) (void *softc); int ticks; From bb71770cdb19f2cabb77afb329025ba460d05ebc Mon Sep 17 00:00:00 2001 From: Jiri Kosina Date: Wed, 26 May 2010 13:33:55 +0200 Subject: [PATCH 098/523] Staging: rtl8192su: remove all code dependent on LINUX_VERSION_CODE Remove all code which is dead for in-kernel driver due to being ifdefed by LINUX_VERSION_CODE. While at it, also remove surrounding code which is commented out, or '#if 1' nops. Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192su/r8192SU_led.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/staging/rtl8192su/r8192SU_led.c b/drivers/staging/rtl8192su/r8192SU_led.c index 609dba67eb4e..5d96b356bf12 100644 --- a/drivers/staging/rtl8192su/r8192SU_led.c +++ b/drivers/staging/rtl8192su/r8192SU_led.c @@ -1087,22 +1087,13 @@ BlinkTimerCallback( struct net_device *dev = (struct net_device *)data; struct r8192_priv *priv = ieee80211_priv(dev); -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) schedule_work(&(priv->BlinkWorkItem)); -#endif } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) void BlinkWorkItemCallback(struct work_struct *work) { struct r8192_priv *priv = container_of(work, struct r8192_priv, BlinkWorkItem); -#else -void BlinkWorkItemCallback(void * Context) -{ - struct net_device *dev = (struct net_device *)Context; - struct r8192_priv *priv = ieee80211_priv(dev); -#endif PLED_819xUsb pLed = priv->pLed; From 9c770f3b881c5066ff014968473ffbbafee82247 Mon Sep 17 00:00:00 2001 From: Jiri Kosina Date: Wed, 26 May 2010 16:20:41 +0200 Subject: [PATCH 099/523] Staging: cxt1e1: remove code guarded by GENERIC_HDLC_VERSION Current linux kernel has GENERIC_HDLC_VERSION equal to 4, no need to have dead code in-kernel which was there for ancient kernel versions. Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cxt1e1/linux.c | 40 ---------------------------------- drivers/staging/cxt1e1/pmcc4.h | 2 ++ 2 files changed, 2 insertions(+), 40 deletions(-) diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c index 4088347a80e6..eb0f4bdf6273 100644 --- a/drivers/staging/cxt1e1/linux.c +++ b/drivers/staging/cxt1e1/linux.c @@ -318,34 +318,6 @@ chan_close (struct net_device * ndev) } -#if !defined(GENERIC_HDLC_VERSION) || (GENERIC_HDLC_VERSION < 4) - -/** Linux 2.4.18-19 **/ -STATIC int -chan_ioctl (hdlc_device * hdlc, struct ifreq * ifr, int cmd) -{ - if (cmd == HDLCSCLOCK) - { - ifr->ifr_ifru.ifru_ivalue = LINE_DEFAULT; - return 0; - } - return -EINVAL; -} -#endif - - -#if !defined(GENERIC_HDLC_VERSION) || (GENERIC_HDLC_VERSION < 4) -STATIC int -chan_dev_ioctl (struct net_device * hdlc, struct ifreq * ifr, int cmd) -{ - if (cmd == HDLCSCLOCK) - { - ifr->ifr_ifru.ifru_ivalue = LINE_DEFAULT; - return 0; - } - return -EINVAL; -} -#else STATIC int chan_dev_ioctl (struct net_device * dev, struct ifreq * ifr, int cmd) { @@ -359,7 +331,6 @@ chan_attach_noop (struct net_device * ndev, unsigned short foo_1, unsigned short return 0; /* our driver has nothing to do here, show's * over, go home */ } -#endif STATIC struct net_device_stats * @@ -422,16 +393,6 @@ get_ci_by_dev (struct net_device * ndev) } -#if !defined(GENERIC_HDLC_VERSION) || (GENERIC_HDLC_VERSION < 4) -STATIC int -c4_linux_xmit (hdlc_device * hdlc, struct sk_buff * skb) -{ - int rval; - - rval = musycc_start_xmit (DEV_TO_PRIV (hdlc)->ci, DEV_TO_PRIV (hdlc)->channum, skb); - return -rval; -} -#else /* new */ STATIC int c4_linux_xmit (struct sk_buff * skb, struct net_device * ndev) { @@ -445,7 +406,6 @@ c4_linux_xmit (struct sk_buff * skb, struct net_device * ndev) rval = musycc_start_xmit (priv->ci, priv->channum, skb); return -rval; } -#endif /* GENERIC_HDLC_VERSION */ static const struct net_device_ops chan_ops = { .ndo_open = chan_open, diff --git a/drivers/staging/cxt1e1/pmcc4.h b/drivers/staging/cxt1e1/pmcc4.h index e288a0a91882..ef6ac7fe7ddd 100644 --- a/drivers/staging/cxt1e1/pmcc4.h +++ b/drivers/staging/cxt1e1/pmcc4.h @@ -117,6 +117,8 @@ extern "C" #include "pmcc4_private.h" +char *get_hdlc_name (hdlc_device *); + /* * external interface */ From cb3126e60ffc1b7658a6ff4f6874585098bf9887 Mon Sep 17 00:00:00 2001 From: Karl Relton Date: Thu, 3 Jun 2010 23:04:06 +0100 Subject: [PATCH 100/523] Staging: wlan-ng: Switch from wext to cfg80211 Switch driver over from wext to cfg80211 interface. Some Notes: - This patch moves the driver wholesale from wext to cfg80211. Wext support is still provided through the cfg80211 provided wext compatability layer. - Currently only infrastructure mode is implemented. Ad hoc mode is not yet implemented, but can be added. - It does not support connecting to a specified bssid, instead roaming is handled by the card itself. This matches the behaviour of the existing driver. - It has been tested using NetworkManager (via wpa_supplicant) configured to use the wext compatability layer, and then again with the native nl80211 layer. Signed-off-by: Karl Relton Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/Makefile | 1 - drivers/staging/wlan-ng/cfg80211.c | 735 +++++++++ drivers/staging/wlan-ng/hfa384x.h | 2 + drivers/staging/wlan-ng/p80211metastruct.h | 2 + drivers/staging/wlan-ng/p80211netdev.c | 47 +- drivers/staging/wlan-ng/p80211netdev.h | 3 +- drivers/staging/wlan-ng/p80211wext.c | 1690 -------------------- drivers/staging/wlan-ng/prism2mgmt.c | 2 + drivers/staging/wlan-ng/prism2sta.c | 64 +- drivers/staging/wlan-ng/prism2usb.c | 2 +- 10 files changed, 824 insertions(+), 1724 deletions(-) create mode 100644 drivers/staging/wlan-ng/cfg80211.c delete mode 100644 drivers/staging/wlan-ng/p80211wext.c diff --git a/drivers/staging/wlan-ng/Makefile b/drivers/staging/wlan-ng/Makefile index 5edac5c8d4ee..db5d597563f8 100644 --- a/drivers/staging/wlan-ng/Makefile +++ b/drivers/staging/wlan-ng/Makefile @@ -4,5 +4,4 @@ prism2_usb-objs := prism2usb.o \ p80211conv.o \ p80211req.o \ p80211wep.o \ - p80211wext.o \ p80211netdev.o diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c new file mode 100644 index 000000000000..b0792f78ac96 --- /dev/null +++ b/drivers/staging/wlan-ng/cfg80211.c @@ -0,0 +1,735 @@ +/* cfg80211 Interface for prism2_usb module */ + + +/* Prism2 channell/frequency/bitrate declarations */ +static const struct ieee80211_channel prism2_channels[] = { + { .center_freq = 2412 }, + { .center_freq = 2417 }, + { .center_freq = 2422 }, + { .center_freq = 2427 }, + { .center_freq = 2432 }, + { .center_freq = 2437 }, + { .center_freq = 2442 }, + { .center_freq = 2447 }, + { .center_freq = 2452 }, + { .center_freq = 2457 }, + { .center_freq = 2462 }, + { .center_freq = 2467 }, + { .center_freq = 2472 }, + { .center_freq = 2484 }, +}; + +static const struct ieee80211_rate prism2_rates[] = { + { .bitrate = 10 }, + { .bitrate = 20 }, + { .bitrate = 55 }, + { .bitrate = 110 } +}; + +#define PRISM2_NUM_CIPHER_SUITES 2 +static const u32 prism2_cipher_suites[PRISM2_NUM_CIPHER_SUITES] = { + WLAN_CIPHER_SUITE_WEP40, + WLAN_CIPHER_SUITE_WEP104 +}; + + +/* prism2 device private data */ +struct prism2_wiphy_private { + wlandevice_t *wlandev; + + struct ieee80211_supported_band band; + struct ieee80211_channel channels[ARRAY_SIZE(prism2_channels)]; + struct ieee80211_rate rates[ARRAY_SIZE(prism2_rates)]; + + struct cfg80211_scan_request *scan_request; +}; + +static const void * const prism2_wiphy_privid = &prism2_wiphy_privid; + + +/* Helper Functions */ +static int prism2_result2err(int prism2_result) +{ + int err = 0; + + switch (prism2_result) { + case P80211ENUM_resultcode_invalid_parameters: + err = -EINVAL; + break; + case P80211ENUM_resultcode_implementation_failure: + err = -EIO; + break; + case P80211ENUM_resultcode_not_supported: + err = -EOPNOTSUPP; + break; + default: + err = 0; + break; + } + + return err; +} + +static int prism2_domibset_uint32(wlandevice_t *wlandev, u32 did, u32 data) +{ + p80211msg_dot11req_mibset_t msg; + p80211item_uint32_t *mibitem = (p80211item_uint32_t *) &msg.mibattribute.data; + + msg.msgcode = DIDmsg_dot11req_mibset; + mibitem->did = did; + mibitem->data = data; + + return p80211req_dorequest(wlandev, (u8 *) & msg); +} + +static int prism2_domibset_pstr32(wlandevice_t *wlandev, + u32 did, u8 len, u8 *data) +{ + p80211msg_dot11req_mibset_t msg; + p80211item_pstr32_t *mibitem = (p80211item_pstr32_t *) &msg.mibattribute.data; + + msg.msgcode = DIDmsg_dot11req_mibset; + mibitem->did = did; + mibitem->data.len = len; + memcpy(mibitem->data.data, data, len); + + return p80211req_dorequest(wlandev, (u8 *) & msg); +} + + +/* The interface functions, called by the cfg80211 layer */ +int prism2_change_virtual_intf(struct wiphy *wiphy, + struct net_device *dev, + enum nl80211_iftype type, u32 *flags, + struct vif_params *params) +{ + wlandevice_t *wlandev = dev->ml_priv; + u32 data; + int result; + int err = 0; + + switch (type) { + case NL80211_IFTYPE_ADHOC: + if (wlandev->macmode == WLAN_MACMODE_IBSS_STA) goto exit; + wlandev->macmode = WLAN_MACMODE_IBSS_STA; + data = 0; + break; + case NL80211_IFTYPE_STATION: + if (wlandev->macmode == WLAN_MACMODE_ESS_STA) goto exit; + wlandev->macmode = WLAN_MACMODE_ESS_STA; + data = 1; + break; + default: + printk(KERN_WARNING "Operation mode: %d not support\n", type); + return -EOPNOTSUPP; + } + + /* Set Operation mode to the PORT TYPE RID */ + result = prism2_domibset_uint32(wlandev, DIDmib_p2_p2Static_p2CnfPortType, data); + + if (result) + err = -EFAULT; + + dev->ieee80211_ptr->iftype = type; + +exit: + return err; +} + +int prism2_add_key(struct wiphy *wiphy, struct net_device *dev, + u8 key_index, const u8 *mac_addr, + struct key_params *params) { + wlandevice_t *wlandev = dev->ml_priv; + u32 did; + + int err = 0; + int result = 0; + + switch (params->cipher) { + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: + result = prism2_domibset_uint32(wlandev, + DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, + key_index); + if (result) goto exit; + + /* send key to driver */ + switch (key_index) { + case 0: + did = + DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0; + break; + + case 1: + did = + DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1; + break; + + case 2: + did = + DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2; + break; + + case 3: + did = + DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3; + break; + + default: + err = -EINVAL; + goto exit; + } + + result = prism2_domibset_pstr32(wlandev, did, params->key_len, params->key); + if (result) goto exit; + break; + + default: + pr_debug("Unsupported cipher suite\n"); + result = 1; + } + +exit: + if (result) err = -EFAULT; + + return err; +} + +int prism2_get_key(struct wiphy *wiphy, struct net_device *dev, + u8 key_index, const u8 *mac_addr, void *cookie, + void (*callback)(void *cookie, struct key_params*)) { + wlandevice_t *wlandev = dev->ml_priv; + struct key_params params; + int len; + + if(key_index >= NUM_WEPKEYS) return -EINVAL; + + len = wlandev->wep_keylens[key_index]; + memset(¶ms, 0, sizeof(params)); + + if (len == 13) { + params.cipher = WLAN_CIPHER_SUITE_WEP104; + } else if (len == 5) { + params.cipher = WLAN_CIPHER_SUITE_WEP104; + } else return -ENOENT; + params.key_len = len; + params.key = wlandev->wep_keys[key_index]; + + callback(cookie, ¶ms); + return 0; +} + +int prism2_del_key(struct wiphy *wiphy, struct net_device *dev, + u8 key_index, const u8 *mac_addr) { + wlandevice_t *wlandev = dev->ml_priv; + u32 did; + int err = 0; + int result = 0; + + /* There is no direct way in the hardware (AFAIK) of removing + a key, so we will cheat by setting the key to a bogus value */ + /* send key to driver */ + switch (key_index) { + case 0: + did = + DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0; + break; + + case 1: + did = + DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1; + break; + + case 2: + did = + DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2; + break; + + case 3: + did = + DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3; + break; + + default: + err = -EINVAL; + goto exit; + } + + result = prism2_domibset_pstr32(wlandev, did, 13, "0000000000000"); + +exit: + if (result) err = -EFAULT; + + return err; +} + +int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev, + u8 key_index) { + wlandevice_t *wlandev = dev->ml_priv; + + int err = 0; + int result = 0; + + result = prism2_domibset_uint32(wlandev, + DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, + key_index); + + if (result) err = -EFAULT; + + return err; +} + + +int prism2_get_station(struct wiphy *wiphy, struct net_device *dev, + u8 *mac, struct station_info *sinfo) { + wlandevice_t *wlandev = dev->ml_priv; + p80211msg_lnxreq_commsquality_t quality; + int result; + + memset(sinfo, 0, sizeof(*sinfo)); + + if ((wlandev == NULL) || (wlandev->msdstate != WLAN_MSD_RUNNING)) + return -EOPNOTSUPP; + + /* build request message */ + quality.msgcode = DIDmsg_lnxreq_commsquality; + quality.dbm.data = P80211ENUM_truth_true; + quality.dbm.status = P80211ENUM_msgitem_status_data_ok; + + /* send message to nsd */ + if (wlandev->mlmerequest == NULL) + return -EOPNOTSUPP; + + result = wlandev->mlmerequest(wlandev, (p80211msg_t *) & quality); + + + if (result == 0) { + sinfo->txrate.legacy = quality.txrate.data; + sinfo->filled |= STATION_INFO_TX_BITRATE; + sinfo->signal = quality.level.data; + sinfo->filled |= STATION_INFO_SIGNAL; + } + + return result; +} + +int prism2_scan(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_scan_request *request) +{ + struct prism2_wiphy_private *priv = wiphy_priv(wiphy); + wlandevice_t *wlandev = dev->ml_priv; + p80211msg_dot11req_scan_t msg1; + p80211msg_dot11req_scan_results_t msg2; + int result; + int err = 0; + int numbss = 0; + int i = 0; + u8 ie_buf[46]; + int ie_len; + + if (!request) + return -EINVAL; + + if (priv->scan_request && priv->scan_request != request) + return -EBUSY; + + if (wlandev->macmode == WLAN_MACMODE_ESS_AP) { + printk(KERN_ERR "Can't scan in AP mode\n"); + return -EOPNOTSUPP; + } + + priv->scan_request = request; + + memset(&msg1, 0x00, sizeof(p80211msg_dot11req_scan_t)); + msg1.msgcode = DIDmsg_dot11req_scan; + msg1.bsstype.data = P80211ENUM_bsstype_any; + + memset(&(msg1.bssid.data), 0xFF, sizeof(p80211item_pstr6_t)); + msg1.bssid.data.len = 6; + + if (request->n_ssids > 0) { + msg1.scantype.data = P80211ENUM_scantype_active; + msg1.ssid.data.len = request->ssids->ssid_len; + memcpy(msg1.ssid.data.data, request->ssids->ssid, request->ssids->ssid_len); + } else { + msg1.scantype.data = 0; + } + msg1.probedelay.data = 0; + + for (i = 0; + (i < request->n_channels) && i < ARRAY_SIZE(prism2_channels); + i++) + msg1.channellist.data.data[i] = + ieee80211_frequency_to_channel(request->channels[i]->center_freq); + msg1.channellist.data.len = request->n_channels; + + msg1.maxchanneltime.data = 250; + msg1.minchanneltime.data = 200; + + result = p80211req_dorequest(wlandev, (u8 *) &msg1); + if (result) { + err = prism2_result2err(msg1.resultcode.data); + goto exit; + } + /* Now retrieve scan results */ + numbss = msg1.numbss.data; + + for (i = 0; i < numbss; i++) { + memset(&msg2, 0, sizeof(msg2)); + msg2.msgcode = DIDmsg_dot11req_scan_results; + msg2.bssindex.data = i; + + result = p80211req_dorequest(wlandev, (u8 *) &msg2); + if ((result != 0) || + (msg2.resultcode.data != P80211ENUM_resultcode_success)) { + break; + } + + ie_buf[0] = WLAN_EID_SSID; + ie_buf[1] = msg2.ssid.data.len; + ie_len = ie_buf[1] + 2; + memcpy(&ie_buf[2], &(msg2.ssid.data.data), msg2.ssid.data.len); + cfg80211_inform_bss(wiphy, + ieee80211_get_channel(wiphy, ieee80211_dsss_chan_to_freq(msg2.dschannel.data)), + (const u8 *) &(msg2.bssid.data.data), + msg2.timestamp.data, msg2.capinfo.data, + msg2.beaconperiod.data, + ie_buf, + ie_len, + (msg2.signal.data - 65536) * 100, /* Conversion to signed type */ + GFP_KERNEL + ); + } + + if (result) { + err = prism2_result2err(msg2.resultcode.data); + } + +exit: + cfg80211_scan_done(request, err ? 1 : 0); + priv->scan_request = NULL; + return err; +} + +int prism2_set_wiphy_params(struct wiphy *wiphy, u32 changed) { + struct prism2_wiphy_private *priv = wiphy_priv(wiphy); + wlandevice_t *wlandev = priv->wlandev; + u32 data; + int result; + int err = 0; + + if (changed & WIPHY_PARAM_RTS_THRESHOLD) { + if (wiphy->rts_threshold == -1) + data = 2347; + else + data = wiphy->rts_threshold; + + result = + prism2_domibset_uint32(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold, + data); + if (result) { + err = -EFAULT; + goto exit; + } + } + + if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { + + if (wiphy->frag_threshold == -1) + data = 2346; + else + data = wiphy->frag_threshold; + + result = + prism2_domibset_uint32(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold, + data); + if (result) { + err = -EFAULT; + goto exit; + } + } + +exit: + return err; +} + +int prism2_connect(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_connect_params *sme) { + wlandevice_t *wlandev = dev->ml_priv; + struct ieee80211_channel *channel = sme->channel; + p80211msg_lnxreq_autojoin_t msg_join; + u32 did; + int length = sme->ssid_len; + int chan = -1; + int is_wep = (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) || + (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104); + int result; + int err = 0; + + /* Set the channel */ + if (channel) { + chan = ieee80211_frequency_to_channel(channel->center_freq); + + result = + prism2_domibset_uint32(wlandev, + DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel, + chan); + + if (result) goto exit; + } + + /* Set the authorisation */ + if ((sme->auth_type == NL80211_AUTHTYPE_OPEN_SYSTEM) || + ((sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC) && !is_wep)) + msg_join.authtype.data = P80211ENUM_authalg_opensystem; + else if ((sme->auth_type == NL80211_AUTHTYPE_SHARED_KEY) || + ((sme->auth_type == NL80211_AUTHTYPE_AUTOMATIC) && is_wep)) + msg_join.authtype.data = P80211ENUM_authalg_sharedkey; + else printk(KERN_WARNING "Unhandled authorisation type for connect (%d)\n", sme->auth_type); + + /* Set the encryption - we only support wep */ + if (is_wep) { + + if (sme->key) { + result = prism2_domibset_uint32(wlandev, + DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, + sme->key_idx); + if (result) goto exit; + + /* send key to driver */ + switch (sme->key_idx) { + case 0: + did = + DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0; + break; + + case 1: + did = + DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1; + break; + + case 2: + did = + DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2; + break; + + case 3: + did = + DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3; + break; + + default: + err = -EINVAL; + goto exit; + } + + result = prism2_domibset_pstr32(wlandev, did, sme->key_len, (u8 *) sme->key); + if (result) goto exit; + + } + + /* Assume we should set privacy invoked and exclude unencrypted + We could possibly use sme->privacy here, but the assumption + seems reasonable anyway */ + result = prism2_domibset_uint32(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, + P80211ENUM_truth_true); + if (result) goto exit; + result = prism2_domibset_uint32(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, + P80211ENUM_truth_true); + if (result) goto exit; + + } else { + /* Assume we should unset privacy invoked and exclude unencrypted */ + result = prism2_domibset_uint32(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, + P80211ENUM_truth_false); + if (result) goto exit; + result = prism2_domibset_uint32(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, + P80211ENUM_truth_false); + if (result) goto exit; + + } + + /* Now do the actual join. Note there is no way that I can + see to request a specific bssid */ + msg_join.msgcode = DIDmsg_lnxreq_autojoin; + + memcpy(msg_join.ssid.data.data, sme->ssid, length); + msg_join.ssid.data.len = length; + + result = p80211req_dorequest(wlandev, (u8 *) & msg_join); + +exit: + if (result) err = -EFAULT; + + return err; +} + +int prism2_disconnect(struct wiphy *wiphy, struct net_device *dev, + u16 reason_code) { + wlandevice_t *wlandev = dev->ml_priv; + p80211msg_lnxreq_autojoin_t msg_join; + int result; + int err = 0; + + + /* Do a join, with a bogus ssid. Thats the only way I can think of */ + msg_join.msgcode = DIDmsg_lnxreq_autojoin; + + memcpy(msg_join.ssid.data.data, "---", 3); + msg_join.ssid.data.len = 3; + + result = p80211req_dorequest(wlandev, (u8 *) & msg_join); + + if (result) err = -EFAULT; + + return err; +} + + +int prism2_join_ibss(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_ibss_params *params) { + return -EOPNOTSUPP; +} + +int prism2_leave_ibss(struct wiphy *wiphy, struct net_device *dev) { + return -EOPNOTSUPP; +} + + +int prism2_set_tx_power(struct wiphy *wiphy, + enum tx_power_setting type, int dbm) { + struct prism2_wiphy_private *priv = wiphy_priv(wiphy); + wlandevice_t *wlandev = priv->wlandev; + u32 data; + int result; + int err = 0; + + if (type == TX_POWER_AUTOMATIC) + data = 30; + else + data = dbm; + + result = prism2_domibset_uint32(wlandev, + DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel, + data); + + if (result) { + err = -EFAULT; + goto exit; + } + +exit: + return err; +} + +int prism2_get_tx_power(struct wiphy *wiphy, int *dbm) { + struct prism2_wiphy_private *priv = wiphy_priv(wiphy); + wlandevice_t *wlandev = priv->wlandev; + p80211msg_dot11req_mibget_t msg; + p80211item_uint32_t *mibitem = (p80211item_uint32_t *) &msg.mibattribute.data; + int result; + int err = 0; + + msg.msgcode = DIDmsg_dot11req_mibget; + mibitem->did = + DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel; + + result = p80211req_dorequest(wlandev, (u8 *) & msg); + + if (result) { + err = -EFAULT; + goto exit; + } + + *dbm = mibitem->data; + +exit: + return err; +} + + + + +/* Interface callback functions, passing data back up to the cfg80211 layer */ +void prism2_connect_result(wlandevice_t *wlandev, u8 failed) { + + cfg80211_connect_result(wlandev->netdev, wlandev->bssid, + NULL, 0, NULL, 0, + failed ? WLAN_STATUS_UNSPECIFIED_FAILURE : WLAN_STATUS_SUCCESS, GFP_KERNEL); +} + +void prism2_disconnected(wlandevice_t *wlandev) { + + cfg80211_disconnected(wlandev->netdev, 0, NULL, + 0, GFP_KERNEL); +} + +void prism2_roamed(wlandevice_t *wlandev) { + + cfg80211_roamed(wlandev->netdev, wlandev->bssid, + NULL, 0, NULL, 0, GFP_KERNEL); +} + + +/* Structures for declaring wiphy interface */ +static const struct cfg80211_ops prism2_usb_cfg_ops = { + .change_virtual_intf = prism2_change_virtual_intf, + .add_key = prism2_add_key, + .get_key = prism2_get_key, + .del_key = prism2_del_key, + .set_default_key = prism2_set_default_key, + .get_station = prism2_get_station, + .scan = prism2_scan, + .set_wiphy_params = prism2_set_wiphy_params, + .connect = prism2_connect, + .disconnect = prism2_disconnect, + .join_ibss = prism2_join_ibss, + .leave_ibss = prism2_leave_ibss, + .set_tx_power = prism2_set_tx_power, + .get_tx_power = prism2_get_tx_power, +}; + + +/* Functions to create/free wiphy interface */ +struct wiphy *wlan_create_wiphy(struct device *dev, wlandevice_t *wlandev) +{ + struct wiphy *wiphy; + struct prism2_wiphy_private *priv; + wiphy = wiphy_new(&prism2_usb_cfg_ops, sizeof(struct prism2_wiphy_private)); + if (!wiphy) + return NULL; + + priv = wiphy_priv(wiphy); + priv->wlandev = wlandev; + memcpy(priv->channels, prism2_channels, sizeof(prism2_channels)); + memcpy(priv->rates, prism2_rates, sizeof(prism2_rates)); + priv->band.channels = priv->channels; + priv->band.n_channels = ARRAY_SIZE(prism2_channels); + priv->band.bitrates = priv->rates; + priv->band.n_bitrates = ARRAY_SIZE(prism2_rates); + wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band; + + set_wiphy_dev(wiphy, dev); + wiphy->privid = prism2_wiphy_privid; + wiphy->max_scan_ssids = 1; + wiphy->interface_modes = + BIT(NL80211_IFTYPE_STATION) | + BIT(NL80211_IFTYPE_ADHOC); + wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; + wiphy->n_cipher_suites = PRISM2_NUM_CIPHER_SUITES; + wiphy->cipher_suites = prism2_cipher_suites; + + if (wiphy_register(wiphy) < 0) + return NULL; + + return wiphy; +} + + +void wlan_free_wiphy(struct wiphy *wiphy) +{ + wiphy_unregister(wiphy); + wiphy_free(wiphy); +} diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h index 1fa42e01e8cb..ab9bfaab8b6b 100644 --- a/drivers/staging/wlan-ng/hfa384x.h +++ b/drivers/staging/wlan-ng/hfa384x.h @@ -1284,6 +1284,8 @@ typedef struct hfa384x { u16 link_status_new; struct sk_buff_head authq; + u32 txrate; + /* And here we have stuff that used to be in priv */ /* State variables */ diff --git a/drivers/staging/wlan-ng/p80211metastruct.h b/drivers/staging/wlan-ng/p80211metastruct.h index db12713eeaa9..e2e344c4ed82 100644 --- a/drivers/staging/wlan-ng/p80211metastruct.h +++ b/drivers/staging/wlan-ng/p80211metastruct.h @@ -113,6 +113,7 @@ typedef struct p80211msg_dot11req_scan_results { p80211item_uint32_t cfpollable; p80211item_uint32_t cfpollreq; p80211item_uint32_t privacy; + p80211item_uint32_t capinfo; p80211item_uint32_t basicrate1; p80211item_uint32_t basicrate2; p80211item_uint32_t basicrate3; @@ -209,6 +210,7 @@ typedef struct p80211msg_lnxreq_commsquality { p80211item_uint32_t link; p80211item_uint32_t level; p80211item_uint32_t noise; + p80211item_uint32_t txrate; } __attribute__ ((packed)) p80211msg_lnxreq_commsquality_t; typedef struct p80211msg_lnxreq_autojoin { diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c index 763ab1187a1c..31308b434344 100644 --- a/drivers/staging/wlan-ng/p80211netdev.c +++ b/drivers/staging/wlan-ng/p80211netdev.c @@ -75,6 +75,7 @@ #include #include +#include #include "p80211types.h" #include "p80211hdr.h" @@ -87,6 +88,8 @@ #include "p80211metastruct.h" #include "p80211metadef.h" +#include "cfg80211.c" + /* Support functions */ static void p80211netdev_rx_bh(unsigned long arg); @@ -732,6 +735,7 @@ static const struct net_device_ops p80211_netdev_ops = { * Arguments: * wlandev ptr to the wlandev structure for the * interface. +* physdev ptr to usb device * Returns: * zero on success, non-zero otherwise. * Call Context: @@ -740,10 +744,12 @@ static const struct net_device_ops p80211_netdev_ops = { * compiled drivers, this function will be called in the * context of the kernel startup code. ----------------------------------------------------------------*/ -int wlan_setup(wlandevice_t *wlandev) +int wlan_setup(wlandevice_t *wlandev, struct device *physdev) { int result = 0; - netdevice_t *dev; + netdevice_t *netdev; + struct wiphy *wiphy; + struct wireless_dev *wdev; /* Set up the wlandev */ wlandev->state = WLAN_DEVICE_CLOSED; @@ -755,20 +761,30 @@ int wlan_setup(wlandevice_t *wlandev) tasklet_init(&wlandev->rx_bh, p80211netdev_rx_bh, (unsigned long)wlandev); + /* Allocate and initialize the wiphy struct */ + wiphy = wlan_create_wiphy(physdev, wlandev); + if (wiphy == NULL) { + printk(KERN_ERR "Failed to alloc wiphy.\n"); + return 1; + } + /* Allocate and initialize the struct device */ - dev = alloc_netdev(0, "wlan%d", ether_setup); - if (dev == NULL) { + netdev = alloc_netdev(sizeof(struct wireless_dev), "wlan%d", ether_setup); + if (netdev == NULL) { printk(KERN_ERR "Failed to alloc netdev.\n"); + wlan_free_wiphy(wiphy); result = 1; } else { - wlandev->netdev = dev; - dev->ml_priv = wlandev; - dev->netdev_ops = &p80211_netdev_ops; + wlandev->netdev = netdev; + netdev->ml_priv = wlandev; + netdev->netdev_ops = &p80211_netdev_ops; + wdev = netdev_priv(netdev); + wdev->wiphy = wiphy; + wdev->iftype = NL80211_IFTYPE_STATION; + netdev->ieee80211_ptr = wdev; - dev->wireless_handlers = &p80211wext_handler_def; - - netif_stop_queue(dev); - netif_carrier_off(dev); + netif_stop_queue(netdev); + netif_carrier_off(netdev); } return result; @@ -797,14 +813,13 @@ int wlan_setup(wlandevice_t *wlandev) ----------------------------------------------------------------*/ int wlan_unsetup(wlandevice_t *wlandev) { - int result = 0; + struct wireless_dev *wdev; tasklet_kill(&wlandev->rx_bh); - if (wlandev->netdev == NULL) { - printk(KERN_ERR "called without wlandev->netdev set.\n"); - result = 1; - } else { + if (wlandev->netdev) { + wdev = netdev_priv(wlandev->netdev); + if(wdev->wiphy) wlan_free_wiphy(wdev->wiphy); free_netdev(wlandev->netdev); wlandev->netdev = NULL; } diff --git a/drivers/staging/wlan-ng/p80211netdev.h b/drivers/staging/wlan-ng/p80211netdev.h index 3c8c64800567..098ccf71e035 100644 --- a/drivers/staging/wlan-ng/p80211netdev.h +++ b/drivers/staging/wlan-ng/p80211netdev.h @@ -148,6 +148,7 @@ int p80211wext_event_associated(struct wlandevice *wlandev, int assoc); #define MAX_KEYLEN 32 #define HOSTWEP_DEFAULTKEY_MASK (BIT(1)|BIT(0)) +#define HOSTWEP_SHAREDKEY BIT(3) #define HOSTWEP_DECRYPT BIT(4) #define HOSTWEP_ENCRYPT BIT(5) #define HOSTWEP_PRIVACYINVOKED BIT(6) @@ -233,7 +234,7 @@ int wep_decrypt(wlandevice_t *wlandev, u8 *buf, u32 len, int key_override, int wep_encrypt(wlandevice_t *wlandev, u8 *buf, u8 *dst, u32 len, int keynum, u8 *iv, u8 *icv); -int wlan_setup(wlandevice_t *wlandev); +int wlan_setup(wlandevice_t *wlandev, struct device *physdev); int wlan_unsetup(wlandevice_t *wlandev); int register_wlandev(wlandevice_t *wlandev); int unregister_wlandev(wlandevice_t *wlandev); diff --git a/drivers/staging/wlan-ng/p80211wext.c b/drivers/staging/wlan-ng/p80211wext.c deleted file mode 100644 index 387194d4a6eb..000000000000 --- a/drivers/staging/wlan-ng/p80211wext.c +++ /dev/null @@ -1,1690 +0,0 @@ -/* src/p80211/p80211wext.c -* -* Glue code to make linux-wlan-ng a happy wireless extension camper. -* -* original author: Reyk Floeter -* Completely re-written by Solomon Peachy -* -* Copyright (C) 2002 AbsoluteValue Systems, Inc. All Rights Reserved. -* -------------------------------------------------------------------- -* -* linux-wlan -* -* The contents of this file are subject to the Mozilla Public -* License Version 1.1 (the "License"); you may not use this file -* except in compliance with the License. You may obtain a copy of -* the License at http://www.mozilla.org/MPL/ -* -* Software distributed under the License is distributed on an "AS -* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -* implied. See the License for the specific language governing -* rights and limitations under the License. -* -* Alternatively, the contents of this file may be used under the -* terms of the GNU Public License version 2 (the "GPL"), in which -* case the provisions of the GPL are applicable instead of the -* above. If you wish to allow the use of your version of this file -* only under the terms of the GPL and not to allow others to use -* your version of this file under the MPL, indicate your decision -* by deleting the provisions above and replace them with the notice -* and other provisions required by the GPL. If you do not delete -* the provisions above, a recipient may use your version of this -* file under either the MPL or the GPL. -* -* -------------------------------------------------------------------- -*/ - -/*================================================================*/ -/* System Includes */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "p80211types.h" -#include "p80211hdr.h" -#include "p80211conv.h" -#include "p80211mgmt.h" -#include "p80211msg.h" -#include "p80211metastruct.h" -#include "p80211metadef.h" -#include "p80211netdev.h" -#include "p80211ioctl.h" -#include "p80211req.h" - -static int p80211wext_giwrate(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *rrq, char *extra); -static int p80211wext_giwessid(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *data, char *essid); - -static u8 p80211_mhz_to_channel(u16 mhz) -{ - if (mhz >= 5000) - return (mhz - 5000) / 5; - - if (mhz == 2484) - return 14; - - if (mhz >= 2407) - return (mhz - 2407) / 5; - - return 0; -} - -static u16 p80211_channel_to_mhz(u8 ch, int dot11a) -{ - - if (ch == 0) - return 0; - if (ch > 200) - return 0; - - /* 5G */ - if (dot11a) - return 5000 + (5 * ch); - - /* 2.4G */ - if (ch == 14) - return 2484; - - if ((ch < 14) && (ch > 0)) - return 2407 + (5 * ch); - - return 0; -} - -/* taken from orinoco.c ;-) */ -static const long p80211wext_channel_freq[] = { - 2412, 2417, 2422, 2427, 2432, 2437, 2442, - 2447, 2452, 2457, 2462, 2467, 2472, 2484 -}; - -#define NUM_CHANNELS ARRAY_SIZE(p80211wext_channel_freq) - -/* steal a spare bit to store the shared/opensystems state. - should default to open if not set */ -#define HOSTWEP_SHAREDKEY BIT(3) - -static int qual_as_percent(int snr) -{ - if (snr <= 0) - return 0; - if (snr <= 40) - return snr * 5 / 2; - return 100; -} - -static int p80211wext_setmib(wlandevice_t *wlandev, u32 did, u32 data) -{ - p80211msg_dot11req_mibset_t msg; - p80211item_uint32_t *mibitem = - (p80211item_uint32_t *)&msg.mibattribute.data; - int result; - - msg.msgcode = DIDmsg_dot11req_mibset; - memset(mibitem, 0, sizeof(*mibitem)); - mibitem->did = did; - mibitem->data = data; - result = p80211req_dorequest(wlandev, (u8 *) &msg); - - return result; -} - -/* - * get a 32 bit mib value - */ -static int p80211wext_getmib(wlandevice_t *wlandev, u32 did, u32 *data) -{ - p80211msg_dot11req_mibset_t msg; - p80211item_uint32_t *mibitem = - (p80211item_uint32_t *)&msg.mibattribute.data; - int result; - - msg.msgcode = DIDmsg_dot11req_mibget; - memset(mibitem, 0, sizeof(*mibitem)); - mibitem->did = did; - result = p80211req_dorequest(wlandev, (u8 *) &msg); - if (!result) - *data = mibitem->data; - - return result; -} - -static int p80211wext_autojoin(wlandevice_t *wlandev) -{ - p80211msg_lnxreq_autojoin_t msg; - struct iw_point data; - char ssid[IW_ESSID_MAX_SIZE]; - - int result; - int err = 0; - - /* Get ESSID */ - result = p80211wext_giwessid(wlandev->netdev, NULL, &data, ssid); - - if (result) { - err = -EFAULT; - goto exit; - } - - if (wlandev->hostwep & HOSTWEP_SHAREDKEY) - msg.authtype.data = P80211ENUM_authalg_sharedkey; - else - msg.authtype.data = P80211ENUM_authalg_opensystem; - - msg.msgcode = DIDmsg_lnxreq_autojoin; - - /* Trim the last '\0' to fit the SSID format */ - - if (data.length && ssid[data.length - 1] == '\0') - data.length = data.length - 1; - - memcpy(msg.ssid.data.data, ssid, data.length); - msg.ssid.data.len = data.length; - - result = p80211req_dorequest(wlandev, (u8 *) &msg); - - if (result) { - err = -EFAULT; - goto exit; - } - -exit: - - return err; - -} - -/* called by /proc/net/wireless */ -struct iw_statistics *p80211wext_get_wireless_stats(netdevice_t *dev) -{ - p80211msg_lnxreq_commsquality_t quality; - wlandevice_t *wlandev = dev->ml_priv; - struct iw_statistics *wstats = &wlandev->wstats; - int retval; - - /* Check */ - if ((wlandev == NULL) || (wlandev->msdstate != WLAN_MSD_RUNNING)) - return NULL; - - /* XXX Only valid in station mode */ - wstats->status = 0; - - /* build request message */ - quality.msgcode = DIDmsg_lnxreq_commsquality; - quality.dbm.data = P80211ENUM_truth_true; - quality.dbm.status = P80211ENUM_msgitem_status_data_ok; - - /* send message to nsd */ - if (wlandev->mlmerequest == NULL) - return NULL; - - retval = wlandev->mlmerequest(wlandev, (p80211msg_t *) &quality); - - wstats->qual.qual = qual_as_percent(quality.link.data); /* overall link quality */ - wstats->qual.level = quality.level.data; /* instant signal level */ - wstats->qual.noise = quality.noise.data; /* instant noise level */ - - wstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; - wstats->discard.code = wlandev->rx.decrypt_err; - wstats->discard.nwid = 0; - wstats->discard.misc = 0; - - wstats->discard.fragment = 0; /* incomplete fragments */ - wstats->discard.retries = 0; /* tx retries. */ - wstats->miss.beacon = 0; - - return wstats; -} - -static int p80211wext_giwname(netdevice_t *dev, - struct iw_request_info *info, - char *name, char *extra) -{ - struct iw_param rate; - int result; - int err = 0; - - result = p80211wext_giwrate(dev, NULL, &rate, NULL); - - if (result) { - err = -EFAULT; - goto exit; - } - - switch (rate.value) { - case 1000000: - case 2000000: - strcpy(name, "IEEE 802.11-DS"); - break; - case 5500000: - case 11000000: - strcpy(name, "IEEE 802.11-b"); - break; - } -exit: - return err; -} - -static int p80211wext_giwfreq(netdevice_t *dev, - struct iw_request_info *info, - struct iw_freq *freq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - int result; - int err = 0; - unsigned int value; - - result = p80211wext_getmib(wlandev, - DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel, - &value); - if (result) { - err = -EFAULT; - goto exit; - } - - if (value > NUM_CHANNELS) { - err = -EFAULT; - goto exit; - } - - /* convert into frequency instead of a channel */ - freq->e = 1; - freq->m = p80211_channel_to_mhz(value, 0) * 100000; - -exit: - return err; -} - -static int p80211wext_siwfreq(netdevice_t *dev, - struct iw_request_info *info, - struct iw_freq *freq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - int result; - int err = 0; - unsigned int value; - - if (!wlan_wext_write) { - err = -EOPNOTSUPP; - goto exit; - } - - if ((freq->e == 0) && (freq->m <= 1000)) - value = freq->m; - else - value = p80211_mhz_to_channel(freq->m); - - result = p80211wext_setmib(wlandev, - DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel, - value); - - if (result) { - err = -EFAULT; - goto exit; - } - -exit: - return err; -} - -static int p80211wext_giwmode(netdevice_t *dev, - struct iw_request_info *info, - __u32 *mode, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - - switch (wlandev->macmode) { - case WLAN_MACMODE_IBSS_STA: - *mode = IW_MODE_ADHOC; - break; - case WLAN_MACMODE_ESS_STA: - *mode = IW_MODE_INFRA; - break; - case WLAN_MACMODE_ESS_AP: - *mode = IW_MODE_MASTER; - break; - default: - /* Not set yet. */ - *mode = IW_MODE_AUTO; - } - - return 0; -} - -static int p80211wext_siwmode(netdevice_t *dev, - struct iw_request_info *info, - __u32 *mode, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - int result; - int err = 0; - - if (!wlan_wext_write) { - err = -EOPNOTSUPP; - goto exit; - } - - if (*mode != IW_MODE_ADHOC && *mode != IW_MODE_INFRA && - *mode != IW_MODE_MASTER) { - err = (-EOPNOTSUPP); - goto exit; - } - - /* Operation mode is the same with current mode */ - if (*mode == wlandev->macmode) - goto exit; - - switch (*mode) { - case IW_MODE_ADHOC: - wlandev->macmode = WLAN_MACMODE_IBSS_STA; - break; - case IW_MODE_INFRA: - wlandev->macmode = WLAN_MACMODE_ESS_STA; - break; - case IW_MODE_MASTER: - wlandev->macmode = WLAN_MACMODE_ESS_AP; - break; - default: - /* Not set yet. */ - printk(KERN_INFO "Operation mode: %d not support\n", *mode); - return -EOPNOTSUPP; - } - - /* Set Operation mode to the PORT TYPE RID */ - result = p80211wext_setmib(wlandev, - DIDmib_p2_p2Static_p2CnfPortType, - (*mode == IW_MODE_ADHOC) ? 0 : 1); - if (result) - err = -EFAULT; -exit: - return err; -} - -static int p80211wext_giwrange(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *data, char *extra) -{ - struct iw_range *range = (struct iw_range *)extra; - int i, val; - - /* for backward compatability set size and zero everything we don't understand */ - data->length = sizeof(*range); - memset(range, 0, sizeof(*range)); - - range->txpower_capa = IW_TXPOW_DBM; - /* XXX what about min/max_pmp, min/max_pmt, etc. */ - - range->we_version_compiled = WIRELESS_EXT; - range->we_version_source = 13; - - range->retry_capa = IW_RETRY_LIMIT; - range->retry_flags = IW_RETRY_LIMIT; - range->min_retry = 0; - range->max_retry = 255; - - range->event_capa[0] = (IW_EVENT_CAPA_K_0 | /* mode/freq/ssid */ - IW_EVENT_CAPA_MASK(SIOCGIWAP) | - IW_EVENT_CAPA_MASK(SIOCGIWSCAN)); - range->event_capa[1] = IW_EVENT_CAPA_K_1; /* encode */ - range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVQUAL) | - IW_EVENT_CAPA_MASK(IWEVCUSTOM)); - - range->num_channels = NUM_CHANNELS; - - /* XXX need to filter against the regulatory domain &| active set */ - val = 0; - for (i = 0; i < NUM_CHANNELS; i++) { - range->freq[val].i = i + 1; - range->freq[val].m = p80211wext_channel_freq[i] * 100000; - range->freq[val].e = 1; - val++; - } - - range->num_frequency = val; - - /* Max of /proc/net/wireless */ - range->max_qual.qual = 100; - range->max_qual.level = 0; - range->max_qual.noise = 0; - range->sensitivity = 3; - /* XXX these need to be nsd-specific! */ - - range->min_rts = 0; - range->max_rts = 2347; - range->min_frag = 256; - range->max_frag = 2346; - - range->max_encoding_tokens = NUM_WEPKEYS; - range->num_encoding_sizes = 2; - range->encoding_size[0] = 5; - range->encoding_size[1] = 13; - - /* XXX what about num_bitrates/throughput? */ - range->num_bitrates = 0; - - /* estimated max throughput */ - /* XXX need to cap it if we're running at ~2Mbps.. */ - range->throughput = 5500000; - - return 0; -} - -static int p80211wext_giwap(netdevice_t *dev, - struct iw_request_info *info, - struct sockaddr *ap_addr, char *extra) -{ - - wlandevice_t *wlandev = dev->ml_priv; - - memcpy(ap_addr->sa_data, wlandev->bssid, WLAN_BSSID_LEN); - ap_addr->sa_family = ARPHRD_ETHER; - - return 0; -} - -static int p80211wext_giwencode(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *erq, char *key) -{ - wlandevice_t *wlandev = dev->ml_priv; - int err = 0; - int i; - - i = (erq->flags & IW_ENCODE_INDEX) - 1; - erq->flags = 0; - - if (wlandev->hostwep & HOSTWEP_PRIVACYINVOKED) - erq->flags |= IW_ENCODE_ENABLED; - else - erq->flags |= IW_ENCODE_DISABLED; - - if (wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED) - erq->flags |= IW_ENCODE_RESTRICTED; - else - erq->flags |= IW_ENCODE_OPEN; - - i = (erq->flags & IW_ENCODE_INDEX) - 1; - - if (i == -1) - i = wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK; - - if ((i < 0) || (i >= NUM_WEPKEYS)) { - err = -EINVAL; - goto exit; - } - - erq->flags |= i + 1; - - /* copy the key from the driver cache as the keys are read-only MIBs */ - erq->length = wlandev->wep_keylens[i]; - memcpy(key, wlandev->wep_keys[i], erq->length); - -exit: - return err; -} - -static int p80211wext_siwencode(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *erq, char *key) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211msg_dot11req_mibset_t msg; - p80211item_pstr32_t pstr; - - int err = 0; - int result = 0; - int i; - - if (!wlan_wext_write) { - err = (-EOPNOTSUPP); - goto exit; - } - - /* Check the Key index first. */ - i = (erq->flags & IW_ENCODE_INDEX); - if (i) { - if ((i < 1) || (i > NUM_WEPKEYS)) { - err = -EINVAL; - goto exit; - } else { - i--; - } - /* Set current key number only if no keys are given */ - if (erq->flags & IW_ENCODE_NOKEY) { - result = - p80211wext_setmib(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, - i); - - if (result) { - err = -EFAULT; - goto exit; - } - } - - } else { - /* Use defaultkey if no Key Index */ - i = wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK; - } - - /* Check if there is no key information in the iwconfig request */ - if ((erq->flags & IW_ENCODE_NOKEY) == 0) { - - /*------------------------------------------------------------ - * If there is WEP Key for setting, check the Key Information - * and then set it to the firmware. - -------------------------------------------------------------*/ - - if (erq->length > 0) { - /* copy the key from the driver cache as the keys are read-only MIBs */ - wlandev->wep_keylens[i] = erq->length; - memcpy(wlandev->wep_keys[i], key, erq->length); - - /* Prepare data struture for p80211req_dorequest. */ - memcpy(pstr.data.data, key, erq->length); - pstr.data.len = erq->length; - - switch (i) { - case 0: - pstr.did = - DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0; - break; - - case 1: - pstr.did = - DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1; - break; - - case 2: - pstr.did = - DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2; - break; - - case 3: - pstr.did = - DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3; - break; - - default: - err = -EINVAL; - goto exit; - } - - msg.msgcode = DIDmsg_dot11req_mibset; - memcpy(&msg.mibattribute.data, &pstr, sizeof(pstr)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); - - if (result) { - err = -EFAULT; - goto exit; - } - } - - } - - /* Check the PrivacyInvoked flag */ - if (erq->flags & IW_ENCODE_DISABLED) { - result = - p80211wext_setmib(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, - P80211ENUM_truth_false); - } else { - result = - p80211wext_setmib(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, - P80211ENUM_truth_true); - } - - if (result) { - err = -EFAULT; - goto exit; - } - - /* The security mode may be open or restricted, and its meaning - depends on the card used. With most cards, in open mode no - authentication is used and the card may also accept non- - encrypted sessions, whereas in restricted mode only encrypted - sessions are accepted and the card will use authentication if - available. - */ - if (erq->flags & IW_ENCODE_RESTRICTED) { - result = - p80211wext_setmib(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, - P80211ENUM_truth_true); - } else if (erq->flags & IW_ENCODE_OPEN) { - result = - p80211wext_setmib(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, - P80211ENUM_truth_false); - } - - if (result) { - err = -EFAULT; - goto exit; - } - -exit: - - return err; -} - -static int p80211wext_giwessid(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *data, char *essid) -{ - wlandevice_t *wlandev = dev->ml_priv; - - if (wlandev->ssid.len) { - data->length = wlandev->ssid.len; - data->flags = 1; - memcpy(essid, wlandev->ssid.data, data->length); - essid[data->length] = 0; - } else { - memset(essid, 0, sizeof(wlandev->ssid.data)); - data->length = 0; - data->flags = 0; - } - - return 0; -} - -static int p80211wext_siwessid(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *data, char *essid) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211msg_lnxreq_autojoin_t msg; - - int result; - int err = 0; - int length = data->length; - - if (!wlan_wext_write) { - err = (-EOPNOTSUPP); - goto exit; - } - - if (wlandev->hostwep & HOSTWEP_SHAREDKEY) - msg.authtype.data = P80211ENUM_authalg_sharedkey; - else - msg.authtype.data = P80211ENUM_authalg_opensystem; - - msg.msgcode = DIDmsg_lnxreq_autojoin; - - /* Trim the last '\0' to fit the SSID format */ - if (length && essid[length - 1] == '\0') - length--; - - memcpy(msg.ssid.data.data, essid, length); - msg.ssid.data.len = length; - - pr_debug("autojoin_ssid for %s \n", essid); - result = p80211req_dorequest(wlandev, (u8 *) &msg); - pr_debug("autojoin_ssid %d\n", result); - - if (result) { - err = -EFAULT; - goto exit; - } - -exit: - return err; -} - -static int p80211wext_siwcommit(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *data, char *essid) -{ - wlandevice_t *wlandev = dev->ml_priv; - int err = 0; - - if (!wlan_wext_write) { - err = (-EOPNOTSUPP); - goto exit; - } - - /* Auto Join */ - err = p80211wext_autojoin(wlandev); - -exit: - return err; -} - -static int p80211wext_giwrate(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *rrq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - int result; - int err = 0; - unsigned int value; - - result = p80211wext_getmib(wlandev, DIDmib_p2_p2MAC_p2CurrentTxRate, &value); - if (result) { - err = -EFAULT; - goto exit; - } - - rrq->fixed = 0; /* can it change? */ - rrq->disabled = 0; - rrq->value = 0; - -#define HFA384x_RATEBIT_1 ((u16)1) -#define HFA384x_RATEBIT_2 ((u16)2) -#define HFA384x_RATEBIT_5dot5 ((u16)4) -#define HFA384x_RATEBIT_11 ((u16)8) - - switch (value) { - case HFA384x_RATEBIT_1: - rrq->value = 1000000; - break; - case HFA384x_RATEBIT_2: - rrq->value = 2000000; - break; - case HFA384x_RATEBIT_5dot5: - rrq->value = 5500000; - break; - case HFA384x_RATEBIT_11: - rrq->value = 11000000; - break; - default: - err = -EINVAL; - } -exit: - return err; -} - -static int p80211wext_giwrts(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *rts, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - int result; - int err = 0; - unsigned int value; - - result = p80211wext_getmib(wlandev, - DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold, - &value); - if (result) { - err = -EFAULT; - goto exit; - } - - rts->value = value; - rts->disabled = (rts->value == 2347); - rts->fixed = 1; - -exit: - return err; -} - -static int p80211wext_siwrts(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *rts, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - int result; - int err = 0; - unsigned int value; - - if (!wlan_wext_write) { - err = -EOPNOTSUPP; - goto exit; - } - - if (rts->disabled) - value = 2347; - else - value = rts->value; - - result = p80211wext_setmib(wlandev, - DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold, - value); - if (result) { - err = -EFAULT; - goto exit; - } - -exit: - return err; -} - -static int p80211wext_giwfrag(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *frag, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - int result; - int err = 0; - unsigned int value; - - result = p80211wext_getmib(wlandev, - DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold, - &value); - if (result) { - err = -EFAULT; - goto exit; - } - - frag->value = value; - frag->disabled = (frag->value == 2346); - frag->fixed = 1; - -exit: - return err; -} - -static int p80211wext_siwfrag(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *frag, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - int result; - int err = 0; - int value; - - if (!wlan_wext_write) { - err = (-EOPNOTSUPP); - goto exit; - } - - if (frag->disabled) - value = 2346; - else - value = frag->value; - - result = p80211wext_setmib(wlandev, - DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold, - value); - - if (result) { - err = -EFAULT; - goto exit; - } - -exit: - return err; -} - -#ifndef IW_RETRY_LONG -#define IW_RETRY_LONG IW_RETRY_MAX -#endif - -#ifndef IW_RETRY_SHORT -#define IW_RETRY_SHORT IW_RETRY_MIN -#endif - -static int p80211wext_giwretry(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *rrq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - int result; - int err = 0; - u16 shortretry, longretry, lifetime; - unsigned int value; - - result = p80211wext_getmib(wlandev, - DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit, - &value); - if (result) { - err = -EFAULT; - goto exit; - } - - shortretry = value; - - result = p80211wext_getmib(wlandev, - DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit, - &value); - if (result) { - err = -EFAULT; - goto exit; - } - - longretry = value; - - result = p80211wext_getmib(wlandev, - DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime, - &value); - if (result) { - err = -EFAULT; - goto exit; - } - - lifetime = value; - - rrq->disabled = 0; - - if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { - rrq->flags = IW_RETRY_LIFETIME; - rrq->value = lifetime * 1024; - } else { - if (rrq->flags & IW_RETRY_LONG) { - rrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG; - rrq->value = longretry; - } else { - rrq->flags = IW_RETRY_LIMIT; - rrq->value = shortretry; - if (shortretry != longretry) - rrq->flags |= IW_RETRY_SHORT; - } - } - -exit: - return err; - -} - -static int p80211wext_siwretry(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *rrq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; - int result; - int err = 0; - unsigned int value; - - if (!wlan_wext_write) { - err = (-EOPNOTSUPP); - goto exit; - } - - if (rrq->disabled) { - err = -EINVAL; - goto exit; - } - - msg.msgcode = DIDmsg_dot11req_mibset; - - if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { - - value = rrq->value /= 1024; - result = p80211wext_setmib(wlandev, - DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime, - value); - if (result) { - err = -EFAULT; - goto exit; - } - } else { - if (rrq->flags & IW_RETRY_LONG) { - result = p80211wext_setmib(wlandev, - DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit, - rrq->value); - - if (result) { - err = -EFAULT; - goto exit; - } - } - - if (rrq->flags & IW_RETRY_SHORT) { - result = p80211wext_setmib(wlandev, - DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit, - rrq->value); - - if (result) { - err = -EFAULT; - goto exit; - } - } - } - -exit: - return err; - -} - -static int p80211wext_siwtxpow(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *rrq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; - int result; - int err = 0; - unsigned int value; - - if (!wlan_wext_write) { - err = (-EOPNOTSUPP); - goto exit; - } - - if (rrq->fixed == 0) - value = 30; - else - value = rrq->value; - result = p80211wext_setmib(wlandev, - DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel, - value); - - if (result) { - err = -EFAULT; - goto exit; - } - -exit: - return err; -} - -static int p80211wext_giwtxpow(netdevice_t *dev, - struct iw_request_info *info, - struct iw_param *rrq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - int result; - int err = 0; - unsigned int value; - - result = p80211wext_getmib(wlandev, - DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel, - &value); - - if (result) { - err = -EFAULT; - goto exit; - } - - /* XXX handle OFF by setting disabled = 1; */ - - rrq->flags = 0; /* IW_TXPOW_DBM; */ - rrq->disabled = 0; - rrq->fixed = 0; - rrq->value = value; - -exit: - return err; -} - -static int p80211wext_siwspy(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *srq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - struct sockaddr address[IW_MAX_SPY]; - int number = srq->length; - int i; - - /* Copy the data from the input buffer */ - memcpy(address, extra, sizeof(struct sockaddr) * number); - - wlandev->spy_number = 0; - - if (number > 0) { - - /* extract the addresses */ - for (i = 0; i < number; i++) { - - memcpy(wlandev->spy_address[i], address[i].sa_data, - ETH_ALEN); - } - - /* reset stats */ - memset(wlandev->spy_stat, 0, - sizeof(struct iw_quality) * IW_MAX_SPY); - - /* set number of addresses */ - wlandev->spy_number = number; - } - - return 0; -} - -/* jkriegl: from orinoco, modified */ -static int p80211wext_giwspy(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *srq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - - struct sockaddr address[IW_MAX_SPY]; - struct iw_quality spy_stat[IW_MAX_SPY]; - int number; - int i; - - number = wlandev->spy_number; - - if (number > 0) { - - /* populate address and spy struct's */ - for (i = 0; i < number; i++) { - memcpy(address[i].sa_data, wlandev->spy_address[i], - ETH_ALEN); - address[i].sa_family = AF_UNIX; - memcpy(&spy_stat[i], &wlandev->spy_stat[i], - sizeof(struct iw_quality)); - } - - /* reset update flag */ - for (i = 0; i < number; i++) - wlandev->spy_stat[i].updated = 0; - } - - /* push stuff to user space */ - srq->length = number; - memcpy(extra, address, sizeof(struct sockaddr) * number); - memcpy(extra + sizeof(struct sockaddr) * number, spy_stat, - sizeof(struct iw_quality) * number); - - return 0; -} - -static int prism2_result2err(int prism2_result) -{ - int err = 0; - - switch (prism2_result) { - case P80211ENUM_resultcode_invalid_parameters: - err = -EINVAL; - break; - case P80211ENUM_resultcode_implementation_failure: - err = -EIO; - break; - case P80211ENUM_resultcode_not_supported: - err = -EOPNOTSUPP; - break; - default: - err = 0; - break; - } - - return err; -} - -static int p80211wext_siwscan(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *srq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211msg_dot11req_scan_t msg; - int result; - int err = 0; - int i = 0; - - if (wlandev->macmode == WLAN_MACMODE_ESS_AP) { - printk(KERN_ERR "Can't scan in AP mode\n"); - err = (-EOPNOTSUPP); - goto exit; - } - - memset(&msg, 0x00, sizeof(p80211msg_dot11req_scan_t)); - msg.msgcode = DIDmsg_dot11req_scan; - msg.bsstype.data = P80211ENUM_bsstype_any; - - memset(&(msg.bssid.data), 0xFF, sizeof(p80211item_pstr6_t)); - msg.bssid.data.len = 6; - - msg.scantype.data = P80211ENUM_scantype_active; - msg.probedelay.data = 0; - - for (i = 1; i <= 14; i++) - msg.channellist.data.data[i - 1] = i; - msg.channellist.data.len = 14; - - msg.maxchanneltime.data = 250; - msg.minchanneltime.data = 200; - - result = p80211req_dorequest(wlandev, (u8 *) &msg); - if (result) - err = prism2_result2err(msg.resultcode.data); - -exit: - return err; -} - -/* Helper to translate scan into Wireless Extensions scan results. - * Inspired by the prism54 code, which was in turn inspired by the - * airo driver code. - */ -static char *wext_translate_bss(struct iw_request_info *info, char *current_ev, - char *end_buf, - p80211msg_dot11req_scan_results_t *bss) -{ - struct iw_event iwe; /* Temporary buffer */ - - /* The first entry must be the MAC address */ - memcpy(iwe.u.ap_addr.sa_data, bss->bssid.data.data, WLAN_BSSID_LEN); - iwe.u.ap_addr.sa_family = ARPHRD_ETHER; - iwe.cmd = SIOCGIWAP; - current_ev = - iwe_stream_add_event(info, current_ev, end_buf, &iwe, - IW_EV_ADDR_LEN); - - /* The following entries will be displayed in the same order we give them */ - - /* The ESSID. */ - if (bss->ssid.data.len > 0) { - char essid[IW_ESSID_MAX_SIZE + 1]; - int size; - - size = - min_t(unsigned short, IW_ESSID_MAX_SIZE, - bss->ssid.data.len); - memset(&essid, 0, sizeof(essid)); - memcpy(&essid, bss->ssid.data.data, size); - pr_debug(" essid size = %d\n", size); - iwe.u.data.length = size; - iwe.u.data.flags = 1; - iwe.cmd = SIOCGIWESSID; - current_ev = - iwe_stream_add_point(info, current_ev, end_buf, &iwe, - &essid[0]); - pr_debug(" essid size OK.\n"); - } - - switch (bss->bsstype.data) { - case P80211ENUM_bsstype_infrastructure: - iwe.u.mode = IW_MODE_MASTER; - break; - - case P80211ENUM_bsstype_independent: - iwe.u.mode = IW_MODE_ADHOC; - break; - - default: - iwe.u.mode = 0; - break; - } - iwe.cmd = SIOCGIWMODE; - if (iwe.u.mode) - current_ev = - iwe_stream_add_event(info, current_ev, end_buf, &iwe, - IW_EV_UINT_LEN); - - /* Encryption capability */ - if (bss->privacy.data == P80211ENUM_truth_true) - iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; - else - iwe.u.data.flags = IW_ENCODE_DISABLED; - iwe.u.data.length = 0; - iwe.cmd = SIOCGIWENCODE; - current_ev = - iwe_stream_add_point(info, current_ev, end_buf, &iwe, NULL); - - /* Add frequency. (short) bss->channel is the frequency in MHz */ - iwe.u.freq.m = bss->dschannel.data; - iwe.u.freq.e = 0; - iwe.cmd = SIOCGIWFREQ; - current_ev = - iwe_stream_add_event(info, current_ev, end_buf, &iwe, - IW_EV_FREQ_LEN); - - /* Add quality statistics */ - iwe.u.qual.level = bss->signal.data; - iwe.u.qual.noise = bss->noise.data; - /* do a simple SNR for quality */ - iwe.u.qual.qual = qual_as_percent(bss->signal.data - bss->noise.data); - iwe.cmd = IWEVQUAL; - current_ev = - iwe_stream_add_event(info, current_ev, end_buf, &iwe, - IW_EV_QUAL_LEN); - - return current_ev; -} - -static int p80211wext_giwscan(netdevice_t *dev, - struct iw_request_info *info, - struct iw_point *srq, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - p80211msg_dot11req_scan_results_t msg; - int result = 0; - int err = 0; - int i = 0; - int scan_good = 0; - char *current_ev = extra; - - /* Since wireless tools doesn't really have a way of passing how - * many scan results results there were back here, keep grabbing them - * until we fail. - */ - do { - memset(&msg, 0, sizeof(msg)); - msg.msgcode = DIDmsg_dot11req_scan_results; - msg.bssindex.data = i; - - result = p80211req_dorequest(wlandev, (u8 *) &msg); - if ((result != 0) || - (msg.resultcode.data != P80211ENUM_resultcode_success)) { - break; - } - - current_ev = - wext_translate_bss(info, current_ev, - extra + IW_SCAN_MAX_DATA, &msg); - scan_good = 1; - i++; - } while (i < IW_MAX_AP); - - srq->length = (current_ev - extra); - srq->flags = 0; /* todo */ - - if (result && !scan_good) - err = prism2_result2err(msg.resultcode.data); - - return err; -} - -/* extra wireless extensions stuff to support NetworkManager (I hope) */ - -/* SIOCSIWENCODEEXT */ -static int p80211wext_set_encodeext(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; - p80211msg_dot11req_mibset_t msg; - p80211item_pstr32_t *pstr; - - int result = 0; - struct iw_point *encoding = &wrqu->encoding; - int idx = encoding->flags & IW_ENCODE_INDEX; - - pr_debug("set_encode_ext flags[%d] alg[%d] keylen[%d]\n", - ext->ext_flags, (int)ext->alg, (int)ext->key_len); - - if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) { - /* set default key ? I'm not sure if this the the correct thing to do here */ - - if (idx) { - if (idx < 1 || idx > NUM_WEPKEYS) - return -EINVAL; - else - idx--; - } - pr_debug("setting default key (%d)\n", idx); - result = - p80211wext_setmib(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, - idx); - if (result) - return -EFAULT; - } - - if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { - if (ext->alg != IW_ENCODE_ALG_WEP) { - pr_debug("asked to set a non wep key :(\n"); - return -EINVAL; - } - if (idx) { - if (idx < 1 || idx > NUM_WEPKEYS) - return -EINVAL; - else - idx--; - } - pr_debug("Set WEP key (%d)\n", idx); - wlandev->wep_keylens[idx] = ext->key_len; - memcpy(wlandev->wep_keys[idx], ext->key, ext->key_len); - - memset(&msg, 0, sizeof(msg)); - pstr = (p80211item_pstr32_t *) &msg.mibattribute.data; - memcpy(pstr->data.data, ext->key, ext->key_len); - pstr->data.len = ext->key_len; - switch (idx) { - case 0: - pstr->did = - DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0; - break; - case 1: - pstr->did = - DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1; - break; - case 2: - pstr->did = - DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2; - break; - case 3: - pstr->did = - DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3; - break; - default: - break; - } - msg.msgcode = DIDmsg_dot11req_mibset; - result = p80211req_dorequest(wlandev, (u8 *) &msg); - pr_debug("result (%d)\n", result); - } - return result; -} - -/* SIOCGIWENCODEEXT */ -static int p80211wext_get_encodeext(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; - - struct iw_point *encoding = &wrqu->encoding; - int result = 0; - int max_len; - int idx; - - pr_debug("get_encode_ext flags[%d] alg[%d] keylen[%d]\n", - ext->ext_flags, (int)ext->alg, (int)ext->key_len); - - max_len = encoding->length - sizeof(*ext); - if (max_len <= 0) { - pr_debug("get_encodeext max_len [%d] invalid\n", max_len); - result = -EINVAL; - goto exit; - } - idx = encoding->flags & IW_ENCODE_INDEX; - - pr_debug("get_encode_ext index [%d]\n", idx); - - if (idx) { - if (idx < 1 || idx > NUM_WEPKEYS) { - pr_debug("get_encode_ext invalid key index [%d]\n", - idx); - result = -EINVAL; - goto exit; - } - idx--; - } else { - /* default key ? not sure what to do */ - /* will just use key[0] for now ! FIX ME */ - } - - encoding->flags = idx + 1; - memset(ext, 0, sizeof(*ext)); - - ext->alg = IW_ENCODE_ALG_WEP; - ext->key_len = wlandev->wep_keylens[idx]; - memcpy(ext->key, wlandev->wep_keys[idx], ext->key_len); - - encoding->flags |= IW_ENCODE_ENABLED; -exit: - return result; -} - -/* SIOCSIWAUTH */ -static int p80211_wext_set_iwauth(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - struct iw_param *param = &wrqu->param; - int result = 0; - - pr_debug("set_iwauth flags[%d]\n", (int)param->flags & IW_AUTH_INDEX); - - switch (param->flags & IW_AUTH_INDEX) { - case IW_AUTH_DROP_UNENCRYPTED: - pr_debug("drop_unencrypted %d\n", param->value); - if (param->value) - result = - p80211wext_setmib(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, - P80211ENUM_truth_true); - else - result = - p80211wext_setmib(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, - P80211ENUM_truth_false); - break; - - case IW_AUTH_PRIVACY_INVOKED: - pr_debug("privacy invoked %d\n", param->value); - if (param->value) - result = - p80211wext_setmib(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, - P80211ENUM_truth_true); - else - result = - p80211wext_setmib(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, - P80211ENUM_truth_false); - - break; - - case IW_AUTH_80211_AUTH_ALG: - if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) { - pr_debug("set open_system\n"); - wlandev->hostwep &= ~HOSTWEP_SHAREDKEY; - } else if (param->value & IW_AUTH_ALG_SHARED_KEY) { - pr_debug("set shared key\n"); - wlandev->hostwep |= HOSTWEP_SHAREDKEY; - } else { - /* don't know what to do know */ - pr_debug("unknown AUTH_ALG (%d)\n", param->value); - result = -EINVAL; - } - break; - - default: - break; - } - - return result; -} - -/* SIOCSIWAUTH */ -static int p80211_wext_get_iwauth(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - wlandevice_t *wlandev = dev->ml_priv; - struct iw_param *param = &wrqu->param; - int result = 0; - - pr_debug("get_iwauth flags[%d]\n", (int)param->flags & IW_AUTH_INDEX); - - switch (param->flags & IW_AUTH_INDEX) { - case IW_AUTH_DROP_UNENCRYPTED: - param->value = - wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED ? 1 : 0; - break; - - case IW_AUTH_PRIVACY_INVOKED: - param->value = - wlandev->hostwep & HOSTWEP_PRIVACYINVOKED ? 1 : 0; - break; - - case IW_AUTH_80211_AUTH_ALG: - param->value = - wlandev->hostwep & HOSTWEP_SHAREDKEY ? - IW_AUTH_ALG_SHARED_KEY : IW_AUTH_ALG_OPEN_SYSTEM; - break; - - default: - break; - } - - return result; -} - -#define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT] - -static iw_handler p80211wext_handlers[] = { - IW_IOCTL(SIOCSIWCOMMIT) = (iw_handler) p80211wext_siwcommit, - IW_IOCTL(SIOCGIWNAME) = (iw_handler) p80211wext_giwname, -/* SIOCSIWNWID,SIOCGIWNWID */ - IW_IOCTL(SIOCSIWFREQ) = (iw_handler) p80211wext_siwfreq, - IW_IOCTL(SIOCGIWFREQ) = (iw_handler) p80211wext_giwfreq, - IW_IOCTL(SIOCSIWMODE) = (iw_handler) p80211wext_siwmode, - IW_IOCTL(SIOCGIWMODE) = (iw_handler) p80211wext_giwmode, -/* SIOCSIWSENS,SIOCGIWSENS,SIOCSIWRANGE */ - IW_IOCTL(SIOCGIWRANGE) = (iw_handler) p80211wext_giwrange, -/* SIOCSIWPRIV,SIOCGIWPRIV,SIOCSIWSTATS,SIOCGIWSTATS */ - IW_IOCTL(SIOCSIWSPY) = (iw_handler) p80211wext_siwspy, - IW_IOCTL(SIOCGIWSPY) = (iw_handler) p80211wext_giwspy, -/* SIOCSIWAP */ - IW_IOCTL(SIOCGIWAP) = (iw_handler) p80211wext_giwap, -/* SIOCGIWAPLIST */ - IW_IOCTL(SIOCSIWSCAN) = (iw_handler) p80211wext_siwscan, - IW_IOCTL(SIOCGIWSCAN) = (iw_handler) p80211wext_giwscan, - IW_IOCTL(SIOCSIWESSID) = (iw_handler) p80211wext_siwessid, - IW_IOCTL(SIOCGIWESSID) = (iw_handler) p80211wext_giwessid, -/* SIOCSIWNICKN */ - IW_IOCTL(SIOCGIWNICKN) = (iw_handler) p80211wext_giwessid, -/* SIOCSIWRATE */ - IW_IOCTL(SIOCGIWRATE) = (iw_handler) p80211wext_giwrate, - IW_IOCTL(SIOCSIWRTS) = (iw_handler) p80211wext_siwrts, - IW_IOCTL(SIOCGIWRTS) = (iw_handler) p80211wext_giwrts, - IW_IOCTL(SIOCSIWFRAG) = (iw_handler) p80211wext_siwfrag, - IW_IOCTL(SIOCGIWFRAG) = (iw_handler) p80211wext_giwfrag, - IW_IOCTL(SIOCSIWTXPOW) = (iw_handler) p80211wext_siwtxpow, - IW_IOCTL(SIOCGIWTXPOW) = (iw_handler) p80211wext_giwtxpow, - IW_IOCTL(SIOCSIWRETRY) = (iw_handler) p80211wext_siwretry, - IW_IOCTL(SIOCGIWRETRY) = (iw_handler) p80211wext_giwretry, - IW_IOCTL(SIOCSIWENCODE) = (iw_handler) p80211wext_siwencode, - IW_IOCTL(SIOCGIWENCODE) = (iw_handler) p80211wext_giwencode, -/* SIOCSIWPOWER,SIOCGIWPOWER */ -/* WPA operations */ -/* SIOCSIWGENIE,SIOCGIWGENIE generic IE */ - IW_IOCTL(SIOCSIWAUTH) = (iw_handler) p80211_wext_set_iwauth, /*set authentication mode params */ - IW_IOCTL(SIOCGIWAUTH) = (iw_handler) p80211_wext_get_iwauth, /*get authentication mode params */ - IW_IOCTL(SIOCSIWENCODEEXT) = (iw_handler) p80211wext_set_encodeext, /*set encoding token & mode */ - IW_IOCTL(SIOCGIWENCODEEXT) = (iw_handler) p80211wext_get_encodeext, /*get encoding token & mode */ -/* SIOCSIWPMKSA PMKSA cache operation */ -}; - -struct iw_handler_def p80211wext_handler_def = { - .num_standard = ARRAY_SIZE(p80211wext_handlers), - .standard = p80211wext_handlers, - .get_wireless_stats = p80211wext_get_wireless_stats -}; - -int p80211wext_event_associated(wlandevice_t *wlandev, int assoc) -{ - union iwreq_data data; - - /* Send the association state first */ - data.ap_addr.sa_family = ARPHRD_ETHER; - if (assoc) - memcpy(data.ap_addr.sa_data, wlandev->bssid, ETH_ALEN); - else - memset(data.ap_addr.sa_data, 0, ETH_ALEN); - - if (wlan_wext_write) - wireless_send_event(wlandev->netdev, SIOCGIWAP, &data, NULL); - - if (!assoc) - goto done; - - /* XXX send association data, like IEs, etc etc. */ - -done: - return 0; -} diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c index 4d1cdfc35420..ef23f8b1454f 100644 --- a/drivers/staging/wlan-ng/prism2mgmt.c +++ b/drivers/staging/wlan-ng/prism2mgmt.c @@ -463,6 +463,8 @@ int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp) /* capinfo bits */ count = le16_to_cpu(item->capinfo); + req->capinfo.status = P80211ENUM_msgitem_status_data_ok; + req->capinfo.data = count; /* privacy flag */ req->privacy.status = P80211ENUM_msgitem_status_data_ok; diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c index 6cd09352f893..5ec5741b5eb1 100644 --- a/drivers/staging/wlan-ng/prism2sta.c +++ b/drivers/staging/wlan-ng/prism2sta.c @@ -124,6 +124,10 @@ MODULE_PARM_DESC(prism2_reset_settletime, "reset settle time in ms"); MODULE_LICENSE("Dual MPL/GPL"); +void prism2_connect_result(wlandevice_t *wlandev, u8 failed); +void prism2_disconnected(wlandevice_t *wlandev); +void prism2_roamed(wlandevice_t *wlandev); + static int prism2sta_open(wlandevice_t *wlandev); static int prism2sta_close(wlandevice_t *wlandev); static void prism2sta_reset(wlandevice_t *wlandev); @@ -401,6 +405,7 @@ static int prism2sta_mlmerequest(wlandevice_t *wlandev, p80211msg_t *msg) qualmsg->link.data = le16_to_cpu(hw->qual.CQ_currBSS); qualmsg->level.data = le16_to_cpu(hw->qual.ASL_currBSS); qualmsg->noise.data = le16_to_cpu(hw->qual.ANL_currFC); + qualmsg->txrate.data = hw->txrate; break; } @@ -1300,6 +1305,9 @@ void prism2sta_processing_defer(struct work_struct *data) (portstatus == HFA384x_PSTATUS_CONN_IBSS) ? WLAN_MACMODE_IBSS_STA : WLAN_MACMODE_ESS_STA; + /* signal back up to cfg80211 layer */ + prism2_connect_result(wlandev, P80211ENUM_truth_false); + /* Get the ball rolling on the comms quality stuff */ prism2sta_commsqual_defer(&hw->commsqual_bh); } @@ -1315,25 +1323,16 @@ void prism2sta_processing_defer(struct work_struct *data) * Indicate Deauthentication * Block Transmits, Ignore receives of data frames */ - if (hw->join_ap == 2) { - hfa384x_JoinRequest_data_t joinreq; - joinreq = hw->joinreq; - /* Send the join request */ - hfa384x_drvr_setconfig(hw, - HFA384x_RID_JOINREQUEST, - &joinreq, - HFA384x_RID_JOINREQUEST_LEN); + if (wlandev->netdev->type == ARPHRD_ETHER) printk(KERN_INFO - "linkstatus=DISCONNECTED (re-submitting join)\n"); - } else { - if (wlandev->netdev->type == ARPHRD_ETHER) - printk(KERN_INFO - "linkstatus=DISCONNECTED (unhandled)\n"); - } + "linkstatus=DISCONNECTED (unhandled)\n"); wlandev->macmode = WLAN_MACMODE_NONE; netif_carrier_off(wlandev->netdev); + /* signal back up to cfg80211 layer */ + prism2_disconnected(wlandev); + break; case HFA384x_LINK_AP_CHANGE: @@ -1376,6 +1375,9 @@ void prism2sta_processing_defer(struct work_struct *data) hw->link_status = HFA384x_LINK_CONNECTED; netif_carrier_on(wlandev->netdev); + /* signal back up to cfg80211 layer */ + prism2_roamed(wlandev); + break; case HFA384x_LINK_AP_OUTOFRANGE: @@ -1435,6 +1437,9 @@ void prism2sta_processing_defer(struct work_struct *data) netif_carrier_off(wlandev->netdev); + /* signal back up to cfg80211 layer */ + prism2_connect_result(wlandev, P80211ENUM_truth_true); + break; default: @@ -1446,7 +1451,6 @@ void prism2sta_processing_defer(struct work_struct *data) } wlandev->linkstatus = (hw->link_status == HFA384x_LINK_CONNECTED); - p80211wext_event_associated(wlandev, wlandev->linkstatus); failed: return; @@ -1985,6 +1989,8 @@ void prism2sta_commsqual_defer(struct work_struct *data) hfa384x_t *hw = container_of(data, struct hfa384x, commsqual_bh); wlandevice_t *wlandev = hw->wlandev; hfa384x_bytestr32_t ssid; + p80211msg_dot11req_mibget_t msg; + p80211item_uint32_t *mibitem = (p80211item_uint32_t *) &msg.mibattribute.data; int result = 0; if (hw->wlandev->hwremoved) @@ -2013,6 +2019,34 @@ void prism2sta_commsqual_defer(struct work_struct *data) le16_to_cpu(hw->qual.ANL_currFC)); } + /* Get the signal rate */ + msg.msgcode = DIDmsg_dot11req_mibget; + mibitem->did = DIDmib_p2_p2MAC_p2CurrentTxRate; + result = p80211req_dorequest(wlandev, (u8 *) & msg); + + if (result) { + pr_debug("get signal rate failed, result = %d\n", + result); + goto done; + } + + switch (mibitem->data) { + case HFA384x_RATEBIT_1: + hw->txrate = 10; + break; + case HFA384x_RATEBIT_2: + hw->txrate = 20; + break; + case HFA384x_RATEBIT_5dot5: + hw->txrate = 55; + break; + case HFA384x_RATEBIT_11: + hw->txrate = 110; + break; + default: + pr_debug("Bad ratebit (%d)\n", mibitem->data); + } + /* Lastly, we need to make sure the BSSID didn't change on us */ result = hfa384x_drvr_getconfig(hw, HFA384x_RID_CURRENTBSSID, diff --git a/drivers/staging/wlan-ng/prism2usb.c b/drivers/staging/wlan-ng/prism2usb.c index f5cff751db2f..4efa027a81e4 100644 --- a/drivers/staging/wlan-ng/prism2usb.c +++ b/drivers/staging/wlan-ng/prism2usb.c @@ -119,7 +119,7 @@ static int prism2sta_probe_usb(struct usb_interface *interface, } hw = wlandev->priv; - if (wlan_setup(wlandev) != 0) { + if (wlan_setup(wlandev, &(interface->dev)) != 0) { printk(KERN_ERR "%s: wlan_setup() failed.\n", dev_info); result = -EIO; goto failed; From 2e04bb7b284198f26e129b03e03459a7045cb8b6 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 18 Jun 2010 15:30:28 -0700 Subject: [PATCH 101/523] Staging: winbond: fix build errors Some errors crept in due to a previous patch that I missed. This fixes them up so the driver continues to build, sorry about that. Signed-off-by: Greg Kroah-Hartman --- drivers/staging/winbond/phy_calibration.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/winbond/phy_calibration.c b/drivers/staging/winbond/phy_calibration.c index 5eefea31948c..5c1f05392db9 100644 --- a/drivers/staging/winbond/phy_calibration.c +++ b/drivers/staging/winbond/phy_calibration.c @@ -32,7 +32,7 @@ static const s32 Angles[] = { FIXED(DEG2RAD(0.111906)), FIXED(DEG2RAD(0.055953)), FIXED(DEG2RAD(0.027977)) }; -/****************** LOCAL FUNCTION DECLARATION SECTION ********************** +/****************** LOCAL FUNCTION DECLARATION SECTION **********************/ /* * void _phy_rf_write_delay(struct hw_data *phw_data); @@ -142,7 +142,6 @@ u32 _s32_to_s6(s32 data) data = 31; else if (data < -32) data = -32; - } val = data & 0x003F; @@ -1496,7 +1495,7 @@ void phy_calibration_winbond(struct hw_data *phw_data, u32 frequency) /******************/ void phy_set_rf_data(struct hw_data *pHwData, u32 index, u32 value) { - u32 ltmpi = 0; + u32 ltmp = 0; switch (pHwData->phy_type) { case RF_MAXIM_2825: From 594578979d0e25e178e0243eca9aa53499b89b05 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 17 Jun 2010 14:08:47 +0200 Subject: [PATCH 102/523] Staging: wlan-ng: silence a sparse warning This doesn't change the behavior. It just silences a sparse warning. drivers/staging/wlan-ng/hfa384x_usb.c:2810:62: warning: dubious: !x | !y The point of the bitwise OR is so that a logical OR could short circuit the second call to test_and_set_bit(). Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x_usb.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index a41db5dc8c7c..563017aaa363 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -2805,11 +2805,13 @@ void hfa384x_tx_timeout(wlandevice_t *wlandev) spin_lock_irqsave(&hw->ctlxq.lock, flags); - if (!hw->wlandev->hwremoved && - /* Note the bitwise OR, not the logical OR. */ - (!test_and_set_bit(WORK_TX_HALT, &hw->usb_flags) | - !test_and_set_bit(WORK_RX_HALT, &hw->usb_flags))) { - schedule_work(&hw->usb_work); + if (!hw->wlandev->hwremoved) { + int sched; + + sched = !test_and_set_bit(WORK_TX_HALT, &hw->usb_flags); + sched |= !test_and_set_bit(WORK_RX_HALT, &hw->usb_flags); + if (sched) + schedule_work(&hw->usb_work); } spin_unlock_irqrestore(&hw->ctlxq.lock, flags); From b55515cf729a33e49ecbc4f623ead33c735b5a65 Mon Sep 17 00:00:00 2001 From: Scott Kidder Date: Wed, 26 May 2010 22:36:15 -0500 Subject: [PATCH 103/523] Staging: otus: fix style issues in zdusb.c This is a patch to zdusb.c that fixes whitespace, C99 comment, and other style issues found by the checkpatch.pl tool Signed-off-by: Scott Kidder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/otus/zdusb.c | 209 ++++++++++++++++------------------- 1 file changed, 98 insertions(+), 111 deletions(-) diff --git a/drivers/staging/otus/zdusb.c b/drivers/staging/otus/zdusb.c index 2c799a250294..4014b7472454 100644 --- a/drivers/staging/otus/zdusb.c +++ b/drivers/staging/otus/zdusb.c @@ -48,7 +48,7 @@ static const char driver_name[] = "Otus"; /* table of devices that work with this driver */ static const struct usb_device_id zd1221_ids[] = { { USB_DEVICE(VENDOR_ATHR, PRODUCT_AR9170) }, - { USB_DEVICE(VENDOR_DLINK, PRODUCT_DWA160A) }, + { USB_DEVICE(VENDOR_DLINK, PRODUCT_DWA160A) }, { USB_DEVICE(VENDOR_NETGEAR, PRODUCT_WNDA3100) }, { USB_DEVICE(VENDOR_NETGEAR, PRODUCT_WN111v2) }, { } /* Terminating entry */ @@ -60,9 +60,9 @@ extern u8_t zfLnxInitSetup(struct net_device *dev, struct usbdrv_private *macp); extern int usbdrv_close(struct net_device *dev); extern u8_t zfLnxClearStructs(struct net_device *dev); extern int zfWdsClose(struct net_device *dev); -extern int zfUnregisterWdsDev(struct net_device* parentDev, u16_t wdsId); +extern int zfUnregisterWdsDev(struct net_device *parentDev, u16_t wdsId); extern int zfLnxVapClose(struct net_device *dev); -extern int zfLnxUnregisterVapDev(struct net_device* parentDev, u16_t vapId); +extern int zfLnxUnregisterVapDev(struct net_device *parentDev, u16_t vapId); /* WDS */ extern struct zsWdsStruct wds[ZM_WDS_PORT_NUMBER]; @@ -73,148 +73,135 @@ extern struct zsVapStruct vap[ZM_VAP_PORT_NUMBER]; static int zfLnxProbe(struct usb_interface *interface, const struct usb_device_id *id) { - struct usb_device *dev = interface_to_usbdev(interface); + struct usb_device *dev = interface_to_usbdev(interface); - struct net_device *net = NULL; - struct usbdrv_private *macp = NULL; - int vendor_id, product_id; - int result = 0; + struct net_device *net = NULL; + struct usbdrv_private *macp = NULL; + int vendor_id, product_id; + int result = 0; - usb_get_dev(dev); + usb_get_dev(dev); - vendor_id = dev->descriptor.idVendor; - product_id = dev->descriptor.idProduct; + vendor_id = dev->descriptor.idVendor; + product_id = dev->descriptor.idProduct; -#ifdef HMAC_DEBUG - printk(KERN_NOTICE "vendor_id = %04x\n", vendor_id); - printk(KERN_NOTICE "product_id = %04x\n", product_id); + #ifdef HMAC_DEBUG + printk(KERN_NOTICE "vendor_id = %04x\n", vendor_id); + printk(KERN_NOTICE "product_id = %04x\n", product_id); - if (dev->speed == USB_SPEED_HIGH) - printk(KERN_NOTICE "USB 2.0 Host\n"); - else - printk(KERN_NOTICE "USB 1.1 Host\n"); -#endif + if (dev->speed == USB_SPEED_HIGH) + printk(KERN_NOTICE "USB 2.0 Host\n"); + else + printk(KERN_NOTICE "USB 1.1 Host\n"); + #endif - macp = kzalloc(sizeof(struct usbdrv_private), GFP_KERNEL); - if (!macp) - { - printk(KERN_ERR "out of memory allocating device structure\n"); - result = -ENOMEM; - goto fail; - } + macp = kzalloc(sizeof(struct usbdrv_private), GFP_KERNEL); + if (!macp) { + printk(KERN_ERR "out of memory allocating device structure\n"); + result = -ENOMEM; + goto fail; + } - net = alloc_etherdev(0); + net = alloc_etherdev(0); - if (net == NULL) - { - printk(KERN_ERR "zfLnxProbe: Not able to alloc etherdev struct\n"); - result = -ENOMEM; - goto fail1; - } + if (net == NULL) { + printk(KERN_ERR "zfLnxProbe: Not able to alloc etherdev struct\n"); + result = -ENOMEM; + goto fail1; + } - strcpy(net->name, "ath%d"); + strcpy(net->name, "ath%d"); - net->ml_priv = macp; //kernel 2.6 - macp->udev = dev; - macp->device = net; + net->ml_priv = macp; /* kernel 2.6 */ + macp->udev = dev; + macp->device = net; - /* set up the endpoint information */ - /* check out the endpoints */ - macp->interface = interface; + /* set up the endpoint information */ + /* check out the endpoints */ + macp->interface = interface; - //init_waitqueue_head(&macp->regSet_wait); - //init_waitqueue_head(&macp->iorwRsp_wait); - //init_waitqueue_head(&macp->term_wait); + /* init_waitqueue_head(&macp->regSet_wait); */ + /* init_waitqueue_head(&macp->iorwRsp_wait); */ + /* init_waitqueue_head(&macp->term_wait); */ - if (!zfLnxAllocAllUrbs(macp)) - { - result = -ENOMEM; - goto fail2; - } + if (!zfLnxAllocAllUrbs(macp)) { + result = -ENOMEM; + goto fail2; + } - if (!zfLnxInitSetup(net, macp)) - { - result = -EIO; - goto fail3; - } - else - { - usb_set_intfdata(interface, macp); - SET_NETDEV_DEV(net, &interface->dev); + if (!zfLnxInitSetup(net, macp)) { + result = -EIO; + goto fail3; + } else { + usb_set_intfdata(interface, macp); + SET_NETDEV_DEV(net, &interface->dev); - if (register_netdev(net) != 0) - { - usb_set_intfdata(interface, NULL); - goto fail3; - } - } - - netif_carrier_off(net); - goto done; + if (register_netdev(net) != 0) { + usb_set_intfdata(interface, NULL); + goto fail3; + } + } + netif_carrier_off(net); + goto done; fail3: - zfLnxFreeAllUrbs(macp); + zfLnxFreeAllUrbs(macp); fail2: - free_netdev(net); //kernel 2.6 + free_netdev(net); /* kernel 2.6 */ fail1: - kfree(macp); - + kfree(macp); fail: - usb_put_dev(dev); - macp = NULL; - + usb_put_dev(dev); + macp = NULL; done: - return result; + return result; } static void zfLnxDisconnect(struct usb_interface *interface) { - struct usbdrv_private *macp = (struct usbdrv_private *) usb_get_intfdata(interface); + struct usbdrv_private *macp = (struct usbdrv_private *) usb_get_intfdata(interface); - printk(KERN_DEBUG "zfLnxDisconnect\n"); + printk(KERN_DEBUG "zfLnxDisconnect\n"); - if (!macp) - { - printk(KERN_ERR "unregistering non-existant device\n"); - return; - } + if (!macp) { + printk(KERN_ERR "unregistering non-existant device\n"); + return; + } - if (macp->driver_isolated) - { - if (macp->device->flags & IFF_UP) - usbdrv_close(macp->device); - } + if (macp->driver_isolated) + if (macp->device->flags & IFF_UP) + usbdrv_close(macp->device); -#if 0 - /* Close WDS */ - //zfWdsClose(wds[0].dev); - /* Unregister WDS */ - //zfUnregisterWdsDev(macp->device, 0); + #if 0 + /* Close WDS */ + /* zfWdsClose(wds[0].dev); */ + /* Unregister WDS */ + /* zfUnregisterWdsDev(macp->device, 0); */ - /* Close VAP */ - zfLnxVapClose(vap[0].dev); - /* Unregister VAP */ - zfLnxUnregisterVapDev(macp->device, 0); -#endif + /* Close VAP */ + zfLnxVapClose(vap[0].dev); + /* Unregister VAP */ + zfLnxUnregisterVapDev(macp->device, 0); + #endif - zfLnxClearStructs(macp->device); + zfLnxClearStructs(macp->device); - unregister_netdev(macp->device); + unregister_netdev(macp->device); - usb_put_dev(interface_to_usbdev(interface)); + usb_put_dev(interface_to_usbdev(interface)); - //printk(KERN_ERR "3. zfLnxUnlinkAllUrbs\n"); - //zfLnxUnlinkAllUrbs(macp); + /* printk(KERN_ERR "3. zfLnxUnlinkAllUrbs\n"); */ + /* zfLnxUnlinkAllUrbs(macp); */ - /* Free network interface */ - free_netdev(macp->device); + /* Free network interface */ + free_netdev(macp->device); - zfLnxFreeAllUrbs(macp); - //zfLnxClearStructs(macp->device); - kfree(macp); - macp = NULL; + zfLnxFreeAllUrbs(macp); + /* zfLnxClearStructs(macp->device); */ + kfree(macp); + macp = NULL; - usb_set_intfdata(interface, NULL); + usb_set_intfdata(interface, NULL); } static struct usb_driver zd1221_driver = { @@ -226,13 +213,13 @@ static struct usb_driver zd1221_driver = { int __init zfLnxIinit(void) { - printk(KERN_NOTICE "%s - version %s\n", DRIVER_NAME, VERSIONID); - return usb_register(&zd1221_driver); + printk(KERN_NOTICE "%s - version %s\n", DRIVER_NAME, VERSIONID); + return usb_register(&zd1221_driver); } void __exit zfLnxExit(void) { - usb_deregister(&zd1221_driver); + usb_deregister(&zd1221_driver); } module_init(zfLnxIinit); From 84f8008a7d1a44aa7c37d0ea367802e07e7daac0 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 7 Jun 2010 12:11:35 -0700 Subject: [PATCH 104/523] Staging: otus: TODO: Don't bother, for documentation purposes only On Mon, 2010-06-07 at 12:02 -0700, Luis R. Rodriguez wrote: > this driver is unmaintained and its only purpose is as a > source of documentation for developers working on ar9170 and carl9170. > Once carl9170 gets 11n support and merged upstream then this driver > can be removed. Then the TODO file should be updated. Signed-off-by: Joe Perches Signed-off-by: Greg Kroah-Hartman --- drivers/staging/otus/TODO | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/staging/otus/TODO b/drivers/staging/otus/TODO index 4caf026a4915..6fea974fcc9f 100644 --- a/drivers/staging/otus/TODO +++ b/drivers/staging/otus/TODO @@ -2,15 +2,7 @@ I'm hesitant to add a TODO file here, as the wireless developers would really have people help them out on the "clean" ar9170 driver that can be found at the linux-wireless developer site. -But, if you wish to clean up this driver instead, here's a short list of -things that need to be done to get it into a more mergable shape: - -TODO: - - checkpatch.pl cleanups - - sparse cleanups - - port to in-kernel 80211 stack - - review by the wireless developer community - -Please send any patches to Greg Kroah-Hartman and -Luis Rodriguez and the -otus-devel@lists.madwifi-project.org mailing list. +This driver is unmaintained and its only purpose is as a +source of documentation for developers working on ar9170 and carl9170. +Once carl9170 gets 11n support and merged upstream then this driver +can be removed. From cc7e7d38e9170719f780dd16312eef216714ad35 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 7 Jun 2010 23:44:57 +0200 Subject: [PATCH 105/523] Staging: otus: fix strcpy() overflow wrq->name is only 16 characters long but "IEEE 802.11-MIMO" is 16 characters + a NULL character, so it's too long. This patch changes it to "IEEE 802.11abgn". Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/otus/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/otus/ioctl.c b/drivers/staging/otus/ioctl.c index a48c8e4a9ea7..b85f1b29e3bc 100644 --- a/drivers/staging/otus/ioctl.c +++ b/drivers/staging/otus/ioctl.c @@ -507,7 +507,7 @@ int usbdrvwext_giwname(struct net_device *dev, { /* struct usbdrv_private *macp = dev->ml_priv; */ - strcpy(wrq->name, "IEEE 802.11-MIMO"); + strcpy(wrq->name, "IEEE 802.11abgn"); return 0; } From fa3620c515491ed94a403c1d4374fcc19350d7f3 Mon Sep 17 00:00:00 2001 From: Matti Lammi Date: Thu, 17 Jun 2010 11:41:33 +0300 Subject: [PATCH 106/523] Staging: otus: Removed one unnecessary space Nothing special really, just a small fix. Signed-off-by: Matti Lammi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/otus/apdbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/otus/apdbg.c b/drivers/staging/otus/apdbg.c index b59028e7e33c..32c26e59baf7 100644 --- a/drivers/staging/otus/apdbg.c +++ b/drivers/staging/otus/apdbg.c @@ -180,7 +180,7 @@ int main(int argc, char **argv) if (argc < 3) { fprintf(stderr, "%s: usage is \"%s " "[
] []\"\n", prgname, prgname); - fprintf(stderr, "valid operation : read, write, mem, reg, \n"); + fprintf(stderr, "valid operation : read, write, mem, reg,\n"); fprintf(stderr, " : txd, rxd, rmem, wmem\n"); fprintf(stderr, " : dmat, regt, test\n"); From 231ded903f2f30b2bcdbf6672c7197187e3bb1ee Mon Sep 17 00:00:00 2001 From: Scott Kidder Date: Fri, 28 May 2010 00:21:51 -0500 Subject: [PATCH 107/523] Staging: cx25821: added KERN_ facility levels Fixed issues found by checkpatch.pl including adding KERN_ facility levels to printk() calls and C99 comments. Signed-off-by: Scott Kidder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/cx25821/cx25821-audups11.c | 25 +++++++++------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/staging/cx25821/cx25821-audups11.c b/drivers/staging/cx25821/cx25821-audups11.c index e49ead982f39..8debde1bb683 100644 --- a/drivers/staging/cx25821/cx25821-audups11.c +++ b/drivers/staging/cx25821/cx25821-audups11.c @@ -82,9 +82,8 @@ static void buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) } } - if (list_empty(&q->active)) { + if (list_empty(&q->active)) dprintk(2, "active queue empty!\n"); - } } static struct videobuf_queue_ops cx25821_video_qops = { @@ -101,7 +100,7 @@ static int video_open(struct file *file) struct cx25821_fh *fh; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - printk("open dev=%s type=%s\n", video_device_node_name(vdev), + printk(KERN_INFO "open dev=%s type=%s\n", video_device_node_name(vdev), v4l2_type_names[type]); /* allocate + initialize per filehandle data */ @@ -139,7 +138,7 @@ static int video_open(struct file *file) } static ssize_t video_read(struct file *file, char __user * data, size_t count, - loff_t * ppos) + loff_t *ppos) { struct cx25821_fh *fh = file->private_data; @@ -187,8 +186,8 @@ static int video_release(struct file *file) struct cx25821_fh *fh = file->private_data; struct cx25821_dev *dev = fh->dev; - //stop the risc engine and fifo - //cx_write(channel11->dma_ctl, 0); + /* stop the risc engine and fifo */ + /* cx_write(channel11->dma_ctl, 0); */ /* stop video capture */ if (cx25821_res_check(fh, RESOURCE_VIDEO11)) { @@ -216,17 +215,14 @@ static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) struct cx25821_fh *fh = priv; struct cx25821_dev *dev = fh->dev; - if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) { + if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) return -EINVAL; - } - if (unlikely(i != fh->type)) { + if (unlikely(i != fh->type)) return -EINVAL; - } - if (unlikely(!cx25821_res_get(dev, fh, cx25821_get_resource(fh, RESOURCE_VIDEO11)))) { + if (unlikely(!cx25821_res_get(dev, fh, cx25821_get_resource(fh, RESOURCE_VIDEO11)))) return -EBUSY; - } return videobuf_streamon(get_queue(fh)); } @@ -297,9 +293,8 @@ static long video_ioctl_upstream11(struct file *file, unsigned int cmd, command = data_from_user->command; - if (command != UPSTREAM_START_AUDIO && command != UPSTREAM_STOP_AUDIO) { + if (command != UPSTREAM_START_AUDIO && command != UPSTREAM_STOP_AUDIO) return 0; - } dev->input_filename = data_from_user->input_filename; dev->input_audiofilename = data_from_user->input_filename; @@ -357,7 +352,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, return 0; } -// exported stuff +/* exported stuff */ static const struct v4l2_file_operations video_fops = { .owner = THIS_MODULE, .open = video_open, From ef079a76fe78d713eb695a222601fccb3e706f0f Mon Sep 17 00:00:00 2001 From: Nanakos Chrysostomos Date: Thu, 27 May 2010 16:19:52 +0000 Subject: [PATCH 108/523] Staging: dream: pmem.c: Fix checkpatch.pl issues. This patch resolves checkpatch.pl issues in the pmem.c file. Signed-off-by: Nanakos Chrysostomos Acked-by: Pavel Machek Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dream/pmem.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/dream/pmem.c b/drivers/staging/dream/pmem.c index 6387365a833d..064b59e5b500 100644 --- a/drivers/staging/dream/pmem.c +++ b/drivers/staging/dream/pmem.c @@ -24,8 +24,8 @@ #include #include #include -#include -#include +#include +#include #include #define PMEM_MAX_DEVICES 10 @@ -175,7 +175,7 @@ static int pmem_mmap(struct file *, struct vm_area_struct *); static int pmem_open(struct inode *, struct file *); static long pmem_ioctl(struct file *, unsigned int, unsigned long); -struct file_operations pmem_fops = { +const struct file_operations pmem_fops = { .release = pmem_release, .mmap = pmem_mmap, .open = pmem_open, @@ -399,8 +399,8 @@ static int pmem_allocate(int id, unsigned long len) DLOG("order %lx\n", order); /* look through the bitmap: - * if you find a free slot of the correct order use it - * otherwise, use the best fit (smallest with size > order) slot + * if you find a free slot of the correct order use it + * otherwise, use the best fit (smallest with size > order) slot */ while (curr < end) { if (PMEM_IS_FREE(id, curr)) { @@ -426,8 +426,8 @@ static int pmem_allocate(int id, unsigned long len) } /* now partition the best fit: - * split the slot into 2 buddies of order - 1 - * repeat until the slot is of the correct order + * split the slot into 2 buddies of order - 1 + * repeat until the slot is of the correct order */ while (PMEM_ORDER(id, best_fit) > (unsigned char)order) { int buddy; From 6167944d8a28c6a405babc4ae0f830be80a13fbb Mon Sep 17 00:00:00 2001 From: Scott Kidder Date: Wed, 26 May 2010 23:38:45 -0500 Subject: [PATCH 109/523] Staging: crystalhd: removed kfree(NULL) checks Removed kfree(NULL checks) that were not necessary Signed-off-by: Scott Kidder Signed-off-by: Greg Kroah-Hartman --- drivers/staging/crystalhd/crystalhd_lnx.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/crystalhd/crystalhd_lnx.c b/drivers/staging/crystalhd/crystalhd_lnx.c index a4ec891328cd..9d2805a33fd6 100644 --- a/drivers/staging/crystalhd/crystalhd_lnx.c +++ b/drivers/staging/crystalhd/crystalhd_lnx.c @@ -152,10 +152,8 @@ static int chd_dec_fetch_cdata(struct crystalhd_adp *adp, struct crystalhd_ioctl if (rc) { BCMLOG_ERR("failed to pull add_cdata sz:%x ua_off:%x\n", io->add_cdata_sz, (unsigned int)ua_off); - if (io->add_cdata) { - kfree(io->add_cdata); - io->add_cdata = NULL; - } + kfree(io->add_cdata); + io->add_cdata = NULL; return -ENODATA; } @@ -435,8 +433,7 @@ static void __devexit chd_dec_release_chdev(struct crystalhd_adp *adp) /* Clear iodata pool.. */ do { temp = chd_dec_alloc_iodata(adp, 0); - if (temp) - kfree(temp); + kfree(temp); } while (temp); crystalhd_delete_elem_pool(adp); From 0374e91c90ee74d4419ac91fb2030d96ee16d544 Mon Sep 17 00:00:00 2001 From: Andreas Herrmann Date: Fri, 28 May 2010 13:59:52 +0200 Subject: [PATCH 110/523] Staging: rtl81xx: Fix build problems when CONFIG_CRYPTO=n Select CONFIG_CRYPTO for all rtl81xx wireless drivers ... to avoid build problems like: ERROR: "crypto_destroy_tfm" [drivers/staging/rtl8187se/r8187se.ko] undefined! ERROR: "crypto_alloc_base" [drivers/staging/rtl8187se/r8187se.ko] undefined! ERROR: "crypto_destroy_tfm" [drivers/staging/rtl8192u/r8192u_usb.ko] undefined! ERROR: "crypto_alloc_base" [drivers/staging/rtl8192u/r8192u_usb.ko] undefined! ERROR: "crypto_destroy_tfm" [drivers/staging/rtl8192su/r8192s_usb.ko] undefined! ERROR: "crypto_alloc_base" [drivers/staging/rtl8192su/r8192s_usb.ko] undefined! ERROR: "crypto_destroy_tfm" [drivers/staging/rtl8192e/r8192e_pci.ko] undefined! ERROR: "crypto_alloc_base" [drivers/staging/rtl8192e/r8192e_pci.ko] undefined! when drivers are built as modules but CONFIG_CRYPTO=n. Signed-off-by: Andreas Herrmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8187se/Kconfig | 1 + drivers/staging/rtl8192e/Kconfig | 1 + drivers/staging/rtl8192su/Kconfig | 1 + drivers/staging/rtl8192u/Kconfig | 1 + 4 files changed, 4 insertions(+) diff --git a/drivers/staging/rtl8187se/Kconfig b/drivers/staging/rtl8187se/Kconfig index 155a78e07405..1b3103fbf29c 100644 --- a/drivers/staging/rtl8187se/Kconfig +++ b/drivers/staging/rtl8187se/Kconfig @@ -4,6 +4,7 @@ config R8187SE select WIRELESS_EXT select WEXT_PRIV select EEPROM_93CX6 + select CRYPTO default N ---help--- If built as a module, it will be called r8187se.ko. diff --git a/drivers/staging/rtl8192e/Kconfig b/drivers/staging/rtl8192e/Kconfig index 2ae3745f775f..2e64b239e241 100644 --- a/drivers/staging/rtl8192e/Kconfig +++ b/drivers/staging/rtl8192e/Kconfig @@ -3,5 +3,6 @@ config RTL8192E depends on PCI && WLAN select WIRELESS_EXT select WEXT_PRIV + select CRYPTO default N ---help--- diff --git a/drivers/staging/rtl8192su/Kconfig b/drivers/staging/rtl8192su/Kconfig index b422ea1ecf9c..27b89a432670 100644 --- a/drivers/staging/rtl8192su/Kconfig +++ b/drivers/staging/rtl8192su/Kconfig @@ -4,5 +4,6 @@ config RTL8192SU select WIRELESS_EXT select WEXT_PRIV select EEPROM_93CX6 + select CRYPTO default N ---help--- diff --git a/drivers/staging/rtl8192u/Kconfig b/drivers/staging/rtl8192u/Kconfig index 0439c90b4163..28969198e7e2 100644 --- a/drivers/staging/rtl8192u/Kconfig +++ b/drivers/staging/rtl8192u/Kconfig @@ -3,5 +3,6 @@ config RTL8192U depends on PCI && WLAN && USB select WIRELESS_EXT select WEXT_PRIV + select CRYPTO default N ---help--- From 70eef90e494aa3a941cbc3c4e196dc367e01b089 Mon Sep 17 00:00:00 2001 From: Nanakos Chrysostomos Date: Thu, 27 May 2010 19:20:41 +0000 Subject: [PATCH 111/523] Staging: dt3155: dt3155_isr.c: Fix checkpatch.pl issues. Fix resolves checkpatch.pl issues. Signed-off-by: Nanakos Chrysostomos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dt3155/dt3155_isr.c | 47 ++++++++++++++++------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/drivers/staging/dt3155/dt3155_isr.c b/drivers/staging/dt3155/dt3155_isr.c index 33ddc9c057ff..59b7bfd535d6 100644 --- a/drivers/staging/dt3155/dt3155_isr.c +++ b/drivers/staging/dt3155/dt3155_isr.c @@ -153,10 +153,12 @@ void push_ready(int m, int index) *****************************************************/ static int get_tail(int m) { - return (dt3155_fbuffer[m]->ready_head - - dt3155_fbuffer[m]->ready_len + - dt3155_fbuffer[m]->nbuffers)% - (dt3155_fbuffer[m]->nbuffers); + int ncount; + ncount = (dt3155_fbuffer[m]->ready_head - + dt3155_fbuffer[m]->ready_len + + dt3155_fbuffer[m]->nbuffers)% + (dt3155_fbuffer[m]->nbuffers); + return ncount; } @@ -191,23 +193,23 @@ void printques(int m) tail = get_tail(m); - printk("\n R:"); + printk(KERN_INFO "\n R:"); for (index = tail; index != head; index++, index = index % (num)) { frame_index = dt3155_fbuffer[m]->ready_que[index]; printk(" %d ", frame_index); } - printk("\n E:"); + printk(KERN_INFO "\n E:"); for (index = 0; index < dt3155_fbuffer[m]->empty_len; index++) { frame_index = dt3155_fbuffer[m]->empty_buffers[index]; printk(" %d ", frame_index); } frame_index = dt3155_fbuffer[m]->active_buf; - printk("\n A: %d", frame_index); + printk(KERN_INFO "\n A: %d", frame_index); frame_index = dt3155_fbuffer[m]->locked_buf; - printk("\n L: %d\n", frame_index); + printk(KERN_INFO "\n L: %d\n", frame_index); } @@ -263,19 +265,21 @@ void allocate_buffers(u32 *buf_addr, u32* total_size_kbs, #endif size_kbs = full_size_kbs; *buf_addr = 0; - printk("DT3155: We would like to get: %d KB\n", full_size_kbs); - printk("DT3155: ...but need at least: %d KB\n", min_size_kbs); - printk("DT3155: ...the allocator has: %d KB\n", allocator_max); + printk(KERN_INFO "DT3155: We would like to get: %d KB\n", full_size_kbs); + printk(KERN_INFO "DT3155: ...but need at least: %d KB\n", min_size_kbs); + printk(KERN_INFO "DT3155: ...the allocator has: %d KB\n", allocator_max); size_kbs = (full_size_kbs <= allocator_max ? full_size_kbs : allocator_max); if (size_kbs > min_size_kbs) { - if ((*buf_addr = allocator_allocate_dma(size_kbs, GFP_KERNEL)) != 0) { - printk("DT3155: Managed to allocate: %d KB\n", size_kbs); + *buf_addr = allocator_allocate_dma(size_kbs, GFP_KERNEL); + if (*buf_addr != 0) { + printk(KERN_INFO "DT3155: Managed to allocate: %d KB\n", + size_kbs); *total_size_kbs = size_kbs; return; } } /* If we got here, the allocation failed */ - printk("DT3155: Allocator failed!\n"); + printk(KERN_INFO "DT3155: Allocator failed!\n"); *buf_addr = 0; *total_size_kbs = 0; return; @@ -324,9 +328,9 @@ u32 dt3155_setup_buffers(u32 *allocatorAddr) /* allocate a large contiguous chunk of RAM */ allocate_buffers(&rambuff_addr, &rambuff_size, bufsize); - printk("DT3155: mem info\n"); - printk(" - rambuf_addr = 0x%x\n", rambuff_addr); - printk(" - length (kb) = %u\n", rambuff_size); + printk(KERN_INFO "DT3155: mem info\n"); + printk(KERN_INFO " - rambuf_addr = 0x%x\n", rambuff_addr); + printk(KERN_INFO " - length (kb) = %u\n", rambuff_size); if (rambuff_addr == 0) { printk(KERN_INFO "DT3155: Error setup_buffers() allocator dma failed\n"); @@ -339,7 +343,8 @@ u32 dt3155_setup_buffers(u32 *allocatorAddr) are so we can give an equal number to each device */ rambuff_acm = rambuff_addr; for (index = 0; index < MAXBUFFERS; index++) { - rambuff_acm = adjust_4MB(rambuff_acm, bufsize);/*avoid spanning 4MB bdry*/ + /*avoid spanning 4MB bdry*/ + rambuff_acm = adjust_4MB(rambuff_acm, bufsize); if (rambuff_acm + bufsize > rambuff_end) break; rambuff_acm += bufsize; @@ -347,7 +352,7 @@ u32 dt3155_setup_buffers(u32 *allocatorAddr) /* Following line is OK, will waste buffers if index * not evenly divisible by ndevices -NJC*/ numbufs = index / ndevices; - printk(" - numbufs = %u\n", numbufs); + printk(KERN_INFO " - numbufs = %u\n", numbufs); if (numbufs < 2) { printk(KERN_INFO "DT3155: Error setup_buffers() couldn't allocate 2 bufs/board\n"); @@ -367,7 +372,7 @@ u32 dt3155_setup_buffers(u32 *allocatorAddr) rambuff_acm = adjust_4MB(rambuff_acm, bufsize); if (rambuff_acm + bufsize > rambuff_end) { /* Should never happen */ - printk("DT3155 PROGRAM ERROR (GCS)\n" + printk(KERN_INFO "DT3155 PROGRAM ERROR (GCS)\n" "Error distributing allocated buffers\n"); return -ENOMEM; } @@ -395,7 +400,7 @@ u32 dt3155_setup_buffers(u32 *allocatorAddr) /* setup the ready queue */ dt3155_fbuffer[m]->ready_head = 0; dt3155_fbuffer[m]->ready_len = 0; - printk("Available buffers for device %d: %d\n", + printk(KERN_INFO "Available buffers for device %d: %d\n", m, dt3155_fbuffer[m]->nbuffers); } From 616f58f6ec5e5777c343499ad65a34e671533e4b Mon Sep 17 00:00:00 2001 From: Mike Gilks Date: Thu, 3 Jun 2010 18:29:23 +0800 Subject: [PATCH 112/523] staging: rtl8192u: fix checkpatch.pl issues to line 514 Fixed most problems pointed out by checkpatch.pl in file r8192U_core.c up to line 500 Signed-off-by: Mike Gilks Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 73 ++++++++++---------------- 1 file changed, 28 insertions(+), 45 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 2bede271a2f0..358013482fd4 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -408,14 +408,12 @@ u16 read_nic_word(struct net_device *dev, int indx) struct usb_device *udev = priv->udev; status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - (indx&0xff)|0xff00, (indx>>8)&0x0f, &data, 2, HZ / 2); + RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, + (indx&0xff)|0xff00, (indx>>8)&0x0f, + &data, 2, HZ / 2); if (status < 0) - { printk("read_nic_word TimeOut! status:%d\n", status); - } - return data; } @@ -429,13 +427,10 @@ u16 read_nic_word_E(struct net_device *dev, int indx) status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xfe00, 0, &data, 2, HZ / 2); + indx|0xfe00, 0, &data, 2, HZ / 2); if (status < 0) - { printk("read_nic_word TimeOut! status:%d\n", status); - } - return data; } @@ -444,31 +439,29 @@ u32 read_nic_dword(struct net_device *dev, int indx) { u32 data; int status; -// int result; + /* int result; */ struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - (indx&0xff)|0xff00, (indx>>8)&0x0f, &data, 4, HZ / 2); -// if(0 != result) { -// printk(KERN_WARNING "read size of data = %d\, date = %d\n", result, data); -// } + RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, + (indx&0xff)|0xff00, (indx>>8)&0x0f, + &data, 4, HZ / 2); + /* if(0 != result) { + * printk(KERN_WARNING "read size of data = %d\, date = %d\n", + * result, data); + * } + */ if (status < 0) - { printk("read_nic_dword TimeOut! status:%d\n", status); - } - - return data; } - -//u8 read_phy_cck(struct net_device *dev, u8 adr); -//u8 read_phy_ofdm(struct net_device *dev, u8 adr); +/* u8 read_phy_cck(struct net_device *dev, u8 adr); */ +/* u8 read_phy_ofdm(struct net_device *dev, u8 adr); */ /* this might still called in what was the PHY rtl8185/rtl8192 common code * plans are to possibilty turn it again in one common code... */ @@ -476,26 +469,22 @@ inline void force_pci_posting(struct net_device *dev) { } - static struct net_device_stats *rtl8192_stats(struct net_device *dev); void rtl8192_commit(struct net_device *dev); -//void rtl8192_restart(struct net_device *dev); +/* void rtl8192_restart(struct net_device *dev); */ void rtl8192_restart(struct work_struct *work); -//void rtl8192_rq_tx_ack(struct work_struct *work); - +/* void rtl8192_rq_tx_ack(struct work_struct *work); */ void watch_dog_timer_callback(unsigned long data); /**************************************************************************** - -----------------------------PROCFS STUFF------------------------- -*****************************************************************************/ + * -----------------------------PROCFS STUFF------------------------- +***************************************************************************** + */ -static struct proc_dir_entry *rtl8192_proc = NULL; +static struct proc_dir_entry *rtl8192_proc; - - -static int proc_get_stats_ap(char *page, char **start, - off_t offset, int count, - int *eof, void *data) +static int proc_get_stats_ap(char *page, char **start, off_t offset, int count, + int *eof, void *data) { struct net_device *dev = data; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); @@ -506,18 +495,12 @@ static int proc_get_stats_ap(char *page, char **start, list_for_each_entry(target, &ieee->network_list, list) { - len += snprintf(page + len, count - len, - "%s ", target->ssid); - - if(target->wpa_ie_len>0 || target->rsn_ie_len>0){ - len += snprintf(page + len, count - len, - "WPA\n"); - } - else{ - len += snprintf(page + len, count - len, - "non_WPA\n"); - } + len += snprintf(page + len, count - len, "%s ", target->ssid); + if (target->wpa_ie_len > 0 || target->rsn_ie_len > 0) + len += snprintf(page + len, count - len, "WPA\n"); + else + len += snprintf(page + len, count - len, "non_WPA\n"); } *eof = 1; From f932e3a361731b403b1c2982197cea7e3d8e0e66 Mon Sep 17 00:00:00 2001 From: Marin Mitov Date: Sun, 6 Jun 2010 14:16:07 +0300 Subject: [PATCH 113/523] Staging: dt3155v4l: correcting a pointer mismatch bug and cleanups The third argument of dma_alloc_coherent() is of type dma_addr_t and is defined as u64 for x86_64, while the member 'device_base' of struct dma_coherent_mem is defined as u32. While at it, clean up the code. Now if dev->dma_mem != NULL all the fields/members are already properly initialized. Signed-off-by: Marin Mitov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dt3155v4l/dt3155v4l.c | 31 ++++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/drivers/staging/dt3155v4l/dt3155v4l.c b/drivers/staging/dt3155v4l/dt3155v4l.c index 6dc3af622848..fd48b38e797c 100644 --- a/drivers/staging/dt3155v4l/dt3155v4l.c +++ b/drivers/staging/dt3155v4l/dt3155v4l.c @@ -1008,6 +1008,8 @@ struct dma_coherent_mem { static int __devinit dt3155_alloc_coherent(struct device *dev, size_t size, int flags) { + struct dma_coherent_mem *mem; + dma_addr_t dev_base; int pages = size >> PAGE_SHIFT; int bitmap_size = BITS_TO_LONGS(pages) * sizeof(long); @@ -1018,25 +1020,28 @@ dt3155_alloc_coherent(struct device *dev, size_t size, int flags) if (dev->dma_mem) goto out; - dev->dma_mem = kzalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL); - if (!dev->dma_mem) + mem = kzalloc(sizeof(*mem), GFP_KERNEL); + if (!mem) goto out; - dev->dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL); - if (!dev->dma_mem->bitmap) + mem->virt_base = dma_alloc_coherent(dev, size, &dev_base, + DT3155_COH_FLAGS); + if (!mem->virt_base) + goto err_alloc_coherent; + mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL); + if (!mem->bitmap) goto err_bitmap; - dev->dma_mem->virt_base = dma_alloc_coherent(dev, size, - &dev->dma_mem->device_base, DT3155_COH_FLAGS); - if (!dev->dma_mem->virt_base) - goto err_coherent; - dev->dma_mem->size = pages; - dev->dma_mem->flags = flags; + /* coherent_dma_mask is already set to 32 bits */ + mem->device_base = dev_base; + mem->size = pages; + mem->flags = flags; + dev->dma_mem = mem; return DMA_MEMORY_MAP; -err_coherent: - kfree(dev->dma_mem->bitmap); err_bitmap: - kfree(dev->dma_mem); + dma_free_coherent(dev, size, mem->virt_base, dev_base); +err_alloc_coherent: + kfree(mem); out: return 0; } From 0f3ff30b9384ffa1b435f263234531582080b100 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 7 Jun 2010 13:25:37 -0500 Subject: [PATCH 114/523] Staging: dt3155: fix different address spaces noise in dt3155_drv.c This fixes the different address spaces noise when copying data to/from user space to kernel space. Signed-off-by: H Hartley Sweeten Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dt3155/dt3155_drv.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/dt3155/dt3155_drv.c b/drivers/staging/dt3155/dt3155_drv.c index 40ef97f3feb5..3024d35ed348 100644 --- a/drivers/staging/dt3155/dt3155_drv.c +++ b/drivers/staging/dt3155/dt3155_drv.c @@ -521,6 +521,7 @@ static int dt3155_ioctl(struct inode *inode, unsigned long arg) { int minor = MINOR(inode->i_rdev); /* What device are we ioctl()'ing? */ + void __user *up = (void __user *)arg; if (minor >= MAXBOARDS || minor < 0) return -ENODEV; @@ -547,7 +548,7 @@ static int dt3155_ioctl(struct inode *inode, { struct dt3155_config tmp; - if (copy_from_user((void *)&tmp, (void *) arg, sizeof(tmp))) + if (copy_from_user(&tmp, up, sizeof(tmp))) return -EFAULT; /* check for valid settings */ if (tmp.rows > DT3155_MAX_ROWS || @@ -565,7 +566,7 @@ static int dt3155_ioctl(struct inode *inode, } case DT3155_GET_CONFIG: { - if (copy_to_user((void *) arg, (void *) &dt3155_status[minor], + if (copy_to_user(up, &dt3155_status[minor], sizeof(struct dt3155_status))) return -EFAULT; return 0; @@ -586,7 +587,7 @@ static int dt3155_ioctl(struct inode *inode, return 0; quick_stop(minor); - if (copy_to_user((void *) arg, (void *) &dt3155_status[minor], + if (copy_to_user(up, &dt3155_status[minor], sizeof(struct dt3155_status))) return -EFAULT; return 0; @@ -610,7 +611,7 @@ static int dt3155_ioctl(struct inode *inode, } dt3155_init_isr(minor); - if (copy_to_user((void *) arg, (void *) &dt3155_status[minor], + if (copy_to_user(up, &dt3155_status[minor], sizeof(struct dt3155_status))) return -EFAULT; return 0; @@ -812,11 +813,11 @@ static ssize_t dt3155_read(struct file *filep, char __user *buf, /* make this an offset */ offset = frame_info->addr - dt3155_status[minor].mem_addr; - put_user(offset, (unsigned int *) buf); + put_user(offset, (unsigned int __user *)buf); buf += sizeof(u32); - put_user(dt3155_status[minor].fbuffer.frame_count, (unsigned int *) buf); + put_user(dt3155_status[minor].fbuffer.frame_count, (unsigned int __user *)buf); buf += sizeof(u32); - put_user(dt3155_status[minor].state, (unsigned int *) buf); + put_user(dt3155_status[minor].state, (unsigned int __user *)buf); buf += sizeof(u32); if (copy_to_user(buf, frame_info, sizeof(*frame_info))) return -EFAULT; From a46f9087e634224b3d0a6560e223425816846dff Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 8 Jun 2010 10:36:57 -0500 Subject: [PATCH 115/523] Staging: dt3155: remove DT_3155_* errno defines Remove the DT_3155_{SUCCESS/FAILURE} errno defines and use the kernel provided ones. Signed-off-by: H Hartley Sweeten Cc: Scott Smedley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/dt3155/dt3155_drv.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/dt3155/dt3155_drv.c b/drivers/staging/dt3155/dt3155_drv.c index 3024d35ed348..dcd384933319 100644 --- a/drivers/staging/dt3155/dt3155_drv.c +++ b/drivers/staging/dt3155/dt3155_drv.c @@ -97,9 +97,6 @@ int dt3155_errno = 0; /* wait queue for interrupts */ wait_queue_head_t dt3155_read_wait_queue[MAXBOARDS]; -#define DT_3155_SUCCESS 0 -#define DT_3155_FAILURE -EIO - /* set to dynamicaly allocate, but it is tunable: */ /* insmod DT_3155 dt3155 dt3155_major=XX */ int dt3155_major = 0; @@ -942,11 +939,11 @@ static int find_PCI (void) } ndevices = pci_index; - return DT_3155_SUCCESS; + return 0; err: pci_dev_put(pci_dev); - return DT_3155_FAILURE; + return -EIO; } u32 allocatorAddr = 0; @@ -1000,7 +997,7 @@ int init_module(void) /* Now let's find the hardware. find_PCI() will set ndevices to the * number of cards found in this machine. */ { - if ((rcode = find_PCI()) != DT_3155_SUCCESS) + if ((rcode = find_PCI()) != 0) { printk("DT3155 error: find_PCI() failed to find dt3155 board(s)\n"); unregister_chrdev(dt3155_major, "dt3155"); From ab17a4ac32ac914cc6d65f25b21bdcaf453c35cf Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Sat, 5 Jun 2010 21:41:00 -0400 Subject: [PATCH 116/523] Staging: pohmelfs: fix compile warning A really trivial patch to solve a warning when compiling staging/pohmelfs Signed-off-by: Javier Martinez Canillas Acked-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman --- drivers/staging/pohmelfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/pohmelfs/inode.c b/drivers/staging/pohmelfs/inode.c index 643b413d9f0f..20b0c68aaa56 100644 --- a/drivers/staging/pohmelfs/inode.c +++ b/drivers/staging/pohmelfs/inode.c @@ -1266,7 +1266,7 @@ static void pohmelfs_put_super(struct super_block *sb) { struct pohmelfs_sb *psb = POHMELFS_SB(sb); struct pohmelfs_inode *pi; - unsigned int count; + unsigned int count = 0; unsigned int in_drop_list = 0; struct inode *inode, *tmp; From b8564d7b3855660e01faa7ba7a4e0303e5a13dfd Mon Sep 17 00:00:00 2001 From: Huang Weiyi Date: Sat, 5 Jun 2010 22:43:09 +0800 Subject: [PATCH 117/523] Staging: XGI: remove duplicated #include Remove duplicated #include('s) in drivers/staging/xgifb/XGI_main_26.c drivers/staging/xgifb/vb_init.c Signed-off-by: Huang Weiyi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 1 - drivers/staging/xgifb/vb_init.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 867012b48a01..68bc1d839ad6 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -28,7 +28,6 @@ #include #include #include -#include #include "osdef.h" diff --git a/drivers/staging/xgifb/vb_init.c b/drivers/staging/xgifb/vb_init.c index b85ca9ba8076..08a02e3aaa5a 100644 --- a/drivers/staging/xgifb/vb_init.c +++ b/drivers/staging/xgifb/vb_init.c @@ -41,7 +41,6 @@ #ifdef LINUX_KERNEL #include -#include #endif From 7ddd5d02799e1bb7e14ccb87bff16261a80efa27 Mon Sep 17 00:00:00 2001 From: Huang Weiyi Date: Sat, 5 Jun 2010 22:42:59 +0800 Subject: [PATCH 118/523] Staging: MSM: remove duplicated #include Remove duplicated #include('s) in drivers/staging/msm/mddihost.h drivers/staging/msm/msm_fb_def.h drivers/staging/msm/staging-devices.c Signed-off-by: Huang Weiyi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/msm/mddihost.h | 2 -- drivers/staging/msm/msm_fb_def.h | 4 ---- drivers/staging/msm/staging-devices.c | 1 - 3 files changed, 7 deletions(-) diff --git a/drivers/staging/msm/mddihost.h b/drivers/staging/msm/mddihost.h index 20b817841c4a..c46f24aea250 100644 --- a/drivers/staging/msm/mddihost.h +++ b/drivers/staging/msm/mddihost.h @@ -44,8 +44,6 @@ #include #include -#include -#include #include "msm_fb_panel.h" diff --git a/drivers/staging/msm/msm_fb_def.h b/drivers/staging/msm/msm_fb_def.h index 6de440937422..c5f9e9e670fb 100644 --- a/drivers/staging/msm/msm_fb_def.h +++ b/drivers/staging/msm/msm_fb_def.h @@ -50,15 +50,11 @@ #include #include -#include #include #include -#include #include -#include "linux/proc_fs.h" #include #include -#include #include #include #include diff --git a/drivers/staging/msm/staging-devices.c b/drivers/staging/msm/staging-devices.c index 0f8ec3e26013..2a5c459b1e5a 100644 --- a/drivers/staging/msm/staging-devices.c +++ b/drivers/staging/msm/staging-devices.c @@ -18,7 +18,6 @@ #include "msm_mdp.h" #include "memory_ll.h" //#include "android_pmem.h" -#include #ifdef CONFIG_MSM_SOC_REV_A #define MSM_SMI_BASE 0xE0000000 From 186305aa1284ac0cae88e18b837c33d5a4a84afc Mon Sep 17 00:00:00 2001 From: Marek Lindner Date: Sun, 6 Jun 2010 21:28:13 +0200 Subject: [PATCH 119/523] Staging: batman-adv: remove redundant struct declaration The hardif_attr and the bat_attr struct share the same attributes, hence it is not necessary to specify 2 different structs. Signed-off-by: Marek Lindner Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/batman-adv/bat_sysfs.c | 48 +++++++------------------- drivers/staging/batman-adv/bat_sysfs.h | 13 +++++++ 2 files changed, 25 insertions(+), 36 deletions(-) diff --git a/drivers/staging/batman-adv/bat_sysfs.c b/drivers/staging/batman-adv/bat_sysfs.c index e2c000b80ca0..065a2123dbc6 100644 --- a/drivers/staging/batman-adv/bat_sysfs.c +++ b/drivers/staging/batman-adv/bat_sysfs.c @@ -28,22 +28,6 @@ #define to_dev(obj) container_of(obj, struct device, kobj) -struct bat_attribute { - struct attribute attr; - ssize_t (*show)(struct kobject *kobj, struct attribute *attr, - char *buf); - ssize_t (*store)(struct kobject *kobj, struct attribute *attr, - char *buf, size_t count); -}; - -struct hardif_attribute { - struct attribute attr; - ssize_t (*show)(struct kobject *kobj, struct attribute *attr, - char *buf); - ssize_t (*store)(struct kobject *kobj, struct attribute *attr, - char *buf, size_t count); -}; - #define BAT_ATTR(_name, _mode, _show, _store) \ struct bat_attribute bat_attr_##_name = { \ .attr = {.name = __stringify(_name), \ @@ -60,14 +44,6 @@ struct bin_attribute bat_attr_##_name = { \ .write = _write, \ }; -#define HARDIF_ATTR(_name, _mode, _show, _store) \ -struct hardif_attribute hardif_attr_##_name = { \ - .attr = {.name = __stringify(_name), \ - .mode = _mode }, \ - .show = _show, \ - .store = _store, \ -}; - static ssize_t show_aggr_ogm(struct kobject *kobj, struct attribute *attr, char *buff) { @@ -433,20 +409,20 @@ static ssize_t show_iface_status(struct kobject *kobj, struct attribute *attr, } } -static HARDIF_ATTR(mesh_iface, S_IRUGO | S_IWUSR, - show_mesh_iface, store_mesh_iface); -static HARDIF_ATTR(iface_status, S_IRUGO, show_iface_status, NULL); +static BAT_ATTR(mesh_iface, S_IRUGO | S_IWUSR, + show_mesh_iface, store_mesh_iface); +static BAT_ATTR(iface_status, S_IRUGO, show_iface_status, NULL); -static struct hardif_attribute *batman_attrs[] = { - &hardif_attr_mesh_iface, - &hardif_attr_iface_status, +static struct bat_attribute *batman_attrs[] = { + &bat_attr_mesh_iface, + &bat_attr_iface_status, NULL, }; int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev) { struct kobject *hardif_kobject = &dev->dev.kobj; - struct hardif_attribute **hardif_attr; + struct bat_attribute **bat_attr; int err; *hardif_obj = kobject_create_and_add(SYSFS_IF_BAT_SUBDIR, @@ -458,12 +434,12 @@ int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev) goto out; } - for (hardif_attr = batman_attrs; *hardif_attr; ++hardif_attr) { - err = sysfs_create_file(*hardif_obj, &((*hardif_attr)->attr)); + for (bat_attr = batman_attrs; *bat_attr; ++bat_attr) { + err = sysfs_create_file(*hardif_obj, &((*bat_attr)->attr)); if (err) { printk(KERN_ERR "batman-adv:Can't add sysfs file: %s/%s/%s\n", dev->name, SYSFS_IF_BAT_SUBDIR, - ((*hardif_attr)->attr).name); + ((*bat_attr)->attr).name); goto rem_attr; } } @@ -471,8 +447,8 @@ int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev) return 0; rem_attr: - for (hardif_attr = batman_attrs; *hardif_attr; ++hardif_attr) - sysfs_remove_file(*hardif_obj, &((*hardif_attr)->attr)); + for (bat_attr = batman_attrs; *bat_attr; ++bat_attr) + sysfs_remove_file(*hardif_obj, &((*bat_attr)->attr)); out: return -ENOMEM; } diff --git a/drivers/staging/batman-adv/bat_sysfs.h b/drivers/staging/batman-adv/bat_sysfs.h index e1893411871e..cb45a912738a 100644 --- a/drivers/staging/batman-adv/bat_sysfs.h +++ b/drivers/staging/batman-adv/bat_sysfs.h @@ -20,10 +20,23 @@ */ +#ifndef BAT_SYSFS_H +#define BAT_SYSFS_H + #define SYSFS_IF_MESH_SUBDIR "mesh" #define SYSFS_IF_BAT_SUBDIR "batman_adv" +struct bat_attribute { + struct attribute attr; + ssize_t (*show)(struct kobject *kobj, struct attribute *attr, + char *buf); + ssize_t (*store)(struct kobject *kobj, struct attribute *attr, + char *buf, size_t count); +}; + int sysfs_add_meshif(struct net_device *dev); void sysfs_del_meshif(struct net_device *dev); int sysfs_add_hardif(struct kobject **hardif_obj, struct net_device *dev); void sysfs_del_hardif(struct kobject **hardif_obj); + +#endif From 96d592ed599434d2d5f339a1d282871bc6377d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20L=C3=BCssing?= Date: Sun, 6 Jun 2010 21:28:17 +0200 Subject: [PATCH 120/523] Staging: batman-adv: Adding netfilter-bridge hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit batman-adv is receiving and sending the packets of its own ether type on a very early/low level. Therefore we need to add explicit hooks to give netfilter/ebtables a chance to filter them. Reported-by: Antonio Quartulli Signed-off-by: Linus Lüssing Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/batman-adv/hard-interface.c | 14 +++++++++++++- drivers/staging/batman-adv/send.c | 9 +++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/staging/batman-adv/hard-interface.c b/drivers/staging/batman-adv/hard-interface.c index 7a582e80de18..6939b8d4ec80 100644 --- a/drivers/staging/batman-adv/hard-interface.c +++ b/drivers/staging/batman-adv/hard-interface.c @@ -30,6 +30,7 @@ #include "hash.h" #include +#include #define MIN(x, y) ((x) < (y) ? (x) : (y)) @@ -432,6 +433,11 @@ out: return NOTIFY_DONE; } +static int batman_skb_recv_finish(struct sk_buff *skb) +{ + return NF_ACCEPT; +} + /* receive a packet with the batman ethertype coming on a hard * interface */ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, @@ -451,6 +457,13 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, if (atomic_read(&module_state) != MODULE_ACTIVE) goto err_free; + /* if netfilter/ebtables wants to block incoming batman + * packets then give them a chance to do so here */ + ret = NF_HOOK(PF_BRIDGE, NF_BR_LOCAL_IN, skb, dev, NULL, + batman_skb_recv_finish); + if (ret != 1) + goto err_out; + /* packet should hold at least type and version */ if (unlikely(skb_headlen(skb) < 2)) goto err_free; @@ -530,7 +543,6 @@ err_out: return NET_RX_DROP; } - struct notifier_block hard_if_notifier = { .notifier_call = hard_if_event, }; diff --git a/drivers/staging/batman-adv/send.c b/drivers/staging/batman-adv/send.c index ac69ed871a76..7365f6dbcb6b 100644 --- a/drivers/staging/batman-adv/send.c +++ b/drivers/staging/batman-adv/send.c @@ -29,6 +29,8 @@ #include "vis.h" #include "aggregation.h" +#include + /* apply hop penalty for a normal link */ static uint8_t hop_penalty(const uint8_t tq) { @@ -90,9 +92,12 @@ int send_skb_packet(struct sk_buff *skb, /* dev_queue_xmit() returns a negative result on error. However on * congestion and traffic shaping, it drops and returns NET_XMIT_DROP - * (which is > 0). This will not be treated as an error. */ + * (which is > 0). This will not be treated as an error. + * Also, if netfilter/ebtables wants to block outgoing batman + * packets then giving them a chance to do so here */ - return dev_queue_xmit(skb); + return NF_HOOK(PF_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, + dev_queue_xmit); send_skb_err: kfree_skb(skb); return NET_XMIT_DROP; From 8af60a8cf06f071a85b6101c86249cce92fa4203 Mon Sep 17 00:00:00 2001 From: Marek Lindner Date: Sun, 6 Jun 2010 21:28:18 +0200 Subject: [PATCH 121/523] Staging: batman-adv: Add information about batman-adv sysfs entries Add documents about new sysfs entries in * /sys/class/net//batman-adv/mesh_iface * /sys/class/net//mesh/vis_mode Signed-off-by: Marek Lindner Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- .../batman-adv/sysfs-class-net-batman-adv | 14 +++++++++++ .../staging/batman-adv/sysfs-class-net-mesh | 25 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 drivers/staging/batman-adv/sysfs-class-net-batman-adv create mode 100644 drivers/staging/batman-adv/sysfs-class-net-mesh diff --git a/drivers/staging/batman-adv/sysfs-class-net-batman-adv b/drivers/staging/batman-adv/sysfs-class-net-batman-adv new file mode 100644 index 000000000000..38dd762def4b --- /dev/null +++ b/drivers/staging/batman-adv/sysfs-class-net-batman-adv @@ -0,0 +1,14 @@ + +What: /sys/class/net//batman-adv/mesh_iface +Date: May 2010 +Contact: Marek Lindner +Description: + The /sys/class/net//batman-adv/mesh_iface file + displays the batman mesh interface this + currently is associated with. + +What: /sys/class/net//batman-adv/iface_status +Date: May 2010 +Contact: Marek Lindner +Description: + Indicates the status of as it is seen by batman. diff --git a/drivers/staging/batman-adv/sysfs-class-net-mesh b/drivers/staging/batman-adv/sysfs-class-net-mesh new file mode 100644 index 000000000000..c75a87b270e9 --- /dev/null +++ b/drivers/staging/batman-adv/sysfs-class-net-mesh @@ -0,0 +1,25 @@ + +What: /sys/class/net//mesh/aggregated_ogms +Date: May 2010 +Contact: Marek Lindner +Description: + Indicates whether the batman protocol messages of the + mesh shall be aggregated or not. + +What: /sys/class/net//mesh/orig_interval +Date: May 2010 +Contact: Marek Lindner +Description: + Defines the interval in milliseconds in which batman + sends its protocol messages. + +What: /sys/class/net//mesh/vis_mode +Date: May 2010 +Contact: Marek Lindner +Description: + Each batman node only maintains information about its + own local neighborhood, therefore generating graphs + showing the topology of the entire mesh is not easily + feasible without having a central instance to collect + the local topologies from all nodes. This file allows + to activate the collecting (server) mode. From e6dc269b402d9fa1562276345931943683e16ebd Mon Sep 17 00:00:00 2001 From: Simon Wunderlich Date: Sun, 6 Jun 2010 21:28:20 +0200 Subject: [PATCH 122/523] Staging: batman-adv: convert vis_interval into define vis_interval does not neccesarily needs to be a variable, as there is no way to change it anyway (and probably no need to). We can therefore remove yet another global variable. Thanks Marek for pointing this out. Signed-off-by: Simon Wunderlich [sven.eckelmann@gmx.de: Rework on top of current version] Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/batman-adv/main.c | 3 --- drivers/staging/batman-adv/main.h | 3 ++- drivers/staging/batman-adv/vis.c | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/batman-adv/main.c b/drivers/staging/batman-adv/main.c index 74c70d589a93..14ab4a0a8805 100644 --- a/drivers/staging/batman-adv/main.c +++ b/drivers/staging/batman-adv/main.c @@ -41,7 +41,6 @@ DEFINE_SPINLOCK(orig_hash_lock); DEFINE_SPINLOCK(forw_bat_list_lock); DEFINE_SPINLOCK(forw_bcast_list_lock); -atomic_t vis_interval; atomic_t bcast_queue_left; atomic_t batman_queue_left; @@ -80,8 +79,6 @@ int init_module(void) atomic_set(&module_state, MODULE_INACTIVE); - atomic_set(&vis_interval, 1000);/* TODO: raise this later, this is only - * for debugging now. */ atomic_set(&bcast_queue_left, BCAST_QUEUE_LEN); atomic_set(&batman_queue_left, BATMAN_QUEUE_LEN); diff --git a/drivers/staging/batman-adv/main.h b/drivers/staging/batman-adv/main.h index 5f8343d360f6..8b9e297b9d2b 100644 --- a/drivers/staging/batman-adv/main.h +++ b/drivers/staging/batman-adv/main.h @@ -57,6 +57,8 @@ #define LOG_BUF_LEN 8192 /* has to be a power of 2 */ #define ETH_STR_LEN 20 +#define VIS_INTERVAL 5000 /* 5 seconds */ + #define MAX_AGGREGATION_BYTES 512 /* should not be bigger than 512 bytes or * change the size of * forw_packet->direct_link_flags */ @@ -134,7 +136,6 @@ extern spinlock_t orig_hash_lock; extern spinlock_t forw_bat_list_lock; extern spinlock_t forw_bcast_list_lock; -extern atomic_t vis_interval; extern atomic_t bcast_queue_left; extern atomic_t batman_queue_left; extern int16_t num_hna; diff --git a/drivers/staging/batman-adv/vis.c b/drivers/staging/batman-adv/vis.c index 1d3d954847fd..d4fe87ecfbb2 100644 --- a/drivers/staging/batman-adv/vis.c +++ b/drivers/staging/batman-adv/vis.c @@ -701,7 +701,7 @@ int vis_init(void) } /* prefill the vis info */ - my_vis_info->first_seen = jiffies - atomic_read(&vis_interval); + my_vis_info->first_seen = jiffies - msecs_to_jiffies(VIS_INTERVAL); INIT_LIST_HEAD(&my_vis_info->recv_list); INIT_LIST_HEAD(&my_vis_info->send_list); kref_init(&my_vis_info->refcount); @@ -764,5 +764,5 @@ void vis_quit(void) static void start_vis_timer(void) { queue_delayed_work(bat_event_workqueue, &vis_timer_wq, - (atomic_read(&vis_interval) * HZ) / 1000); + (VIS_INTERVAL * HZ) / 1000); } From cf2d3fc9786ba005f9bde50a4e72a1d0b70472ff Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sun, 6 Jun 2010 21:03:04 +0200 Subject: [PATCH 123/523] Staging: batman-adv: return -EFAULT on copy_to_user errors copy_to_user() returns the number of bites remaining but we want to return a negative error code here. Signed-off-by: Dan Carpenter Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/batman-adv/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/batman-adv/device.c b/drivers/staging/batman-adv/device.c index 7eb6559e0315..32204b5572d0 100644 --- a/drivers/staging/batman-adv/device.c +++ b/drivers/staging/batman-adv/device.c @@ -196,7 +196,7 @@ ssize_t bat_device_read(struct file *file, char __user *buf, size_t count, kfree(device_packet); if (error) - return error; + return -EFAULT; return sizeof(struct icmp_packet); } From 1bd2c2159a32313ae1f872b6225601aed397524c Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Sun, 6 Jun 2010 21:03:05 +0200 Subject: [PATCH 124/523] Staging: batman-adv: fix function prototype In today linux-next I got a compile warning in staging/batman-adv. This is due a struct bin_attribute read function prototype change and the driver was not updated. This patch solves the issue Signed-off-by: Javier Martinez Canillas Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/batman-adv/bat_sysfs.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/batman-adv/bat_sysfs.c b/drivers/staging/batman-adv/bat_sysfs.c index 065a2123dbc6..ffb8ea2702a2 100644 --- a/drivers/staging/batman-adv/bat_sysfs.c +++ b/drivers/staging/batman-adv/bat_sysfs.c @@ -201,9 +201,9 @@ static struct bat_attribute *mesh_attrs[] = { NULL, }; -static ssize_t transtable_local_read(struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buff, loff_t off, size_t count) +static ssize_t transtable_local_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buff, loff_t off, size_t count) { struct device *dev = to_dev(kobj->parent); struct net_device *net_dev = to_net_dev(dev); @@ -211,9 +211,9 @@ static ssize_t transtable_local_read(struct kobject *kobj, return hna_local_fill_buffer_text(net_dev, buff, count, off); } -static ssize_t transtable_global_read(struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buff, loff_t off, size_t count) +static ssize_t transtable_global_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buff, loff_t off, size_t count) { struct device *dev = to_dev(kobj->parent); struct net_device *net_dev = to_net_dev(dev); @@ -221,9 +221,9 @@ static ssize_t transtable_global_read(struct kobject *kobj, return hna_global_fill_buffer_text(net_dev, buff, count, off); } -static ssize_t originators_read(struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buff, loff_t off, size_t count) +static ssize_t originators_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buff, loff_t off, size_t count) { struct device *dev = to_dev(kobj->parent); struct net_device *net_dev = to_net_dev(dev); @@ -231,9 +231,9 @@ static ssize_t originators_read(struct kobject *kobj, return orig_fill_buffer_text(net_dev, buff, count, off); } -static ssize_t vis_data_read(struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buff, loff_t off, size_t count) +static ssize_t vis_data_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buff, loff_t off, size_t count) { struct device *dev = to_dev(kobj->parent); struct net_device *net_dev = to_net_dev(dev); From c41214328a7635dc35aa81d89ea579c8a2eb2769 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Tue, 22 Jun 2010 01:25:42 +0200 Subject: [PATCH 125/523] Staging: batman-adv: Move device for icmp injection to debugfs batctl uses /dev/batman-adv to send special batman-adv icmp packets to other nodes in the mesh. To get it working with multiple batX devices we must ensure that every mesh device can have their own socket which is used to inject those packets in exactly one mesh. The current implementation still doesn't allow to use complete separated meshes as we rely on structures which are not part of the private data of a batman device. Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/batman-adv/Makefile | 2 +- drivers/staging/batman-adv/bat_debugfs.c | 77 ++++ drivers/staging/batman-adv/bat_debugfs.h | 33 ++ drivers/staging/batman-adv/device.c | 354 ------------------ drivers/staging/batman-adv/icmp_socket.c | 328 ++++++++++++++++ .../batman-adv/{device.h => icmp_socket.h} | 18 +- drivers/staging/batman-adv/main.c | 21 +- drivers/staging/batman-adv/routing.c | 4 +- drivers/staging/batman-adv/types.h | 5 +- 9 files changed, 463 insertions(+), 379 deletions(-) create mode 100644 drivers/staging/batman-adv/bat_debugfs.c create mode 100644 drivers/staging/batman-adv/bat_debugfs.h delete mode 100644 drivers/staging/batman-adv/device.c create mode 100644 drivers/staging/batman-adv/icmp_socket.c rename drivers/staging/batman-adv/{device.h => icmp_socket.h} (54%) diff --git a/drivers/staging/batman-adv/Makefile b/drivers/staging/batman-adv/Makefile index f25068c0fae6..654c4d2b9726 100644 --- a/drivers/staging/batman-adv/Makefile +++ b/drivers/staging/batman-adv/Makefile @@ -19,4 +19,4 @@ # obj-m += batman-adv.o -batman-adv-objs := main.o send.o routing.o soft-interface.o device.o translation-table.o bitarray.o hash.o ring_buffer.o vis.o hard-interface.o aggregation.o originator.o bat_sysfs.o +batman-adv-objs := main.o bat_debugfs.o bat_sysfs.o send.o routing.o soft-interface.o icmp_socket.o translation-table.o bitarray.o hash.o ring_buffer.o vis.o hard-interface.o aggregation.o originator.o diff --git a/drivers/staging/batman-adv/bat_debugfs.c b/drivers/staging/batman-adv/bat_debugfs.c new file mode 100644 index 000000000000..d5b28eb1c69c --- /dev/null +++ b/drivers/staging/batman-adv/bat_debugfs.c @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2010 B.A.T.M.A.N. contributors: + * + * Marek Lindner + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA + * + */ + +#include + +#include "main.h" +#include "bat_debugfs.h" +#include "translation-table.h" +#include "originator.h" +#include "hard-interface.h" +#include "vis.h" +#include "icmp_socket.h" + +static struct dentry *bat_debugfs; + +void debugfs_init(void) +{ + bat_debugfs = debugfs_create_dir(DEBUGFS_BAT_SUBDIR, NULL); +} + +void debugfs_destroy(void) +{ + if (bat_debugfs) { + debugfs_remove_recursive(bat_debugfs); + bat_debugfs = NULL; + } +} + +int debugfs_add_meshif(struct net_device *dev) +{ + struct bat_priv *bat_priv = netdev_priv(dev); + + if (!bat_debugfs) + goto out; + + bat_priv->debug_dir = debugfs_create_dir(dev->name, bat_debugfs); + if (!bat_priv->debug_dir) + goto out; + + bat_socket_setup(bat_priv); + + return 0; +out: +#ifdef CONFIG_DEBUG_FS + return -ENOMEM; +#else + return 0; +#endif /* CONFIG_DEBUG_FS */ +} + +void debugfs_del_meshif(struct net_device *dev) +{ + struct bat_priv *bat_priv = netdev_priv(dev); + + if (bat_debugfs) { + debugfs_remove_recursive(bat_priv->debug_dir); + bat_priv->debug_dir = NULL; + } +} diff --git a/drivers/staging/batman-adv/bat_debugfs.h b/drivers/staging/batman-adv/bat_debugfs.h new file mode 100644 index 000000000000..5cdd3327d98c --- /dev/null +++ b/drivers/staging/batman-adv/bat_debugfs.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2010 B.A.T.M.A.N. contributors: + * + * Marek Lindner + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA + * + */ + + +#ifndef BAT_DEBUGFS_H +#define BAT_DEBUGFS_H + +#define DEBUGFS_BAT_SUBDIR "batman_adv" + +void debugfs_init(void); +void debugfs_destroy(void); +int debugfs_add_meshif(struct net_device *dev); +void debugfs_del_meshif(struct net_device *dev); + +#endif diff --git a/drivers/staging/batman-adv/device.c b/drivers/staging/batman-adv/device.c deleted file mode 100644 index 32204b5572d0..000000000000 --- a/drivers/staging/batman-adv/device.c +++ /dev/null @@ -1,354 +0,0 @@ -/* - * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: - * - * Marek Lindner - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301, USA - * - */ - -#include -#include -#include "main.h" -#include "device.h" -#include "send.h" -#include "types.h" -#include "hash.h" -#include "hard-interface.h" - -static struct class *batman_class; - -static int Major; /* Major number assigned to our device driver */ - -static const struct file_operations fops = { - .open = bat_device_open, - .release = bat_device_release, - .read = bat_device_read, - .write = bat_device_write, - .poll = bat_device_poll, -}; - -static struct device_client *device_client_hash[256]; - -void bat_device_init(void) -{ - memset(device_client_hash, 0, sizeof(device_client_hash)); -} - -int bat_device_setup(void) -{ - int tmp_major; - - if (Major) - return 1; - - /* register our device - kernel assigns a free major number */ - tmp_major = register_chrdev(0, DRIVER_DEVICE, &fops); - if (tmp_major < 0) { - printk(KERN_ERR "batman-adv:" - "Registering the character device failed with %d\n", - tmp_major); - return 0; - } - - batman_class = class_create(THIS_MODULE, "batman-adv"); - - if (IS_ERR(batman_class)) { - printk(KERN_ERR "batman-adv:" - "Could not register class 'batman-adv'\n"); - return 0; - } - - device_create(batman_class, NULL, MKDEV(tmp_major, 0), NULL, - "batman-adv"); - - Major = tmp_major; - return 1; -} - -void bat_device_destroy(void) -{ - if (!Major) - return; - - device_destroy(batman_class, MKDEV(Major, 0)); - class_destroy(batman_class); - - /* Unregister the device */ - unregister_chrdev(Major, DRIVER_DEVICE); - - Major = 0; -} - -int bat_device_open(struct inode *inode, struct file *file) -{ - unsigned int i; - struct device_client *device_client; - - device_client = kmalloc(sizeof(struct device_client), GFP_KERNEL); - - if (!device_client) - return -ENOMEM; - - for (i = 0; i < ARRAY_SIZE(device_client_hash); i++) { - if (!device_client_hash[i]) { - device_client_hash[i] = device_client; - break; - } - } - - if (i == ARRAY_SIZE(device_client_hash)) { - printk(KERN_ERR "batman-adv:" - "Error - can't add another packet client: " - "maximum number of clients reached\n"); - kfree(device_client); - return -EXFULL; - } - - INIT_LIST_HEAD(&device_client->queue_list); - device_client->queue_len = 0; - device_client->index = i; - spin_lock_init(&device_client->lock); - init_waitqueue_head(&device_client->queue_wait); - - file->private_data = device_client; - - inc_module_count(); - return 0; -} - -int bat_device_release(struct inode *inode, struct file *file) -{ - struct device_client *device_client = - (struct device_client *)file->private_data; - struct device_packet *device_packet; - struct list_head *list_pos, *list_pos_tmp; - unsigned long flags; - - spin_lock_irqsave(&device_client->lock, flags); - - /* for all packets in the queue ... */ - list_for_each_safe(list_pos, list_pos_tmp, &device_client->queue_list) { - device_packet = list_entry(list_pos, - struct device_packet, list); - - list_del(list_pos); - kfree(device_packet); - } - - device_client_hash[device_client->index] = NULL; - spin_unlock_irqrestore(&device_client->lock, flags); - - kfree(device_client); - dec_module_count(); - - return 0; -} - -ssize_t bat_device_read(struct file *file, char __user *buf, size_t count, - loff_t *ppos) -{ - struct device_client *device_client = - (struct device_client *)file->private_data; - struct device_packet *device_packet; - int error; - unsigned long flags; - - if ((file->f_flags & O_NONBLOCK) && (device_client->queue_len == 0)) - return -EAGAIN; - - if ((!buf) || (count < sizeof(struct icmp_packet))) - return -EINVAL; - - if (!access_ok(VERIFY_WRITE, buf, count)) - return -EFAULT; - - error = wait_event_interruptible(device_client->queue_wait, - device_client->queue_len); - - if (error) - return error; - - spin_lock_irqsave(&device_client->lock, flags); - - device_packet = list_first_entry(&device_client->queue_list, - struct device_packet, list); - list_del(&device_packet->list); - device_client->queue_len--; - - spin_unlock_irqrestore(&device_client->lock, flags); - - error = __copy_to_user(buf, &device_packet->icmp_packet, - sizeof(struct icmp_packet)); - - kfree(device_packet); - - if (error) - return -EFAULT; - - return sizeof(struct icmp_packet); -} - -ssize_t bat_device_write(struct file *file, const char __user *buff, - size_t len, loff_t *off) -{ - struct device_client *device_client = - (struct device_client *)file->private_data; - struct icmp_packet icmp_packet; - struct orig_node *orig_node; - struct batman_if *batman_if; - uint8_t dstaddr[ETH_ALEN]; - unsigned long flags; - - if (len < sizeof(struct icmp_packet)) { - bat_dbg(DBG_BATMAN, "batman-adv:" - "Error - can't send packet from char device: " - "invalid packet size\n"); - return -EINVAL; - } - - if (!access_ok(VERIFY_READ, buff, sizeof(struct icmp_packet))) - return -EFAULT; - - if (__copy_from_user(&icmp_packet, buff, sizeof(icmp_packet))) - return -EFAULT; - - if (icmp_packet.packet_type != BAT_ICMP) { - bat_dbg(DBG_BATMAN, "batman-adv:" - "Error - can't send packet from char device: " - "got bogus packet type (expected: BAT_ICMP)\n"); - return -EINVAL; - } - - if (icmp_packet.msg_type != ECHO_REQUEST) { - bat_dbg(DBG_BATMAN, "batman-adv:" - "Error - can't send packet from char device: " - "got bogus message type (expected: ECHO_REQUEST)\n"); - return -EINVAL; - } - - icmp_packet.uid = device_client->index; - - if (icmp_packet.version != COMPAT_VERSION) { - icmp_packet.msg_type = PARAMETER_PROBLEM; - icmp_packet.ttl = COMPAT_VERSION; - bat_device_add_packet(device_client, &icmp_packet); - goto out; - } - - if (atomic_read(&module_state) != MODULE_ACTIVE) - goto dst_unreach; - - spin_lock_irqsave(&orig_hash_lock, flags); - orig_node = ((struct orig_node *)hash_find(orig_hash, icmp_packet.dst)); - - if (!orig_node) - goto unlock; - - if (!orig_node->router) - goto unlock; - - batman_if = orig_node->router->if_incoming; - memcpy(dstaddr, orig_node->router->addr, ETH_ALEN); - - spin_unlock_irqrestore(&orig_hash_lock, flags); - - if (!batman_if) - goto dst_unreach; - - if (batman_if->if_status != IF_ACTIVE) - goto dst_unreach; - - memcpy(icmp_packet.orig, - batman_if->net_dev->dev_addr, - ETH_ALEN); - - send_raw_packet((unsigned char *)&icmp_packet, - sizeof(struct icmp_packet), - batman_if, dstaddr); - - goto out; - -unlock: - spin_unlock_irqrestore(&orig_hash_lock, flags); -dst_unreach: - icmp_packet.msg_type = DESTINATION_UNREACHABLE; - bat_device_add_packet(device_client, &icmp_packet); -out: - return len; -} - -unsigned int bat_device_poll(struct file *file, poll_table *wait) -{ - struct device_client *device_client = - (struct device_client *)file->private_data; - - poll_wait(file, &device_client->queue_wait, wait); - - if (device_client->queue_len > 0) - return POLLIN | POLLRDNORM; - - return 0; -} - -void bat_device_add_packet(struct device_client *device_client, - struct icmp_packet *icmp_packet) -{ - struct device_packet *device_packet; - unsigned long flags; - - device_packet = kmalloc(sizeof(struct device_packet), GFP_ATOMIC); - - if (!device_packet) - return; - - INIT_LIST_HEAD(&device_packet->list); - memcpy(&device_packet->icmp_packet, icmp_packet, - sizeof(struct icmp_packet)); - - spin_lock_irqsave(&device_client->lock, flags); - - /* while waiting for the lock the device_client could have been - * deleted */ - if (!device_client_hash[icmp_packet->uid]) { - spin_unlock_irqrestore(&device_client->lock, flags); - kfree(device_packet); - return; - } - - list_add_tail(&device_packet->list, &device_client->queue_list); - device_client->queue_len++; - - if (device_client->queue_len > 100) { - device_packet = list_first_entry(&device_client->queue_list, - struct device_packet, list); - - list_del(&device_packet->list); - kfree(device_packet); - device_client->queue_len--; - } - - spin_unlock_irqrestore(&device_client->lock, flags); - - wake_up(&device_client->queue_wait); -} - -void bat_device_receive_packet(struct icmp_packet *icmp_packet) -{ - struct device_client *hash = device_client_hash[icmp_packet->uid]; - - if (hash) - bat_device_add_packet(hash, icmp_packet); -} diff --git a/drivers/staging/batman-adv/icmp_socket.c b/drivers/staging/batman-adv/icmp_socket.c new file mode 100644 index 000000000000..d4411cbe350c --- /dev/null +++ b/drivers/staging/batman-adv/icmp_socket.c @@ -0,0 +1,328 @@ +/* + * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: + * + * Marek Lindner + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA + * + */ + +#include +#include +#include "main.h" +#include "icmp_socket.h" +#include "send.h" +#include "types.h" +#include "hash.h" +#include "hard-interface.h" + + +static struct socket_client *socket_client_hash[256]; + +static void bat_socket_add_packet(struct socket_client *socket_client, + struct icmp_packet *icmp_packet); + +void bat_socket_init(void) +{ + memset(socket_client_hash, 0, sizeof(socket_client_hash)); +} + +static int bat_socket_open(struct inode *inode, struct file *file) +{ + unsigned int i; + struct socket_client *socket_client; + + socket_client = kmalloc(sizeof(struct socket_client), GFP_KERNEL); + + if (!socket_client) + return -ENOMEM; + + for (i = 0; i < ARRAY_SIZE(socket_client_hash); i++) { + if (!socket_client_hash[i]) { + socket_client_hash[i] = socket_client; + break; + } + } + + if (i == ARRAY_SIZE(socket_client_hash)) { + printk(KERN_ERR "batman-adv:" + "Error - can't add another packet client: " + "maximum number of clients reached\n"); + kfree(socket_client); + return -EXFULL; + } + + INIT_LIST_HEAD(&socket_client->queue_list); + socket_client->queue_len = 0; + socket_client->index = i; + spin_lock_init(&socket_client->lock); + init_waitqueue_head(&socket_client->queue_wait); + + file->private_data = socket_client; + + inc_module_count(); + return 0; +} + +static int bat_socket_release(struct inode *inode, struct file *file) +{ + struct socket_client *socket_client = + (struct socket_client *)file->private_data; + struct socket_packet *socket_packet; + struct list_head *list_pos, *list_pos_tmp; + unsigned long flags; + + spin_lock_irqsave(&socket_client->lock, flags); + + /* for all packets in the queue ... */ + list_for_each_safe(list_pos, list_pos_tmp, &socket_client->queue_list) { + socket_packet = list_entry(list_pos, + struct socket_packet, list); + + list_del(list_pos); + kfree(socket_packet); + } + + socket_client_hash[socket_client->index] = NULL; + spin_unlock_irqrestore(&socket_client->lock, flags); + + kfree(socket_client); + dec_module_count(); + + return 0; +} + +static ssize_t bat_socket_read(struct file *file, char __user *buf, + size_t count, loff_t *ppos) +{ + struct socket_client *socket_client = + (struct socket_client *)file->private_data; + struct socket_packet *socket_packet; + int error; + unsigned long flags; + + if ((file->f_flags & O_NONBLOCK) && (socket_client->queue_len == 0)) + return -EAGAIN; + + if ((!buf) || (count < sizeof(struct icmp_packet))) + return -EINVAL; + + if (!access_ok(VERIFY_WRITE, buf, count)) + return -EFAULT; + + error = wait_event_interruptible(socket_client->queue_wait, + socket_client->queue_len); + + if (error) + return error; + + spin_lock_irqsave(&socket_client->lock, flags); + + socket_packet = list_first_entry(&socket_client->queue_list, + struct socket_packet, list); + list_del(&socket_packet->list); + socket_client->queue_len--; + + spin_unlock_irqrestore(&socket_client->lock, flags); + + error = __copy_to_user(buf, &socket_packet->icmp_packet, + sizeof(struct icmp_packet)); + + kfree(socket_packet); + + if (error) + return -EFAULT; + + return sizeof(struct icmp_packet); +} + +static ssize_t bat_socket_write(struct file *file, const char __user *buff, + size_t len, loff_t *off) +{ + struct socket_client *socket_client = + (struct socket_client *)file->private_data; + struct icmp_packet icmp_packet; + struct orig_node *orig_node; + struct batman_if *batman_if; + uint8_t dstaddr[ETH_ALEN]; + unsigned long flags; + + if (len < sizeof(struct icmp_packet)) { + bat_dbg(DBG_BATMAN, "batman-adv:" + "Error - can't send packet from char device: " + "invalid packet size\n"); + return -EINVAL; + } + + if (!access_ok(VERIFY_READ, buff, sizeof(struct icmp_packet))) + return -EFAULT; + + if (__copy_from_user(&icmp_packet, buff, sizeof(icmp_packet))) + return -EFAULT; + + if (icmp_packet.packet_type != BAT_ICMP) { + bat_dbg(DBG_BATMAN, "batman-adv:" + "Error - can't send packet from char device: " + "got bogus packet type (expected: BAT_ICMP)\n"); + return -EINVAL; + } + + if (icmp_packet.msg_type != ECHO_REQUEST) { + bat_dbg(DBG_BATMAN, "batman-adv:" + "Error - can't send packet from char device: " + "got bogus message type (expected: ECHO_REQUEST)\n"); + return -EINVAL; + } + + icmp_packet.uid = socket_client->index; + + if (icmp_packet.version != COMPAT_VERSION) { + icmp_packet.msg_type = PARAMETER_PROBLEM; + icmp_packet.ttl = COMPAT_VERSION; + bat_socket_add_packet(socket_client, &icmp_packet); + goto out; + } + + if (atomic_read(&module_state) != MODULE_ACTIVE) + goto dst_unreach; + + spin_lock_irqsave(&orig_hash_lock, flags); + orig_node = ((struct orig_node *)hash_find(orig_hash, icmp_packet.dst)); + + if (!orig_node) + goto unlock; + + if (!orig_node->router) + goto unlock; + + batman_if = orig_node->router->if_incoming; + memcpy(dstaddr, orig_node->router->addr, ETH_ALEN); + + spin_unlock_irqrestore(&orig_hash_lock, flags); + + if (!batman_if) + goto dst_unreach; + + if (batman_if->if_status != IF_ACTIVE) + goto dst_unreach; + + memcpy(icmp_packet.orig, + batman_if->net_dev->dev_addr, + ETH_ALEN); + + send_raw_packet((unsigned char *)&icmp_packet, + sizeof(struct icmp_packet), + batman_if, dstaddr); + + goto out; + +unlock: + spin_unlock_irqrestore(&orig_hash_lock, flags); +dst_unreach: + icmp_packet.msg_type = DESTINATION_UNREACHABLE; + bat_socket_add_packet(socket_client, &icmp_packet); +out: + return len; +} + +static unsigned int bat_socket_poll(struct file *file, poll_table *wait) +{ + struct socket_client *socket_client = + (struct socket_client *)file->private_data; + + poll_wait(file, &socket_client->queue_wait, wait); + + if (socket_client->queue_len > 0) + return POLLIN | POLLRDNORM; + + return 0; +} + +static const struct file_operations fops = { + .owner = THIS_MODULE, + .open = bat_socket_open, + .release = bat_socket_release, + .read = bat_socket_read, + .write = bat_socket_write, + .poll = bat_socket_poll, +}; + +int bat_socket_setup(struct bat_priv *bat_priv) +{ + struct dentry *d; + + if (!bat_priv->debug_dir) + goto err; + + d = debugfs_create_file(ICMP_SOCKET, S_IFREG | S_IWUSR | S_IRUSR, + bat_priv->debug_dir, NULL, &fops); + if (d) + goto err; + + return 0; + +err: + return 1; +} + +static void bat_socket_add_packet(struct socket_client *socket_client, + struct icmp_packet *icmp_packet) +{ + struct socket_packet *socket_packet; + unsigned long flags; + + socket_packet = kmalloc(sizeof(struct socket_packet), GFP_ATOMIC); + + if (!socket_packet) + return; + + INIT_LIST_HEAD(&socket_packet->list); + memcpy(&socket_packet->icmp_packet, icmp_packet, + sizeof(struct icmp_packet)); + + spin_lock_irqsave(&socket_client->lock, flags); + + /* while waiting for the lock the socket_client could have been + * deleted */ + if (!socket_client_hash[icmp_packet->uid]) { + spin_unlock_irqrestore(&socket_client->lock, flags); + kfree(socket_packet); + return; + } + + list_add_tail(&socket_packet->list, &socket_client->queue_list); + socket_client->queue_len++; + + if (socket_client->queue_len > 100) { + socket_packet = list_first_entry(&socket_client->queue_list, + struct socket_packet, list); + + list_del(&socket_packet->list); + kfree(socket_packet); + socket_client->queue_len--; + } + + spin_unlock_irqrestore(&socket_client->lock, flags); + + wake_up(&socket_client->queue_wait); +} + +void bat_socket_receive_packet(struct icmp_packet *icmp_packet) +{ + struct socket_client *hash = socket_client_hash[icmp_packet->uid]; + + if (hash) + bat_socket_add_packet(hash, icmp_packet); +} diff --git a/drivers/staging/batman-adv/device.h b/drivers/staging/batman-adv/icmp_socket.h similarity index 54% rename from drivers/staging/batman-adv/device.h rename to drivers/staging/batman-adv/icmp_socket.h index eb14b371cea9..5ad73daa08ca 100644 --- a/drivers/staging/batman-adv/device.h +++ b/drivers/staging/batman-adv/icmp_socket.h @@ -21,16 +21,8 @@ #include "types.h" -void bat_device_init(void); -int bat_device_setup(void); -void bat_device_destroy(void); -int bat_device_open(struct inode *inode, struct file *file); -int bat_device_release(struct inode *inode, struct file *file); -ssize_t bat_device_read(struct file *file, char __user *buf, size_t count, - loff_t *ppos); -ssize_t bat_device_write(struct file *file, const char __user *buff, - size_t len, loff_t *off); -unsigned int bat_device_poll(struct file *file, poll_table *wait); -void bat_device_add_packet(struct device_client *device_client, - struct icmp_packet *icmp_packet); -void bat_device_receive_packet(struct icmp_packet *icmp_packet); +#define ICMP_SOCKET "socket" + +void bat_socket_init(void); +int bat_socket_setup(struct bat_priv *bat_priv); +void bat_socket_receive_packet(struct icmp_packet *icmp_packet); diff --git a/drivers/staging/batman-adv/main.c b/drivers/staging/batman-adv/main.c index 14ab4a0a8805..ed18b08e704b 100644 --- a/drivers/staging/batman-adv/main.c +++ b/drivers/staging/batman-adv/main.c @@ -21,11 +21,12 @@ #include "main.h" #include "bat_sysfs.h" +#include "bat_debugfs.h" #include "routing.h" #include "send.h" #include "originator.h" #include "soft-interface.h" -#include "device.h" +#include "icmp_socket.h" #include "translation-table.h" #include "hard-interface.h" #include "types.h" @@ -89,7 +90,8 @@ int init_module(void) if (!bat_event_workqueue) return -ENOMEM; - bat_device_init(); + bat_socket_init(); + debugfs_init(); /* initialize layer 2 interface */ soft_device = alloc_netdev(sizeof(struct bat_priv) , "bat%d", @@ -114,6 +116,11 @@ int init_module(void) if (retval < 0) goto unreg_soft_device; + retval = debugfs_add_meshif(soft_device); + + if (retval < 0) + goto unreg_sysfs; + register_netdevice_notifier(&hard_if_notifier); dev_add_pack(&batman_adv_packet_type); @@ -123,6 +130,8 @@ int init_module(void) return 0; +unreg_sysfs: + sysfs_del_meshif(soft_device); unreg_soft_device: unregister_netdev(soft_device); soft_device = NULL; @@ -143,6 +152,7 @@ void cleanup_module(void) hardif_remove_interfaces(); if (soft_device) { + debugfs_del_meshif(soft_device); sysfs_del_meshif(soft_device); unregister_netdev(soft_device); soft_device = NULL; @@ -154,7 +164,7 @@ void cleanup_module(void) bat_event_workqueue = NULL; } -/* activates the module, creates bat device, starts timer ... */ +/* activates the module, starts timer ... */ void activate_module(void) { if (originator_init() < 1) @@ -168,9 +178,6 @@ void activate_module(void) hna_local_add(soft_device->dev_addr); - if (bat_device_setup() < 1) - goto end; - if (vis_init() < 1) goto err; @@ -205,7 +212,7 @@ void deactivate_module(void) hna_global_free(); synchronize_net(); - bat_device_destroy(); + debugfs_destroy(); synchronize_rcu(); atomic_set(&module_state, MODULE_INACTIVE); diff --git a/drivers/staging/batman-adv/routing.c b/drivers/staging/batman-adv/routing.c index 066dc8b38817..d4bdca9c1260 100644 --- a/drivers/staging/batman-adv/routing.c +++ b/drivers/staging/batman-adv/routing.c @@ -25,7 +25,7 @@ #include "hash.h" #include "soft-interface.h" #include "hard-interface.h" -#include "device.h" +#include "icmp_socket.h" #include "translation-table.h" #include "originator.h" #include "types.h" @@ -668,7 +668,7 @@ static int recv_my_icmp_packet(struct sk_buff *skb) /* add data to device queue */ if (icmp_packet->msg_type != ECHO_REQUEST) { - bat_device_receive_packet(icmp_packet); + bat_socket_receive_packet(icmp_packet); return NET_RX_DROP; } diff --git a/drivers/staging/batman-adv/types.h b/drivers/staging/batman-adv/types.h index 86007c7eb443..751cd6322813 100644 --- a/drivers/staging/batman-adv/types.h +++ b/drivers/staging/batman-adv/types.h @@ -106,9 +106,10 @@ struct bat_priv { char num_ifaces; struct batman_if *primary_if; struct kobject *mesh_obj; + struct dentry *debug_dir; }; -struct device_client { +struct socket_client { struct list_head queue_list; unsigned int queue_len; unsigned char index; @@ -116,7 +117,7 @@ struct device_client { wait_queue_head_t queue_wait; }; -struct device_packet { +struct socket_packet { struct list_head list; struct icmp_packet icmp_packet; }; From 4caecbc03931522bd4af165edb1cfcfc4d3d7887 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Tue, 22 Jun 2010 01:25:43 +0200 Subject: [PATCH 126/523] Staging: batman-adv: Move tables from sysfs to debugfs Files which represent more than a single attribute aren't allowed in sysfs. As we have some files which aren't essential and are lists or tables aggregated from data from different places inside batman-adv, we must place them in a filesystem without such a restriction. Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/batman-adv/bat_debugfs.c | 71 ++++++++ drivers/staging/batman-adv/bat_sysfs.c | 79 --------- drivers/staging/batman-adv/main.h | 3 +- drivers/staging/batman-adv/originator.c | 64 +++----- drivers/staging/batman-adv/originator.h | 3 +- .../staging/batman-adv/translation-table.c | 153 +++++++++--------- .../staging/batman-adv/translation-table.h | 6 +- drivers/staging/batman-adv/vis.c | 111 +++++++++---- drivers/staging/batman-adv/vis.h | 3 +- 9 files changed, 253 insertions(+), 240 deletions(-) diff --git a/drivers/staging/batman-adv/bat_debugfs.c b/drivers/staging/batman-adv/bat_debugfs.c index d5b28eb1c69c..a8fe1c91fa4c 100644 --- a/drivers/staging/batman-adv/bat_debugfs.c +++ b/drivers/staging/batman-adv/bat_debugfs.c @@ -31,6 +31,60 @@ static struct dentry *bat_debugfs; +static int originators_open(struct inode *inode, struct file *file) +{ + struct net_device *net_dev = (struct net_device *)inode->i_private; + return single_open(file, orig_seq_print_text, net_dev); +} + +static int transtable_global_open(struct inode *inode, struct file *file) +{ + struct net_device *net_dev = (struct net_device *)inode->i_private; + return single_open(file, hna_global_seq_print_text, net_dev); +} + +static int transtable_local_open(struct inode *inode, struct file *file) +{ + struct net_device *net_dev = (struct net_device *)inode->i_private; + return single_open(file, hna_local_seq_print_text, net_dev); +} + +static int vis_data_open(struct inode *inode, struct file *file) +{ + struct net_device *net_dev = (struct net_device *)inode->i_private; + return single_open(file, vis_seq_print_text, net_dev); +} + +struct bat_debuginfo { + struct attribute attr; + const struct file_operations fops; +}; + +#define BAT_DEBUGINFO(_name, _mode, _open) \ +struct bat_debuginfo bat_debuginfo_##_name = { \ + .attr = { .name = __stringify(_name), \ + .mode = _mode, }, \ + .fops = { .owner = THIS_MODULE, \ + .open = _open, \ + .read = seq_read, \ + .llseek = seq_lseek, \ + .release = single_release, \ + } \ +}; + +static BAT_DEBUGINFO(originators, S_IRUGO, originators_open); +static BAT_DEBUGINFO(transtable_global, S_IRUGO, transtable_global_open); +static BAT_DEBUGINFO(transtable_local, S_IRUGO, transtable_local_open); +static BAT_DEBUGINFO(vis_data, S_IRUGO, vis_data_open); + +static struct bat_debuginfo *mesh_debuginfos[] = { + &bat_debuginfo_originators, + &bat_debuginfo_transtable_global, + &bat_debuginfo_transtable_local, + &bat_debuginfo_vis_data, + NULL, +}; + void debugfs_init(void) { bat_debugfs = debugfs_create_dir(DEBUGFS_BAT_SUBDIR, NULL); @@ -47,6 +101,8 @@ void debugfs_destroy(void) int debugfs_add_meshif(struct net_device *dev) { struct bat_priv *bat_priv = netdev_priv(dev); + struct bat_debuginfo **bat_debug; + struct dentry *file; if (!bat_debugfs) goto out; @@ -57,7 +113,22 @@ int debugfs_add_meshif(struct net_device *dev) bat_socket_setup(bat_priv); + for (bat_debug = mesh_debuginfos; *bat_debug; ++bat_debug) { + file = debugfs_create_file(((*bat_debug)->attr).name, + S_IFREG | ((*bat_debug)->attr).mode, + bat_priv->debug_dir, + dev, &(*bat_debug)->fops); + if (!file) { + printk(KERN_ERR "batman-adv:Can't add debugfs file: " + "%s/%s\n", dev->name, ((*bat_debug)->attr).name); + goto rem_attr; + } + } + return 0; +rem_attr: + debugfs_remove_recursive(bat_priv->debug_dir); + bat_priv->debug_dir = NULL; out: #ifdef CONFIG_DEBUG_FS return -ENOMEM; diff --git a/drivers/staging/batman-adv/bat_sysfs.c b/drivers/staging/batman-adv/bat_sysfs.c index ffb8ea2702a2..651bdb4b6699 100644 --- a/drivers/staging/batman-adv/bat_sysfs.c +++ b/drivers/staging/batman-adv/bat_sysfs.c @@ -36,14 +36,6 @@ struct bat_attribute bat_attr_##_name = { \ .store = _store, \ }; -#define BAT_BIN_ATTR(_name, _mode, _read, _write) \ -struct bin_attribute bat_attr_##_name = { \ - .attr = { .name = __stringify(_name), \ - .mode = _mode, }, \ - .read = _read, \ - .write = _write, \ -}; - static ssize_t show_aggr_ogm(struct kobject *kobj, struct attribute *attr, char *buff) { @@ -201,65 +193,11 @@ static struct bat_attribute *mesh_attrs[] = { NULL, }; -static ssize_t transtable_local_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buff, loff_t off, size_t count) -{ - struct device *dev = to_dev(kobj->parent); - struct net_device *net_dev = to_net_dev(dev); - - return hna_local_fill_buffer_text(net_dev, buff, count, off); -} - -static ssize_t transtable_global_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buff, loff_t off, size_t count) -{ - struct device *dev = to_dev(kobj->parent); - struct net_device *net_dev = to_net_dev(dev); - - return hna_global_fill_buffer_text(net_dev, buff, count, off); -} - -static ssize_t originators_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buff, loff_t off, size_t count) -{ - struct device *dev = to_dev(kobj->parent); - struct net_device *net_dev = to_net_dev(dev); - - return orig_fill_buffer_text(net_dev, buff, count, off); -} - -static ssize_t vis_data_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buff, loff_t off, size_t count) -{ - struct device *dev = to_dev(kobj->parent); - struct net_device *net_dev = to_net_dev(dev); - - return vis_fill_buffer_text(net_dev, buff, count, off); -} - -static BAT_BIN_ATTR(transtable_local, S_IRUGO, transtable_local_read, NULL); -static BAT_BIN_ATTR(transtable_global, S_IRUGO, transtable_global_read, NULL); -static BAT_BIN_ATTR(originators, S_IRUGO, originators_read, NULL); -static BAT_BIN_ATTR(vis_data, S_IRUGO, vis_data_read, NULL); - -static struct bin_attribute *mesh_bin_attrs[] = { - &bat_attr_transtable_local, - &bat_attr_transtable_global, - &bat_attr_originators, - &bat_attr_vis_data, - NULL, -}; - int sysfs_add_meshif(struct net_device *dev) { struct kobject *batif_kobject = &dev->dev.kobj; struct bat_priv *bat_priv = netdev_priv(dev); struct bat_attribute **bat_attr; - struct bin_attribute **bin_attr; int err; /* FIXME: should be done in the general mesh setup @@ -289,21 +227,8 @@ int sysfs_add_meshif(struct net_device *dev) } } - for (bin_attr = mesh_bin_attrs; *bin_attr; ++bin_attr) { - err = sysfs_create_bin_file(bat_priv->mesh_obj, (*bin_attr)); - if (err) { - printk(KERN_ERR "batman-adv:Can't add sysfs file: %s/%s/%s\n", - dev->name, SYSFS_IF_MESH_SUBDIR, - ((*bin_attr)->attr).name); - goto rem_bin_attr; - } - } - return 0; -rem_bin_attr: - for (bin_attr = mesh_bin_attrs; *bin_attr; ++bin_attr) - sysfs_remove_bin_file(bat_priv->mesh_obj, (*bin_attr)); rem_attr: for (bat_attr = mesh_attrs; *bat_attr; ++bat_attr) sysfs_remove_file(bat_priv->mesh_obj, &((*bat_attr)->attr)); @@ -318,10 +243,6 @@ void sysfs_del_meshif(struct net_device *dev) { struct bat_priv *bat_priv = netdev_priv(dev); struct bat_attribute **bat_attr; - struct bin_attribute **bin_attr; - - for (bin_attr = mesh_bin_attrs; *bin_attr; ++bin_attr) - sysfs_remove_bin_file(bat_priv->mesh_obj, (*bin_attr)); for (bat_attr = mesh_attrs; *bat_attr; ++bat_attr) sysfs_remove_file(bat_priv->mesh_obj, &((*bat_attr)->attr)); diff --git a/drivers/staging/batman-adv/main.h b/drivers/staging/batman-adv/main.h index 8b9e297b9d2b..7cb0b185de19 100644 --- a/drivers/staging/batman-adv/main.h +++ b/drivers/staging/batman-adv/main.h @@ -72,7 +72,7 @@ #define MODULE_ACTIVE 1 #define MODULE_DEACTIVATING 2 -#define BCAST_QUEUE_LEN 256 +#define BCAST_QUEUE_LEN 256 #define BATMAN_QUEUE_LEN 256 /* @@ -119,6 +119,7 @@ extern int bat_debug_type(int type); #include #include /* struct sock */ #include +#include #include "types.h" #ifndef REVISION_VERSION diff --git a/drivers/staging/batman-adv/originator.c b/drivers/staging/batman-adv/originator.c index 568aef8371be..c15970704c8b 100644 --- a/drivers/staging/batman-adv/originator.c +++ b/drivers/staging/batman-adv/originator.c @@ -271,39 +271,31 @@ void purge_orig(struct work_struct *work) start_purge_timer(); } -ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff, - size_t count, loff_t off) +int orig_seq_print_text(struct seq_file *seq, void *offset) { HASHIT(hashit); + struct net_device *net_dev = (struct net_device *)seq->private; struct bat_priv *bat_priv = netdev_priv(net_dev); struct orig_node *orig_node; struct neigh_node *neigh_node; - size_t hdr_len, tmp_len; - int batman_count = 0, bytes_written = 0; + int batman_count = 0; unsigned long flags; char orig_str[ETH_STR_LEN], router_str[ETH_STR_LEN]; - if (!bat_priv->primary_if) { - if (off == 0) - return sprintf(buff, - "BATMAN mesh %s disabled - " + if ((!bat_priv->primary_if) || + (bat_priv->primary_if->if_status != IF_ACTIVE)) { + if (!bat_priv->primary_if) + return seq_printf(seq, "BATMAN mesh %s disabled - " "please specify interfaces to enable it\n", net_dev->name); - return 0; + return seq_printf(seq, "BATMAN mesh %s " + "disabled - primary interface not active\n", + net_dev->name); } - if (bat_priv->primary_if->if_status != IF_ACTIVE && off == 0) - return sprintf(buff, - "BATMAN mesh %s " - "disabled - primary interface not active\n", - net_dev->name); - else if (bat_priv->primary_if->if_status != IF_ACTIVE) - return 0; - rcu_read_lock(); - hdr_len = sprintf(buff, - " %-14s (%s/%i) %17s [%10s]: %20s " + seq_printf(seq, " %-14s (%s/%i) %17s [%10s]: %20s " "... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n", "Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF", "Potential nexthops", SOURCE_VERSION, REVISION_VERSION_STR, @@ -311,9 +303,6 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff, net_dev->name); rcu_read_unlock(); - if (off < hdr_len) - bytes_written = hdr_len; - spin_lock_irqsave(&orig_hash_lock, flags); while (hash_iterate(orig_hash, &hashit)) { @@ -326,44 +315,29 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff, if (orig_node->router->tq_avg == 0) continue; - /* estimated line length */ - if (count < bytes_written + 200) - break; - addr_to_string(orig_str, orig_node->orig); addr_to_string(router_str, orig_node->router->addr); - tmp_len = sprintf(buff + bytes_written, - "%-17s (%3i) %17s [%10s]:", - orig_str, orig_node->router->tq_avg, - router_str, - orig_node->router->if_incoming->dev); + seq_printf(seq, "%-17s (%3i) %17s [%10s]:", + orig_str, orig_node->router->tq_avg, router_str, + orig_node->router->if_incoming->dev); list_for_each_entry(neigh_node, &orig_node->neigh_list, list) { addr_to_string(orig_str, neigh_node->addr); - tmp_len += sprintf(buff + bytes_written + tmp_len, - " %17s (%3i)", orig_str, + seq_printf(seq, " %17s (%3i)", orig_str, neigh_node->tq_avg); } - tmp_len += sprintf(buff + bytes_written + tmp_len, "\n"); - + seq_printf(seq, "\n"); batman_count++; - hdr_len += tmp_len; - - if (off >= hdr_len) - continue; - - bytes_written += tmp_len; } spin_unlock_irqrestore(&orig_hash_lock, flags); - if ((batman_count == 0) && (off == 0)) - bytes_written += sprintf(buff + bytes_written, - "No batman nodes in range ...\n"); + if ((batman_count == 0)) + seq_printf(seq, "No batman nodes in range ...\n"); - return bytes_written; + return 0; } static int orig_node_add_if(struct orig_node *orig_node, int max_if_num) diff --git a/drivers/staging/batman-adv/originator.h b/drivers/staging/batman-adv/originator.h index afbc7c0e8aa3..e91e8a1f4adb 100644 --- a/drivers/staging/batman-adv/originator.h +++ b/drivers/staging/batman-adv/originator.h @@ -28,7 +28,6 @@ struct orig_node *get_orig_node(uint8_t *addr); struct neigh_node * create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, uint8_t *neigh, struct batman_if *if_incoming); -ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff, - size_t count, loff_t off); +int orig_seq_print_text(struct seq_file *seq, void *offset); int orig_hash_add_if(struct batman_if *batman_if, int max_if_num); int orig_hash_del_if(struct batman_if *batman_if, int max_if_num); diff --git a/drivers/staging/batman-adv/translation-table.c b/drivers/staging/batman-adv/translation-table.c index e01ff2151f76..604122c59660 100644 --- a/drivers/staging/batman-adv/translation-table.c +++ b/drivers/staging/batman-adv/translation-table.c @@ -160,59 +160,59 @@ int hna_local_fill_buffer(unsigned char *buff, int buff_len) return i; } -int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff, - size_t count, loff_t off) +int hna_local_seq_print_text(struct seq_file *seq, void *offset) { + struct net_device *net_dev = (struct net_device *)seq->private; struct bat_priv *bat_priv = netdev_priv(net_dev); struct hna_local_entry *hna_local_entry; HASHIT(hashit); - int bytes_written = 0; + HASHIT(hashit_count); unsigned long flags; - size_t hdr_len; + size_t buf_size, pos; + char *buff; if (!bat_priv->primary_if) { - if (off == 0) - return sprintf(buff, - "BATMAN mesh %s disabled - " - "please specify interfaces to enable it\n", - net_dev->name); - - return 0; + return seq_printf(seq, "BATMAN mesh %s disabled - " + "please specify interfaces to enable it\n", + net_dev->name); } - hdr_len = sprintf(buff, - "Locally retrieved addresses (from %s) " - "announced via HNA:\n", - net_dev->name); - - if (off < hdr_len) - bytes_written = hdr_len; + seq_printf(seq, "Locally retrieved addresses (from %s) " + "announced via HNA:\n", + net_dev->name); spin_lock_irqsave(&hna_local_hash_lock, flags); + buf_size = 1; + /* Estimate length for: " * xx:xx:xx:xx:xx:xx\n" */ + while (hash_iterate(hna_local_hash, &hashit_count)) + buf_size += 21; + + buff = kmalloc(buf_size, GFP_ATOMIC); + if (!buff) { + spin_unlock_irqrestore(&hna_local_hash_lock, flags); + return -ENOMEM; + } + buff[0] = '\0'; + pos = 0; + while (hash_iterate(hna_local_hash, &hashit)) { - hdr_len += 21; - - if (count < bytes_written + 22) - break; - - if (off >= hdr_len) - continue; - hna_local_entry = hashit.bucket->data; - bytes_written += snprintf(buff + bytes_written, 22, - " * " MAC_FMT "\n", - hna_local_entry->addr[0], - hna_local_entry->addr[1], - hna_local_entry->addr[2], - hna_local_entry->addr[3], - hna_local_entry->addr[4], - hna_local_entry->addr[5]); + pos += snprintf(buff + pos, 22, " * " MAC_FMT "\n", + hna_local_entry->addr[0], + hna_local_entry->addr[1], + hna_local_entry->addr[2], + hna_local_entry->addr[3], + hna_local_entry->addr[4], + hna_local_entry->addr[5]); } spin_unlock_irqrestore(&hna_local_hash_lock, flags); - return bytes_written; + + seq_printf(seq, "%s", buff); + kfree(buff); + return 0; } static void _hna_local_del(void *data) @@ -378,65 +378,66 @@ void hna_global_add_orig(struct orig_node *orig_node, spin_unlock_irqrestore(&hna_global_hash_lock, flags); } -int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff, - size_t count, loff_t off) +int hna_global_seq_print_text(struct seq_file *seq, void *offset) { + struct net_device *net_dev = (struct net_device *)seq->private; struct bat_priv *bat_priv = netdev_priv(net_dev); struct hna_global_entry *hna_global_entry; HASHIT(hashit); - int bytes_written = 0; + HASHIT(hashit_count); unsigned long flags; - size_t hdr_len; + size_t buf_size, pos; + char *buff; if (!bat_priv->primary_if) { - if (off == 0) - return sprintf(buff, - "BATMAN mesh %s disabled - " - "please specify interfaces to enable it\n", - net_dev->name); - - return 0; + return seq_printf(seq, "BATMAN mesh %s disabled - " + "please specify interfaces to enable it\n", + net_dev->name); } - hdr_len = sprintf(buff, - "Globally announced HNAs received via the mesh %s " - "(translation table):\n", - net_dev->name); - - if (off < hdr_len) - bytes_written = hdr_len; + seq_printf(seq, "Globally announced HNAs received via the mesh %s " + "(translation table):\n", + net_dev->name); spin_lock_irqsave(&hna_global_hash_lock, flags); + buf_size = 1; + /* Estimate length for: " * xx:xx:xx:xx:xx:xx via xx:xx:xx:xx:xx:xx\n"*/ + while (hash_iterate(hna_global_hash, &hashit_count)) + buf_size += 43; + + buff = kmalloc(buf_size, GFP_ATOMIC); + if (!buff) { + spin_unlock_irqrestore(&hna_global_hash_lock, flags); + return -ENOMEM; + } + buff[0] = '\0'; + pos = 0; + while (hash_iterate(hna_global_hash, &hashit)) { - hdr_len += 43; - - if (count < bytes_written + 44) - break; - - if (off >= hdr_len) - continue; - hna_global_entry = hashit.bucket->data; - bytes_written += snprintf(buff + bytes_written, 44, - " * " MAC_FMT " via " MAC_FMT "\n", - hna_global_entry->addr[0], - hna_global_entry->addr[1], - hna_global_entry->addr[2], - hna_global_entry->addr[3], - hna_global_entry->addr[4], - hna_global_entry->addr[5], - hna_global_entry->orig_node->orig[0], - hna_global_entry->orig_node->orig[1], - hna_global_entry->orig_node->orig[2], - hna_global_entry->orig_node->orig[3], - hna_global_entry->orig_node->orig[4], - hna_global_entry->orig_node->orig[5]); + pos += snprintf(buff + pos, 44, + " * " MAC_FMT " via " MAC_FMT "\n", + hna_global_entry->addr[0], + hna_global_entry->addr[1], + hna_global_entry->addr[2], + hna_global_entry->addr[3], + hna_global_entry->addr[4], + hna_global_entry->addr[5], + hna_global_entry->orig_node->orig[0], + hna_global_entry->orig_node->orig[1], + hna_global_entry->orig_node->orig[2], + hna_global_entry->orig_node->orig[3], + hna_global_entry->orig_node->orig[4], + hna_global_entry->orig_node->orig[5]); } spin_unlock_irqrestore(&hna_global_hash_lock, flags); - return bytes_written; + + seq_printf(seq, "%s", buff); + kfree(buff); + return 0; } void _hna_global_del_orig(struct hna_global_entry *hna_global_entry, diff --git a/drivers/staging/batman-adv/translation-table.h b/drivers/staging/batman-adv/translation-table.h index 8f412fca87f1..8b3429e96af2 100644 --- a/drivers/staging/batman-adv/translation-table.h +++ b/drivers/staging/batman-adv/translation-table.h @@ -25,15 +25,13 @@ int hna_local_init(void); void hna_local_add(uint8_t *addr); void hna_local_remove(uint8_t *addr, char *message); int hna_local_fill_buffer(unsigned char *buff, int buff_len); -int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff, - size_t count, loff_t off); +int hna_local_seq_print_text(struct seq_file *seq, void *offset); void hna_local_purge(struct work_struct *work); void hna_local_free(void); int hna_global_init(void); void hna_global_add_orig(struct orig_node *orig_node, unsigned char *hna_buff, int hna_buff_len); -int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff, - size_t count, loff_t off); +int hna_global_seq_print_text(struct seq_file *seq, void *offset); void _hna_global_del_orig(struct hna_global_entry *hna_global_entry, char *orig_str); void hna_global_del_orig(struct orig_node *orig_node, char *message); diff --git a/drivers/staging/batman-adv/vis.c b/drivers/staging/batman-adv/vis.c index d4fe87ecfbb2..c73774b16b88 100644 --- a/drivers/staging/batman-adv/vis.c +++ b/drivers/staging/batman-adv/vis.c @@ -115,7 +115,7 @@ static void vis_data_insert_interface(const uint8_t *interface, } /* its a new address, add it to the list */ - entry = kmalloc(sizeof(*entry), GFP_KERNEL); + entry = kmalloc(sizeof(*entry), GFP_ATOMIC); if (!entry) return; memcpy(entry->addr, interface, ETH_ALEN); @@ -142,12 +142,29 @@ static ssize_t vis_data_read_prim_sec(char *buff, struct hlist_head *if_list) return len; } +static size_t vis_data_count_prim_sec(struct hlist_head *if_list) +{ + struct if_list_entry *entry; + struct hlist_node *pos; + size_t count = 0; + + hlist_for_each_entry(entry, pos, if_list, list) { + if (entry->primary) + count += 9; + else + count += 23; + } + + return count; +} + /* read an entry */ static ssize_t vis_data_read_entry(char *buff, struct vis_info_entry *entry, uint8_t *src, bool primary) { - char to[40]; + char to[18]; + /* maximal length: max(4+17+2, 3+17+1+3+2) == 26 */ addr_to_string(to, entry->dest); if (primary && entry->quality == 0) return sprintf(buff, "HNA %s, ", to); @@ -157,38 +174,74 @@ static ssize_t vis_data_read_entry(char *buff, struct vis_info_entry *entry, return 0; } -ssize_t vis_fill_buffer_text(struct net_device *net_dev, char *buff, - size_t count, loff_t off) +int vis_seq_print_text(struct seq_file *seq, void *offset) { HASHIT(hashit); + HASHIT(hashit_count); struct vis_info *info; struct vis_info_entry *entries; + struct net_device *net_dev = (struct net_device *)seq->private; struct bat_priv *bat_priv = netdev_priv(net_dev); HLIST_HEAD(vis_if_list); struct if_list_entry *entry; struct hlist_node *pos, *n; - size_t hdr_len, tmp_len; - int i, bytes_written = 0; + int i; char tmp_addr_str[ETH_STR_LEN]; unsigned long flags; int vis_server = atomic_read(&bat_priv->vis_mode); + size_t buff_pos, buf_size; + char *buff; if ((!bat_priv->primary_if) || (vis_server == VIS_TYPE_CLIENT_UPDATE)) return 0; - hdr_len = 0; - + buf_size = 1; + /* Estimate length */ spin_lock_irqsave(&vis_hash_lock, flags); + while (hash_iterate(vis_hash, &hashit_count)) { + info = hashit_count.bucket->data; + entries = (struct vis_info_entry *) + ((char *)info + sizeof(struct vis_info)); + + for (i = 0; i < info->packet.entries; i++) { + if (entries[i].quality == 0) + continue; + vis_data_insert_interface(entries[i].src, &vis_if_list, + compare_orig(entries[i].src, + info->packet.vis_orig)); + } + + hlist_for_each_entry(entry, pos, &vis_if_list, list) { + buf_size += 18 + 26 * info->packet.entries; + + /* add primary/secondary records */ + if (compare_orig(entry->addr, info->packet.vis_orig)) + buf_size += + vis_data_count_prim_sec(&vis_if_list); + + buf_size += 1; + } + + hlist_for_each_entry_safe(entry, pos, n, &vis_if_list, list) { + hlist_del(&entry->list); + kfree(entry); + } + } + + buff = kmalloc(buf_size, GFP_ATOMIC); + if (!buff) { + spin_unlock_irqrestore(&vis_hash_lock, flags); + return -ENOMEM; + } + buff[0] = '\0'; + buff_pos = 0; + while (hash_iterate(vis_hash, &hashit)) { info = hashit.bucket->data; entries = (struct vis_info_entry *) ((char *)info + sizeof(struct vis_info)); - /* estimated line length */ - if (count < bytes_written + 200) - break; - for (i = 0; i < info->packet.entries; i++) { if (entries[i].quality == 0) continue; @@ -199,30 +252,22 @@ ssize_t vis_fill_buffer_text(struct net_device *net_dev, char *buff, hlist_for_each_entry(entry, pos, &vis_if_list, list) { addr_to_string(tmp_addr_str, entry->addr); - tmp_len = sprintf(buff + bytes_written, - "%s,", tmp_addr_str); + buff_pos += sprintf(buff + buff_pos, "%s,", + tmp_addr_str); for (i = 0; i < info->packet.entries; i++) - tmp_len += vis_data_read_entry( - buff + bytes_written + tmp_len, - &entries[i], entry->addr, - entry->primary); + buff_pos += vis_data_read_entry(buff + buff_pos, + &entries[i], + entry->addr, + entry->primary); /* add primary/secondary records */ if (compare_orig(entry->addr, info->packet.vis_orig)) - tmp_len += vis_data_read_prim_sec( - buff + bytes_written + tmp_len, - &vis_if_list); + buff_pos += + vis_data_read_prim_sec(buff + buff_pos, + &vis_if_list); - tmp_len += sprintf(buff + bytes_written + tmp_len, - "\n"); - - hdr_len += tmp_len; - - if (off >= hdr_len) - continue; - - bytes_written += tmp_len; + buff_pos += sprintf(buff + buff_pos, "\n"); } hlist_for_each_entry_safe(entry, pos, n, &vis_if_list, list) { @@ -230,9 +275,13 @@ ssize_t vis_fill_buffer_text(struct net_device *net_dev, char *buff, kfree(entry); } } + spin_unlock_irqrestore(&vis_hash_lock, flags); - return bytes_written; + seq_printf(seq, "%s", buff); + kfree(buff); + + return 0; } /* add the info packet to the send list, if it was not diff --git a/drivers/staging/batman-adv/vis.h b/drivers/staging/batman-adv/vis.h index 9c1fd771cbae..5dd6521cd7d1 100644 --- a/drivers/staging/batman-adv/vis.h +++ b/drivers/staging/batman-adv/vis.h @@ -47,8 +47,7 @@ struct recvlist_node { extern struct hashtable_t *vis_hash; extern spinlock_t vis_hash_lock; -ssize_t vis_fill_buffer_text(struct net_device *net_dev, char *buff, - size_t count, loff_t off); +int vis_seq_print_text(struct seq_file *seq, void *offset); void receive_server_sync_packet(struct bat_priv *bat_priv, struct vis_packet *vis_packet, int vis_info_len); From 3a632cc71a8a0aea00db14c22f75d1a3846f9c4f Mon Sep 17 00:00:00 2001 From: Marek Lindner Date: Tue, 22 Jun 2010 01:25:44 +0200 Subject: [PATCH 127/523] Staging: batman-adv: convert all sysfs files to single value files This patch removes the extra usage output which came when the sysfs files were read. Signed-off-by: Marek Lindner Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/batman-adv/bat_sysfs.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/batman-adv/bat_sysfs.c b/drivers/staging/batman-adv/bat_sysfs.c index 651bdb4b6699..b9618176a605 100644 --- a/drivers/staging/batman-adv/bat_sysfs.c +++ b/drivers/staging/batman-adv/bat_sysfs.c @@ -36,18 +36,18 @@ struct bat_attribute bat_attr_##_name = { \ .store = _store, \ }; -static ssize_t show_aggr_ogm(struct kobject *kobj, struct attribute *attr, +static ssize_t show_aggr_ogms(struct kobject *kobj, struct attribute *attr, char *buff) { struct device *dev = to_dev(kobj->parent); struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev)); int aggr_status = atomic_read(&bat_priv->aggregation_enabled); - return sprintf(buff, "status: %s\ncommands: enable, disable, 0, 1\n", + return sprintf(buff, "%s\n", aggr_status == 0 ? "disabled" : "enabled"); } -static ssize_t store_aggr_ogm(struct kobject *kobj, struct attribute *attr, +static ssize_t store_aggr_ogms(struct kobject *kobj, struct attribute *attr, char *buff, size_t count) { struct device *dev = to_dev(kobj->parent); @@ -91,10 +91,9 @@ static ssize_t show_vis_mode(struct kobject *kobj, struct attribute *attr, struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev)); int vis_mode = atomic_read(&bat_priv->vis_mode); - return sprintf(buff, "status: %s\ncommands: client, server, %d, %d\n", + return sprintf(buff, "%s\n", vis_mode == VIS_TYPE_CLIENT_UPDATE ? - "client" : "server", - VIS_TYPE_SERVER_SYNC, VIS_TYPE_CLIENT_UPDATE); + "client" : "server"); } static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr, @@ -109,7 +108,8 @@ static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr, ret = strict_strtoul(buff, 10, &val); if (((count == 2) && (!ret) && (val == VIS_TYPE_CLIENT_UPDATE)) || - (strncmp(buff, "client", 6) == 0)) + (strncmp(buff, "client", 6) == 0) || + (strncmp(buff, "off", 3) == 0)) vis_mode_tmp = VIS_TYPE_CLIENT_UPDATE; if (((count == 2) && (!ret) && (val == VIS_TYPE_SERVER_SYNC)) || @@ -143,7 +143,7 @@ static ssize_t show_orig_interval(struct kobject *kobj, struct attribute *attr, struct device *dev = to_dev(kobj->parent); struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev)); - return sprintf(buff, "status: %i\n", + return sprintf(buff, "%i\n", atomic_read(&bat_priv->orig_interval)); } @@ -180,14 +180,14 @@ static ssize_t store_orig_interval(struct kobject *kobj, struct attribute *attr, return count; } -static BAT_ATTR(aggregate_ogm, S_IRUGO | S_IWUSR, - show_aggr_ogm, store_aggr_ogm); +static BAT_ATTR(aggregated_ogms, S_IRUGO | S_IWUSR, + show_aggr_ogms, store_aggr_ogms); static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode); static BAT_ATTR(orig_interval, S_IRUGO | S_IWUSR, show_orig_interval, store_orig_interval); static struct bat_attribute *mesh_attrs[] = { - &bat_attr_aggregate_ogm, + &bat_attr_aggregated_ogms, &bat_attr_vis_mode, &bat_attr_orig_interval, NULL, @@ -261,7 +261,7 @@ static ssize_t show_mesh_iface(struct kobject *kobj, struct attribute *attr, if (!batman_if) return 0; - return sprintf(buff, "status: %s\ncommands: none, bat0\n", + return sprintf(buff, "%s\n", batman_if->if_status == IF_NOT_IN_USE ? "none" : "bat0"); } From 1bcb164e5d28b316512cd06c5092bc6a03506417 Mon Sep 17 00:00:00 2001 From: Marek Lindner Date: Tue, 22 Jun 2010 01:25:45 +0200 Subject: [PATCH 128/523] Staging: batman-adv: remove superfluous hint to "translation table" Signed-off-by: Marek Lindner [sven.eckelmann@gmx.de: Rework on top of current version] Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/batman-adv/translation-table.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/batman-adv/translation-table.c b/drivers/staging/batman-adv/translation-table.c index 604122c59660..5a0264aac1e8 100644 --- a/drivers/staging/batman-adv/translation-table.c +++ b/drivers/staging/batman-adv/translation-table.c @@ -395,8 +395,7 @@ int hna_global_seq_print_text(struct seq_file *seq, void *offset) net_dev->name); } - seq_printf(seq, "Globally announced HNAs received via the mesh %s " - "(translation table):\n", + seq_printf(seq, "Globally announced HNAs received via the mesh %s\n", net_dev->name); spin_lock_irqsave(&hna_global_hash_lock, flags); From 516c9a777819150bf3a9b709cd93325cf29a93bf Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Tue, 22 Jun 2010 01:25:46 +0200 Subject: [PATCH 129/523] Staging: batman-adv: Convert MAC_FMT to %pM Remove the last uses of MAC_FMT Signed-off-by: Joe Perches [sven.eckelmann@gmx.de: Adapted for current batman-adv version] Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/batman-adv/main.c | 3 +-- .../staging/batman-adv/translation-table.c | 24 ++++--------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/drivers/staging/batman-adv/main.c b/drivers/staging/batman-adv/main.c index ed18b08e704b..72fccb1c5236 100644 --- a/drivers/staging/batman-adv/main.c +++ b/drivers/staging/batman-adv/main.c @@ -230,8 +230,7 @@ void dec_module_count(void) int addr_to_string(char *buff, uint8_t *addr) { - return sprintf(buff, MAC_FMT, - addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); + return sprintf(buff, "%pM", addr); } /* returns 1 if they are the same originator */ diff --git a/drivers/staging/batman-adv/translation-table.c b/drivers/staging/batman-adv/translation-table.c index 5a0264aac1e8..d9233b06f131 100644 --- a/drivers/staging/batman-adv/translation-table.c +++ b/drivers/staging/batman-adv/translation-table.c @@ -199,13 +199,8 @@ int hna_local_seq_print_text(struct seq_file *seq, void *offset) while (hash_iterate(hna_local_hash, &hashit)) { hna_local_entry = hashit.bucket->data; - pos += snprintf(buff + pos, 22, " * " MAC_FMT "\n", - hna_local_entry->addr[0], - hna_local_entry->addr[1], - hna_local_entry->addr[2], - hna_local_entry->addr[3], - hna_local_entry->addr[4], - hna_local_entry->addr[5]); + pos += snprintf(buff + pos, 22, " * %pM\n", + hna_local_entry->addr); } spin_unlock_irqrestore(&hna_local_hash_lock, flags); @@ -417,19 +412,8 @@ int hna_global_seq_print_text(struct seq_file *seq, void *offset) hna_global_entry = hashit.bucket->data; pos += snprintf(buff + pos, 44, - " * " MAC_FMT " via " MAC_FMT "\n", - hna_global_entry->addr[0], - hna_global_entry->addr[1], - hna_global_entry->addr[2], - hna_global_entry->addr[3], - hna_global_entry->addr[4], - hna_global_entry->addr[5], - hna_global_entry->orig_node->orig[0], - hna_global_entry->orig_node->orig[1], - hna_global_entry->orig_node->orig[2], - hna_global_entry->orig_node->orig[3], - hna_global_entry->orig_node->orig[4], - hna_global_entry->orig_node->orig[5]); + " * %pM via %pM\n", hna_global_entry->addr, + hna_global_entry->orig_node->orig); } spin_unlock_irqrestore(&hna_global_hash_lock, flags); From 42fa1b92ab3261ef60ef4f60ff6eff2a0585348d Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Tue, 22 Jun 2010 01:25:47 +0200 Subject: [PATCH 130/523] Staging: batman-adv: Mark locally used symbols as static Functions and variables which are used only inside one object file can be declared as static. This helped to find unused functions/variables * mainIfAddr_default * main_if_was_up and functions with declarations but missing definitions * hash_debug * orig_find * send_own_packet_work Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/batman-adv/bitarray.c | 2 +- drivers/staging/batman-adv/bitarray.h | 3 - drivers/staging/batman-adv/hash.c | 2 +- drivers/staging/batman-adv/hash.h | 6 - drivers/staging/batman-adv/originator.c | 32 +++--- drivers/staging/batman-adv/originator.h | 2 - drivers/staging/batman-adv/routing.c | 2 +- drivers/staging/batman-adv/routing.h | 2 - drivers/staging/batman-adv/send.c | 4 +- drivers/staging/batman-adv/send.h | 2 - drivers/staging/batman-adv/soft-interface.c | 104 +++++++++--------- drivers/staging/batman-adv/soft-interface.h | 6 - .../staging/batman-adv/translation-table.c | 9 +- .../staging/batman-adv/translation-table.h | 3 - drivers/staging/batman-adv/vis.c | 4 +- drivers/staging/batman-adv/vis.h | 3 - 16 files changed, 79 insertions(+), 107 deletions(-) diff --git a/drivers/staging/batman-adv/bitarray.c b/drivers/staging/batman-adv/bitarray.c index 2fef6e35f8c3..cfca0339220b 100644 --- a/drivers/staging/batman-adv/bitarray.c +++ b/drivers/staging/batman-adv/bitarray.c @@ -63,7 +63,7 @@ void bit_mark(TYPE_OF_WORD *seq_bits, int32_t n) } /* shift the packet array by n places. */ -void bit_shift(TYPE_OF_WORD *seq_bits, int32_t n) +static void bit_shift(TYPE_OF_WORD *seq_bits, int32_t n) { int32_t word_offset, word_num; int32_t i; diff --git a/drivers/staging/batman-adv/bitarray.h b/drivers/staging/batman-adv/bitarray.h index 76ad24c9f3de..4dd1e7cf9486 100644 --- a/drivers/staging/batman-adv/bitarray.h +++ b/drivers/staging/batman-adv/bitarray.h @@ -32,9 +32,6 @@ uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint16_t last_seqno, /* turn corresponding bit on, so we can remember that we got the packet */ void bit_mark(TYPE_OF_WORD *seq_bits, int32_t n); -/* shift the packet array by n places. */ -void bit_shift(TYPE_OF_WORD *seq_bits, int32_t n); - /* receive and process one packet, returns 1 if received seq_num is considered * new, 0 if old */ diff --git a/drivers/staging/batman-adv/hash.c b/drivers/staging/batman-adv/hash.c index d4a4adc57042..1286f8ff44f4 100644 --- a/drivers/staging/batman-adv/hash.c +++ b/drivers/staging/batman-adv/hash.c @@ -23,7 +23,7 @@ #include "hash.h" /* clears the hash */ -void hash_init(struct hashtable_t *hash) +static void hash_init(struct hashtable_t *hash) { int i; diff --git a/drivers/staging/batman-adv/hash.h b/drivers/staging/batman-adv/hash.h index ea6d21e01251..05055957f124 100644 --- a/drivers/staging/batman-adv/hash.h +++ b/drivers/staging/batman-adv/hash.h @@ -56,9 +56,6 @@ struct hashtable_t { * argument and the size the second */ }; -/* clears the hash */ -void hash_init(struct hashtable_t *hash); - /* allocates and clears the hash */ struct hashtable_t *hash_new(int size, hashdata_compare_cb compare, hashdata_choose_cb choose); @@ -98,7 +95,4 @@ struct hashtable_t *hash_resize(struct hashtable_t *hash, int size); * the returned iterator to access the elements until hash_it_t returns NULL. */ struct hash_it_t *hash_iterate(struct hashtable_t *hash, struct hash_it_t *iter_in); - -/* print the hash table for debugging */ -void hash_debug(struct hashtable_t *hash); #endif diff --git a/drivers/staging/batman-adv/originator.c b/drivers/staging/batman-adv/originator.c index c15970704c8b..1f6cbe8f8f0b 100644 --- a/drivers/staging/batman-adv/originator.c +++ b/drivers/staging/batman-adv/originator.c @@ -56,21 +56,6 @@ err: return 0; } -void originator_free(void) -{ - unsigned long flags; - - if (!orig_hash) - return; - - cancel_delayed_work_sync(&purge_orig_wq); - - spin_lock_irqsave(&orig_hash_lock, flags); - hash_delete(orig_hash, free_orig_node); - orig_hash = NULL; - spin_unlock_irqrestore(&orig_hash_lock, flags); -} - struct neigh_node * create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, uint8_t *neigh, struct batman_if *if_incoming) @@ -93,7 +78,7 @@ create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, return neigh_node; } -void free_orig_node(void *data) +static void free_orig_node(void *data) { struct list_head *list_pos, *list_pos_tmp; struct neigh_node *neigh_node; @@ -114,6 +99,21 @@ void free_orig_node(void *data) kfree(orig_node); } +void originator_free(void) +{ + unsigned long flags; + + if (!orig_hash) + return; + + cancel_delayed_work_sync(&purge_orig_wq); + + spin_lock_irqsave(&orig_hash_lock, flags); + hash_delete(orig_hash, free_orig_node); + orig_hash = NULL; + spin_unlock_irqrestore(&orig_hash_lock, flags); +} + /* this function finds or creates an originator entry for the given * address if it does not exits */ struct orig_node *get_orig_node(uint8_t *addr) diff --git a/drivers/staging/batman-adv/originator.h b/drivers/staging/batman-adv/originator.h index e91e8a1f4adb..6632538d12fc 100644 --- a/drivers/staging/batman-adv/originator.h +++ b/drivers/staging/batman-adv/originator.h @@ -20,10 +20,8 @@ */ int originator_init(void); -void free_orig_node(void *data); void originator_free(void); void purge_orig(struct work_struct *work); -struct orig_node *orig_find(char *mac); struct orig_node *get_orig_node(uint8_t *addr); struct neigh_node * create_neighbor(struct orig_node *orig_node, struct orig_node *orig_neigh_node, diff --git a/drivers/staging/batman-adv/routing.c b/drivers/staging/batman-adv/routing.c index d4bdca9c1260..480c645e3a61 100644 --- a/drivers/staging/batman-adv/routing.c +++ b/drivers/staging/batman-adv/routing.c @@ -33,7 +33,7 @@ #include "vis.h" #include "aggregation.h" -DECLARE_WAIT_QUEUE_HEAD(thread_wait); +static DECLARE_WAIT_QUEUE_HEAD(thread_wait); void slide_own_bcast_window(struct batman_if *batman_if) { diff --git a/drivers/staging/batman-adv/routing.h b/drivers/staging/batman-adv/routing.h index 8288decea370..c6850d26779c 100644 --- a/drivers/staging/batman-adv/routing.h +++ b/drivers/staging/batman-adv/routing.h @@ -21,8 +21,6 @@ #include "types.h" -extern wait_queue_head_t thread_wait; - void slide_own_bcast_window(struct batman_if *batman_if); void receive_bat_packet(struct ethhdr *ethhdr, struct batman_packet *batman_packet, diff --git a/drivers/staging/batman-adv/send.c b/drivers/staging/batman-adv/send.c index 7365f6dbcb6b..e8f0e2a7b421 100644 --- a/drivers/staging/batman-adv/send.c +++ b/drivers/staging/batman-adv/send.c @@ -31,6 +31,8 @@ #include +static void send_outstanding_bcast_packet(struct work_struct *work); + /* apply hop penalty for a normal link */ static uint8_t hop_penalty(const uint8_t tq) { @@ -431,7 +433,7 @@ out: return NETDEV_TX_BUSY; } -void send_outstanding_bcast_packet(struct work_struct *work) +static void send_outstanding_bcast_packet(struct work_struct *work) { struct batman_if *batman_if; struct delayed_work *delayed_work = diff --git a/drivers/staging/batman-adv/send.h b/drivers/staging/batman-adv/send.h index feaa2fc7f9a1..0a0990d6483b 100644 --- a/drivers/staging/batman-adv/send.h +++ b/drivers/staging/batman-adv/send.h @@ -21,7 +21,6 @@ #include "types.h" -void send_own_packet_work(struct work_struct *work); int send_skb_packet(struct sk_buff *skb, struct batman_if *batman_if, uint8_t *dst_addr); @@ -34,6 +33,5 @@ void schedule_forward_packet(struct orig_node *orig_node, uint8_t directlink, int hna_buff_len, struct batman_if *if_outgoing); int add_bcast_packet_to_list(struct sk_buff *skb); -void send_outstanding_bcast_packet(struct work_struct *work); void send_outstanding_bat_packet(struct work_struct *work); void purge_outstanding_packets(struct batman_if *batman_if); diff --git a/drivers/staging/batman-adv/soft-interface.c b/drivers/staging/batman-adv/soft-interface.c index 51c40b77c8d7..c483693d5944 100644 --- a/drivers/staging/batman-adv/soft-interface.c +++ b/drivers/staging/batman-adv/soft-interface.c @@ -36,7 +36,6 @@ static int32_t skb_packets; static int32_t skb_bad_packets; unsigned char mainIfAddr[ETH_ALEN]; -static unsigned char mainIfAddr_default[ETH_ALEN]; static int bat_get_settings(struct net_device *dev, struct ethtool_cmd *cmd); static void bat_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info); @@ -61,11 +60,6 @@ void set_main_if_addr(uint8_t *addr) memcpy(mainIfAddr, addr, ETH_ALEN); } -int main_if_was_up(void) -{ - return (memcmp(mainIfAddr, mainIfAddr_default, ETH_ALEN) != 0 ? 1 : 0); -} - int my_skb_push(struct sk_buff *skb, unsigned int len) { int result = 0; @@ -83,69 +77,25 @@ int my_skb_push(struct sk_buff *skb, unsigned int len) return 0; } -#ifdef HAVE_NET_DEVICE_OPS -static const struct net_device_ops bat_netdev_ops = { - .ndo_open = interface_open, - .ndo_stop = interface_release, - .ndo_get_stats = interface_stats, - .ndo_set_mac_address = interface_set_mac_addr, - .ndo_change_mtu = interface_change_mtu, - .ndo_start_xmit = interface_tx, - .ndo_validate_addr = eth_validate_addr -}; -#endif - -void interface_setup(struct net_device *dev) -{ - struct bat_priv *priv = netdev_priv(dev); - char dev_addr[ETH_ALEN]; - - ether_setup(dev); - -#ifdef HAVE_NET_DEVICE_OPS - dev->netdev_ops = &bat_netdev_ops; -#else - dev->open = interface_open; - dev->stop = interface_release; - dev->get_stats = interface_stats; - dev->set_mac_address = interface_set_mac_addr; - dev->change_mtu = interface_change_mtu; - dev->hard_start_xmit = interface_tx; -#endif - dev->destructor = free_netdev; - - dev->mtu = hardif_min_mtu(); - dev->hard_header_len = BAT_HEADER_LEN; /* reserve more space in the - * skbuff for our header */ - - /* generate random address */ - random_ether_addr(dev_addr); - memcpy(dev->dev_addr, dev_addr, ETH_ALEN); - - SET_ETHTOOL_OPS(dev, &bat_ethtool_ops); - - memset(priv, 0, sizeof(struct bat_priv)); -} - -int interface_open(struct net_device *dev) +static int interface_open(struct net_device *dev) { netif_start_queue(dev); return 0; } -int interface_release(struct net_device *dev) +static int interface_release(struct net_device *dev) { netif_stop_queue(dev); return 0; } -struct net_device_stats *interface_stats(struct net_device *dev) +static struct net_device_stats *interface_stats(struct net_device *dev) { struct bat_priv *priv = netdev_priv(dev); return &priv->stats; } -int interface_set_mac_addr(struct net_device *dev, void *p) +static int interface_set_mac_addr(struct net_device *dev, void *p) { struct sockaddr *addr = p; @@ -163,7 +113,7 @@ int interface_set_mac_addr(struct net_device *dev, void *p) return 0; } -int interface_change_mtu(struct net_device *dev, int new_mtu) +static int interface_change_mtu(struct net_device *dev, int new_mtu) { /* check ranges */ if ((new_mtu < 68) || (new_mtu > hardif_min_mtu())) @@ -315,6 +265,50 @@ void interface_rx(struct sk_buff *skb, int hdr_size) netif_rx(skb); } +#ifdef HAVE_NET_DEVICE_OPS +static const struct net_device_ops bat_netdev_ops = { + .ndo_open = interface_open, + .ndo_stop = interface_release, + .ndo_get_stats = interface_stats, + .ndo_set_mac_address = interface_set_mac_addr, + .ndo_change_mtu = interface_change_mtu, + .ndo_start_xmit = interface_tx, + .ndo_validate_addr = eth_validate_addr +}; +#endif + +void interface_setup(struct net_device *dev) +{ + struct bat_priv *priv = netdev_priv(dev); + char dev_addr[ETH_ALEN]; + + ether_setup(dev); + +#ifdef HAVE_NET_DEVICE_OPS + dev->netdev_ops = &bat_netdev_ops; +#else + dev->open = interface_open; + dev->stop = interface_release; + dev->get_stats = interface_stats; + dev->set_mac_address = interface_set_mac_addr; + dev->change_mtu = interface_change_mtu; + dev->hard_start_xmit = interface_tx; +#endif + dev->destructor = free_netdev; + + dev->mtu = hardif_min_mtu(); + dev->hard_header_len = BAT_HEADER_LEN; /* reserve more space in the + * skbuff for our header */ + + /* generate random address */ + random_ether_addr(dev_addr); + memcpy(dev->dev_addr, dev_addr, ETH_ALEN); + + SET_ETHTOOL_OPS(dev, &bat_ethtool_ops); + + memset(priv, 0, sizeof(struct bat_priv)); +} + /* ethtool */ static int bat_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) { diff --git a/drivers/staging/batman-adv/soft-interface.h b/drivers/staging/batman-adv/soft-interface.h index e7f59af7df33..3852c573221e 100644 --- a/drivers/staging/batman-adv/soft-interface.h +++ b/drivers/staging/batman-adv/soft-interface.h @@ -20,13 +20,7 @@ */ void set_main_if_addr(uint8_t *addr); -int main_if_was_up(void); void interface_setup(struct net_device *dev); -int interface_open(struct net_device *dev); -int interface_release(struct net_device *dev); -struct net_device_stats *interface_stats(struct net_device *dev); -int interface_set_mac_addr(struct net_device *dev, void *addr); -int interface_change_mtu(struct net_device *dev, int new_mtu); int interface_tx(struct sk_buff *skb, struct net_device *dev); void interface_rx(struct sk_buff *skb, int hdr_size); int my_skb_push(struct sk_buff *skb, unsigned int len); diff --git a/drivers/staging/batman-adv/translation-table.c b/drivers/staging/batman-adv/translation-table.c index d9233b06f131..9fd32a979324 100644 --- a/drivers/staging/batman-adv/translation-table.c +++ b/drivers/staging/batman-adv/translation-table.c @@ -32,7 +32,10 @@ atomic_t hna_local_changed; DEFINE_SPINLOCK(hna_local_hash_lock); static DEFINE_SPINLOCK(hna_global_hash_lock); +static void hna_local_purge(struct work_struct *work); static DECLARE_DELAYED_WORK(hna_local_purge_wq, hna_local_purge); +static void _hna_global_del_orig(struct hna_global_entry *hna_global_entry, + char *message); static void hna_local_start_timer(void) { @@ -242,7 +245,7 @@ void hna_local_remove(uint8_t *addr, char *message) spin_unlock_irqrestore(&hna_local_hash_lock, flags); } -void hna_local_purge(struct work_struct *work) +static void hna_local_purge(struct work_struct *work) { struct hna_local_entry *hna_local_entry; HASHIT(hashit); @@ -423,8 +426,8 @@ int hna_global_seq_print_text(struct seq_file *seq, void *offset) return 0; } -void _hna_global_del_orig(struct hna_global_entry *hna_global_entry, - char *message) +static void _hna_global_del_orig(struct hna_global_entry *hna_global_entry, + char *message) { bat_dbg(DBG_ROUTES, "Deleting global hna entry %pM (via %pM): %s\n", hna_global_entry->addr, hna_global_entry->orig_node->orig, diff --git a/drivers/staging/batman-adv/translation-table.h b/drivers/staging/batman-adv/translation-table.h index 8b3429e96af2..232208fedef5 100644 --- a/drivers/staging/batman-adv/translation-table.h +++ b/drivers/staging/batman-adv/translation-table.h @@ -26,14 +26,11 @@ void hna_local_add(uint8_t *addr); void hna_local_remove(uint8_t *addr, char *message); int hna_local_fill_buffer(unsigned char *buff, int buff_len); int hna_local_seq_print_text(struct seq_file *seq, void *offset); -void hna_local_purge(struct work_struct *work); void hna_local_free(void); int hna_global_init(void); void hna_global_add_orig(struct orig_node *orig_node, unsigned char *hna_buff, int hna_buff_len); int hna_global_seq_print_text(struct seq_file *seq, void *offset); -void _hna_global_del_orig(struct hna_global_entry *hna_global_entry, - char *orig_str); void hna_global_del_orig(struct orig_node *orig_node, char *message); void hna_global_free(void); struct orig_node *transtable_search(uint8_t *addr); diff --git a/drivers/staging/batman-adv/vis.c b/drivers/staging/batman-adv/vis.c index c73774b16b88..7bd553a5cd39 100644 --- a/drivers/staging/batman-adv/vis.c +++ b/drivers/staging/batman-adv/vis.c @@ -43,8 +43,8 @@ _dummy > smallest_signed_int(_dummy); }) #define seq_after(x, y) seq_before(y, x) -struct hashtable_t *vis_hash; -DEFINE_SPINLOCK(vis_hash_lock); +static struct hashtable_t *vis_hash; +static DEFINE_SPINLOCK(vis_hash_lock); static DEFINE_SPINLOCK(recv_list_lock); static struct vis_info *my_vis_info; static struct list_head send_list; /* always locked with vis_hash_lock */ diff --git a/drivers/staging/batman-adv/vis.h b/drivers/staging/batman-adv/vis.h index 5dd6521cd7d1..1cfadce59325 100644 --- a/drivers/staging/batman-adv/vis.h +++ b/drivers/staging/batman-adv/vis.h @@ -44,9 +44,6 @@ struct recvlist_node { uint8_t mac[ETH_ALEN]; }; -extern struct hashtable_t *vis_hash; -extern spinlock_t vis_hash_lock; - int vis_seq_print_text(struct seq_file *seq, void *offset); void receive_server_sync_packet(struct bat_priv *bat_priv, struct vis_packet *vis_packet, From 8bfe3638747b2c2f842edf9eb2a407a22a9d537d Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Tue, 22 Jun 2010 01:25:48 +0200 Subject: [PATCH 131/523] Staging: batman-adv: Ignore debugfs on kernels without debugfs support All code for debugfs is ignored when the creation of the batman-adv root directory in debugfs fails. It must also be ignored when the debugfs_create_dir tells us that debugfs is not implemented to prevent possible crashes in the future. Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/batman-adv/bat_debugfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/batman-adv/bat_debugfs.c b/drivers/staging/batman-adv/bat_debugfs.c index a8fe1c91fa4c..fafca9f0a33c 100644 --- a/drivers/staging/batman-adv/bat_debugfs.c +++ b/drivers/staging/batman-adv/bat_debugfs.c @@ -88,6 +88,8 @@ static struct bat_debuginfo *mesh_debuginfos[] = { void debugfs_init(void) { bat_debugfs = debugfs_create_dir(DEBUGFS_BAT_SUBDIR, NULL); + if (bat_debugfs == ERR_PTR(-ENODEV)) + bat_debugfs = NULL; } void debugfs_destroy(void) From 5a39195769febbc29a1d60d02f655ee32c252813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20L=C3=BCssing?= Date: Tue, 22 Jun 2010 01:25:49 +0200 Subject: [PATCH 132/523] Staging: batman-adv: permit setting ogm interval to JITTER*2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When trying to set the originator interval to 40ms, we are asked to set it to a minimum value of 40ms. This patch permits setting an originator interval of JITTER*2 (40ms by default) now. Signed-off-by: Linus Lüssing Signed-off-by: Simon Wunderlich Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/batman-adv/bat_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/batman-adv/bat_sysfs.c b/drivers/staging/batman-adv/bat_sysfs.c index b9618176a605..b8ccb7511ef5 100644 --- a/drivers/staging/batman-adv/bat_sysfs.c +++ b/drivers/staging/batman-adv/bat_sysfs.c @@ -163,7 +163,7 @@ static ssize_t store_orig_interval(struct kobject *kobj, struct attribute *attr, return -EINVAL; } - if (orig_interval_tmp <= JITTER * 2) { + if (orig_interval_tmp < JITTER * 2) { printk(KERN_INFO "batman-adv:New originator interval too small: %li (min: %i)\n", orig_interval_tmp, JITTER * 2); return -EINVAL; From 6856ba1f44522b381c9a60b7972dd0fb52c54093 Mon Sep 17 00:00:00 2001 From: Simon Wunderlich Date: Tue, 22 Jun 2010 01:25:50 +0200 Subject: [PATCH 133/523] Staging: batman-adv: Add release information for version 2010.0.0 Signed-off-by: Simon Wunderlich Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/batman-adv/CHANGELOG | 12 ++++++++++++ drivers/staging/batman-adv/README | 2 +- drivers/staging/batman-adv/main.h | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/staging/batman-adv/CHANGELOG b/drivers/staging/batman-adv/CHANGELOG index c8f9d9e06bb4..86450b4f7d76 100644 --- a/drivers/staging/batman-adv/CHANGELOG +++ b/drivers/staging/batman-adv/CHANGELOG @@ -1,3 +1,15 @@ +batman-adv 2010.0.0: + +* support latest kernels (2.6.21 - 2.6.35) +* further code refactoring and cleaning for coding style +* move from procfs based configuration to sysfs +* reorganized sequence number handling +* limit queue lengths for batman and broadcast packets +* many bugs (endless loop and rogue packets on shutdown, wrong tcpdump output, + missing frees in error situations, sleeps in atomic contexts) squashed + + -- Fri, 18 Jun 2010 21:34:26 +0200 + batman-adv 0.2.1: * support latest kernels (2.6.20 - 2.6.33) diff --git a/drivers/staging/batman-adv/README b/drivers/staging/batman-adv/README index 14244a2c4e4f..7192b7fa2183 100644 --- a/drivers/staging/batman-adv/README +++ b/drivers/staging/batman-adv/README @@ -1,4 +1,4 @@ -[state: 03-05-2010] +[state: 12-06-2010] BATMAN-ADV ---------- diff --git a/drivers/staging/batman-adv/main.h b/drivers/staging/batman-adv/main.h index 7cb0b185de19..f70d99af4289 100644 --- a/drivers/staging/batman-adv/main.h +++ b/drivers/staging/batman-adv/main.h @@ -27,7 +27,7 @@ #define DRIVER_DESC "B.A.T.M.A.N. advanced" #define DRIVER_DEVICE "batman-adv" -#define SOURCE_VERSION "0.2.2-beta" +#define SOURCE_VERSION "2010.0.0" /* B.A.T.M.A.N. parameters */ From cf2d72ec5c66ac3ebe9d28c3d88314a958cc180e Mon Sep 17 00:00:00 2001 From: Simon Wunderlich Date: Tue, 22 Jun 2010 01:25:51 +0200 Subject: [PATCH 134/523] Staging: batman-adv: 32bit sequence number and TTL for broadcasts This patch changes the sequence number range from 8 or 16 bit to 32 bit. This should avoid problems with the sequence number sliding window algorithm which we had seen in the past for broadcast floods or malicious packet injections. We can not assure 100% security with this patch, but it is quite an improvement over the old 16 bit sequence numbers: * expected window size can be increased (4096 -> 65536) * 64k packets in the right order would now be needed to cause a loop, which seems practically impossible. Furthermore, a TTL field has been added to the broadcast packet type, just to make sure. These changes required to increase the compatibility level once again. Signed-off-by: Simon Wunderlich [sven.eckelmann@gmx.de: Change atomic64_* back to atomic_*, Rework on top of current version] Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/batman-adv/aggregation.c | 4 ++-- drivers/staging/batman-adv/bitarray.c | 8 ++++---- drivers/staging/batman-adv/bitarray.h | 6 +++--- drivers/staging/batman-adv/main.h | 2 +- drivers/staging/batman-adv/packet.h | 9 +++++---- drivers/staging/batman-adv/routing.c | 17 ++++++++++------- drivers/staging/batman-adv/send.c | 15 ++++++++++----- drivers/staging/batman-adv/soft-interface.c | 5 +++-- drivers/staging/batman-adv/types.h | 6 +++--- drivers/staging/batman-adv/vis.c | 5 +++-- 10 files changed, 44 insertions(+), 33 deletions(-) diff --git a/drivers/staging/batman-adv/aggregation.c b/drivers/staging/batman-adv/aggregation.c index ce8b8a6e5ae6..3a5c3499ca06 100644 --- a/drivers/staging/batman-adv/aggregation.c +++ b/drivers/staging/batman-adv/aggregation.c @@ -252,9 +252,9 @@ void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff, while (aggregated_packet(buff_pos, packet_len, batman_packet->num_hna)) { - /* network to host order for our 16bit seqno, and the + /* network to host order for our 32bit seqno, and the orig_interval. */ - batman_packet->seqno = ntohs(batman_packet->seqno); + batman_packet->seqno = ntohl(batman_packet->seqno); hna_buff = packet_buff + buff_pos + BAT_PACKET_LEN; receive_bat_packet(ethhdr, batman_packet, diff --git a/drivers/staging/batman-adv/bitarray.c b/drivers/staging/batman-adv/bitarray.c index cfca0339220b..c10fe03ec63b 100644 --- a/drivers/staging/batman-adv/bitarray.c +++ b/drivers/staging/batman-adv/bitarray.c @@ -24,10 +24,10 @@ /* returns true if the corresponding bit in the given seq_bits indicates true * and curr_seqno is within range of last_seqno */ -uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint16_t last_seqno, - uint16_t curr_seqno) +uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint32_t last_seqno, + uint32_t curr_seqno) { - int16_t diff, word_offset, word_num; + int32_t diff, word_offset, word_num; diff = last_seqno - curr_seqno; if (diff < 0 || diff >= TQ_LOCAL_WINDOW_SIZE) { @@ -125,7 +125,7 @@ static void bit_reset_window(TYPE_OF_WORD *seq_bits) * 1 if the window was moved (either new or very old) * 0 if the window was not moved/shifted. */ -char bit_get_packet(TYPE_OF_WORD *seq_bits, int16_t seq_num_diff, +char bit_get_packet(TYPE_OF_WORD *seq_bits, int32_t seq_num_diff, int8_t set_mark) { /* sequence number is slightly older. We already got a sequence number diff --git a/drivers/staging/batman-adv/bitarray.h b/drivers/staging/batman-adv/bitarray.h index 4dd1e7cf9486..dad13bf473d0 100644 --- a/drivers/staging/batman-adv/bitarray.h +++ b/drivers/staging/batman-adv/bitarray.h @@ -26,8 +26,8 @@ /* returns true if the corresponding bit in the given seq_bits indicates true * and curr_seqno is within range of last_seqno */ -uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint16_t last_seqno, - uint16_t curr_seqno); +uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint32_t last_seqno, + uint32_t curr_seqno); /* turn corresponding bit on, so we can remember that we got the packet */ void bit_mark(TYPE_OF_WORD *seq_bits, int32_t n); @@ -35,7 +35,7 @@ void bit_mark(TYPE_OF_WORD *seq_bits, int32_t n); /* receive and process one packet, returns 1 if received seq_num is considered * new, 0 if old */ -char bit_get_packet(TYPE_OF_WORD *seq_bits, int16_t seq_num_diff, +char bit_get_packet(TYPE_OF_WORD *seq_bits, int32_t seq_num_diff, int8_t set_mark); /* count the hamming weight, how many good packets did we receive? */ diff --git a/drivers/staging/batman-adv/main.h b/drivers/staging/batman-adv/main.h index f70d99af4289..145ac5131bf8 100644 --- a/drivers/staging/batman-adv/main.h +++ b/drivers/staging/batman-adv/main.h @@ -65,7 +65,7 @@ #define MAX_AGGREGATION_MS 100 #define RESET_PROTECTION_MS 30000 -#define EXPECTED_SEQNO_RANGE 4096 +#define EXPECTED_SEQNO_RANGE 65536 /* don't reset again within 30 seconds */ #define MODULE_INACTIVE 0 diff --git a/drivers/staging/batman-adv/packet.h b/drivers/staging/batman-adv/packet.h index 152f57b1c6c5..f0387babfa69 100644 --- a/drivers/staging/batman-adv/packet.h +++ b/drivers/staging/batman-adv/packet.h @@ -28,7 +28,7 @@ #define BAT_VIS 0x05 /* this file is included by batctl which needs these defines */ -#define COMPAT_VERSION 8 +#define COMPAT_VERSION 11 #define DIRECTLINK 0x40 #define VIS_SERVER 0x20 @@ -48,7 +48,7 @@ struct batman_packet { uint8_t version; /* batman version field */ uint8_t flags; /* 0x40: DIRECTLINK flag, 0x20 VIS_SERVER flag... */ uint8_t tq; - uint16_t seqno; + uint32_t seqno; uint8_t orig[6]; uint8_t prev_sender[6]; uint8_t ttl; @@ -79,15 +79,16 @@ struct bcast_packet { uint8_t packet_type; uint8_t version; /* batman version field */ uint8_t orig[6]; - uint16_t seqno; + uint8_t ttl; + uint32_t seqno; } __attribute__((packed)); struct vis_packet { uint8_t packet_type; uint8_t version; /* batman version field */ uint8_t vis_type; /* which type of vis-participant sent this? */ - uint8_t seqno; /* sequence number */ uint8_t entries; /* number of entries behind this struct */ + uint32_t seqno; /* sequence number */ uint8_t ttl; /* TTL */ uint8_t vis_orig[6]; /* originator that informs about its * neighbors */ diff --git a/drivers/staging/batman-adv/routing.c b/drivers/staging/batman-adv/routing.c index 480c645e3a61..9dbfabeb9704 100644 --- a/drivers/staging/batman-adv/routing.c +++ b/drivers/staging/batman-adv/routing.c @@ -318,7 +318,7 @@ update_hna: * 0 if the packet is to be accepted * 1 if the packet is to be ignored. */ -static int window_protected(int16_t seq_num_diff, +static int window_protected(int32_t seq_num_diff, unsigned long *last_reset) { if ((seq_num_diff <= -TQ_LOCAL_WINDOW_SIZE) @@ -352,7 +352,7 @@ static char count_real_packets(struct ethhdr *ethhdr, struct orig_node *orig_node; struct neigh_node *tmp_neigh_node; char is_duplicate = 0; - int16_t seq_diff; + int32_t seq_diff; int need_update = 0; int set_mark; @@ -406,7 +406,7 @@ void receive_bat_packet(struct ethhdr *ethhdr, char is_my_addr = 0, is_my_orig = 0, is_my_oldorig = 0; char is_broadcast = 0, is_bidirectional, is_single_hop_neigh; char is_duplicate; - unsigned short if_incoming_seqno; + uint32_t if_incoming_seqno; /* Silently drop when the batman packet is actually not a * correct packet. @@ -950,7 +950,7 @@ int recv_bcast_packet(struct sk_buff *skb) struct bcast_packet *bcast_packet; struct ethhdr *ethhdr; int hdr_size = sizeof(struct bcast_packet); - int16_t seq_diff; + int32_t seq_diff; unsigned long flags; /* drop packet if it has not necessary minimum size */ @@ -977,6 +977,9 @@ int recv_bcast_packet(struct sk_buff *skb) if (is_my_mac(bcast_packet->orig)) return NET_RX_DROP; + if (bcast_packet->ttl < 2) + return NET_RX_DROP; + spin_lock_irqsave(&orig_hash_lock, flags); orig_node = ((struct orig_node *) hash_find(orig_hash, bcast_packet->orig)); @@ -989,12 +992,12 @@ int recv_bcast_packet(struct sk_buff *skb) /* check whether the packet is a duplicate */ if (get_bit_status(orig_node->bcast_bits, orig_node->last_bcast_seqno, - ntohs(bcast_packet->seqno))) { + ntohl(bcast_packet->seqno))) { spin_unlock_irqrestore(&orig_hash_lock, flags); return NET_RX_DROP; } - seq_diff = ntohs(bcast_packet->seqno) - orig_node->last_bcast_seqno; + seq_diff = ntohl(bcast_packet->seqno) - orig_node->last_bcast_seqno; /* check whether the packet is old and the host just restarted. */ if (window_protected(seq_diff, &orig_node->bcast_seqno_reset)) { @@ -1005,7 +1008,7 @@ int recv_bcast_packet(struct sk_buff *skb) /* mark broadcast in flood history, update window position * if required. */ if (bit_get_packet(orig_node->bcast_bits, seq_diff, 1)) - orig_node->last_bcast_seqno = ntohs(bcast_packet->seqno); + orig_node->last_bcast_seqno = ntohl(bcast_packet->seqno); spin_unlock_irqrestore(&orig_hash_lock, flags); /* rebroadcast packet */ diff --git a/drivers/staging/batman-adv/send.c b/drivers/staging/batman-adv/send.c index e8f0e2a7b421..f2653dd37c07 100644 --- a/drivers/staging/batman-adv/send.c +++ b/drivers/staging/batman-adv/send.c @@ -159,7 +159,7 @@ static void send_packet_to_if(struct forw_packet *forw_packet, "%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d," " IDF %s) on interface %s [%s]\n", fwd_str, (packet_num > 0 ? "aggregated " : ""), - batman_packet->orig, ntohs(batman_packet->seqno), + batman_packet->orig, ntohl(batman_packet->seqno), batman_packet->tq, batman_packet->ttl, (batman_packet->flags & DIRECTLINK ? "on" : "off"), @@ -204,7 +204,7 @@ static void send_packet(struct forw_packet *forw_packet) "%s packet (originator %pM, seqno %d, TTL %d) " "on interface %s [%s]\n", (forw_packet->own ? "Sending own" : "Forwarding"), - batman_packet->orig, ntohs(batman_packet->seqno), + batman_packet->orig, ntohl(batman_packet->seqno), batman_packet->ttl, forw_packet->if_incoming->dev, forw_packet->if_incoming->addr_str); @@ -283,14 +283,14 @@ void schedule_own_packet(struct batman_if *batman_if) batman_packet = (struct batman_packet *)batman_if->packet_buff; /* change sequence number to network order */ - batman_packet->seqno = htons((uint16_t)atomic_read(&batman_if->seqno)); + batman_packet->seqno = + htonl((uint32_t)atomic_read(&batman_if->seqno)); if (vis_server == VIS_TYPE_SERVER_SYNC) batman_packet->flags = VIS_SERVER; else batman_packet->flags &= ~VIS_SERVER; - /* could be read by receive_bat_packet() */ atomic_inc(&batman_if->seqno); slide_own_bcast_window(batman_if); @@ -347,7 +347,7 @@ void schedule_forward_packet(struct orig_node *orig_node, in_tq, tq_avg, batman_packet->tq, in_ttl - 1, batman_packet->ttl); - batman_packet->seqno = htons(batman_packet->seqno); + batman_packet->seqno = htonl(batman_packet->seqno); if (directlink) batman_packet->flags |= DIRECTLINK; @@ -399,6 +399,7 @@ static void _add_bcast_packet_to_list(struct forw_packet *forw_packet, int add_bcast_packet_to_list(struct sk_buff *skb) { struct forw_packet *forw_packet; + struct bcast_packet *bcast_packet; if (!atomic_dec_not_zero(&bcast_queue_left)) { bat_dbg(DBG_BATMAN, "bcast packet queue full\n"); @@ -414,6 +415,10 @@ int add_bcast_packet_to_list(struct sk_buff *skb) if (!skb) goto packet_free; + /* as we have a copy now, it is safe to decrease the TTL */ + bcast_packet = (struct bcast_packet *)skb->data; + bcast_packet->ttl--; + skb_reset_mac_header(skb); forw_packet->skb = skb; diff --git a/drivers/staging/batman-adv/soft-interface.c b/drivers/staging/batman-adv/soft-interface.c index c483693d5944..ce789a755739 100644 --- a/drivers/staging/batman-adv/soft-interface.c +++ b/drivers/staging/batman-adv/soft-interface.c @@ -30,7 +30,7 @@ #include #include -static uint16_t bcast_seqno = 1; /* give own bcast messages seq numbers to avoid +static uint32_t bcast_seqno = 1; /* give own bcast messages seq numbers to avoid * broadcast storms */ static int32_t skb_packets; static int32_t skb_bad_packets; @@ -155,6 +155,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev) bcast_packet = (struct bcast_packet *)skb->data; bcast_packet->version = COMPAT_VERSION; + bcast_packet->ttl = TTL; /* batman packet type: broadcast */ bcast_packet->packet_type = BAT_BCAST; @@ -164,7 +165,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev) memcpy(bcast_packet->orig, mainIfAddr, ETH_ALEN); /* set broadcast sequence number */ - bcast_packet->seqno = htons(bcast_seqno); + bcast_packet->seqno = htonl(bcast_seqno); /* broadcast packet. on success, increase seqno. */ if (add_bcast_packet_to_list(skb) == NETDEV_TX_OK) diff --git a/drivers/staging/batman-adv/types.h b/drivers/staging/batman-adv/types.h index 751cd6322813..d0af4893686a 100644 --- a/drivers/staging/batman-adv/types.h +++ b/drivers/staging/batman-adv/types.h @@ -72,11 +72,11 @@ struct orig_node { unsigned long batman_seqno_reset; uint8_t flags; unsigned char *hna_buff; - int16_t hna_buff_len; - uint16_t last_real_seqno; + int16_t hna_buff_len; + uint32_t last_real_seqno; uint8_t last_ttl; TYPE_OF_WORD bcast_bits[NUM_WORDS]; - uint16_t last_bcast_seqno; + uint32_t last_bcast_seqno; struct list_head neigh_list; }; diff --git a/drivers/staging/batman-adv/vis.c b/drivers/staging/batman-adv/vis.c index 7bd553a5cd39..d9ab981d9571 100644 --- a/drivers/staging/batman-adv/vis.c +++ b/drivers/staging/batman-adv/vis.c @@ -357,7 +357,8 @@ static struct vis_info *add_packet(struct vis_packet *vis_packet, old_info = hash_find(vis_hash, &search_elem); if (old_info != NULL) { - if (!seq_after(vis_packet->seqno, old_info->packet.seqno)) { + if (!seq_after(ntohl(vis_packet->seqno), + ntohl(old_info->packet.seqno))) { if (old_info->packet.seqno == vis_packet->seqno) { recv_list_add(&old_info->recv_list, vis_packet->sender_orig); @@ -525,7 +526,7 @@ static int generate_vis_packet(struct bat_priv *bat_priv) spin_lock_irqsave(&orig_hash_lock, flags); memcpy(info->packet.target_orig, broadcastAddr, ETH_ALEN); info->packet.ttl = TTL; - info->packet.seqno++; + info->packet.seqno = htonl(ntohl(info->packet.seqno) + 1); info->packet.entries = 0; if (info->packet.vis_type == VIS_TYPE_CLIENT_UPDATE) { From e35fd5ecde2ef0b247a607bc82c4b8f1de06d53b Mon Sep 17 00:00:00 2001 From: Simon Wunderlich Date: Tue, 22 Jun 2010 01:25:52 +0200 Subject: [PATCH 135/523] Staging: batman-adv: Add bonding functionality This patch introduces bonding functionality to batman-advanced, targeted for the 0.3 release. As we are able to route the payload traffic as we want, we may use multiple interfaces on multihomed hosts to transfer data to achieve higher bandwidth. This can be considered as "light Multi Path Routing" for single hop connections. To detect which interfaces of a peer node belong to the same host, a new flag PRIMARIES_FIRST_HOP is introduced. This flag is set on the first hop of OGMs of the primary (first) interface, which is broadcasted on all interfaces. When receiving such an OGM, we can learn which interfaces belong to the same host (by assigning them to the primary originator). Bonding works by sending packets in a round-robin fashion to the available interfaces of a neighbor host, if multiple interfaces are available. The neighbor interfaces should be almost equally good to reach. To avoid interferences (i.e. sending on the same channel), only neighbor interfaces with different mac addresses and different outgoing interfaces are considered as candidates. Bonding is deactivated by default, and can be activated by echo 1 > /sys/class/net/bat0/mesh/bonding for each individual node. Signed-off-by: Simon Wunderlich [sven.eckelmann@gmx.de: Rework on top of current version] Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/batman-adv/bat_sysfs.c | 52 +++++ drivers/staging/batman-adv/hard-interface.c | 2 +- drivers/staging/batman-adv/main.h | 5 + drivers/staging/batman-adv/originator.c | 8 +- drivers/staging/batman-adv/packet.h | 1 + drivers/staging/batman-adv/routing.c | 238 +++++++++++++++++--- drivers/staging/batman-adv/routing.h | 3 + drivers/staging/batman-adv/send.c | 4 +- drivers/staging/batman-adv/soft-interface.c | 60 ++--- drivers/staging/batman-adv/types.h | 11 + 10 files changed, 325 insertions(+), 59 deletions(-) diff --git a/drivers/staging/batman-adv/bat_sysfs.c b/drivers/staging/batman-adv/bat_sysfs.c index b8ccb7511ef5..4e9c71d5a969 100644 --- a/drivers/staging/batman-adv/bat_sysfs.c +++ b/drivers/staging/batman-adv/bat_sysfs.c @@ -84,6 +84,55 @@ static ssize_t store_aggr_ogms(struct kobject *kobj, struct attribute *attr, return count; } +static ssize_t show_bond(struct kobject *kobj, struct attribute *attr, + char *buff) +{ + struct device *dev = to_dev(kobj->parent); + struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev)); + int bond_status = atomic_read(&bat_priv->bonding_enabled); + + return sprintf(buff, "%s\n", + bond_status == 0 ? "disabled" : "enabled"); +} + +static ssize_t store_bond(struct kobject *kobj, struct attribute *attr, + char *buff, size_t count) +{ + struct device *dev = to_dev(kobj->parent); + struct net_device *net_dev = to_net_dev(dev); + struct bat_priv *bat_priv = netdev_priv(net_dev); + int bonding_enabled_tmp = -1; + + if (((count == 2) && (buff[0] == '1')) || + (strncmp(buff, "enable", 6) == 0)) + bonding_enabled_tmp = 1; + + if (((count == 2) && (buff[0] == '0')) || + (strncmp(buff, "disable", 7) == 0)) + bonding_enabled_tmp = 0; + + if (bonding_enabled_tmp < 0) { + if (buff[count - 1] == '\n') + buff[count - 1] = '\0'; + + printk(KERN_ERR "batman-adv:Invalid parameter for 'bonding' setting on mesh %s received: %s\n", + net_dev->name, buff); + return -EINVAL; + } + + if (atomic_read(&bat_priv->bonding_enabled) == bonding_enabled_tmp) + return count; + + printk(KERN_INFO "batman-adv:Changing bonding from: %s to: %s on mesh: %s\n", + atomic_read(&bat_priv->bonding_enabled) == 1 ? + "enabled" : "disabled", + bonding_enabled_tmp == 1 ? "enabled" : "disabled", + net_dev->name); + + atomic_set(&bat_priv->bonding_enabled, (unsigned)bonding_enabled_tmp); + return count; +} + static ssize_t show_vis_mode(struct kobject *kobj, struct attribute *attr, char *buff) { @@ -182,12 +231,14 @@ static ssize_t store_orig_interval(struct kobject *kobj, struct attribute *attr, static BAT_ATTR(aggregated_ogms, S_IRUGO | S_IWUSR, show_aggr_ogms, store_aggr_ogms); +static BAT_ATTR(bonding, S_IRUGO | S_IWUSR, show_bond, store_bond); static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode); static BAT_ATTR(orig_interval, S_IRUGO | S_IWUSR, show_orig_interval, store_orig_interval); static struct bat_attribute *mesh_attrs[] = { &bat_attr_aggregated_ogms, + &bat_attr_bonding, &bat_attr_vis_mode, &bat_attr_orig_interval, NULL, @@ -203,6 +254,7 @@ int sysfs_add_meshif(struct net_device *dev) /* FIXME: should be done in the general mesh setup routine as soon as we have it */ atomic_set(&bat_priv->aggregation_enabled, 1); + atomic_set(&bat_priv->bonding_enabled, 0); atomic_set(&bat_priv->vis_mode, VIS_TYPE_CLIENT_UPDATE); atomic_set(&bat_priv->orig_interval, 1000); bat_priv->primary_if = NULL; diff --git a/drivers/staging/batman-adv/hard-interface.c b/drivers/staging/batman-adv/hard-interface.c index 6939b8d4ec80..f393cc0d744e 100644 --- a/drivers/staging/batman-adv/hard-interface.c +++ b/drivers/staging/batman-adv/hard-interface.c @@ -109,7 +109,7 @@ static void set_primary_if(struct bat_priv *bat_priv, set_main_if_addr(batman_if->net_dev->dev_addr); batman_packet = (struct batman_packet *)(batman_if->packet_buff); - batman_packet->flags = 0; + batman_packet->flags = PRIMARIES_FIRST_HOP; batman_packet->ttl = TTL; /*** diff --git a/drivers/staging/batman-adv/main.h b/drivers/staging/batman-adv/main.h index 145ac5131bf8..fe5ee51357b5 100644 --- a/drivers/staging/batman-adv/main.h +++ b/drivers/staging/batman-adv/main.h @@ -59,6 +59,11 @@ #define VIS_INTERVAL 5000 /* 5 seconds */ +/* how much worse secondary interfaces may be to + * to be considered as bonding candidates */ + +#define BONDING_TQ_THRESHOLD 50 + #define MAX_AGGREGATION_BYTES 512 /* should not be bigger than 512 bytes or * change the size of * forw_packet->direct_link_flags */ diff --git a/drivers/staging/batman-adv/originator.c b/drivers/staging/batman-adv/originator.c index 1f6cbe8f8f0b..195c1ee0198a 100644 --- a/drivers/staging/batman-adv/originator.c +++ b/drivers/staging/batman-adv/originator.c @@ -226,6 +226,8 @@ static bool purge_orig_neighbors(struct orig_node *orig_node, static bool purge_orig_node(struct orig_node *orig_node) { + /* FIXME: each batman_if will be attached to a softif */ + struct bat_priv *bat_priv = netdev_priv(soft_device); struct neigh_node *best_neigh_node; if (time_after(jiffies, @@ -237,10 +239,14 @@ static bool purge_orig_node(struct orig_node *orig_node) orig_node->orig, (orig_node->last_valid / HZ)); return true; } else { - if (purge_orig_neighbors(orig_node, &best_neigh_node)) + if (purge_orig_neighbors(orig_node, &best_neigh_node)) { update_routes(orig_node, best_neigh_node, orig_node->hna_buff, orig_node->hna_buff_len); + /* update bonding candidates, we could have lost + * some candidates. */ + update_bonding_candidates(bat_priv, orig_node); + } } return false; diff --git a/drivers/staging/batman-adv/packet.h b/drivers/staging/batman-adv/packet.h index f0387babfa69..d0d35eabb03f 100644 --- a/drivers/staging/batman-adv/packet.h +++ b/drivers/staging/batman-adv/packet.h @@ -31,6 +31,7 @@ #define COMPAT_VERSION 11 #define DIRECTLINK 0x40 #define VIS_SERVER 0x20 +#define PRIMARIES_FIRST_HOP 0x10 /* ICMP message types */ #define ECHO_REPLY 0 diff --git a/drivers/staging/batman-adv/routing.c b/drivers/staging/batman-adv/routing.c index 9dbfabeb9704..6a2c2d18d3f5 100644 --- a/drivers/staging/batman-adv/routing.c +++ b/drivers/staging/batman-adv/routing.c @@ -395,11 +395,132 @@ static char count_real_packets(struct ethhdr *ethhdr, return is_duplicate; } +/* copy primary address for bonding */ +static void mark_bonding_address(struct bat_priv *bat_priv, + struct orig_node *orig_node, + struct orig_node *orig_neigh_node, + struct batman_packet *batman_packet) + +{ + /* don't care if bonding is not enabled */ + if (!atomic_read(&bat_priv->bonding_enabled)) { + orig_node->bond.candidates = 0; + return; + } + + if (batman_packet->flags & PRIMARIES_FIRST_HOP) + memcpy(orig_neigh_node->primary_addr, + orig_node->orig, ETH_ALEN); + + return; +} + +/* mark possible bond.candidates in the neighbor list */ +void update_bonding_candidates(struct bat_priv *bat_priv, + struct orig_node *orig_node) +{ + int candidates; + int interference_candidate; + int best_tq; + struct neigh_node *tmp_neigh_node, *tmp_neigh_node2; + struct neigh_node *first_candidate, *last_candidate; + + /* don't care if bonding is not enabled */ + if (!atomic_read(&bat_priv->bonding_enabled)) { + orig_node->bond.candidates = 0; + return; + } + + /* update the candidates for this originator */ + if (!orig_node->router) { + orig_node->bond.candidates = 0; + return; + } + + best_tq = orig_node->router->tq_avg; + + /* update bond.candidates */ + + candidates = 0; + + /* mark other nodes which also received "PRIMARIES FIRST HOP" packets + * as "bonding partner" */ + + /* first, zero the list */ + list_for_each_entry(tmp_neigh_node, &orig_node->neigh_list, list) { + tmp_neigh_node->next_bond_candidate = NULL; + } + + first_candidate = NULL; + last_candidate = NULL; + list_for_each_entry(tmp_neigh_node, &orig_node->neigh_list, list) { + + /* only consider if it has the same primary address ... */ + if (memcmp(orig_node->orig, + tmp_neigh_node->orig_node->primary_addr, + ETH_ALEN) != 0) + continue; + + /* ... and is good enough to be considered */ + if (tmp_neigh_node->tq_avg < best_tq - BONDING_TQ_THRESHOLD) + continue; + + /* check if we have another candidate with the same + * mac address or interface. If we do, we won't + * select this candidate because of possible interference. */ + + interference_candidate = 0; + list_for_each_entry(tmp_neigh_node2, + &orig_node->neigh_list, list) { + + if (tmp_neigh_node2 == tmp_neigh_node) + continue; + + /* we only care if the other candidate is even + * considered as candidate. */ + if (tmp_neigh_node2->next_bond_candidate == NULL) + continue; + + + if ((tmp_neigh_node->if_incoming == + tmp_neigh_node2->if_incoming) + || (memcmp(tmp_neigh_node->addr, + tmp_neigh_node2->addr, ETH_ALEN) == 0)) { + + interference_candidate = 1; + break; + } + } + /* don't care further if it is an interference candidate */ + if (interference_candidate) + continue; + + if (first_candidate == NULL) { + first_candidate = tmp_neigh_node; + tmp_neigh_node->next_bond_candidate = first_candidate; + } else + tmp_neigh_node->next_bond_candidate = last_candidate; + + last_candidate = tmp_neigh_node; + + candidates++; + } + + if (candidates > 0) { + first_candidate->next_bond_candidate = last_candidate; + orig_node->bond.selected = first_candidate; + } + + orig_node->bond.candidates = candidates; +} + void receive_bat_packet(struct ethhdr *ethhdr, struct batman_packet *batman_packet, unsigned char *hna_buff, int hna_buff_len, struct batman_if *if_incoming) { + /* FIXME: each orig_node->batman_if will be attached to a softif */ + struct bat_priv *bat_priv = netdev_priv(soft_device); struct batman_if *batman_if; struct orig_node *orig_neigh_node, *orig_node; char has_directlink_flag; @@ -577,6 +698,10 @@ void receive_bat_packet(struct ethhdr *ethhdr, update_orig(orig_node, ethhdr, batman_packet, if_incoming, hna_buff, hna_buff_len, is_duplicate); + mark_bonding_address(bat_priv, orig_node, + orig_neigh_node, batman_packet); + update_bonding_candidates(bat_priv, orig_node); + /* is single hop (direct) neighbor */ if (is_single_hop_neigh) { @@ -859,16 +984,75 @@ int recv_icmp_packet(struct sk_buff *skb) return ret; } +/* find a suitable router for this originator, and use + * bonding if possible. */ +struct neigh_node *find_router(struct orig_node *orig_node) +{ + /* FIXME: each orig_node->batman_if will be attached to a softif */ + struct bat_priv *bat_priv = netdev_priv(soft_device); + struct orig_node *primary_orig_node; + struct orig_node *router_orig; + struct neigh_node *router; + static uint8_t zero_mac[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; + + if (!orig_node) + return NULL; + + if (!orig_node->router) + return NULL; + + /* don't care if bonding is not enabled */ + if (!atomic_read(&bat_priv->bonding_enabled)) + return orig_node->router; + + router_orig = orig_node->router->orig_node; + + /* if we have something in the primary_addr, we can search + * for a potential bonding candidate. */ + if (memcmp(router_orig->primary_addr, zero_mac, ETH_ALEN) == 0) + return orig_node->router; + + /* find the orig_node which has the primary interface. might + * even be the same as our router_orig in many cases */ + + if (memcmp(router_orig->primary_addr, + router_orig->orig, ETH_ALEN) == 0) { + primary_orig_node = router_orig; + } else { + primary_orig_node = hash_find(orig_hash, + router_orig->primary_addr); + if (!primary_orig_node) + return orig_node->router; + } + + /* with less than 2 candidates, we can't do any + * bonding and prefer the original router. */ + + if (primary_orig_node->bond.candidates < 2) + return orig_node->router; + + router = primary_orig_node->bond.selected; + + /* sanity check - this should never happen. */ + if (!router) + return orig_node->router; + + /* select the next bonding partner ... */ + primary_orig_node->bond.selected = router->next_bond_candidate; + + return router; +} + int recv_unicast_packet(struct sk_buff *skb) { struct unicast_packet *unicast_packet; struct orig_node *orig_node; + struct neigh_node *router; struct ethhdr *ethhdr; struct batman_if *batman_if; struct sk_buff *skb_old; uint8_t dstaddr[ETH_ALEN]; int hdr_size = sizeof(struct unicast_packet); - int ret; unsigned long flags; /* drop packet if it has not necessary minimum size */ @@ -906,42 +1090,44 @@ int recv_unicast_packet(struct sk_buff *skb) return NET_RX_DROP; } - ret = NET_RX_DROP; /* get routing information */ spin_lock_irqsave(&orig_hash_lock, flags); orig_node = ((struct orig_node *) hash_find(orig_hash, unicast_packet->dest)); - if ((orig_node != NULL) && - (orig_node->router != NULL)) { + router = find_router(orig_node); - /* don't lock while sending the packets ... we therefore - * copy the required data before sending */ - batman_if = orig_node->router->if_incoming; - memcpy(dstaddr, orig_node->router->addr, ETH_ALEN); + if (!router) { spin_unlock_irqrestore(&orig_hash_lock, flags); + return NET_RX_DROP; + } - /* create a copy of the skb, if needed, to modify it. */ - if (!skb_clone_writable(skb, sizeof(struct unicast_packet))) { - skb_old = skb; - skb = skb_copy(skb, GFP_ATOMIC); - if (!skb) - return NET_RX_DROP; - unicast_packet = (struct unicast_packet *)skb->data; - ethhdr = (struct ethhdr *)skb_mac_header(skb); - kfree_skb(skb_old); - } - /* decrement ttl */ - unicast_packet->ttl--; + /* don't lock while sending the packets ... we therefore + * copy the required data before sending */ - /* route it */ - send_skb_packet(skb, batman_if, dstaddr); - ret = NET_RX_SUCCESS; + batman_if = router->if_incoming; + memcpy(dstaddr, router->addr, ETH_ALEN); - } else - spin_unlock_irqrestore(&orig_hash_lock, flags); + spin_unlock_irqrestore(&orig_hash_lock, flags); - return ret; + /* create a copy of the skb, if needed, to modify it. */ + if (!skb_clone_writable(skb, sizeof(struct unicast_packet))) { + skb_old = skb; + skb = skb_copy(skb, GFP_ATOMIC); + if (!skb) + return NET_RX_DROP; + unicast_packet = (struct unicast_packet *) skb->data; + ethhdr = (struct ethhdr *)skb_mac_header(skb); + kfree_skb(skb_old); + } + + /* decrement ttl */ + unicast_packet->ttl--; + + /* route it */ + send_skb_packet(skb, batman_if, dstaddr); + + return NET_RX_SUCCESS; } int recv_bcast_packet(struct sk_buff *skb) diff --git a/drivers/staging/batman-adv/routing.h b/drivers/staging/batman-adv/routing.h index c6850d26779c..0e33d227cf19 100644 --- a/drivers/staging/batman-adv/routing.h +++ b/drivers/staging/batman-adv/routing.h @@ -35,3 +35,6 @@ int recv_bcast_packet(struct sk_buff *skb); int recv_vis_packet(struct sk_buff *skb); int recv_bat_packet(struct sk_buff *skb, struct batman_if *batman_if); +struct neigh_node *find_router(struct orig_node *orig_node); +void update_bonding_candidates(struct bat_priv *bat_priv, + struct orig_node *orig_node); diff --git a/drivers/staging/batman-adv/send.c b/drivers/staging/batman-adv/send.c index f2653dd37c07..e61a62c6cb9a 100644 --- a/drivers/staging/batman-adv/send.c +++ b/drivers/staging/batman-adv/send.c @@ -287,7 +287,7 @@ void schedule_own_packet(struct batman_if *batman_if) htonl((uint32_t)atomic_read(&batman_if->seqno)); if (vis_server == VIS_TYPE_SERVER_SYNC) - batman_packet->flags = VIS_SERVER; + batman_packet->flags |= VIS_SERVER; else batman_packet->flags &= ~VIS_SERVER; @@ -349,6 +349,8 @@ void schedule_forward_packet(struct orig_node *orig_node, batman_packet->seqno = htonl(batman_packet->seqno); + /* switch of primaries first hop flag when forwarding */ + batman_packet->flags &= ~PRIMARIES_FIRST_HOP; if (directlink) batman_packet->flags |= DIRECTLINK; else diff --git a/drivers/staging/batman-adv/soft-interface.c b/drivers/staging/batman-adv/soft-interface.c index ce789a755739..37fd56565ca5 100644 --- a/drivers/staging/batman-adv/soft-interface.c +++ b/drivers/staging/batman-adv/soft-interface.c @@ -22,6 +22,7 @@ #include "main.h" #include "soft-interface.h" #include "hard-interface.h" +#include "routing.h" #include "send.h" #include "translation-table.h" #include "types.h" @@ -129,6 +130,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev) struct unicast_packet *unicast_packet; struct bcast_packet *bcast_packet; struct orig_node *orig_node; + struct neigh_node *router; struct ethhdr *ethhdr = (struct ethhdr *)skb->data; struct bat_priv *priv = netdev_priv(dev); struct batman_if *batman_if; @@ -186,38 +188,36 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev) if (!orig_node) orig_node = transtable_search(ethhdr->h_dest); - if ((orig_node) && - (orig_node->router)) { - struct neigh_node *router = orig_node->router; + router = find_router(orig_node); - if (my_skb_push(skb, sizeof(struct unicast_packet)) < 0) - goto unlock; - - unicast_packet = (struct unicast_packet *)skb->data; - - unicast_packet->version = COMPAT_VERSION; - /* batman packet type: unicast */ - unicast_packet->packet_type = BAT_UNICAST; - /* set unicast ttl */ - unicast_packet->ttl = TTL; - /* copy the destination for faster routing */ - memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN); - - /* net_dev won't be available when not active */ - if (router->if_incoming->if_status != IF_ACTIVE) - goto unlock; - - /* don't lock while sending the packets ... we therefore - * copy the required data before sending */ - - batman_if = router->if_incoming; - memcpy(dstaddr, router->addr, ETH_ALEN); - spin_unlock_irqrestore(&orig_hash_lock, flags); - - send_skb_packet(skb, batman_if, dstaddr); - } else { + if (!router) goto unlock; - } + + /* don't lock while sending the packets ... we therefore + * copy the required data before sending */ + + batman_if = router->if_incoming; + memcpy(dstaddr, router->addr, ETH_ALEN); + + spin_unlock_irqrestore(&orig_hash_lock, flags); + + if (batman_if->if_status != IF_ACTIVE) + goto dropped; + + if (my_skb_push(skb, sizeof(struct unicast_packet)) < 0) + goto dropped; + + unicast_packet = (struct unicast_packet *)skb->data; + + unicast_packet->version = COMPAT_VERSION; + /* batman packet type: unicast */ + unicast_packet->packet_type = BAT_UNICAST; + /* set unicast ttl */ + unicast_packet->ttl = TTL; + /* copy the destination for faster routing */ + memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN); + + send_skb_packet(skb, batman_if, dstaddr); } priv->stats.tx_packets++; diff --git a/drivers/staging/batman-adv/types.h b/drivers/staging/batman-adv/types.h index d0af4893686a..84c3f43c4ac9 100644 --- a/drivers/staging/batman-adv/types.h +++ b/drivers/staging/batman-adv/types.h @@ -52,6 +52,7 @@ struct batman_if { /** * orig_node - structure for orig_list maintaining nodes of mesh + * @primary_addr: hosts primary interface address * @last_valid: when last packet from this node was received * @bcast_seqno_reset: time when the broadcast seqno window was reset * @batman_seqno_reset: time when the batman seqno window was reset @@ -59,9 +60,13 @@ struct batman_if { * @last_real_seqno: last and best known squence number * @last_ttl: ttl of last received packet * @last_bcast_seqno: last broadcast sequence number received by this host + * + * @candidates: how many candidates are available + * @selected: next bonding candidate */ struct orig_node { uint8_t orig[ETH_ALEN]; + uint8_t primary_addr[ETH_ALEN]; struct neigh_node *router; TYPE_OF_WORD *bcast_own; uint8_t *bcast_own_sum; @@ -78,6 +83,10 @@ struct orig_node { TYPE_OF_WORD bcast_bits[NUM_WORDS]; uint32_t last_bcast_seqno; struct list_head neigh_list; + struct { + uint8_t candidates; + struct neigh_node *selected; + } bond; }; /** @@ -92,6 +101,7 @@ struct neigh_node { uint8_t tq_index; uint8_t tq_avg; uint8_t last_ttl; + struct neigh_node *next_bond_candidate; unsigned long last_valid; TYPE_OF_WORD real_bits[NUM_WORDS]; struct orig_node *orig_node; @@ -101,6 +111,7 @@ struct neigh_node { struct bat_priv { struct net_device_stats stats; atomic_t aggregation_enabled; + atomic_t bonding_enabled; atomic_t vis_mode; atomic_t orig_interval; char num_ifaces; From 11f79decfd4e33e29694075a859f529e6d4321ad Mon Sep 17 00:00:00 2001 From: Simon Wunderlich Date: Tue, 22 Jun 2010 01:25:53 +0200 Subject: [PATCH 136/523] Staging: batman-adv: bonding and interface alternating This patch adds interface alternating to the new bonding feature. By default, we now try to avoid forwarding packets on the receiving interface, instead choosing alternative interfaces. This feature works only on nodes which have multiple interfaces connected to the mesh. This approach should reduce problems of the half-duplex nature of WiFi Hardware and thus increase performance. Signed-off-by: Simon Wunderlich Acked-by: Marek Lindner [sven.eckelmann@gmx.de: Rework on top of current version] Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/batman-adv/hard-interface.c | 2 +- drivers/staging/batman-adv/routing.c | 72 ++++++++++++++------- drivers/staging/batman-adv/routing.h | 5 +- drivers/staging/batman-adv/soft-interface.c | 2 +- 4 files changed, 52 insertions(+), 29 deletions(-) diff --git a/drivers/staging/batman-adv/hard-interface.c b/drivers/staging/batman-adv/hard-interface.c index f393cc0d744e..5f8213786eaf 100644 --- a/drivers/staging/batman-adv/hard-interface.c +++ b/drivers/staging/batman-adv/hard-interface.c @@ -512,7 +512,7 @@ int batman_skb_recv(struct sk_buff *skb, struct net_device *dev, /* unicast packet */ case BAT_UNICAST: - ret = recv_unicast_packet(skb); + ret = recv_unicast_packet(skb, batman_if); break; /* broadcast packet */ diff --git a/drivers/staging/batman-adv/routing.c b/drivers/staging/batman-adv/routing.c index 6a2c2d18d3f5..048795e319a8 100644 --- a/drivers/staging/batman-adv/routing.c +++ b/drivers/staging/batman-adv/routing.c @@ -402,12 +402,6 @@ static void mark_bonding_address(struct bat_priv *bat_priv, struct batman_packet *batman_packet) { - /* don't care if bonding is not enabled */ - if (!atomic_read(&bat_priv->bonding_enabled)) { - orig_node->bond.candidates = 0; - return; - } - if (batman_packet->flags & PRIMARIES_FIRST_HOP) memcpy(orig_neigh_node->primary_addr, orig_node->orig, ETH_ALEN); @@ -425,12 +419,6 @@ void update_bonding_candidates(struct bat_priv *bat_priv, struct neigh_node *tmp_neigh_node, *tmp_neigh_node2; struct neigh_node *first_candidate, *last_candidate; - /* don't care if bonding is not enabled */ - if (!atomic_read(&bat_priv->bonding_enabled)) { - orig_node->bond.candidates = 0; - return; - } - /* update the candidates for this originator */ if (!orig_node->router) { orig_node->bond.candidates = 0; @@ -986,14 +974,16 @@ int recv_icmp_packet(struct sk_buff *skb) /* find a suitable router for this originator, and use * bonding if possible. */ -struct neigh_node *find_router(struct orig_node *orig_node) +struct neigh_node *find_router(struct orig_node *orig_node, + struct batman_if *recv_if) { /* FIXME: each orig_node->batman_if will be attached to a softif */ struct bat_priv *bat_priv = netdev_priv(soft_device); struct orig_node *primary_orig_node; struct orig_node *router_orig; - struct neigh_node *router; + struct neigh_node *router, *first_candidate, *best_router; static uint8_t zero_mac[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; + int bonding_enabled; if (!orig_node) return NULL; @@ -1001,9 +991,12 @@ struct neigh_node *find_router(struct orig_node *orig_node) if (!orig_node->router) return NULL; - /* don't care if bonding is not enabled */ - if (!atomic_read(&bat_priv->bonding_enabled)) - return orig_node->router; + /* without bonding, the first node should + * always choose the default router. */ + + bonding_enabled = atomic_read(&bat_priv->bonding_enabled); + if (!bonding_enabled && (recv_if == NULL)) + return orig_node->router; router_orig = orig_node->router->orig_node; @@ -1031,19 +1024,48 @@ struct neigh_node *find_router(struct orig_node *orig_node) if (primary_orig_node->bond.candidates < 2) return orig_node->router; - router = primary_orig_node->bond.selected; - /* sanity check - this should never happen. */ - if (!router) - return orig_node->router; + /* all nodes between should choose a candidate which + * is is not on the interface where the packet came + * in. */ + first_candidate = primary_orig_node->bond.selected; + router = first_candidate; - /* select the next bonding partner ... */ - primary_orig_node->bond.selected = router->next_bond_candidate; + if (bonding_enabled) { + /* in the bonding case, send the packets in a round + * robin fashion over the remaining interfaces. */ + do { + /* recv_if == NULL on the first node. */ + if (router->if_incoming != recv_if) + break; + + router = router->next_bond_candidate; + } while (router != first_candidate); + + primary_orig_node->bond.selected = router->next_bond_candidate; + + } else { + /* if bonding is disabled, use the best of the + * remaining candidates which are not using + * this interface. */ + best_router = first_candidate; + + do { + /* recv_if == NULL on the first node. */ + if ((router->if_incoming != recv_if) && + (router->tq_avg > best_router->tq_avg)) + best_router = router; + + router = router->next_bond_candidate; + } while (router != first_candidate); + + router = best_router; + } return router; } -int recv_unicast_packet(struct sk_buff *skb) +int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if) { struct unicast_packet *unicast_packet; struct orig_node *orig_node; @@ -1095,7 +1117,7 @@ int recv_unicast_packet(struct sk_buff *skb) orig_node = ((struct orig_node *) hash_find(orig_hash, unicast_packet->dest)); - router = find_router(orig_node); + router = find_router(orig_node, recv_if); if (!router) { spin_unlock_irqrestore(&orig_hash_lock, flags); diff --git a/drivers/staging/batman-adv/routing.h b/drivers/staging/batman-adv/routing.h index 0e33d227cf19..43387a2a3324 100644 --- a/drivers/staging/batman-adv/routing.h +++ b/drivers/staging/batman-adv/routing.h @@ -30,11 +30,12 @@ void update_routes(struct orig_node *orig_node, struct neigh_node *neigh_node, unsigned char *hna_buff, int hna_buff_len); int recv_icmp_packet(struct sk_buff *skb); -int recv_unicast_packet(struct sk_buff *skb); +int recv_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if); int recv_bcast_packet(struct sk_buff *skb); int recv_vis_packet(struct sk_buff *skb); int recv_bat_packet(struct sk_buff *skb, struct batman_if *batman_if); -struct neigh_node *find_router(struct orig_node *orig_node); +struct neigh_node *find_router(struct orig_node *orig_node, + struct batman_if *recv_if); void update_bonding_candidates(struct bat_priv *bat_priv, struct orig_node *orig_node); diff --git a/drivers/staging/batman-adv/soft-interface.c b/drivers/staging/batman-adv/soft-interface.c index 37fd56565ca5..ef7860d53a5c 100644 --- a/drivers/staging/batman-adv/soft-interface.c +++ b/drivers/staging/batman-adv/soft-interface.c @@ -188,7 +188,7 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev) if (!orig_node) orig_node = transtable_search(ethhdr->h_dest); - router = find_router(orig_node); + router = find_router(orig_node, NULL); if (!router) goto unlock; From e4cb3720bfcf8b57b4c5a2adbbb6b5967af53432 Mon Sep 17 00:00:00 2001 From: Daniel Seither Date: Tue, 22 Jun 2010 01:25:54 +0200 Subject: [PATCH 137/523] Staging: batman-adv: record route for ICMP messages The standard layer 3 ping utility can use the record route (RR) option of IP to collect route data for sent ping messages (ping -R). This patch introduces comparable functionality for batman-adv ICMP messages. The patch adds a second batman ICMP packet format (icmp_packet_rr) such that up to 17 MAC addresses can be recorded (sufficient for up to 8 hops per direction). When no RR is wanted, the old icmp_packet without the RR overhead can be sent. Signed-off-by: Daniel Seither Signed-off-by: Marek Lindner [sven.eckelmann@gmx.de: Rework on top of current version] Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/batman-adv/icmp_socket.c | 45 ++++++++++++++---------- drivers/staging/batman-adv/icmp_socket.h | 3 +- drivers/staging/batman-adv/packet.h | 17 +++++++++ drivers/staging/batman-adv/routing.c | 43 ++++++++++++++-------- drivers/staging/batman-adv/types.h | 3 +- 5 files changed, 76 insertions(+), 35 deletions(-) diff --git a/drivers/staging/batman-adv/icmp_socket.c b/drivers/staging/batman-adv/icmp_socket.c index d4411cbe350c..08a5f7b7b11b 100644 --- a/drivers/staging/batman-adv/icmp_socket.c +++ b/drivers/staging/batman-adv/icmp_socket.c @@ -32,7 +32,8 @@ static struct socket_client *socket_client_hash[256]; static void bat_socket_add_packet(struct socket_client *socket_client, - struct icmp_packet *icmp_packet); + struct icmp_packet_rr *icmp_packet, + size_t icmp_len); void bat_socket_init(void) { @@ -110,6 +111,7 @@ static ssize_t bat_socket_read(struct file *file, char __user *buf, struct socket_client *socket_client = (struct socket_client *)file->private_data; struct socket_packet *socket_packet; + size_t packet_len; int error; unsigned long flags; @@ -138,14 +140,15 @@ static ssize_t bat_socket_read(struct file *file, char __user *buf, spin_unlock_irqrestore(&socket_client->lock, flags); error = __copy_to_user(buf, &socket_packet->icmp_packet, - sizeof(struct icmp_packet)); + socket_packet->icmp_len); + packet_len = socket_packet->icmp_len; kfree(socket_packet); if (error) return -EFAULT; - return sizeof(struct icmp_packet); + return packet_len; } static ssize_t bat_socket_write(struct file *file, const char __user *buff, @@ -153,9 +156,10 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, { struct socket_client *socket_client = (struct socket_client *)file->private_data; - struct icmp_packet icmp_packet; + struct icmp_packet_rr icmp_packet; struct orig_node *orig_node; struct batman_if *batman_if; + size_t packet_len = sizeof(struct icmp_packet); uint8_t dstaddr[ETH_ALEN]; unsigned long flags; @@ -166,10 +170,13 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, return -EINVAL; } - if (!access_ok(VERIFY_READ, buff, sizeof(struct icmp_packet))) + if (len >= sizeof(struct icmp_packet_rr)) + packet_len = sizeof(struct icmp_packet_rr); + + if (!access_ok(VERIFY_READ, buff, packet_len)) return -EFAULT; - if (__copy_from_user(&icmp_packet, buff, sizeof(icmp_packet))) + if (__copy_from_user(&icmp_packet, buff, packet_len)) return -EFAULT; if (icmp_packet.packet_type != BAT_ICMP) { @@ -191,7 +198,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, if (icmp_packet.version != COMPAT_VERSION) { icmp_packet.msg_type = PARAMETER_PROBLEM; icmp_packet.ttl = COMPAT_VERSION; - bat_socket_add_packet(socket_client, &icmp_packet); + bat_socket_add_packet(socket_client, &icmp_packet, packet_len); goto out; } @@ -218,13 +225,13 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff, if (batman_if->if_status != IF_ACTIVE) goto dst_unreach; - memcpy(icmp_packet.orig, - batman_if->net_dev->dev_addr, - ETH_ALEN); + memcpy(icmp_packet.orig, batman_if->net_dev->dev_addr, ETH_ALEN); + + if (packet_len == sizeof(struct icmp_packet_rr)) + memcpy(icmp_packet.rr, batman_if->net_dev->dev_addr, ETH_ALEN); send_raw_packet((unsigned char *)&icmp_packet, - sizeof(struct icmp_packet), - batman_if, dstaddr); + packet_len, batman_if, dstaddr); goto out; @@ -232,7 +239,7 @@ unlock: spin_unlock_irqrestore(&orig_hash_lock, flags); dst_unreach: icmp_packet.msg_type = DESTINATION_UNREACHABLE; - bat_socket_add_packet(socket_client, &icmp_packet); + bat_socket_add_packet(socket_client, &icmp_packet, packet_len); out: return len; } @@ -278,7 +285,8 @@ err: } static void bat_socket_add_packet(struct socket_client *socket_client, - struct icmp_packet *icmp_packet) + struct icmp_packet_rr *icmp_packet, + size_t icmp_len) { struct socket_packet *socket_packet; unsigned long flags; @@ -289,8 +297,8 @@ static void bat_socket_add_packet(struct socket_client *socket_client, return; INIT_LIST_HEAD(&socket_packet->list); - memcpy(&socket_packet->icmp_packet, icmp_packet, - sizeof(struct icmp_packet)); + memcpy(&socket_packet->icmp_packet, icmp_packet, icmp_len); + socket_packet->icmp_len = icmp_len; spin_lock_irqsave(&socket_client->lock, flags); @@ -319,10 +327,11 @@ static void bat_socket_add_packet(struct socket_client *socket_client, wake_up(&socket_client->queue_wait); } -void bat_socket_receive_packet(struct icmp_packet *icmp_packet) +void bat_socket_receive_packet(struct icmp_packet_rr *icmp_packet, + size_t icmp_len) { struct socket_client *hash = socket_client_hash[icmp_packet->uid]; if (hash) - bat_socket_add_packet(hash, icmp_packet); + bat_socket_add_packet(hash, icmp_packet, icmp_len); } diff --git a/drivers/staging/batman-adv/icmp_socket.h b/drivers/staging/batman-adv/icmp_socket.h index 5ad73daa08ca..2dc954ac91ba 100644 --- a/drivers/staging/batman-adv/icmp_socket.h +++ b/drivers/staging/batman-adv/icmp_socket.h @@ -25,4 +25,5 @@ void bat_socket_init(void); int bat_socket_setup(struct bat_priv *bat_priv); -void bat_socket_receive_packet(struct icmp_packet *icmp_packet); +void bat_socket_receive_packet(struct icmp_packet_rr *icmp_packet, + size_t icmp_len); diff --git a/drivers/staging/batman-adv/packet.h b/drivers/staging/batman-adv/packet.h index d0d35eabb03f..8a044186c20f 100644 --- a/drivers/staging/batman-adv/packet.h +++ b/drivers/staging/batman-adv/packet.h @@ -69,6 +69,23 @@ struct icmp_packet { uint8_t uid; } __attribute__((packed)); +#define BAT_RR_LEN 16 + +/* icmp_packet_rr must start with all fields from imcp_packet + as this is assumed by code that handles ICMP packets */ +struct icmp_packet_rr { + uint8_t packet_type; + uint8_t version; /* batman version field */ + uint8_t msg_type; /* see ICMP message types above */ + uint8_t ttl; + uint8_t dst[6]; + uint8_t orig[6]; + uint16_t seqno; + uint8_t uid; + uint8_t rr_cur; + uint8_t rr[BAT_RR_LEN][ETH_ALEN]; +} __attribute__((packed)); + struct unicast_packet { uint8_t packet_type; uint8_t version; /* batman version field */ diff --git a/drivers/staging/batman-adv/routing.c b/drivers/staging/batman-adv/routing.c index 048795e319a8..acd8f745ebc0 100644 --- a/drivers/staging/batman-adv/routing.c +++ b/drivers/staging/batman-adv/routing.c @@ -765,10 +765,10 @@ int recv_bat_packet(struct sk_buff *skb, return NET_RX_SUCCESS; } -static int recv_my_icmp_packet(struct sk_buff *skb) +static int recv_my_icmp_packet(struct sk_buff *skb, size_t icmp_len) { struct orig_node *orig_node; - struct icmp_packet *icmp_packet; + struct icmp_packet_rr *icmp_packet; struct ethhdr *ethhdr; struct sk_buff *skb_old; struct batman_if *batman_if; @@ -776,12 +776,12 @@ static int recv_my_icmp_packet(struct sk_buff *skb) unsigned long flags; uint8_t dstaddr[ETH_ALEN]; - icmp_packet = (struct icmp_packet *)skb->data; + icmp_packet = (struct icmp_packet_rr *)skb->data; ethhdr = (struct ethhdr *)skb_mac_header(skb); /* add data to device queue */ if (icmp_packet->msg_type != ECHO_REQUEST) { - bat_socket_receive_packet(icmp_packet); + bat_socket_receive_packet(icmp_packet, icmp_len); return NET_RX_DROP; } @@ -803,13 +803,12 @@ static int recv_my_icmp_packet(struct sk_buff *skb) /* create a copy of the skb, if needed, to modify it. */ skb_old = NULL; - if (!skb_clone_writable(skb, sizeof(struct icmp_packet))) { + if (!skb_clone_writable(skb, icmp_len)) { skb_old = skb; skb = skb_copy(skb, GFP_ATOMIC); if (!skb) return NET_RX_DROP; - - icmp_packet = (struct icmp_packet *)skb->data; + icmp_packet = (struct icmp_packet_rr *)skb->data; ethhdr = (struct ethhdr *)skb_mac_header(skb); kfree_skb(skb_old); } @@ -828,7 +827,7 @@ static int recv_my_icmp_packet(struct sk_buff *skb) return ret; } -static int recv_icmp_ttl_exceeded(struct sk_buff *skb) +static int recv_icmp_ttl_exceeded(struct sk_buff *skb, size_t icmp_len) { struct orig_node *orig_node; struct icmp_packet *icmp_packet; @@ -867,7 +866,7 @@ static int recv_icmp_ttl_exceeded(struct sk_buff *skb) spin_unlock_irqrestore(&orig_hash_lock, flags); /* create a copy of the skb, if needed, to modify it. */ - if (!skb_clone_writable(skb, sizeof(struct icmp_packet))) { + if (!skb_clone_writable(skb, icmp_len)) { skb_old = skb; skb = skb_copy(skb, GFP_ATOMIC); if (!skb) @@ -894,7 +893,7 @@ static int recv_icmp_ttl_exceeded(struct sk_buff *skb) int recv_icmp_packet(struct sk_buff *skb) { - struct icmp_packet *icmp_packet; + struct icmp_packet_rr *icmp_packet; struct ethhdr *ethhdr; struct orig_node *orig_node; struct sk_buff *skb_old; @@ -904,6 +903,12 @@ int recv_icmp_packet(struct sk_buff *skb) unsigned long flags; uint8_t dstaddr[ETH_ALEN]; + /** + * we truncate all incoming icmp packets if they don't match our size + */ + if (skb_headlen(skb) >= sizeof(struct icmp_packet_rr)) + hdr_size = sizeof(struct icmp_packet_rr); + /* drop packet if it has not necessary minimum size */ if (skb_headlen(skb) < hdr_size) return NET_RX_DROP; @@ -922,15 +927,23 @@ int recv_icmp_packet(struct sk_buff *skb) if (!is_my_mac(ethhdr->h_dest)) return NET_RX_DROP; - icmp_packet = (struct icmp_packet *)skb->data; + icmp_packet = (struct icmp_packet_rr *)skb->data; + + /* add record route information if not full */ + if ((hdr_size == sizeof(struct icmp_packet_rr)) && + (icmp_packet->rr_cur < BAT_RR_LEN)) { + memcpy(&(icmp_packet->rr[icmp_packet->rr_cur]), + ethhdr->h_dest, ETH_ALEN); + icmp_packet->rr_cur++; + } /* packet for me */ if (is_my_mac(icmp_packet->dst)) - return recv_my_icmp_packet(skb); + return recv_my_icmp_packet(skb, hdr_size); /* TTL exceeded */ if (icmp_packet->ttl < 2) - return recv_icmp_ttl_exceeded(skb); + return recv_icmp_ttl_exceeded(skb, hdr_size); ret = NET_RX_DROP; @@ -949,12 +962,12 @@ int recv_icmp_packet(struct sk_buff *skb) spin_unlock_irqrestore(&orig_hash_lock, flags); /* create a copy of the skb, if needed, to modify it. */ - if (!skb_clone_writable(skb, sizeof(struct icmp_packet))) { + if (!skb_clone_writable(skb, hdr_size)) { skb_old = skb; skb = skb_copy(skb, GFP_ATOMIC); if (!skb) return NET_RX_DROP; - icmp_packet = (struct icmp_packet *)skb->data; + icmp_packet = (struct icmp_packet_rr *)skb->data; ethhdr = (struct ethhdr *)skb_mac_header(skb); kfree_skb(skb_old); } diff --git a/drivers/staging/batman-adv/types.h b/drivers/staging/batman-adv/types.h index 84c3f43c4ac9..e1fc4605772f 100644 --- a/drivers/staging/batman-adv/types.h +++ b/drivers/staging/batman-adv/types.h @@ -130,7 +130,8 @@ struct socket_client { struct socket_packet { struct list_head list; - struct icmp_packet icmp_packet; + size_t icmp_len; + struct icmp_packet_rr icmp_packet; }; struct hna_local_entry { From acf82e050150490e7a2d795594b2c6cb54243bfd Mon Sep 17 00:00:00 2001 From: Bill Pemberton Date: Thu, 17 Jun 2010 13:10:33 -0400 Subject: [PATCH 138/523] Staging: xgifb: use %lx instead of %x in printk format This fixes compiler warning format '%x' expects type 'unsigned int', but argument 2 has type 'long unsigned int' Signed-off-by: Bill Pemberton Cc: Arnaud Patard Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index 68bc1d839ad6..4d8dadd17d93 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -3510,7 +3510,8 @@ int __devinit xgifb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) XGIfb_registered = 1; - printk(KERN_INFO "XGIfb: Installed XGIFB_GET_INFO ioctl (%x)\n", XGIFB_GET_INFO); + printk(KERN_INFO "XGIfb: Installed XGIFB_GET_INFO ioctl (%lx)\n", + XGIFB_GET_INFO); /* printk(KERN_INFO "XGIfb: 2D acceleration is %s, scrolling mode %s\n", XGIfb_accel ? "enabled" : "disabled", From 23aada9cc34759352e9a82c1a157d0e1ba3712bc Mon Sep 17 00:00:00 2001 From: Bill Pemberton Date: Thu, 17 Jun 2010 13:10:34 -0400 Subject: [PATCH 139/523] Staging: xgifb: remove use of LINUX_VERSION_CODE Remove ifdefs that check LINUX_VERSION_CODE as this is not needed in the staging tree. Signed-off-by: Bill Pemberton Cc: Arnaud Patard Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_accel.c | 212 ---------------------------- drivers/staging/xgifb/XGI_accel.h | 14 +- drivers/staging/xgifb/XGI_main.h | 113 +-------------- drivers/staging/xgifb/XGI_main_26.c | 29 +--- drivers/staging/xgifb/vb_ext.c | 5 - drivers/staging/xgifb/vb_setmode.c | 5 - 6 files changed, 3 insertions(+), 375 deletions(-) diff --git a/drivers/staging/xgifb/XGI_accel.c b/drivers/staging/xgifb/XGI_accel.c index 86ec3421942f..24f454d93772 100644 --- a/drivers/staging/xgifb/XGI_accel.c +++ b/drivers/staging/xgifb/XGI_accel.c @@ -37,27 +37,12 @@ #include #include -/* -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -#include -#else -#include