diff options
author | Stephen Rothwell <sfr@canb.auug.org.au> | 2010-05-03 14:17:49 +1000 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2010-05-03 14:17:49 +1000 |
commit | 3c59b4691587b8977cc77ecf07985758a2ba0d97 (patch) | |
tree | 9d75478c8881667d94d5be0a5f6e55d294dde56e | |
parent | 7f1e428f9030b9703f27ef571609d8e17a06e323 (diff) | |
parent | bed46a81dd0846619c8af6bdd38f8fa59ae05fa0 (diff) |
Merge remote branch 'staging-next/staging-next'
Conflicts:
drivers/staging/arlan/arlan-main.c
drivers/staging/comedi/drivers/cb_das16_cs.c
drivers/staging/cx25821/cx25821-alsa.c
drivers/staging/dt3155/dt3155_drv.c
drivers/staging/netwave/netwave_cs.c
418 files changed, 32622 insertions, 16228 deletions
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 5589616082e7..336551eafd28 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -59,8 +59,6 @@ source "drivers/staging/wlan-ng/Kconfig" source "drivers/staging/echo/Kconfig" -source "drivers/staging/poch/Kconfig" - source "drivers/staging/otus/Kconfig" source "drivers/staging/rt2860/Kconfig" @@ -113,6 +111,8 @@ source "drivers/staging/vme/Kconfig" source "drivers/staging/rar_register/Kconfig" +source "drivers/staging/memrar/Kconfig" + source "drivers/staging/sep/Kconfig" source "drivers/staging/iio/Kconfig" @@ -139,7 +139,13 @@ source "drivers/staging/sm7xx/Kconfig" source "drivers/staging/dt3155/Kconfig" +source "drivers/staging/dt3155v4l/Kconfig" + source "drivers/staging/crystalhd/Kconfig" +source "drivers/staging/cxt1e1/Kconfig" + +source "drivers/staging/ti-st/Kconfig" + endif # !STAGING_EXCLUDE_BUILD endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index ec45d4bb8c11..c26fd5ee445f 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -12,7 +12,6 @@ obj-$(CONFIG_USB_IP_COMMON) += usbip/ obj-$(CONFIG_W35UND) += winbond/ obj-$(CONFIG_PRISM2_USB) += wlan-ng/ obj-$(CONFIG_ECHO) += echo/ -obj-$(CONFIG_POCH) += poch/ obj-$(CONFIG_OTUS) += otus/ obj-$(CONFIG_RT2860) += rt2860/ obj-$(CONFIG_RT2870) += rt2870/ @@ -37,6 +36,7 @@ obj-$(CONFIG_FB_UDL) += udlfb/ obj-$(CONFIG_HYPERV) += hv/ obj-$(CONFIG_VME_BUS) += vme/ 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/ @@ -51,4 +51,7 @@ obj-$(CONFIG_PCMCIA_WAVELAN) += wavelan/ obj-$(CONFIG_PCMCIA_NETWAVE) += netwave/ obj-$(CONFIG_FB_SM7XX) += sm7xx/ obj-$(CONFIG_DT3155) += dt3155/ +obj-$(CONFIG_VIDEO_DT3155) += dt3155v4l/ obj-$(CONFIG_CRYSTALHD) += crystalhd/ +obj-$(CONFIG_CXT1E1) += cxt1e1/ +obj-$(CONFIG_TI_ST) += ti-st/ diff --git a/drivers/staging/adis16255/Kconfig b/drivers/staging/adis16255/Kconfig new file mode 100644 index 000000000000..3952cf95b783 --- /dev/null +++ b/drivers/staging/adis16255/Kconfig @@ -0,0 +1,9 @@ +config ADIS16255 + tristate "Ananlog Devices ADIS16250/16255" + depends on SPI && SYSFS + ---help--- + If you say yes here you get support for the Analog Devices + ADIS16250/16255 Low Power Gyroscope. + + This driver can also be built as a module. If so, the module + will be called adis16255. diff --git a/drivers/staging/adis16255/Makefile b/drivers/staging/adis16255/Makefile new file mode 100644 index 000000000000..3f8b1f06b194 --- /dev/null +++ b/drivers/staging/adis16255/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_ADIS16255) +údis16255.o diff --git a/drivers/staging/adis16255/TODO b/drivers/staging/adis16255/TODO new file mode 100644 index 000000000000..31e4ac3bdb61 --- /dev/null +++ b/drivers/staging/adis16255/TODO @@ -0,0 +1,8 @@ +* sample rate changeable or at least readable from sysfs +* reset gyroscope +* encapsulate adis_init and adis_turn_off +* AD_CHK deletion +* chip selftest in adis_init +* reduce kernel messages to reasonable amount + +Contact: Matthias Brugger <mensch0815@gmail.com> diff --git a/drivers/staging/adis16255/adis16255.c b/drivers/staging/adis16255/adis16255.c new file mode 100644 index 000000000000..8d110692a030 --- /dev/null +++ b/drivers/staging/adis16255/adis16255.c @@ -0,0 +1,396 @@ +/* + * Analog Devices ADIS16250/ADIS16255 Low Power Gyroscope + * + * Written by: Matthias Brugger <m_brugger@web.de> + * + * Copyright (C) 2010 Fraunhofer Institute for Integrated Circuits + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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., + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <linux/init.h> +#include <linux/module.h> +#include <linux/device.h> +#include <linux/list.h> +#include <linux/errno.h> +#include <linux/mutex.h> +#include <linux/slab.h> + +#include <linux/interrupt.h> +#include <linux/sysfs.h> +#include <linux/stat.h> +#include <linux/delay.h> + +#include <linux/gpio.h> + +#include <linux/spi/spi.h> +#include <linux/workqueue.h> + +#include "adis16255.h" + +#define ADIS_STATUS 0x3d +#define ADIS_SMPL_PRD_MSB 0x37 +#define ADIS_SMPL_PRD_LSB 0x36 +#define ADIS_MSC_CTRL_MSB 0x35 +#define ADIS_MSC_CTRL_LSB 0x34 +#define ADIS_GPIO_CTRL 0x33 +#define ADIS_ALM_SMPL1 0x25 +#define ADIS_ALM_MAG1 0x21 +#define ADIS_GYRO_SCALE 0x17 +#define ADIS_GYRO_OUT 0x05 +#define ADIS_SUPPLY_OUT 0x03 +#define ADIS_ENDURANCE 0x01 + +/* + * data structure for every sensor + * + * @dev: Driver model representation of the device. + * @spi: Pointer to the spi device which will manage i/o to spi bus. + * @data: Last read data from device. + * @irq_adis: GPIO Number of IRQ signal + * @irq: irq line manage by kernel + * @negative: indicates if sensor is upside down (negative ÿ1) + * @direction: indicates axis (x, y, z) the sensor is meassuring + */ +struct spi_adis16255_data { + struct device dev; + struct spi_device *spi; + s16 data; + int irq_adis; + int irq; + u8 negative; + char direction; +}; + +/*-------------------------------------------------------------------------*/ + +static int spi_adis16255_read_data(struct spi_adis16255_data *spiadis, + u8 adr, + u8 *rbuf) +{ + struct spi_device *spi ÿpiadis->spi; + struct spi_message msg; + struct spi_transfer xfer1, xfer2; + u8 *buf, *rx; + int ret; + + buf ÿmalloc(4, GFP_KERNEL); + if (buf ÿNULL) + return -ENOMEM; + + rx ÿzalloc(4, GFP_KERNEL); + if (rx ÿNULL) { + ret ÿENOMEM; + goto err_buf; + } + + buf[0] údr; + buf[1] ðx00; + buf[2] ðx00; + buf[3] ðx00; + + spi_message_init(&msg); + memset(&xfer1, 0, sizeof(xfer1)); + memset(&xfer2, 0, sizeof(xfer2)); + + xfer1.tx_buf ûuf; + xfer1.rx_buf ûuf + 2; + xfer1.len ò; + xfer1.delay_usecs ù; + + xfer2.tx_buf ÿx + 2; + xfer2.rx_buf ÿx; + xfer2.len ò; + + spi_message_add_tail(&xfer1, &msg); + spi_message_add_tail(&xfer2, &msg); + + ret ÿpi_sync(spi, &msg); + if (ret ÿ0) { + rbuf[0] ÿx[0]; + rbuf[1] ÿx[1]; + } + + kfree(rx); +err_buf: + kfree(buf); + + return ret; +} + +static int spi_adis16255_write_data(struct spi_adis16255_data *spiadis, + u8 adr1, + u8 adr2, + u8 *wbuf) +{ + struct spi_device *spi ÿpiadis->spi; + struct spi_message msg; + struct spi_transfer xfer1, xfer2; + u8 *buf, *rx; + int ret; + + buf ÿmalloc(4, GFP_KERNEL); + if (buf ÿNULL) + return -ENOMEM; + + rx ÿzalloc(4, GFP_KERNEL); + if (rx ÿNULL) { + ret ÿENOMEM; + goto err_buf; + } + + spi_message_init(&msg); + memset(&xfer1, 0, sizeof(xfer1)); + memset(&xfer2, 0, sizeof(xfer2)); + + buf[0] údr1 | 0x80; + buf[1] ÿwbuf; + + buf[2] údr2 | 0x80; + buf[3] ÿ(wbuf + 1); + + xfer1.tx_buf ûuf; + xfer1.rx_buf ÿx; + xfer1.len ò; + xfer1.delay_usecs ù; + + xfer2.tx_buf ûuf+2; + xfer2.rx_buf ÿx+2; + xfer2.len ò; + + spi_message_add_tail(&xfer1, &msg); + spi_message_add_tail(&xfer2, &msg); + + ret ÿpi_sync(spi, &msg); + if (ret !ð) + dev_warn(&spi->dev, "wirte data to %#x %#x failed\n", + buf[0], buf[2]); + + kfree(rx); +err_buf: + kfree(buf); + return ret; +} + +/*-------------------------------------------------------------------------*/ + +static irqreturn_t adis_irq_thread(int irq, void *dev_id) +{ + struct spi_adis16255_data *spiadis ýev_id; + int status; + u16 value; + + status ÿspi_adis16255_read_data(spiadis, ADIS_GYRO_OUT, (u8 *)&value); + if (status ÿ0) { + /* perform on new data only... */ + if (value & 0x8000) { + /* delete error and new data bit */ + value ÿalue & 0x3fff; + /* set negative value */ + if (value & 0x2000) + value ÿalue | 0xe000; + + if (likely(spiadis->negative)) + value ÿvalue; + + spiadis->data ÿs16) value; + } + } else { + dev_warn(&spiadis->spi->dev, "SPI FAILED\n"); + } + + return IRQ_HANDLED; +} + +/*-------------------------------------------------------------------------*/ + +ssize_t adis16255_show_data(struct device *device, + struct device_attribute *da, + char *buf) +{ + struct spi_adis16255_data *spiadis ýev_get_drvdata(device); + return snprintf(buf, PAGE_SIZE, "%d\n", spiadis->data); +} +DEVICE_ATTR(data, S_IRUGO , adis16255_show_data, NULL); + +ssize_t adis16255_show_direction(struct device *device, + struct device_attribute *da, + char *buf) +{ + struct spi_adis16255_data *spiadis ýev_get_drvdata(device); + return snprintf(buf, PAGE_SIZE, "%c\n", spiadis->direction); +} +DEVICE_ATTR(direction, S_IRUGO , adis16255_show_direction, NULL); + +static struct attribute *adis16255_attributes[] ÿ + &dev_attr_data.attr, + &dev_attr_direction.attr, + NULL +}; + +static const struct attribute_group adis16255_attr_group ÿ + .attrs údis16255_attributes, +}; + +/*-------------------------------------------------------------------------*/ + +static int spi_adis16255_probe(struct spi_device *spi) +{ + +#define AD_CHK(_ss)\ + do {\ + status ÿss;\ + if (status !ð)\ + goto irq_err;\ + } while (0); + + struct adis16255_init_data *init_data ÿpi->dev.platform_data; + struct spi_adis16255_data *spiadis; + int status ð; + u16 value; + + spiadis ÿzalloc(sizeof(*spiadis), GFP_KERNEL); + if (!spiadis) + return -ENOMEM; + + spiadis->spi ÿpi; + spiadis->irq_adis ÿnit_data->irq; + spiadis->direction ÿnit_data->direction; + + if (init_data->negative) + spiadis->negative ñ; + + status ÿpio_request(spiadis->irq_adis, "adis16255"); + if (status !ð) + goto err; + + status ÿpio_direction_input(spiadis->irq_adis); + if (status !ð) + goto gpio_err; + + spiadis->irq ÿpio_to_irq(spiadis->irq_adis); + + status ÿequest_threaded_irq(spiadis->irq, + NULL, adis_irq_thread, + IRQF_DISABLED, "adis-driver", spiadis); + + if (status !ð) { + dev_err(&spi->dev, "IRQ request failed\n"); + goto gpio_err; + } + + dev_dbg(&spi->dev, "GPIO %d IRQ %d\n", spiadis->irq_adis, spiadis->irq); + + dev_set_drvdata(&spi->dev, spiadis); + AD_CHK(sysfs_create_group(&spi->dev.kobj, &adis16255_attr_group)); + + dev_info(&spi->dev, "spi_adis16255 driver added!\n"); + + AD_CHK(spi_adis16255_read_data(spiadis, ADIS_SUPPLY_OUT, (u8 *)&value)); + dev_info(&spi->dev, "sensor works with %d mV (%.4x)!\n", + ((value & 0x0fff)*18315)/10000, + (value & 0x0fff)); + + AD_CHK(spi_adis16255_read_data(spiadis, ADIS_GYRO_SCALE, (u8 *)&value)); + dev_info(&spi->dev, "adis GYRO_SCALE is %.4x\n", value); + + AD_CHK(spi_adis16255_read_data(spiadis, ADIS_STATUS, (u8 *)&value)); + dev_info(&spi->dev, "adis STATUS is %.4x\n", value); + + /* timebase ñ.953 ms, Ns ð -> 512 Hz sample rate */ + value ÿ0x0001; + AD_CHK(spi_adis16255_write_data(spiadis, + ADIS_SMPL_PRD_MSB, ADIS_SMPL_PRD_LSB, + (u8 *)&value)); + value ðx0000; + AD_CHK(spi_adis16255_read_data(spiadis, ADIS_SMPL_PRD_MSB, + (u8 *)&value)); + dev_info(&spi->dev, "adis SMP_PRD is %.4x\n", value); + + /* set interrupt on new data... */ + value ðx0006; + AD_CHK(spi_adis16255_write_data(spiadis, + ADIS_MSC_CTRL_MSB, ADIS_MSC_CTRL_LSB, + (u8 *)&value)); + value ðx0000; + AD_CHK(spi_adis16255_read_data(spiadis, ADIS_MSC_CTRL_MSB, + (u8 *)&value)); + dev_info(&spi->dev, "adis MSC_CONTROL is %.4x\n", value); + + return status; + +irq_err: + free_irq(spiadis->irq, spiadis); +gpio_err: + gpio_free(spiadis->irq_adis); +err: + kfree(spiadis); + return status; +} + +static int spi_adis16255_remove(struct spi_device *spi) +{ + u16 value ð; + struct spi_adis16255_data *spiadis ýev_get_drvdata(&spi->dev); + + /* turn sensor off */ + spi_adis16255_write_data(spiadis, + ADIS_SMPL_PRD_MSB, ADIS_SMPL_PRD_LSB, + (u8 *)&value); + spi_adis16255_write_data(spiadis, + ADIS_MSC_CTRL_MSB, ADIS_MSC_CTRL_LSB, + (u8 *)&value); + + dev_info(&spi->dev, "unregister: GPIO %d IRQ %d\n", + spiadis->irq_adis, spiadis->irq); + + free_irq(spiadis->irq, spiadis); + gpio_free(spiadis->irq_adis); + + sysfs_remove_group(&spiadis->spi->dev.kobj, &adis16255_attr_group); + + kfree(spiadis); + + dev_info(&spi->dev, "spi_adis16255 driver removed!\n"); + return 0; +} + +static struct spi_driver spi_adis16255_drv ÿ + .driver ÿ + .name ÿ"spi_adis16255", + .owner ÿHIS_MODULE, + }, + .probe ÿpi_adis16255_probe, + .remove ÿ __devexit_p(spi_adis16255_remove), +}; + +/*-------------------------------------------------------------------------*/ + +static int __init spi_adis16255_init(void) +{ + return spi_register_driver(&spi_adis16255_drv); +} +module_init(spi_adis16255_init); + +static void __exit spi_adis16255_exit(void) +{ + spi_unregister_driver(&spi_adis16255_drv); +} +module_exit(spi_adis16255_exit); + +MODULE_AUTHOR("Matthias Brugger"); +MODULE_DESCRIPTION("SPI device driver for ADIS16255 sensor"); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/adis16255/adis16255.h b/drivers/staging/adis16255/adis16255.h new file mode 100644 index 000000000000..03e07001bab2 --- /dev/null +++ b/drivers/staging/adis16255/adis16255.h @@ -0,0 +1,12 @@ +#ifndef ADIS16255_H +#define ADIS16255_H + +#include <linux/types.h> + +struct adis16255_init_data { + char direction; + u8 negative; + int irq; +}; + +#endif diff --git a/drivers/staging/arlan/arlan-main.c b/drivers/staging/arlan/arlan-main.c index 80284522c42b..06ac5b200617 100644 --- a/drivers/staging/arlan/arlan-main.c +++ b/drivers/staging/arlan/arlan-main.c @@ -80,15 +80,14 @@ static int arlan_open(struct net_device *dev); static netdev_tx_t arlan_tx(struct sk_buff *skb, struct net_device *dev); static irqreturn_t arlan_interrupt(int irq, void *dev_id); static int arlan_close(struct net_device *dev); -static struct net_device_stats * - arlan_statistics (struct net_device *dev); -static void arlan_set_multicast (struct net_device *dev); -static int arlan_hw_tx (struct net_device* dev, char *buf, int length ); -static int arlan_hw_config (struct net_device * dev); -static void arlan_tx_done_interrupt (struct net_device * dev, int status); -static void arlan_rx_interrupt (struct net_device * dev, u_char rxStatus, u_short, u_short); -static void arlan_process_interrupt (struct net_device * dev); -static void arlan_tx_timeout (struct net_device *dev); +static struct net_device_stats *arlan_statistics(struct net_device *dev); +static void arlan_set_multicast(struct net_device *dev); +static int arlan_hw_tx(struct net_device *dev, char *buf, int length); +static int arlan_hw_config(struct net_device *dev); +static void arlan_tx_done_interrupt(struct net_device *dev, int status); +static void arlan_rx_interrupt(struct net_device *dev, u_char rxStatus, u_short, u_short); +static void arlan_process_interrupt(struct net_device *dev); +static void arlan_tx_timeout(struct net_device *dev); static inline long us2ticks(int us) { @@ -102,14 +101,14 @@ static inline long us2ticks(int us) struct timeval timev;\ do_gettimeofday(&timev);\ if (arlan_entry_debug || arlan_entry_and_exit_debug)\ - printk("--->>>" name " %ld " "\n",((long int) timev.tv_sec * 1000000 + timev.tv_usec));\ + printk("--->>>" name " %ld " "\n", ((long int) timev.tv_sec * 1000000 + timev.tv_usec));\ } #define ARLAN_DEBUG_EXIT(name) \ {\ struct timeval timev;\ do_gettimeofday(&timev);\ if (arlan_exit_debug || arlan_entry_and_exit_debug)\ - printk("<<<---" name " %ld " "\n",((long int) timev.tv_sec * 1000000 + timev.tv_usec) );\ + printk("<<<---" name " %ld " "\n", ((long int) timev.tv_sec * 1000000 + timev.tv_usec));\ } #else #define ARLAN_DEBUG_ENTRY(name) @@ -118,8 +117,8 @@ static inline long us2ticks(int us) #define arlan_interrupt_ack(dev)\ - clearClearInterrupt(dev);\ - setClearInterrupt(dev); + clearClearInterrupt(dev);\ + setClearInterrupt(dev); static inline int arlan_drop_tx(struct net_device *dev) { @@ -127,18 +126,15 @@ static inline int arlan_drop_tx(struct net_device *dev) dev->stats.tx_errors++; if (priv->Conf->tx_delay_ms) - { priv->tx_done_delayed = jiffies + priv->Conf->tx_delay_ms * HZ / 1000 + 1; - } - else - { + else { priv->waiting_command_mask &= ~ARLAN_COMMAND_TX; TXHEAD(dev).offset = 0; TXTAIL(dev).offset = 0; priv->txLast = 0; priv->bad = 0; if (!priv->under_reset && !priv->under_config) - netif_wake_queue (dev); + netif_wake_queue(dev); } return 1; } @@ -169,13 +165,11 @@ int arlan_command(struct net_device *dev, int command_p) if (time_after(jiffies, priv->lastReset + 5 * HZ)) priv->waiting_command_mask &= ~ARLAN_COMMAND_RESET; - if (priv->waiting_command_mask & ARLAN_COMMAND_INT_ACK) - { + if (priv->waiting_command_mask & ARLAN_COMMAND_INT_ACK) { arlan_interrupt_ack(dev); priv->waiting_command_mask &= ~ARLAN_COMMAND_INT_ACK; } - if (priv->waiting_command_mask & ARLAN_COMMAND_INT_ENABLE) - { + if (priv->waiting_command_mask & ARLAN_COMMAND_INT_ENABLE) { setInterruptEnable(dev); priv->waiting_command_mask &= ~ARLAN_COMMAND_INT_ENABLE; } @@ -185,12 +179,10 @@ int arlan_command(struct net_device *dev, int command_p) /* Check cards status and waiting */ - if (priv->waiting_command_mask & (ARLAN_COMMAND_LONG_WAIT_NOW | ARLAN_COMMAND_WAIT_NOW)) - { - while (priv->waiting_command_mask & (ARLAN_COMMAND_LONG_WAIT_NOW | ARLAN_COMMAND_WAIT_NOW)) - { + if (priv->waiting_command_mask & (ARLAN_COMMAND_LONG_WAIT_NOW | ARLAN_COMMAND_WAIT_NOW)) { + while (priv->waiting_command_mask & (ARLAN_COMMAND_LONG_WAIT_NOW | ARLAN_COMMAND_WAIT_NOW)) { if (READSHMB(arlan->resetFlag) || - READSHMB(arlan->commandByte)) /* || + READSHMB(arlan->commandByte)) /* || (readControlRegister(dev) & ARLAN_ACCESS)) */ udelay(40); @@ -199,27 +191,20 @@ int arlan_command(struct net_device *dev, int command_p) udelayed++; - if (priv->waiting_command_mask & ARLAN_COMMAND_LONG_WAIT_NOW) - { - if (udelayed * 40 > 1000000) - { + if (priv->waiting_command_mask & ARLAN_COMMAND_LONG_WAIT_NOW) { + if (udelayed * 40 > 1000000) { printk(KERN_ERR "%s long wait too long \n", dev->name); priv->waiting_command_mask |= ARLAN_COMMAND_RESET; break; } - } - else if (priv->waiting_command_mask & ARLAN_COMMAND_WAIT_NOW) - { - if (udelayed * 40 > 1000) - { + } else if (priv->waiting_command_mask & ARLAN_COMMAND_WAIT_NOW) { + if (udelayed * 40 > 1000) { printk(KERN_ERR "%s short wait too long \n", dev->name); goto bad_end; } } } - } - else - { + } else { i = 0; while ((READSHMB(arlan->resetFlag) || READSHMB(arlan->commandByte)) && @@ -230,9 +215,7 @@ int arlan_command(struct net_device *dev, int command_p) if ((READSHMB(arlan->resetFlag) || READSHMB(arlan->commandByte)) && !(priv->waiting_command_mask & ARLAN_COMMAND_RESET)) - { goto card_busy_end; - } } if (priv->waiting_command_mask & ARLAN_COMMAND_RESET) priv->under_reset = 1; @@ -241,55 +224,43 @@ int arlan_command(struct net_device *dev, int command_p) /* Issuing command */ arlan_lock_card_access(dev); - if (priv->waiting_command_mask & ARLAN_COMMAND_POWERUP) - { - // if (readControlRegister(dev) & (ARLAN_ACCESS && ARLAN_POWER)) + if (priv->waiting_command_mask & ARLAN_COMMAND_POWERUP) { + /* if (readControlRegister(dev) & (ARLAN_ACCESS && ARLAN_POWER)) */ setPowerOn(dev); arlan_interrupt_lancpu(dev); priv->waiting_command_mask &= ~ARLAN_COMMAND_POWERUP; priv->waiting_command_mask |= ARLAN_COMMAND_RESET; priv->card_polling_interval = HZ / 10; - } - else if (priv->waiting_command_mask & ARLAN_COMMAND_ACTIVATE) - { + } else if (priv->waiting_command_mask & ARLAN_COMMAND_ACTIVATE) { WRITESHMB(arlan->commandByte, ARLAN_COM_ACTIVATE); arlan_interrupt_lancpu(dev); priv->waiting_command_mask &= ~ARLAN_COMMAND_ACTIVATE; priv->card_polling_interval = HZ / 10; - } - else if (priv->waiting_command_mask & ARLAN_COMMAND_RX_ABORT) - { - if (priv->rx_command_given) - { + } else if (priv->waiting_command_mask & ARLAN_COMMAND_RX_ABORT) { + if (priv->rx_command_given) { WRITESHMB(arlan->commandByte, ARLAN_COM_RX_ABORT); arlan_interrupt_lancpu(dev); priv->rx_command_given = 0; } priv->waiting_command_mask &= ~ARLAN_COMMAND_RX_ABORT; priv->card_polling_interval = 1; - } - else if (priv->waiting_command_mask & ARLAN_COMMAND_TX_ABORT) - { - if (priv->tx_command_given) - { + } else if (priv->waiting_command_mask & ARLAN_COMMAND_TX_ABORT) { + if (priv->tx_command_given) { WRITESHMB(arlan->commandByte, ARLAN_COM_TX_ABORT); arlan_interrupt_lancpu(dev); priv->tx_command_given = 0; } priv->waiting_command_mask &= ~ARLAN_COMMAND_TX_ABORT; priv->card_polling_interval = 1; - } - else if (priv->waiting_command_mask & ARLAN_COMMAND_RESET) - { - priv->under_reset=1; - netif_stop_queue (dev); + } else if (priv->waiting_command_mask & ARLAN_COMMAND_RESET) { + priv->under_reset = 1; + netif_stop_queue(dev); arlan_drop_tx(dev); if (priv->tx_command_given || priv->rx_command_given) - { printk(KERN_ERR "%s: Reset under tx or rx command \n", dev->name); - } - netif_stop_queue (dev); + + netif_stop_queue(dev); if (arlan_debug & ARLAN_DEBUG_RESET) printk(KERN_ERR "%s: Doing chip reset\n", dev->name); priv->lastReset = jiffies; @@ -303,11 +274,9 @@ int arlan_command(struct net_device *dev, int command_p) priv->card_polling_interval = HZ / 4; priv->waiting_command_mask &= ~ARLAN_COMMAND_RESET; priv->waiting_command_mask |= ARLAN_COMMAND_INT_RACK; -// priv->waiting_command_mask |= ARLAN_COMMAND_INT_RENABLE; -// priv->waiting_command_mask |= ARLAN_COMMAND_RX; - } - else if (priv->waiting_command_mask & ARLAN_COMMAND_INT_RACK) - { + /* priv->waiting_command_mask |= ARLAN_COMMAND_INT_RENABLE; */ + /* priv->waiting_command_mask |= ARLAN_COMMAND_RX; */ + } else if (priv->waiting_command_mask & ARLAN_COMMAND_INT_RACK) { clearHardwareReset(dev); clearClearInterrupt(dev); setClearInterrupt(dev); @@ -316,126 +285,94 @@ int arlan_command(struct net_device *dev, int command_p) priv->waiting_command_mask |= ARLAN_COMMAND_CONF; priv->under_config = 1; priv->under_reset = 0; - } - else if (priv->waiting_command_mask & ARLAN_COMMAND_INT_RENABLE) - { + } else if (priv->waiting_command_mask & ARLAN_COMMAND_INT_RENABLE) { setInterruptEnable(dev); priv->waiting_command_mask &= ~ARLAN_COMMAND_INT_RENABLE; - } - else if (priv->waiting_command_mask & ARLAN_COMMAND_CONF) - { + } else if (priv->waiting_command_mask & ARLAN_COMMAND_CONF) { if (priv->tx_command_given || priv->rx_command_given) - { printk(KERN_ERR "%s: Reset under tx or rx command \n", dev->name); - } + arlan_drop_tx(dev); setInterruptEnable(dev); arlan_hw_config(dev); arlan_interrupt_lancpu(dev); priv->waiting_command_mask &= ~ARLAN_COMMAND_CONF; priv->card_polling_interval = HZ / 10; -// priv->waiting_command_mask |= ARLAN_COMMAND_INT_RACK; -// priv->waiting_command_mask |= ARLAN_COMMAND_INT_ENABLE; + /* priv->waiting_command_mask |= ARLAN_COMMAND_INT_RACK; */ + /* priv->waiting_command_mask |= ARLAN_COMMAND_INT_ENABLE; */ priv->waiting_command_mask |= ARLAN_COMMAND_CONF_WAIT; - } - else if (priv->waiting_command_mask & ARLAN_COMMAND_CONF_WAIT) - { + } else if (priv->waiting_command_mask & ARLAN_COMMAND_CONF_WAIT) { if (READSHMB(arlan->configuredStatusFlag) != 0 && - READSHMB(arlan->diagnosticInfo) == 0xff) - { + READSHMB(arlan->diagnosticInfo) == 0xff) { priv->waiting_command_mask &= ~ARLAN_COMMAND_CONF_WAIT; priv->waiting_command_mask |= ARLAN_COMMAND_RX; priv->waiting_command_mask |= ARLAN_COMMAND_TBUSY_CLEAR; priv->card_polling_interval = HZ / 10; priv->tx_command_given = 0; priv->under_config = 0; - } - else - { + } else { priv->card_polling_interval = 1; if (arlan_debug & ARLAN_DEBUG_TIMING) printk(KERN_ERR "configure delayed \n"); } - } - else if (priv->waiting_command_mask & ARLAN_COMMAND_RX) - { - if (!registrationBad(dev)) - { + } else if (priv->waiting_command_mask & ARLAN_COMMAND_RX) { + if (!registrationBad(dev)) { setInterruptEnable(dev); memset_io(arlan->commandParameter, 0, 0xf); WRITESHMB(arlan->commandByte, ARLAN_COM_INT | ARLAN_COM_RX_ENABLE); WRITESHMB(arlan->commandParameter[0], conf->rxParameter); arlan_interrupt_lancpu(dev); - priv->rx_command_given = 0; // mnjah, bad + priv->rx_command_given = 0; /* mnjah, bad */ priv->waiting_command_mask &= ~ARLAN_COMMAND_RX; priv->card_polling_interval = 1; - } - else + } else priv->card_polling_interval = 2; - } - else if (priv->waiting_command_mask & ARLAN_COMMAND_TBUSY_CLEAR) - { - if ( !registrationBad(dev) && - (netif_queue_stopped(dev) || !netif_running(dev)) ) - { + } else if (priv->waiting_command_mask & ARLAN_COMMAND_TBUSY_CLEAR) { + if (!registrationBad(dev) && + (netif_queue_stopped(dev) || !netif_running(dev))) { priv->waiting_command_mask &= ~ARLAN_COMMAND_TBUSY_CLEAR; - netif_wake_queue (dev); + netif_wake_queue(dev); } - } - else if (priv->waiting_command_mask & ARLAN_COMMAND_TX) - { - if (!test_and_set_bit(0, (void *) &priv->tx_command_given)) - { - if (time_after(jiffies, + } else if (priv->waiting_command_mask & ARLAN_COMMAND_TX) { + if (!test_and_set_bit(0, (void *) &priv->tx_command_given)) { + if (time_after(jiffies, priv->tx_last_sent + us2ticks(conf->rx_tweak1)) || time_before(jiffies, - priv->last_rx_int_ack_time + us2ticks(conf->rx_tweak2))) - { + priv->last_rx_int_ack_time + us2ticks(conf->rx_tweak2))) { setInterruptEnable(dev); memset_io(arlan->commandParameter, 0, 0xf); WRITESHMB(arlan->commandByte, ARLAN_COM_TX_ENABLE | ARLAN_COM_INT); memcpy_toio(arlan->commandParameter, &TXLAST(dev), 14); -// for ( i=1 ; i < 15 ; i++) printk("%02x:",READSHMB(arlan->commandParameter[i])); + /* for ( i=1 ; i < 15 ; i++) printk("%02x:",READSHMB(arlan->commandParameter[i])); */ priv->tx_last_sent = jiffies; arlan_interrupt_lancpu(dev); priv->tx_command_given = 1; priv->waiting_command_mask &= ~ARLAN_COMMAND_TX; priv->card_polling_interval = 1; - } - else - { + } else { priv->tx_command_given = 0; priv->card_polling_interval = 1; } - } - else if (arlan_debug & ARLAN_DEBUG_CHAIN_LOCKS) + } else if (arlan_debug & ARLAN_DEBUG_CHAIN_LOCKS) printk(KERN_ERR "tx command when tx chain locked \n"); - } - else if (priv->waiting_command_mask & ARLAN_COMMAND_NOOPINT) - { + } else if (priv->waiting_command_mask & ARLAN_COMMAND_NOOPINT) { { WRITESHMB(arlan->commandByte, ARLAN_COM_NOP | ARLAN_COM_INT); } arlan_interrupt_lancpu(dev); priv->waiting_command_mask &= ~ARLAN_COMMAND_NOOPINT; priv->card_polling_interval = HZ / 3; - } - else if (priv->waiting_command_mask & ARLAN_COMMAND_NOOP) - { + } else if (priv->waiting_command_mask & ARLAN_COMMAND_NOOP) { WRITESHMB(arlan->commandByte, ARLAN_COM_NOP); arlan_interrupt_lancpu(dev); priv->waiting_command_mask &= ~ARLAN_COMMAND_NOOP; priv->card_polling_interval = HZ / 3; - } - else if (priv->waiting_command_mask & ARLAN_COMMAND_SLOW_POLL) - { + } else if (priv->waiting_command_mask & ARLAN_COMMAND_SLOW_POLL) { WRITESHMB(arlan->commandByte, ARLAN_COM_GOTO_SLOW_POLL); arlan_interrupt_lancpu(dev); priv->waiting_command_mask &= ~ARLAN_COMMAND_SLOW_POLL; priv->card_polling_interval = HZ / 3; - } - else if (priv->waiting_command_mask & ARLAN_COMMAND_POWERDOWN) - { + } else if (priv->waiting_command_mask & ARLAN_COMMAND_POWERDOWN) { setPowerOff(dev); if (arlan_debug & ARLAN_DEBUG_CARD_STATE) printk(KERN_WARNING "%s: Arlan Going Standby\n", dev->name); @@ -478,10 +415,8 @@ static inline void arlan_command_process(struct net_device *dev) struct arlan_private *priv = netdev_priv(dev); int times = 0; - while (priv->waiting_command_mask && times < 8) - { - if (priv->waiting_command_mask) - { + while (priv->waiting_command_mask && times < 8) { + if (priv->waiting_command_mask) { if (arlan_command(dev, 0)) break; times++; @@ -500,24 +435,17 @@ static inline void arlan_retransmit_now(struct net_device *dev) ARLAN_DEBUG_ENTRY("arlan_retransmit_now"); - if (TXLAST(dev).offset == 0) - { - if (TXHEAD(dev).offset) - { + if (TXLAST(dev).offset == 0) { + if (TXHEAD(dev).offset) { priv->txLast = 0; IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_DEBUG "TX buff switch to head \n"); - - } - else if (TXTAIL(dev).offset) - { + } else if (TXTAIL(dev).offset) { IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_DEBUG "TX buff switch to tail \n"); priv->txLast = 1; - } - else + } else IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_ERR "ReTransmit buff empty"); - netif_wake_queue (dev); + netif_wake_queue(dev); return; - } arlan_command(dev, ARLAN_COMMAND_TX); @@ -540,78 +468,71 @@ static void arlan_registration_timer(unsigned long data) long lostTime = ((long)jiffies - (long)priv->registrationLastSeen) * (1000/HZ); - if (registrationBad(dev)) - { + if (registrationBad(dev)) { priv->registrationLostCount++; if (lostTime > 7000 && lostTime < 7200) - { printk(KERN_NOTICE "%s registration Lost \n", dev->name); - } + if (lostTime / priv->reRegisterExp > 2000) arlan_command(dev, ARLAN_COMMAND_CLEAN_AND_CONF); if (lostTime / (priv->reRegisterExp) > 3500) arlan_command(dev, ARLAN_COMMAND_CLEAN_AND_RESET); if (priv->reRegisterExp < 400) priv->reRegisterExp += 2; - if (lostTime > 7200) - { + if (lostTime > 7200) { next_tick = HZ; arlan_command(dev, ARLAN_COMMAND_CLEAN_AND_RESET); } - } - else - { + } else { if (priv->Conf->registrationMode && lostTime > 10000 && - priv->registrationLostCount) - { + priv->registrationLostCount) { printk(KERN_NOTICE "%s registration is back after %ld milliseconds\n", dev->name, lostTime); } priv->registrationLastSeen = jiffies; priv->registrationLostCount = 0; priv->reRegisterExp = 1; - if (!netif_running(dev) ) + if (!netif_running(dev)) netif_wake_queue(dev); - if (time_after(priv->tx_last_sent,priv->tx_last_cleared) && - time_after(jiffies, priv->tx_last_sent * 5*HZ) ){ - arlan_command(dev, ARLAN_COMMAND_CLEAN_AND_RESET); + if (time_after(priv->tx_last_sent, priv->tx_last_cleared) && + time_after(jiffies, priv->tx_last_sent * 5*HZ)) { + arlan_command(dev, ARLAN_COMMAND_CLEAN_AND_RESET); priv->tx_last_cleared = jiffies; } } - if (!registrationBad(dev) && priv->ReTransmitRequested) - { + if (!registrationBad(dev) && priv->ReTransmitRequested) { IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_ERR "Retransmit from timer \n"); priv->ReTransmitRequested = 0; arlan_retransmit_now(dev); } + if (!registrationBad(dev) && time_after(jiffies, priv->tx_done_delayed) && - priv->tx_done_delayed != 0) - { + priv->tx_done_delayed != 0) { TXLAST(dev).offset = 0; + if (priv->txLast) priv->txLast = 0; else if (TXTAIL(dev).offset) priv->txLast = 1; - if (TXLAST(dev).offset) - { + if (TXLAST(dev).offset) { arlan_retransmit_now(dev); dev->trans_start = jiffies; } + if (!(TXHEAD(dev).offset && TXTAIL(dev).offset)) - { - netif_wake_queue (dev); - } + netif_wake_queue(dev); + priv->tx_done_delayed = 0; bh_mark_needed = 1; } + if (bh_mark_needed) - { - netif_wake_queue (dev); - } + netif_wake_queue(dev); + arlan_process_interrupt(dev); if (next_tick < priv->card_polling_interval) @@ -672,8 +593,7 @@ static int arlan_hw_tx(struct net_device *dev, char *buf, int length) tailStarts = 0x800 - (((TXTAIL(dev).offset - offsetof(struct arlan_shmem, txBuffer)) / 64) + 2) * 64; - if (!TXHEAD(dev).offset && length < tailStarts) - { + if (!TXHEAD(dev).offset && length < tailStarts) { IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_ERR "TXHEAD insert, tailStart %d\n", tailStarts); @@ -687,9 +607,7 @@ static int arlan_hw_tx(struct net_device *dev, char *buf, int length) TXHEAD(dev).routing = conf->txRouting; TXHEAD(dev).scrambled = conf->txScrambled; memcpy_toio((char __iomem *)arlan + TXHEAD(dev).offset, buf + ARLAN_FAKE_HDR_LEN, TXHEAD(dev).length); - } - else if (!TXTAIL(dev).offset && length < (0x800 - headEnds)) - { + } else if (!TXTAIL(dev).offset && length < (0x800 - headEnds)) { IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_ERR "TXTAIL insert, headEnd %d\n", headEnds); @@ -703,10 +621,8 @@ static int arlan_hw_tx(struct net_device *dev, char *buf, int length) TXTAIL(dev).routing = conf->txRouting; TXTAIL(dev).scrambled = conf->txScrambled; memcpy_toio(((char __iomem *)arlan + TXTAIL(dev).offset), buf + ARLAN_FAKE_HDR_LEN, TXTAIL(dev).length); - } - else - { - netif_stop_queue (dev); + } else { + netif_stop_queue(dev); IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_ERR "TX TAIL & HEAD full, return, tailStart %d headEnd %d\n", tailStarts, headEnds); return -1; @@ -715,26 +631,23 @@ static int arlan_hw_tx(struct net_device *dev, char *buf, int length) priv->out_bytes10 += length; if (conf->measure_rate < 1) conf->measure_rate = 1; - if (time_after(jiffies, priv->out_time + conf->measure_rate * HZ)) - { + if (time_after(jiffies, priv->out_time + conf->measure_rate * HZ)) { conf->out_speed = priv->out_bytes / conf->measure_rate; priv->out_bytes = 0; priv->out_time = jiffies; } - if (time_after(jiffies, priv->out_time10 + conf->measure_rate * 10*HZ)) - { + + if (time_after(jiffies, priv->out_time10 + conf->measure_rate * 10*HZ)) { conf->out_speed10 = priv->out_bytes10 / (10 * conf->measure_rate); priv->out_bytes10 = 0; priv->out_time10 = jiffies; } - if (TXHEAD(dev).offset && TXTAIL(dev).offset) - { - netif_stop_queue (dev); - return 0; - } - else - netif_start_queue (dev); + if (TXHEAD(dev).offset && TXTAIL(dev).offset) { + netif_stop_queue(dev); + return 0; + } else + netif_start_queue(dev); IFDEBUG(ARLAN_DEBUG_HEADER_DUMP) printk(KERN_WARNING "%s Transmit t %2x:%2x:%2x:%2x:%2x:%2x f %2x:%2x:%2x:%2x:%2x:%2x \n", dev->name, @@ -817,11 +730,11 @@ static int arlan_hw_config(struct net_device *dev) WRITESHMB(arlan->commandByte, ARLAN_COM_INT | ARLAN_COM_CONF); /* do configure */ memset_io(arlan->commandParameter, 0, 0xf); /* 0xf */ memset_io(arlan->commandParameter + 1, 0, 2); - if (conf->writeEEPROM) - { - memset_io(arlan->commandParameter, conf->writeEEPROM, 1); -// conf->writeEEPROM=0; + if (conf->writeEEPROM) { + memset_io(arlan->commandParameter, conf->writeEEPROM, 1); + /* conf->writeEEPROM=0; */ } + if (conf->registrationMode && conf->registrationInterrupts) memset_io(arlan->commandParameter + 3, 1, 1); else @@ -847,47 +760,46 @@ static int arlan_read_card_configuration(struct net_device *dev) ARLAN_DEBUG_ENTRY("arlan_read_card_configuration"); - if (radioNodeId == radioNodeIdUNKNOWN) - { + + if (radioNodeId == radioNodeIdUNKNOWN) { + /* multiline macro, cannot remove braces */ READSHM(conf->radioNodeId, arlan->radioNodeId, u_short); - } - else + } else conf->radioNodeId = radioNodeId; - - if (SID == SIDUNKNOWN) - { + + if (SID == SIDUNKNOWN) { + /* multiline macro, cannot remove braces */ READSHM(conf->SID, arlan->SID, u_int); - } - else conf->SID = SID; - - if (spreadingCode == spreadingCodeUNKNOWN) - { - READSHM(conf->spreadingCode, arlan->spreadingCode, u_char); - } - else + } else + conf->SID = SID; + + if (spreadingCode == spreadingCodeUNKNOWN) { + /* multiline macro, cannot remove braces */ + READSHM(conf->spreadingCode, arlan->spreadingCode, u_char); + } else conf->spreadingCode = spreadingCode; - - if (channelSet == channelSetUNKNOWN) - { + + if (channelSet == channelSetUNKNOWN) { + /* multiline macro, cannot remove braces */ READSHM(conf->channelSet, arlan->channelSet, u_char); - } - else conf->channelSet = channelSet; + } else + conf->channelSet = channelSet; - if (channelNumber == channelNumberUNKNOWN) - { + if (channelNumber == channelNumberUNKNOWN) { + /* multiline macro, cannot remove braces */ READSHM(conf->channelNumber, arlan->channelNumber, u_char); - } - else conf->channelNumber = channelNumber; - + } else + conf->channelNumber = channelNumber; + READSHM(conf->scramblingDisable, arlan->scramblingDisable, u_char); READSHM(conf->txAttenuation, arlan->txAttenuation, u_char); - - if (systemId == systemIdUNKNOWN) - { + + if (systemId == systemIdUNKNOWN) { + /* multiline macro, cannot remove braces */ READSHM(conf->systemId, arlan->systemId, u_int); - } - else conf->systemId = systemId; - + } else + conf->systemId = systemId; + READSHM(conf->maxDatagramSize, arlan->maxDatagramSize, u_short); READSHM(conf->maxFrameSize, arlan->maxFrameSize, u_short); READSHM(conf->maxRetries, arlan->maxRetries, u_char); @@ -895,18 +807,18 @@ static int arlan_read_card_configuration(struct net_device *dev) READSHM(conf->priority, arlan->priority, u_char); READSHM(conf->rootOrRepeater, arlan->rootOrRepeater, u_char); - if (SID == SIDUNKNOWN) - { + if (SID == SIDUNKNOWN) { + /* multiline macro, cannot remove braces */ READSHM(conf->SID, arlan->SID, u_int); - } - else conf->SID = SID; - - if (registrationMode == registrationModeUNKNOWN) - { + } else + conf->SID = SID; + + if (registrationMode == registrationModeUNKNOWN) { + /* multiline macro, cannot remove braces */ READSHM(conf->registrationMode, arlan->registrationMode, u_char); - } - else conf->registrationMode = registrationMode; - + } else + conf->registrationMode = registrationMode; + READSHM(conf->registrationFill, arlan->registrationFill, u_char); READSHM(conf->localTalkAddress, arlan->localTalkAddress, u_char); READSHM(conf->codeFormat, arlan->codeFormat, u_char); @@ -921,16 +833,16 @@ static int arlan_read_card_configuration(struct net_device *dev) READSHM(conf->headerSize, arlan->headerSize, u_short); READSHM(conf->hardwareType, arlan->hardwareType, u_char); READSHM(conf->radioType, arlan->radioModule, u_char); - + if (conf->radioType == 0) conf->radioType = 0xc; WRITESHM(arlan->configStatus, 0xA5, u_char); READSHM(tlx415, arlan->configStatus, u_char); - + if (tlx415 != 0xA5) printk(KERN_INFO "%s tlx415 chip \n", dev->name); - + conf->txClear = 0; conf->txRetries = 1; conf->txRouting = 1; @@ -973,7 +885,7 @@ static int __init arlan_check_fingerprint(unsigned long memaddr) ARLAN_DEBUG_ENTRY("arlan_check_fingerprint"); if (!request_mem_region(paddr, ARLAN_SHMEM_SIZE, "arlan")) { - // printk(KERN_WARNING "arlan: memory region %lx excluded from probing \n",paddr); + /* printk(KERN_WARNING "arlan: memory region %lx excluded from probing \n",paddr); */ return -ENODEV; } @@ -981,12 +893,12 @@ static int __init arlan_check_fingerprint(unsigned long memaddr) tempBuf[30] = 0; /* check for card at this address */ - if (0 != strncmp(tempBuf, probeText, 29)){ - release_mem_region(paddr, ARLAN_SHMEM_SIZE); + if (0 != strncmp(tempBuf, probeText, 29)) { + release_mem_region(paddr, ARLAN_SHMEM_SIZE); return -ENODEV; } -// printk(KERN_INFO "arlan found at 0x%x \n",memaddr); + /* printk(KERN_INFO "arlan found at 0x%x \n",memaddr); */ ARLAN_DEBUG_EXIT("arlan_check_fingerprint"); return 0; @@ -1054,7 +966,7 @@ static int __init arlan_setup_device(struct net_device *dev, int num) dev->tx_queue_len = tx_queue_len; dev->netdev_ops = &arlan_netdev_ops; dev->watchdog_timeo = 3*HZ; - + ap->irq_test_done = 0; ap->Conf = &arlan_conf[num]; @@ -1065,7 +977,7 @@ static int __init arlan_setup_device(struct net_device *dev, int num) err = register_netdev(dev); if (err) { - release_mem_region(virt_to_phys((void *) dev->mem_start), + release_mem_region(virt_to_phys((void *) dev->mem_start), ARLAN_SHMEM_SIZE); free_netdev(dev); return err; @@ -1075,7 +987,7 @@ static int __init arlan_setup_device(struct net_device *dev, int num) return 0; } -static int __init arlan_probe_here(struct net_device *dev, +static int __init arlan_probe_here(struct net_device *dev, unsigned long memaddr) { struct arlan_private *ap = netdev_priv(dev); @@ -1085,15 +997,15 @@ static int __init arlan_probe_here(struct net_device *dev, if (arlan_check_fingerprint(memaddr)) return -ENODEV; - printk(KERN_NOTICE "%s: Arlan found at %llx, \n ", dev->name, - (u64) virt_to_phys((void*)memaddr)); + printk(KERN_NOTICE "%s: Arlan found at %llx, \n ", dev->name, + (u64) virt_to_phys((void *)memaddr)); ap->card = (void *) memaddr; dev->mem_start = memaddr; dev->mem_end = memaddr + ARLAN_SHMEM_SIZE-1; - if (dev->irq < 2) - { + if (dev->irq < 2) { + /* multiline macro, cannot remove braces */ READSHM(dev->irq, ap->card->irqLevel, u_char); } else if (dev->irq == 2) dev->irq = 9; @@ -1114,14 +1026,12 @@ static int arlan_open(struct net_device *dev) ARLAN_DEBUG_ENTRY("arlan_open"); ret = request_irq(dev->irq, &arlan_interrupt, 0, dev->name, dev); - if (ret) - { + if (ret) { printk(KERN_ERR "%s: unable to get IRQ %d .\n", dev->name, dev->irq); return ret; } - priv->bad = 0; priv->lastReset = 0; priv->reset = 0; @@ -1131,14 +1041,14 @@ static int arlan_open(struct net_device *dev) priv->interrupt_processing_active = 0; spin_lock_init(&priv->lock); - netif_start_queue (dev); + netif_start_queue(dev); priv->registrationLostCount = 0; priv->registrationLastSeen = jiffies; priv->txLast = 0; priv->tx_command_given = 0; priv->rx_command_given = 0; - + priv->reRegisterExp = 1; priv->tx_last_sent = jiffies - 1; priv->tx_last_cleared = jiffies; @@ -1159,13 +1069,13 @@ static int arlan_open(struct net_device *dev) } -static void arlan_tx_timeout (struct net_device *dev) +static void arlan_tx_timeout(struct net_device *dev) { printk(KERN_ERR "%s: arlan transmit timed out, kernel decided\n", dev->name); /* Try to restart the adaptor. */ arlan_command(dev, ARLAN_COMMAND_CLEAN_AND_RESET); - // dev->trans_start = jiffies; - // netif_start_queue (dev); + /* dev->trans_start = jiffies; */ + /* netif_start_queue (dev); */ } @@ -1175,13 +1085,13 @@ static netdev_tx_t arlan_tx(struct sk_buff *skb, struct net_device *dev) unsigned char *buf; ARLAN_DEBUG_ENTRY("arlan_tx"); - + length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN; buf = skb->data; if (length + 0x12 > 0x800) { printk(KERN_ERR "TX RING overflow \n"); - netif_stop_queue (dev); + netif_stop_queue(dev); } if (arlan_hw_tx(dev, buf, length) == -1) @@ -1197,7 +1107,7 @@ static netdev_tx_t arlan_tx(struct sk_buff *skb, struct net_device *dev) bad_end: arlan_process_interrupt(dev); - netif_stop_queue (dev); + netif_stop_queue(dev); ARLAN_DEBUG_EXIT("arlan_tx"); return NETDEV_TX_BUSY; } @@ -1229,9 +1139,8 @@ static inline void arlan_queue_retransmit(struct net_device *dev) ARLAN_DEBUG_ENTRY("arlan_queue_retransmit"); if (DoNotWaitReTransmitCrap(dev)) - { - arlan_drop_tx(dev); - } else + arlan_drop_tx(dev); + else priv->ReTransmitRequested++; ARLAN_DEBUG_EXIT("arlan_queue_retransmit"); @@ -1245,14 +1154,11 @@ static inline void RetryOrFail(struct net_device *dev) if (priv->retransmissions > priv->Conf->retries || DoNotReTransmitCrap(dev)) - { arlan_drop_tx(dev); - } else if (priv->bad <= priv->Conf->fastReTransCount) - { arlan_retransmit_now(dev); - } - else arlan_queue_retransmit(dev); + else + arlan_queue_retransmit(dev); ARLAN_DEBUG_EXIT("RetryOrFail"); } @@ -1266,131 +1172,126 @@ static void arlan_tx_done_interrupt(struct net_device *dev, int status) priv->tx_last_cleared = jiffies; priv->tx_command_given = 0; - switch (status) + switch (status) { + case 1: { - case 1: - { - IFDEBUG(ARLAN_DEBUG_TX_CHAIN) - printk("arlan intr: transmit OK\n"); - dev->stats.tx_packets++; - priv->bad = 0; - priv->reset = 0; - priv->retransmissions = 0; - if (priv->Conf->tx_delay_ms) - { - priv->tx_done_delayed = jiffies + (priv->Conf->tx_delay_ms * HZ) / 1000 + 1; - } - else - { - TXLAST(dev).offset = 0; - if (priv->txLast) - priv->txLast = 0; - else if (TXTAIL(dev).offset) - priv->txLast = 1; - if (TXLAST(dev).offset) - { - arlan_retransmit_now(dev); - dev->trans_start = jiffies; - } - if (!TXHEAD(dev).offset || !TXTAIL(dev).offset) - { - netif_wake_queue (dev); - } + IFDEBUG(ARLAN_DEBUG_TX_CHAIN) + printk("arlan intr: transmit OK\n"); + dev->stats.tx_packets++; + priv->bad = 0; + priv->reset = 0; + priv->retransmissions = 0; + if (priv->Conf->tx_delay_ms) + priv->tx_done_delayed = jiffies + (priv->Conf->tx_delay_ms * HZ) / 1000 + 1; + else { + TXLAST(dev).offset = 0; + if (priv->txLast) + priv->txLast = 0; + else if (TXTAIL(dev).offset) + priv->txLast = 1; + + if (TXLAST(dev).offset) { + arlan_retransmit_now(dev); + dev->trans_start = jiffies; } - } - break; - - case 2: - { - IFDEBUG(ARLAN_DEBUG_TX_CHAIN) - printk("arlan intr: transmit timed out\n"); - priv->bad += 1; - //arlan_queue_retransmit(dev); - RetryOrFail(dev); - } - break; - case 3: - { - IFDEBUG(ARLAN_DEBUG_TX_CHAIN) - printk("arlan intr: transmit max retries\n"); - priv->bad += 1; - priv->reset = 0; - //arlan_queue_retransmit(dev); - RetryOrFail(dev); + if (!TXHEAD(dev).offset || !TXTAIL(dev).offset) + netif_wake_queue(dev); } - break; - - case 4: - { - IFDEBUG(ARLAN_DEBUG_TX_CHAIN) - printk("arlan intr: transmit aborted\n"); - priv->bad += 1; - arlan_queue_retransmit(dev); - //RetryOrFail(dev); - } - break; + } + break; - case 5: - { - IFDEBUG(ARLAN_DEBUG_TX_CHAIN) - printk("arlan intr: transmit not registered\n"); - priv->bad += 1; - //debug=101; - arlan_queue_retransmit(dev); - } - break; + case 2: + { + IFDEBUG(ARLAN_DEBUG_TX_CHAIN) + printk("arlan intr: transmit timed out\n"); + priv->bad += 1; + /* arlan_queue_retransmit(dev); */ + RetryOrFail(dev); + } + break; - case 6: - { - IFDEBUG(ARLAN_DEBUG_TX_CHAIN) - printk("arlan intr: transmit destination full\n"); - priv->bad += 1; - priv->reset = 0; - //arlan_drop_tx(dev); - arlan_queue_retransmit(dev); - } - break; + case 3: + { + IFDEBUG(ARLAN_DEBUG_TX_CHAIN) + printk("arlan intr: transmit max retries\n"); + priv->bad += 1; + priv->reset = 0; + /* arlan_queue_retransmit(dev); */ + RetryOrFail(dev); + } + break; - case 7: - { - IFDEBUG(ARLAN_DEBUG_TX_CHAIN) - printk("arlan intr: transmit unknown ack\n"); - priv->bad += 1; - priv->reset = 0; - arlan_queue_retransmit(dev); - } - break; - - case 8: - { - IFDEBUG(ARLAN_DEBUG_TX_CHAIN) - printk("arlan intr: transmit dest mail box full\n"); - priv->bad += 1; - priv->reset = 0; - //arlan_drop_tx(dev); - arlan_queue_retransmit(dev); - } - break; + case 4: + { + IFDEBUG(ARLAN_DEBUG_TX_CHAIN) + printk("arlan intr: transmit aborted\n"); + priv->bad += 1; + arlan_queue_retransmit(dev); + /* RetryOrFail(dev); */ + } + break; - case 9: - { - IFDEBUG(ARLAN_DEBUG_TX_CHAIN) - printk("arlan intr: transmit root dest not reg.\n"); - priv->bad += 1; - priv->reset = 1; - //arlan_drop_tx(dev); - arlan_queue_retransmit(dev); - } - break; + case 5: + { + IFDEBUG(ARLAN_DEBUG_TX_CHAIN) + printk("arlan intr: transmit not registered\n"); + priv->bad += 1; + /* debug=101; */ + arlan_queue_retransmit(dev); + } + break; - default: - { - printk(KERN_ERR "arlan intr: transmit status unknown\n"); - priv->bad += 1; - priv->reset = 1; - arlan_drop_tx(dev); - } + case 6: + { + IFDEBUG(ARLAN_DEBUG_TX_CHAIN) + printk("arlan intr: transmit destination full\n"); + priv->bad += 1; + priv->reset = 0; + /* arlan_drop_tx(dev); */ + arlan_queue_retransmit(dev); + } + break; + + case 7: + { + IFDEBUG(ARLAN_DEBUG_TX_CHAIN) + printk("arlan intr: transmit unknown ack\n"); + priv->bad += 1; + priv->reset = 0; + arlan_queue_retransmit(dev); + } + break; + + case 8: + { + IFDEBUG(ARLAN_DEBUG_TX_CHAIN) + printk("arlan intr: transmit dest mail box full\n"); + priv->bad += 1; + priv->reset = 0; + /* arlan_drop_tx(dev); */ + arlan_queue_retransmit(dev); + } + break; + + case 9: + { + IFDEBUG(ARLAN_DEBUG_TX_CHAIN) + printk("arlan intr: transmit root dest not reg.\n"); + priv->bad += 1; + priv->reset = 1; + /* arlan_drop_tx(dev); */ + arlan_queue_retransmit(dev); + } + break; + + default: + { + printk(KERN_ERR "arlan intr: transmit status unknown\n"); + priv->bad += 1; + priv->reset = 1; + arlan_drop_tx(dev); + } } ARLAN_DEBUG_EXIT("arlan_tx_done_interrupt"); @@ -1408,135 +1309,126 @@ static void arlan_rx_interrupt(struct net_device *dev, u_char rxStatus, u_short ARLAN_DEBUG_ENTRY("arlan_rx_interrupt"); - // by spec, not WRITESHMB(arlan->rxStatus,0x00); - // prohibited here arlan_command(dev, ARLAN_COMMAND_RX); + /* by spec, not WRITESHMB(arlan->rxStatus,0x00); */ + /* prohibited here arlan_command(dev, ARLAN_COMMAND_RX); */ - if (pkt_len < 10 || pkt_len > 2048) - { + if (pkt_len < 10 || pkt_len > 2048) { printk(KERN_WARNING "%s: got too short or long packet, len %d \n", dev->name, pkt_len); return; } - if (rxOffset + pkt_len > 0x2000) - { + if (rxOffset + pkt_len > 0x2000) { printk("%s: got too long packet, len %d offset %x\n", dev->name, pkt_len, rxOffset); return; } + priv->in_bytes += pkt_len; priv->in_bytes10 += pkt_len; if (conf->measure_rate < 1) conf->measure_rate = 1; - if (time_after(jiffies, priv->in_time + conf->measure_rate * HZ)) - { + if (time_after(jiffies, priv->in_time + conf->measure_rate * HZ)) { conf->in_speed = priv->in_bytes / conf->measure_rate; priv->in_bytes = 0; priv->in_time = jiffies; } - if (time_after(jiffies, priv->in_time10 + conf->measure_rate * 10*HZ)) - { + if (time_after(jiffies, priv->in_time10 + conf->measure_rate * 10*HZ)) { conf->in_speed10 = priv->in_bytes10 / (10 * conf->measure_rate); priv->in_bytes10 = 0; priv->in_time10 = jiffies; } DEBUGSHM(1, "arlan rcv pkt rxStatus= %d ", arlan->rxStatus, u_char); - switch (rxStatus) + switch (rxStatus) { + case 1: + case 2: + case 3: { - case 1: - case 2: - case 3: - { - /* Malloc up new buffer. */ - struct sk_buff *skb; + /* Malloc up new buffer. */ + struct sk_buff *skb; - DEBUGSHM(50, "arlan recv pkt offs=%d\n", arlan->rxOffset, u_short); - DEBUGSHM(1, "arlan rxFrmType = %d \n", arlan->rxFrmType, u_char); - DEBUGSHM(1, KERN_INFO "arlan rx scrambled = %d \n", arlan->scrambled, u_char); + DEBUGSHM(50, "arlan recv pkt offs=%d\n", arlan->rxOffset, u_short); + DEBUGSHM(1, "arlan rxFrmType = %d \n", arlan->rxFrmType, u_char); + DEBUGSHM(1, KERN_INFO "arlan rx scrambled = %d \n", arlan->scrambled, u_char); - /* here we do multicast filtering to avoid slow 8-bit memcopy */ + /* here we do multicast filtering to avoid slow 8-bit memcopy */ #ifdef ARLAN_MULTICAST - if (!(dev->flags & IFF_ALLMULTI) && - !(dev->flags & IFF_PROMISC) && - !netdev_mc_empty(dev)) - { - char hw_dst_addr[6]; - struct netdev_hw_addr *ha; - int i; - - memcpy_fromio(hw_dst_addr, arlan->ultimateDestAddress, 6); - if (hw_dst_addr[0] == 0x01) - { - if (mdebug) - if (hw_dst_addr[1] == 0x00) - printk(KERN_ERR "%s mcast 0x0100 \n", dev->name); - else if (hw_dst_addr[1] == 0x40) - printk(KERN_ERR "%s m/bcast 0x0140 \n", dev->name); - netdev_for_each_mc_entry(ha, dev) { - if (arlan_debug & ARLAN_DEBUG_HEADER_DUMP) - printk(KERN_ERR "%s mcl %pM\n", - dev->name, - ha->addr); - for (i = 0; i < 6; i++) - if (ha->addr[i] != hw_dst_addr[i]) - break; - if (i == 6) + if (!(dev->flags & IFF_ALLMULTI) && + !(dev->flags & IFF_PROMISC) && + !netdev_mc_empty(dev)) { + char hw_dst_addr[6]; + struct netdev_hw_addr *ha; + int i; + + memcpy_fromio(hw_dst_addr, arlan->ultimateDestAddress, 6); + if (hw_dst_addr[0] == 0x01) { + if (mdebug) + if (hw_dst_addr[1] == 0x00) + printk(KERN_ERR "%s mcast 0x0100 \n", dev->name); + else if (hw_dst_addr[1] == 0x40) + printk(KERN_ERR "%s m/bcast 0x0140 \n", dev->name); + netdev_for_each_mc_entry(ha, dev) { + if (arlan_debug & ARLAN_DEBUG_HEADER_DUMP) + printk(KERN_ERR "%s mcl %pM\n", + dev->name, ha->addr); + for (i = 0; i < 6; i++) + if (ha->addr[i] != hw_dst_addr[i]) break; - } - /* we reach here if multicast filtering is on and packet - * is multicast and not for receive */ - goto end_of_interrupt; + if (i == 6) + break; } + /* we reach here if multicast filtering is on and packet */ + /* is multicast and not for receive */ + goto end_of_interrupt; } -#endif // ARLAN_MULTICAST - /* multicast filtering ends here */ - pkt_len += ARLAN_FAKE_HDR_LEN; - - skb = dev_alloc_skb(pkt_len + 4); - if (skb == NULL) - { - printk(KERN_ERR "%s: Memory squeeze, dropping packet.\n", dev->name); - dev->stats.rx_dropped++; - break; - } - skb_reserve(skb, 2); - skbtmp = skb_put(skb, pkt_len); + } +#endif /* ARLAN_MULTICAST */ + /* multicast filtering ends here */ + pkt_len += ARLAN_FAKE_HDR_LEN; + + skb = dev_alloc_skb(pkt_len + 4); + if (skb == NULL) { + printk(KERN_ERR "%s: Memory squeeze, dropping packet.\n", dev->name); + dev->stats.rx_dropped++; + break; + } + skb_reserve(skb, 2); + skbtmp = skb_put(skb, pkt_len); - memcpy_fromio(skbtmp + ARLAN_FAKE_HDR_LEN, ((char __iomem *) arlan) + rxOffset, pkt_len - ARLAN_FAKE_HDR_LEN); - memcpy_fromio(skbtmp, arlan->ultimateDestAddress, 6); - memcpy_fromio(skbtmp + 6, arlan->rxSrc, 6); - WRITESHMB(arlan->rxStatus, 0x00); - arlan_command(dev, ARLAN_COMMAND_RX); + memcpy_fromio(skbtmp + ARLAN_FAKE_HDR_LEN, ((char __iomem *) arlan) + rxOffset, pkt_len - ARLAN_FAKE_HDR_LEN); + memcpy_fromio(skbtmp, arlan->ultimateDestAddress, 6); + memcpy_fromio(skbtmp + 6, arlan->rxSrc, 6); + WRITESHMB(arlan->rxStatus, 0x00); + arlan_command(dev, ARLAN_COMMAND_RX); - IFDEBUG(ARLAN_DEBUG_HEADER_DUMP) - { - char immedDestAddress[6]; - char immedSrcAddress[6]; - memcpy_fromio(immedDestAddress, arlan->immedDestAddress, 6); - memcpy_fromio(immedSrcAddress, arlan->immedSrcAddress, 6); - - printk(KERN_WARNING "%s t %pM f %pM imd %pM ims %pM\n", - dev->name, skbtmp, - &skbtmp[6], - immedDestAddress, - immedSrcAddress); - } - skb->protocol = eth_type_trans(skb, dev); - IFDEBUG(ARLAN_DEBUG_HEADER_DUMP) - if (skb->protocol != 0x608 && skb->protocol != 0x8) - { - for (i = 0; i <= 22; i++) - printk("%02x:", (u_char) skbtmp[i + 12]); - printk(KERN_ERR "\n"); - printk(KERN_WARNING "arlan kernel pkt type trans %x \n", skb->protocol); - } - netif_rx(skb); - dev->stats.rx_packets++; - dev->stats.rx_bytes += pkt_len; + IFDEBUG(ARLAN_DEBUG_HEADER_DUMP) + { + char immedDestAddress[6]; + char immedSrcAddress[6]; + memcpy_fromio(immedDestAddress, arlan->immedDestAddress, 6); + memcpy_fromio(immedSrcAddress, arlan->immedSrcAddress, 6); + + printk(KERN_WARNING "%s t %pM f %pM imd %pM ims %pM\n", + dev->name, skbtmp, + &skbtmp[6], + immedDestAddress, + immedSrcAddress); } + skb->protocol = eth_type_trans(skb, dev); + IFDEBUG(ARLAN_DEBUG_HEADER_DUMP) + if (skb->protocol != 0x608 && skb->protocol != 0x8) { + for (i = 0; i <= 22; i++) + printk("%02x:", (u_char) skbtmp[i + 12]); + printk(KERN_ERR "\n"); + printk(KERN_WARNING "arlan kernel pkt type trans %x \n", skb->protocol); + } + netif_rx(skb); + dev->stats.rx_packets++; + dev->stats.rx_bytes += pkt_len; + } + break; + + default: + printk(KERN_ERR "arlan intr: received unknown status\n"); + dev->stats.rx_crc_errors++; break; - - default: - printk(KERN_ERR "arlan intr: received unknown status\n"); - dev->stats.rx_crc_errors++; - break; } ARLAN_DEBUG_EXIT("arlan_rx_interrupt"); } @@ -1553,30 +1445,26 @@ static void arlan_process_interrupt(struct net_device *dev) ARLAN_DEBUG_ENTRY("arlan_process_interrupt"); - if (test_and_set_bit(0, (void *) &priv->interrupt_processing_active)) - { + if (test_and_set_bit(0, (void *) &priv->interrupt_processing_active)) { if (arlan_debug & ARLAN_DEBUG_CHAIN_LOCKS) printk(KERN_ERR "interrupt chain reentering \n"); goto end_int_process; } while ((rxStatus || txStatus || priv->interrupt_ack_requested) - && (interrupt_count < 5)) - { + && (interrupt_count < 5)) { if (rxStatus) priv->last_rx_int_ack_time = jiffies; arlan_command(dev, ARLAN_COMMAND_INT_ACK); arlan_command(dev, ARLAN_COMMAND_INT_ENABLE); - + IFDEBUG(ARLAN_DEBUG_INTERRUPT) printk(KERN_ERR "%s: got IRQ rx %x tx %x comm %x rxOff %x rxLen %x \n", dev->name, rxStatus, txStatus, READSHMB(arlan->commandByte), rxOffset, pkt_len); - if (rxStatus == 0 && txStatus == 0) - { - if (priv->irq_test_done) - { + if (rxStatus == 0 && txStatus == 0) { + if (priv->irq_test_done) { if (!registrationBad(dev)) IFDEBUG(ARLAN_DEBUG_INTERRUPT) printk(KERN_ERR "%s unknown interrupt(nop? regLost ?) reason tx %d rx %d ", dev->name, txStatus, rxStatus); @@ -1588,35 +1476,35 @@ static void arlan_process_interrupt(struct net_device *dev) priv->interrupt_ack_requested = 0; goto ends; } - if (txStatus != 0) - { + + if (txStatus != 0) { WRITESHMB(arlan->txStatus, 0x00); arlan_tx_done_interrupt(dev, txStatus); goto ends; } - if (rxStatus == 1 || rxStatus == 2) - { /* a packet waiting */ + + if (rxStatus == 1 || rxStatus == 2) { + /* a packet waiting */ arlan_rx_interrupt(dev, rxStatus, rxOffset, pkt_len); goto ends; } - if (rxStatus > 2 && rxStatus < 0xff) - { + + if (rxStatus > 2 && rxStatus < 0xff) { WRITESHMB(arlan->rxStatus, 0x00); printk(KERN_ERR "%s unknown rxStatus reason tx %d rx %d ", dev->name, txStatus, rxStatus); goto ends; } - if (rxStatus == 0xff) - { + + if (rxStatus == 0xff) { WRITESHMB(arlan->rxStatus, 0x00); arlan_command(dev, ARLAN_COMMAND_RX); if (registrationBad(dev)) netif_device_detach(dev); - if (!registrationBad(dev)) - { + if (!registrationBad(dev)) { priv->registrationLastSeen = jiffies; if (!netif_queue_stopped(dev) && !priv->under_reset && !priv->under_config) - netif_wake_queue (dev); + netif_wake_queue(dev); } goto ends; } @@ -1658,7 +1546,7 @@ static irqreturn_t arlan_interrupt(int irq, void *dev_id) priv->interrupt_ack_requested++; arlan_process_interrupt(dev); - + priv->irq_test_done = 1; ARLAN_DEBUG_EXIT("arlan_interrupt"); @@ -1688,7 +1576,7 @@ static int arlan_close(struct net_device *dev) } #ifdef ARLAN_DEBUGGING -static long alignLong(volatile u_char * ptr) +static long alignLong(volatile u_char *ptr) { long ret; memcpy_fromio(&ret, (void *) ptr, 4); @@ -1741,16 +1629,13 @@ static void arlan_set_multicast(struct net_device *dev) ARLAN_DEBUG_ENTRY("arlan_set_multicast"); - if (dev->flags & IFF_PROMISC) - { + if (dev->flags & IFF_PROMISC) { unsigned char recMode; READSHM(recMode, arlan->receiveMode, u_char); conf->receiveMode = (ARLAN_RCV_PROMISC | ARLAN_RCV_CONTROL); if (conf->receiveMode != recMode) board_conf_needed = 1; - } - else - { + } else { /* turn off promiscuous mode */ unsigned char recMode; READSHM(recMode, arlan->receiveMode, u_char); @@ -1758,6 +1643,7 @@ static void arlan_set_multicast(struct net_device *dev) if (conf->receiveMode != recMode) board_conf_needed = 1; } + if (board_conf_needed) arlan_command(dev, ARLAN_COMMAND_CONF); @@ -1776,7 +1662,7 @@ struct net_device * __init arlan_probe(int unit) if (arlans_found == MAX_ARLANS) return ERR_PTR(-ENODEV); - /* + /* * Reserve space for local data and a copy of the shared memory * that is used by the /proc interface. */ @@ -1788,23 +1674,20 @@ struct net_device * __init arlan_probe(int unit) if (unit >= 0) { sprintf(dev->name, "eth%d", unit); netdev_boot_setup_check(dev); - + if (dev->mem_start) { if (arlan_probe_here(dev, dev->mem_start) == 0) goto found; goto not_found; } - } - for (m = (int)phys_to_virt(lastFoundAt) + ARLAN_SHMEM_SIZE; - m <= (int)phys_to_virt(0xDE000); - m += ARLAN_SHMEM_SIZE) - { - if (arlan_probe_here(dev, m) == 0) - { - lastFoundAt = (int)virt_to_phys((void*)m); + for (m = (int)phys_to_virt(lastFoundAt) + ARLAN_SHMEM_SIZE; + m <= (int)phys_to_virt(0xDE000); + m += ARLAN_SHMEM_SIZE) { + if (arlan_probe_here(dev, m) == 0) { + lastFoundAt = (int)virt_to_phys((void *)m); goto found; } } @@ -1826,7 +1709,7 @@ struct net_device * __init arlan_probe(int unit) return dev; } -#ifdef MODULE +#ifdef MODULE int __init init_module(void) { int i = 0; @@ -1839,7 +1722,7 @@ int __init init_module(void) for (i = 0; i < MAX_ARLANS; i++) { struct net_device *dev = arlan_probe(i); - if (IS_ERR(dev)) + if (IS_ERR(dev)) return PTR_ERR(dev); } init_arlan_proc(); @@ -1861,14 +1744,13 @@ void __exit cleanup_module(void) cleanup_arlan_proc(); - for (i = 0; i < MAX_ARLANS; i++) - { + for (i = 0; i < MAX_ARLANS; i++) { dev = arlan_device[i]; if (dev) { - arlan_command(dev, ARLAN_COMMAND_POWERDOWN ); + arlan_command(dev, ARLAN_COMMAND_POWERDOWN); unregister_netdev(dev); - release_mem_region(virt_to_phys((void *) dev->mem_start), + release_mem_region(virt_to_phys((void *) dev->mem_start), ARLAN_SHMEM_SIZE); free_netdev(dev); arlan_device[i] = NULL; diff --git a/drivers/staging/arlan/arlan-proc.c b/drivers/staging/arlan/arlan-proc.c index b22983e6c0cf..62cd1d0b59ef 100644 --- a/drivers/staging/arlan/arlan-proc.c +++ b/drivers/staging/arlan/arlan-proc.c @@ -9,48 +9,55 @@ -#define ARLAN_STR_SIZE 0x2ff0 -#define DEV_ARLAN_INFO 1 -#define DEV_ARLAN 1 -#define SARLG(type,var) {\ - pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x%x\n", #var, READSHMB(priva->card->var)); \ +#define ARLAN_STR_SIZE 0x2ff0 +#define DEV_ARLAN_INFO 1 +#define DEV_ARLAN 1 +#define SARLG(type, var) {\ + pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x%x\n", #var,\ + READSHMB(priva->card->var));\ } -#define SARLBN(type,var,nn) {\ - pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x",#var);\ - for (i=0; i < nn; i++ ) pos += sprintf(arlan_drive_info+pos, "%02x",READSHMB(priva->card->var[i]));\ - pos += sprintf(arlan_drive_info+pos, "\n"); \ +#define SARLBN(type, var, nn) {\ + pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x", #var);\ + for (i = 0; i < nn; i++)\ + pos += sprintf(arlan_drive_info+pos, "%02x",\ + READSHMB(priva->card->var[i]));\ + pos += sprintf(arlan_drive_info+pos, "\n");\ } -#define SARLBNpln(type,var,nn) {\ - for (i=0; i < nn; i++ ) pos += sprintf(arlan_drive_info+pos, "%02x",READSHMB(priva->card->var[i]));\ +#define SARLBNpln(type, var, nn) {\ + for (i = 0; i < nn; i++)\ + pos += sprintf(arlan_drive_info+pos, "%02x",\ + READSHMB(priva->card->var[i]));\ } -#define SARLSTR(var,nn) {\ +#define SARLSTR(var, nn) {\ char tmpStr[400];\ int tmpLn = nn;\ - if (nn > 399 ) tmpLn = 399; \ - memcpy(tmpStr,(char *) priva->conf->var,tmpLn);\ + if (nn > 399)\ + tmpLn = 399;\ + memcpy(tmpStr, (char *) priva->conf->var, tmpLn);\ tmpStr[tmpLn] = 0; \ - pos += sprintf(arlan_drive_info+pos, "%s\t=\t%s \n",#var,priva->conf->var);\ + pos += sprintf(arlan_drive_info+pos, "%s\t=\t%s\n",\ + #var, priva->conf->var);\ } -#define SARLUC(var) SARLG(u_char, var) -#define SARLUCN(var,nn) SARLBN(u_char,var, nn) +#define SARLUC(var) SARLG(u_char, var) +#define SARLUCN(var, nn) SARLBN(u_char, var, nn) #define SARLUS(var) SARLG(u_short, var) -#define SARLUSN(var,nn) SARLBN(u_short,var, nn) +#define SARLUSN(var, nn) SARLBN(u_short, var, nn) #define SARLUI(var) SARLG(u_int, var) #define SARLUSA(var) {\ u_short tmpVar;\ - memcpy(&tmpVar, (short *) priva->conf->var,2); \ - pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x%x\n",#var, tmpVar);\ + memcpy(&tmpVar, (short *) priva->conf->var, 2); \ + pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x%x\n", #var, tmpVar);\ } #define SARLUIA(var) {\ u_int tmpVar;\ - memcpy(&tmpVar, (int* )priva->conf->var,4); \ - pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x%x\n",#var, tmpVar);\ + memcpy(&tmpVar, (int *)priva->conf->var, 4); \ + pos += sprintf(arlan_drive_info+pos, "%s\t=\t0x%x\n", #var, tmpVar);\ } @@ -63,51 +70,51 @@ static const char *arlan_diagnostic_info_string(struct net_device *dev) READSHM(diagnosticInfo, arlan->diagnosticInfo, u_char); - switch (diagnosticInfo) - { - case 0xFF: + switch (diagnosticInfo) { + + case 0xFF: return "Diagnostic info is OK"; - case 0xFE: - return "ERROR EPROM Checksum error "; - case 0xFD: - return "ERROR Local Ram Test Failed "; - case 0xFC: - return "ERROR SCC failure "; - case 0xFB: - return "ERROR BackBone failure "; - case 0xFA: - return "ERROR transceiver not found "; - case 0xF9: - return "ERROR no more address space "; - case 0xF8: - return "ERROR Checksum error "; - case 0xF7: - return "ERROR Missing SS Code"; - case 0xF6: - return "ERROR Invalid config format"; - case 0xF5: - return "ERROR Reserved errorcode F5"; - case 0xF4: - return "ERROR Invalid spreading code/channel number"; - case 0xF3: - return "ERROR Load Code Error"; - case 0xF2: - return "ERROR Reserver errorcode F2 "; - case 0xF1: - return "ERROR Invalid command receivec by LAN card "; - case 0xF0: - return "ERROR Invalid parameter found in command "; - case 0xEF: - return "ERROR On-chip timer failure "; - case 0xEE: - return "ERROR T410 timer failure "; - case 0xED: - return "ERROR Too Many TxEnable commands "; - case 0xEC: - return "ERROR EEPROM error on radio module "; - default: - return "ERROR unknown Diagnostic info reply code "; - } + case 0xFE: + return "ERROR EPROM Checksum error "; + case 0xFD: + return "ERROR Local Ram Test Failed "; + case 0xFC: + return "ERROR SCC failure "; + case 0xFB: + return "ERROR BackBone failure "; + case 0xFA: + return "ERROR transceiver not found "; + case 0xF9: + return "ERROR no more address space "; + case 0xF8: + return "ERROR Checksum error "; + case 0xF7: + return "ERROR Missing SS Code"; + case 0xF6: + return "ERROR Invalid config format"; + case 0xF5: + return "ERROR Reserved errorcode F5"; + case 0xF4: + return "ERROR Invalid spreading code/channel number"; + case 0xF3: + return "ERROR Load Code Error"; + case 0xF2: + return "ERROR Reserver errorcode F2 "; + case 0xF1: + return "ERROR Invalid command receivec by LAN card "; + case 0xF0: + return "ERROR Invalid parameter found in command "; + case 0xEF: + return "ERROR On-chip timer failure "; + case 0xEE: + return "ERROR T410 timer failure "; + case 0xED: + return "ERROR Too Many TxEnable commands "; + case 0xEC: + return "ERROR EEPROM error on radio module "; + default: + return "ERROR unknown Diagnostic info reply code "; + } } static const char *arlan_hardware_type_string(struct net_device *dev) @@ -117,70 +124,69 @@ static const char *arlan_hardware_type_string(struct net_device *dev) volatile struct arlan_shmem __iomem *arlan = priv->card; READSHM(hardwareType, arlan->hardwareType, u_char); - switch (hardwareType) - { - case 0x00: - return "type A450"; - case 0x01: - return "type A650 "; - case 0x04: - return "type TMA coproc"; - case 0x0D: - return "type A650E "; - case 0x18: - return "type TMA coproc Australian"; - case 0x19: - return "type A650A "; - case 0x26: - return "type TMA coproc European"; - case 0x2E: - return "type A655 "; - case 0x2F: - return "type A655A "; - case 0x30: - return "type A655E "; - case 0x0B: - return "type A670 "; - case 0x0C: - return "type A670E "; - case 0x2D: - return "type A670A "; - case 0x0F: - return "type A411T"; - case 0x16: - return "type A411TA"; - case 0x1B: - return "type A440T"; - case 0x1C: - return "type A412T"; - case 0x1E: - return "type A412TA"; - case 0x22: - return "type A411TE"; - case 0x24: - return "type A412TE"; - case 0x27: - return "type A671T "; - case 0x29: - return "type A671TA "; - case 0x2B: - return "type A671TE "; - case 0x31: - return "type A415T "; - case 0x33: - return "type A415TA "; - case 0x35: - return "type A415TE "; - case 0x37: - return "type A672"; - case 0x39: - return "type A672A "; - case 0x3B: - return "type A672T"; - case 0x6B: - return "type IC2200"; - default: - return "type A672T"; + switch (hardwareType) { + case 0x00: + return "type A450"; + case 0x01: + return "type A650 "; + case 0x04: + return "type TMA coproc"; + case 0x0D: + return "type A650E "; + case 0x18: + return "type TMA coproc Australian"; + case 0x19: + return "type A650A "; + case 0x26: + return "type TMA coproc European"; + case 0x2E: + return "type A655 "; + case 0x2F: + return "type A655A "; + case 0x30: + return "type A655E "; + case 0x0B: + return "type A670 "; + case 0x0C: + return "type A670E "; + case 0x2D: + return "type A670A "; + case 0x0F: + return "type A411T"; + case 0x16: + return "type A411TA"; + case 0x1B: + return "type A440T"; + case 0x1C: + return "type A412T"; + case 0x1E: + return "type A412TA"; + case 0x22: + return "type A411TE"; + case 0x24: + return "type A412TE"; + case 0x27: + return "type A671T "; + case 0x29: + return "type A671TA "; + case 0x2B: + return "type A671TE "; + case 0x31: + return "type A415T "; + case 0x33: + return "type A415TA "; + case 0x35: + return "type A415TE "; + case 0x37: + return "type A672"; + case 0x39: + return "type A672A "; + case 0x3B: + return "type A672T"; + case 0x6B: + return "type IC2200"; + default: + return "type A672T"; } } #ifdef ARLAN_DEBUGGING @@ -193,12 +199,12 @@ static void arlan_print_diagnostic_info(struct net_device *dev) struct arlan_private *priv = netdev_priv(dev); volatile struct arlan_shmem __iomem *arlan = priv->card; - // ARLAN_DEBUG_ENTRY("arlan_print_diagnostic_info"); + /* ARLAN_DEBUG_ENTRY("arlan_print_diagnostic_info"); */ if (READSHMB(arlan->configuredStatusFlag) == 0) - printk("Arlan: Card NOT configured\n"); + printk(KERN_WARNING "Arlan: Card NOT configured\n"); else - printk("Arlan: Card is configured\n"); + printk(KERN_INFO "Arlan: Card is configured\n"); READSHM(diagnosticInfo, arlan->diagnosticInfo, u_char); READSHM(diagnosticOffset, arlan->diagnosticOffset, u_short); @@ -206,14 +212,15 @@ static void arlan_print_diagnostic_info(struct net_device *dev) printk(KERN_INFO "%s\n", arlan_diagnostic_info_string(dev)); if (diagnosticInfo != 0xff) - printk("%s arlan: Diagnostic Offset %d \n", dev->name, diagnosticOffset); + printk(KERN_INFO "%s arlan: Diagnostic Offset %d\n",\ + dev->name, diagnosticOffset); - printk("arlan: LAN CODE ID = "); + printk(KERN_INFO "arlan: LAN CODE ID = "); for (i = 0; i < 6; i++) DEBUGSHM(1, "%03d:", arlan->lanCardNodeId[i], u_char); printk("\n"); - printk("arlan: Arlan BroadCast address = "); + printk(KERN_INFO "arlan: Arlan BroadCast address = "); for (i = 0; i < 6; i++) DEBUGSHM(1, "%03d:", arlan->broadcastAddress[i], u_char); printk("\n"); @@ -229,13 +236,13 @@ static void arlan_print_diagnostic_info(struct net_device *dev) DEBUGSHM(1, "arlan: SID =%d\n", arlan->SID, u_short); DEBUGSHM(1, "arlan: rxOffset=%d\n", arlan->rxOffset, u_short); - DEBUGSHM(1, "arlan: registration mode is %d\n", arlan->registrationMode, u_char); + DEBUGSHM(1, "arlan: registration mode is %d\n",\ + arlan->registrationMode, u_char); - printk("arlan: name= "); + printk(KERN_INFO "arlan: name= "); IFDEBUG(1) - - for (i = 0; i < 16; i++) - { + + for (i = 0; i < 16; i++) { char c; READSHM(c, arlan->name[i], char); if (c) @@ -243,18 +250,19 @@ static void arlan_print_diagnostic_info(struct net_device *dev) } printk("\n"); -// ARLAN_DEBUG_EXIT("arlan_print_diagnostic_info"); + /* ARLAN_DEBUG_EXIT("arlan_print_diagnostic_info"); */ } -/****************************** TEST MEMORY **************/ +/****************************** TEST MEMORY **************/ static int arlan_hw_test_memory(struct net_device *dev) { u_char *ptr; int i; - int memlen = sizeof(struct arlan_shmem) - 0xF; /* avoid control register */ + int memlen = sizeof(struct arlan_shmem) - 0xF; /* avoid + control register */ volatile char *arlan_mem = (char *) (dev->mem_start); struct arlan_private *priv = netdev_priv(dev); volatile struct arlan_shmem __iomem *arlan = priv->card; @@ -271,13 +279,11 @@ static int arlan_hw_test_memory(struct net_device *dev) WRITESHM(arlan_mem[i], ((u_char) pattern++), u_char); pattern = 0; - for (i = 0; i < memlen; i++) - { + for (i = 0; i < memlen; i++) { char res; READSHM(res, arlan_mem[i], char); - if (res != pattern++) - { - printk(KERN_ERR "Arlan driver memory test 1 failed \n"); + if (res != pattern++) { + printk(KERN_ERR "Arlan driver memory test 1 failed\n"); return -1; } } @@ -287,13 +293,11 @@ static int arlan_hw_test_memory(struct net_device *dev) WRITESHM(arlan_mem[i], ~(pattern++), char); pattern = 0; - for (i = 0; i < memlen; i++) - { + for (i = 0; i < memlen; i++) { char res; READSHM(res, arlan_mem[i], char); - if (res != ~(pattern++)) - { - printk(KERN_ERR "Arlan driver memory test 2 failed \n"); + if (res != ~(pattern++)) { + printk(KERN_ERR "Arlan driver memory test 2 failed\n"); return -1; } } @@ -311,9 +315,9 @@ static int arlan_hw_test_memory(struct net_device *dev) clearHardwareReset(dev); /* wait for reset flag to become zero, we'll wait for two seconds */ - if (arlan_command(dev, ARLAN_COMMAND_LONG_WAIT_NOW)) - { - printk(KERN_ERR "%s arlan: failed to come back from memory test\n", dev->name); + if (arlan_command(dev, ARLAN_COMMAND_LONG_WAIT_NOW)) { + printk(KERN_ERR "%s arlan: failed to come\ + back from memory test\n", dev->name); return -1; } return 0; @@ -325,29 +329,32 @@ static int arlan_setup_card_by_book(struct net_device *dev) struct arlan_private *priv = netdev_priv(dev); volatile struct arlan_shmem __iomem *arlan = priv->card; -// ARLAN_DEBUG_ENTRY("arlan_setup_card"); + /* ARLAN_DEBUG_ENTRY("arlan_setup_card"); */ READSHM(configuredStatusFlag, arlan->configuredStatusFlag, u_char); IFDEBUG(10) if (configuredStatusFlag != 0) - IFDEBUG(10) printk("arlan: CARD IS CONFIGURED\n"); + IFDEBUG(10) printk(KERN_INFO "arlan: CARD IS CONFIGURED\n"); else - IFDEBUG(10) printk("arlan: card is NOT configured\n"); + IFDEBUG(10) printk(KERN_WARNING\ + "arlan: card is NOT configured\n"); if (testMemory || (READSHMB(arlan->diagnosticInfo) != 0xff)) if (arlan_hw_test_memory(dev)) return -1; - DEBUGSHM(4, "arlan configuredStatus = %d \n", arlan->configuredStatusFlag, u_char); - DEBUGSHM(4, "arlan driver diagnostic: 0x%2x\n", arlan->diagnosticInfo, u_char); + DEBUGSHM(4, "arlan configuredStatus = %d\n",\ + arlan->configuredStatusFlag, u_char); + DEBUGSHM(4, "arlan driver diagnostic: 0x%2x\n",\ + arlan->diagnosticInfo, u_char); /* issue nop command - no interrupt */ arlan_command(dev, ARLAN_COMMAND_NOOP); if (arlan_command(dev, ARLAN_COMMAND_WAIT_NOW) != 0) return -1; - IFDEBUG(50) printk("1st Noop successfully executed !!\n"); + IFDEBUG(50) printk(KERN_INFO "1st Noop successfully executed !!\n"); /* try to turn on the arlan interrupts */ clearClearInterrupt(dev); @@ -361,18 +368,18 @@ static int arlan_setup_card_by_book(struct net_device *dev) return -1; - IFDEBUG(50) printk("2nd Noop successfully executed !!\n"); + IFDEBUG(50) printk(KERN_INFO "2nd Noop successfully executed !!\n"); READSHM(irqLevel, arlan->irqLevel, u_char) - - if (irqLevel != dev->irq) - { - IFDEBUG(1) printk(KERN_WARNING "arlan dip switches set irq to %d\n", irqLevel); - printk(KERN_WARNING "device driver irq set to %d - does not match\n", dev->irq); + + if (irqLevel != dev->irq) { + IFDEBUG(1) printk(KERN_WARNING "arlan dip switches\ + set irq to %d\n", irqLevel); + printk(KERN_WARNING "device driver irq set to %d-\ + does not match\n", dev->irq); dev->irq = irqLevel; - } - else - IFDEBUG(2) printk("irq level is OK\n"); + } else + IFDEBUG(2) printk(KERN_INFO "irq level is OK\n"); IFDEBUG(3) arlan_print_diagnostic_info(dev); @@ -380,8 +387,7 @@ static int arlan_setup_card_by_book(struct net_device *dev) arlan_command(dev, ARLAN_COMMAND_CONF); READSHM(configuredStatusFlag, arlan->configuredStatusFlag, u_char); - if (configuredStatusFlag == 0) - { + if (configuredStatusFlag == 0) { printk(KERN_WARNING "arlan configure failed\n"); return -1; } @@ -391,7 +397,7 @@ static int arlan_setup_card_by_book(struct net_device *dev) printk(KERN_NOTICE "%s: arlan driver version %s loaded\n", dev->name, arlan_version); -// ARLAN_DEBUG_EXIT("arlan_setup_card"); + /* ARLAN_DEBUG_EXIT("arlan_setup_card"); */ return 0; /* no errors */ } @@ -402,7 +408,7 @@ static int arlan_setup_card_by_book(struct net_device *dev) static char arlan_drive_info[ARLAN_STR_SIZE] = "A655\n\0"; -static int arlan_sysctl_info(ctl_table * ctl, int write, +static int arlan_sysctl_info(ctl_table *ctl, int write, void __user *buffer, size_t * lenp, loff_t *ppos) { int i; @@ -410,35 +416,30 @@ static int arlan_sysctl_info(ctl_table * ctl, int write, struct arlan_private *priva = NULL; struct net_device *dev; pos = 0; - if (write) - { - printk("wrirte: "); + if (write) { + printk(KERN_INFO "wrirte: "); for (i = 0; i < 100; i++) - printk("adi %x \n", arlan_drive_info[i]); + printk("adi %x\n", arlan_drive_info[i]); } - if (ctl->procname == NULL || arlan_drive_info == NULL) - { - printk(KERN_WARNING " procname is NULL in sysctl_table or arlan_drive_info is NULL \n at arlan module\n "); + if (ctl->procname == NULL || arlan_drive_info == NULL) { + printk(KERN_WARNING " procname is NULL in sysctl_table or arlan_drive_info is NULL\n at arlan module\n "); return -1; } devnum = ctl->procname[5] - '0'; - if (devnum < 0 || devnum > MAX_ARLANS - 1) - { + if (devnum < 0 || devnum > MAX_ARLANS - 1) { printk(KERN_WARNING "too strange devnum in procfs parse\n "); return -1; - } - else if (arlan_device[devnum] == NULL) - { + } else if (arlan_device[devnum] == NULL) { if (ctl->procname) - pos += sprintf(arlan_drive_info + pos, "\t%s\n\n", ctl->procname); - pos += sprintf(arlan_drive_info + pos, "No device found here \n"); + pos += sprintf(arlan_drive_info + pos,\ + "\t%s\n\n", ctl->procname); + pos += sprintf(arlan_drive_info + pos,\ + "No device found here\n"); goto final; - } - else + } else priva = netdev_priv(arlan_device[devnum]); - if (priva == NULL) - { + if (priva == NULL) { printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n "); return -1; } @@ -446,17 +447,19 @@ static int arlan_sysctl_info(ctl_table * ctl, int write, memcpy_fromio(priva->conf, priva->card, sizeof(struct arlan_shmem)); - pos = sprintf(arlan_drive_info, "Arlan info \n"); + pos = sprintf(arlan_drive_info, "Arlan info\n"); /* Header Signature */ SARLSTR(textRegion, 48); SARLUC(resetFlag); - pos += sprintf(arlan_drive_info + pos, "diagnosticInfo\t=\t%s \n", arlan_diagnostic_info_string(dev)); + pos += sprintf(arlan_drive_info + pos,\ + "diagnosticInfo\t=\t%s\n", arlan_diagnostic_info_string(dev)); SARLUC(diagnosticInfo); SARLUS(diagnosticOffset); SARLUCN(_1, 12); SARLUCN(lanCardNodeId, 6); SARLUCN(broadcastAddress, 6); - pos += sprintf(arlan_drive_info + pos, "hardwareType =\t %s \n", arlan_hardware_type_string(dev)); + pos += sprintf(arlan_drive_info + pos,\ + "hardwareType =\t %s\n", arlan_hardware_type_string(dev)); SARLUC(hardwareType); SARLUC(majorHardwareVersion); SARLUC(minorHardwareVersion); @@ -602,17 +605,18 @@ static int arlan_sysctl_info(ctl_table * ctl, int write, SARLUCN(dumpPtr, 4); SARLUC(dumpVal); SARLUC(wireTest); - + /* next 4 seems too long for procfs, over single page ? SARLUCN( _17, 0x86); SARLUCN( txBuffer, 0x800); - SARLUCN( rxBuffer, 0x800); + SARLUCN( rxBuffer, 0x800); SARLUCN( _18, 0x0bff); */ pos += sprintf(arlan_drive_info + pos, "rxRing\t=\t0x"); for (i = 0; i < 0x50; i++) - pos += sprintf(arlan_drive_info + pos, "%02x", ((char *) priva->conf)[priva->conf->rxOffset + i]); + pos += sprintf(arlan_drive_info + pos, "%02x",\ + ((char *) priva->conf)[priva->conf->rxOffset + i]); pos += sprintf(arlan_drive_info + pos, "\n"); SARLUC(configStatus); @@ -624,14 +628,14 @@ static int arlan_sysctl_info(ctl_table * ctl, int write, pos += sprintf(arlan_drive_info + pos, " total %d chars\n", pos); if (ctl) if (ctl->procname) - pos += sprintf(arlan_drive_info + pos, " driver name : %s\n", ctl->procname); + pos += sprintf(arlan_drive_info + pos,\ + " driver name : %s\n", ctl->procname); final: *lenp = pos; if (!write) retv = proc_dostring(ctl, write, buffer, lenp, ppos); - else - { + else { *lenp = 0; return -1; } @@ -639,7 +643,7 @@ final: } -static int arlan_sysctl_info161719(ctl_table * ctl, int write, +static int arlan_sysctl_info161719(ctl_table *ctl, int write, void __user *buffer, size_t * lenp, loff_t *ppos) { int i; @@ -648,16 +652,16 @@ static int arlan_sysctl_info161719(ctl_table * ctl, int write, pos = 0; devnum = ctl->procname[5] - '0'; - if (arlan_device[devnum] == NULL) - { - pos += sprintf(arlan_drive_info + pos, "No device found here \n"); + if (arlan_device[devnum] == NULL) { + pos += sprintf(arlan_drive_info + pos,\ + "No device found here\n"); goto final; - } - else + } else priva = netdev_priv(arlan_device[devnum]); - if (priva == NULL) - { - printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n "); + + if (priva == NULL) { + printk(KERN_WARNING " Could not find the device\ + private in arlan procsys, bad\n "); return -1; } memcpy_fromio(priva->conf, priva->card, sizeof(struct arlan_shmem)); @@ -673,7 +677,7 @@ final: return retv; } -static int arlan_sysctl_infotxRing(ctl_table * ctl, int write, +static int arlan_sysctl_infotxRing(ctl_table *ctl, int write, void __user *buffer, size_t * lenp, loff_t *ppos) { int i; @@ -682,15 +686,14 @@ static int arlan_sysctl_infotxRing(ctl_table * ctl, int write, pos = 0; devnum = ctl->procname[5] - '0'; - if (arlan_device[devnum] == NULL) - { - pos += sprintf(arlan_drive_info + pos, "No device found here \n"); - goto final; - } - else + if (arlan_device[devnum] == NULL) { + pos += sprintf(arlan_drive_info + pos,\ + "No device found here\n"); + goto final; + } else priva = netdev_priv(arlan_device[devnum]); - if (priva == NULL) - { + + if (priva == NULL) { printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n "); return -1; } @@ -702,7 +705,7 @@ final: return retv; } -static int arlan_sysctl_inforxRing(ctl_table * ctl, int write, +static int arlan_sysctl_inforxRing(ctl_table *ctl, int write, void __user *buffer, size_t * lenp, loff_t *ppos) { int i; @@ -711,14 +714,13 @@ static int arlan_sysctl_inforxRing(ctl_table * ctl, int write, pos = 0; devnum = ctl->procname[5] - '0'; - if (arlan_device[devnum] == NULL) - { - pos += sprintf(arlan_drive_info + pos, "No device found here \n"); - goto final; + if (arlan_device[devnum] == NULL) { + pos += sprintf(arlan_drive_info + pos,\ + "No device found here\n"); + goto final; } else priva = netdev_priv(arlan_device[devnum]); - if (priva == NULL) - { + if (priva == NULL) { printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n "); return -1; } @@ -730,7 +732,7 @@ final: return retv; } -static int arlan_sysctl_info18(ctl_table * ctl, int write, +static int arlan_sysctl_info18(ctl_table *ctl, int write, void __user *buffer, size_t * lenp, loff_t *ppos) { int i; @@ -739,18 +741,18 @@ static int arlan_sysctl_info18(ctl_table * ctl, int write, pos = 0; devnum = ctl->procname[5] - '0'; - if (arlan_device[devnum] == NULL) - { - pos += sprintf(arlan_drive_info + pos, "No device found here \n"); + if (arlan_device[devnum] == NULL) { + pos += sprintf(arlan_drive_info + pos,\ + "No device found here\n"); goto final; - } - else + } else priva = netdev_priv(arlan_device[devnum]); - if (priva == NULL) - { + + if (priva == NULL) { printk(KERN_WARNING " Could not find the device private in arlan procsys, bad\n "); return -1; } + memcpy_fromio(priva->conf, priva->card, sizeof(struct arlan_shmem)); SARLBNpln(u_char, _18, 0x800); @@ -766,74 +768,73 @@ final: static char conf_reset_result[200]; -static int arlan_configure(ctl_table * ctl, int write, +static int arlan_configure(ctl_table *ctl, int write, void __user *buffer, size_t * lenp, loff_t *ppos) { int pos = 0; int devnum = ctl->procname[6] - '0'; struct arlan_private *priv; - if (devnum < 0 || devnum > MAX_ARLANS - 1) - { - printk(KERN_WARNING "too strange devnum in procfs parse\n "); + if (devnum < 0 || devnum > MAX_ARLANS - 1) { + printk(KERN_WARNING "too strange devnum in procfs parse\n"); return -1; - } - else if (arlan_device[devnum] != NULL) - { - priv = netdev_priv(arlan_device[devnum]); - - arlan_command(arlan_device[devnum], ARLAN_COMMAND_CLEAN_AND_CONF); - } - else + } else if (arlan_device[devnum] != NULL) { + priv = netdev_priv(arlan_device[devnum]); + arlan_command(arlan_device[devnum],\ + ARLAN_COMMAND_CLEAN_AND_CONF); + } else return -1; *lenp = pos; return proc_dostring(ctl, write, buffer, lenp, ppos); } -static int arlan_sysctl_reset(ctl_table * ctl, int write, +static int arlan_sysctl_reset(ctl_table *ctl, int write, void __user *buffer, size_t * lenp, loff_t *ppos) { int pos = 0; int devnum = ctl->procname[5] - '0'; struct arlan_private *priv; - if (devnum < 0 || devnum > MAX_ARLANS - 1) - { - printk(KERN_WARNING "too strange devnum in procfs parse\n "); + if (devnum < 0 || devnum > MAX_ARLANS - 1) { + printk(KERN_WARNING "too strange devnum in procfs parse\n"); return -1; - } - else if (arlan_device[devnum] != NULL) - { + + } else if (arlan_device[devnum] != NULL) { priv = netdev_priv(arlan_device[devnum]); - arlan_command(arlan_device[devnum], ARLAN_COMMAND_CLEAN_AND_RESET); + arlan_command(arlan_device[devnum], \ + ARLAN_COMMAND_CLEAN_AND_RESET); } else return -1; + *lenp = pos + 3; return proc_dostring(ctl, write, buffer, lenp, ppos); } /* Place files in /proc/sys/dev/arlan */ -#define CTBLN(card,nam) \ - { .procname = #nam,\ - .data = &(arlan_conf[card].nam),\ - .maxlen = sizeof(int), .mode = 0600, .proc_handler = proc_dointvec} +#define CTBLN(card, nam) \ + { .procname = #nam,\ + .data = &(arlan_conf[card].nam),\ + .maxlen = sizeof(int), .mode = 0600, .proc_handler = proc_dointvec} #ifdef ARLAN_DEBUGGING -#define ARLAN_PROC_DEBUG_ENTRIES \ - { .procname = "entry_exit_debug",\ - .data = &arlan_entry_and_exit_debug,\ - .maxlen = sizeof(int), .mode = 0600, .proc_handler = proc_dointvec},\ +#define ARLAN_PROC_DEBUG_ENTRIES do {\ + + { .procname = "entry_exit_debug",\ + .data = &arlan_entry_and_exit_debug,\ + .maxlen = sizeof(int), .mode = 0600, .proc_handler = proc_dointvec},\ { .procname = "debug", .data = &arlan_debug,\ - .maxlen = sizeof(int), .mode = 0600, .proc_handler = proc_dointvec}, -#else + .maxlen = sizeof(int), .mode = 0600, .proc_handler = proc_dointvec}, + + } while (0) +#else #define ARLAN_PROC_DEBUG_ENTRIES #endif #define ARLAN_SYSCTL_TABLE_TOTAL(cardNo)\ - CTBLN(cardNo,spreadingCode),\ + CTBLN(cardNo, spreadingCode),\ CTBLN(cardNo, channelNumber),\ CTBLN(cardNo, scramblingDisable),\ CTBLN(cardNo, txAttenuation),\ @@ -861,43 +862,40 @@ static int arlan_sysctl_reset(ctl_table * ctl, int write, CTBLN(cardNo, rxParameter),\ CTBLN(cardNo, txTimeoutMs),\ CTBLN(cardNo, waitCardTimeout),\ - CTBLN(cardNo, channelSet), \ + CTBLN(cardNo, channelSet),\ { .procname = "name",\ .data = arlan_conf[cardNo].siteName,\ - .maxlen = 16, .mode = 0600, .proc_handler = proc_dostring},\ - CTBLN(cardNo,waitTime),\ - CTBLN(cardNo,lParameter),\ - CTBLN(cardNo,_15),\ - CTBLN(cardNo,headerSize),\ - CTBLN(cardNo,tx_delay_ms),\ - CTBLN(cardNo,retries),\ - CTBLN(cardNo,ReTransmitPacketMaxSize),\ - CTBLN(cardNo,waitReTransmitPacketMaxSize),\ - CTBLN(cardNo,fastReTransCount),\ - CTBLN(cardNo,driverRetransmissions),\ - CTBLN(cardNo,txAckTimeoutMs),\ - CTBLN(cardNo,registrationInterrupts),\ - CTBLN(cardNo,hardwareType),\ - CTBLN(cardNo,radioType),\ - CTBLN(cardNo,writeEEPROM),\ - CTBLN(cardNo,writeRadioType),\ + .maxlen = 16, .mode = 0600, .proc_handler = proc_dostring },\ + CTBLN(cardNo, waitTime),\ + CTBLN(cardNo, lParameter),\ + CTBLN(cardNo, _15),\ + CTBLN(cardNo, headerSize),\ + CTBLN(cardNo, tx_delay_ms),\ + CTBLN(cardNo, retries),\ + CTBLN(cardNo, ReTransmitPacketMaxSize),\ + CTBLN(cardNo, waitReTransmitPacketMaxSize),\ + CTBLN(cardNo, fastReTransCount),\ + CTBLN(cardNo, driverRetransmissions),\ + CTBLN(cardNo, txAckTimeoutMs),\ + CTBLN(cardNo, registrationInterrupts),\ + CTBLN(cardNo, hardwareType),\ + CTBLN(cardNo, radioType),\ + CTBLN(cardNo, writeEEPROM),\ + CTBLN(cardNo, writeRadioType),\ ARLAN_PROC_DEBUG_ENTRIES\ - CTBLN(cardNo,in_speed),\ - CTBLN(cardNo,out_speed),\ - CTBLN(cardNo,in_speed10),\ - CTBLN(cardNo,out_speed10),\ - CTBLN(cardNo,in_speed_max),\ - CTBLN(cardNo,out_speed_max),\ - CTBLN(cardNo,measure_rate),\ - CTBLN(cardNo,pre_Command_Wait),\ - CTBLN(cardNo,rx_tweak1),\ - CTBLN(cardNo,rx_tweak2),\ - CTBLN(cardNo,tx_queue_len),\ - - - -static ctl_table arlan_conf_table0[] = -{ + CTBLN(cardNo, in_speed),\ + CTBLN(cardNo, out_speed),\ + CTBLN(cardNo, in_speed10),\ + CTBLN(cardNo, out_speed10),\ + CTBLN(cardNo, in_speed_max),\ + CTBLN(cardNo, out_speed_max),\ + CTBLN(cardNo, measure_rate),\ + CTBLN(cardNo, pre_Command_Wait),\ + CTBLN(cardNo, rx_tweak1),\ + CTBLN(cardNo, rx_tweak2),\ + CTBLN(cardNo, tx_queue_len),\ + +static ctl_table arlan_conf_table0[] = { ARLAN_SYSCTL_TABLE_TOTAL(0) #ifdef ARLAN_PROC_SHM_DUMP @@ -954,8 +952,7 @@ static ctl_table arlan_conf_table0[] = { } }; -static ctl_table arlan_conf_table1[] = -{ +static ctl_table arlan_conf_table1[] = { ARLAN_SYSCTL_TABLE_TOTAL(1) @@ -1013,8 +1010,7 @@ static ctl_table arlan_conf_table1[] = { } }; -static ctl_table arlan_conf_table2[] = -{ +static ctl_table arlan_conf_table2[] = { ARLAN_SYSCTL_TABLE_TOTAL(2) @@ -1072,8 +1068,7 @@ static ctl_table arlan_conf_table2[] = { } }; -static ctl_table arlan_conf_table3[] = -{ +static ctl_table arlan_conf_table3[] = { ARLAN_SYSCTL_TABLE_TOTAL(3) @@ -1133,8 +1128,7 @@ static ctl_table arlan_conf_table3[] = -static ctl_table arlan_table[] = -{ +static ctl_table arlan_table[] = { { .procname = "arlan0", .maxlen = 0, @@ -1164,17 +1158,15 @@ static ctl_table arlan_table[] = #else -static ctl_table arlan_table[] = -{ +static ctl_table arlan_table[] = { { } }; #endif -// static int mmtu = 1234; +/* static int mmtu = 1234; */ -static ctl_table arlan_root_table[] = -{ +static ctl_table arlan_root_table[] = { { .procname = "arlan", .maxlen = 0, @@ -1189,8 +1181,6 @@ static struct ctl_table_header *arlan_device_sysctl_header; int __init init_arlan_proc(void) { - - int i = 0; if (arlan_device_sysctl_header) return 0; arlan_device_sysctl_header = register_sysctl_table(arlan_root_table); @@ -1198,7 +1188,6 @@ int __init init_arlan_proc(void) return -1; return 0; - } void __exit cleanup_arlan_proc(void) diff --git a/drivers/staging/arlan/arlan.h b/drivers/staging/arlan/arlan.h index ffcd3ea048aa..3974acf076b9 100644 --- a/drivers/staging/arlan/arlan.h +++ b/drivers/staging/arlan/arlan.h @@ -318,7 +318,7 @@ extern struct arlan_conf_stru arlan_conf[MAX_ARLANS]; struct TxParam { volatile short offset; volatile short length; - volatile u_char dest[6]; + volatile u_char dest[6]; volatile unsigned char clear; volatile unsigned char retries; volatile unsigned char routing; @@ -354,37 +354,37 @@ struct arlan_private { unsigned long tx_last_sent; unsigned long tx_last_cleared; unsigned long retransmissions; - unsigned long interrupt_ack_requested; + unsigned long interrupt_ack_requested; spinlock_t lock; unsigned long waiting_command_mask; - unsigned long card_polling_interval; - unsigned long last_command_buff_free_time; + unsigned long card_polling_interval; + unsigned long last_command_buff_free_time; - int under_reset; - int under_config; - int rx_command_given; - int tx_command_given; + int under_reset; + int under_config; + int rx_command_given; + int tx_command_given; unsigned long interrupt_processing_active; unsigned long last_rx_int_ack_time; unsigned long in_bytes; - unsigned long out_bytes; + unsigned long out_bytes; unsigned long in_time; unsigned long out_time; unsigned long in_time10; unsigned long out_time10; unsigned long in_bytes10; - unsigned long out_bytes10; + unsigned long out_bytes10; int init_etherdev_alloc; }; #define ARLAN_CLEAR 0x00 -#define ARLAN_RESET 0x01 +#define ARLAN_RESET 0x01 #define ARLAN_CHANNEL_ATTENTION 0x02 -#define ARLAN_INTERRUPT_ENABLE 0x04 -#define ARLAN_CLEAR_INTERRUPT 0x08 -#define ARLAN_POWER 0x40 +#define ARLAN_INTERRUPT_ENABLE 0x04 +#define ARLAN_CLEAR_INTERRUPT 0x08 +#define ARLAN_POWER 0x40 #define ARLAN_ACCESS 0x80 #define ARLAN_COM_CONF 0x01 @@ -445,8 +445,8 @@ struct arlan_private { #define registrationBad(dev)\ - (( READSHMB(((struct arlan_private *)netdev_priv(dev))->card->registrationMode) > 0) && \ - ( READSHMB(((struct arlan_private *)netdev_priv(dev))->card->registrationStatus) == 0)) + ((READSHMB(((struct arlan_private *)netdev_priv(dev))->card->registrationMode) > 0) && \ + (READSHMB(((struct arlan_private *)netdev_priv(dev))->card->registrationStatus) == 0)) #define readControlRegister(dev)\ @@ -461,9 +461,9 @@ struct arlan_private { int cr; \ \ cr = readControlRegister(dev);\ - if (cr & ARLAN_CHANNEL_ATTENTION) { \ + if (cr & ARLAN_CHANNEL_ATTENTION) \ writeControlRegister(dev, (cr & ~ARLAN_CHANNEL_ATTENTION));\ - } else \ + else \ writeControlRegister(dev, (cr | ARLAN_CHANNEL_ATTENTION));\ } @@ -504,8 +504,8 @@ struct arlan_private { #define ARLAN_COMMAND_RX_ABORT 0x000080 #define ARLAN_COMMAND_POWERDOWN 0x000100 #define ARLAN_COMMAND_POWERUP 0x000200 -#define ARLAN_COMMAND_SLOW_POLL 0x000400 -#define ARLAN_COMMAND_ACTIVATE 0x000800 +#define ARLAN_COMMAND_SLOW_POLL 0x000400 +#define ARLAN_COMMAND_ACTIVATE 0x000800 #define ARLAN_COMMAND_INT_ACK 0x001000 #define ARLAN_COMMAND_INT_ENABLE 0x002000 #define ARLAN_COMMAND_WAIT_NOW 0x004000 diff --git a/drivers/staging/asus_oled/asus_oled.c b/drivers/staging/asus_oled/asus_oled.c index 7ebecc92c61b..5b279fb30f3f 100644 --- a/drivers/staging/asus_oled/asus_oled.c +++ b/drivers/staging/asus_oled/asus_oled.c @@ -771,7 +771,7 @@ static struct usb_driver oled_driver = { }; static CLASS_ATTR_STRING(version, S_IRUGO, - ASUS_OLED_UNDERSCORE_NAME " " ASUS_OLED_VERSION); + ASUS_OLED_UNDERSCORE_NAME " " ASUS_OLED_VERSION); static int __init asus_oled_init(void) { diff --git a/drivers/staging/batman-adv/send.c b/drivers/staging/batman-adv/send.c index 2a9fac8c240e..ff7b1f10684f 100644 --- a/drivers/staging/batman-adv/send.c +++ b/drivers/staging/batman-adv/send.c @@ -134,7 +134,8 @@ static void send_packet_to_if(struct forw_packet *forw_packet, if (batman_if->if_active != IF_ACTIVE) return; - packet_num = buff_pos = 0; + packet_num = 0; + buff_pos = 0; batman_packet = (struct batman_packet *) (forw_packet->packet_buff); diff --git a/drivers/staging/comedi/Makefile b/drivers/staging/comedi/Makefile index 05811f79d85b..20afea301c87 100644 --- a/drivers/staging/comedi/Makefile +++ b/drivers/staging/comedi/Makefile @@ -9,4 +9,3 @@ comedi-objs := \ range.o \ drivers.o \ comedi_compat32.o \ - comedi_ksyms.o \ diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h index b559a9c2f857..1251e074cb2b 100644 --- a/drivers/staging/comedi/comedi.h +++ b/drivers/staging/comedi/comedi.h @@ -490,7 +490,8 @@ I8254_BINARY = 0 }; - static inline unsigned NI_USUAL_PFI_SELECT(unsigned pfi_channel) { + static inline unsigned NI_USUAL_PFI_SELECT(unsigned pfi_channel) + { if (pfi_channel < 10) return 0x1 + pfi_channel; else @@ -590,14 +591,17 @@ NI_GPCT_PRESCALE_X8_CLOCK_SRC_BITS = 0x20000000, /* divide source by 8 */ NI_GPCT_INVERT_CLOCK_SRC_BIT = 0x80000000 }; - static inline unsigned NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(unsigned n) { + static inline unsigned NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(unsigned n) + { /* NI 660x-specific */ return 0x10 + n; } - static inline unsigned NI_GPCT_RTSI_CLOCK_SRC_BITS(unsigned n) { + static inline unsigned NI_GPCT_RTSI_CLOCK_SRC_BITS(unsigned n) + { return 0x18 + n; } - static inline unsigned NI_GPCT_PFI_CLOCK_SRC_BITS(unsigned n) { + static inline unsigned NI_GPCT_PFI_CLOCK_SRC_BITS(unsigned n) + { /* no pfi on NI 660x */ return 0x20 + n; } @@ -625,16 +629,20 @@ May be bitwise-or'd with CR_EDGE or CR_INVERT. */ we should add them here with an offset of 0x300 when known. */ NI_GPCT_DISABLED_GATE_SELECT = 0x8000, }; - static inline unsigned NI_GPCT_GATE_PIN_GATE_SELECT(unsigned n) { + static inline unsigned NI_GPCT_GATE_PIN_GATE_SELECT(unsigned n) + { return 0x102 + n; } - static inline unsigned NI_GPCT_RTSI_GATE_SELECT(unsigned n) { + static inline unsigned NI_GPCT_RTSI_GATE_SELECT(unsigned n) + { return NI_USUAL_RTSI_SELECT(n); } - static inline unsigned NI_GPCT_PFI_GATE_SELECT(unsigned n) { + static inline unsigned NI_GPCT_PFI_GATE_SELECT(unsigned n) + { return NI_USUAL_PFI_SELECT(n); } - static inline unsigned NI_GPCT_UP_DOWN_PIN_GATE_SELECT(unsigned n) { + static inline unsigned NI_GPCT_UP_DOWN_PIN_GATE_SELECT(unsigned n) + { return 0x202 + n; } @@ -650,7 +658,8 @@ INSN_CONFIG_SET_OTHER_SRC when using NI general-purpose counters. */ /* Still unknown, probably only need NI_GPCT_PFI_OTHER_SELECT */ NI_GPCT_DISABLED_OTHER_SELECT = 0x8000, }; - static inline unsigned NI_GPCT_PFI_OTHER_SELECT(unsigned n) { + static inline unsigned NI_GPCT_PFI_OTHER_SELECT(unsigned n) + { return NI_USUAL_PFI_SELECT(n); } @@ -699,7 +708,8 @@ INSN_CONFIG_ARM */ NI_MIO_PLL_PXI10_CLOCK = 3, NI_MIO_PLL_RTSI0_CLOCK = 4 }; - static inline unsigned NI_MIO_PLL_RTSI_CLOCK(unsigned rtsi_channel) { + static inline unsigned NI_MIO_PLL_RTSI_CLOCK(unsigned rtsi_channel) + { return NI_MIO_PLL_RTSI0_CLOCK + rtsi_channel; } @@ -719,7 +729,8 @@ INSN_CONFIG_ARM */ NI_RTSI_OUTPUT_RTSI_OSC = 12 /* pre-m-series always have RTSI clock on line 7 */ }; - static inline unsigned NI_RTSI_OUTPUT_RTSI_BRD(unsigned n) { + static inline unsigned NI_RTSI_OUTPUT_RTSI_BRD(unsigned n) + { return NI_RTSI_OUTPUT_RTSI_BRD_0 + n; } @@ -754,7 +765,8 @@ INSN_CONFIG_ARM */ NI_PFI_OUTPUT_CDI_SAMPLE = 29, NI_PFI_OUTPUT_CDO_UPDATE = 30 }; - static inline unsigned NI_PFI_OUTPUT_RTSI(unsigned rtsi_channel) { + static inline unsigned NI_PFI_OUTPUT_RTSI(unsigned rtsi_channel) + { return NI_PFI_OUTPUT_RTSI0 + rtsi_channel; } @@ -772,10 +784,12 @@ INSN_CONFIG_ARM */ /* NI External Trigger lines. These values are not arbitrary, but are related * to the bits required to program the board (offset by 1 for historical * reasons). */ - static inline unsigned NI_EXT_PFI(unsigned pfi_channel) { + static inline unsigned NI_EXT_PFI(unsigned pfi_channel) + { return NI_USUAL_PFI_SELECT(pfi_channel) - 1; } - static inline unsigned NI_EXT_RTSI(unsigned rtsi_channel) { + static inline unsigned NI_EXT_RTSI(unsigned rtsi_channel) + { return NI_USUAL_RTSI_SELECT(rtsi_channel) - 1; } @@ -801,21 +815,24 @@ INSN_CONFIG_ARM */ NI_CDIO_SCAN_BEGIN_SRC_FREQ_OUT = 32, NI_CDIO_SCAN_BEGIN_SRC_DIO_CHANGE_DETECT_IRQ = 33 }; - static inline unsigned NI_CDIO_SCAN_BEGIN_SRC_PFI(unsigned pfi_channel) { + static inline unsigned NI_CDIO_SCAN_BEGIN_SRC_PFI(unsigned pfi_channel) + { return NI_USUAL_PFI_SELECT(pfi_channel); } - static inline unsigned NI_CDIO_SCAN_BEGIN_SRC_RTSI(unsigned - rtsi_channel) { + static inline unsigned NI_CDIO_SCAN_BEGIN_SRC_RTSI(unsigned rtsi_channel) + { return NI_USUAL_RTSI_SELECT(rtsi_channel); } /* scan_begin_src for scan_begin_arg==TRIG_EXT with analog output command on NI * boards. These scan begin sources can also be bitwise-or'd with CR_INVERT to * change polarity. */ - static inline unsigned NI_AO_SCAN_BEGIN_SRC_PFI(unsigned pfi_channel) { + static inline unsigned NI_AO_SCAN_BEGIN_SRC_PFI(unsigned pfi_channel) + { return NI_USUAL_PFI_SELECT(pfi_channel); } - static inline unsigned NI_AO_SCAN_BEGIN_SRC_RTSI(unsigned rtsi_channel) { + static inline unsigned NI_AO_SCAN_BEGIN_SRC_RTSI(unsigned rtsi_channel) + { return NI_USUAL_RTSI_SELECT(rtsi_channel); } diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index aca96747e5e2..b11f9b08000b 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -57,6 +57,7 @@ MODULE_LICENSE("GPL"); #ifdef CONFIG_COMEDI_DEBUG int comedi_debug; +EXPORT_SYMBOL(comedi_debug); module_param(comedi_debug, int, 0644); #endif @@ -598,19 +599,19 @@ copyback: static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data, void *file); /* - * COMEDI_INSNLIST - * synchronous instructions + * COMEDI_INSNLIST + * synchronous instructions * - * arg: - * pointer to sync cmd structure + * arg: + * pointer to sync cmd structure * - * reads: - * sync cmd struct at arg - * instruction list - * data (for writes) + * reads: + * sync cmd struct at arg + * instruction list + * data (for writes) * - * writes: - * data (for reads) + * writes: + * data (for reads) */ /* arbitrary limits */ #define MAX_SAMPLES 256 @@ -736,7 +737,8 @@ static int check_insn_config_length(struct comedi_insn *insn, /* by default we allow the insn since we don't have checks for * all possible cases yet */ default: - printk("comedi: no check for data length of config insn id " + printk(KERN_WARNING + "comedi: no check for data length of config insn id " "%i is implemented.\n" " Add a check to %s in %s.\n" " Assuming n=%i is correct.\n", data[0], __func__, @@ -837,7 +839,7 @@ static int parse_insn(struct comedi_device *dev, struct comedi_insn *insn, goto out; } - ret = check_chanlist(s, 1, &insn->chanspec); + ret = comedi_check_chanlist(s, 1, &insn->chanspec); if (ret < 0) { ret = -EINVAL; DPRINTK("bad chanspec\n"); @@ -894,18 +896,18 @@ out: } /* - * COMEDI_INSN - * synchronous instructions + * COMEDI_INSN + * synchronous instructions * - * arg: - * pointer to insn + * arg: + * pointer to insn * - * reads: - * struct comedi_insn struct at arg - * data (for writes) + * reads: + * struct comedi_insn struct at arg + * data (for writes) * - * writes: - * data (for reads) + * writes: + * data (for reads) */ static int do_insn_ioctl(struct comedi_device *dev, void *arg, void *file) { @@ -1050,7 +1052,7 @@ static int do_cmd_ioctl(struct comedi_device *dev, void *arg, void *file) } /* make sure each element in channel/gain list is valid */ - ret = check_chanlist(s, async->cmd.chanlist_len, async->cmd.chanlist); + ret = comedi_check_chanlist(s, async->cmd.chanlist_len, async->cmd.chanlist); if (ret < 0) { DPRINTK("bad chanlist\n"); goto cleanup; @@ -1172,7 +1174,7 @@ static int do_cmdtest_ioctl(struct comedi_device *dev, void *arg, void *file) } /* make sure each element in channel/gain list is valid */ - ret = check_chanlist(s, user_cmd.chanlist_len, chanlist); + ret = comedi_check_chanlist(s, user_cmd.chanlist_len, chanlist); if (ret < 0) { DPRINTK("bad chanlist\n"); goto cleanup; @@ -1925,7 +1927,7 @@ static int __init comedi_init(void) } comedi_class = class_create(THIS_MODULE, "comedi"); if (IS_ERR(comedi_class)) { - printk("comedi: failed to create class"); + printk(KERN_ERR "comedi: failed to create class"); cdev_del(&comedi_cdev); unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), COMEDI_NUM_MINORS); @@ -1971,8 +1973,10 @@ module_exit(comedi_cleanup); void comedi_error(const struct comedi_device *dev, const char *s) { - printk("comedi%d: %s: %s\n", dev->minor, dev->driver->driver_name, s); + printk(KERN_ERR "comedi%d: %s: %s\n", dev->minor, + dev->driver->driver_name, s); } +EXPORT_SYMBOL(comedi_error); void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s) { @@ -2015,6 +2019,7 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s) } s->async->events = 0; } +EXPORT_SYMBOL(comedi_event); void comedi_set_subdevice_runflags(struct comedi_subdevice *s, unsigned mask, unsigned bits) @@ -2026,6 +2031,7 @@ void comedi_set_subdevice_runflags(struct comedi_subdevice *s, unsigned mask, s->runflags |= (bits & mask); spin_unlock_irqrestore(&s->spin_lock, flags); } +EXPORT_SYMBOL(comedi_set_subdevice_runflags); unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s) { @@ -2037,6 +2043,7 @@ unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s) spin_unlock_irqrestore(&s->spin_lock, flags); return runflags; } +EXPORT_SYMBOL(comedi_get_subdevice_runflags); static int is_device_busy(struct comedi_device *dev) { @@ -2105,6 +2112,7 @@ int comedi_alloc_board_minor(struct device *hardware_device) kfree(info->device); kfree(info); printk(KERN_ERR + "comedi: error: ran out of minor numbers for board device files.\n"); return -EBUSY; } @@ -2149,6 +2157,7 @@ int comedi_alloc_board_minor(struct device *hardware_device) } return i; } +EXPORT_SYMBOL_GPL(comedi_alloc_board_minor); void comedi_free_board_minor(unsigned minor) { @@ -2174,6 +2183,7 @@ void comedi_free_board_minor(unsigned minor) kfree(info); } } +EXPORT_SYMBOL_GPL(comedi_free_board_minor); int comedi_alloc_subdevice_minor(struct comedi_device *dev, struct comedi_subdevice *s) @@ -2283,6 +2293,7 @@ struct comedi_device_file_info *comedi_get_device_file_info(unsigned minor) spin_unlock_irqrestore(&comedi_file_info_table_lock, flags); return info; } +EXPORT_SYMBOL_GPL(comedi_get_device_file_info); static int resize_async_buffer(struct comedi_device *dev, struct comedi_subdevice *s, diff --git a/drivers/staging/comedi/comedi_fops.h b/drivers/staging/comedi/comedi_fops.h index cb503c88c7f4..da4b4f5553f5 100644 --- a/drivers/staging/comedi/comedi_fops.h +++ b/drivers/staging/comedi/comedi_fops.h @@ -5,5 +5,6 @@ extern struct class *comedi_class; extern const struct file_operations comedi_fops; extern int comedi_autoconfig; +extern struct comedi_driver *comedi_drivers; #endif /* _COMEDI_FOPS_H */ diff --git a/drivers/staging/comedi/comedi_ksyms.c b/drivers/staging/comedi/comedi_ksyms.c deleted file mode 100644 index 87803e69a149..000000000000 --- a/drivers/staging/comedi/comedi_ksyms.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - module/exp_ioctl.c - exported comedi functions - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 1997-8 David A. Schleef <ds@schleef.org> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#define __NO_VERSION__ - -#include "comedidev.h" - -/* for drivers */ -EXPORT_SYMBOL(comedi_driver_register); -EXPORT_SYMBOL(comedi_driver_unregister); -/* EXPORT_SYMBOL(comedi_bufcheck); */ -/* EXPORT_SYMBOL(comedi_done); */ -/* EXPORT_SYMBOL(comedi_error_done); */ -EXPORT_SYMBOL(comedi_error); -/* EXPORT_SYMBOL(comedi_eobuf); */ -/* EXPORT_SYMBOL(comedi_eos); */ -EXPORT_SYMBOL(comedi_event); -EXPORT_SYMBOL(comedi_get_subdevice_runflags); -EXPORT_SYMBOL(comedi_set_subdevice_runflags); -EXPORT_SYMBOL(range_bipolar10); -EXPORT_SYMBOL(range_bipolar5); -EXPORT_SYMBOL(range_bipolar2_5); -EXPORT_SYMBOL(range_unipolar10); -EXPORT_SYMBOL(range_unipolar5); -EXPORT_SYMBOL(range_unknown); -#ifdef CONFIG_COMEDI_DEBUG -EXPORT_SYMBOL(comedi_debug); -#endif -EXPORT_SYMBOL_GPL(comedi_alloc_board_minor); -EXPORT_SYMBOL_GPL(comedi_free_board_minor); -EXPORT_SYMBOL_GPL(comedi_pci_auto_config); -EXPORT_SYMBOL_GPL(comedi_pci_auto_unconfig); -EXPORT_SYMBOL_GPL(comedi_usb_auto_config); -EXPORT_SYMBOL_GPL(comedi_usb_auto_unconfig); - -/* for kcomedilib */ -EXPORT_SYMBOL(check_chanlist); -EXPORT_SYMBOL_GPL(comedi_get_device_file_info); - -EXPORT_SYMBOL(comedi_buf_put); -EXPORT_SYMBOL(comedi_buf_get); -EXPORT_SYMBOL(comedi_buf_read_n_available); -EXPORT_SYMBOL(comedi_buf_write_free); -EXPORT_SYMBOL(comedi_buf_write_alloc); -EXPORT_SYMBOL(comedi_buf_read_free); -EXPORT_SYMBOL(comedi_buf_read_alloc); -EXPORT_SYMBOL(comedi_buf_memcpy_to); -EXPORT_SYMBOL(comedi_buf_memcpy_from); -EXPORT_SYMBOL(comedi_reset_async_buf); diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index ebdccfdf220e..5e4672751d42 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -57,7 +57,7 @@ static int __init x ## _init_module(void) \ {return comedi_driver_register(&(x)); } \ static void __exit x ## _cleanup_module(void) \ - {comedi_driver_unregister(&(x)); } \ + {comedi_driver_unregister(&(x)); } \ module_init(x ## _init_module); \ module_exit(x ## _cleanup_module); @@ -109,17 +109,9 @@ COMEDI_MODULE_MACROS \ COMEDI_PCI_INITCLEANUP_NOMODULE(comedi_driver, pci_id_table) -#define PCI_VENDOR_ID_INOVA 0x104c -#define PCI_VENDOR_ID_NATINST 0x1093 -#define PCI_VENDOR_ID_DATX 0x1116 -#define PCI_VENDOR_ID_COMPUTERBOARDS 0x1307 -#define PCI_VENDOR_ID_ADVANTECH 0x13fe -#define PCI_VENDOR_ID_RTD 0x1435 -#define PCI_VENDOR_ID_AMPLICON 0x14dc #define PCI_VENDOR_ID_ADLINK 0x144a #define PCI_VENDOR_ID_ICP 0x104c #define PCI_VENDOR_ID_CONTEC 0x1221 -#define PCI_VENDOR_ID_MEILHAUS 0x1402 #define COMEDI_NUM_MINORS 0x100 #define COMEDI_NUM_BOARD_MINORS 0x30 @@ -132,7 +124,7 @@ struct comedi_subdevice { struct comedi_device *device; int type; int n_chan; - volatile int subdev_flags; + int subdev_flags; int len_chanlist; /* maximum length of channel/gain list */ void *private; @@ -390,7 +382,7 @@ enum subdevice_runflags { */ int do_rangeinfo_ioctl(struct comedi_device *dev, struct comedi_rangeinfo *arg); -int check_chanlist(struct comedi_subdevice *s, int n, unsigned int *chanlist); +int comedi_check_chanlist(struct comedi_subdevice *s, int n, unsigned int *chanlist); void comedi_set_subdevice_runflags(struct comedi_subdevice *s, unsigned mask, unsigned bits); unsigned comedi_get_subdevice_runflags(struct comedi_subdevice *s); @@ -402,7 +394,7 @@ int insn_inval(struct comedi_device *dev, struct comedi_subdevice *s, #define RANGE(a, b) {(a)*1e6, (b)*1e6, 0} #define RANGE_ext(a, b) {(a)*1e6, (b)*1e6, RF_EXTERNAL} #define RANGE_mA(a, b) {(a)*1e6, (b)*1e6, UNIT_mA} -#define RANGE_unitless(a, b) {(a)*1e6, (b)*1e6, 0} /* XXX */ +#define RANGE_unitless(a, b) {(a)*1e6, (b)*1e6, 0} #define BIP_RANGE(a) {-(a)*1e6, (a)*1e6, 0} #define UNI_RANGE(a) {0, (a)*1e6, 0} diff --git a/drivers/staging/comedi/comedilib.h b/drivers/staging/comedi/comedilib.h index 3918d53b3040..00414359138d 100644 --- a/drivers/staging/comedi/comedilib.h +++ b/drivers/staging/comedi/comedilib.h @@ -24,170 +24,16 @@ #ifndef _LINUX_COMEDILIB_H #define _LINUX_COMEDILIB_H -#include "comedi.h" - -/* Kernel internal stuff. Needed by real-time modules and such. */ - -#ifndef __KERNEL__ -#error linux/comedilib.h should not be included by non-kernel-space code -#endif - -/* exported functions */ - -#ifndef KCOMEDILIB_DEPRECATED - -/* these functions may not be called at real-time priority */ - void *comedi_open(const char *path); int comedi_close(void *dev); - -/* these functions may be called at any priority, but may fail at - real-time priority */ - -int comedi_lock(void *dev, unsigned int subdev); -int comedi_unlock(void *dev, unsigned int subdev); - -/* these functions may be called at any priority, but you must hold - the lock for the subdevice */ - -int comedi_loglevel(int loglevel); -void comedi_perror(const char *s); -char *comedi_strerror(int errnum); -int comedi_errno(void); -int comedi_fileno(void *dev); - -int comedi_cancel(void *dev, unsigned int subdev); -int comedi_register_callback(void *dev, unsigned int subdev, - unsigned int mask, int (*cb) (unsigned int, - void *), void *arg); - -int comedi_command(void *dev, struct comedi_cmd *cmd); -int comedi_command_test(void *dev, struct comedi_cmd *cmd); -int comedi_trigger(void *dev, unsigned int subdev, struct comedi_trig *it); -int __comedi_trigger(void *dev, unsigned int subdev, struct comedi_trig *it); -int comedi_data_write(void *dev, unsigned int subdev, unsigned int chan, - unsigned int range, unsigned int aref, unsigned int data); -int comedi_data_read(void *dev, unsigned int subdev, unsigned int chan, - unsigned int range, unsigned int aref, unsigned int *data); -int comedi_data_read_hint(void *dev, unsigned int subdev, - unsigned int chan, unsigned int range, - unsigned int aref); -int comedi_data_read_delayed(void *dev, unsigned int subdev, unsigned int chan, - unsigned int range, unsigned int aref, - unsigned int *data, unsigned int nano_sec); int comedi_dio_config(void *dev, unsigned int subdev, unsigned int chan, unsigned int io); -int comedi_dio_read(void *dev, unsigned int subdev, unsigned int chan, - unsigned int *val); -int comedi_dio_write(void *dev, unsigned int subdev, unsigned int chan, - unsigned int val); int comedi_dio_bitfield(void *dev, unsigned int subdev, unsigned int mask, unsigned int *bits); -int comedi_get_n_subdevices(void *dev); -int comedi_get_version_code(void *dev); -const char *comedi_get_driver_name(void *dev); -const char *comedi_get_board_name(void *dev); -int comedi_get_subdevice_type(void *dev, unsigned int subdevice); int comedi_find_subdevice_by_type(void *dev, int type, unsigned int subd); int comedi_get_n_channels(void *dev, unsigned int subdevice); -unsigned int comedi_get_maxdata(void *dev, unsigned int subdevice, unsigned - int chan); -int comedi_get_n_ranges(void *dev, unsigned int subdevice, unsigned int chan); -int comedi_do_insn(void *dev, struct comedi_insn *insn); -int comedi_poll(void *dev, unsigned int subdev); - -/* DEPRECATED functions */ -int comedi_get_rangetype(void *dev, unsigned int subdevice, unsigned int chan); -/* ALPHA functions */ -unsigned int comedi_get_subdevice_flags(void *dev, unsigned int subdevice); -int comedi_get_len_chanlist(void *dev, unsigned int subdevice); -int comedi_get_krange(void *dev, unsigned int subdevice, unsigned int - chan, unsigned int range, struct comedi_krange *krange); -unsigned int comedi_get_buf_head_pos(void *dev, unsigned int subdevice); -int comedi_set_user_int_count(void *dev, unsigned int subdevice, - unsigned int buf_user_count); -int comedi_map(void *dev, unsigned int subdev, void *ptr); -int comedi_unmap(void *dev, unsigned int subdev); -int comedi_get_buffer_size(void *dev, unsigned int subdev); -int comedi_mark_buffer_read(void *dev, unsigned int subdevice, - unsigned int num_bytes); -int comedi_mark_buffer_written(void *d, unsigned int subdevice, - unsigned int num_bytes); -int comedi_get_buffer_contents(void *dev, unsigned int subdevice); -int comedi_get_buffer_offset(void *dev, unsigned int subdevice); - -#else - -/* these functions may not be called at real-time priority */ - -int comedi_open(unsigned int minor); -void comedi_close(unsigned int minor); - -/* these functions may be called at any priority, but may fail at - real-time priority */ - -int comedi_lock(unsigned int minor, unsigned int subdev); -int comedi_unlock(unsigned int minor, unsigned int subdev); - -/* these functions may be called at any priority, but you must hold - the lock for the subdevice */ - -int comedi_cancel(unsigned int minor, unsigned int subdev); -int comedi_register_callback(unsigned int minor, unsigned int subdev, - unsigned int mask, int (*cb) (unsigned int, - void *), void *arg); - -int comedi_command(unsigned int minor, struct comedi_cmd *cmd); -int comedi_command_test(unsigned int minor, struct comedi_cmd *cmd); -int comedi_trigger(unsigned int minor, unsigned int subdev, - struct comedi_trig *it); -int __comedi_trigger(unsigned int minor, unsigned int subdev, - struct comedi_trig *it); -int comedi_data_write(unsigned int dev, unsigned int subdev, unsigned int chan, - unsigned int range, unsigned int aref, unsigned int data); -int comedi_data_read(unsigned int dev, unsigned int subdev, unsigned int chan, - unsigned int range, unsigned int aref, unsigned int *data); -int comedi_dio_config(unsigned int dev, unsigned int subdev, unsigned int chan, - unsigned int io); -int comedi_dio_read(unsigned int dev, unsigned int subdev, unsigned int chan, - unsigned int *val); -int comedi_dio_write(unsigned int dev, unsigned int subdev, unsigned int chan, - unsigned int val); -int comedi_dio_bitfield(unsigned int dev, unsigned int subdev, - unsigned int mask, unsigned int *bits); -int comedi_get_n_subdevices(unsigned int dev); -int comedi_get_version_code(unsigned int dev); -char *comedi_get_driver_name(unsigned int dev); -char *comedi_get_board_name(unsigned int minor); -int comedi_get_subdevice_type(unsigned int minor, unsigned int subdevice); -int comedi_find_subdevice_by_type(unsigned int minor, int type, - unsigned int subd); -int comedi_get_n_channels(unsigned int minor, unsigned int subdevice); -unsigned int comedi_get_maxdata(unsigned int minor, unsigned int subdevice, unsigned - int chan); -int comedi_get_n_ranges(unsigned int minor, unsigned int subdevice, unsigned int - chan); -int comedi_do_insn(unsigned int minor, struct comedi_insn *insn); -int comedi_poll(unsigned int minor, unsigned int subdev); - -/* DEPRECATED functions */ -int comedi_get_rangetype(unsigned int minor, unsigned int subdevice, - unsigned int chan); - -/* ALPHA functions */ -unsigned int comedi_get_subdevice_flags(unsigned int minor, unsigned int - subdevice); -int comedi_get_len_chanlist(unsigned int minor, unsigned int subdevice); -int comedi_get_krange(unsigned int minor, unsigned int subdevice, unsigned int - chan, unsigned int range, struct comedi_krange *krange); -unsigned int comedi_get_buf_head_pos(unsigned int minor, unsigned int - subdevice); -int comedi_set_user_int_count(unsigned int minor, unsigned int subdevice, - unsigned int buf_user_count); -int comedi_map(unsigned int minor, unsigned int subdev, void **ptr); -int comedi_unmap(unsigned int minor, unsigned int subdev); - -#endif +/* internal to kcomedilb */ +int comedi_do_insn(void *dev, struct comedi_insn *insn); #endif diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 44d6b62c230d..d7a450917405 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -38,7 +38,6 @@ #include <linux/mm.h> #include <linux/slab.h> #include "comedidev.h" -#include "wrapper.h" #include <linux/highmem.h> /* for SuSE brokenness */ #include <linux/vmalloc.h> #include <linux/cdev.h> @@ -102,7 +101,7 @@ static void __comedi_device_detach(struct comedi_device *dev) if (dev->driver) dev->driver->detach(dev); else - printk("BUG: dev->driver=NULL in comedi_device_detach()\n"); + printk(KERN_WARNING "BUG: dev->driver=NULL in comedi_device_detach()\n"); cleanup_device(dev); } @@ -124,7 +123,7 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) for (driv = comedi_drivers; driv; driv = driv->next) { if (!try_module_get(driv->module)) { printk - ("comedi: failed to increment module count, skipping\n"); + (KERN_INFO "comedi: failed to increment module count, skipping\n"); continue; } if (driv->num_names) { @@ -139,7 +138,8 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) continue; } } - /* initialize dev->driver here so comedi_error() can be called from attach */ + /* initialize dev->driver here so + * comedi_error() can be called from attach */ dev->driver = driv; ret = driv->attach(dev, it); if (ret < 0) { @@ -154,7 +154,7 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* report valid board names before returning error */ for (driv = comedi_drivers; driv; driv = driv->next) { if (!try_module_get(driv->module)) { - printk("comedi: failed to increment module count\n"); + printk(KERN_INFO "comedi: failed to increment module count\n"); continue; } comedi_report_boards(driv); @@ -172,7 +172,7 @@ attached: } if (!dev->board_name) { - printk("BUG: dev->board_name=<%p>\n", dev->board_name); + printk(KERN_WARNING "BUG: dev->board_name=<%p>\n", dev->board_name); dev->board_name = "BUG"; } smp_wmb(); @@ -188,6 +188,7 @@ int comedi_driver_register(struct comedi_driver *driver) return 0; } +EXPORT_SYMBOL(comedi_driver_register); int comedi_driver_unregister(struct comedi_driver *driver) { @@ -208,7 +209,7 @@ int comedi_driver_unregister(struct comedi_driver *driver) if (dev->attached && dev->driver == driver) { if (dev->use_count) printk - ("BUG! detaching device with use_count=%d\n", + (KERN_WARNING "BUG! detaching device with use_count=%d\n", dev->use_count); comedi_device_detach(dev); } @@ -228,6 +229,7 @@ int comedi_driver_unregister(struct comedi_driver *driver) } return -EINVAL; } +EXPORT_SYMBOL(comedi_driver_unregister); static int postconfig(struct comedi_device *dev) { @@ -253,7 +255,7 @@ static int postconfig(struct comedi_device *dev) async = kzalloc(sizeof(struct comedi_async), GFP_KERNEL); if (async == NULL) { - printk("failed to allocate async struct\n"); + printk(KERN_INFO "failed to allocate async struct\n"); return -ENOMEM; } init_waitqueue_head(&async->wait_head); @@ -268,7 +270,7 @@ static int postconfig(struct comedi_device *dev) async->prealloc_buf = NULL; async->prealloc_bufsz = 0; if (comedi_buf_alloc(dev, s, DEFAULT_BUF_SIZE) < 0) { - printk("Buffer allocation failed\n"); + printk(KERN_INFO "Buffer allocation failed\n"); return -ENOMEM; } if (s->buf_change) { @@ -303,7 +305,8 @@ static int postconfig(struct comedi_device *dev) return 0; } -/* generic recognize function for drivers that register their supported board names */ +/* generic recognize function for drivers + * that register their supported board names */ void *comedi_recognize(struct comedi_driver *driv, const char *name) { unsigned i; @@ -324,17 +327,17 @@ void comedi_report_boards(struct comedi_driver *driv) unsigned int i; const char *const *name_ptr; - printk("comedi: valid board names for %s driver are:\n", + printk(KERN_INFO "comedi: valid board names for %s driver are:\n", driv->driver_name); name_ptr = driv->board_name; for (i = 0; i < driv->num_names; i++) { - printk(" %s\n", *name_ptr); + printk(KERN_INFO " %s\n", *name_ptr); name_ptr = (const char **)((char *)name_ptr + driv->offset); } if (driv->num_names == 0) - printk(" %s\n", driv->driver_name); + printk(KERN_INFO " %s\n", driv->driver_name); } static int poll_invalid(struct comedi_device *dev, struct comedi_subdevice *s) @@ -440,9 +443,7 @@ int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s, unsigned i; for (i = 0; i < async->n_buf_pages; ++i) { if (async->buf_page_list[i].virt_addr) { - mem_map_unreserve(virt_to_page - (async->buf_page_list[i]. - virt_addr)); + clear_bit(PG_reserved, &(virt_to_page(async->buf_page_list[i].virt_addr)->flags)); if (s->async_dma_dir != DMA_NONE) { dma_free_coherent(dev->hw_dev, PAGE_SIZE, @@ -495,12 +496,9 @@ int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s, if (async->buf_page_list[i].virt_addr == NULL) break; - mem_map_reserve(virt_to_page - (async->buf_page_list[i]. - virt_addr)); - pages[i] = - virt_to_page(async-> - buf_page_list[i].virt_addr); + set_bit(PG_reserved, + &(virt_to_page(async->buf_page_list[i].virt_addr)->flags)); + pages[i] = virt_to_page(async->buf_page_list[i].virt_addr); } } if (i == n_pages) { @@ -517,9 +515,7 @@ int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s, NULL) { break; } - mem_map_unreserve(virt_to_page - (async->buf_page_list - [i].virt_addr)); + clear_bit(PG_reserved, &(virt_to_page(async->buf_page_list[i].virt_addr)->flags)); if (s->async_dma_dir != DMA_NONE) { dma_free_coherent(dev->hw_dev, PAGE_SIZE, @@ -568,7 +564,7 @@ unsigned int comedi_buf_munge(struct comedi_async *async, block_size = num_bytes - count; if (block_size < 0) { - printk("%s: %s: bug! block_size is negative\n", + printk(KERN_WARNING "%s: %s: bug! block_size is negative\n", __FILE__, __func__); break; } @@ -579,7 +575,8 @@ unsigned int comedi_buf_munge(struct comedi_async *async, s->munge(s->device, s, async->prealloc_buf + async->munge_ptr, block_size, async->munge_chan); - smp_wmb(); /* barrier insures data is munged in buffer before munge_count is incremented */ + smp_wmb(); /* barrier insures data is munged in buffer + * before munge_count is incremented */ async->munge_chan += block_size / num_sample_bytes; async->munge_chan %= async->cmd.chanlist_len; @@ -626,6 +623,7 @@ unsigned int comedi_buf_write_alloc(struct comedi_async *async, smp_mb(); return nbytes; } +EXPORT_SYMBOL(comedi_buf_write_alloc); /* allocates nothing unless it can completely fulfill the request */ unsigned int comedi_buf_write_alloc_strict(struct comedi_async *async, @@ -649,7 +647,7 @@ unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes) if ((int)(async->buf_write_count + nbytes - async->buf_write_alloc_count) > 0) { printk - ("comedi: attempted to write-free more bytes than have been write-allocated.\n"); + (KERN_INFO "comedi: attempted to write-free more bytes than have been write-allocated.\n"); nbytes = async->buf_write_alloc_count - async->buf_write_count; } async->buf_write_count += nbytes; @@ -660,6 +658,7 @@ unsigned comedi_buf_write_free(struct comedi_async *async, unsigned int nbytes) return nbytes; } +EXPORT_SYMBOL(comedi_buf_write_free); /* allocates a chunk for the reader from filled (and munged) buffer space */ unsigned comedi_buf_read_alloc(struct comedi_async *async, unsigned nbytes) @@ -674,11 +673,13 @@ unsigned comedi_buf_read_alloc(struct comedi_async *async, unsigned nbytes) smp_rmb(); return nbytes; } +EXPORT_SYMBOL(comedi_buf_read_alloc); /* transfers control of a chunk from reader to free buffer space */ unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes) { - /* barrier insures data has been read out of buffer before read count is incremented */ + /* barrier insures data has been read out of + * buffer before read count is incremented */ smp_mb(); if ((int)(async->buf_read_count + nbytes - async->buf_read_alloc_count) > 0) { @@ -691,6 +692,7 @@ unsigned comedi_buf_read_free(struct comedi_async *async, unsigned int nbytes) async->buf_read_ptr %= async->prealloc_bufsz; return nbytes; } +EXPORT_SYMBOL(comedi_buf_read_free); void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset, const void *data, unsigned int num_bytes) @@ -716,6 +718,7 @@ void comedi_buf_memcpy_to(struct comedi_async *async, unsigned int offset, write_ptr = 0; } } +EXPORT_SYMBOL(comedi_buf_memcpy_to); void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, void *dest, unsigned int nbytes) @@ -742,6 +745,7 @@ void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, read_ptr = 0; } } +EXPORT_SYMBOL(comedi_buf_memcpy_from); unsigned int comedi_buf_read_n_available(struct comedi_async *async) { @@ -757,6 +761,7 @@ unsigned int comedi_buf_read_n_available(struct comedi_async *async) smp_rmb(); return num_bytes; } +EXPORT_SYMBOL(comedi_buf_read_n_available); int comedi_buf_get(struct comedi_async *async, short *x) { @@ -769,6 +774,7 @@ int comedi_buf_get(struct comedi_async *async, short *x) comedi_buf_read_free(async, sizeof(short)); return 1; } +EXPORT_SYMBOL(comedi_buf_get); int comedi_buf_put(struct comedi_async *async, short x) { @@ -782,6 +788,7 @@ int comedi_buf_put(struct comedi_async *async, short x) comedi_buf_write_free(async, sizeof(short)); return 1; } +EXPORT_SYMBOL(comedi_buf_put); void comedi_reset_async_buf(struct comedi_async *async) { @@ -801,6 +808,7 @@ void comedi_reset_async_buf(struct comedi_async *async) async->events = 0; } +EXPORT_SYMBOL(comedi_reset_async_buf); int comedi_auto_config(struct device *hardware_device, const char *board_name, const int *options, unsigned num_options) @@ -873,20 +881,24 @@ int comedi_pci_auto_config(struct pci_dev *pcidev, const char *board_name) return comedi_auto_config(&pcidev->dev, board_name, options, ARRAY_SIZE(options)); } +EXPORT_SYMBOL_GPL(comedi_pci_auto_config); void comedi_pci_auto_unconfig(struct pci_dev *pcidev) { comedi_auto_unconfig(&pcidev->dev); } +EXPORT_SYMBOL_GPL(comedi_pci_auto_unconfig); int comedi_usb_auto_config(struct usb_device *usbdev, const char *board_name) { BUG_ON(usbdev == NULL); return comedi_auto_config(&usbdev->dev, board_name, NULL, 0); } +EXPORT_SYMBOL_GPL(comedi_usb_auto_config); void comedi_usb_auto_unconfig(struct usb_device *usbdev) { BUG_ON(usbdev == NULL); comedi_auto_unconfig(&usbdev->dev); } +EXPORT_SYMBOL_GPL(comedi_usb_auto_unconfig); diff --git a/drivers/staging/comedi/drivers/8253.h b/drivers/staging/comedi/drivers/8253.h index 0bb35db4ea3b..3eb45d46e05b 100644 --- a/drivers/staging/comedi/drivers/8253.h +++ b/drivers/staging/comedi/drivers/8253.h @@ -214,7 +214,8 @@ static inline void i8253_cascade_ns_to_timer_2div(int i8253_osc_base, #ifndef CMDTEST /* i8254_load programs 8254 counter chip. It should also work for the 8253. - * base_address is the lowest io address for the chip (the address of counter 0). + * base_address is the lowest io address + * for the chip (the address of counter 0). * counter_number is the counter you want to load (0,1 or 2) * count is the number to load into the counter. * diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile index df2854d543cc..be995144e20d 100644 --- a/drivers/staging/comedi/drivers/Makefile +++ b/drivers/staging/comedi/drivers/Makefile @@ -25,6 +25,7 @@ obj-$(CONFIG_COMEDI_PCI_DRIVERS) += addi_apci_3120.o obj-$(CONFIG_COMEDI_PCI_DRIVERS) += addi_apci_3501.o obj-$(CONFIG_COMEDI_PCI_DRIVERS) += addi_apci_3xxx.o obj-$(CONFIG_COMEDI_PCI_DRIVERS) += adl_pci6208.o +obj-$(CONFIG_COMEDI_PCI_DRIVERS) += adl_pci7230.o obj-$(CONFIG_COMEDI_PCI_DRIVERS) += adl_pci7296.o obj-$(CONFIG_COMEDI_PCI_DRIVERS) += adl_pci7432.o obj-$(CONFIG_COMEDI_PCI_DRIVERS) += adl_pci8164.o diff --git a/drivers/staging/comedi/drivers/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c index 6925faaf5293..712b9e0788b6 100644 --- a/drivers/staging/comedi/drivers/adl_pci6208.c +++ b/drivers/staging/comedi/drivers/adl_pci6208.c @@ -54,7 +54,7 @@ References: #include "../comedidev.h" #include "comedi_pci.h" -#define PCI6208_DRIVER_NAME "adl_pci6208" +#define PCI6208_DRIVER_NAME "adl_pci6208" /* Board descriptions */ struct pci6208_board { @@ -134,10 +134,10 @@ static int pci6208_ao_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data); /* static int pci6208_dio_insn_bits (struct comedi_device *dev, - * struct comedi_subdevice *s, */ + * struct comedi_subdevice *s, */ /* struct comedi_insn *insn,unsigned int *data); */ /* static int pci6208_dio_insn_config(struct comedi_device *dev, - * struct comedi_subdevice *s, */ + * struct comedi_subdevice *s, */ /* struct comedi_insn *insn,unsigned int *data); */ /* @@ -268,7 +268,7 @@ static int pci6208_ao_rinsn(struct comedi_device *dev, * This allows packed reading/writing of the DIO channels. The * comedi core can convert between insn_bits and insn_read/write */ /* static int pci6208_dio_insn_bits(struct comedi_device *dev, - * struct comedi_subdevice *s, */ + * struct comedi_subdevice *s, */ /* struct comedi_insn *insn,unsigned int *data) */ /* { */ /* if(insn->n!=2)return -EINVAL; */ @@ -293,7 +293,7 @@ static int pci6208_ao_rinsn(struct comedi_device *dev, /* } */ /* static int pci6208_dio_insn_config(struct comedi_device *dev, - * struct comedi_subdevice *s, */ + * struct comedi_subdevice *s, */ /* struct comedi_insn *insn,unsigned int *data) */ /* { */ /* int chan=CR_CHAN(insn->chanspec); */ diff --git a/drivers/staging/comedi/drivers/adl_pci7230.c b/drivers/staging/comedi/drivers/adl_pci7230.c new file mode 100644 index 000000000000..24a82eb9d153 --- /dev/null +++ b/drivers/staging/comedi/drivers/adl_pci7230.c @@ -0,0 +1,206 @@ +/* + comedi/drivers/adl_pci7230.c + + Hardware comedi driver fot PCI7230 Adlink card + Copyright (C) 2010 David Fernandez <dfcastelao@gmail.com> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ +/* +Driver: adl_pci7230 +Description: Driver for the Adlink PCI-7230 32 ch. isolated digital io board +Devices: [ADLink] PCI-7230 (adl_pci7230) +Author: David Fernandez <dfcastelao@gmail.com> +Status: experimental +Updated: Mon, 14 Apr 2008 15:08:14 +0100 + +Configuration Options: + [0] - PCI bus of device (optional) + [1] - PCI slot of device (optional) + If bus/slot is not specified, the first supported + PCI device found will be used. +*/ + +#include "../comedidev.h" +#include <linux/kernel.h> +#include "comedi_pci.h" + +#define PCI7230_DI 0x00 +#define PCI7230_DO 0x00 + +#define PCI_DEVICE_ID_PCI7230 0x7230 + +static DEFINE_PCI_DEVICE_TABLE(adl_pci7230_pci_table) = { + { + PCI_VENDOR_ID_ADLINK, + PCI_DEVICE_ID_PCI7230, + PCI_ANY_ID, + PCI_ANY_ID, + 0, + 0, + 0 + }, + {0} +}; + +MODULE_DEVICE_TABLE(pci, adl_pci7230_pci_table); + +struct adl_pci7230_private { + int data; + struct pci_dev *pci_dev; +}; + +#define devpriv ((struct adl_pci7230_private *)dev->private) + +static int adl_pci7230_attach(struct comedi_device *dev, + struct comedi_devconfig *it); +static int adl_pci7230_detach(struct comedi_device *dev); +static struct comedi_driver driver_adl_pci7230 = { + .driver_name = "adl_pci7230", + .module = THIS_MODULE, + .attach = adl_pci7230_attach, + .detach = adl_pci7230_detach, +}; + +/* Digital IO */ + +static int adl_pci7230_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); + +static int adl_pci7230_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data); + +static int adl_pci7230_attach(struct comedi_device *dev, + struct comedi_devconfig *it) +{ + struct pci_dev *pcidev; + struct comedi_subdevice *s; + int bus, slot; + + printk(KERN_INFO "comedi%d: adl_pci7230\n", dev->minor); + + dev->board_name = "pci7230"; + bus = it->options[0]; + slot = it->options[1]; + + if (alloc_private(dev, sizeof(struct adl_pci7230_private)) < 0) + return -ENOMEM; + + if (alloc_subdevices(dev, 2) < 0) + return -ENOMEM; + + for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); + pcidev != NULL; + pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { + + if (pcidev->vendor == PCI_VENDOR_ID_ADLINK && + pcidev->device == PCI_DEVICE_ID_PCI7230) { + if (bus || slot) { + /* requested particular bus/slot */ + if (pcidev->bus->number != bus || + PCI_SLOT(pcidev->devfn) != slot) { + continue; + } + } + devpriv->pci_dev = pcidev; + break; + } + } + if (pcidev == NULL) { + printk(KERN_ERR "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n", + dev->minor, bus, slot); + return -EIO; + } + if (comedi_pci_enable(pcidev, "adl_pci7230") < 0) { + printk(KERN_ERR "comedi%d: Failed to enable PCI device and request regions\n", + dev->minor); + return -EIO; + } + dev->iobase = pci_resource_start(pcidev, 2); + printk(KERN_DEBUG "comedi: base addr %4lx\n", dev->iobase); + + s = dev->subdevices + 0; + /* Isolated do */ + s->type = COMEDI_SUBD_DO; + s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = 16; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = adl_pci7230_do_insn_bits; + + s = dev->subdevices + 1; + /* Isolated di */ + s->type = COMEDI_SUBD_DI; + s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON; + s->n_chan = 16; + s->maxdata = 1; + s->range_table = &range_digital; + s->insn_bits = adl_pci7230_di_insn_bits; + + printk(KERN_DEBUG "comedi: attached\n"); + + return 1; +} + +static int adl_pci7230_detach(struct comedi_device *dev) +{ + printk(KERN_DEBUG "comedi%d: pci7230: remove\n", dev->minor); + + if (devpriv && devpriv->pci_dev) { + if (dev->iobase) + comedi_pci_disable(devpriv->pci_dev); + pci_dev_put(devpriv->pci_dev); + } + + return 0; +} + +static int adl_pci7230_do_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + if (insn->n != 2) + return -EINVAL; + + if (data[0]) { + s->state &= ~data[0]; + s->state |= (data[0] & data[1]); + + outl((s->state << 16) & 0xffffffff, dev->iobase + PCI7230_DO); + } + + return 2; +} + +static int adl_pci7230_di_insn_bits(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) +{ + if (insn->n != 2) + return -EINVAL; + + data[1] = inl(dev->iobase + PCI7230_DI) & 0xffffffff; + + return 2; +} + +COMEDI_PCI_INITCLEANUP(driver_adl_pci7230, adl_pci7230_pci_table); diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index da172a553d15..bbe0e332dae8 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -585,19 +585,17 @@ pci9111_ai_do_cmd_test(struct comedi_device *dev, (cmd->scan_begin_src != TRIG_EXT)) error++; - if ((cmd->convert_src != TRIG_TIMER) && (cmd->convert_src != TRIG_EXT)) { + if ((cmd->convert_src != TRIG_TIMER) && (cmd->convert_src != TRIG_EXT)) error++; - } if ((cmd->convert_src == TRIG_TIMER) && !((cmd->scan_begin_src == TRIG_TIMER) || - (cmd->scan_begin_src == TRIG_FOLLOW))) { + (cmd->scan_begin_src == TRIG_FOLLOW))) error++; - } if ((cmd->convert_src == TRIG_EXT) && !((cmd->scan_begin_src == TRIG_EXT) || - (cmd->scan_begin_src == TRIG_FOLLOW))) { + (cmd->scan_begin_src == TRIG_FOLLOW))) error++; - } + if (cmd->scan_end_src != TRIG_COUNT) error++; @@ -1067,9 +1065,8 @@ static int pci9111_ai_insn_read(struct comedi_device *dev, pci9111_ai_channel_set(CR_CHAN((&insn->chanspec)[0])); - if ((pci9111_ai_range_get()) != CR_RANGE((&insn->chanspec)[0])) { + if ((pci9111_ai_range_get()) != CR_RANGE((&insn->chanspec)[0])) pci9111_ai_range_set(CR_RANGE((&insn->chanspec)[0])); - } pci9111_fifo_reset(); @@ -1090,11 +1087,10 @@ static int pci9111_ai_insn_read(struct comedi_device *dev, conversion_done: - if (resolution == PCI9111_HR_AI_RESOLUTION) { + if (resolution == PCI9111_HR_AI_RESOLUTION) data[i] = pci9111_hr_ai_get_data(); - } else { + else data[i] = pci9111_ai_get_data(); - } } #ifdef AI_INSN_DEBUG @@ -1131,9 +1127,8 @@ static int pci9111_ao_insn_read(struct comedi_device *dev, { int i; - for (i = 0; i < insn->n; i++) { + for (i = 0; i < insn->n; i++) data[i] = dev_private->ao_readback & PCI9111_AO_RESOLUTION_MASK; - } return i; } @@ -1222,9 +1217,8 @@ static int pci9111_attach(struct comedi_device *dev, int error, i; const struct pci9111_board *board; - if (alloc_private(dev, sizeof(struct pci9111_private_data)) < 0) { + if (alloc_private(dev, sizeof(struct pci9111_private_data)) < 0) return -ENOMEM; - } /* Probe the device to determine what device in the series it is. */ printk("comedi%d: " PCI9111_DRIVER_NAME " driver\n", dev->minor); @@ -1394,14 +1388,12 @@ static int pci9111_detach(struct comedi_device *dev) } /* Release previously allocated irq */ - if (dev->irq != 0) { + if (dev->irq != 0) free_irq(dev->irq, dev); - } if (dev_private != 0 && dev_private->pci_device != 0) { - if (dev->iobase) { + if (dev->iobase) comedi_pci_disable(dev_private->pci_device); - } pci_dev_put(dev_private->pci_device); } diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c b/drivers/staging/comedi/drivers/adl_pci9118.c index 944f20ae5a6a..dc4bd0423e6f 100644 --- a/drivers/staging/comedi/drivers/adl_pci9118.c +++ b/drivers/staging/comedi/drivers/adl_pci9118.c @@ -44,26 +44,25 @@ c) If isn't used DMA then you can use only mode where Configuration options: [0] - PCI bus of device (optional) [1] - PCI slot of device (optional) - If bus/slot is not specified, then first available PCI - card will be used. + If bus/slot is not specified, then first available PCI + card will be used. [2] - 0= standard 8 DIFF/16 SE channels configuration - n= external multiplexer connected, 1<=n<=256 + n = external multiplexer connected, 1 <= n <= 256 [3] - 0=autoselect DMA or EOC interrupts operation - 1=disable DMA mode - 3=disable DMA and INT, only insn interface will work + 1 = disable DMA mode + 3 = disable DMA and INT, only insn interface will work [4] - sample&hold signal - card can generate signal for external S&H board - 0=use SSHO (pin 45) signal is generated in onboard hardware S&H logic - 0!=use ADCHN7 (pin 23) signal is generated from driver, number - say how long delay is requested in ns and sign polarity of the hold - (in this case external multiplexor can serve only 128 channels) + 0 = use SSHO(pin 45) signal is generated in onboard hardware S&H logic + 0 != use ADCHN7(pin 23) signal is generated from driver, number say how + long delay is requested in ns and sign polarity of the hold + (in this case external multiplexor can serve only 128 channels) [5] - 0=stop measure on all hardware errors - 2|=ignore ADOR - A/D Overrun status + 2 | = ignore ADOR - A/D Overrun status 8|=ignore Bover - A/D Burst Mode Overrun status 256|=ignore nFull - A/D FIFO Full status */ #include "../comedidev.h" -#include "../pci_ids.h" #include <linux/delay.h> #include <linux/gfp.h> @@ -74,10 +73,18 @@ Configuration options: #include "comedi_pci.h" #include "comedi_fc.h" +#define PCI_VENDOR_ID_AMCC 0x10e8 + /* paranoid checks are broken */ -#undef PCI9118_PARANOIDCHECK /* if defined, then is used code which control correct channel number on every 12 bit sample */ +#undef PCI9118_PARANOIDCHECK /* + * if defined, then is used code which control + * correct channel number on every 12 bit sample + */ -#undef PCI9118_EXTDEBUG /* if defined then driver prints a lot of messages */ +#undef PCI9118_EXTDEBUG /* + * if defined then driver prints + * a lot of messages + */ #undef DPRINTK #ifdef PCI9118_EXTDEBUG @@ -87,7 +94,10 @@ Configuration options: #endif #define IORANGE_9118 64 /* I hope */ -#define PCI9118_CHANLEN 255 /* len of chanlist, some source say 256, but reality looks like 255 :-( */ +#define PCI9118_CHANLEN 255 /* + * len of chanlist, some source say 256, + * but reality looks like 255 :-( + */ #define PCI9118_CNT0 0x00 /* R/W: 8254 counter 0 */ #define PCI9118_CNT1 0x04 /* R/W: 8254 counter 0 */ @@ -113,20 +123,47 @@ Configuration options: #define AdControl_UniP 0x80 /* 1=bipolar, 0=unipolar */ #define AdControl_Diff 0x40 /* 1=differential, 0= single end inputs */ #define AdControl_SoftG 0x20 /* 1=8254 counter works, 0=counter stops */ -#define AdControl_ExtG 0x10 /* 1=8254 countrol controlled by TGIN(pin 46), 0=controled by SoftG */ -#define AdControl_ExtM 0x08 /* 1=external hardware trigger (pin 44), 0=internal trigger */ -#define AdControl_TmrTr 0x04 /* 1=8254 is iternal trigger source, 0=software trigger is source (register PCI9118_SOFTTRG) */ +#define AdControl_ExtG 0x10 /* + * 1=8254 countrol controlled by TGIN(pin 46), + * 0=controlled by SoftG + */ +#define AdControl_ExtM 0x08 /* + * 1=external hardware trigger (pin 44), + * 0=internal trigger + */ +#define AdControl_TmrTr 0x04 /* + * 1=8254 is iternal trigger source, + * 0=software trigger is source + * (register PCI9118_SOFTTRG) + */ #define AdControl_Int 0x02 /* 1=enable INT, 0=disable */ #define AdControl_Dma 0x01 /* 1=enable DMA, 0=disable */ /* bits from A/D function register (PCI9118_ADFUNC) */ -#define AdFunction_PDTrg 0x80 /* 1=positive, 0=negative digital trigger (only positive is correct) */ -#define AdFunction_PETrg 0x40 /* 1=positive, 0=negative external trigger (only positive is correct) */ +#define AdFunction_PDTrg 0x80 /* + * 1=positive, + * 0=negative digital trigger + * (only positive is correct) + */ +#define AdFunction_PETrg 0x40 /* + * 1=positive, + * 0=negative external trigger + * (only positive is correct) + */ #define AdFunction_BSSH 0x20 /* 1=with sample&hold, 0=without */ #define AdFunction_BM 0x10 /* 1=burst mode, 0=normal mode */ -#define AdFunction_BS 0x08 /* 1=burst mode start, 0=burst mode stop */ -#define AdFunction_PM 0x04 /* 1=post trigger mode, 0=not post trigger */ -#define AdFunction_AM 0x02 /* 1=about trigger mode, 0=not about trigger */ +#define AdFunction_BS 0x08 /* + * 1=burst mode start, + * 0=burst mode stop + */ +#define AdFunction_PM 0x04 /* + * 1=post trigger mode, + * 0=not post trigger + */ +#define AdFunction_AM 0x02 /* + * 1=about trigger mode, + * 0=not about trigger + */ #define AdFunction_Start 0x01 /* 1=trigger start, 0=trigger stop */ /* bits from A/D status register (PCI9118_ADSTAT) */ @@ -178,30 +215,39 @@ static const struct comedi_lrange range_pci9118hg = { 8, { } }; -#define PCI9118_BIPOLAR_RANGES 4 /* used for test on mixture of BIP/UNI ranges */ +#define PCI9118_BIPOLAR_RANGES 4 /* + * used for test on mixture + * of BIP/UNI ranges + */ static int pci9118_attach(struct comedi_device *dev, struct comedi_devconfig *it); static int pci9118_detach(struct comedi_device *dev); struct boardtype { - const char *name; /* board name */ - int vendor_id; /* PCI vendor a device ID of card */ + const char *name; /* board name */ + int vendor_id; /* PCI vendor a device ID of card */ int device_id; - int iorange_amcc; /* iorange for own S5933 region */ - int iorange_9118; /* pass thru card region size */ - int n_aichan; /* num of A/D chans */ - int n_aichand; /* num of A/D chans in diff mode */ - int mux_aichan; /* num of A/D chans with external multiplexor */ - int n_aichanlist; /* len of chanlist */ - int n_aochan; /* num of D/A chans */ - int ai_maxdata; /* resolution of A/D */ - int ao_maxdata; /* resolution of D/A */ - const struct comedi_lrange *rangelist_ai; /* rangelist for A/D */ - const struct comedi_lrange *rangelist_ao; /* rangelist for D/A */ - unsigned int ai_ns_min; /* max sample speed of card v ns */ - unsigned int ai_pacer_min; /* minimal pacer value (c1*c2 or c1 in burst) */ - int half_fifo_size; /* size of FIFO/2 */ + int iorange_amcc; /* iorange for own S5933 region */ + int iorange_9118; /* pass thru card region size */ + int n_aichan; /* num of A/D chans */ + int n_aichand; /* num of A/D chans in diff mode */ + int mux_aichan; /* + * num of A/D chans with + * external multiplexor + */ + int n_aichanlist; /* len of chanlist */ + int n_aochan; /* num of D/A chans */ + int ai_maxdata; /* resolution of A/D */ + int ao_maxdata; /* resolution of D/A */ + const struct comedi_lrange *rangelist_ai; /* rangelist for A/D */ + const struct comedi_lrange *rangelist_ao; /* rangelist for D/A */ + unsigned int ai_ns_min; /* max sample speed of card v ns */ + unsigned int ai_pacer_min; /* + * minimal pacer value + * (c1*c2 or c1 in burst) + */ + int half_fifo_size; /* size of FIFO/2 */ }; @@ -246,63 +292,113 @@ static struct comedi_driver driver_pci9118 = { COMEDI_PCI_INITCLEANUP(driver_pci9118, pci9118_pci_table); struct pci9118_private { - unsigned long iobase_a; /* base+size for AMCC chip */ - unsigned int master; /* master capable */ - struct pci_dev *pcidev; /* ptr to actual pcidev */ - unsigned int usemux; /* we want to use external multiplexor! */ + unsigned long iobase_a; /* base+size for AMCC chip */ + unsigned int master; /* master capable */ + struct pci_dev *pcidev; /* ptr to actual pcidev */ + unsigned int usemux; /* we want to use external multiplexor! */ #ifdef PCI9118_PARANOIDCHECK - unsigned short chanlist[PCI9118_CHANLEN + 1]; /* list of scaned channel */ - unsigned char chanlistlen; /* number of scanlist */ + unsigned short chanlist[PCI9118_CHANLEN + 1]; /* + * list of + * scanned channel + */ + unsigned char chanlistlen; /* number of scanlist */ #endif - unsigned char AdControlReg; /* A/D control register */ - unsigned char IntControlReg; /* Interrupt control register */ - unsigned char AdFunctionReg; /* A/D function register */ - char valid; /* driver is ok */ - char ai_neverending; /* we do unlimited AI */ - unsigned int i8254_osc_base; /* frequence of onboard oscilator */ - unsigned int ai_do; /* what do AI? 0=nothing, 1 to 4 mode */ - unsigned int ai_act_scan; /* how many scans we finished */ - unsigned int ai_buf_ptr; /* data buffer ptr in samples */ - unsigned int ai_n_chan; /* how many channels is measured */ - unsigned int ai_n_scanlen; /* len of actual scanlist */ - unsigned int ai_n_realscanlen; /* what we must transfer for one outgoing scan include front/back adds */ - unsigned int ai_act_dmapos; /* position in actual real stream */ - unsigned int ai_add_front; /* how many channels we must add before scan to satisfy S&H? */ - unsigned int ai_add_back; /* how many channels we must add before scan to satisfy DMA? */ - unsigned int *ai_chanlist; /* actaul chanlist */ + unsigned char AdControlReg; /* A/D control register */ + unsigned char IntControlReg; /* Interrupt control register */ + unsigned char AdFunctionReg; /* A/D function register */ + char valid; /* driver is ok */ + char ai_neverending; /* we do unlimited AI */ + unsigned int i8254_osc_base; /* frequence of onboard oscilator */ + unsigned int ai_do; /* what do AI? 0=nothing, 1 to 4 mode */ + unsigned int ai_act_scan; /* how many scans we finished */ + unsigned int ai_buf_ptr; /* data buffer ptr in samples */ + unsigned int ai_n_chan; /* how many channels is measured */ + unsigned int ai_n_scanlen; /* len of actual scanlist */ + unsigned int ai_n_realscanlen; /* + * what we must transfer for one + * outgoing scan include front/back adds + */ + unsigned int ai_act_dmapos; /* position in actual real stream */ + unsigned int ai_add_front; /* + * how many channels we must add + * before scan to satisfy S&H? + */ + unsigned int ai_add_back; /* + * how many channels we must add + * before scan to satisfy DMA? + */ + unsigned int *ai_chanlist; /* actual chanlist */ unsigned int ai_timer1; unsigned int ai_timer2; unsigned int ai_flags; - char ai12_startstop; /* measure can start/stop on external trigger */ - unsigned int ai_divisor1, ai_divisor2; /* divisors for start of measure on external start */ + char ai12_startstop; /* + * measure can start/stop + * on external trigger + */ + unsigned int ai_divisor1, ai_divisor2; /* + * divisors for start of measure + * on external start + */ unsigned int ai_data_len; short *ai_data; - short ao_data[2]; /* data output buffer */ - unsigned int ai_scans; /* number of scans to do */ - char dma_doublebuf; /* we can use double buffring */ - unsigned int dma_actbuf; /* which buffer is used now */ - short *dmabuf_virt[2]; /* pointers to begin of DMA buffer */ - unsigned long dmabuf_hw[2]; /* hw address of DMA buff */ - unsigned int dmabuf_size[2]; /* size of dma buffer in bytes */ - unsigned int dmabuf_use_size[2]; /* which size we may now used for transfer */ - unsigned int dmabuf_used_size[2]; /* which size was trully used */ + short ao_data[2]; /* data output buffer */ + unsigned int ai_scans; /* number of scans to do */ + char dma_doublebuf; /* we can use double buffring */ + unsigned int dma_actbuf; /* which buffer is used now */ + short *dmabuf_virt[2]; /* + * pointers to begin of + * DMA buffer + */ + unsigned long dmabuf_hw[2]; /* hw address of DMA buff */ + unsigned int dmabuf_size[2]; /* + * size of dma buffer in bytes + */ + unsigned int dmabuf_use_size[2]; /* + * which size we may now use + * for transfer + */ + unsigned int dmabuf_used_size[2]; /* which size was truly used */ unsigned int dmabuf_panic_size[2]; - unsigned int dmabuf_samples[2]; /* size in samples */ - int dmabuf_pages[2]; /* number of pages in buffer */ - unsigned char cnt0_users; /* bit field of 8254 CNT0 users (0-unused, 1-AO, 2-DI, 3-DO) */ - unsigned char exttrg_users; /* bit field of external trigger users (0-AI, 1-AO, 2-DI, 3-DO) */ - unsigned int cnt0_divisor; /* actual CNT0 divisor */ - void (*int_ai_func) (struct comedi_device *, struct comedi_subdevice *, unsigned short, unsigned int, unsigned short); /* ptr to actual interrupt AI function */ - unsigned char ai16bits; /* =1 16 bit card */ - unsigned char usedma; /* =1 use DMA transfer and not INT */ - unsigned char useeoshandle; /* =1 change WAKE_EOS DMA transfer to fit on every second */ - unsigned char usessh; /* =1 turn on S&H support */ - int softsshdelay; /* >0 use software S&H, numer is requested delay in ns */ - unsigned char softsshsample; /* polarity of S&H signal in sample state */ - unsigned char softsshhold; /* polarity of S&H signal in hold state */ - unsigned int ai_maskerr; /* which warning was printed */ - unsigned int ai_maskharderr; /* on which error bits stops */ - unsigned int ai_inttrig_start; /* TRIG_INT for start */ + unsigned int dmabuf_samples[2]; /* size in samples */ + int dmabuf_pages[2]; /* number of pages in buffer */ + unsigned char cnt0_users; /* + * bit field of 8254 CNT0 users + * (0-unused, 1-AO, 2-DI, 3-DO) + */ + unsigned char exttrg_users; /* + * bit field of external trigger + * users(0-AI, 1-AO, 2-DI, 3-DO) + */ + unsigned int cnt0_divisor; /* actual CNT0 divisor */ + void (*int_ai_func) (struct comedi_device *, struct comedi_subdevice *, + unsigned short, + unsigned int, + unsigned short); /* + * ptr to actual interrupt + * AI function + */ + unsigned char ai16bits; /* =1 16 bit card */ + unsigned char usedma; /* =1 use DMA transfer and not INT */ + unsigned char useeoshandle; /* + * =1 change WAKE_EOS DMA transfer + * to fit on every second + */ + unsigned char usessh; /* =1 turn on S&H support */ + int softsshdelay; /* + * >0 use software S&H, + * numer is requested delay in ns + */ + unsigned char softsshsample; /* + * polarity of S&H signal + * in sample state + */ + unsigned char softsshhold; /* + * polarity of S&H signal + * in hold state + */ + unsigned int ai_maskerr; /* which warning was printed */ + unsigned int ai_maskharderr; /* on which error bits stops */ + unsigned int ai_inttrig_start; /* TRIG_INT for start */ }; #define devpriv ((struct pci9118_private *)dev->private) @@ -346,12 +442,19 @@ static int pci9118_insn_read_ai(struct comedi_device *dev, devpriv->AdControlReg = AdControl_Int & 0xff; devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg; - outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); /* positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop */ + outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); + /* + * positive triggers, no S&H, + * no burst, burst stop, + * no post trigger, + * no about trigger, + * trigger stop + */ if (!setup_channel_list(dev, s, 1, &insn->chanspec, 0, 0, 0, 0, 0)) return -EINVAL; - outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ + outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ for (n = 0; n < insn->n; n++) { outw(0, dev->iobase + PCI9118_SOFTTRG); /* start conversion */ @@ -365,7 +468,7 @@ static int pci9118_insn_read_ai(struct comedi_device *dev, comedi_error(dev, "A/D insn timeout"); data[n] = 0; - outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ + outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ return -ETIME; conv_finish: @@ -379,7 +482,7 @@ conv_finish: } } - outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ + outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ return n; } @@ -394,11 +497,11 @@ static int pci9118_insn_write_ao(struct comedi_device *dev, int n, chanreg, ch; ch = CR_CHAN(insn->chanspec); - if (ch) { + if (ch) chanreg = PCI9118_DA2; - } else { + else chanreg = PCI9118_DA1; - } + for (n = 0; n < insn->n; n++) { outl(data[n], dev->iobase + chanreg); @@ -561,11 +664,11 @@ static void pci9118_ai_munge(struct comedi_device *dev, for (i = 0; i < num_samples; i++) { if (devpriv->usedma) array[i] = be16_to_cpu(array[i]); - if (devpriv->ai16bits) { + if (devpriv->ai16bits) array[i] ^= 0x8000; - } else { + else array[i] = (array[i] >> 4) & 0x0fff; - } + } } @@ -590,11 +693,13 @@ static void interrupt_pci9118_ai_onesample(struct comedi_device *dev, #ifdef PCI9118_PARANOIDCHECK if (devpriv->ai16bits == 0) { - if ((sampl & 0x000f) != devpriv->chanlist[s->async->cur_chan]) { /* data dropout! */ + if ((sampl & 0x000f) != devpriv->chanlist[s->async->cur_chan]) { + /* data dropout! */ printk - ("comedi: A/D SAMPL - data dropout: received channel %d, expected %d!\n", - sampl & 0x000f, - devpriv->chanlist[s->async->cur_chan]); + ("comedi: A/D SAMPL - data dropout: " + "received channel %d, expected %d!\n", + sampl & 0x000f, + devpriv->chanlist[s->async->cur_chan]); s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; pci9118_ai_cancel(dev, s); comedi_event(dev, s); @@ -604,11 +709,13 @@ static void interrupt_pci9118_ai_onesample(struct comedi_device *dev, #endif cfc_write_to_buffer(s, sampl); s->async->cur_chan++; - if (s->async->cur_chan >= devpriv->ai_n_scanlen) { /* one scan done */ + if (s->async->cur_chan >= devpriv->ai_n_scanlen) { + /* one scan done */ s->async->cur_chan %= devpriv->ai_n_scanlen; devpriv->ai_act_scan++; if (!(devpriv->ai_neverending)) - if (devpriv->ai_act_scan >= devpriv->ai_scans) { /* all data sampled */ + if (devpriv->ai_act_scan >= devpriv->ai_scans) { + /* all data sampled */ pci9118_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA; } @@ -644,16 +751,19 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, comedi_event(dev, s); return; } - if (int_adstat & devpriv->ai_maskerr) -/* if (int_adstat & 0x106) */ + /* if (int_adstat & 0x106) */ if (pci9118_decode_error_status(dev, s, int_adstat)) return; - samplesinbuf = devpriv->dmabuf_use_size[devpriv->dma_actbuf] >> 1; /* number of received real samples */ + samplesinbuf = devpriv->dmabuf_use_size[devpriv->dma_actbuf] >> 1; + /* number of received real samples */ /* DPRINTK("dma_actbuf=%d\n",devpriv->dma_actbuf); */ - if (devpriv->dma_doublebuf) { /* switch DMA buffers if is used double buffering */ + if (devpriv->dma_doublebuf) { /* + * switch DMA buffers if is used + * double buffering + */ next_dma_buf = 1 - devpriv->dma_actbuf; outl(devpriv->dmabuf_hw[next_dma_buf], devpriv->iobase_a + AMCC_OP_REG_MWAR); @@ -666,25 +776,32 @@ static void interrupt_pci9118_ai_dma(struct comedi_device *dev, } if (samplesinbuf) { - m = devpriv->ai_data_len >> 1; /* how many samples is to end of buffer */ -/* DPRINTK("samps=%d m=%d %d %d\n",samplesinbuf,m,s->async->buf_int_count,s->async->buf_int_ptr); */ + m = devpriv->ai_data_len >> 1; /* + * how many samples is to + * end of buffer + */ +/* + * DPRINTK("samps=%d m=%d %d %d\n", + * samplesinbuf,m,s->async->buf_int_count,s->async->buf_int_ptr); + */ sampls = m; move_block_from_dma(dev, s, devpriv->dmabuf_virt[devpriv->dma_actbuf], samplesinbuf); - m = m - sampls; /* m= how many samples was transfered */ + m = m - sampls; /* m= how many samples was transfered */ } /* DPRINTK("YYY\n"); */ if (!devpriv->ai_neverending) - if (devpriv->ai_act_scan >= devpriv->ai_scans) { /* all data sampled */ + if (devpriv->ai_act_scan >= devpriv->ai_scans) { + /* all data sampled */ pci9118_ai_cancel(dev, s); s->async->events |= COMEDI_CB_EOA; } - if (devpriv->dma_doublebuf) { /* switch dma buffers */ + if (devpriv->dma_doublebuf) { /* switch dma buffers */ devpriv->dma_actbuf = 1 - devpriv->dma_actbuf; - } else { /* restart DMA if is not used double buffering */ + } else { /* restart DMA if is not used double buffering */ outl(devpriv->dmabuf_hw[0], devpriv->iobase_a + AMCC_OP_REG_MWAR); outl(devpriv->dmabuf_use_size[0], @@ -705,39 +822,62 @@ static irqreturn_t interrupt_pci9118(int irq, void *d) unsigned int int_daq = 0, int_amcc, int_adstat; if (!dev->attached) - return IRQ_NONE; /* not fully initialized */ + return IRQ_NONE; /* not fully initialized */ - int_daq = inl(dev->iobase + PCI9118_INTSRC) & 0xf; /* get IRQ reasons from card */ - int_amcc = inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* get INT register from AMCC chip */ + int_daq = inl(dev->iobase + PCI9118_INTSRC) & 0xf; + /* get IRQ reasons from card */ + int_amcc = inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR); + /* get INT register from AMCC chip */ -/* DPRINTK("INT daq=0x%01x amcc=0x%08x MWAR=0x%08x MWTC=0x%08x ADSTAT=0x%02x ai_do=%d\n", int_daq, int_amcc, inl(devpriv->iobase_a+AMCC_OP_REG_MWAR), inl(devpriv->iobase_a+AMCC_OP_REG_MWTC), inw(dev->iobase+PCI9118_ADSTAT)&0x1ff,devpriv->ai_do); */ +/* + * DPRINTK("INT daq=0x%01x amcc=0x%08x MWAR=0x%08x + * MWTC=0x%08x ADSTAT=0x%02x ai_do=%d\n", + * int_daq, int_amcc, inl(devpriv->iobase_a+AMCC_OP_REG_MWAR), + * inl(devpriv->iobase_a+AMCC_OP_REG_MWTC), + * inw(dev->iobase+PCI9118_ADSTAT)&0x1ff,devpriv->ai_do); + */ if ((!int_daq) && (!(int_amcc & ANY_S593X_INT))) - return IRQ_NONE; /* interrupt from other source */ + return IRQ_NONE; /* interrupt from other source */ - outl(int_amcc | 0x00ff0000, devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* shutdown IRQ reasons in AMCC */ + outl(int_amcc | 0x00ff0000, devpriv->iobase_a + AMCC_OP_REG_INTCSR); + /* shutdown IRQ reasons in AMCC */ - int_adstat = inw(dev->iobase + PCI9118_ADSTAT) & 0x1ff; /* get STATUS register */ + int_adstat = inw(dev->iobase + PCI9118_ADSTAT) & 0x1ff; + /* get STATUS register */ if (devpriv->ai_do) { if (devpriv->ai12_startstop) - if ((int_adstat & AdStatus_DTH) && (int_daq & Int_DTrg)) { /* start stop of measure */ + if ((int_adstat & AdStatus_DTH) && + (int_daq & Int_DTrg)) { + /* start stop of measure */ if (devpriv->ai12_startstop & START_AI_EXT) { devpriv->ai12_startstop &= ~START_AI_EXT; if (!(devpriv->ai12_startstop & - STOP_AI_EXT)) - pci9118_exttrg_del(dev, EXTTRG_AI); /* deactivate EXT trigger */ - start_pacer(dev, devpriv->ai_do, devpriv->ai_divisor1, devpriv->ai_divisor2); /* start pacer */ + STOP_AI_EXT)) + pci9118_exttrg_del + (dev, EXTTRG_AI); + /* deactivate EXT trigger */ + start_pacer(dev, devpriv->ai_do, + devpriv->ai_divisor1, + devpriv->ai_divisor2); + /* start pacer */ outl(devpriv->AdControlReg, - dev->iobase + PCI9118_ADCNTRL); + dev->iobase + PCI9118_ADCNTRL); } else { if (devpriv->ai12_startstop & - STOP_AI_EXT) { + STOP_AI_EXT) { devpriv->ai12_startstop &= - ~STOP_AI_EXT; - pci9118_exttrg_del(dev, EXTTRG_AI); /* deactivate EXT trigger */ - devpriv->ai_neverending = 0; /* well, on next interrupt from DMA/EOC measure will stop */ + ~STOP_AI_EXT; + pci9118_exttrg_del + (dev, EXTTRG_AI); + /* deactivate EXT trigger */ + devpriv->ai_neverending = 0; + /* + * well, on next interrupt from + * DMA/EOC measure will stop + */ } } } @@ -791,20 +931,20 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev, err++; tmp = cmd->scan_begin_src; - if (devpriv->master) { + if (devpriv->master) cmd->scan_begin_src &= TRIG_TIMER | TRIG_EXT | TRIG_FOLLOW; - } else { + else cmd->scan_begin_src &= TRIG_FOLLOW; - } + if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src) err++; tmp = cmd->convert_src; - if (devpriv->master) { + if (devpriv->master) cmd->convert_src &= TRIG_TIMER | TRIG_EXT | TRIG_NOW; - } else { + else cmd->convert_src &= TRIG_TIMER | TRIG_EXT; - } + if (!cmd->convert_src || tmp != cmd->convert_src) err++; @@ -821,7 +961,11 @@ static int pci9118_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 + */ if (cmd->start_src != TRIG_NOW && cmd->start_src != TRIG_INT && cmd->start_src != TRIG_EXT) { @@ -1026,7 +1170,7 @@ static int pci9118_ai_cmdtest(struct comedi_device *dev, if (cmd->chanlist) if (!check_channel_list(dev, s, cmd->chanlist_len, cmd->chanlist, 0, 0)) - return 5; /* incorrect channels list */ + return 5; /* incorrect channels list */ return 0; } @@ -1043,88 +1187,101 @@ static int Compute_and_setup_dma(struct comedi_device *dev) dmalen1 = devpriv->dmabuf_size[1]; DPRINTK("1 dmalen0=%d dmalen1=%d ai_data_len=%d\n", dmalen0, dmalen1, devpriv->ai_data_len); - /* isn't output buff smaller that our DMA buff? */ + /* isn't output buff smaller that our DMA buff? */ if (dmalen0 > (devpriv->ai_data_len)) { - dmalen0 = devpriv->ai_data_len & ~3L; /* allign to 32bit down */ + dmalen0 = devpriv->ai_data_len & ~3L; /* + * align to 32bit down + */ } if (dmalen1 > (devpriv->ai_data_len)) { - dmalen1 = devpriv->ai_data_len & ~3L; /* allign to 32bit down */ + dmalen1 = devpriv->ai_data_len & ~3L; /* + * align to 32bit down + */ } DPRINTK("2 dmalen0=%d dmalen1=%d \n", dmalen0, dmalen1); - /* we want wake up every scan? */ + /* we want wake up every scan? */ if (devpriv->ai_flags & TRIG_WAKE_EOS) { if (dmalen0 < (devpriv->ai_n_realscanlen << 1)) { - /* uff, too short DMA buffer, disable EOS support! */ + /* uff, too short DMA buffer, disable EOS support! */ devpriv->ai_flags &= (~TRIG_WAKE_EOS); printk - ("comedi%d: WAR: DMA0 buf too short, cann't support TRIG_WAKE_EOS (%d<%d)\n", + ("comedi%d: WAR: DMA0 buf too short, can't " + "support TRIG_WAKE_EOS (%d<%d)\n", dev->minor, dmalen0, devpriv->ai_n_realscanlen << 1); } else { - /* short first DMA buffer to one scan */ + /* short first DMA buffer to one scan */ dmalen0 = devpriv->ai_n_realscanlen << 1; DPRINTK - ("21 dmalen0=%d ai_n_realscanlen=%d useeoshandle=%d\n", - dmalen0, devpriv->ai_n_realscanlen, - devpriv->useeoshandle); + ("21 dmalen0=%d ai_n_realscanlen=%d " + "useeoshandle=%d\n", + dmalen0, devpriv->ai_n_realscanlen, + devpriv->useeoshandle); if (devpriv->useeoshandle) dmalen0 += 2; if (dmalen0 < 4) { printk - ("comedi%d: ERR: DMA0 buf len bug? (%d<4)\n", - dev->minor, dmalen0); + ("comedi%d: ERR: DMA0 buf len bug? " + "(%d<4)\n", + dev->minor, dmalen0); dmalen0 = 4; } } } if (devpriv->ai_flags & TRIG_WAKE_EOS) { if (dmalen1 < (devpriv->ai_n_realscanlen << 1)) { - /* uff, too short DMA buffer, disable EOS support! */ + /* uff, too short DMA buffer, disable EOS support! */ devpriv->ai_flags &= (~TRIG_WAKE_EOS); printk - ("comedi%d: WAR: DMA1 buf too short, cann't support TRIG_WAKE_EOS (%d<%d)\n", + ("comedi%d: WAR: DMA1 buf too short, " + "can't support TRIG_WAKE_EOS (%d<%d)\n", dev->minor, dmalen1, devpriv->ai_n_realscanlen << 1); } else { - /* short second DMA buffer to one scan */ + /* short second DMA buffer to one scan */ dmalen1 = devpriv->ai_n_realscanlen << 1; DPRINTK - ("22 dmalen1=%d ai_n_realscanlen=%d useeoshandle=%d\n", + ("22 dmalen1=%d ai_n_realscanlen=%d " + "useeoshandle=%d\n", dmalen1, devpriv->ai_n_realscanlen, devpriv->useeoshandle); if (devpriv->useeoshandle) dmalen1 -= 2; if (dmalen1 < 4) { printk - ("comedi%d: ERR: DMA1 buf len bug? (%d<4)\n", - dev->minor, dmalen1); + ("comedi%d: ERR: DMA1 buf len bug? " + "(%d<4)\n", + dev->minor, dmalen1); dmalen1 = 4; } } } DPRINTK("3 dmalen0=%d dmalen1=%d \n", dmalen0, dmalen1); - /* transfer without TRIG_WAKE_EOS */ + /* transfer without TRIG_WAKE_EOS */ if (!(devpriv->ai_flags & TRIG_WAKE_EOS)) { - /* if it's possible then allign DMA buffers to length of scan */ + /* if it's possible then allign DMA buffers to length of scan */ i = dmalen0; dmalen0 = (dmalen0 / (devpriv->ai_n_realscanlen << 1)) * (devpriv->ai_n_realscanlen << 1); dmalen0 &= ~3L; if (!dmalen0) - dmalen0 = i; /* uff. very long scan? */ + dmalen0 = i; /* uff. very long scan? */ i = dmalen1; dmalen1 = (dmalen1 / (devpriv->ai_n_realscanlen << 1)) * (devpriv->ai_n_realscanlen << 1); dmalen1 &= ~3L; if (!dmalen1) - dmalen1 = i; /* uff. very long scan? */ - /* if measure isn't neverending then test, if it whole fits into one or two DMA buffers */ + dmalen1 = i; /* uff. very long scan? */ + /* + * if measure isn't neverending then test, if it fits whole + * into one or two DMA buffers + */ if (!devpriv->ai_neverending) { - /* fits whole measure into one DMA buffer? */ + /* fits whole measure into one DMA buffer? */ if (dmalen0 > ((devpriv->ai_n_realscanlen << 1) * devpriv->ai_scans)) { @@ -1138,7 +1295,10 @@ static int Compute_and_setup_dma(struct comedi_device *dev) DPRINTK("3.1 dmalen0=%d dmalen1=%d \n", dmalen0, dmalen1); dmalen0 &= ~3L; - } else { /* fits whole measure into two DMA buffer? */ + } else { /* + * fits whole measure into + * two DMA buffer? + */ if (dmalen1 > ((devpriv->ai_n_realscanlen << 1) * devpriv->ai_scans - dmalen0)) @@ -1154,7 +1314,7 @@ static int Compute_and_setup_dma(struct comedi_device *dev) DPRINTK("4 dmalen0=%d dmalen1=%d \n", dmalen0, dmalen1); - /* these DMA buffer size we'll be used */ + /* these DMA buffer size will be used */ devpriv->dma_actbuf = 0; devpriv->dmabuf_use_size[0] = dmalen0; devpriv->dmabuf_use_size[1] = dmalen1; @@ -1176,10 +1336,11 @@ static int Compute_and_setup_dma(struct comedi_device *dev) } #endif - outl(inl(devpriv->iobase_a + AMCC_OP_REG_MCSR) & (~EN_A2P_TRANSFERS), devpriv->iobase_a + AMCC_OP_REG_MCSR); /* stop DMA */ + outl(inl(devpriv->iobase_a + AMCC_OP_REG_MCSR) & (~EN_A2P_TRANSFERS), + devpriv->iobase_a + AMCC_OP_REG_MCSR); /* stop DMA */ outl(devpriv->dmabuf_hw[0], devpriv->iobase_a + AMCC_OP_REG_MWAR); outl(devpriv->dmabuf_use_size[0], devpriv->iobase_a + AMCC_OP_REG_MWTC); - /* init DMA transfer */ + /* init DMA transfer */ outl(0x00000000 | AINT_WRITE_COMPL, devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* outl(0x02000000|AINT_WRITE_COMPL, devpriv->iobase_a+AMCC_OP_REG_INTCSR); */ @@ -1187,7 +1348,9 @@ static int Compute_and_setup_dma(struct comedi_device *dev) outl(inl(devpriv->iobase_a + AMCC_OP_REG_MCSR) | RESET_A2P_FLAGS | A2P_HI_PRIORITY | EN_A2P_TRANSFERS, devpriv->iobase_a + AMCC_OP_REG_MCSR); - outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | EN_A2P_TRANSFERS, devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* allow bus mastering */ + outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | EN_A2P_TRANSFERS, + devpriv->iobase_a + AMCC_OP_REG_INTCSR); + /* allow bus mastering */ DPRINTK("adl_pci9118 EDBG: END: Compute_and_setup_dma()\n"); return 0; @@ -1220,17 +1383,21 @@ static int pci9118_ai_docmd_sampl(struct comedi_device *dev, return -EIO; }; - devpriv->int_ai_func = interrupt_pci9118_ai_onesample; /* transfer function */ + devpriv->int_ai_func = interrupt_pci9118_ai_onesample; + /* transfer function */ if (devpriv->ai12_startstop) - pci9118_exttrg_add(dev, EXTTRG_AI); /* activate EXT trigger */ + pci9118_exttrg_add(dev, EXTTRG_AI); + /* activate EXT trigger */ if ((devpriv->ai_do == 1) || (devpriv->ai_do == 2)) devpriv->IntControlReg |= Int_Timer; devpriv->AdControlReg |= AdControl_Int; - outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | 0x1f00, devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* allow INT in AMCC */ + outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | 0x1f00, + devpriv->iobase_a + AMCC_OP_REG_INTCSR); + /* allow INT in AMCC */ if (!(devpriv->ai12_startstop & (START_AI_EXT | START_AI_INT))) { outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL); @@ -1296,10 +1463,12 @@ static int pci9118_ai_docmd_dma(struct comedi_device *dev, }; if (devpriv->ai12_startstop) { - pci9118_exttrg_add(dev, EXTTRG_AI); /* activate EXT trigger */ + pci9118_exttrg_add(dev, EXTTRG_AI); + /* activate EXT trigger */ } - devpriv->int_ai_func = interrupt_pci9118_ai_dma; /* transfer function */ + devpriv->int_ai_func = interrupt_pci9118_ai_dma; + /* transfer function */ outl(0x02000000 | AINT_WRITE_COMPL, devpriv->iobase_a + AMCC_OP_REG_INTCSR); @@ -1342,7 +1511,7 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_add_back = 0; devpriv->ai_maskerr = 0x10e; - /* prepare for start/stop conditions */ + /* prepare for start/stop conditions */ if (cmd->start_src == TRIG_EXT) devpriv->ai12_startstop |= START_AI_EXT; if (cmd->stop_src == TRIG_EXT) { @@ -1369,10 +1538,10 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_scans = 0; } - /* use sample&hold signal? */ + /* use sample&hold signal? */ if (cmd->convert_src == TRIG_NOW) { devpriv->usessh = 1; - } /* yes */ + } /* yes */ else { devpriv->usessh = 0; } /* no */ @@ -1381,7 +1550,10 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_neverending, devpriv->ai_scans, devpriv->usessh, devpriv->ai12_startstop); - /* use additional sample at end of every scan to satisty DMA 32 bit transfer? */ + /* + * use additional sample at end of every scan + * to satisty DMA 32 bit transfer? + */ devpriv->ai_add_front = 0; devpriv->ai_add_back = 0; devpriv->useeoshandle = 0; @@ -1393,27 +1565,44 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_add_back = 1; } if (cmd->convert_src == TRIG_TIMER) { - devpriv->usedma = 0; /* use INT transfer if scanlist have only one channel */ + devpriv->usedma = 0; + /* + * use INT transfer if scanlist + * have only one channel + */ } } if ((cmd->flags & TRIG_WAKE_EOS) && (devpriv->ai_n_scanlen & 1) && (devpriv->ai_n_scanlen > 1)) { if (cmd->scan_begin_src == TRIG_FOLLOW) { - /* vpriv->useeoshandle=1; // change DMA transfer block to fit EOS on every second call */ - devpriv->usedma = 0; /* XXX maybe can be corrected to use 16 bit DMA */ - } else { /* well, we must insert one sample to end of EOS to meet 32 bit transfer */ + /* + * vpriv->useeoshandle=1; // change DMA transfer + * block to fit EOS on every second call + */ + devpriv->usedma = 0; + /* + * XXX maybe can be corrected to use 16 bit DMA + */ + } else { /* + * well, we must insert one sample + * to end of EOS to meet 32 bit transfer + */ devpriv->ai_add_back = 1; } } - } else { /* interrupt transfer don't need any correction */ + } else { /* interrupt transfer don't need any correction */ devpriv->usedma = 0; } - /* we need software S&H signal? It add two samples before every scan as minimum */ + /* + * we need software S&H signal? + * It adds two samples before every scan as minimum + */ if (devpriv->usessh && devpriv->softsshdelay) { devpriv->ai_add_front = 2; - if ((devpriv->usedma == 1) && (devpriv->ai_add_back == 1)) { /* move it to front */ + if ((devpriv->usedma == 1) && (devpriv->ai_add_back == 1)) { + /* move it to front */ devpriv->ai_add_front++; devpriv->ai_add_back = 0; } @@ -1422,17 +1611,22 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) addchans = devpriv->softsshdelay / cmd->convert_arg; if (devpriv->softsshdelay % cmd->convert_arg) addchans++; - if (addchans > (devpriv->ai_add_front - 1)) { /* uff, still short :-( */ + if (addchans > (devpriv->ai_add_front - 1)) { + /* uff, still short */ devpriv->ai_add_front = addchans + 1; if (devpriv->usedma == 1) if ((devpriv->ai_add_front + devpriv->ai_n_chan + devpriv->ai_add_back) & 1) - devpriv->ai_add_front++; /* round up to 32 bit */ + devpriv->ai_add_front++; + /* round up to 32 bit */ } } - /* well, we now know what must be all added */ - devpriv->ai_n_realscanlen = /* what we must take from card in real to have ai_n_scanlen on output? */ + /* well, we now know what must be all added */ + devpriv->ai_n_realscanlen = /* + * what we must take from card in real + * to have ai_n_scanlen on output? + */ (devpriv->ai_add_front + devpriv->ai_n_chan + devpriv->ai_add_back) * (devpriv->ai_n_scanlen / devpriv->ai_n_chan); @@ -1443,7 +1637,7 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_n_chan, devpriv->ai_add_back, devpriv->ai_n_scanlen); - /* check and setup channel list */ + /* check and setup channel list */ if (!check_channel_list(dev, s, devpriv->ai_n_chan, devpriv->ai_chanlist, devpriv->ai_add_front, devpriv->ai_add_back)) @@ -1454,9 +1648,16 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->useeoshandle)) return -EINVAL; - /* compute timers settings */ - /* simplest way, fr=4Mhz/(tim1*tim2), channel manipulation without timers effect */ - if (((cmd->scan_begin_src == TRIG_FOLLOW) || (cmd->scan_begin_src == TRIG_EXT) || (cmd->scan_begin_src == TRIG_INT)) && (cmd->convert_src == TRIG_TIMER)) { /* both timer is used for one time */ + /* compute timers settings */ + /* + * simplest way, fr=4Mhz/(tim1*tim2), + * channel manipulation without timers effect + */ + if (((cmd->scan_begin_src == TRIG_FOLLOW) || + (cmd->scan_begin_src == TRIG_EXT) || + (cmd->scan_begin_src == TRIG_INT)) && + (cmd->convert_src == TRIG_TIMER)) { + /* both timer is used for one time */ if (cmd->scan_begin_src == TRIG_EXT) { devpriv->ai_do = 4; } else { @@ -1472,10 +1673,14 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_timer2 = cmd->convert_arg; } - if ((cmd->scan_begin_src == TRIG_TIMER) && ((cmd->convert_src == TRIG_TIMER) || (cmd->convert_src == TRIG_NOW))) { /* double timed action */ + if ((cmd->scan_begin_src == TRIG_TIMER) && + ((cmd->convert_src == TRIG_TIMER) || + (cmd->convert_src == TRIG_NOW))) { + /* double timed action */ if (!devpriv->usedma) { comedi_error(dev, - "cmd->scan_begin_src=TRIG_TIMER works only with bus mastering!"); + "cmd->scan_begin_src=TRIG_TIMER works " + "only with bus mastering!"); return -EIO; } @@ -1496,15 +1701,27 @@ static int pci9118_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_do = 3; } - start_pacer(dev, -1, 0, 0); /* stop pacer */ + start_pacer(dev, -1, 0, 0); /* stop pacer */ - devpriv->AdControlReg = 0; /* bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable DMA */ + devpriv->AdControlReg = 0; /* + * bipolar, S.E., use 8254, stop 8354, + * internal trigger, soft trigger, + * disable DMA + */ outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); - devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg; /* positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop */ + devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg; + /* + * positive triggers, no S&H, no burst, + * burst stop, no post trigger, + * no about trigger, trigger stop + */ outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); udelay(1); - outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ - inl(dev->iobase + PCI9118_ADSTAT); /* flush A/D and INT status register */ + outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ + inl(dev->iobase + PCI9118_ADSTAT); /* + * flush A/D and INT + * status register + */ inl(dev->iobase + PCI9118_INTSRC); devpriv->ai_act_scan = 0; @@ -1537,33 +1754,37 @@ static int check_channel_list(struct comedi_device *dev, } if ((frontadd + n_chan + backadd) > s->len_chanlist) { printk - ("comedi%d: range/channel list is too long for actual configuration (%d>%d)!", + ("comedi%d: range/channel list is too long for " + "actual configuration (%d>%d)!", dev->minor, n_chan, s->len_chanlist - frontadd - backadd); return 0; } if (CR_AREF(chanlist[0]) == AREF_DIFF) - differencial = 1; /* all input must be diff */ + differencial = 1; /* all input must be diff */ if (CR_RANGE(chanlist[0]) < PCI9118_BIPOLAR_RANGES) - bipolar = 1; /* all input must be bipolar */ + bipolar = 1; /* all input must be bipolar */ if (n_chan > 1) - for (i = 1; i < n_chan; i++) { /* check S.E/diff */ + for (i = 1; i < n_chan; i++) { /* check S.E/diff */ if ((CR_AREF(chanlist[i]) == AREF_DIFF) != (differencial)) { comedi_error(dev, - "Differencial and single ended inputs cann't be mixtured!"); + "Differencial and single ended " + "inputs can't be mixtured!"); return 0; } if ((CR_RANGE(chanlist[i]) < PCI9118_BIPOLAR_RANGES) != (bipolar)) { comedi_error(dev, - "Bipolar and unipolar ranges cann't be mixtured!"); + "Bipolar and unipolar ranges " + "can't be mixtured!"); return 0; } if ((!devpriv->usemux) & (differencial) & (CR_CHAN(chanlist[i]) >= this_board->n_aichand)) { comedi_error(dev, - "If AREF_DIFF is used then is available only first 8 channels!"); + "If AREF_DIFF is used then is " + "available only first 8 channels!"); return 0; } } @@ -1583,7 +1804,8 @@ static int setup_channel_list(struct comedi_device *dev, unsigned int scanquad, gain, ssh = 0x00; DPRINTK - ("adl_pci9118 EDBG: BGN: setup_channel_list(%d,.,%d,.,%d,%d,%d,%d)\n", + ("adl_pci9118 EDBG: BGN: setup_channel_list" + "(%d,.,%d,.,%d,%d,%d,%d)\n", dev->minor, n_chan, rot, frontadd, backadd, usedma); if (usedma == 1) { @@ -1592,27 +1814,33 @@ static int setup_channel_list(struct comedi_device *dev, } if (CR_AREF(chanlist[0]) == AREF_DIFF) - differencial = 1; /* all input must be diff */ + differencial = 1; /* all input must be diff */ if (CR_RANGE(chanlist[0]) < PCI9118_BIPOLAR_RANGES) - bipolar = 1; /* all input must be bipolar */ + bipolar = 1; /* all input must be bipolar */ - /* All is ok, so we can setup channel/range list */ + /* All is ok, so we can setup channel/range list */ if (!bipolar) { - devpriv->AdControlReg |= AdControl_UniP; /* set unibipolar */ + devpriv->AdControlReg |= AdControl_UniP; + /* set unibipolar */ } else { - devpriv->AdControlReg &= ((~AdControl_UniP) & 0xff); /* enable bipolar */ + devpriv->AdControlReg &= ((~AdControl_UniP) & 0xff); + /* enable bipolar */ } if (differencial) { - devpriv->AdControlReg |= AdControl_Diff; /* enable diff inputs */ + devpriv->AdControlReg |= AdControl_Diff; + /* enable diff inputs */ } else { - devpriv->AdControlReg &= ((~AdControl_Diff) & 0xff); /* set single ended inputs */ + devpriv->AdControlReg &= ((~AdControl_Diff) & 0xff); + /* set single ended inputs */ } - outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); /* setup mode */ + outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); + /* setup mode */ - outl(2, dev->iobase + PCI9118_SCANMOD); /* gods know why this sequence! */ + outl(2, dev->iobase + PCI9118_SCANMOD); + /* gods know why this sequence! */ outl(0, dev->iobase + PCI9118_SCANMOD); outl(1, dev->iobase + PCI9118_SCANMOD); @@ -1622,12 +1850,15 @@ static int setup_channel_list(struct comedi_device *dev, devpriv->chanlist[i] = 0x55aa; #endif - if (frontadd) { /* insert channels for S&H */ + if (frontadd) { /* insert channels for S&H */ ssh = devpriv->softsshsample; DPRINTK("FA: %04x: ", ssh); - for (i = 0; i < frontadd; i++) { /* store range list to card */ - scanquad = CR_CHAN(chanlist[0]); /* get channel number; */ - gain = CR_RANGE(chanlist[0]); /* get gain number */ + for (i = 0; i < frontadd; i++) { + /* store range list to card */ + scanquad = CR_CHAN(chanlist[0]); + /* get channel number; */ + gain = CR_RANGE(chanlist[0]); + /* get gain number */ scanquad |= ((gain & 0x03) << 8); outl(scanquad | ssh, dev->iobase + PCI9118_GAIN); DPRINTK("%02x ", scanquad | ssh); @@ -1637,23 +1868,24 @@ static int setup_channel_list(struct comedi_device *dev, } DPRINTK("SL: ", ssh); - for (i = 0; i < n_chan; i++) { /* store range list to card */ - scanquad = CR_CHAN(chanlist[i]); /* get channel number; */ + for (i = 0; i < n_chan; i++) { /* store range list to card */ + scanquad = CR_CHAN(chanlist[i]); /* get channel number */ #ifdef PCI9118_PARANOIDCHECK devpriv->chanlist[i ^ usedma] = (scanquad & 0xf) << rot; #endif - gain = CR_RANGE(chanlist[i]); /* get gain number */ + gain = CR_RANGE(chanlist[i]); /* get gain number */ scanquad |= ((gain & 0x03) << 8); outl(scanquad | ssh, dev->iobase + PCI9118_GAIN); DPRINTK("%02x ", scanquad | ssh); } DPRINTK("\n "); - if (backadd) { /* insert channels for fit onto 32bit DMA */ + if (backadd) { /* insert channels for fit onto 32bit DMA */ DPRINTK("BA: %04x: ", ssh); - for (i = 0; i < backadd; i++) { /* store range list to card */ - scanquad = CR_CHAN(chanlist[0]); /* get channel number; */ - gain = CR_RANGE(chanlist[0]); /* get gain number */ + for (i = 0; i < backadd; i++) { /* store range list to card */ + scanquad = CR_CHAN(chanlist[0]); + /* get channel number */ + gain = CR_RANGE(chanlist[0]); /* get gain number */ scanquad |= ((gain & 0x03) << 8); outl(scanquad | ssh, dev->iobase + PCI9118_GAIN); DPRINTK("%02x ", scanquad | ssh); @@ -1661,30 +1893,33 @@ static int setup_channel_list(struct comedi_device *dev, DPRINTK("\n "); } #ifdef PCI9118_PARANOIDCHECK - devpriv->chanlist[n_chan ^ usedma] = devpriv->chanlist[0 ^ usedma]; /* for 32bit oerations */ + devpriv->chanlist[n_chan ^ usedma] = devpriv->chanlist[0 ^ usedma]; + /* for 32bit operations */ if (useeos) { - for (i = 1; i < n_chan; i++) { /* store range list to card */ + for (i = 1; i < n_chan; i++) { /* store range list to card */ devpriv->chanlist[(n_chan + i) ^ usedma] = (CR_CHAN(chanlist[i]) & 0xf) << rot; } - devpriv->chanlist[(2 * n_chan) ^ usedma] = devpriv->chanlist[0 ^ usedma]; /* for 32bit oerations */ + devpriv->chanlist[(2 * n_chan) ^ usedma] = + devpriv->chanlist[0 ^ usedma]; + /* for 32bit operations */ useeos = 2; } else { useeos = 1; } #ifdef PCI9118_EXTDEBUG DPRINTK("CHL: "); - for (i = 0; i <= (useeos * n_chan); i++) { + for (i = 0; i <= (useeos * n_chan); i++) DPRINTK("%04x ", devpriv->chanlist[i]); - } + DPRINTK("\n "); #endif #endif - outl(0, dev->iobase + PCI9118_SCANMOD); /* close scan queue */ -/* udelay(100); important delay, or first sample will be cripled */ + outl(0, dev->iobase + PCI9118_SCANMOD); /* close scan queue */ + /* udelay(100); important delay, or first sample will be crippled */ DPRINTK("adl_pci9118 EDBG: END: setup_channel_list()\n"); - return 1; /* we can serve this with scan logic */ + return 1; /* we can serve this with scan logic */ } /* @@ -1699,7 +1934,8 @@ static void pci9118_calc_divisors(char mode, struct comedi_device *dev, char usessh, unsigned int chnsshfront) { DPRINTK - ("adl_pci9118 EDBG: BGN: pci9118_calc_divisors(%d,%d,.,%u,%u,%u,%d,.,.,,%u,%u)\n", + ("adl_pci9118 EDBG: BGN: pci9118_calc_divisors" + "(%d,%d,.,%u,%u,%u,%d,.,.,,%u,%u)\n", mode, dev->minor, *tim1, *tim2, flags, chans, usessh, chnsshfront); switch (mode) { case 1: @@ -1716,17 +1952,18 @@ static void pci9118_calc_divisors(char mode, struct comedi_device *dev, *tim2 = this_board->ai_ns_min; DPRINTK("1 div1=%u div2=%u timer1=%u timer2=%u\n", *div1, *div2, *tim1, *tim2); - *div1 = *tim2 / devpriv->i8254_osc_base; /* convert timer (burst) */ + *div1 = *tim2 / devpriv->i8254_osc_base; + /* convert timer (burst) */ DPRINTK("2 div1=%u div2=%u timer1=%u timer2=%u\n", *div1, *div2, *tim1, *tim2); if (*div1 < this_board->ai_pacer_min) *div1 = this_board->ai_pacer_min; DPRINTK("3 div1=%u div2=%u timer1=%u timer2=%u\n", *div1, *div2, *tim1, *tim2); - *div2 = *tim1 / devpriv->i8254_osc_base; /* scan timer */ + *div2 = *tim1 / devpriv->i8254_osc_base; /* scan timer */ DPRINTK("4 div1=%u div2=%u timer1=%u timer2=%u\n", *div1, *div2, *tim1, *tim2); - *div2 = *div2 / *div1; /* major timer is c1*c2 */ + *div2 = *div2 / *div1; /* major timer is c1*c2 */ DPRINTK("5 div1=%u div2=%u timer1=%u timer2=%u\n", *div1, *div2, *tim1, *tim2); if (*div2 < chans) @@ -1734,9 +1971,10 @@ static void pci9118_calc_divisors(char mode, struct comedi_device *dev, DPRINTK("6 div1=%u div2=%u timer1=%u timer2=%u\n", *div1, *div2, *tim1, *tim2); - *tim2 = *div1 * devpriv->i8254_osc_base; /* real convert timer */ + *tim2 = *div1 * devpriv->i8254_osc_base; + /* real convert timer */ - if (usessh & (chnsshfront == 0)) /* use BSSH signal */ + if (usessh & (chnsshfront == 0)) /* use BSSH signal */ if (*div2 < (chans + 2)) *div2 = chans + 2; @@ -1776,11 +2014,13 @@ static void start_pacer(struct comedi_device *dev, int mode, static int pci9118_exttrg_add(struct comedi_device *dev, unsigned char source) { if (source > 3) - return -1; /* incorrect source */ + return -1; /* incorrect source */ devpriv->exttrg_users |= (1 << source); devpriv->IntControlReg |= Int_DTrg; outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL); - outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | 0x1f00, devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* allow INT in AMCC */ + outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | 0x1f00, + devpriv->iobase_a + AMCC_OP_REG_INTCSR); + /* allow INT in AMCC */ return 0; } @@ -1790,12 +2030,15 @@ static int pci9118_exttrg_add(struct comedi_device *dev, unsigned char source) static int pci9118_exttrg_del(struct comedi_device *dev, unsigned char source) { if (source > 3) - return -1; /* incorrect source */ + return -1; /* incorrect source */ devpriv->exttrg_users &= ~(1 << source); - if (!devpriv->exttrg_users) { /* shutdown ext trg intterrupts */ + if (!devpriv->exttrg_users) { /* shutdown ext trg intterrupts */ devpriv->IntControlReg &= ~Int_DTrg; - if (!devpriv->IntControlReg) /* all IRQ disabled */ - outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) & (~0x00001f00), devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* disable int in AMCC */ + if (!devpriv->IntControlReg) /* all IRQ disabled */ + outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) & + (~0x00001f00), + devpriv->iobase_a + AMCC_OP_REG_INTCSR); + /* disable int in AMCC */ outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL); } return 0; @@ -1808,17 +2051,29 @@ static int pci9118_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { if (devpriv->usedma) - outl(inl(devpriv->iobase_a + AMCC_OP_REG_MCSR) & (~EN_A2P_TRANSFERS), devpriv->iobase_a + AMCC_OP_REG_MCSR); /* stop DMA */ + outl(inl(devpriv->iobase_a + AMCC_OP_REG_MCSR) & + (~EN_A2P_TRANSFERS), + devpriv->iobase_a + AMCC_OP_REG_MCSR); /* stop DMA */ pci9118_exttrg_del(dev, EXTTRG_AI); - start_pacer(dev, 0, 0, 0); /* stop 8254 counters */ + start_pacer(dev, 0, 0, 0); /* stop 8254 counters */ devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg; - outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); /* positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop */ + outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); + /* + * positive triggers, no S&H, no burst, + * burst stop, no post trigger, + * no about trigger, trigger stop + */ devpriv->AdControlReg = 0x00; - outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); /* bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable INT and DMA */ + outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); + /* + * bipolar, S.E., use 8254, stop 8354, + * internal trigger, soft trigger, + * disable INT and DMA + */ outl(0, dev->iobase + PCI9118_BURST); outl(1, dev->iobase + PCI9118_SCANMOD); - outl(2, dev->iobase + PCI9118_SCANMOD); /* reset scan queue */ - outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ + outl(2, dev->iobase + PCI9118_SCANMOD); /* reset scan queue */ + outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ devpriv->ai_do = 0; devpriv->usedma = 0; @@ -1832,7 +2087,9 @@ static int pci9118_ai_cancel(struct comedi_device *dev, devpriv->dma_actbuf = 0; if (!devpriv->IntControlReg) - outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | 0x1f00, devpriv->iobase_a + AMCC_OP_REG_INTCSR); /* allow INT in AMCC */ + outl(inl(devpriv->iobase_a + AMCC_OP_REG_INTCSR) | 0x1f00, + devpriv->iobase_a + AMCC_OP_REG_INTCSR); + /* allow INT in AMCC */ return 0; } @@ -1845,31 +2102,52 @@ static int pci9118_reset(struct comedi_device *dev) devpriv->IntControlReg = 0; devpriv->exttrg_users = 0; inl(dev->iobase + PCI9118_INTCTRL); - outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL); /* disable interrupts source */ + outl(devpriv->IntControlReg, dev->iobase + PCI9118_INTCTRL); + /* disable interrupts source */ outl(0x30, dev->iobase + PCI9118_CNTCTRL); /* outl(0xb4, dev->iobase + PCI9118_CNTCTRL); */ - start_pacer(dev, 0, 0, 0); /* stop 8254 counters */ + start_pacer(dev, 0, 0, 0); /* stop 8254 counters */ devpriv->AdControlReg = 0; - outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); /* bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable INT and DMA */ + outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); + /* + * bipolar, S.E., use 8254, + * stop 8354, internal trigger, + * soft trigger, + * disable INT and DMA + */ outl(0, dev->iobase + PCI9118_BURST); outl(1, dev->iobase + PCI9118_SCANMOD); - outl(2, dev->iobase + PCI9118_SCANMOD); /* reset scan queue */ + outl(2, dev->iobase + PCI9118_SCANMOD); /* reset scan queue */ devpriv->AdFunctionReg = AdFunction_PDTrg | AdFunction_PETrg; - outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); /* positive triggers, no S&H, no burst, burst stop, no post trigger, no about trigger, trigger stop */ + outl(devpriv->AdFunctionReg, dev->iobase + PCI9118_ADFUNC); + /* + * positive triggers, no S&H, + * no burst, burst stop, + * no post trigger, + * no about trigger, + * trigger stop + */ devpriv->ao_data[0] = 2047; devpriv->ao_data[1] = 2047; - outl(devpriv->ao_data[0], dev->iobase + PCI9118_DA1); /* reset A/D outs to 0V */ + outl(devpriv->ao_data[0], dev->iobase + PCI9118_DA1); + /* reset A/D outs to 0V */ outl(devpriv->ao_data[1], dev->iobase + PCI9118_DA2); - outl(0, dev->iobase + PCI9118_DO); /* reset digi outs to L */ + outl(0, dev->iobase + PCI9118_DO); /* reset digi outs to L */ udelay(10); inl(dev->iobase + PCI9118_AD_DATA); - outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ - outl(0, dev->iobase + PCI9118_INTSRC); /* remove INT requests */ - inl(dev->iobase + PCI9118_ADSTAT); /* flush A/D status register */ - inl(dev->iobase + PCI9118_INTSRC); /* flush INT requests */ + outl(0, dev->iobase + PCI9118_DELFIFO); /* flush FIFO */ + outl(0, dev->iobase + PCI9118_INTSRC); /* remove INT requests */ + inl(dev->iobase + PCI9118_ADSTAT); /* flush A/D status register */ + inl(dev->iobase + PCI9118_INTSRC); /* flush INT requests */ devpriv->AdControlReg = 0; - outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); /* bipolar, S.E., use 8254, stop 8354, internal trigger, soft trigger, disable INT and DMA */ + outl(devpriv->AdControlReg, dev->iobase + PCI9118_ADCNTRL); + /* + * bipolar, S.E., use 8254, + * stop 8354, internal trigger, + * soft trigger, + * disable INT and DMA + */ devpriv->cnt0_users = 0; devpriv->exttrg_users = 0; @@ -1899,7 +2177,7 @@ static int pci9118_attach(struct comedi_device *dev, opt_bus = it->options[0]; opt_slot = it->options[1]; if (it->options[3] & 1) { - master = 0; /* user don't want use bus master */ + master = 0; /* user don't want use bus master */ } else { master = 1; } @@ -1937,17 +2215,17 @@ static int pci9118_attach(struct comedi_device *dev, if (!pcidev) { if (opt_bus || opt_slot) { - printk(" - Card at b:s %d:%d %s\n", + printk(KERN_ERR " - Card at b:s %d:%d %s\n", opt_bus, opt_slot, errstr); } else { - printk(" - Card %s\n", errstr); + printk(KERN_ERR " - Card %s\n", errstr); } return -EIO; } - if (master) { + if (master) pci_set_master(pcidev); - } + pci_bus = pcidev->bus->number; pci_slot = PCI_SLOT(pcidev->devfn); @@ -1956,8 +2234,8 @@ static int pci9118_attach(struct comedi_device *dev, iobase_a = pci_resource_start(pcidev, 0); iobase_9 = pci_resource_start(pcidev, 2); - printk(", b:s:f=%d:%d:%d, io=0x%4lx, 0x%4lx", pci_bus, pci_slot, - pci_func, iobase_9, iobase_a); + printk(KERN_ERR ", b:s:f=%d:%d:%d, io=0x%4lx, 0x%4lx", pci_bus, + pci_slot, pci_func, iobase_9, iobase_a); dev->iobase = iobase_9; dev->board_name = this_board->name; @@ -1968,7 +2246,7 @@ static int pci9118_attach(struct comedi_device *dev, pci9118_reset(dev); if (it->options[3] & 2) - irq = 0; /* user don't want use IRQ */ + irq = 0; /* user don't want use IRQ */ if (irq > 0) { if (request_irq(irq, interrupt_pci9118, IRQF_SHARED, "ADLink PCI-9118", dev)) { @@ -1984,7 +2262,7 @@ static int pci9118_attach(struct comedi_device *dev, dev->irq = irq; - if (master) { /* alloc DMA buffers */ + if (master) { /* alloc DMA buffers */ devpriv->dma_doublebuf = 0; for (i = 0; i < 2; i++) { for (pages = 4; pages >= 0; pages--) { @@ -2024,16 +2302,18 @@ static int pci9118_attach(struct comedi_device *dev, if (it->options[2] > 0) { devpriv->usemux = it->options[2]; if (devpriv->usemux > 256) - devpriv->usemux = 256; /* max 256 channels! */ + devpriv->usemux = 256; /* max 256 channels! */ if (it->options[4] > 0) if (devpriv->usemux > 128) { - devpriv->usemux = 128; /* max 128 channels with softare S&H! */ + devpriv->usemux = 128; + /* max 128 channels with softare S&H! */ } printk(", ext. mux %d channels", devpriv->usemux); } devpriv->softsshdelay = it->options[4]; - if (devpriv->softsshdelay < 0) { /* select sample&hold signal polarity */ + if (devpriv->softsshdelay < 0) { + /* select sample&hold signal polarity */ devpriv->softsshdelay = -devpriv->softsshdelay; devpriv->softsshsample = 0x80; devpriv->softsshhold = 0x00; @@ -2045,7 +2325,8 @@ static int pci9118_attach(struct comedi_device *dev, printk(".\n"); pci_read_config_word(devpriv->pcidev, PCI_COMMAND, &u16w); - pci_write_config_word(devpriv->pcidev, PCI_COMMAND, u16w | 64); /* Enable parity check for parity error */ + pci_write_config_word(devpriv->pcidev, PCI_COMMAND, u16w | 64); + /* Enable parity check for parity error */ ret = alloc_subdevices(dev, 4); if (ret < 0) @@ -2055,11 +2336,11 @@ static int pci9118_attach(struct comedi_device *dev, dev->read_subdev = s; s->type = COMEDI_SUBD_AI; s->subdev_flags = SDF_READABLE | SDF_COMMON | SDF_GROUND | SDF_DIFF; - if (devpriv->usemux) { + if (devpriv->usemux) s->n_chan = devpriv->usemux; - } else { + else s->n_chan = this_board->n_aichan; - } + s->maxdata = this_board->ai_maxdata; s->len_chanlist = this_board->n_aichanlist; s->range_table = this_board->rangelist_ai; @@ -2103,9 +2384,10 @@ static int pci9118_attach(struct comedi_device *dev, s->insn_bits = pci9118_insn_bits_do; devpriv->valid = 1; - devpriv->i8254_osc_base = 250; /* 250ns=4MHz */ - devpriv->ai_maskharderr = 0x10a; /* default measure crash condition */ - if (it->options[5]) /* disable some requested */ + devpriv->i8254_osc_base = 250; /* 250ns=4MHz */ + devpriv->ai_maskharderr = 0x10a; + /* default measure crash condition */ + if (it->options[5]) /* disable some requested */ devpriv->ai_maskharderr &= ~it->options[5]; switch (this_board->ai_maxdata) { @@ -2130,9 +2412,9 @@ static int pci9118_detach(struct comedi_device *dev) if (dev->irq) free_irq(dev->irq, dev); if (devpriv->pcidev) { - if (dev->iobase) { + if (dev->iobase) comedi_pci_disable(devpriv->pcidev); - } + pci_dev_put(devpriv->pcidev); } if (devpriv->dmabuf_virt[0]) diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c index 394d2ea19c2e..5c1ff779af2c 100644 --- a/drivers/staging/comedi/drivers/adv_pci1710.c +++ b/drivers/staging/comedi/drivers/adv_pci1710.c @@ -63,6 +63,8 @@ Configuration options: #define DPRINTK(fmt, args...) #endif +#define PCI_VENDOR_ID_ADVANTECH 0x13fe + /* hardware types of the cards */ #define TYPE_PCI171X 0 #define TYPE_PCI1713 2 @@ -657,9 +659,9 @@ static void interrupt_pci1710_every_sample(void *d) #endif ++s->async->cur_chan; - if (s->async->cur_chan >= devpriv->ai_n_chan) { + if (s->async->cur_chan >= devpriv->ai_n_chan) s->async->cur_chan = 0; - } + if (s->async->cur_chan == 0) { /* one scan done */ devpriv->ai_act_scan++; @@ -863,12 +865,12 @@ static int pci171x_ai_docmd_and_mode(int mode, struct comedi_device *dev, devpriv->ai_eos = 0; } - if ((devpriv->ai_scans == 0) || (devpriv->ai_scans == -1)) { + if ((devpriv->ai_scans == 0) || (devpriv->ai_scans == -1)) devpriv->neverending_ai = 1; - } /* well, user want neverending */ - else { + /* well, user want neverending */ + else devpriv->neverending_ai = 0; - } + switch (mode) { case 1: case 2: @@ -1109,11 +1111,11 @@ static int pci171x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ai_timer1 = 0; devpriv->ai_timer2 = 0; - if (cmd->stop_src == TRIG_COUNT) { + if (cmd->stop_src == TRIG_COUNT) devpriv->ai_scans = cmd->stop_arg; - } else { + else devpriv->ai_scans = 0; - } + if (cmd->scan_begin_src == TRIG_FOLLOW) { /* mode 1, 2, 3 */ if (cmd->convert_src == TRIG_TIMER) { /* mode 1 and 2 */ @@ -1593,9 +1595,9 @@ static int pci1710_detach(struct comedi_device *dev) if (dev->irq) free_irq(dev->irq, dev); if (devpriv->pcidev) { - if (dev->iobase) { + if (dev->iobase) comedi_pci_disable(devpriv->pcidev); - } + pci_dev_put(devpriv->pcidev); } } diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index 6b0b7eda3be8..9fe8fcc7f1d6 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -52,7 +52,7 @@ TODO: #include "comedi_pci.h" -#define ADVANTECH_VENDOR 0x13fe /* Advantech PCI vendor ID */ +#define PCI_VENDOR_ID_ADVANTECH 0x13fe /* Advantech PCI vendor ID */ /* hardware types of the cards */ #define TYPE_PCI1723 0 @@ -60,35 +60,57 @@ TODO: #define IORANGE_1723 0x2A /* all the registers for the pci1723 board */ -#define PCI1723_DA(N) ((N)<<1) /* W: D/A register N (0 to 7) */ - -#define PCI1723_SYN_SET 0x12 /*synchronized set register */ -#define PCI1723_ALL_CHNNELE_SYN_STROBE 0x12 /*synchronized status register */ - -#define PCI1723_RANGE_CALIBRATION_MODE 0x14 /* range and calibration mode */ -#define PCI1723_RANGE_CALIBRATION_STATUS 0x14 /* range and calibration status */ - -#define PCI1723_CONTROL_CMD_CALIBRATION_FUN 0x16 /* SADC control command for calibration function */ -#define PCI1723_STATUS_CMD_CALIBRATION_FUN 0x16 /* SADC control status for calibration function */ - -#define PCI1723_CALIBRATION_PARA_STROBE 0x18 /* Calibration parameter strobe */ +#define PCI1723_DA(N) ((N)<<1) /* W: D/A register N (0 to 7) */ + +#define PCI1723_SYN_SET 0x12 /* synchronized set register */ +#define PCI1723_ALL_CHNNELE_SYN_STROBE 0x12 + /* synchronized status register */ + +#define PCI1723_RANGE_CALIBRATION_MODE 0x14 + /* range and calibration mode */ +#define PCI1723_RANGE_CALIBRATION_STATUS 0x14 + /* range and calibration status */ + +#define PCI1723_CONTROL_CMD_CALIBRATION_FUN 0x16 + /* + * SADC control command for + * calibration function + */ +#define PCI1723_STATUS_CMD_CALIBRATION_FUN 0x16 + /* + * SADC control status for + * calibration function + */ + +#define PCI1723_CALIBRATION_PARA_STROBE 0x18 + /* Calibration parameter strobe */ #define PCI1723_DIGITAL_IO_PORT_SET 0x1A /* Digital I/O port setting */ #define PCI1723_DIGITAL_IO_PORT_MODE 0x1A /* Digital I/O port mode */ -#define PCI1723_WRITE_DIGITAL_OUTPUT_CMD 0x1C /* Write digital output command */ +#define PCI1723_WRITE_DIGITAL_OUTPUT_CMD 0x1C + /* Write digital output command */ #define PCI1723_READ_DIGITAL_INPUT_DATA 0x1C /* Read digital input data */ -#define PCI1723_WRITE_CAL_CMD 0x1E /* Write calibration command */ -#define PCI1723_READ_CAL_STATUS 0x1E /* Read calibration status */ +#define PCI1723_WRITE_CAL_CMD 0x1E /* Write calibration command */ +#define PCI1723_READ_CAL_STATUS 0x1E /* Read calibration status */ -#define PCI1723_SYN_STROBE 0x20 /* Synchronized strobe */ +#define PCI1723_SYN_STROBE 0x20 /* Synchronized strobe */ -#define PCI1723_RESET_ALL_CHN_STROBE 0x22 /* Reset all D/A channels strobe */ +#define PCI1723_RESET_ALL_CHN_STROBE 0x22 + /* Reset all D/A channels strobe */ -#define PCI1723_RESET_CAL_CONTROL_STROBE 0x24 /* Reset the calibration controller strobe */ +#define PCI1723_RESET_CAL_CONTROL_STROBE 0x24 + /* + * Reset the calibration + * controller strobe + */ -#define PCI1723_CHANGE_CHA_OUTPUT_TYPE_STROBE 0x26 /* Change D/A channels output type strobe */ +#define PCI1723_CHANGE_CHA_OUTPUT_TYPE_STROBE 0x26 + /* + * Change D/A channels output + * type strobe + */ #define PCI1723_SELECT_CALIBRATION 0x28 /* Select the calibration Ref_V */ @@ -104,20 +126,20 @@ static const struct comedi_lrange range_pci1723 = { 1, { */ struct pci1723_board { const char *name; - int vendor_id; /* PCI vendor a device ID of card */ + int vendor_id; /* PCI vendor a device ID of card */ int device_id; int iorange; char cardtype; - int n_aochan; /* num of D/A chans */ - int n_diochan; /* num of DIO chans */ - int ao_maxdata; /* resolution of D/A */ - const struct comedi_lrange *rangelist_ao; /* rangelist for D/A */ + int n_aochan; /* num of D/A chans */ + int n_diochan; /* num of DIO chans */ + int ao_maxdata; /* resolution of D/A */ + const struct comedi_lrange *rangelist_ao; /* rangelist for D/A */ }; static const struct pci1723_board boardtypes[] = { { .name = "pci1723", - .vendor_id = ADVANTECH_VENDOR, + .vendor_id = PCI_VENDOR_ID_ADVANTECH, .device_id = 0x1723, .iorange = IORANGE_1723, .cardtype = TYPE_PCI1723, @@ -128,8 +150,10 @@ static const struct pci1723_board boardtypes[] = { }, }; -/* This is used by modprobe to translate PCI IDs to drivers. Should - * only be used for PCI and ISA-PnP devices */ +/* + * This is used by modprobe to translate PCI IDs to drivers. + * Should only be used for PCI and ISA-PnP devices + */ static DEFINE_PCI_DEVICE_TABLE(pci1723_pci_table) = { { PCI_VENDOR_ID_ADVANTECH, 0x1723, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { @@ -157,47 +181,47 @@ static struct comedi_driver driver_pci1723 = { .detach = pci1723_detach, }; -/* this structure is for data unique to this hardware driver. */ +/* This structure is for data unique to this hardware driver. */ struct pci1723_private { int valid; /* card is usable; */ struct pci_dev *pcidev; - unsigned char da_range[8]; /* D/A output range for each channel */ + unsigned char da_range[8]; /* D/A output range for each channel */ - short ao_data[8]; /* data output buffer */ + short ao_data[8]; /* data output buffer */ }; -/*the following macro to make it easy to -* access the private structure. -*/ +/* The following macro to make it easy to access the private structure. */ #define devpriv ((struct pci1723_private *)dev->private) #define this_board boardtypes /* - * the pci1723 card reset; + * The pci1723 card reset; */ static int pci1723_reset(struct comedi_device *dev) { int i; DPRINTK("adv_pci1723 EDBG: BGN: pci1723_reset(...)\n"); - outw(0x01, dev->iobase + PCI1723_SYN_SET); /* set synchronous output mode */ + outw(0x01, dev->iobase + PCI1723_SYN_SET); + /* set synchronous output mode */ for (i = 0; i < 8; i++) { - /* set all outputs to 0V */ + /* set all outputs to 0V */ devpriv->ao_data[i] = 0x8000; outw(devpriv->ao_data[i], dev->iobase + PCI1723_DA(i)); - /* set all ranges to +/- 10V */ + /* set all ranges to +/- 10V */ devpriv->da_range[i] = 0; outw(((devpriv->da_range[i] << 4) | i), PCI1723_RANGE_CALIBRATION_MODE); } - outw(0, dev->iobase + PCI1723_CHANGE_CHA_OUTPUT_TYPE_STROBE); /* update ranges */ - outw(0, dev->iobase + PCI1723_SYN_STROBE); /* update outputs */ + outw(0, dev->iobase + PCI1723_CHANGE_CHA_OUTPUT_TYPE_STROBE); + /* update ranges */ + outw(0, dev->iobase + PCI1723_SYN_STROBE); /* update outputs */ - /* set asynchronous output mode */ + /* set asynchronous output mode */ outw(0, dev->iobase + PCI1723_SYN_SET); DPRINTK("adv_pci1723 EDBG: END: pci1723_reset(...)\n"); @@ -251,11 +275,11 @@ static int pci1723_dio_insn_config(struct comedi_device *dev, unsigned short dio_mode; mask = 1 << CR_CHAN(insn->chanspec); - if (mask & 0x00FF) { + if (mask & 0x00FF) bits = 0x00FF; - } else { + else bits = 0xFF00; - } + switch (data[0]) { case INSN_CONFIG_DIO_INPUT: s->io_bits &= ~bits; @@ -270,12 +294,12 @@ static int pci1723_dio_insn_config(struct comedi_device *dev, return -EINVAL; } - /* update hardware DIO mode */ - dio_mode = 0x0000; /* low byte output, high byte output */ + /* update hardware DIO mode */ + dio_mode = 0x0000; /* low byte output, high byte output */ if ((s->io_bits & 0x00FF) == 0) - dio_mode |= 0x0001; /* low byte input */ + dio_mode |= 0x0001; /* low byte input */ if ((s->io_bits & 0xFF00) == 0) - dio_mode |= 0x0002; /* high byte input */ + dio_mode |= 0x0002; /* high byte input */ outw(dio_mode, dev->iobase + PCI1723_DIGITAL_IO_PORT_SET); return 1; } @@ -311,7 +335,8 @@ static int pci1723_attach(struct comedi_device *dev, int opt_bus, opt_slot; const char *errstr; - printk("comedi%d: adv_pci1723: board=%s", dev->minor, this_board->name); + printk(KERN_ERR "comedi%d: adv_pci1723: board=%s", + dev->minor, this_board->name); opt_bus = it->options[0]; opt_slot = it->options[1]; @@ -349,10 +374,10 @@ static int pci1723_attach(struct comedi_device *dev, if (!pcidev) { if (opt_bus || opt_slot) { - printk(" - Card at b:s %d:%d %s\n", - opt_bus, opt_slot, errstr); + printk(KERN_ERR " - Card at b:s %d:%d %s\n", + opt_bus, opt_slot, errstr); } else { - printk(" - Card %s\n", errstr); + printk(KERN_ERR " - Card %s\n", errstr); } return -EIO; } @@ -362,8 +387,8 @@ static int pci1723_attach(struct comedi_device *dev, pci_func = PCI_FUNC(pcidev->devfn); iobase = pci_resource_start(pcidev, 2); - printk(", b:s:f=%d:%d:%d, io=0x%4x", pci_bus, pci_slot, pci_func, - iobase); + printk(KERN_ERR ", b:s:f=%d:%d:%d, io=0x%4x", + pci_bus, pci_slot, pci_func, iobase); dev->iobase = iobase; @@ -398,22 +423,23 @@ static int pci1723_attach(struct comedi_device *dev, s->insn_write = pci1723_ao_write_winsn; s->insn_read = pci1723_insn_read_ao; - /* read DIO config */ - switch (inw(dev->iobase + PCI1723_DIGITAL_IO_PORT_MODE) & 0x03) { - case 0x00: /* low byte output, high byte output */ + /* read DIO config */ + switch (inw(dev->iobase + PCI1723_DIGITAL_IO_PORT_MODE) + & 0x03) { + case 0x00: /* low byte output, high byte output */ s->io_bits = 0xFFFF; break; - case 0x01: /* low byte input, high byte output */ + case 0x01: /* low byte input, high byte output */ s->io_bits = 0xFF00; break; - case 0x02: /* low byte output, high byte input */ + case 0x02: /* low byte output, high byte input */ s->io_bits = 0x00FF; break; - case 0x03: /* low byte input, high byte input */ + case 0x03: /* low byte input, high byte input */ s->io_bits = 0x0000; break; } - /* read DIO port state */ + /* read DIO port state */ s->state = inw(dev->iobase + PCI1723_READ_DIGITAL_INPUT_DATA); subdev++; @@ -450,16 +476,15 @@ static int pci1723_attach(struct comedi_device *dev, */ static int pci1723_detach(struct comedi_device *dev) { - printk("comedi%d: pci1723: remove\n", dev->minor); + printk(KERN_ERR "comedi%d: pci1723: remove\n", dev->minor); if (dev->private) { if (devpriv->valid) pci1723_reset(dev); if (devpriv->pcidev) { - if (dev->iobase) { + if (dev->iobase) comedi_pci_disable(devpriv->pcidev); - } pci_dev_put(devpriv->pcidev); } } diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index 61d35fe64350..40eeecf5347f 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -45,6 +45,8 @@ Configuration options: #define DPRINTK(fmt, args...) #endif +#define PCI_VENDOR_ID_ADVANTECH 0x13fe + /* hardware types of the cards */ enum hw_cards_id { TYPE_PCI1730, TYPE_PCI1733, TYPE_PCI1734, TYPE_PCI1736, @@ -367,9 +369,9 @@ static int pci_dio_insn_bits_di_b(struct comedi_device *dev, int i; data[1] = 0; - for (i = 0; i < d->regs; i++) { + for (i = 0; i < d->regs; i++) data[1] |= inb(dev->iobase + d->addr + i) << (8 * i); - } + return 2; } @@ -882,9 +884,9 @@ static int CheckAndAllocCard(struct comedi_device *dev, struct pci_dio_private *pr, *prev; for (pr = pci_priv, prev = NULL; pr != NULL; prev = pr, pr = pr->next) { - if (pr->pcidev == pcidev) { + if (pr->pcidev == pcidev) return 0; /* this card is used, look for another */ - } + } if (prev) { @@ -1040,22 +1042,22 @@ static int pci_dio_detach(struct comedi_device *dev) int subdev; if (dev->private) { - if (devpriv->valid) { + if (devpriv->valid) pci_dio_reset(dev); - } + /* This shows the silliness of using this kind of * scheme for numbering subdevices. Don't do it. --ds */ subdev = 0; for (i = 0; i < MAX_DI_SUBDEVS; i++) { - if (this_board->sdi[i].chans) { + if (this_board->sdi[i].chans) subdev++; - } + } for (i = 0; i < MAX_DO_SUBDEVS; i++) { - if (this_board->sdo[i].chans) { + if (this_board->sdo[i].chans) subdev++; - } + } for (i = 0; i < MAX_DIO_SUBDEVG; i++) { for (j = 0; j < this_board->sdio[i].regs; j++) { @@ -1071,20 +1073,20 @@ static int pci_dio_detach(struct comedi_device *dev) } if (devpriv->pcidev) { - if (dev->iobase) { + if (dev->iobase) comedi_pci_disable(devpriv->pcidev); - } + pci_dev_put(devpriv->pcidev); } - if (devpriv->prev) { + if (devpriv->prev) devpriv->prev->next = devpriv->next; - } else { + else pci_priv = devpriv->next; - } - if (devpriv->next) { + + if (devpriv->next) devpriv->next->prev = devpriv->prev; - } + } return 0; diff --git a/drivers/staging/comedi/drivers/aio_aio12_8.c b/drivers/staging/comedi/drivers/aio_aio12_8.c index c4cac66db12e..7a1c636df5be 100644 --- a/drivers/staging/comedi/drivers/aio_aio12_8.c +++ b/drivers/staging/comedi/drivers/aio_aio12_8.c @@ -110,7 +110,7 @@ static int aio_aio12_8_ai_read(struct comedi_device *dev, while (timeout && !(inb(dev->iobase + AIO12_8_STATUS) & STATUS_ADC_EOC)) { timeout--; - printk("timeout %d\n", timeout); + printk(KERN_ERR "timeout %d\n", timeout); udelay(1); } if (timeout == 0) { @@ -172,7 +172,7 @@ static int aio_aio12_8_attach(struct comedi_device *dev, iobase = it->options[0]; if (!request_region(iobase, 24, "aio_aio12_8")) { - printk("I/O port conflict"); + printk(KERN_ERR "I/O port conflict"); return -EIO; } diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c index 92bcc205dd4b..6a87652e7e2a 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.c +++ b/drivers/staging/comedi/drivers/amplc_dio200.c @@ -218,7 +218,7 @@ order they appear in the channel list. #define DIO200_DRIVER_NAME "amplc_dio200" /* PCI IDs */ -/* #define PCI_VENDOR_ID_AMPLICON 0x14dc */ +#define PCI_VENDOR_ID_AMPLICON 0x14dc #define PCI_DEVICE_ID_AMPLICON_PCI272 0x000a #define PCI_DEVICE_ID_AMPLICON_PCI215 0x000b #define PCI_DEVICE_ID_INVALID 0xffff diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index c54cca8b2565..c486a878e180 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -118,7 +118,7 @@ Caveats: /* * PCI IDs. */ -/* #define PCI_VENDOR_ID_AMPLICON 0x14dc */ +#define PCI_VENDOR_ID_AMPLICON 0x14dc #define PCI_DEVICE_ID_AMPLICON_PCI224 0x0007 #define PCI_DEVICE_ID_AMPLICON_PCI234 0x0008 #define PCI_DEVICE_ID_INVALID 0xffff @@ -496,9 +496,9 @@ pci224_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, /* Writing a list of values to an AO channel is probably not * very useful, but that's how the interface is defined. */ - for (i = 0; i < insn->n; i++) { + for (i = 0; i < insn->n; i++) pci224_ao_set_data(dev, chan, range, data[i]); - } + return i; } @@ -519,9 +519,9 @@ pci224_ao_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, chan = CR_CHAN(insn->chanspec); - for (i = 0; i < insn->n; i++) { + for (i = 0; i < insn->n; i++) data[i] = devpriv->ao_readback[chan]; - } + return i; } @@ -544,9 +544,9 @@ static void pci224_ao_stop(struct comedi_device *dev, { unsigned long flags; - if (!test_and_clear_bit(AO_CMD_STARTED, &devpriv->state)) { + if (!test_and_clear_bit(AO_CMD_STARTED, &devpriv->state)) return; - } + spin_lock_irqsave(&devpriv->ao_spinlock, flags); /* Kill the interrupts. */ @@ -597,11 +597,11 @@ static void pci224_ao_start(struct comedi_device *dev, } else { /* Enable interrupts. */ spin_lock_irqsave(&devpriv->ao_spinlock, flags); - if (cmd->stop_src == TRIG_EXT) { + if (cmd->stop_src == TRIG_EXT) devpriv->intsce = PCI224_INTR_EXT | PCI224_INTR_DAC; - } else { + else devpriv->intsce = PCI224_INTR_DAC; - } + outb(devpriv->intsce, devpriv->iobase1 + PCI224_INT_SCE); spin_unlock_irqrestore(&devpriv->ao_spinlock, flags); } @@ -630,9 +630,9 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, num_scans = comedi_buf_read_n_available(s->async) / bytes_per_scan; if (!devpriv->ao_stop_continuous) { /* Fixed number of scans. */ - if (num_scans > devpriv->ao_stop_count) { + if (num_scans > devpriv->ao_stop_count) num_scans = devpriv->ao_stop_count; - } + } /* Determine how much room is in the FIFO (in samples). */ @@ -669,13 +669,13 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, } } /* Determine how many new scans can be put in the FIFO. */ - if (cmd->chanlist_len) { + if (cmd->chanlist_len) room /= cmd->chanlist_len; - } + /* Determine how many scans to process. */ - if (num_scans > room) { + if (num_scans > room) num_scans = room; - } + /* Process scans. */ for (n = 0; n < num_scans; n++) { cfc_read_array_from_buffer(s, &devpriv->ao_scan_vals[0], @@ -718,19 +718,19 @@ static void pci224_ao_handle_fifo(struct comedi_device *dev, trig = PCI224_DACCON_TRIG_Z2CT0; } else { /* cmd->scan_begin_src == TRIG_EXT */ - if (cmd->scan_begin_arg & CR_INVERT) { + if (cmd->scan_begin_arg & CR_INVERT) trig = PCI224_DACCON_TRIG_EXTN; - } else { + else trig = PCI224_DACCON_TRIG_EXTP; - } + } devpriv->daccon = COMBINE(devpriv->daccon, trig, PCI224_DACCON_TRIG_MASK); outw(devpriv->daccon, dev->iobase + PCI224_DACCON); } - if (s->async->events) { + if (s->async->events) comedi_event(dev, s); - } + } /* @@ -855,9 +855,9 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, err++; } tmp = cmd->chanlist_len * CONVERT_PERIOD; - if (tmp < MIN_SCAN_PERIOD) { + if (tmp < MIN_SCAN_PERIOD) tmp = MIN_SCAN_PERIOD; - } + if (cmd->scan_begin_arg < tmp) { cmd->scan_begin_arg = tmp; err++; @@ -966,9 +966,9 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, devpriv->cached_div1 = div1; devpriv->cached_div2 = div2; } - if (tmp != cmd->scan_begin_arg) { + if (tmp != cmd->scan_begin_arg) err++; - } + } if (err) @@ -994,13 +994,13 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, tmp = 0; for (n = 0; n < cmd->chanlist_len; n++) { ch = CR_CHAN(cmd->chanlist[n]); - if (tmp & (1U << ch)) { + if (tmp & (1U << ch)) errors |= dupchan_err; - } + tmp |= (1U << ch); - if (CR_RANGE(cmd->chanlist[n]) != range) { + if (CR_RANGE(cmd->chanlist[n]) != range) errors |= range_err; - } + } if (errors) { if (errors & dupchan_err) { @@ -1038,9 +1038,9 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) unsigned long flags; /* Cannot handle null/empty chanlist. */ - if (cmd->chanlist == NULL || cmd->chanlist_len == 0) { + if (cmd->chanlist == NULL || cmd->chanlist_len == 0) return -EINVAL; - } + /* Determine which channels are enabled and their load order. */ devpriv->ao_enab = 0; @@ -1050,9 +1050,9 @@ static int pci224_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) devpriv->ao_enab |= 1U << ch; rank = 0; for (j = 0; j < cmd->chanlist_len; j++) { - if (CR_CHAN(cmd->chanlist[j]) < ch) { + if (CR_CHAN(cmd->chanlist[j]) < ch) rank++; - } + } devpriv->ao_scan_order[rank] = i; } @@ -1221,9 +1221,9 @@ pci224_ao_munge(struct comedi_device *dev, struct comedi_subdevice *s, offset = 32768; } /* Munge the data. */ - for (i = 0; i < length; i++) { + for (i = 0; i < length; i++) array[i] = (array[i] << shift) - offset; - } + } /* @@ -1254,15 +1254,15 @@ static irqreturn_t pci224_interrupt(int irq, void *d) cmd = &s->async->cmd; if (valid_intstat & PCI224_INTR_EXT) { devpriv->intsce &= ~PCI224_INTR_EXT; - if (cmd->start_src == TRIG_EXT) { + if (cmd->start_src == TRIG_EXT) pci224_ao_start(dev, s); - } else if (cmd->stop_src == TRIG_EXT) { + else if (cmd->stop_src == TRIG_EXT) pci224_ao_stop(dev, s); - } + } - if (valid_intstat & PCI224_INTR_DAC) { + if (valid_intstat & PCI224_INTR_DAC) pci224_ao_handle_fifo(dev, s); - } + } /* Reenable interrupt sources. */ spin_lock_irqsave(&devpriv->ao_spinlock, flags); @@ -1381,23 +1381,23 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* Allocate readback buffer for AO channels. */ devpriv->ao_readback = kmalloc(sizeof(devpriv->ao_readback[0]) * thisboard->ao_chans, GFP_KERNEL); - if (!devpriv->ao_readback) { + if (!devpriv->ao_readback) return -ENOMEM; - } + /* Allocate buffer to hold values for AO channel scan. */ devpriv->ao_scan_vals = kmalloc(sizeof(devpriv->ao_scan_vals[0]) * thisboard->ao_chans, GFP_KERNEL); - if (!devpriv->ao_scan_vals) { + if (!devpriv->ao_scan_vals) return -ENOMEM; - } + /* Allocate buffer to hold AO channel scan order. */ devpriv->ao_scan_order = kmalloc(sizeof(devpriv->ao_scan_order[0]) * thisboard->ao_chans, GFP_KERNEL); - if (!devpriv->ao_scan_order) { + if (!devpriv->ao_scan_order) return -ENOMEM; - } + /* Disable interrupt sources. */ devpriv->intsce = 0; @@ -1445,9 +1445,9 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->range_table_list = range_table_list = kmalloc(sizeof(struct comedi_lrange *) * s->n_chan, GFP_KERNEL); - if (!s->range_table_list) { + if (!s->range_table_list) return -ENOMEM; - } + for (n = 2; n < 3 + s->n_chan; n++) { if (it->options[n] < 0 || it->options[n] > 1) { printk(KERN_WARNING "comedi%d: %s: warning! " @@ -1459,11 +1459,11 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it) for (n = 0; n < s->n_chan; n++) { if (n < COMEDI_NDEVCONFOPTS - 3 && it->options[3 + n] == 1) { - if (it->options[2] == 1) { + if (it->options[2] == 1) range_table_list[n] = &range_pci234_ext; - } else { + else range_table_list[n] = &range_bipolar5; - } + } else { if (it->options[2] == 1) { range_table_list[n] = @@ -1506,11 +1506,11 @@ static int pci224_attach(struct comedi_device *dev, struct comedi_devconfig *it) printk(KERN_INFO "comedi%d: %s ", dev->minor, dev->board_name); printk("(pci %s) ", pci_name(pci_dev)); - if (irq) { + if (irq) printk("(irq %u%s) ", irq, (dev->irq ? "" : " UNAVAILABLE")); - } else { + else printk("(no irq) "); - } + printk("attached\n"); @@ -1529,9 +1529,9 @@ static int pci224_detach(struct comedi_device *dev) { printk(KERN_DEBUG "comedi%d: %s: detach\n", dev->minor, DRIVER_NAME); - if (dev->irq) { + if (dev->irq) free_irq(dev->irq, dev); - } + if (dev->subdevices) { struct comedi_subdevice *s; @@ -1544,9 +1544,9 @@ static int pci224_detach(struct comedi_device *dev) kfree(devpriv->ao_scan_vals); kfree(devpriv->ao_scan_order); if (devpriv->pci_dev) { - if (dev->iobase) { + if (dev->iobase) comedi_pci_disable(devpriv->pci_dev); - } + pci_dev_put(devpriv->pci_dev); } } diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 091a1a5822a8..7fffd967d47e 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -669,9 +669,9 @@ static short pci230_ai_read(struct comedi_device *dev) /* If a bipolar range was specified, mangle it (twos * complement->straight binary). */ - if (devpriv->ai_bipolar) { + if (devpriv->ai_bipolar) data ^= 1 << (thisboard->ai_bits - 1); - } + return data; } @@ -680,9 +680,9 @@ static inline unsigned short pci230_ao_mangle_datum(struct comedi_device *dev, { /* If a bipolar range was specified, mangle it (straight binary->twos * complement). */ - if (devpriv->ao_bipolar) { + if (devpriv->ao_bipolar) datum ^= 1 << (thisboard->ao_bits - 1); - } + /* PCI230 is 12 bit - stored in upper bits of 16 bit register (lower * four bits reserved for expansion). */ @@ -734,9 +734,9 @@ static int pci230_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* Allocate the private structure area using alloc_private(). * Macro defined in comedidev.h - memsets struct fields to 0. */ - if ((alloc_private(dev, sizeof(struct pci230_private))) < 0) { + if ((alloc_private(dev, sizeof(struct pci230_private))) < 0) return -ENOMEM; - } + spin_lock_init(&devpriv->isr_spinlock); spin_lock_init(&devpriv->res_spinlock); spin_lock_init(&devpriv->ai_stop_spinlock); @@ -991,9 +991,9 @@ static int pci230_detach(struct comedi_device *dev) if (devpriv) { if (devpriv->pci_dev) { - if (dev->iobase) { + if (dev->iobase) comedi_pci_disable(devpriv->pci_dev); - } + pci_dev_put(devpriv->pci_dev); } } @@ -1055,9 +1055,9 @@ static void put_resources(struct comedi_device *dev, unsigned int res_mask, && (res_mask != 0); b <<= 1, i++) { if ((res_mask & b) != 0) { res_mask &= ~b; - if (devpriv->res_owner[i] == owner) { + if (devpriv->res_owner[i] == owner) devpriv->res_owner[i] = OWNER_NONE; - } + } } spin_unlock_irqrestore(&devpriv->res_spinlock, irqflags); @@ -1132,11 +1132,11 @@ static int pci230_ai_rinsn(struct comedi_device *dev, } devpriv->adcg = (devpriv->adcg & ~(3 << gainshift)) | (pci230_ai_gain[range] << gainshift); - if (devpriv->ai_bipolar) { + if (devpriv->ai_bipolar) adccon |= PCI230_ADC_IR_BIP; - } else { + else adccon |= PCI230_ADC_IR_UNI; - } + /* Enable only this channel in the scan list - otherwise by default * we'll get one sample from each channel. */ @@ -1408,13 +1408,13 @@ static int pci230_ao_cmdtest(struct comedi_device *dev, chan = CR_CHAN(cmd->chanlist[n]); range = CR_RANGE(cmd->chanlist[n]); /* Channel numbers must strictly increase. */ - if (chan < prev_chan) { + if (chan < prev_chan) errors |= seq_err; - } + /* Ranges must be the same. */ - if (range != first_range) { + if (range != first_range) errors |= range_err; - } + prev_chan = chan; } if (errors != 0) { @@ -1583,9 +1583,9 @@ static int pci230_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (cmd->scan_begin_src == TRIG_TIMER) { /* Claim Z2-CT1. */ - if (!get_one_resource(dev, RES_Z2CT1, OWNER_AOCMD)) { + if (!get_one_resource(dev, RES_Z2CT1, OWNER_AOCMD)) return -EBUSY; - } + } /* Get number of scans required. */ @@ -1609,9 +1609,9 @@ static int pci230_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) unsigned int i; dacen = 0; - for (i = 0; i < cmd->chanlist_len; i++) { + for (i = 0; i < cmd->chanlist_len; i++) dacen |= 1 << CR_CHAN(cmd->chanlist[i]); - } + /* Set channel scan list. */ outw(dacen, dev->iobase + PCI230P2_DACEN); /* @@ -1656,9 +1656,9 @@ static int pci230_ai_check_scan_period(struct comedi_cmd *cmd) int err = 0; chanlist_len = cmd->chanlist_len; - if (cmd->chanlist_len == 0) { + if (cmd->chanlist_len == 0) chanlist_len = 1; - } + min_scan_period = chanlist_len * cmd->convert_arg; if ((min_scan_period < chanlist_len) || (min_scan_period < cmd->convert_arg)) { @@ -1777,11 +1777,11 @@ static int pci230_ai_cmdtest(struct comedi_device *dev, * single-ended or pseudo-differential. */ if (cmd->chanlist && (cmd->chanlist_len > 0)) { /* Peek analogue reference of first channel. */ - if (CR_AREF(cmd->chanlist[0]) == AREF_DIFF) { + if (CR_AREF(cmd->chanlist[0]) == AREF_DIFF) max_speed_ai = MAX_SPEED_AI_DIFF; - } else { + else max_speed_ai = MAX_SPEED_AI_SE; - } + } else { /* No channel list. Assume single-ended. */ max_speed_ai = MAX_SPEED_AI_SE; @@ -1871,9 +1871,9 @@ static int pci230_ai_cmdtest(struct comedi_device *dev, } } else if (cmd->scan_begin_src == TRIG_TIMER) { /* N.B. cmd->convert_arg is also TRIG_TIMER */ - if (!pci230_ai_check_scan_period(cmd)) { + if (!pci230_ai_check_scan_period(cmd)) err++; - } + } else { if (cmd->scan_begin_arg != 0) { cmd->scan_begin_arg = 0; @@ -1961,13 +1961,13 @@ static int pci230_ai_cmdtest(struct comedi_device *dev, errors |= seq_err; } /* Channels must have same AREF. */ - if (aref != prev_aref) { + if (aref != prev_aref) errors |= aref_err; - } + /* Channel ranges must have same polarity. */ - if (polarity != prev_polarity) { + if (polarity != prev_polarity) errors |= polarity_err; - } + /* Single-ended channel pairs must have same * range. */ if ((aref != AREF_DIFF) @@ -1987,9 +1987,9 @@ static int pci230_ai_cmdtest(struct comedi_device *dev, } /* If channel list is a repeating subsequence, need a whole * number of repeats. */ - if ((n % subseq_len) != 0) { + if ((n % subseq_len) != 0) errors |= seq_err; - } + if ((devpriv->hwver > 0) && (devpriv->hwver < 4)) { /* * Buggy PCI230+ or PCI260+ requires channel 0 to be @@ -2228,9 +2228,9 @@ static void pci230_ai_start(struct comedi_device *dev, devpriv->adccon = (devpriv->adccon & ~PCI230_ADC_TRIG_MASK) | conv; outw(devpriv->adccon, dev->iobase + PCI230_ADCCON); - if (cmd->convert_src == TRIG_INT) { + if (cmd->convert_src == TRIG_INT) async->inttrig = pci230_ai_inttrig_convert; - } + /* Update FIFO interrupt trigger level, which is currently * set to "full". */ pci230_ai_update_fifo_trigger_level(dev, s); @@ -2345,9 +2345,9 @@ static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) } } /* Claim resources. */ - if (!get_resources(dev, res_mask, OWNER_AICMD)) { + if (!get_resources(dev, res_mask, OWNER_AICMD)) return -EBUSY; - } + /* Get number of scans required. */ if (cmd->stop_src == TRIG_COUNT) { @@ -2392,11 +2392,11 @@ static int pci230_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) range = CR_RANGE(cmd->chanlist[0]); devpriv->ai_bipolar = pci230_ai_bipolar[range]; - if (devpriv->ai_bipolar) { + if (devpriv->ai_bipolar) adccon |= PCI230_ADC_IR_BIP; - } else { + else adccon |= PCI230_ADC_IR_UNI; - } + for (i = 0; i < cmd->chanlist_len; i++) { unsigned int gainshift; @@ -2543,9 +2543,9 @@ static unsigned int pci230_choose_clk_count(uint64_t ns, unsigned int *count, for (clk_src = CLK_10MHZ;; clk_src++) { cnt = divide_ns(ns, pci230_timebase[clk_src], round_mode); - if ((cnt <= 65536) || (clk_src == CLK_1KHZ)) { + if ((cnt <= 65536) || (clk_src == CLK_1KHZ)) break; - } + } *count = cnt; return clk_src; @@ -2575,9 +2575,9 @@ static void pci230_ct_setup_ns_mode(struct comedi_device *dev, unsigned int ct, /* Program clock source. */ outb(CLK_CONFIG(ct, clk_src), devpriv->iobase1 + PCI230_ZCLK_SCE); /* Set initial count. */ - if (count >= 65536) { + if (count >= 65536) count = 0; - } + i8254_write(devpriv->iobase1 + PCI230_Z2_CT_BASE, 0, ct, count); } @@ -2599,9 +2599,9 @@ static irqreturn_t pci230_interrupt(int irq, void *d) /* Read interrupt status/enable register. */ status_int = inb(devpriv->iobase1 + PCI230_INT_STAT); - if (status_int == PCI230_INT_DISABLE) { + if (status_int == PCI230_INT_DISABLE) return IRQ_NONE; - } + spin_lock_irqsave(&devpriv->isr_spinlock, irqflags); valid_status_int = devpriv->int_en & status_int; @@ -2660,9 +2660,9 @@ static void pci230_handle_ao_nofifo(struct comedi_device *dev, struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; - if (!devpriv->ao_continuous && (devpriv->ao_scan_count == 0)) { + if (!devpriv->ao_continuous && (devpriv->ao_scan_count == 0)) return; - } + for (i = 0; i < cmd->chanlist_len; i++) { /* Read sample from Comedi's circular buffer. */ @@ -2711,9 +2711,9 @@ static int pci230_handle_ao_fifo(struct comedi_device *dev, num_scans = comedi_buf_read_n_available(async) / bytes_per_scan; if (!devpriv->ao_continuous) { /* Fixed number of scans. */ - if (num_scans > devpriv->ao_scan_count) { + if (num_scans > devpriv->ao_scan_count) num_scans = devpriv->ao_scan_count; - } + if (devpriv->ao_scan_count == 0) { /* End of acquisition. */ events |= COMEDI_CB_EOA; @@ -2736,21 +2736,21 @@ static int pci230_handle_ao_fifo(struct comedi_device *dev, } if (events == 0) { /* Determine how much room is in the FIFO (in samples). */ - if ((dacstat & PCI230P2_DAC_FIFO_FULL) != 0) { + if ((dacstat & PCI230P2_DAC_FIFO_FULL) != 0) room = PCI230P2_DAC_FIFOROOM_FULL; - } else if ((dacstat & PCI230P2_DAC_FIFO_HALF) != 0) { + else if ((dacstat & PCI230P2_DAC_FIFO_HALF) != 0) room = PCI230P2_DAC_FIFOROOM_HALFTOFULL; - } else if ((dacstat & PCI230P2_DAC_FIFO_EMPTY) != 0) { + else if ((dacstat & PCI230P2_DAC_FIFO_EMPTY) != 0) room = PCI230P2_DAC_FIFOROOM_EMPTY; - } else { + else room = PCI230P2_DAC_FIFOROOM_ONETOHALF; - } + /* Convert room to number of scans that can be added. */ room /= cmd->chanlist_len; /* Determine number of scans to process. */ - if (num_scans > room) { + if (num_scans > room) num_scans = room; - } + /* Process scans. */ for (n = 0; n < num_scans; n++) { for (i = 0; i < cmd->chanlist_len; i++) { @@ -2817,14 +2817,14 @@ static void pci230_handle_ai(struct comedi_device *dev, } else { todo = (devpriv->ai_scan_count * scanlen) - devpriv->ai_scan_pos; - if (todo > PCI230_ADC_FIFOLEVEL_HALFFULL) { + if (todo > PCI230_ADC_FIFOLEVEL_HALFFULL) todo = PCI230_ADC_FIFOLEVEL_HALFFULL; - } + } - if (todo == 0) { + if (todo == 0) return; - } + fifoamount = 0; for (i = 0; i < todo; i++) { @@ -2906,9 +2906,9 @@ static void pci230_ao_stop(struct comedi_device *dev, spin_lock_irqsave(&devpriv->ao_stop_spinlock, irqflags); started = test_and_clear_bit(AO_CMD_STARTED, &devpriv->state); spin_unlock_irqrestore(&devpriv->ao_stop_spinlock, irqflags); - if (!started) { + if (!started) return; - } + cmd = &s->async->cmd; if (cmd->scan_begin_src == TRIG_TIMER) { @@ -2968,9 +2968,9 @@ static void pci230_ai_stop(struct comedi_device *dev, spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags); started = test_and_clear_bit(AI_CMD_STARTED, &devpriv->state); spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, irqflags); - if (!started) { + if (!started) return; - } + cmd = &s->async->cmd; if (cmd->convert_src == TRIG_TIMER) { diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c index e0352c6cf82d..638e5cec897d 100644 --- a/drivers/staging/comedi/drivers/cb_das16_cs.c +++ b/drivers/staging/comedi/drivers/cb_das16_cs.c @@ -175,16 +175,16 @@ static int das16cs_attach(struct comedi_device *dev, printk("I/O base=0x%04lx ", dev->iobase); printk("fingerprint:\n"); - for (i = 0; i < 48; i += 2) { + for (i = 0; i < 48; i += 2) printk("%04x ", inw(dev->iobase + i)); - } + printk("\n"); ret = request_irq(link->irq, das16cs_interrupt, IRQF_SHARED, "cb_das16_cs", dev); - if (ret < 0) { + if (ret < 0) return ret; - } + dev->irq = link->irq; printk("irq=%u ", dev->irq); @@ -262,9 +262,9 @@ static int das16cs_detach(struct comedi_device *dev) { printk("comedi%d: das16cs: remove\n", dev->minor); - if (dev->irq) { + if (dev->irq) free_irq(dev->irq, dev); - } + return 0; } diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 82295e0f07f9..0d9e92e59f9d 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -107,6 +107,8 @@ TODO: #define PRESCALED_TIMER_BASE 10000 /* 100kHz 'prescaled' clock for slow aquisition, maybe I'll support this someday */ #define DMA_BUFFER_SIZE 0x1000 +#define PCI_VENDOR_ID_COMPUTERBOARDS 0x1307 + /* maximum value that can be loaded into board's 24-bit counters*/ static const int max_counter_value = 0xffffff; @@ -1621,9 +1623,9 @@ int alloc_and_init_dma_members(struct comedi_device *dev) priv(dev)->ai_buffer[i] = pci_alloc_consistent(priv(dev)->hw_dev, DMA_BUFFER_SIZE, &priv(dev)->ai_buffer_bus_addr[i]); - if (priv(dev)->ai_buffer[i] == NULL) { + if (priv(dev)->ai_buffer[i] == NULL) return -ENOMEM; - } + } for (i = 0; i < AO_DMA_RING_COUNT; i++) { if (ao_cmd_is_supported(board(dev))) { @@ -1632,9 +1634,9 @@ int alloc_and_init_dma_members(struct comedi_device *dev) DMA_BUFFER_SIZE, &priv(dev)-> ao_buffer_bus_addr[i]); - if (priv(dev)->ao_buffer[i] == NULL) { + if (priv(dev)->ao_buffer[i] == NULL) return -ENOMEM; - } + } } /* allocate dma descriptors */ @@ -1643,9 +1645,9 @@ int alloc_and_init_dma_members(struct comedi_device *dev) sizeof(struct plx_dma_desc) * ai_dma_ring_count(board(dev)), &priv(dev)->ai_dma_desc_bus_addr); - if (priv(dev)->ai_dma_desc == NULL) { + if (priv(dev)->ai_dma_desc == NULL) return -ENOMEM; - } + DEBUG_PRINT("ai dma descriptors start at bus addr 0x%x\n", priv(dev)->ai_dma_desc_bus_addr); if (ao_cmd_is_supported(board(dev))) { @@ -1654,9 +1656,9 @@ int alloc_and_init_dma_members(struct comedi_device *dev) sizeof(struct plx_dma_desc) * AO_DMA_RING_COUNT, &priv(dev)->ao_dma_desc_bus_addr); - if (priv(dev)->ao_dma_desc == NULL) { + if (priv(dev)->ao_dma_desc == NULL) return -ENOMEM; - } + DEBUG_PRINT("ao dma descriptors start at bus addr 0x%x\n", priv(dev)->ao_dma_desc_bus_addr); } @@ -1848,9 +1850,9 @@ static int attach(struct comedi_device *dev, struct comedi_devconfig *it) printk(" irq %u\n", dev->irq); retval = setup_subdevices(dev); - if (retval < 0) { + if (retval < 0) return retval; - } + return 0; } @@ -1919,9 +1921,9 @@ static int detach(struct comedi_device *dev) priv(dev)->ao_dma_desc, priv(dev)-> ao_dma_desc_bus_addr); - if (priv(dev)->main_phys_iobase) { + if (priv(dev)->main_phys_iobase) comedi_pci_disable(priv(dev)->hw_dev); - } + pci_dev_put(priv(dev)->hw_dev); } } @@ -2902,9 +2904,9 @@ static void pio_drain_ai_fifo_16(struct comedi_device *dev) if (cmd->stop_src == TRIG_COUNT) { if (priv(dev)->ai_count == 0) break; - if (num_samples > priv(dev)->ai_count) { + if (num_samples > priv(dev)->ai_count) num_samples = priv(dev)->ai_count; - } + priv(dev)->ai_count -= num_samples; } @@ -2943,9 +2945,9 @@ static void pio_drain_ai_fifo_32(struct comedi_device *dev) readw(priv(dev)->main_iobase + ADC_READ_PNTR_REG) & 0x7fff; if (cmd->stop_src == TRIG_COUNT) { - if (max_transfer > priv(dev)->ai_count) { + if (max_transfer > priv(dev)->ai_count) max_transfer = priv(dev)->ai_count; - } + } for (i = 0; read_code != write_code && i < max_transfer;) { fifo_data = readl(priv(dev)->dio_counter_iobase + ADC_FIFO_REG); @@ -2964,9 +2966,9 @@ static void pio_drain_ai_fifo_32(struct comedi_device *dev) /* empty fifo */ static void pio_drain_ai_fifo(struct comedi_device *dev) { - if (board(dev)->layout == LAYOUT_4020) { + if (board(dev)->layout == LAYOUT_4020) pio_drain_ai_fifo_32(dev); - } else + else pio_drain_ai_fifo_16(dev); } @@ -3038,9 +3040,9 @@ void handle_ai_interrupt(struct comedi_device *dev, unsigned short status, priv(dev)->plx9080_iobase + PLX_DMA1_CS_REG); DEBUG_PRINT("dma1 status 0x%x\n", dma1_status); - if (dma1_status & PLX_DMA_EN_BIT) { + if (dma1_status & PLX_DMA_EN_BIT) drain_dma_buffers(dev, 1); - } + DEBUG_PRINT(" cleared dma ch1 interrupt\n"); } spin_unlock_irqrestore(&dev->spinlock, flags); diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index 2e61727fc9a0..49dccbbd713f 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -52,6 +52,8 @@ See http://www.measurementcomputing.com/PDFManuals/pcim-das1602_16.pdf for more /* #define CBPCIMDAS_DEBUG */ #undef CBPCIMDAS_DEBUG +#define PCI_VENDOR_ID_COMPUTERBOARDS 0x1307 + /* Registers for the PCIM-DAS1602/16 */ /* sizes of io regions (bytes) */ diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c index e32a31763d50..f404ec7723e5 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdda.c +++ b/drivers/staging/comedi/drivers/cb_pcimdda.c @@ -91,7 +91,8 @@ Configuration Options: #include "8255.h" /* device ids of the cards we support -- currently only 1 card supported */ -#define PCI_ID_PCIM_DDA06_16 0x0053 +#define PCI_VENDOR_ID_COMPUTERBOARDS 0x1307 +#define PCI_ID_PCIM_DDA06_16 0x0053 /* * This is straight from skel.c -- I did this in case this source file diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c index 41311d99473b..429ec703d596 100644 --- a/drivers/staging/comedi/drivers/comedi_bond.c +++ b/drivers/staging/comedi/drivers/comedi_bond.c @@ -87,6 +87,7 @@ Configuration Options: * options that are used with comedi_config. */ +#include "../comedi.h" #include "../comedilib.h" #include "../comedidev.h" #include <linux/string.h> @@ -96,9 +97,7 @@ Configuration Options: #define MAX_CHANS 256 #define MODULE_NAME "comedi_bond" -#ifdef MODULE_LICENSE MODULE_LICENSE("GPL"); -#endif #ifndef STR # define STR1(x) #x # define STR(x) STR1(x) diff --git a/drivers/staging/comedi/drivers/comedi_parport.c b/drivers/staging/comedi/drivers/comedi_parport.c index 043afe4439c7..fcd7721c5537 100644 --- a/drivers/staging/comedi/drivers/comedi_parport.c +++ b/drivers/staging/comedi/drivers/comedi_parport.c @@ -309,18 +309,18 @@ static int parport_attach(struct comedi_device *dev, iobase = it->options[0]; printk(KERN_INFO "comedi%d: parport: 0x%04lx ", dev->minor, iobase); if (!request_region(iobase, PARPORT_SIZE, "parport (comedi)")) { - printk("I/O port conflict\n"); + printk(KERN_ERR "I/O port conflict\n"); return -EIO; } dev->iobase = iobase; irq = it->options[1]; if (irq) { - printk(" irq=%u", irq); + printk(KERN_INFO " irq=%u", irq); ret = request_irq(irq, parport_interrupt, 0, "comedi_parport", dev); if (ret < 0) { - printk(" irq not available\n"); + printk(KERN_ERR " irq not available\n"); return -EINVAL; } dev->irq = irq; @@ -380,13 +380,13 @@ static int parport_attach(struct comedi_device *dev, devpriv->c_data = 0; outb(devpriv->c_data, dev->iobase + PARPORT_C); - printk("\n"); + printk(KERN_INFO "\n"); return 1; } static int parport_detach(struct comedi_device *dev) { - printk("comedi%d: parport: remove\n", dev->minor); + printk(KERN_INFO "comedi%d: parport: remove\n", dev->minor); if (dev->iobase) release_region(dev->iobase, PARPORT_SIZE); diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index f4258334532c..9cb144f7e70c 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -1,55 +1,55 @@ /* - comedi/drivers/das08.c - DAS08 driver - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 2000 David A. Schleef <ds@schleef.org> - Copyright (C) 2001,2002,2003 Frank Mori Hess <fmhess@users.sourceforge.net> - Copyright (C) 2004 Salvador E. Tropea <set@users.sf.net> <set@ieee.org> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -***************************************************************** + * comedi/drivers/das08.c + * DAS08 driver + * + * COMEDI - Linux Control and Measurement Device Interface + * Copyright (C) 2000 David A. Schleef <ds@schleef.org> + * Copyright (C) 2001,2002,2003 Frank Mori Hess <fmhess@users.sourceforge.net> + * Copyright (C) 2004 Salvador E. Tropea <set@users.sf.net> <set@ieee.org> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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., 675 Mass Ave, Cambridge, MA 02139, USA. + * + ***************************************************************** + */ -*/ /* -Driver: das08 -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) -Status: works - -This is a rewrite of the das08 and das08jr drivers. - -Options (for ISA cards): - [0] - base io address - -Options (for pci-das08): - [0] - bus (optional) - [1] = slot (optional) - -The das08 driver doesn't support asynchronous commands, since -the cheap das08 hardware doesn't really support them. The -comedi_rt_timer driver can be used to emulate commands for this -driver. -*/ + * Driver: das08 + * 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) + * Status: works + * + * This is a rewrite of the das08 and das08jr drivers. + * + * Options (for ISA cards): + * [0] - base io address + * + * Options (for pci-das08): + * [0] - bus (optional) + * [1] = slot (optional) + * + * The das08 driver doesn't support asynchronous commands, since + * the cheap das08 hardware doesn't really support them. The + * comedi_rt_timer driver can be used to emulate commands for this + * driver. + */ #include "../comedidev.h" @@ -122,8 +122,8 @@ driver. */ #define DAS08JR_DIO 3 -#define DAS08JR_AO_LSB(x) ((x)?6:4) -#define DAS08JR_AO_MSB(x) ((x)?7:5) +#define DAS08JR_AO_LSB(x) ((x) ? 6 : 4) +#define DAS08JR_AO_MSB(x) ((x) ? 7 : 5) /* cio-das08_aox.pdf @@ -148,8 +148,8 @@ driver. #define DAS08AO_GAIN_CONTROL 3 #define DAS08AO_GAIN_STATUS 3 -#define DAS08AO_AO_LSB(x) ((x)?0xa:8) -#define DAS08AO_AO_MSB(x) ((x)?0xb:9) +#define DAS08AO_AO_LSB(x) ((x) ? 0xa : 8) +#define DAS08AO_AO_MSB(x) ((x) ? 0xb : 9) #define DAS08AO_AO_UPDATE 8 /* gainlist same as _pgx_ below */ @@ -239,8 +239,9 @@ static const struct comedi_lrange *const das08_ai_lranges[] = { &range_das08_pgm, }; -static const int das08_pgh_gainlist[] = - { 8, 0, 10, 2, 12, 4, 14, 6, 1, 3, 5, 7 }; +static const int das08_pgh_gainlist[] = { + 8, 0, 10, 2, 12, 4, 14, 6, 1, 3, 5, 7 +}; static const int das08_pgl_gainlist[] = { 8, 0, 2, 4, 6, 1, 3, 5, 7 }; static const int das08_pgm_gainlist[] = { 8, 0, 10, 12, 14, 9, 11, 13, 15 }; @@ -535,7 +536,8 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, inb(dev->iobase + DAS08_MSB); /* set multiplexer */ - spin_lock(&dev->spinlock); /* lock to prevent race with digital output */ + /* lock to prevent race with digital output */ + spin_lock(&dev->spinlock); devpriv->do_mux_bits &= ~DAS08_MUX_MASK; devpriv->do_mux_bits |= DAS08_MUX(chan); outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL); @@ -552,7 +554,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, /* clear over-range bits for 16-bit boards */ if (thisboard->ai_nbits == 16) if (inb(dev->iobase + DAS08_MSB) & 0x80) - printk("das08: over-range\n"); + printk(KERN_INFO "das08: over-range\n"); /* trigger conversion */ outb_p(0, dev->iobase + DAS08_TRIG_12BIT); @@ -562,7 +564,7 @@ static int das08_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, break; } if (i == TIMEOUT) { - printk("das08: timeout\n"); + printk(KERN_ERR "das08: timeout\n"); return -ETIME; } msb = inb(dev->iobase + DAS08_MSB); @@ -607,7 +609,8 @@ static int das08_do_wbits(struct comedi_device *dev, struct comedi_subdevice *s, /* set new bit values */ wbits |= data[0] & data[1]; /* remember digital output bits */ - spin_lock(&dev->spinlock); /* prevent race with setting of analog input mux */ + /* prevent race with setting of analog input mux */ + spin_lock(&dev->spinlock); devpriv->do_mux_bits &= ~DAS08_DO_MASK; devpriv->do_mux_bits |= DAS08_OP(wbits); outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL); @@ -860,9 +863,9 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) /* allocate ioports for non-pcmcia, non-pci boards */ if ((thisboard->bustype != pcmcia) && (thisboard->bustype != pci)) { - printk(" iobase 0x%lx\n", iobase); + printk(KERN_INFO " iobase 0x%lx\n", iobase); if (!request_region(iobase, thisboard->iosize, DRV_NAME)) { - printk(" I/O port conflict\n"); + printk(KERN_ERR " I/O port conflict\n"); return -EIO; } } @@ -878,8 +881,11 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) /* ai */ if (thisboard->ai) { s->type = COMEDI_SUBD_AI; - /* XXX some boards actually have differential inputs instead of single ended. - * The driver does nothing with arefs though, so it's no big deal. */ + /* XXX some boards actually have differential + * inputs instead of single ended. + * The driver does nothing with arefs though, + * so it's no big deal. + */ s->subdev_flags = SDF_READABLE | SDF_GROUND; s->n_chan = 8; s->maxdata = (1 << thisboard->ai_nbits) - 1; @@ -966,6 +972,7 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) return 0; } +EXPORT_SYMBOL_GPL(das08_common_attach); static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it) { @@ -980,7 +987,7 @@ static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret < 0) return ret; - printk("comedi%d: das08: ", dev->minor); + printk(KERN_INFO "comedi%d: das08: ", dev->minor); /* deal with a pci board */ if (thisboard->bustype == pci) { #ifdef CONFIG_COMEDI_PCI @@ -1007,20 +1014,21 @@ static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it) } } if (!pdev) { - printk("No pci das08 cards found\n"); + printk(KERN_ERR "No pci das08 cards found\n"); return -EIO; } devpriv->pdev = pdev; /* enable PCI device and reserve I/O spaces */ if (comedi_pci_enable(pdev, DRV_NAME)) { - printk - (" Error enabling PCI device and requesting regions\n"); + printk(KERN_ERR " Error enabling PCI device and " + "requesting regions\n"); return -EIO; } /* read base addresses */ pci_iobase = pci_resource_start(pdev, 1); iobase = pci_resource_start(pdev, 2); - printk("pcibase 0x%lx iobase 0x%lx\n", pci_iobase, iobase); + printk(KERN_INFO "pcibase 0x%lx iobase 0x%lx\n", + pci_iobase, iobase); devpriv->pci_iobase = pci_iobase; #if 0 /* We could enable to pci-das08's interrupt here to make it possible @@ -1034,17 +1042,18 @@ static int das08_attach(struct comedi_device *dev, struct comedi_devconfig *it) outw(INTR1_ENABLE | PCI_INTR_ENABLE, pci_iobase + INTCSR); #endif #else /* CONFIG_COMEDI_PCI */ - 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 /* CONFIG_COMEDI_PCI */ } else { iobase = it->options[0]; } - printk("\n"); + printk(KERN_INFO "\n"); return das08_common_attach(dev, iobase); } + int das08_common_detach(struct comedi_device *dev) { printk(KERN_INFO "comedi%d: das08: remove\n", dev->minor); @@ -1060,9 +1069,9 @@ int das08_common_detach(struct comedi_device *dev) #ifdef CONFIG_COMEDI_PCI if (devpriv) { if (devpriv->pdev) { - if (devpriv->pci_iobase) { + if (devpriv->pci_iobase) comedi_pci_disable(devpriv->pdev); - } + pci_dev_put(devpriv->pdev); } } @@ -1070,6 +1079,7 @@ int das08_common_detach(struct comedi_device *dev) return 0; } +EXPORT_SYMBOL_GPL(das08_common_detach); #ifdef CONFIG_COMEDI_PCI COMEDI_PCI_INITCLEANUP(driver_das08, das08_pci_table); @@ -1077,8 +1087,6 @@ COMEDI_PCI_INITCLEANUP(driver_das08, das08_pci_table); COMEDI_INITCLEANUP(driver_das08); #endif -EXPORT_SYMBOL_GPL(das08_common_attach); -EXPORT_SYMBOL_GPL(das08_common_detach); #ifdef CONFIG_COMEDI_PCMCIA EXPORT_SYMBOL_GPL(das08_cs_boards); #endif diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index f2aadda9b241..ccee4f1802d6 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -74,7 +74,8 @@ Keithley Manuals: 4922.PDF (das-1400) 4923.PDF (das1200, 1400, 1600) -Computer boards manuals also available from their website www.measurementcomputing.com +Computer boards manuals also available from their website +www.measurementcomputing.com */ @@ -92,7 +93,8 @@ Computer boards manuals also available from their website www.measurementcomputi /* #define DEBUG */ #ifdef DEBUG -#define DEBUG_PRINT(format, args...) printk("das16: " format, ## args) +#define DEBUG_PRINT(format, args...) \ + printk(KERN_DEBUG "das16: " format, ## args) #else #define DEBUG_PRINT(format, args...) #endif @@ -186,15 +188,16 @@ Computer boards manuals also available from their website www.measurementcomputi */ -static const int sample_size = 2; /* size in bytes of a sample from board */ +/* size in bytes of a sample from board */ +static const int sample_size = 2; #define DAS16_TRIG 0 #define DAS16_AI_LSB 0 #define DAS16_AI_MSB 1 #define DAS16_MUX 2 #define DAS16_DIO 3 -#define DAS16_AO_LSB(x) ((x)?6:4) -#define DAS16_AO_MSB(x) ((x)?7:5) +#define DAS16_AO_LSB(x) ((x) ? 6 : 4) +#define DAS16_AO_MSB(x) ((x) ? 7 : 5) #define DAS16_STATUS 8 #define BUSY (1<<7) #define UNIPOLAR (1<<6) @@ -271,7 +274,7 @@ static const struct comedi_lrange range_das1x02_unip = { 4, { }; static const struct comedi_lrange range_das16jr = { 9, { - /* also used by 16/330 */ + /* also used by 16/330 */ BIP_RANGE(10), BIP_RANGE(5), BIP_RANGE(2.5), @@ -547,7 +550,8 @@ static const struct das16_board das16_boards[] = { .id = 0x20, }, { - .name = "das-1401", /* 4919.pdf and 4922.pdf (keithley user's manual) */ + /* 4919.pdf and 4922.pdf (keithley user's manual) */ + .name = "das-1401", .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 10000, @@ -558,10 +562,11 @@ static const struct das16_board das16_boards[] = { .i8255_offset = 0x0, .i8254_offset = 0x0c, .size = 0x408, - .id = 0xc0 /* 4919.pdf says id bits are 0xe0, 4922.pdf says 0xc0 */ + .id = 0xc0 /* 4919.pdf says id bits are 0xe0, 4922.pdf says 0xc0 */ }, { - .name = "das-1402", /* 4919.pdf and 4922.pdf (keithley user's manual) */ + /* 4919.pdf and 4922.pdf (keithley user's manual) */ + .name = "das-1402", .ai = das16_ai_rinsn, .ai_nbits = 12, .ai_speed = 10000, @@ -572,7 +577,7 @@ static const struct das16_board das16_boards[] = { .i8255_offset = 0x0, .i8254_offset = 0x0c, .size = 0x408, - .id = 0xc0 /* 4919.pdf says id bits are 0xe0, 4922.pdf says 0xc0 */ + .id = 0xc0 /* 4919.pdf says id bits are 0xe0, 4922.pdf says 0xc0 */ }, { .name = "das-1601", /* 4919.pdf */ @@ -704,7 +709,8 @@ static const struct das16_board das16_boards[] = { .name = "das16/jr/ctr5", /* ? */ }, { - .name = "cio-das16/m1/16", /* cio-das16_m1_16.pdf, this board is a bit quirky, no dma */ + /* cio-das16_m1_16.pdf, this board is a bit quirky, no dma */ + .name = "cio-das16/m1/16", }, #endif }; @@ -736,14 +742,19 @@ struct das16_private_struct { unsigned int clockbase; /* master clock speed in ns */ volatile unsigned int control_state; /* dma, interrupt and trigger control bits */ volatile unsigned long adc_byte_count; /* number of bytes remaining */ - unsigned int divisor1; /* divisor dividing master clock to get conversion frequency */ - unsigned int divisor2; /* divisor dividing master clock to get conversion frequency */ + /* divisor dividing master clock to get conversion frequency */ + unsigned int divisor1; + /* divisor dividing master clock to get conversion frequency */ + unsigned int divisor2; unsigned int dma_chan; /* dma channel */ uint16_t *dma_buffer[2]; dma_addr_t dma_buffer_addr[2]; unsigned int current_buffer; volatile unsigned int dma_transfer_size; /* target number of bytes to transfer per dma shot */ - /* user-defined analog input and output ranges defined from config options */ + /** + * user-defined analog input and output ranges + * defined from config options + */ struct comedi_lrange *user_ai_range_table; struct comedi_lrange *user_ao_range_table; @@ -798,7 +809,10 @@ static int das16_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 + */ if (cmd->scan_begin_src != TRIG_TIMER && cmd->scan_begin_src != TRIG_EXT && cmd->scan_begin_src != TRIG_FOLLOW) @@ -893,12 +907,15 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s, if (CR_CHAN(cmd->chanlist[i]) != (start_chan + i) % s->n_chan) { comedi_error(dev, - "entries in chanlist must be consecutive channels, counting upwards\n"); + "entries in chanlist must be " + "consecutive channels, " + "counting upwards\n"); err++; } if (CR_RANGE(cmd->chanlist[i]) != gain) { comedi_error(dev, - "entries in chanlist must all have the same gain\n"); + "entries in chanlist must all " + "have the same gain\n"); err++; } } @@ -920,12 +937,13 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) if (devpriv->dma_chan == 0 || (dev->irq == 0 && devpriv->timer_mode == 0)) { comedi_error(dev, - "irq (or use of 'timer mode') dma required to execute comedi_cmd"); + "irq (or use of 'timer mode') dma required to " + "execute comedi_cmd"); return -1; } if (cmd->flags & TRIG_RT) { - comedi_error(dev, - "isa dma transfers cannot be performed with TRIG_RT, aborting"); + comedi_error(dev, "isa dma transfers cannot be performed with " + "TRIG_RT, aborting"); return -1; } @@ -933,16 +951,17 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) cmd->stop_arg * cmd->chanlist_len * sizeof(uint16_t); /* disable conversions for das1600 mode */ - if (thisboard->size > 0x400) { + if (thisboard->size > 0x400) outb(DAS1600_CONV_DISABLE, dev->iobase + DAS1600_CONV); - } + /* set scan limits */ byte = CR_CHAN(cmd->chanlist[0]); byte |= CR_CHAN(cmd->chanlist[cmd->chanlist_len - 1]) << 4; outb(byte, dev->iobase + DAS16_MUX); /* set gain (this is also burst rate register but according to - * computer boards manual, burst rate does nothing, even on keithley cards) */ + * computer boards manual, burst rate does nothing, even on + * keithley cards) */ if (thisboard->ai_pg != das16_pg_none) { range = CR_RANGE(cmd->chanlist[0]); outb((das16_gainlists[thisboard->ai_pg])[range], @@ -1005,9 +1024,9 @@ static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s) outb(devpriv->control_state, dev->iobase + DAS16_CONTROL); /* Enable conversions if using das1600 mode */ - if (thisboard->size > 0x400) { + if (thisboard->size > 0x400) outb(0, dev->iobase + DAS1600_CONV); - } + return 0; } @@ -1030,9 +1049,9 @@ static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s) } /* disable burst mode */ - if (thisboard->size > 0x400) { + if (thisboard->size > 0x400) outb(0, dev->iobase + DAS1600_BURST); - } + spin_unlock_irqrestore(&dev->spinlock, flags); @@ -1085,11 +1104,11 @@ static int das16_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, } msb = inb(dev->iobase + DAS16_AI_MSB); lsb = inb(dev->iobase + DAS16_AI_LSB); - if (thisboard->ai_nbits == 12) { + if (thisboard->ai_nbits == 12) data[n] = ((lsb >> 4) & 0xf) | (msb << 4); - } else { + else data[n] = lsb | (msb << 8); - } + } return n; @@ -1207,8 +1226,8 @@ static int disable_dma_on_even(struct comedi_device *dev) residue = get_dma_residue(devpriv->dma_chan); } if (i == disable_limit) { - comedi_error(dev, - "failed to get an even dma transfer, could be trouble."); + comedi_error(dev, "failed to get an even dma transfer, " + "could be trouble."); } return residue; } @@ -1254,7 +1273,8 @@ static void das16_interrupt(struct comedi_device *dev) } else num_bytes = devpriv->dma_transfer_size - residue; - if (cmd->stop_src == TRIG_COUNT && num_bytes >= devpriv->adc_byte_count) { + if (cmd->stop_src == TRIG_COUNT && + num_bytes >= devpriv->adc_byte_count) { num_bytes = devpriv->adc_byte_count; async->events |= COMEDI_CB_EOA; } @@ -1275,9 +1295,9 @@ static void das16_interrupt(struct comedi_device *dev) set_dma_count(devpriv->dma_chan, devpriv->dma_transfer_size); enable_dma(devpriv->dma_chan); /* reenable conversions for das1600 mode, (stupid hardware) */ - if (thisboard->size > 0x400 && devpriv->timer_mode == 0) { + if (thisboard->size > 0x400 && devpriv->timer_mode == 0) outb(0x00, dev->iobase + DAS1600_CONV); - } + } release_dma_lock(dma_flags); @@ -1330,25 +1350,25 @@ static int das16_probe(struct comedi_device *dev, struct comedi_devconfig *it) status = inb(dev->iobase + DAS16_STATUS); - if ((status & UNIPOLAR)) { + if ((status & UNIPOLAR)) devpriv->ai_unipolar = 1; - } else { + else devpriv->ai_unipolar = 0; - } - if ((status & DAS16_MUXBIT)) { + + if ((status & DAS16_MUXBIT)) devpriv->ai_singleended = 1; - } else { + else devpriv->ai_singleended = 0; - } + /* diobits indicates boards */ diobits = inb(dev->iobase + DAS16_DIO) & 0xf0; - printk(" id bits are 0x%02x\n", diobits); + printk(KERN_INFO " id bits are 0x%02x\n", diobits); if (thisboard->id != diobits) { - printk(" requested board's id bits are 0x%x (ignore)\n", + printk(KERN_INFO " requested board's id bits are 0x%x (ignore)\n", thisboard->id); } @@ -1363,10 +1383,10 @@ static int das1600_mode_detect(struct comedi_device *dev) if (status & DAS1600_CLK_10MHZ) { devpriv->clockbase = 100; - printk(" 10MHz pacer clock\n"); + printk(KERN_INFO " 10MHz pacer clock\n"); } else { devpriv->clockbase = 1000; - printk(" 1MHz pacer clock\n"); + printk(KERN_INFO " 1MHz pacer clock\n"); } reg_dump(dev); @@ -1406,14 +1426,15 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (timer_mode) irq = 0; - printk("comedi%d: das16:", dev->minor); + printk(KERN_INFO "comedi%d: das16:", dev->minor); /* check that clock setting is valid */ if (it->options[3]) { if (it->options[3] != 0 && it->options[3] != 1 && it->options[3] != 10) { printk - ("\n Invalid option. Master clock must be set to 1 or 10 (MHz)\n"); + ("\n Invalid option. Master clock must be set " + "to 1 or 10 (MHz)\n"); return -EINVAL; } } @@ -1425,23 +1446,23 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (thisboard->size < 0x400) { printk(" 0x%04lx-0x%04lx\n", iobase, iobase + thisboard->size); if (!request_region(iobase, thisboard->size, "das16")) { - printk(" I/O port conflict\n"); + printk(KERN_ERR " I/O port conflict\n"); return -EIO; } } else { - printk(" 0x%04lx-0x%04lx 0x%04lx-0x%04lx\n", + printk(KERN_INFO " 0x%04lx-0x%04lx 0x%04lx-0x%04lx\n", iobase, iobase + 0x0f, iobase + 0x400, iobase + 0x400 + (thisboard->size & 0x3ff)); if (!request_region(iobase, 0x10, "das16")) { - printk(" I/O port conflict: 0x%04lx-0x%04lx\n", + printk(KERN_ERR " I/O port conflict: 0x%04lx-0x%04lx\n", iobase, iobase + 0x0f); return -EIO; } if (!request_region(iobase + 0x400, thisboard->size & 0x3ff, "das16")) { release_region(iobase, 0x10); - printk(" I/O port conflict: 0x%04lx-0x%04lx\n", + printk(KERN_ERR " I/O port conflict: 0x%04lx-0x%04lx\n", iobase + 0x400, iobase + 0x400 + (thisboard->size & 0x3ff)); return -EIO; @@ -1452,7 +1473,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* probe id bits to make sure they are consistent */ if (das16_probe(dev, it)) { - printk(" id bits do not match selected board, aborting\n"); + printk(KERN_ERR " id bits do not match selected board, aborting\n"); return -EINVAL; } dev->board_name = thisboard->name; @@ -1474,7 +1495,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (ret < 0) return ret; dev->irq = irq; - printk(" ( irq = %u )", irq); + printk(KERN_INFO " ( irq = %u )", irq); } else if (irq == 0) { printk(" ( no irq )"); } else { @@ -1488,16 +1509,15 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* allocate dma buffers */ int i; for (i = 0; i < 2; i++) { - devpriv->dma_buffer[i] = pci_alloc_consistent(NULL, - DAS16_DMA_SIZE, - &devpriv-> - dma_buffer_addr - [i]); + devpriv->dma_buffer[i] = pci_alloc_consistent( + NULL, DAS16_DMA_SIZE, + &devpriv->dma_buffer_addr[i]); + if (devpriv->dma_buffer[i] == NULL) return -ENOMEM; } if (request_dma(dma_chan, "das16")) { - printk(" failed to allocate dma channel %i\n", + printk(KERN_ERR " failed to allocate dma channel %i\n", dma_chan); return -EINVAL; } @@ -1506,11 +1526,11 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) disable_dma(devpriv->dma_chan); set_dma_mode(devpriv->dma_chan, DMA_MODE_READ); release_dma_lock(flags); - printk(" ( dma = %u)\n", dma_chan); + printk(KERN_INFO " ( dma = %u)\n", dma_chan); } else if (dma_chan == 0) { - printk(" ( no dma )\n"); + printk(KERN_INFO " ( no dma )\n"); } else { - printk(" invalid dma channel\n"); + printk(KERN_ERR " invalid dma channel\n"); return -EINVAL; } @@ -1569,7 +1589,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->subdev_flags |= SDF_DIFF; } s->maxdata = (1 << thisboard->ai_nbits) - 1; - if (devpriv->user_ai_range_table) { /* user defined ai range */ + if (devpriv->user_ai_range_table) { /* user defined ai range */ s->range_table = devpriv->user_ai_range_table; } else if (devpriv->ai_unipolar) { s->range_table = das16_ai_uni_lranges[thisboard->ai_pg]; @@ -1592,11 +1612,12 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->subdev_flags = SDF_WRITABLE; s->n_chan = 2; s->maxdata = (1 << thisboard->ao_nbits) - 1; - if (devpriv->user_ao_range_table) { /* user defined ao range */ + /* user defined ao range */ + if (devpriv->user_ao_range_table) s->range_table = devpriv->user_ao_range_table; - } else { + else s->range_table = &range_unknown; - } + s->insn_write = thisboard->ao; } else { s->type = COMEDI_SUBD_UNUSED; @@ -1656,7 +1677,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it) static int das16_detach(struct comedi_device *dev) { - printk("comedi%d: das16: remove\n", dev->minor); + printk(KERN_INFO "comedi%d: das16: remove\n", dev->minor); das16_reset(dev); @@ -1750,8 +1771,8 @@ static void das16_ai_munge(struct comedi_device *dev, for (i = 0; i < num_samples; i++) { data[i] = le16_to_cpu(data[i]); - if (thisboard->ai_nbits == 12) { + if (thisboard->ai_nbits == 12) data[i] = (data[i] >> 4) & 0xfff; - } + } } diff --git a/drivers/staging/comedi/drivers/das1800.c b/drivers/staging/comedi/drivers/das1800.c index 3c3e0455c7c4..d91c2d9d595b 100644 --- a/drivers/staging/comedi/drivers/das1800.c +++ b/drivers/staging/comedi/drivers/das1800.c @@ -797,10 +797,8 @@ static int das1800_detach(struct comedi_device *dev) free_dma(devpriv->dma0); if (devpriv->dma1) free_dma(devpriv->dma1); - if (devpriv->ai_buf0) - kfree(devpriv->ai_buf0); - if (devpriv->ai_buf1) - kfree(devpriv->ai_buf1); + kfree(devpriv->ai_buf0); + kfree(devpriv->ai_buf1); } printk("comedi%d: %s: remove\n", dev->minor, diff --git a/drivers/staging/comedi/drivers/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c index 3f365aee4822..83fb6e56c3e9 100644 --- a/drivers/staging/comedi/drivers/dt2801.c +++ b/drivers/staging/comedi/drivers/dt2801.c @@ -472,7 +472,7 @@ static const struct comedi_lrange *dac_range_table[] = { static const struct comedi_lrange *dac_range_lkup(int opt) { - if (opt < 0 || opt > 5) + if (opt < 0 || opt >= 5) return &range_unknown; return dac_range_table[opt]; } diff --git a/drivers/staging/comedi/drivers/dt2814.c b/drivers/staging/comedi/drivers/dt2814.c index e1b73752f607..16fde066d266 100644 --- a/drivers/staging/comedi/drivers/dt2814.c +++ b/drivers/staging/comedi/drivers/dt2814.c @@ -99,13 +99,13 @@ static int dt2814_ai_insn_read(struct comedi_device *dev, outb(chan, dev->iobase + DT2814_CSR); for (i = 0; i < DT2814_TIMEOUT; i++) { status = inb(dev->iobase + DT2814_CSR); - printk("dt2814: status: %02x\n", status); + printk(KERN_INFO "dt2814: status: %02x\n", status); udelay(10); if (status & DT2814_FINISH) break; } if (i >= DT2814_TIMEOUT) { - printk("dt2814: status: %02x\n", status); + printk(KERN_INFO "dt2814: status: %02x\n", status); return -ETIMEDOUT; } @@ -173,7 +173,8 @@ static int dt2814_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->stop_src != TRIG_TIMER && cmd->stop_src != TRIG_EXT) @@ -256,9 +257,9 @@ static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it) unsigned long iobase; iobase = it->options[0]; - printk("comedi%d: dt2814: 0x%04lx ", dev->minor, iobase); + printk(KERN_INFO "comedi%d: dt2814: 0x%04lx ", dev->minor, iobase); if (!request_region(iobase, DT2814_SIZE, "dt2814")) { - printk("I/O port conflict\n"); + printk(KERN_ERR "I/O port conflict\n"); return -EIO; } dev->iobase = iobase; @@ -267,7 +268,7 @@ static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it) outb(0, dev->iobase + DT2814_CSR); udelay(100); if (inb(dev->iobase + DT2814_CSR) & DT2814_ERR) { - printk("reset error (fatal)\n"); + printk(KERN_ERR "reset error (fatal)\n"); return -EIO; } i = inb(dev->iobase + DT2814_DATA); @@ -286,9 +287,9 @@ static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it) irq = probe_irq_off(irqs); restore_flags(flags); - if (inb(dev->iobase + DT2814_CSR) & DT2814_ERR) { - printk("error probing irq (bad) \n"); - } + if (inb(dev->iobase + DT2814_CSR) & DT2814_ERR) + printk(KERN_DEBUG "error probing irq (bad)\n"); + i = inb(dev->iobase + DT2814_DATA); i = inb(dev->iobase + DT2814_DATA); @@ -297,18 +298,18 @@ static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it) dev->irq = 0; if (irq > 0) { if (request_irq(irq, dt2814_interrupt, 0, "dt2814", dev)) { - printk("(irq %d unavailable)\n", irq); + printk(KERN_WARNING "(irq %d unavailable)\n", irq); } else { - printk("( irq = %d )\n", irq); + printk(KERN_INFO "( irq = %d )\n", irq); dev->irq = irq; } } else if (irq == 0) { - printk("(no irq)\n"); + printk(KERN_WARNING "(no irq)\n"); } else { #if 0 - printk("(probe returned multiple irqs--bad)\n"); + printk(KERN_DEBUG "(probe returned multiple irqs--bad)\n"); #else - printk("(irq probe not implemented)\n"); + printk(KERN_WARNING "(irq probe not implemented)\n"); #endif } @@ -337,14 +338,13 @@ static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it) static int dt2814_detach(struct comedi_device *dev) { - printk("comedi%d: dt2814: remove\n", dev->minor); + printk(KERN_INFO "comedi%d: dt2814: remove\n", dev->minor); - if (dev->irq) { + if (dev->irq) free_irq(dev->irq, dev); - } - if (dev->iobase) { + + if (dev->iobase) release_region(dev->iobase, DT2814_SIZE); - } return 0; } diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index e548763cf2f3..fd8728c83669 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -45,9 +45,9 @@ Configuration options: [7] - AO 1 jumpered for 0=straight binary, 1=2's complement [8] - AI jumpered for 0=[-10,10]V, 1=[0,10], 2=[-5,5], 3=[0,5] [9] - AO 0 jumpered for 0=[-10,10]V, 1=[0,10], 2=[-5,5], 3=[0,5], - 4=[-2.5,2.5] + 4=[-2.5,2.5] [10]- A0 1 jumpered for 0=[-10,10]V, 1=[0,10], 2=[-5,5], 3=[0,5], - 4=[-2.5,2.5] + 4=[-2.5,2.5] Notes: - AO commands might be broken. @@ -155,79 +155,58 @@ Notes: #define DT2821_XCLK 0x0002 /* (R/W) external clock enable */ #define DT2821_BDINIT 0x0001 /* (W) initialize board */ -static const struct comedi_lrange range_dt282x_ai_lo_bipolar = { 4, { - RANGE(-10, - 10), - RANGE(-5, - 5), - RANGE(-2.5, - 2.5), - RANGE - (-1.25, - 1.25) - } +static const struct comedi_lrange range_dt282x_ai_lo_bipolar = { + 4, { + RANGE(-10, 10), + RANGE(-5, 5), + RANGE(-2.5, 2.5), + RANGE(-1.25, 1.25) + } }; -static const struct comedi_lrange range_dt282x_ai_lo_unipolar = { 4, { - RANGE(0, - 10), - RANGE(0, - 5), - RANGE(0, - 2.5), - RANGE(0, - 1.25) - } +static const struct comedi_lrange range_dt282x_ai_lo_unipolar = { + 4, { + RANGE(0, 10), + RANGE(0, 5), + RANGE(0, 2.5), + RANGE(0, 1.25) + } }; -static const struct comedi_lrange range_dt282x_ai_5_bipolar = { 4, { - RANGE(-5, - 5), - RANGE(-2.5, - 2.5), - RANGE(-1.25, - 1.25), - RANGE - (-0.625, - 0.625), - } +static const struct comedi_lrange range_dt282x_ai_5_bipolar = { + 4, { + RANGE(-5, 5), + RANGE(-2.5, 2.5), + RANGE(-1.25, 1.25), + RANGE(-0.625, 0.625) + } }; -static const struct comedi_lrange range_dt282x_ai_5_unipolar = { 4, { - RANGE(0, - 5), - RANGE(0, - 2.5), - RANGE(0, - 1.25), - RANGE(0, - 0.625), - } +static const struct comedi_lrange range_dt282x_ai_5_unipolar = { + 4, { + RANGE(0, 5), + RANGE(0, 2.5), + RANGE(0, 1.25), + RANGE(0, 0.625), + } }; -static const struct comedi_lrange range_dt282x_ai_hi_bipolar = { 4, { - RANGE(-10, - 10), - RANGE(-1, - 1), - RANGE(-0.1, - 0.1), - RANGE - (-0.02, - 0.02) - } +static const struct comedi_lrange range_dt282x_ai_hi_bipolar = { + 4, { + RANGE(-10, 10), + RANGE(-1, 1), + RANGE(-0.1, 0.1), + RANGE(-0.02, 0.02) + } }; -static const struct comedi_lrange range_dt282x_ai_hi_unipolar = { 4, { - RANGE(0, - 10), - RANGE(0, - 1), - RANGE(0, - 0.1), - RANGE(0, - 0.02) - } +static const struct comedi_lrange range_dt282x_ai_hi_unipolar = { + 4, { + RANGE(0, 10), + RANGE(0, 1), + RANGE(0, 0.1), + RANGE(0, 0.02) + } }; struct dt282x_board { @@ -370,7 +349,7 @@ static const struct dt282x_board boardtypes[] = { }, }; -#define n_boardtypes sizeof(boardtypes)/sizeof(struct dt282x_board) +#define n_boardtypes (sizeof(boardtypes)/sizeof(struct dt282x_board)) #define this_board ((const struct dt282x_board *)dev->board_ptr) struct dt282x_private { @@ -411,21 +390,25 @@ struct dt282x_private { #define update_adcsr(a) outw(devpriv->adcsr|(a), dev->iobase+DT2821_ADCSR) #define mux_busy() (inw(dev->iobase+DT2821_ADCSR)&DT2821_MUXBUSY) #define ad_done() (inw(dev->iobase+DT2821_ADCSR)&DT2821_ADDONE) -#define update_supcsr(a) outw(devpriv->supcsr|(a), dev->iobase+DT2821_SUPCSR) +#define update_supcsr(a) outw(devpriv->supcsr|(a), dev->iobase+DT2821_SUPCSR) /* * danger! macro abuse... a is the expression to wait on, and b is * the statement(s) to execute if it doesn't happen. */ -#define wait_for(a, b) \ - do{ \ - int _i; \ - for (_i=0;_i<DT2821_TIMEOUT;_i++){ \ - if (a){_i=0;break;} \ - udelay(5); \ - } \ - if (_i){b} \ - }while (0) +#define wait_for(a, b) \ + do { \ + int _i; \ + for (_i = 0; _i < DT2821_TIMEOUT; _i++) { \ + if (a) { \ + _i = 0; \ + break; \ + } \ + udelay(5); \ + } \ + if (_i) \ + b \ + } while (0) static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it); @@ -462,18 +445,16 @@ static void dt282x_munge(struct comedi_device *dev, short *buf, unsigned short sign = 1 << (boardtype.adbits - 1); int n; - if (devpriv->ad_2scomp) { + if (devpriv->ad_2scomp) sign = 1 << (boardtype.adbits - 1); - } else { + else sign = 0; - } if (nbytes % 2) comedi_error(dev, "bug! odd number of bytes from dma xfer"); n = nbytes / 2; - for (i = 0; i < n; i++) { + for (i = 0; i < n; i++) buf[i] = (buf[i] & mask) ^ sign; - } } static void dt282x_ao_dma_interrupt(struct comedi_device *dev) @@ -486,7 +467,7 @@ static void dt282x_ao_dma_interrupt(struct comedi_device *dev) update_supcsr(DT2821_CLRDMADNE); if (!s->async->prealloc_buf) { - printk("async->data disappeared. dang!\n"); + printk(KERN_ERR "async->data disappeared. dang!\n"); return; } @@ -499,7 +480,7 @@ static void dt282x_ao_dma_interrupt(struct comedi_device *dev) size = cfc_read_array_from_buffer(s, ptr, devpriv->dma_maxsize); if (size == 0) { - printk("dt282x: AO underrun\n"); + printk(KERN_ERR "dt282x: AO underrun\n"); dt282x_ao_cancel(dev, s); s->async->events |= COMEDI_CB_OVERFLOW; return; @@ -519,7 +500,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev) update_supcsr(DT2821_CLRDMADNE); if (!s->async->prealloc_buf) { - printk("async->data disappeared. dang!\n"); + printk(KERN_ERR "async->data disappeared. dang!\n"); return; } @@ -540,7 +521,7 @@ static void dt282x_ai_dma_interrupt(struct comedi_device *dev) devpriv->nread -= size / 2; if (devpriv->nread < 0) { - printk("dt282x: off by one\n"); + printk(KERN_INFO "dt282x: off by one\n"); devpriv->nread = 0; } if (!devpriv->nread) { @@ -651,7 +632,7 @@ static irqreturn_t dt282x_interrupt(int irq, void *d) static int warn = 5; if (--warn <= 0) { disable_irq(dev->irq); - printk("disabling irq\n"); + printk(KERN_INFO "disabling irq\n"); } #endif comedi_error(dev, "D/A error"); @@ -666,13 +647,13 @@ static irqreturn_t dt282x_interrupt(int irq, void *d) data = (short)inw(dev->iobase + DT2821_ADDAT); data &= (1 << boardtype.adbits) - 1; - if (devpriv->ad_2scomp) { + + if (devpriv->ad_2scomp) data ^= 1 << (boardtype.adbits - 1); - } ret = comedi_buf_put(s->async, data); - if (ret == 0) { + + if (ret == 0) s->async->events |= COMEDI_CB_OVERFLOW; - } devpriv->nread--; if (!devpriv->nread) { @@ -685,7 +666,8 @@ static irqreturn_t dt282x_interrupt(int irq, void *d) } #endif comedi_event(dev, s); - /* printk("adcsr=0x%02x dacsr-0x%02x supcsr=0x%02x\n", adcsr, dacsr, supcsr); */ + /* printk("adcsr=0x%02x dacsr-0x%02x supcsr=0x%02x\n", + adcsr, dacsr, supcsr); */ return IRQ_RETVAL(handled); } @@ -776,7 +758,10 @@ static int dt282x_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_FOLLOW && @@ -859,7 +844,8 @@ static int dt282x_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (devpriv->usedma == 0) { comedi_error(dev, - "driver requires 2 dma channels to execute command"); + "driver requires 2 dma channels" + " to execute command"); return -EIO; } @@ -1049,7 +1035,10 @@ static int dt282x_ao_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->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE) @@ -1064,7 +1053,7 @@ static int dt282x_ao_cmdtest(struct comedi_device *dev, cmd->start_arg = 0; err++; } - if (cmd->scan_begin_arg < 5000 /* XXX unknown */ ) { + if (cmd->scan_begin_arg < 5000 /* XXX unknown */) { cmd->scan_begin_arg = 5000; err++; } @@ -1115,7 +1104,7 @@ static int dt282x_ao_inttrig(struct comedi_device *dev, size = cfc_read_array_from_buffer(s, devpriv->dma[0].buf, devpriv->dma_maxsize); if (size == 0) { - printk("dt282x: AO underrun\n"); + printk(KERN_ERR "dt282x: AO underrun\n"); return -EPIPE; } prep_ao_dma(dev, 0, size); @@ -1123,7 +1112,7 @@ static int dt282x_ao_inttrig(struct comedi_device *dev, size = cfc_read_array_from_buffer(s, devpriv->dma[1].buf, devpriv->dma_maxsize); if (size == 0) { - printk("dt282x: AO underrun\n"); + printk(KERN_ERR "dt282x: AO underrun\n"); return -EPIPE; } prep_ao_dma(dev, 1, size); @@ -1141,7 +1130,8 @@ static int dt282x_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (devpriv->usedma == 0) { comedi_error(dev, - "driver requires 2 dma channels to execute command"); + "driver requires 2 dma channels" + " to execute command"); return -EIO; } @@ -1262,7 +1252,8 @@ static const struct comedi_lrange *opt_ao_range_lkup(int x) return ao_range_table[x]; } -enum { opt_iobase = 0, opt_irq, opt_dma1, opt_dma2, /* i/o base, irq, dma channels */ +enum { /* i/o base, irq, dma channels */ + opt_iobase = 0, opt_irq, opt_dma1, opt_dma2, opt_diff, /* differential */ opt_ai_twos, opt_ao0_twos, opt_ao1_twos, /* twos comp */ opt_ai_range, opt_ao0_range, opt_ao1_range, /* range */ @@ -1295,9 +1286,9 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it) if (!iobase) iobase = 0x240; - printk("comedi%d: dt282x: 0x%04lx", dev->minor, iobase); + printk(KERN_INFO "comedi%d: dt282x: 0x%04lx", dev->minor, iobase); if (!request_region(iobase, DT2821_SIZE, "dt282x")) { - printk(" I/O port conflict\n"); + printk(KERN_INFO " I/O port conflict\n"); return -EBUSY; } dev->iobase = iobase; @@ -1305,7 +1296,7 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it) outw(DT2821_BDINIT, dev->iobase + DT2821_SUPCSR); i = inw(dev->iobase + DT2821_ADCSR); #ifdef DEBUG - printk(" fingerprint=%x,%x,%x,%x,%x", + printk(KERN_DEBUG " fingerprint=%x,%x,%x,%x,%x", inw(dev->iobase + DT2821_ADCSR), inw(dev->iobase + DT2821_CHANCSR), inw(dev->iobase + DT2821_DACSR), @@ -1323,7 +1314,7 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it) != DT2821_SUPCSR_VAL) || ((inw(dev->iobase + DT2821_TMRCTR) & DT2821_TMRCTR_MASK) != DT2821_TMRCTR_VAL)) { - printk(" board not found"); + printk(KERN_ERR " board not found"); return -EIO; } /* should do board test */ @@ -1344,26 +1335,25 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it) irq = probe_irq_off(irqs); restore_flags(flags); - if (0 /* error */ ) { - printk(" error probing irq (bad)"); - } + if (0 /* error */) + printk(KERN_ERR " error probing irq (bad)"); } #endif if (irq > 0) { - printk(" ( irq = %d )", irq); + printk(KERN_INFO " ( irq = %d )", irq); ret = request_irq(irq, dt282x_interrupt, 0, "dt282x", dev); if (ret < 0) { - printk(" failed to get irq\n"); + printk(KERN_ERR " failed to get irq\n"); return -EIO; } dev->irq = irq; } else if (irq == 0) { - printk(" (no irq)"); + printk(KERN_INFO " (no irq)"); } else { #if 0 - printk(" (probe returned multiple irqs--bad)"); + printk(KERN_INFO " (probe returned multiple irqs--bad)"); #else - printk(" (irq probe not implemented)"); + printk(KERN_INFO " (irq probe not implemented)"); #endif } @@ -1435,16 +1425,15 @@ static int dt282x_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->maxdata = 1; s->range_table = &range_digital; - printk("\n"); + printk(KERN_INFO "\n"); return 0; } static void free_resources(struct comedi_device *dev) { - if (dev->irq) { + if (dev->irq) free_irq(dev->irq, dev); - } if (dev->iobase) release_region(dev->iobase, DT2821_SIZE); if (dev->private) { @@ -1461,7 +1450,7 @@ static void free_resources(struct comedi_device *dev) static int dt282x_detach(struct comedi_device *dev) { - printk("comedi%d: dt282x: remove\n", dev->minor); + printk(KERN_INFO "comedi%d: dt282x: remove\n", dev->minor); free_resources(dev); @@ -1475,7 +1464,7 @@ static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2) devpriv->usedma = 0; if (!dma1 && !dma2) { - printk(" (no dma)"); + printk(KERN_ERR " (no dma)"); return 0; } @@ -1503,11 +1492,11 @@ static int dt282x_grab_dma(struct comedi_device *dev, int dma1, int dma2) devpriv->dma[0].buf = (void *)__get_free_page(GFP_KERNEL | GFP_DMA); devpriv->dma[1].buf = (void *)__get_free_page(GFP_KERNEL | GFP_DMA); if (!devpriv->dma[0].buf || !devpriv->dma[1].buf) { - printk(" can't get DMA memory"); + printk(KERN_ERR " can't get DMA memory"); return -ENOMEM; } - printk(" (dma=%d,%d)", dma1, dma2); + printk(KERN_INFO " (dma=%d,%d)", dma1, dma2); devpriv->usedma = 1; diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index bbbef790c8f6..ca687890fc12 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -314,9 +314,8 @@ static int dt3k_send_cmd(struct comedi_device *dev, unsigned int cmd) break; udelay(1); } - if ((status & DT3000_COMPLETION_MASK) == DT3000_NOERROR) { + if ((status & DT3000_COMPLETION_MASK) == DT3000_NOERROR) return 0; - } printk("dt3k_send_cmd() timeout/error status=0x%04x\n", status); @@ -359,9 +358,8 @@ static irqreturn_t dt3k_interrupt(int irq, void *d) struct comedi_subdevice *s; unsigned int status; - if (!dev->attached) { + if (!dev->attached) return IRQ_NONE; - } s = dev->subdevices + 0; status = readw(devpriv->io_addr + DPR_Intr_Flag); @@ -374,9 +372,8 @@ static irqreturn_t dt3k_interrupt(int irq, void *d) s->async->events |= COMEDI_CB_BLOCK; } - if (status & (DT3000_ADSWERR | DT3000_ADHWERR)) { + if (status & (DT3000_ADSWERR | DT3000_ADHWERR)) s->async->events |= COMEDI_CB_ERROR | COMEDI_CB_EOA; - } debug_n_ints++; if (debug_n_ints >= 10) { @@ -399,9 +396,8 @@ static void debug_intr_flags(unsigned int flags) int i; printk("dt3k: intr_flags:"); for (i = 0; i < 8; i++) { - if (flags & (1 << i)) { + if (flags & (1 << i)) printk(" %s", intr_flags[i]); - } } printk("\n"); } @@ -690,9 +686,8 @@ static int dt3k_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s, /* XXX docs don't explain how to select aref */ aref = CR_AREF(insn->chanspec); - for (i = 0; i < insn->n; i++) { + for (i = 0; i < insn->n; i++) data[i] = dt3k_readsingle(dev, SUBS_AI, chan, gain); - } return i; } @@ -720,9 +715,8 @@ static int dt3k_ao_insn_read(struct comedi_device *dev, unsigned int chan; chan = CR_CHAN(insn->chanspec); - for (i = 0; i < insn->n; i++) { + for (i = 0; i < insn->n; i++) data[i] = devpriv->ao_readback[chan]; - } return i; } @@ -911,9 +905,8 @@ static int dt3000_detach(struct comedi_device *dev) if (devpriv) { if (devpriv->pci_dev) { - if (devpriv->phys_addr) { + if (devpriv->phys_addr) comedi_pci_disable(devpriv->pci_dev); - } pci_dev_put(devpriv->pci_dev); } if (devpriv->io_addr) diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c index 80e192d2e77e..c8484aec657d 100644 --- a/drivers/staging/comedi/drivers/me_daq.c +++ b/drivers/staging/comedi/drivers/me_daq.c @@ -60,6 +60,7 @@ from http://www.comedi.org #define ME_DRIVER_NAME "me_daq" +#define PCI_VENDOR_ID_MEILHAUS 0x1402 #define ME2000_DEVICE_ID 0x2000 #define ME2600_DEVICE_ID 0x2600 diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 188f58042746..99d9985c5b37 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -76,7 +76,7 @@ void mite_init(void) for (pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); pcidev != NULL; pcidev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pcidev)) { - if (pcidev->vendor == PCI_VENDOR_ID_NATINST) { + if (pcidev->vendor == PCI_VENDOR_ID_NI) { unsigned i; mite = kzalloc(sizeof(*mite), GFP_KERNEL); diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index 9d5049f8fa85..999551f54c2a 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -27,8 +27,6 @@ #include <linux/pci.h> #include "../comedidev.h" -#define PCI_VENDOR_ID_NATINST 0x1093 - /* #define DEBUG_MITE */ #define PCIMIO_COMPAT diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c index 653b4c8700af..1fc76cc6a28e 100644 --- a/drivers/staging/comedi/drivers/ni_6527.c +++ b/drivers/staging/comedi/drivers/ni_6527.c @@ -107,10 +107,9 @@ static const struct ni6527_board ni6527_boards[] = { #define this_board ((const struct ni6527_board *)dev->board_ptr) static DEFINE_PCI_DEVICE_TABLE(ni6527_pci_table) = { - { - PCI_VENDOR_ID_NATINST, 0x2b10, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x2b20, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - 0} + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2b10)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2b20)}, + {0} }; MODULE_DEVICE_TABLE(pci, ni6527_pci_table); diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index 9a4fffe5655f..d793f5a4ac98 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -266,30 +266,29 @@ static inline unsigned ni_65xx_total_num_ports(const struct ni_65xx_board } static DEFINE_PCI_DEVICE_TABLE(ni_65xx_pci_table) = { - { - PCI_VENDOR_ID_NATINST, 0x1710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x7085, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x7086, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x7087, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x7088, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70a9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70c3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70c8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70c9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70cc, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70CD, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70d1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70d2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70d3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x7124, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x7125, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x7126, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x7127, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x7128, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x718b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x718c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x71c5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - 0} + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1710)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x7085)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x7086)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x7087)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x7088)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70a9)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70c3)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70c8)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70c9)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70cc)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70CD)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70d1)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70d2)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70d3)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x7124)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x7125)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x7126)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x7127)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x7128)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x718b)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x718c)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x71c5)}, + {0} }; MODULE_DEVICE_TABLE(pci, ni_65xx_pci_table); diff --git a/drivers/staging/comedi/drivers/ni_660x.c b/drivers/staging/comedi/drivers/ni_660x.c index 017630fb2424..6a6fae53ea0b 100644 --- a/drivers/staging/comedi/drivers/ni_660x.c +++ b/drivers/staging/comedi/drivers/ni_660x.c @@ -420,12 +420,11 @@ static const struct ni_660x_board ni_660x_boards[] = { #define NI_660X_MAX_NUM_COUNTERS (NI_660X_MAX_NUM_CHIPS * counters_per_chip) static DEFINE_PCI_DEVICE_TABLE(ni_660x_pci_table) = { - { - PCI_VENDOR_ID_NATINST, 0x2c60, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x1310, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x1360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x2cc0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - 0} + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2c60)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1310)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1360)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2cc0)}, + {0} }; MODULE_DEVICE_TABLE(pci, ni_660x_pci_table); diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c index 68221bfba5dd..44ae8368454d 100644 --- a/drivers/staging/comedi/drivers/ni_670x.c +++ b/drivers/staging/comedi/drivers/ni_670x.c @@ -47,8 +47,6 @@ Commands are not supported. #include "mite.h" -#define PCI_VENDOR_ID_NATINST 0x1093 - #define AO_VALUE_OFFSET 0x00 #define AO_CHAN_OFFSET 0x0c #define AO_STATUS_OFFSET 0x10 @@ -91,12 +89,9 @@ static const struct ni_670x_board ni_670x_boards[] = { }; static DEFINE_PCI_DEVICE_TABLE(ni_670x_pci_table) = { - { - PCI_VENDOR_ID_NATINST, 0x2c90, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x1920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - /*{ PCI_VENDOR_ID_NATINST, 0x0000, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },*/ - { - 0} + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2c90)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1920)}, + {0} }; MODULE_DEVICE_TABLE(pci, ni_670x_pci_table); diff --git a/drivers/staging/comedi/drivers/ni_at_ao.c b/drivers/staging/comedi/drivers/ni_at_ao.c index 3778565c1f6b..ce60224bb7bf 100644 --- a/drivers/staging/comedi/drivers/ni_at_ao.c +++ b/drivers/staging/comedi/drivers/ni_at_ao.c @@ -226,7 +226,7 @@ static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it) iobase = 0x1c0; ao_unipolar = it->options[3]; - printk("comedi%d: ni_at_ao: 0x%04lx", dev->minor, iobase); + printk(KERN_INFO "comedi%d: ni_at_ao: 0x%04lx", dev->minor, iobase); if (!request_region(iobase, ATAO_SIZE, "ni_at_ao")) { printk(" I/O port conflict\n"); @@ -283,14 +283,14 @@ static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it) atao_reset(dev); - printk("\n"); + printk(KERN_INFO "\n"); return 0; } static int atao_detach(struct comedi_device *dev) { - printk("comedi%d: atao: remove\n", dev->minor); + printk(KERN_INFO "comedi%d: atao: remove\n", dev->minor); if (dev->iobase) release_region(dev->iobase, ATAO_SIZE); diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c index 072bc4b62011..c6d95650a1d4 100644 --- a/drivers/staging/comedi/drivers/ni_daq_700.c +++ b/drivers/staging/comedi/drivers/ni_daq_700.c @@ -145,6 +145,7 @@ void subdev_700_interrupt(struct comedi_device *dev, struct comedi_subdevice *s) comedi_event(dev, s); } +EXPORT_SYMBOL(subdev_700_interrupt); static int subdev_700_cb(int dir, int port, int data, unsigned long arg) { @@ -326,6 +327,7 @@ int subdev_700_init(struct comedi_device *dev, struct comedi_subdevice *s, return 0; } +EXPORT_SYMBOL(subdev_700_init); int subdev_700_init_irq(struct comedi_device *dev, struct comedi_subdevice *s, int (*cb) (int, int, int, unsigned long), @@ -345,6 +347,7 @@ int subdev_700_init_irq(struct comedi_device *dev, struct comedi_subdevice *s, return 0; } +EXPORT_SYMBOL(subdev_700_init_irq); void subdev_700_cleanup(struct comedi_device *dev, struct comedi_subdevice *s) { @@ -353,11 +356,7 @@ void subdev_700_cleanup(struct comedi_device *dev, struct comedi_subdevice *s) kfree(s->private); } - -EXPORT_SYMBOL(subdev_700_init); -EXPORT_SYMBOL(subdev_700_init_irq); EXPORT_SYMBOL(subdev_700_cleanup); -EXPORT_SYMBOL(subdev_700_interrupt); static int dio700_attach(struct comedi_device *dev, struct comedi_devconfig *it) { diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index 558e525fed37..67c8a538802c 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -499,9 +499,8 @@ static struct comedi_driver driver_labpc = { #ifdef CONFIG_COMEDI_PCI static DEFINE_PCI_DEVICE_TABLE(labpc_pci_table) = { - { - PCI_VENDOR_ID_NATINST, 0x161, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - 0} + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x161)}, + {0} }; MODULE_DEVICE_TABLE(pci, labpc_pci_table); @@ -536,7 +535,7 @@ int labpc_common_attach(struct comedi_device *dev, unsigned long iobase, printk("\n"); if (iobase == 0) { - printk("io base address is zero!\n"); + printk(KERN_ERR "io base address is zero!\n"); return -EINVAL; } /* request io regions for isa boards */ diff --git a/drivers/staging/comedi/drivers/ni_pcidio.c b/drivers/staging/comedi/drivers/ni_pcidio.c index 9d337516409d..b126638d33b2 100644 --- a/drivers/staging/comedi/drivers/ni_pcidio.c +++ b/drivers/staging/comedi/drivers/ni_pcidio.c @@ -83,8 +83,6 @@ comedi_nonfree_firmware tarball available from http://www.comedi.org #define DPRINTK(format, args...) #endif -#define PCI_VENDOR_ID_NATINST 0x1093 - #define PCI_DIO_SIZE 4096 #define PCI_MITE_SIZE 4096 @@ -379,18 +377,17 @@ static const struct nidio_board nidio_boards[] = { #define this_board ((const struct nidio_board *)dev->board_ptr) static DEFINE_PCI_DEVICE_TABLE(ni_pcidio_pci_table) = { - { - PCI_VENDOR_ID_NATINST, 0x1150, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x1320, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x12b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x0160, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x1630, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x13c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x0400, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x1250, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x17d0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x1800, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - 0} + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1150)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1320)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x12b0)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x0160)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1630)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x13c0)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x0400)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1250)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x17d0)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1800)}, + {0} }; MODULE_DEVICE_TABLE(pci, ni_pcidio_pci_table); diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c index 24c8b8ed5b4c..577fda84190d 100644 --- a/drivers/staging/comedi/drivers/ni_pcimio.c +++ b/drivers/staging/comedi/drivers/ni_pcimio.c @@ -130,60 +130,59 @@ Bugs: /* The following two tables must be in the same order */ static DEFINE_PCI_DEVICE_TABLE(ni_pci_table) = { - { - PCI_VENDOR_ID_NATINST, 0x0162, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x1170, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x1180, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x1190, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x11b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x11c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x11d0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x1270, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x1330, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x1340, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x1350, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x14e0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x14f0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x1580, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x15b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x1880, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x1870, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x18b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x18c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x2410, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x2420, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x2430, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x2890, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x28c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x2a60, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x2a70, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x2a80, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x2ab0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x2b80, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x2b90, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x2c80, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x2ca0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70aa, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70ab, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70ac, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70af, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70b4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70b6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70b7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70b8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70bc, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70bd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70bf, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x70f2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x710d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x716c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x716d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x717f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x71bc, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - PCI_VENDOR_ID_NATINST, 0x717d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, { - 0} + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x0162)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1170)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1180)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1190)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x11b0)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x11c0)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x11d0)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1270)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1330)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1340)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1350)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x14e0)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x14f0)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1580)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x15b0)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1880)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x1870)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x18b0)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x18c0)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2410)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2420)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2430)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2890)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x28c0)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2a60)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2a70)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2a80)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2ab0)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2b80)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2b90)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2c80)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2ca0)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70aa)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70ab)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70ac)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70af)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70b0)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70b4)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70b6)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70b7)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70b8)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70bc)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70bd)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70bf)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70c0)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x70f2)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x710d)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x716c)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x716d)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x717f)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x71bc)}, + {PCI_DEVICE(PCI_VENDOR_ID_NI, 0x717d)}, + {0} }; MODULE_DEVICE_TABLE(pci, ni_pci_table); diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index aba57d93dd3d..490753b3d904 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -131,7 +131,8 @@ MODULE_DEVICE_TABLE(pci, skel_pci_table); /* this structure is for data unique to this hardware driver. If several hardware drivers keep similar information in this structure, - feel free to suggest moving the variable to the struct comedi_device struct. */ + feel free to suggest moving the variable to the struct comedi_device struct. + */ struct skel_private { int data; @@ -211,7 +212,7 @@ static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it) { struct comedi_subdevice *s; - printk("comedi%d: skel: ", dev->minor); + pr_info("comedi%d: skel: ", dev->minor); /* * If you can probe the device to determine what device in a series @@ -282,7 +283,7 @@ static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->type = COMEDI_SUBD_UNUSED; } - printk("attached\n"); + pr_info("attached\n"); return 0; } @@ -297,7 +298,7 @@ static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it) */ static int skel_detach(struct comedi_device *dev) { - printk("comedi%d: skel: remove\n", dev->minor); + pr_info("comedi%d: skel: remove\n", dev->minor); return 0; } @@ -336,7 +337,7 @@ static int skel_ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s, if (i == TIMEOUT) { /* printk() should be used instead of printk() * whenever the code can be called from real-time. */ - printk("timeout\n"); + pr_info("timeout\n"); return -ETIMEDOUT; } @@ -397,7 +398,8 @@ static int skel_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 && @@ -529,7 +531,7 @@ static int skel_ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, int i; int chan = CR_CHAN(insn->chanspec); - printk("skel_ao_winsn\n"); + pr_info("skel_ao_winsn\n"); /* Writing a list of values to an AO channel is probably not * very useful, but that's how the interface is defined. */ for (i = 0; i < insn->n; i++) { @@ -623,6 +625,7 @@ static int skel_dio_insn_config(struct comedi_device *dev, * as necessary. */ COMEDI_INITCLEANUP(driver_skel); -/* If you are writing a PCI driver you should use COMEDI_PCI_INITCLEANUP instead. -*/ +/* If you are writing a PCI driver you should use COMEDI_PCI_INITCLEANUP + * instead. + */ /* COMEDI_PCI_INITCLEANUP(driver_skel, skel_pci_table) */ diff --git a/drivers/staging/comedi/drivers/ssv_dnp.c b/drivers/staging/comedi/drivers/ssv_dnp.c index 17c92a57b0dd..18b0a83c4bbc 100644 --- a/drivers/staging/comedi/drivers/ssv_dnp.c +++ b/drivers/staging/comedi/drivers/ssv_dnp.c @@ -41,14 +41,14 @@ Status: unknown /* 0..3 remain unchanged! For details about Port C Mode Register see */ /* the remarks in dnp_insn_config() below. */ -#define CSCIR 0x22 /* Chip Setup and Control Index Register */ -#define CSCDR 0x23 /* Chip Setup and Control Data Register */ -#define PAMR 0xa5 /* Port A Mode Register */ -#define PADR 0xa9 /* Port A Data Register */ -#define PBMR 0xa4 /* Port B Mode Register */ -#define PBDR 0xa8 /* Port B Data Register */ -#define PCMR 0xa3 /* Port C Mode Register */ -#define PCDR 0xa7 /* Port C Data Register */ +#define CSCIR 0x22 /* Chip Setup and Control Index Register */ +#define CSCDR 0x23 /* Chip Setup and Control Data Register */ +#define PAMR 0xa5 /* Port A Mode Register */ +#define PADR 0xa9 /* Port A Data Register */ +#define PBMR 0xa4 /* Port B Mode Register */ +#define PBDR 0xa8 /* Port B Data Register */ +#define PCMR 0xa3 /* Port C Mode Register */ +#define PCDR 0xa7 /* Port C Data Register */ /* This data structure holds information about the supported boards -------- */ @@ -59,8 +59,9 @@ struct dnp_board { int have_dio; }; -static const struct dnp_board dnp_boards[] = { /* we only support one DNP 'board' */ - { /* variant at the moment */ +/* We only support one DNP 'board' variant at the moment */ +static const struct dnp_board dnp_boards[] = { +{ .name = "dnp-1486", .ai_chans = 16, .ai_bits = 12, @@ -80,9 +81,9 @@ struct dnp_private_data { #define devpriv ((dnp_private *)dev->private) /* ------------------------------------------------------------------------- */ -/* The struct comedi_driver structure tells the Comedi core module which functions */ -/* to call to configure/deconfigure (attach/detach) the board, and also */ -/* about the kernel module that contains the device code. */ +/* The struct comedi_driver structure tells the Comedi core module which */ +/* functions to call to configure/deconfigure (attach/detach) the board, and */ +/* also about the kernel module that contains the device code. */ /* */ /* In the following section we define the API of this driver. */ /* ------------------------------------------------------------------------- */ @@ -97,7 +98,7 @@ static struct comedi_driver driver_dnp = { .detach = dnp_detach, .board_name = &dnp_boards[0].name, /* only necessary for non-PnP devs */ - .offset = sizeof(struct dnp_board), /* like ISA-PnP, PCI or PCMCIA. */ + .offset = sizeof(struct dnp_board), /* like ISA-PnP, PCI or PCMCIA */ .num_names = ARRAY_SIZE(dnp_boards), }; @@ -122,28 +123,30 @@ static int dnp_attach(struct comedi_device *dev, struct comedi_devconfig *it) struct comedi_subdevice *s; - printk("comedi%d: dnp: ", dev->minor); + printk(KERN_INFO "comedi%d: dnp: ", dev->minor); - /* Autoprobing: this should find out which board we have. Currently only */ - /* the 1486 board is supported and autoprobing is not implemented :-) */ + /* Autoprobing: this should find out which board we have. Currently */ + /* only the 1486 board is supported and autoprobing is not */ + /* implemented :-) */ /* dev->board_ptr = dnp_probe(dev); */ - /* Initialize the name of the board. We can use the "thisboard" macro now. */ + /* Initialize the name of the board. */ + /* We can use the "thisboard" macro now. */ dev->board_name = thisboard->name; - /* Allocate the private structure area. alloc_private() is a convenient */ - /* macro defined in comedidev.h. */ + /* Allocate the private structure area. alloc_private() is a */ + /* convenient macro defined in comedidev.h. */ if (alloc_private(dev, sizeof(struct dnp_private_data)) < 0) return -ENOMEM; - /* Allocate the subdevice structures. alloc_subdevice() is a convenient */ - /* macro defined in comedidev.h. */ + /* Allocate the subdevice structures. alloc_subdevice() is a */ + /* convenient macro defined in comedidev.h. */ if (alloc_subdevices(dev, 1) < 0) return -ENOMEM; s = dev->subdevices + 0; - /* digital i/o subdevice */ + /* digital i/o subdevice */ s->type = COMEDI_SUBD_DIO; s->subdev_flags = SDF_READABLE | SDF_WRITABLE; s->n_chan = 20; @@ -158,7 +161,7 @@ static int dnp_attach(struct comedi_device *dev, struct comedi_devconfig *it) * allocated for the primary 8259, so we don't need to allocate them * ourselves. */ - /* configure all ports as input (default) */ + /* configure all ports as input (default) */ outb(PAMR, CSCIR); outb(0x00, CSCDR); outb(PBMR, CSCIR); @@ -181,7 +184,7 @@ static int dnp_attach(struct comedi_device *dev, struct comedi_devconfig *it) static int dnp_detach(struct comedi_device *dev) { - /* configure all ports as input (default) */ + /* configure all ports as input (default) */ outb(PAMR, CSCIR); outb(0x00, CSCDR); outb(PBMR, CSCIR); @@ -189,8 +192,8 @@ static int dnp_detach(struct comedi_device *dev) outb(PCMR, CSCIR); outb((inb(CSCDR) & 0xAA), CSCDR); - /* announce that we are finished */ - printk("comedi%d: dnp: remove\n", dev->minor); + /* announce that we are finished */ + printk(KERN_INFO "comedi%d: dnp: remove\n", dev->minor); return 0; @@ -210,12 +213,12 @@ static int dnp_dio_insn_bits(struct comedi_device *dev, if (insn->n != 2) return -EINVAL; /* insn uses data[0] and data[1] */ - /* The insn data is a mask in data[0] and the new data in data[1], each */ - /* channel cooresponding to a bit. */ + /* The insn data is a mask in data[0] and the new data in data[1], */ + /* each channel cooresponding to a bit. */ - /* Ports A and B are straight forward: each bit corresponds to an output */ - /* pin with the same order. Port C is different: bits 0...3 correspond to */ - /* bits 4...7 of the output register (PCDR). */ + /* Ports A and B are straight forward: each bit corresponds to an */ + /* output pin with the same order. Port C is different: bits 0...3 */ + /* correspond to bits 4...7 of the output register (PCDR). */ if (data[0]) { @@ -235,7 +238,7 @@ static int dnp_dio_insn_bits(struct comedi_device *dev, | (u8) ((data[1] & 0x0F0000) >> 12), CSCDR); } - /* on return, data[1] contains the value of the digital input lines. */ + /* on return, data[1] contains the value of the digital input lines. */ outb(PADR, CSCIR); data[0] = inb(CSCDR); outb(PBDR, CSCIR); @@ -260,7 +263,8 @@ static int dnp_dio_insn_config(struct comedi_device *dev, u8 register_buffer; - int chan = CR_CHAN(insn->chanspec); /* reduces chanspec to lower 16 bits */ + /* reduces chanspec to lower 16 bits */ + int chan = CR_CHAN(insn->chanspec); switch (data[0]) { case INSN_CONFIG_DIO_OUTPUT: @@ -275,11 +279,11 @@ static int dnp_dio_insn_config(struct comedi_device *dev, return -EINVAL; break; } - /* Test: which port does the channel belong to? */ + /* Test: which port does the channel belong to? */ - /* We have to pay attention with port C: this is the meaning of PCMR: */ - /* Bit in PCMR: 7 6 5 4 3 2 1 0 */ - /* Corresponding port C pin: d 3 d 2 d 1 d 0 d= don't touch */ + /* We have to pay attention with port C: this is the meaning of PCMR: */ + /* Bit in PCMR: 7 6 5 4 3 2 1 0 */ + /* Corresponding port C pin: d 3 d 2 d 1 d 0 d= don't touch */ if ((chan >= 0) && (chan <= 7)) { /* this is port A */ @@ -289,8 +293,8 @@ static int dnp_dio_insn_config(struct comedi_device *dev, chan -= 8; outb(PBMR, CSCIR); } else if ((chan >= 16) && (chan <= 19)) { - /* this is port C; multiplication with 2 brings bits into correct */ - /* position for PCMR! */ + /* this is port C; multiplication with 2 brings bits into */ + /* correct position for PCMR! */ chan -= 16; chan *= 2; outb(PCMR, CSCIR); @@ -298,7 +302,7 @@ static int dnp_dio_insn_config(struct comedi_device *dev, return -EINVAL; } - /* read 'old' direction of the port and set bits (out=1, in=0) */ + /* read 'old' direction of the port and set bits (out=1, in=0) */ register_buffer = inb(CSCDR); if (data[0] == COMEDI_OUTPUT) register_buffer |= (1 << chan); diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c index e89b81812538..05b1973ea35f 100644 --- a/drivers/staging/comedi/drivers/usbduxfast.c +++ b/drivers/staging/comedi/drivers/usbduxfast.c @@ -177,8 +177,8 @@ struct usbduxfastsub_s { int16_t *insnBuffer; /* input buffer for single insn */ int ifnum; /* interface number */ struct usb_interface *interface; /* interface structure */ - struct comedi_device *comedidev; /* comedi device for the interrupt - context */ + /* comedi device for the interrupt context */ + struct comedi_device *comedidev; short int ai_cmd_running; /* asynchronous command is running */ short int ai_continous; /* continous aquisition */ long int ai_sample_count; /* number of samples to acquire */ @@ -271,7 +271,8 @@ static int usbduxfast_ai_stop(struct usbduxfastsub_s *udfs, int do_unlink) udfs->ai_cmd_running = 0; if (do_unlink) - ret = usbduxfastsub_unlink_InURBs(udfs); /* stop aquistion */ + /* stop aquistion */ + ret = usbduxfastsub_unlink_InURBs(udfs); return ret; } @@ -451,13 +452,15 @@ static int usbduxfastsub_start(struct usbduxfastsub_s *udfs) /* 7f92 to zero */ local_transfer_buffer[0] = 0; - ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0), USBDUXFASTSUB_FIRMWARE, /* bRequest, "Firmware" */ - VENDOR_DIR_OUT, /* bmRequestType */ - USBDUXFASTSUB_CPUCS, /* Value */ - 0x0000, /* Index */ - local_transfer_buffer, /* address of the transfer buffer */ - 1, /* Length */ - EZTIMEOUT); /* Timeout */ + /* bRequest, "Firmware" */ + ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0), USBDUXFASTSUB_FIRMWARE, + VENDOR_DIR_OUT, /* bmRequestType */ + USBDUXFASTSUB_CPUCS, /* Value */ + 0x0000, /* Index */ + /* address of the transfer buffer */ + local_transfer_buffer, + 1, /* Length */ + EZTIMEOUT); /* Timeout */ if (ret < 0) { printk("comedi_: usbduxfast_: control msg failed (start)\n"); return ret; @@ -473,7 +476,8 @@ static int usbduxfastsub_stop(struct usbduxfastsub_s *udfs) /* 7f92 to one */ local_transfer_buffer[0] = 1; - ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0), USBDUXFASTSUB_FIRMWARE, /* bRequest, "Firmware" */ + /* bRequest, "Firmware" */ + ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0), USBDUXFASTSUB_FIRMWARE, VENDOR_DIR_OUT, /* bmRequestType */ USBDUXFASTSUB_CPUCS, /* Value */ 0x0000, /* Index */ @@ -499,13 +503,15 @@ static int usbduxfastsub_upload(struct usbduxfastsub_s *udfs, printk(KERN_DEBUG " to addr %d, first byte=%d.\n", startAddr, local_transfer_buffer[0]); #endif - ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0), USBDUXFASTSUB_FIRMWARE, /* brequest, firmware */ - VENDOR_DIR_OUT, /* bmRequestType */ - startAddr, /* value */ - 0x0000, /* index */ - local_transfer_buffer, /* our local safe buffer */ - len, /* length */ - EZTIMEOUT); /* timeout */ + /* brequest, firmware */ + ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0), USBDUXFASTSUB_FIRMWARE, + VENDOR_DIR_OUT, /* bmRequestType */ + startAddr, /* value */ + 0x0000, /* index */ + /* our local safe buffer */ + local_transfer_buffer, + len, /* length */ + EZTIMEOUT); /* timeout */ #ifdef CONFIG_COMEDI_DEBUG printk(KERN_DEBUG "comedi_: usbduxfast: result=%d\n", ret); @@ -1347,7 +1353,7 @@ static int usbduxfast_ai_insn_read(struct comedi_device *dev, #define FIRMWARE_MAX_LEN 0x2000 static int firmwareUpload(struct usbduxfastsub_s *usbduxfastsub, - const u8 * firmwareBinary, int sizeFirmware) + const u8 *firmwareBinary, int sizeFirmware) { int ret; uint8_t *fwBuf; diff --git a/drivers/staging/comedi/kcomedilib/Makefile b/drivers/staging/comedi/kcomedilib/Makefile index ffcc9ad32adb..006aa1ce4a13 100644 --- a/drivers/staging/comedi/kcomedilib/Makefile +++ b/drivers/staging/comedi/kcomedilib/Makefile @@ -1,8 +1,6 @@ obj-$(CONFIG_COMEDI) += kcomedilib.o kcomedilib-objs := \ - data.o \ - ksyms.o \ dio.o \ kcomedilib_main.o \ get.o diff --git a/drivers/staging/comedi/kcomedilib/data.c b/drivers/staging/comedi/kcomedilib/data.c deleted file mode 100644 index aefc41ab7c46..000000000000 --- a/drivers/staging/comedi/kcomedilib/data.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - kcomedilib/data.c - implements comedi_data_*() functions - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 2000 David A. Schleef <ds@schleef.org> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include "../comedi.h" -#include "../comedilib.h" -#include "../comedidev.h" - -#include <linux/string.h> -#include <linux/delay.h> - -int comedi_data_write(void *dev, unsigned int subdev, unsigned int chan, - unsigned int range, unsigned int aref, unsigned int data) -{ - struct comedi_insn insn; - - memset(&insn, 0, sizeof(insn)); - insn.insn = INSN_WRITE; - insn.n = 1; - insn.data = &data; - insn.subdev = subdev; - insn.chanspec = CR_PACK(chan, range, aref); - - return comedi_do_insn(dev, &insn); -} - -int comedi_data_read(void *dev, unsigned int subdev, unsigned int chan, - unsigned int range, unsigned int aref, unsigned int *data) -{ - struct comedi_insn insn; - - memset(&insn, 0, sizeof(insn)); - insn.insn = INSN_READ; - insn.n = 1; - insn.data = data; - insn.subdev = subdev; - insn.chanspec = CR_PACK(chan, range, aref); - - return comedi_do_insn(dev, &insn); -} - -int comedi_data_read_hint(void *dev, unsigned int subdev, - unsigned int chan, unsigned int range, - unsigned int aref) -{ - struct comedi_insn insn; - unsigned int dummy_data; - - memset(&insn, 0, sizeof(insn)); - insn.insn = INSN_READ; - insn.n = 0; - insn.data = &dummy_data; - insn.subdev = subdev; - insn.chanspec = CR_PACK(chan, range, aref); - - return comedi_do_insn(dev, &insn); -} - -int comedi_data_read_delayed(void *dev, unsigned int subdev, - unsigned int chan, unsigned int range, - unsigned int aref, unsigned int *data, - unsigned int nano_sec) -{ - int retval; - - retval = comedi_data_read_hint(dev, subdev, chan, range, aref); - if (retval < 0) - return retval; - - udelay((nano_sec + 999) / 1000); - - return comedi_data_read(dev, subdev, chan, range, aref, data); -} diff --git a/drivers/staging/comedi/kcomedilib/dio.c b/drivers/staging/comedi/kcomedilib/dio.c index 30192f3c4652..e37aa5308141 100644 --- a/drivers/staging/comedi/kcomedilib/dio.c +++ b/drivers/staging/comedi/kcomedilib/dio.c @@ -25,6 +25,7 @@ #include "../comedilib.h" #include <linux/string.h> +#include <linux/module.h> int comedi_dio_config(void *dev, unsigned int subdev, unsigned int chan, unsigned int io) @@ -40,6 +41,7 @@ int comedi_dio_config(void *dev, unsigned int subdev, unsigned int chan, return comedi_do_insn(dev, &insn); } +EXPORT_SYMBOL(comedi_dio_config); int comedi_dio_read(void *dev, unsigned int subdev, unsigned int chan, unsigned int *val) @@ -93,3 +95,4 @@ int comedi_dio_bitfield(void *dev, unsigned int subdev, unsigned int mask, return ret; } +EXPORT_SYMBOL(comedi_dio_bitfield); diff --git a/drivers/staging/comedi/kcomedilib/get.c b/drivers/staging/comedi/kcomedilib/get.c index 6d8418715253..99ab27ab8054 100644 --- a/drivers/staging/comedi/kcomedilib/get.c +++ b/drivers/staging/comedi/kcomedilib/get.c @@ -26,48 +26,6 @@ #include "../comedilib.h" #include "../comedidev.h" -int comedi_get_n_subdevices(void *d) -{ - struct comedi_device *dev = (struct comedi_device *)d; - - return dev->n_subdevices; -} - -int comedi_get_version_code(void *d) -{ - return COMEDI_VERSION_CODE; -} - -const char *comedi_get_driver_name(void *d) -{ - struct comedi_device *dev = (struct comedi_device *)d; - - return dev->driver->driver_name; -} - -const char *comedi_get_board_name(void *d) -{ - struct comedi_device *dev = (struct comedi_device *)d; - - return dev->board_name; -} - -int comedi_get_subdevice_type(void *d, unsigned int subdevice) -{ - struct comedi_device *dev = (struct comedi_device *)d; - struct comedi_subdevice *s = dev->subdevices + subdevice; - - return s->type; -} - -unsigned int comedi_get_subdevice_flags(void *d, unsigned int subdevice) -{ - struct comedi_device *dev = (struct comedi_device *)d; - struct comedi_subdevice *s = dev->subdevices + subdevice; - - return s->subdev_flags; -} - int comedi_find_subdevice_by_type(void *d, int type, unsigned int subd) { struct comedi_device *dev = (struct comedi_device *)d; @@ -81,6 +39,7 @@ int comedi_find_subdevice_by_type(void *d, int type, unsigned int subd) } return -1; } +EXPORT_SYMBOL(comedi_find_subdevice_by_type); int comedi_get_n_channels(void *d, unsigned int subdevice) { @@ -89,205 +48,4 @@ int comedi_get_n_channels(void *d, unsigned int subdevice) return s->n_chan; } - -int comedi_get_len_chanlist(void *d, unsigned int subdevice) -{ - struct comedi_device *dev = (struct comedi_device *)d; - struct comedi_subdevice *s = dev->subdevices + subdevice; - - return s->len_chanlist; -} - -unsigned int comedi_get_maxdata(void *d, unsigned int subdevice, - unsigned int chan) -{ - struct comedi_device *dev = (struct comedi_device *)d; - struct comedi_subdevice *s = dev->subdevices + subdevice; - - if (s->maxdata_list) - return s->maxdata_list[chan]; - - return s->maxdata; -} - -#ifdef KCOMEDILIB_DEPRECATED -int comedi_get_rangetype(void *d, unsigned int subdevice, unsigned int chan) -{ - struct comedi_device *dev = (struct comedi_device *)d; - struct comedi_subdevice *s = dev->subdevices + subdevice; - int ret; - - if (s->range_table_list) { - ret = s->range_table_list[chan]->length; - } else { - ret = s->range_table->length; - } - - ret = ret | (dev->minor << 28) | (subdevice << 24) | (chan << 16); - - return ret; -} -#endif - -int comedi_get_n_ranges(void *d, unsigned int subdevice, unsigned int chan) -{ - struct comedi_device *dev = (struct comedi_device *)d; - struct comedi_subdevice *s = dev->subdevices + subdevice; - int ret; - - if (s->range_table_list) { - ret = s->range_table_list[chan]->length; - } else { - ret = s->range_table->length; - } - - return ret; -} - -/* - * ALPHA (non-portable) -*/ -int comedi_get_krange(void *d, unsigned int subdevice, unsigned int chan, - unsigned int range, struct comedi_krange *krange) -{ - struct comedi_device *dev = (struct comedi_device *)d; - struct comedi_subdevice *s = dev->subdevices + subdevice; - const struct comedi_lrange *lr; - - if (s->range_table_list) { - lr = s->range_table_list[chan]; - } else { - lr = s->range_table; - } - if (range >= lr->length) - return -EINVAL; - - memcpy(krange, lr->range + range, sizeof(struct comedi_krange)); - - return 0; -} - -/* - * ALPHA (may be renamed) -*/ -unsigned int comedi_get_buf_head_pos(void *d, unsigned int subdevice) -{ - struct comedi_device *dev = (struct comedi_device *)d; - struct comedi_subdevice *s = dev->subdevices + subdevice; - struct comedi_async *async; - - async = s->async; - if (async == NULL) - return 0; - - return async->buf_write_count; -} - -int comedi_get_buffer_contents(void *d, unsigned int subdevice) -{ - struct comedi_device *dev = (struct comedi_device *)d; - struct comedi_subdevice *s = dev->subdevices + subdevice; - struct comedi_async *async; - unsigned int num_bytes; - - if (subdevice >= dev->n_subdevices) - return -1; - async = s->async; - if (async == NULL) - return 0; - num_bytes = comedi_buf_read_n_available(s->async); - return num_bytes; -} - -/* - * ALPHA -*/ -int comedi_set_user_int_count(void *d, unsigned int subdevice, - unsigned int buf_user_count) -{ - struct comedi_device *dev = (struct comedi_device *)d; - struct comedi_subdevice *s = dev->subdevices + subdevice; - struct comedi_async *async; - int num_bytes; - - async = s->async; - if (async == NULL) - return -1; - - num_bytes = buf_user_count - async->buf_read_count; - if (num_bytes < 0) - return -1; - comedi_buf_read_alloc(async, num_bytes); - comedi_buf_read_free(async, num_bytes); - - return 0; -} - -int comedi_mark_buffer_read(void *d, unsigned int subdevice, - unsigned int num_bytes) -{ - struct comedi_device *dev = (struct comedi_device *)d; - struct comedi_subdevice *s = dev->subdevices + subdevice; - struct comedi_async *async; - - if (subdevice >= dev->n_subdevices) - return -1; - async = s->async; - if (async == NULL) - return -1; - - comedi_buf_read_alloc(async, num_bytes); - comedi_buf_read_free(async, num_bytes); - - return 0; -} - -int comedi_mark_buffer_written(void *d, unsigned int subdevice, - unsigned int num_bytes) -{ - struct comedi_device *dev = (struct comedi_device *)d; - struct comedi_subdevice *s = dev->subdevices + subdevice; - struct comedi_async *async; - int bytes_written; - - if (subdevice >= dev->n_subdevices) - return -1; - async = s->async; - if (async == NULL) - return -1; - bytes_written = comedi_buf_write_alloc(async, num_bytes); - comedi_buf_write_free(async, bytes_written); - if (bytes_written != num_bytes) - return -1; - return 0; -} - -int comedi_get_buffer_size(void *d, unsigned int subdev) -{ - struct comedi_device *dev = (struct comedi_device *)d; - struct comedi_subdevice *s = dev->subdevices + subdev; - struct comedi_async *async; - - if (subdev >= dev->n_subdevices) - return -1; - async = s->async; - if (async == NULL) - return 0; - - return async->prealloc_bufsz; -} - -int comedi_get_buffer_offset(void *d, unsigned int subdevice) -{ - struct comedi_device *dev = (struct comedi_device *)d; - struct comedi_subdevice *s = dev->subdevices + subdevice; - struct comedi_async *async; - - if (subdevice >= dev->n_subdevices) - return -1; - async = s->async; - if (async == NULL) - return 0; - - return async->buf_read_ptr; -} +EXPORT_SYMBOL(comedi_get_n_channels); diff --git a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c index 288fef4fcbcc..32c7bbb8d78a 100644 --- a/drivers/staging/comedi/kcomedilib/kcomedilib_main.c +++ b/drivers/staging/comedi/kcomedilib/kcomedilib_main.c @@ -31,7 +31,7 @@ #include <linux/delay.h> #include <linux/ioport.h> #include <linux/mm.h> -#include <asm/io.h> +#include <linux/io.h> #include "../comedi.h" #include "../comedilib.h" @@ -68,6 +68,7 @@ void *comedi_open(const char *filename) return (void *)dev; } +EXPORT_SYMBOL(comedi_open); void *comedi_open_old(unsigned int minor) { @@ -96,6 +97,7 @@ int comedi_close(void *d) return 0; } +EXPORT_SYMBOL(comedi_close); int comedi_loglevel(int newlevel) { @@ -104,7 +106,7 @@ int comedi_loglevel(int newlevel) void comedi_perror(const char *message) { - printk("%s: unknown error\n", message); + printk(KERN_ERR "%s: unknown error\n", message); } char *comedi_strerror(int err) @@ -251,7 +253,7 @@ int comedi_do_insn(void *d, struct comedi_insn *insn) /* XXX check lock */ - ret = check_chanlist(s, 1, &insn->chanspec); + ret = comedi_check_chanlist(s, 1, &insn->chanspec); if (ret < 0) { printk("bad chanspec\n"); ret = -EINVAL; diff --git a/drivers/staging/comedi/kcomedilib/ksyms.c b/drivers/staging/comedi/kcomedilib/ksyms.c deleted file mode 100644 index 8bf4471ce6c1..000000000000 --- a/drivers/staging/comedi/kcomedilib/ksyms.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - comedi/kcomedilib/ksyms.c - a comedlib interface for kernel modules - - COMEDI - Linux Control and Measurement Device Interface - Copyright (C) 1997-2001 David A. Schleef <ds@schleef.org> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This 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., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include "../comedi.h" -#include "../comedilib.h" -#include "../comedidev.h" - -#include <linux/module.h> - -#include <linux/errno.h> -#include <linux/kernel.h> -#include <linux/sched.h> -#include <linux/fcntl.h> -#include <linux/delay.h> -#include <linux/ioport.h> -#include <linux/mm.h> - -/* functions specific to kcomedilib */ - -EXPORT_SYMBOL(comedi_register_callback); -EXPORT_SYMBOL(comedi_get_krange); -EXPORT_SYMBOL(comedi_get_buf_head_pos); -EXPORT_SYMBOL(comedi_set_user_int_count); -EXPORT_SYMBOL(comedi_map); -EXPORT_SYMBOL(comedi_unmap); - -/* This list comes from user-space comedilib, to show which - * functions are not ported yet. */ - -EXPORT_SYMBOL(comedi_open); -EXPORT_SYMBOL(comedi_close); - -/* logging */ -EXPORT_SYMBOL(comedi_loglevel); -EXPORT_SYMBOL(comedi_perror); -EXPORT_SYMBOL(comedi_strerror); -/* EXPORT_SYMBOL(comedi_errno); */ -EXPORT_SYMBOL(comedi_fileno); - -/* device queries */ -EXPORT_SYMBOL(comedi_get_n_subdevices); -EXPORT_SYMBOL(comedi_get_version_code); -EXPORT_SYMBOL(comedi_get_driver_name); -EXPORT_SYMBOL(comedi_get_board_name); - -/* subdevice queries */ -EXPORT_SYMBOL(comedi_get_subdevice_type); -EXPORT_SYMBOL(comedi_find_subdevice_by_type); -EXPORT_SYMBOL(comedi_get_subdevice_flags); -EXPORT_SYMBOL(comedi_get_n_channels); -/* -* EXPORT_SYMBOL(comedi_range_is_chan_specific); -* EXPORT_SYMBOL(comedi_maxdata_is_chan_specific); -*/ - -/* channel queries */ -EXPORT_SYMBOL(comedi_get_maxdata); -#ifdef KCOMEDILIB_DEPRECATED -EXPORT_SYMBOL(comedi_get_rangetype); -#endif -EXPORT_SYMBOL(comedi_get_n_ranges); -/* EXPORT_SYMBOL(comedi_find_range); */ - -/* buffer queries */ -EXPORT_SYMBOL(comedi_get_buffer_size); -/* -* EXPORT_SYMBOL(comedi_get_max_buffer_size); -* EXPORT_SYMBOL(comedi_set_buffer_size); -*/ -EXPORT_SYMBOL(comedi_get_buffer_contents); -EXPORT_SYMBOL(comedi_get_buffer_offset); - -/* low-level stuff */ -/* -* EXPORT_SYMBOL(comedi_trigger); EXPORT_SYMBOL(comedi_do_insnlist); -*/ -EXPORT_SYMBOL(comedi_do_insn); -EXPORT_SYMBOL(comedi_lock); -EXPORT_SYMBOL(comedi_unlock); - -/* physical units */ -/* -* EXPORT_SYMBOL(comedi_to_phys); EXPORT_SYMBOL(comedi_from_phys); -*/ - -/* synchronous stuff */ -EXPORT_SYMBOL(comedi_data_read); -EXPORT_SYMBOL(comedi_data_read_hint); -EXPORT_SYMBOL(comedi_data_read_delayed); -EXPORT_SYMBOL(comedi_data_write); -EXPORT_SYMBOL(comedi_dio_config); -EXPORT_SYMBOL(comedi_dio_read); -EXPORT_SYMBOL(comedi_dio_write); -EXPORT_SYMBOL(comedi_dio_bitfield); - -/* slowly varying stuff */ -/* -* EXPORT_SYMBOL(comedi_sv_init); EXPORT_SYMBOL(comedi_sv_update); -* EXPORT_SYMBOL(comedi_sv_measure); -*/ - -/* commands */ -/* -* EXPORT_SYMBOL(comedi_get_cmd_src_mask); -* EXPORT_SYMBOL(comedi_get_cmd_generic_timed); -*/ -EXPORT_SYMBOL(comedi_cancel); -EXPORT_SYMBOL(comedi_command); -EXPORT_SYMBOL(comedi_command_test); -EXPORT_SYMBOL(comedi_poll); - -/* buffer configuration */ -EXPORT_SYMBOL(comedi_mark_buffer_read); -EXPORT_SYMBOL(comedi_mark_buffer_written); - -/* EXPORT_SYMBOL(comedi_get_range); */ -EXPORT_SYMBOL(comedi_get_len_chanlist); - -/* deprecated */ -/* -* EXPORT_SYMBOL(comedi_get_timer); -* EXPORT_SYMBOL(comedi_timed_1chan); -*/ - -/* alpha */ -/* EXPORT_SYMBOL(comedi_set_global_oor_behavior); */ diff --git a/drivers/staging/comedi/pci_ids.h b/drivers/staging/comedi/pci_ids.h deleted file mode 100644 index d979aa8e396b..000000000000 --- a/drivers/staging/comedi/pci_ids.h +++ /dev/null @@ -1,31 +0,0 @@ -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - ***************************************************************************/ - -#ifndef __COMPAT_LINUX_PCI_IDS_H -#define __COMPAT_LINUX_PCI_IDS_H - -#include <linux/pci_ids.h> - -#ifndef PCI_VENDOR_ID_AMCC -#define PCI_VENDOR_ID_AMCC 0x10e8 -#endif - -#ifndef PCI_VENDOR_ID_CBOARDS -#define PCI_VENDOR_ID_CBOARDS 0x1307 -#endif - -#ifndef PCI_VENDOR_ID_QUANCOM -#define PCI_VENDOR_ID_QUANCOM 0x8008 -#endif - -#ifndef PCI_DEVICE_ID_QUANCOM_GPIB -#define PCI_DEVICE_ID_QUANCOM_GPIB 0x3302 -#endif - -#endif /* __COMPAT_LINUX_PCI_IDS_H */ diff --git a/drivers/staging/comedi/proc.c b/drivers/staging/comedi/proc.c index 5a22fe62c400..c0035cb759aa 100644 --- a/drivers/staging/comedi/proc.c +++ b/drivers/staging/comedi/proc.c @@ -30,15 +30,11 @@ #define __NO_VERSION__ #include "comedidev.h" +#include "comedi_fops.h" #include <linux/proc_fs.h> /* #include <linux/string.h> */ int comedi_read_procmem(char *buf, char **start, off_t offset, int len, - int *eof, void *data); - -extern struct comedi_driver *comedi_drivers; - -int comedi_read_procmem(char *buf, char **start, off_t offset, int len, int *eof, void *data) { int i; @@ -49,7 +45,8 @@ int comedi_read_procmem(char *buf, char **start, off_t offset, int len, l += sprintf(buf + l, "comedi version " COMEDI_RELEASE "\n" "format string: %s\n", - "\"%2d: %-20s %-20s %4d\",i,driver_name,board_name,n_subdevices"); + "\"%2d: %-20s %-20s %4d\", i, " + "driver_name, board_name, n_subdevices"); for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++) { struct comedi_device_file_info *dev_file_info = diff --git a/drivers/staging/comedi/range.c b/drivers/staging/comedi/range.c index 8313dfcb6732..6b03a69762a4 100644 --- a/drivers/staging/comedi/range.c +++ b/drivers/staging/comedi/range.c @@ -22,14 +22,20 @@ */ #include "comedidev.h" -#include <asm/uaccess.h> +#include <linux/uaccess.h> const struct comedi_lrange range_bipolar10 = { 1, {BIP_RANGE(10)} }; const struct comedi_lrange range_bipolar5 = { 1, {BIP_RANGE(5)} }; const struct comedi_lrange range_bipolar2_5 = { 1, {BIP_RANGE(2.5)} }; const struct comedi_lrange range_unipolar10 = { 1, {UNI_RANGE(10)} }; const struct comedi_lrange range_unipolar5 = { 1, {UNI_RANGE(5)} }; -const struct comedi_lrange range_unknown = { 1, {{0, 1000000, UNIT_none}} }; +const struct comedi_lrange range_unknown = { 1, {{0, 1000000, UNIT_none} } }; +EXPORT_SYMBOL(range_bipolar10); +EXPORT_SYMBOL(range_bipolar5); +EXPORT_SYMBOL(range_bipolar2_5); +EXPORT_SYMBOL(range_unipolar10); +EXPORT_SYMBOL(range_unipolar5); +EXPORT_SYMBOL(range_unknown); /* COMEDI_RANGEINFO @@ -120,7 +126,8 @@ static int aref_invalid(struct comedi_subdevice *s, unsigned int chanspec) This function checks each element in a channel/gain list to make make sure it is valid. */ -int check_chanlist(struct comedi_subdevice *s, int n, unsigned int *chanlist) +int comedi_check_chanlist(struct comedi_subdevice *s, int n, + unsigned int *chanlist) { int i; int chan; @@ -130,14 +137,10 @@ int check_chanlist(struct comedi_subdevice *s, int n, unsigned int *chanlist) if (CR_CHAN(chanlist[i]) >= s->n_chan || CR_RANGE(chanlist[i]) >= s->range_table->length || aref_invalid(s, chanlist[i])) { - printk - ("bad chanlist[%d]=0x%08x n_chan=%d range length=%d\n", - i, chanlist[i], s->n_chan, - s->range_table->length); -#if 0 - for (i = 0; i < n; i++) - printk("[%d]=0x%08x\n", i, chanlist[i]); -#endif + printk(KERN_ERR "bad chanlist[%d]=0x%08x " + "in_chan=%d range length=%d\n", i, + chanlist[i], s->n_chan, + s->range_table->length); return -EINVAL; } } else if (s->range_table_list) { @@ -147,14 +150,15 @@ int check_chanlist(struct comedi_subdevice *s, int n, unsigned int *chanlist) CR_RANGE(chanlist[i]) >= s->range_table_list[chan]->length || aref_invalid(s, chanlist[i])) { - printk("bad chanlist[%d]=0x%08x\n", i, - chanlist[i]); + printk(KERN_ERR "bad chanlist[%d]=0x%08x\n", + i, chanlist[i]); return -EINVAL; } } } else { - printk("comedi: (bug) no range type list!\n"); + printk(KERN_ERR "comedi: (bug) no range type list!\n"); return -EINVAL; } return 0; } +EXPORT_SYMBOL(comedi_check_chanlist); diff --git a/drivers/staging/comedi/wrapper.h b/drivers/staging/comedi/wrapper.h deleted file mode 100644 index 77fc673900e9..000000000000 --- a/drivers/staging/comedi/wrapper.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - linux/wrapper.h compatibility header - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef __COMPAT_LINUX_WRAPPER_H_ -#define __COMPAT_LINUX_WRAPPER_H_ - -#define mem_map_reserve(p) set_bit(PG_reserved, &((p)->flags)) -#define mem_map_unreserve(p) clear_bit(PG_reserved, &((p)->flags)) - -#endif /* __COMPAT_LINUX_WRAPPER_H_ */ diff --git a/drivers/staging/crystalhd/bc_dts_glob_lnx.h b/drivers/staging/crystalhd/bc_dts_glob_lnx.h index b3125e3e0372..0fd34e20dc88 100644 --- a/drivers/staging/crystalhd/bc_dts_glob_lnx.h +++ b/drivers/staging/crystalhd/bc_dts_glob_lnx.h @@ -40,7 +40,7 @@ #include <sys/time.h> #include <time.h> #include <arpa/inet.h> -#include <asm/param.h> +#include <linux/param.h> #include <linux/ioctl.h> #include <sys/select.h> diff --git a/drivers/staging/crystalhd/bc_dts_types.h b/drivers/staging/crystalhd/bc_dts_types.h index ac0c81717385..95a2f875f1e7 100644 --- a/drivers/staging/crystalhd/bc_dts_types.h +++ b/drivers/staging/crystalhd/bc_dts_types.h @@ -25,7 +25,7 @@ #ifndef _BC_DTS_TYPES_H_ #define _BC_DTS_TYPES_H_ -#ifdef __LINUX_USER__ // Don't include these for KERNEL.. +#ifdef __LINUX_USER__ /* Don't include these for KERNEL.. */ #include <stdint.h> #endif diff --git a/drivers/staging/crystalhd/bcm_70012_regs.h b/drivers/staging/crystalhd/bcm_70012_regs.h index 6922f54e432f..f3ab3146cd90 100644 --- a/drivers/staging/crystalhd/bcm_70012_regs.h +++ b/drivers/staging/crystalhd/bcm_70012_regs.h @@ -25,22 +25,22 @@ * m = memory, c = core, r = register, f = field, d = data. */ #if !defined(GET_FIELD) && !defined(SET_FIELD) -#define BRCM_ALIGN(c,r,f) c##_##r##_##f##_ALIGN -#define BRCM_BITS(c,r,f) c##_##r##_##f##_BITS -#define BRCM_MASK(c,r,f) c##_##r##_##f##_MASK -#define BRCM_SHIFT(c,r,f) c##_##r##_##f##_SHIFT +#define BRCM_ALIGN(c, r, f) c##_##r##_##f##_ALIGN +#define BRCM_BITS(c, r, f) c##_##r##_##f##_BITS +#define BRCM_MASK(c, r, f) c##_##r##_##f##_MASK +#define BRCM_SHIFT(c, r, f) c##_##r##_##f##_SHIFT -#define GET_FIELD(m,c,r,f) \ - ((((m) & BRCM_MASK(c,r,f)) >> BRCM_SHIFT(c,r,f)) << BRCM_ALIGN(c,r,f)) +#define GET_FIELD(m, c, r, f) \ + ((((m) & BRCM_MASK(c, r, f)) >> BRCM_SHIFT(c, r, f)) << BRCM_ALIGN(c, r, f)) -#define SET_FIELD(m,c,r,f,d) \ - ((m) = (((m) & ~BRCM_MASK(c,r,f)) | ((((d) >> BRCM_ALIGN(c,r,f)) << \ - BRCM_SHIFT(c,r,f)) & BRCM_MASK(c,r,f))) \ +#define SET_FIELD(m, c, r, f, d) \ + ((m) = (((m) & ~BRCM_MASK(c, r, f)) | ((((d) >> BRCM_ALIGN(c, r, f)) << \ + BRCM_SHIFT(c, r, f)) & BRCM_MASK(c, r, f))) \ ) -#define SET_TYPE_FIELD(m,c,r,f,d) SET_FIELD(m,c,r,f,c##_##d) -#define SET_NAME_FIELD(m,c,r,f,d) SET_FIELD(m,c,r,f,c##_##r##_##f##_##d) -#define SET_VALUE_FIELD(m,c,r,f,d) SET_FIELD(m,c,r,f,d) +#define SET_TYPE_FIELD(m, c, r, f, d) SET_FIELD(m, c, r, f, c##_##d) +#define SET_NAME_FIELD(m, c, r, f, d) SET_FIELD(m, c, r, f, c##_##r##_##f##_##d) +#define SET_VALUE_FIELD(m, c, r, f, d) SET_FIELD(m, c, r, f, d) #endif /* GET & SET */ diff --git a/drivers/staging/crystalhd/crystalhd_cmds.c b/drivers/staging/crystalhd/crystalhd_cmds.c index 26145a8d0f78..d826715809df 100644 --- a/drivers/staging/crystalhd/crystalhd_cmds.c +++ b/drivers/staging/crystalhd/crystalhd_cmds.c @@ -88,7 +88,7 @@ static BC_STATUS bc_cproc_notify_mode(struct crystalhd_cmd *ctx, return BC_STS_SUCCESS; } if (ctx->state != BC_LINK_INVALID) { - BCMLOG_ERR("Link invalid state %d \n", ctx->state); + BCMLOG_ERR("Link invalid state %d\n", ctx->state); return BC_STS_ERR_USAGE; } /* Check for duplicate playback sessions..*/ @@ -301,7 +301,7 @@ static BC_STATUS bc_cproc_download_fw(struct crystalhd_cmd *ctx, } if (ctx->state != BC_LINK_INVALID) { - BCMLOG_ERR("Link invalid state %d \n", ctx->state); + BCMLOG_ERR("Link invalid state %d\n", ctx->state); return BC_STS_ERR_USAGE; } @@ -309,7 +309,7 @@ static BC_STATUS bc_cproc_download_fw(struct crystalhd_cmd *ctx, idata->add_cdata_sz); if (sts != BC_STS_SUCCESS) { - BCMLOG_ERR("Firmware Download Failure!! - %d\n", sts); + BCMLOG_ERR("Firmware Download Failure!! - %d\n", sts) } else ctx->state |= BC_LINK_INIT; @@ -335,7 +335,7 @@ static BC_STATUS bc_cproc_do_fw_cmd(struct crystalhd_cmd *ctx, crystalhd_ioctl_d uint32_t *cmd; if (!(ctx->state & BC_LINK_INIT)) { - BCMLOG_ERR("Link invalid state %d \n", ctx->state); + BCMLOG_ERR("Link invalid state %d\n", ctx->state); return BC_STS_ERR_USAGE; } @@ -379,7 +379,7 @@ static void bc_proc_in_completion(crystalhd_dio_req *dio_hnd, return; } if (sts == BC_STS_IO_USER_ABORT) - return; + return; dio_hnd->uinfo.comp_sts = sts; dio_hnd->uinfo.ev_sts = 1; @@ -452,7 +452,7 @@ static BC_STATUS bc_cproc_hw_txdma(struct crystalhd_cmd *ctx, if (!rc) { return dio->uinfo.comp_sts; } else if (rc == -EBUSY) { - BCMLOG(BCMLOG_DBG, "_tx_post() T/O \n"); + BCMLOG(BCMLOG_DBG, "_tx_post() T/O\n"); sts = BC_STS_TIMEOUT; } else if (rc == -EINTR) { BCMLOG(BCMLOG_DBG, "Tx Wait Signal int.\n"); @@ -482,7 +482,7 @@ static BC_STATUS bc_cproc_check_inbuffs(bool pin, void *ubuff, uint32_t ub_sz, /* Check for alignment */ if (((uintptr_t)ubuff) & 0x03) { - BCMLOG_ERR("%s-->Un-aligned address not implemented yet.. %p \n", + BCMLOG_ERR("%s-->Un-aligned address not implemented yet.. %p\n", ((pin) ? "TX" : "RX"), ubuff); return BC_STS_NOT_IMPL; } @@ -523,7 +523,7 @@ static BC_STATUS bc_cproc_proc_input(struct crystalhd_cmd *ctx, crystalhd_ioctl_ sts = crystalhd_map_dio(ctx->adp, ubuff, ub_sz, 0, 0, 1, &dio_hnd); if (sts != BC_STS_SUCCESS) { - BCMLOG_ERR("dio map - %d \n", sts); + BCMLOG_ERR("dio map - %d\n", sts); return sts; } @@ -563,7 +563,7 @@ static BC_STATUS bc_cproc_add_cap_buff(struct crystalhd_cmd *ctx, sts = crystalhd_map_dio(ctx->adp, ubuff, ub_sz, uv_off, en_422, 0, &dio_hnd); if (sts != BC_STS_SUCCESS) { - BCMLOG_ERR("dio map - %d \n", sts); + BCMLOG_ERR("dio map - %d\n", sts); return sts; } @@ -1026,7 +1026,7 @@ crystalhd_cmd_proc crystalhd_get_cmd_proc(struct crystalhd_cmd *ctx, uint32_t cm if (g_crystalhd_cproc_tbl[i].cmd_id == cmd) { if ((uc->mode == DTS_MONITOR_MODE) && (g_crystalhd_cproc_tbl[i].block_mon)) { - BCMLOG(BCMLOG_INFO, "Blocking cmd %d \n", cmd); + BCMLOG(BCMLOG_INFO, "Blocking cmd %d\n", cmd); break; } cproc = g_crystalhd_cproc_tbl[i].cmd_proc; diff --git a/drivers/staging/crystalhd/crystalhd_cmds.h b/drivers/staging/crystalhd/crystalhd_cmds.h index 6b290aed8e0b..9989038b5c1b 100644 --- a/drivers/staging/crystalhd/crystalhd_cmds.h +++ b/drivers/staging/crystalhd/crystalhd_cmds.h @@ -66,7 +66,7 @@ struct crystalhd_cmd { struct crystalhd_hw hw_ctx; }; -typedef BC_STATUS (*crystalhd_cmd_proc)(struct crystalhd_cmd *, crystalhd_ioctl_data *); +typedef BC_STATUS(*crystalhd_cmd_proc)(struct crystalhd_cmd *, crystalhd_ioctl_data *); typedef struct _crystalhd_cmd_tbl { uint32_t cmd_id; diff --git a/drivers/staging/crystalhd/crystalhd_hw.c b/drivers/staging/crystalhd/crystalhd_hw.c index c438c489aa92..56d1e42bbad6 100644 --- a/drivers/staging/crystalhd/crystalhd_hw.c +++ b/drivers/staging/crystalhd/crystalhd_hw.c @@ -432,7 +432,7 @@ static void crystalhd_hw_delete_ioqs(struct crystalhd_hw *hw) if (!hw) return; - BCMLOG(BCMLOG_DBG, "Deleting IOQs \n"); + BCMLOG(BCMLOG_DBG, "Deleting IOQs\n"); crystalhd_hw_delete_ioq(hw->adp, hw->tx_actq); crystalhd_hw_delete_ioq(hw->adp, hw->tx_freeq); crystalhd_hw_delete_ioq(hw->adp, hw->rx_actq); @@ -570,7 +570,7 @@ static bool crystalhd_tx_list0_handler(struct crystalhd_hw *hw, uint32_t err_sts if (!(err_sts & err_mask)) return false; - BCMLOG_ERR("Error on Tx-L0 %x \n", err_sts); + BCMLOG_ERR("Error on Tx-L0 %x\n", err_sts); tmp = err_mask; @@ -602,7 +602,7 @@ static bool crystalhd_tx_list1_handler(struct crystalhd_hw *hw, uint32_t err_sts if (!(err_sts & err_mask)) return false; - BCMLOG_ERR("Error on Tx-L1 %x \n", err_sts); + BCMLOG_ERR("Error on Tx-L1 %x\n", err_sts); tmp = err_mask; @@ -635,9 +635,9 @@ static void crystalhd_tx_isr(struct crystalhd_hw *hw, uint32_t int_sts) BC_STS_SUCCESS); if (!(int_sts & (INTR_INTR_STATUS_L0_TX_DMA_ERR_INTR_MASK | - INTR_INTR_STATUS_L1_TX_DMA_ERR_INTR_MASK))) { - /* No error mask set.. */ - return; + INTR_INTR_STATUS_L1_TX_DMA_ERR_INTR_MASK))) { + /* No error mask set.. */ + return; } /* Handle Tx errors. */ @@ -1134,33 +1134,29 @@ static void crystalhd_stop_rx_dma_engine(struct crystalhd_hw *hw) if (l0y) { l0y = crystalhd_reg_rd(hw->adp, MISC1_Y_RX_FIRST_DESC_L_ADDR_LIST0); l0y &= DMA_START_BIT; - if (!l0y) { + if (!l0y) hw->rx_list_sts[0] &= ~rx_waiting_y_intr; - } } if (l1y) { l1y = crystalhd_reg_rd(hw->adp, MISC1_Y_RX_FIRST_DESC_L_ADDR_LIST1); l1y &= DMA_START_BIT; - if (!l1y) { + if (!l1y) hw->rx_list_sts[1] &= ~rx_waiting_y_intr; - } } if (l0uv) { l0uv = crystalhd_reg_rd(hw->adp, MISC1_UV_RX_FIRST_DESC_L_ADDR_LIST0); l0uv &= DMA_START_BIT; - if (!l0uv) { + if (!l0uv) hw->rx_list_sts[0] &= ~rx_waiting_uv_intr; - } } if (l1uv) { l1uv = crystalhd_reg_rd(hw->adp, MISC1_UV_RX_FIRST_DESC_L_ADDR_LIST1); l1uv &= DMA_START_BIT; - if (!l1uv) { + if (!l1uv) hw->rx_list_sts[1] &= ~rx_waiting_uv_intr; - } } msleep_interruptible(100); count--; @@ -1432,9 +1428,8 @@ static bool crystalhd_rx_list1_handler(struct crystalhd_hw *hw, uint32_t int_sts /* UV1 - DMA */ tmp = uv_err_sts & GET_UV1_ERR_MSK; - if (int_sts & INTR_INTR_STATUS_L1_UV_RX_DMA_DONE_INTR_MASK) { + if (int_sts & INTR_INTR_STATUS_L1_UV_RX_DMA_DONE_INTR_MASK) hw->rx_list_sts[1] &= ~rx_waiting_uv_intr; - } if (uv_err_sts & MISC1_UV_RX_ERROR_STATUS_RX_L1_UNDERRUN_ERROR_MASK) { hw->rx_list_sts[1] &= ~rx_waiting_uv_intr; @@ -1740,7 +1735,7 @@ BC_STATUS crystalhd_do_fw_cmd(struct crystalhd_hw *hw, BC_FW_CMD *fw_cmd) res_buff = fw_cmd->rsp; if (!cmd_buff || !res_buff) { - BCMLOG_ERR("Invalid Parameters for F/W Command \n"); + BCMLOG_ERR("Invalid Parameters for F/W Command\n"); return BC_STS_INV_ARG; } diff --git a/drivers/staging/crystalhd/crystalhd_lnx.c b/drivers/staging/crystalhd/crystalhd_lnx.c index 54bad652c0c5..141a3e38a835 100644 --- a/drivers/staging/crystalhd/crystalhd_lnx.c +++ b/drivers/staging/crystalhd/crystalhd_lnx.c @@ -15,7 +15,7 @@ along with this driver. If not, see <http://www.gnu.org/licenses/>. ***************************************************************************/ -#include <linux/version.h> +#include <linux/smp_lock.h> #include <linux/slab.h> #include "crystalhd_lnx.h" @@ -51,7 +51,7 @@ static int chd_dec_enable_int(struct crystalhd_adp *adp) rc = request_irq(adp->pdev->irq, chd_dec_isr, IRQF_SHARED, adp->name, (void *)adp); if (rc) { - BCMLOG_ERR("Interrupt request failed.. \n"); + BCMLOG_ERR("Interrupt request failed..\n"); pci_disable_msi(adp->pdev); } @@ -112,7 +112,7 @@ static inline int crystalhd_user_data(unsigned long ud, void *dr, int size, int int rc; if (!ud || !dr) { - BCMLOG_ERR("Invalid arg \n"); + BCMLOG_ERR("Invalid arg\n"); return -EINVAL; } @@ -122,7 +122,7 @@ static inline int crystalhd_user_data(unsigned long ud, void *dr, int size, int rc = copy_from_user(dr, (void *)ud, size); if (rc) { - BCMLOG_ERR("Invalid args for command \n"); + BCMLOG_ERR("Invalid args for command\n"); rc = -EFAULT; } @@ -206,7 +206,7 @@ static int chd_dec_proc_user_data(struct crystalhd_adp *adp, rc = crystalhd_user_data(ua, &io->udata, sizeof(io->udata), set); if (rc) { - BCMLOG_ERR("failed to %s iodata \n", (set ? "set" : "get")); + BCMLOG_ERR("failed to %s iodata\n", (set ? "set" : "get")); return rc; } @@ -261,12 +261,12 @@ static int chd_dec_api_cmd(struct crystalhd_adp *adp, unsigned long ua, } /* API interfaces */ -static int chd_dec_ioctl(struct inode *in, struct file *fd, - unsigned int cmd, unsigned long ua) +static long chd_dec_ioctl(struct file *fd, unsigned int cmd, unsigned long ua) { struct crystalhd_adp *adp = chd_get_adp(); crystalhd_cmd_proc cproc; struct crystalhd_user *uc; + int ret; if (!adp || !fd) { BCMLOG_ERR("Invalid adp\n"); @@ -279,13 +279,17 @@ static int chd_dec_ioctl(struct inode *in, struct file *fd, return -ENODATA; } + lock_kernel(); cproc = crystalhd_get_cmd_proc(&adp->cmds, cmd, uc); if (!cproc) { BCMLOG_ERR("Unhandled command: %d\n", cmd); + unlock_kernel(); return -EINVAL; } - return chd_dec_api_cmd(adp, ua, uc->uid, cmd, cproc); + ret = chd_dec_api_cmd(adp, ua, uc->uid, cmd, cproc); + unlock_kernel(); + return ret; } static int chd_dec_open(struct inode *in, struct file *fd) @@ -308,7 +312,7 @@ static int chd_dec_open(struct inode *in, struct file *fd) sts = crystalhd_user_open(&adp->cmds, &uc); if (sts != BC_STS_SUCCESS) { - BCMLOG_ERR("cmd_user_open - %d \n", sts); + BCMLOG_ERR("cmd_user_open - %d\n", sts); rc = -EBUSY; } @@ -326,7 +330,7 @@ static int chd_dec_close(struct inode *in, struct file *fd) BCMLOG_ENTER; if (!adp) { - BCMLOG_ERR("Invalid adp \n"); + BCMLOG_ERR("Invalid adp\n"); return -EINVAL; } @@ -345,7 +349,7 @@ static int chd_dec_close(struct inode *in, struct file *fd) static const struct file_operations chd_dec_fops = { .owner = THIS_MODULE, - .ioctl = chd_dec_ioctl, + .unlocked_ioctl = chd_dec_ioctl, .open = chd_dec_open, .release = chd_dec_close, }; @@ -376,7 +380,7 @@ static int __devinit chd_dec_init_chdev(struct crystalhd_adp *adp) dev = device_create(crystalhd_class, NULL, MKDEV(adp->chd_dec_major, 0), NULL, "crystalhd"); - if (!dev) { + if (IS_ERR(dev)) { BCMLOG_ERR("failed to create device\n"); goto device_create_fail; } @@ -521,7 +525,7 @@ static void __devexit chd_dec_pci_remove(struct pci_dev *pdev) sts = crystalhd_delete_cmd_context(&pinfo->cmds); if (sts != BC_STS_SUCCESS) - BCMLOG_ERR("cmd delete :%d \n", sts); + BCMLOG_ERR("cmd delete :%d\n", sts); chd_dec_release_chdev(pinfo); @@ -581,7 +585,7 @@ static int __devinit chd_dec_pci_probe(struct pci_dev *pdev, chd_dec_init_chdev(pinfo); rc = chd_dec_enable_int(pinfo); if (rc) { - BCMLOG_ERR("_enable_int err:%d \n", rc); + BCMLOG_ERR("_enable_int err:%d\n", rc); pci_disable_device(pdev); return -ENODEV; } @@ -601,7 +605,7 @@ static int __devinit chd_dec_pci_probe(struct pci_dev *pdev, sts = crystalhd_setup_cmd_context(&pinfo->cmds, pinfo); if (sts != BC_STS_SUCCESS) { - BCMLOG_ERR("cmd setup :%d \n", sts); + BCMLOG_ERR("cmd setup :%d\n", sts); pci_disable_device(pdev); return -ENODEV; } @@ -675,7 +679,7 @@ int chd_dec_pci_resume(struct pci_dev *pdev) rc = chd_dec_enable_int(adp); if (rc) { - BCMLOG_ERR("_enable_int err:%d \n", rc); + BCMLOG_ERR("_enable_int err:%d\n", rc); pci_disable_device(pdev); return -ENODEV; } @@ -738,13 +742,13 @@ static int __init chd_dec_module_init(void) int rc; chd_set_log_level(NULL, "debug"); - BCMLOG(BCMLOG_DATA, "Loading crystalhd %d.%d.%d \n", + BCMLOG(BCMLOG_DATA, "Loading crystalhd %d.%d.%d\n", crystalhd_kmod_major, crystalhd_kmod_minor, crystalhd_kmod_rev); rc = pci_register_driver(&bc_chd_70012_driver); if (rc < 0) - BCMLOG_ERR("Could not find any devices. err:%d \n", rc); + BCMLOG_ERR("Could not find any devices. err:%d\n", rc); return rc; } @@ -752,7 +756,7 @@ module_init(chd_dec_module_init); static void __exit chd_dec_module_cleanup(void) { - BCMLOG(BCMLOG_DATA, "unloading crystalhd %d.%d.%d \n", + BCMLOG(BCMLOG_DATA, "unloading crystalhd %d.%d.%d\n", crystalhd_kmod_major, crystalhd_kmod_minor, crystalhd_kmod_rev); pci_unregister_driver(&bc_chd_70012_driver); diff --git a/drivers/staging/crystalhd/crystalhd_lnx.h b/drivers/staging/crystalhd/crystalhd_lnx.h index d338ae97a4cf..eee4926f04ea 100644 --- a/drivers/staging/crystalhd/crystalhd_lnx.h +++ b/drivers/staging/crystalhd/crystalhd_lnx.h @@ -42,11 +42,11 @@ #include <linux/pagemap.h> #include <linux/vmalloc.h> -#include <asm/io.h> +#include <linux/io.h> #include <asm/irq.h> #include <asm/pgtable.h> #include <asm/system.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include "crystalhd_cmds.h" diff --git a/drivers/staging/crystalhd/crystalhd_misc.c b/drivers/staging/crystalhd/crystalhd_misc.c index 73593b078b33..d1346672531f 100644 --- a/drivers/staging/crystalhd/crystalhd_misc.c +++ b/drivers/staging/crystalhd/crystalhd_misc.c @@ -237,7 +237,7 @@ BC_STATUS crystalhd_mem_rd(struct crystalhd_adp *adp, uint32_t start_off, if (!adp || !rd_buff || (bc_chk_dram_range(adp, start_off, dw_cnt) != BC_STS_SUCCESS)) { - BCMLOG_ERR("Invalid arg \n"); + BCMLOG_ERR("Invalid arg\n"); return BC_STS_INV_ARG; } for (ix = 0; ix < dw_cnt; ix++) @@ -265,7 +265,7 @@ BC_STATUS crystalhd_mem_wr(struct crystalhd_adp *adp, uint32_t start_off, if (!adp || !wr_buff || (bc_chk_dram_range(adp, start_off, dw_cnt) != BC_STS_SUCCESS)) { - BCMLOG_ERR("Invalid arg \n"); + BCMLOG_ERR("Invalid arg\n"); return BC_STS_INV_ARG; } @@ -293,7 +293,7 @@ BC_STATUS crystalhd_pci_cfg_rd(struct crystalhd_adp *adp, uint32_t off, int rc = 0; if (!adp || !val) { - BCMLOG_ERR("Invalid arg \n"); + BCMLOG_ERR("Invalid arg\n"); return BC_STS_INV_ARG; } @@ -338,7 +338,7 @@ BC_STATUS crystalhd_pci_cfg_wr(struct crystalhd_adp *adp, uint32_t off, int rc = 0; if (!adp || !val) { - BCMLOG_ERR("Invalid arg \n"); + BCMLOG_ERR("Invalid arg\n"); return BC_STS_INV_ARG; } @@ -685,7 +685,7 @@ BC_STATUS crystalhd_map_dio(struct crystalhd_adp *adp, void *ubuff, int i = 0, rw = 0, res = 0, nr_pages = 0, skip_fb_sg = 0; if (!adp || !ubuff || !ubuff_sz || !dio_hnd) { - BCMLOG_ERR("Invalid arg \n"); + BCMLOG_ERR("Invalid arg\n"); return BC_STS_INV_ARG; } /* Compute pages */ @@ -791,7 +791,7 @@ BC_STATUS crystalhd_map_dio(struct crystalhd_adp *adp, void *ubuff, dio->sg_cnt = pci_map_sg(adp->pdev, dio->sg, dio->page_cnt, dio->direction); if (dio->sg_cnt <= 0) { - BCMLOG_ERR("sg map %d-%d \n", dio->sg_cnt, dio->page_cnt); + BCMLOG_ERR("sg map %d-%d\n", dio->sg_cnt, dio->page_cnt); crystalhd_unmap_dio(adp, dio); return BC_STS_ERROR; } @@ -826,7 +826,7 @@ BC_STATUS crystalhd_unmap_dio(struct crystalhd_adp *adp, crystalhd_dio_req *dio) int j = 0; if (!adp || !dio) { - BCMLOG_ERR("Invalid arg \n"); + BCMLOG_ERR("Invalid arg\n"); return BC_STS_INV_ARG; } @@ -947,7 +947,7 @@ void crystalhd_destroy_dio_pool(struct crystalhd_adp *adp) adp->fill_byte_pool = NULL; } - BCMLOG(BCMLOG_DBG, "Released dio pool %d \n", count); + BCMLOG(BCMLOG_DBG, "Released dio pool %d\n", count); } /** @@ -973,7 +973,7 @@ int __devinit crystalhd_create_elem_pool(struct crystalhd_adp *adp, for (i = 0; i < pool_size; i++) { temp = kzalloc(sizeof(*temp), GFP_KERNEL); if (!temp) { - BCMLOG_ERR("kalloc failed \n"); + BCMLOG_ERR("kalloc failed\n"); return -ENOMEM; } crystalhd_free_elem(adp, temp); diff --git a/drivers/staging/cx25821/cx25821-alsa.c b/drivers/staging/cx25821/cx25821-alsa.c index 33e559d58b1b..aa3b04d75499 100644 --- a/drivers/staging/cx25821/cx25821-alsa.c +++ b/drivers/staging/cx25821/cx25821-alsa.c @@ -479,7 +479,7 @@ static int snd_cx25821_hw_params(struct snd_pcm_substream *substream, buf->vb.width, buf->vb.height, 1); if (ret < 0) { printk(KERN_INFO - "DEBUG: ERROR after cx25821_risc_databuffer_audio()\n"); + "DEBUG: ERROR after cx25821_risc_databuffer_audio()\n"); goto error; } diff --git a/drivers/staging/cxt1e1/Kconfig b/drivers/staging/cxt1e1/Kconfig new file mode 100644 index 000000000000..68e9b6d973f7 --- /dev/null +++ b/drivers/staging/cxt1e1/Kconfig @@ -0,0 +1,22 @@ +config CXT1E1 + tristate "SBE wanPMC-C[421]E1T1 hardware support" + depends on HDLC && PCI + ---help--- + This driver supports the SBE wanPMC-CxT1E1 1, 2 and 4 port T3 + channelized stream WAN adapter card which contains a HDLC/Transparent + mode controller. + + If you want to compile this driver as a module + say M here and read <file:Documentation/modules.txt>. + The module will be called 'cxt1e1'. + + If unsure, say N. + +config SBE_PMCC4_NCOMM + bool "SBE PMCC4 NCOMM support" + depends on CXT1E1 + ---help--- + SBE supplies optional support for NCOMM products. + + If you have purchased this optional support you must say Y or M + here to allow the driver to operate with the NCOMM product. diff --git a/drivers/staging/cxt1e1/Makefile b/drivers/staging/cxt1e1/Makefile new file mode 100644 index 000000000000..10020d7b79a8 --- /dev/null +++ b/drivers/staging/cxt1e1/Makefile @@ -0,0 +1,19 @@ +obj-$(CONFIG_CXT1E1) += cxt1e1.o + +EXTRA_CFLAGS += -DSBE_PMCC4_ENABLE +EXTRA_CFLAGS += -DSBE_ISR_TASKLET +EXTRA_CFLAGS += -DSBE_INCLUDE_SYMBOLS + +cxt1e1-objs += \ + ossiRelease.o \ + musycc.o \ + pmcc4_drv.o \ + comet.o \ + linux.o \ + functions.o \ + hwprobe.o \ + sbeproc.o \ + pmc93x6_eeprom.o \ + sbecrc.o \ + comet_tables.o \ + sbeid.o diff --git a/drivers/staging/cxt1e1/comet.c b/drivers/staging/cxt1e1/comet.c new file mode 100644 index 000000000000..b70909967038 --- /dev/null +++ b/drivers/staging/cxt1e1/comet.c @@ -0,0 +1,566 @@ +/* Copyright (C) 2003-2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + */ + +#include <asm/io.h> +#include <linux/hdlc.h> +#include "pmcc4_sysdep.h" +#include "sbecom_inline_linux.h" +#include "libsbew.h" +#include "pmcc4.h" +#include "comet.h" +#include "comet_tables.h" + +#ifdef SBE_INCLUDE_SYMBOLS +#define STATIC +#else +#define STATIC static +#endif + + +extern int log_level; + +#define COMET_NUM_SAMPLES 24 /* Number of entries in the waveform table */ +#define COMET_NUM_UNITS 5 /* Number of points per entry in table */ + +/* forward references */ +STATIC void SetPwrLevel (comet_t * comet); +STATIC void WrtRcvEqualizerTbl (ci_t * ci, comet_t * comet, u_int32_t *table); +STATIC void WrtXmtWaveformTbl (ci_t * ci, comet_t * comet, u_int8_t table[COMET_NUM_SAMPLES][COMET_NUM_UNITS]); + + +void *TWV_table[12] = { + TWVLongHaul0DB, TWVLongHaul7_5DB, TWVLongHaul15DB, TWVLongHaul22_5DB, + TWVShortHaul0, TWVShortHaul1, TWVShortHaul2, TWVShortHaul3, TWVShortHaul4, + TWVShortHaul5, + TWV_E1_75Ohm, /** PORT POINT - 75 Ohm not supported **/ + TWV_E1_120Ohm +}; + + +static int +lbo_tbl_lkup (int t1, int lbo) +{ + if ((lbo < CFG_LBO_LH0) || (lbo > CFG_LBO_E120)) /* error switches to + * default */ + { + if (t1) + lbo = CFG_LBO_LH0; /* default T1 waveform table */ + else + lbo = CFG_LBO_E120; /* default E1 waveform table */ + } + return (lbo - 1); /* make index ZERO relative */ +} + + +void +init_comet (void *ci, comet_t * comet, u_int32_t port_mode, int clockmaster, + u_int8_t moreParams) +{ + u_int8_t isT1mode; + u_int8_t tix = CFG_LBO_LH0; /* T1 default */ + + isT1mode = IS_FRAME_ANY_T1 (port_mode); + /* T1 or E1 */ + if (isT1mode) + { + pci_write_32 ((u_int32_t *) &comet->gbl_cfg, 0xa0); /* Select T1 Mode & PIO + * output enabled */ + tix = lbo_tbl_lkup (isT1mode, CFG_LBO_LH0); /* default T1 waveform + * table */ + } else + { + pci_write_32 ((u_int32_t *) &comet->gbl_cfg, 0x81); /* Select E1 Mode & PIO + * output enabled */ + tix = lbo_tbl_lkup (isT1mode, CFG_LBO_E120); /* default E1 waveform + * table */ + } + + if (moreParams & CFG_LBO_MASK) + tix = lbo_tbl_lkup (isT1mode, moreParams & CFG_LBO_MASK); /* dial-in requested + * waveform table */ + + /* Tx line Intfc cfg ** Set for analog & no special patterns */ + pci_write_32 ((u_int32_t *) &comet->tx_line_cfg, 0x00); /* Transmit Line + * Interface Config. */ + + /* master test ** Ignore Test settings for now */ + pci_write_32 ((u_int32_t *) &comet->mtest, 0x00); /* making sure it's + * Default value */ + + /* Turn on Center (CENT) and everything else off */ + pci_write_32 ((u_int32_t *) &comet->rjat_cfg, 0x10); /* RJAT cfg */ + /* Set Jitter Attenuation to recommend T1 values */ + if (isT1mode) + { + pci_write_32 ((u_int32_t *) &comet->rjat_n1clk, 0x2F); /* RJAT Divider N1 + * Control */ + pci_write_32 ((u_int32_t *) &comet->rjat_n2clk, 0x2F); /* RJAT Divider N2 + * Control */ + } else + { + pci_write_32 ((u_int32_t *) &comet->rjat_n1clk, 0xFF); /* RJAT Divider N1 + * Control */ + pci_write_32 ((u_int32_t *) &comet->rjat_n2clk, 0xFF); /* RJAT Divider N2 + * Control */ + } + + /* Turn on Center (CENT) and everything else off */ + pci_write_32 ((u_int32_t *) &comet->tjat_cfg, 0x10); /* TJAT Config. */ + + /* Do not bypass jitter attenuation and bypass elastic store */ + pci_write_32 ((u_int32_t *) &comet->rx_opt, 0x00); /* rx opts */ + + /* TJAT ctrl & TJAT divider ctrl */ + /* Set Jitter Attenuation to recommended T1 values */ + if (isT1mode) + { + pci_write_32 ((u_int32_t *) &comet->tjat_n1clk, 0x2F); /* TJAT Divider N1 + * Control */ + pci_write_32 ((u_int32_t *) &comet->tjat_n2clk, 0x2F); /* TJAT Divider N2 + * Control */ + } else + { + pci_write_32 ((u_int32_t *) &comet->tjat_n1clk, 0xFF); /* TJAT Divider N1 + * Control */ + pci_write_32 ((u_int32_t *) &comet->tjat_n2clk, 0xFF); /* TJAT Divider N2 + * Control */ + } + + /* 1c: rx ELST cfg 20: tx ELST cfg 28&38: rx&tx data link ctrl */ + if (isT1mode) + { /* Select 193-bit frame format */ + pci_write_32 ((u_int32_t *) &comet->rx_elst_cfg, 0x00); + pci_write_32 ((u_int32_t *) &comet->tx_elst_cfg, 0x00); + } else + { /* Select 256-bit frame format */ + pci_write_32 ((u_int32_t *) &comet->rx_elst_cfg, 0x03); + pci_write_32 ((u_int32_t *) &comet->tx_elst_cfg, 0x03); + pci_write_32 ((u_int32_t *) &comet->rxce1_ctl, 0x00); /* disable T1 data link + * receive */ + pci_write_32 ((u_int32_t *) &comet->txci1_ctl, 0x00); /* disable T1 data link + * transmit */ + } + + /* the following is a default value */ + /* Enable 8 out of 10 validation */ + pci_write_32 ((u_int32_t *) &comet->t1_rboc_ena, 0x00); /* t1RBOC + * enable(BOC:BitOriented + * Code) */ + if (isT1mode) + { + + /* IBCD cfg: aka Inband Code Detection ** loopback code length set to */ + pci_write_32 ((u_int32_t *) &comet->ibcd_cfg, 0x04); /* 6 bit down, 5 bit up + * (assert) */ + pci_write_32 ((u_int32_t *) &comet->ibcd_act, 0x08); /* line loopback + * activate pattern */ + pci_write_32 ((u_int32_t *) &comet->ibcd_deact, 0x24); /* deactivate code + * pattern (i.e.001) */ + } + /* 10: CDRC cfg 28&38: rx&tx data link 1 ctrl 48: t1 frmr cfg */ + /* 50: SIGX cfg, COSS (change of signaling state) 54: XBAS cfg */ + /* 60: t1 ALMI cfg */ + /* Configure Line Coding */ + + switch (port_mode) + { + case CFG_FRAME_SF: /* 1 - T1 B8ZS */ + pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->t1_frmr_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->t1_xbas_cfg, 0x20); /* 5:B8ZS */ + pci_write_32 ((u_int32_t *) &comet->t1_almi_cfg, 0); + break; + case CFG_FRAME_ESF: /* 2 - T1 B8ZS */ + pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->rxce1_ctl, 0x20); /* Bit 5: T1 DataLink + * Enable */ + pci_write_32 ((u_int32_t *) &comet->txci1_ctl, 0x20); /* 5: T1 DataLink Enable */ + pci_write_32 ((u_int32_t *) &comet->t1_frmr_cfg, 0x30); /* 4:ESF 5:ESFFA */ + pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0x04); /* 2:ESF */ + pci_write_32 ((u_int32_t *) &comet->t1_xbas_cfg, 0x30); /* 4:ESF 5:B8ZS */ + pci_write_32 ((u_int32_t *) &comet->t1_almi_cfg, 0x10); /* 4:ESF */ + break; + case CFG_FRAME_E1PLAIN: /* 3 - HDB3 */ + pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->e1_tran_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->e1_frmr_aopts, 0x40); + break; + case CFG_FRAME_E1CAS: /* 4 - HDB3 */ + pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->e1_tran_cfg, 0x60); + pci_write_32 ((u_int32_t *) &comet->e1_frmr_aopts, 0); + break; + case CFG_FRAME_E1CRC: /* 5 - HDB3 */ + pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->e1_tran_cfg, 0x10); + pci_write_32 ((u_int32_t *) &comet->e1_frmr_aopts, 0xc2); + break; + case CFG_FRAME_E1CRC_CAS: /* 6 - HDB3 */ + pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->e1_tran_cfg, 0x70); + pci_write_32 ((u_int32_t *) &comet->e1_frmr_aopts, 0x82); + break; + case CFG_FRAME_SF_AMI: /* 7 - T1 AMI */ + pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0x80); /* Enable AMI Line + * Decoding */ + pci_write_32 ((u_int32_t *) &comet->t1_frmr_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->t1_xbas_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->t1_almi_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0); + break; + case CFG_FRAME_ESF_AMI: /* 8 - T1 AMI */ + pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0x80); /* Enable AMI Line + * Decoding */ + pci_write_32 ((u_int32_t *) &comet->rxce1_ctl, 0x20); /* 5: T1 DataLink Enable */ + pci_write_32 ((u_int32_t *) &comet->txci1_ctl, 0x20); /* 5: T1 DataLink Enable */ + pci_write_32 ((u_int32_t *) &comet->t1_frmr_cfg, 0x30); /* Bit 4:ESF 5:ESFFA */ + pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0x04); /* 2:ESF */ + pci_write_32 ((u_int32_t *) &comet->t1_xbas_cfg, 0x10); /* 4:ESF */ + pci_write_32 ((u_int32_t *) &comet->t1_almi_cfg, 0x10); /* 4:ESF */ + break; + case CFG_FRAME_E1PLAIN_AMI: /* 9 - AMI */ + pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0x80); /* Enable AMI Line + * Decoding */ + pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->e1_tran_cfg, 0x80); + pci_write_32 ((u_int32_t *) &comet->e1_frmr_aopts, 0x40); + break; + case CFG_FRAME_E1CAS_AMI: /* 10 - AMI */ + pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0x80); /* Enable AMI Line + * Decoding */ + pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->e1_tran_cfg, 0xe0); + pci_write_32 ((u_int32_t *) &comet->e1_frmr_aopts, 0); + break; + case CFG_FRAME_E1CRC_AMI: /* 11 - AMI */ + pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0x80); /* Enable AMI Line + * Decoding */ + pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->e1_tran_cfg, 0x90); + pci_write_32 ((u_int32_t *) &comet->e1_frmr_aopts, 0xc2); + break; + case CFG_FRAME_E1CRC_CAS_AMI: /* 12 - AMI */ + pci_write_32 ((u_int32_t *) &comet->cdrc_cfg, 0x80); /* Enable AMI Line + * Decoding */ + pci_write_32 ((u_int32_t *) &comet->sigx_cfg, 0); + pci_write_32 ((u_int32_t *) &comet->e1_tran_cfg, 0xf0); + pci_write_32 ((u_int32_t *) &comet->e1_frmr_aopts, 0x82); + break; + } /* end switch */ + + /*** + * Set Full Frame mode (NXDSO[1] = 0, NXDSO[0] = 0) + * CMODE=1: Clock slave mode with BRCLK as an input, + * DE=0: Use falling edge of BRCLK for data, + * FE=0: Use falling edge of BRCLK for frame, + * CMS=0: Use backplane freq, + * RATE[1:0]=0,0: T1 + ***/ + + + /* 0x30: "BRIF cfg"; 0x20 is 'CMODE', 0x03 is (bit) rate */ + /* note "rate bits can only be set once after reset" */ + if (clockmaster) + { /* CMODE == clockMode, 0=clock master (so + * all 3 others should be slave) */ + if (isT1mode) /* rate = 1.544 Mb/s */ + pci_write_32 ((u_int32_t *) &comet->brif_cfg, 0x00); /* Comet 0 Master + * Mode(CMODE=0) */ + else /* rate = 2.048 Mb/s */ + pci_write_32 ((u_int32_t *) &comet->brif_cfg, 0x01); /* Comet 0 Master + * Mode(CMODE=0) */ + + /* 31: BRIF frame pulse cfg 06: tx timing options */ + pci_write_32 ((u_int32_t *) &comet->brif_fpcfg, 0x00); /* Master Mode + * i.e.FPMODE=0 (@0x20) */ + if ((moreParams & CFG_CLK_PORT_MASK) == CFG_CLK_PORT_INTERNAL) + { + if (log_level >= LOG_SBEBUG12) + printk (">> init_comet: clockmaster internal clock\n"); + pci_write_32 ((u_int32_t *) &comet->tx_time, 0x0d); /* internal oscillator */ + } else /* external clock source */ + { + if (log_level >= LOG_SBEBUG12) + printk (">> init_comet: clockmaster external clock\n"); + pci_write_32 ((u_int32_t *) &comet->tx_time, 0x09); /* loop timing + * (external) */ + } + + } else /* slave */ + { + if (isT1mode) + pci_write_32 ((u_int32_t *) &comet->brif_cfg, 0x20); /* Slave Mode(CMODE=1, + * see above) */ + else + pci_write_32 ((u_int32_t *) &comet->brif_cfg, 0x21); /* Slave Mode (CMODE=1) */ + pci_write_32 ((u_int32_t *) &comet->brif_fpcfg, 0x20); /* Slave Mode i.e. + * FPMODE=1 (@0x20) */ + if (log_level >= LOG_SBEBUG12) + printk (">> init_comet: clockslave internal clock\n"); + pci_write_32 ((u_int32_t *) &comet->tx_time, 0x0d); /* oscillator timing */ + } + + /* 32: BRIF parity F-bit cfg */ + /* Totem-pole operation */ + pci_write_32 ((u_int32_t *) &comet->brif_pfcfg, 0x01); /* Receive Backplane + * Parity/F-bit */ + + /* dc: RLPS equalizer V ref */ + /* Configuration */ + if (isT1mode) + pci_write_32 ((u_int32_t *) &comet->rlps_eqvr, 0x2c); /* RLPS Equalizer + * Voltage */ + else + pci_write_32 ((u_int32_t *) &comet->rlps_eqvr, 0x34); /* RLPS Equalizer + * Voltage */ + + /* Reserved bit set and SQUELCH enabled */ + /* f8: RLPS cfg & status f9: RLPS ALOS detect/clear threshold */ + pci_write_32 ((u_int32_t *) &comet->rlps_cfgsts, 0x11); /* RLPS Configuration + * Status */ + if (isT1mode) + pci_write_32 ((u_int32_t *) &comet->rlps_alos_thresh, 0x55); /* ? */ + else + pci_write_32 ((u_int32_t *) &comet->rlps_alos_thresh, 0x22); /* ? */ + + + /* Set Full Frame mode (NXDSO[1] = 0, NXDSO[0] = 0) */ + /* CMODE=0: Clock slave mode with BTCLK as an input, DE=1: Use rising */ + /* edge of BTCLK for data, FE=1: Use rising edge of BTCLK for frame, */ + /* CMS=0: Use backplane freq, RATE[1:0]=0,0: T1 */ +/*** Transmit side is always an Input, Slave Clock*/ + /* 40: BTIF cfg 41: BTIF frame pulse cfg */ + if (isT1mode) + pci_write_32 ((u_int32_t *) &comet->btif_cfg, 0x38); /* BTIF Configuration + * Reg. */ + else + pci_write_32 ((u_int32_t *) &comet->btif_cfg, 0x39); /* BTIF Configuration + * Reg. */ + + pci_write_32 ((u_int32_t *) &comet->btif_fpcfg, 0x01); /* BTIF Frame Pulse + * Config. */ + + /* 0a: master diag 06: tx timing options */ + /* if set Comet to loop back */ + + /* Comets set to normal */ + pci_write_32 ((u_int32_t *) &comet->mdiag, 0x00); + + /* BTCLK driven by TCLKI internally (crystal driven) and Xmt Elasted */ + /* Store is enabled. */ + + WrtXmtWaveformTbl (ci, comet, TWV_table[tix]); + if (isT1mode) + WrtRcvEqualizerTbl ((ci_t *) ci, comet, &T1_Equalizer[0]); + else + WrtRcvEqualizerTbl ((ci_t *) ci, comet, &E1_Equalizer[0]); + SetPwrLevel (comet); +} + +/* +** Name: WrtXmtWaveform +** Description: Formulate the Data for the Pulse Waveform Storage +** Write register, (F2), from the sample and unit inputs. +** Write the data to the Pulse Waveform Storage Data register. +** Returns: Nothing +*/ +STATIC void +WrtXmtWaveform (ci_t * ci, comet_t * comet, u_int32_t sample, u_int32_t unit, u_int8_t data) +{ + u_int8_t WaveformAddr; + + WaveformAddr = (sample << 3) + (unit & 7); + pci_write_32 ((u_int32_t *) &comet->xlpg_pwave_addr, WaveformAddr); + pci_flush_write (ci); /* for write order preservation when + * Optimizing driver */ + pci_write_32 ((u_int32_t *) &comet->xlpg_pwave_data, 0x7F & data); +} + +/* +** Name: WrtXmtWaveformTbl +** Description: Fill in the Transmit Waveform Values +** for driving the transmitter DAC. +** Returns: Nothing +*/ +STATIC void +WrtXmtWaveformTbl (ci_t * ci, comet_t * comet, + u_int8_t table[COMET_NUM_SAMPLES][COMET_NUM_UNITS]) +{ + u_int32_t sample, unit; + + for (sample = 0; sample < COMET_NUM_SAMPLES; sample++) + { + for (unit = 0; unit < COMET_NUM_UNITS; unit++) + WrtXmtWaveform (ci, comet, sample, unit, table[sample][unit]); + } + + /* Enable transmitter and set output amplitude */ + pci_write_32 ((u_int32_t *) &comet->xlpg_cfg, table[COMET_NUM_SAMPLES][0]); +} + + +/* +** Name: WrtXmtWaveform +** Description: Fill in the Receive Equalizer RAM from the desired +** table. +** Returns: Nothing +** +** Remarks: Per PM4351 Device Errata, Receive Equalizer RAM Initialization +** is coded with early setup of indirect address. +*/ + +STATIC void +WrtRcvEqualizerTbl (ci_t * ci, comet_t * comet, u_int32_t *table) +{ + u_int32_t ramaddr; + volatile u_int32_t value; + + for (ramaddr = 0; ramaddr < 256; ramaddr++) + { + /*** the following lines are per Errata 7, 2.5 ***/ + { + pci_write_32 ((u_int32_t *) &comet->rlps_eq_rwsel, 0x80); /* Set up for a read + * operation */ + pci_flush_write (ci); /* for write order preservation when + * Optimizing driver */ + pci_write_32 ((u_int32_t *) &comet->rlps_eq_iaddr, (u_int8_t) ramaddr); /* write the addr, + * initiate a read */ + pci_flush_write (ci); /* for write order preservation when + * Optimizing driver */ + /* + * wait 3 line rate clock cycles to ensure address bits are + * captured by T1/E1 clock + */ + OS_uwait (4, "wret"); /* 683ns * 3 = 1366 ns, approx 2us (but + * use 4us) */ + } + + value = *table++; + pci_write_32 ((u_int32_t *) &comet->rlps_idata3, (u_int8_t) (value >> 24)); + pci_write_32 ((u_int32_t *) &comet->rlps_idata2, (u_int8_t) (value >> 16)); + pci_write_32 ((u_int32_t *) &comet->rlps_idata1, (u_int8_t) (value >> 8)); + pci_write_32 ((u_int32_t *) &comet->rlps_idata0, (u_int8_t) value); + pci_flush_write (ci); /* for write order preservation when + * Optimizing driver */ + + /* Storing RAM address, causes RAM to be updated */ + + pci_write_32 ((u_int32_t *) &comet->rlps_eq_rwsel, 0); /* Set up for a write + * operation */ + pci_flush_write (ci); /* for write order preservation when + * Optimizing driver */ + pci_write_32 ((u_int32_t *) &comet->rlps_eq_iaddr, (u_int8_t) ramaddr); /* write the addr, + * initiate a read */ + pci_flush_write (ci); /* for write order preservation when + * Optimizing driver */ + /* + * wait 3 line rate clock cycles to ensure address bits are captured + * by T1/E1 clock + */ + OS_uwait (4, "wret"); /* 683ns * 3 = 1366 ns, approx 2us (but + * use 4us) */ + } + + pci_write_32 ((u_int32_t *) &comet->rlps_eq_cfg, 0xCB); /* Enable Equalizer & + * set it to use 256 + * periods */ +} + + +/* +** Name: SetPwrLevel +** Description: Implement power level setting algorithm described below +** Returns: Nothing +*/ + +STATIC void +SetPwrLevel (comet_t * comet) +{ + volatile u_int32_t temp; + +/* +** Algorithm to Balance the Power Distribution of Ttip Tring +** +** Zero register F6 +** Write 0x01 to register F4 +** Write another 0x01 to register F4 +** Read register F4 +** Remove the 0x01 bit by Anding register F4 with 0xFE +** Write the resultant value to register F4 +** Repeat these steps for register F5 +** Write 0x01 to register F6 +*/ + pci_write_32 ((u_int32_t *) &comet->xlpg_fdata_sel, 0x00); /* XLPG Fuse Data Select */ + + pci_write_32 ((u_int32_t *) &comet->xlpg_atest_pctl, 0x01); /* XLPG Analog Test + * Positive control */ + pci_write_32 ((u_int32_t *) &comet->xlpg_atest_pctl, 0x01); + + temp = pci_read_32 ((u_int32_t *) &comet->xlpg_atest_pctl) & 0xfe; + pci_write_32 ((u_int32_t *) &comet->xlpg_atest_pctl, temp); + + pci_write_32 ((u_int32_t *) &comet->xlpg_atest_nctl, 0x01); /* XLPG Analog Test + * Negative control */ + pci_write_32 ((u_int32_t *) &comet->xlpg_atest_nctl, 0x01); + + temp = pci_read_32 ((u_int32_t *) &comet->xlpg_atest_nctl) & 0xfe; + pci_write_32 ((u_int32_t *) &comet->xlpg_atest_nctl, temp); + pci_write_32 ((u_int32_t *) &comet->xlpg_fdata_sel, 0x01); /* XLPG */ +} + + +/* +** Name: SetCometOps +** Description: Set up the selected Comet's clock edge drive for both +** the transmit out the analog side and receive to the +** backplane side. +** Returns: Nothing +*/ +#if 0 +STATIC void +SetCometOps (comet_t * comet) +{ + volatile u_int8_t rd_value; + + if (comet == mConfig.C4Func1Base + (COMET0_OFFSET >> 2)) + { + rd_value = (u_int8_t) pci_read_32 ((u_int32_t *) &comet->brif_cfg); /* read the BRIF + * Configuration */ + rd_value &= ~0x20; + pci_write_32 ((u_int32_t *) &comet->brif_cfg, (u_int32_t) rd_value); + + rd_value = (u_int8_t) pci_read_32 ((u_int32_t *) &comet->brif_fpcfg); /* read the BRIF Frame + * Pulse Configuration */ + rd_value &= ~0x20; + pci_write_32 ((u_int32_t *) &comet->brif_fpcfg, (u_int8_t) rd_value); + } else + { + rd_value = (u_int8_t) pci_read_32 ((u_int32_t *) &comet->brif_cfg); /* read the BRIF + * Configuration */ + rd_value |= 0x20; + pci_write_32 ((u_int32_t *) &comet->brif_cfg, (u_int32_t) rd_value); + + rd_value = (u_int8_t) pci_read_32 ((u_int32_t *) &comet->brif_fpcfg); /* read the BRIF Frame + * Pulse Configuration */ + rd_value |= 0x20; + pci_write_32 ((u_int32_t *) &comet->brif_fpcfg, (u_int8_t) rd_value); + } +} +#endif + +/*** End-of-File ***/ diff --git a/drivers/staging/cxt1e1/comet.h b/drivers/staging/cxt1e1/comet.h new file mode 100644 index 000000000000..5cb3afda0112 --- /dev/null +++ b/drivers/staging/cxt1e1/comet.h @@ -0,0 +1,366 @@ +/* + * $Id: comet.h,v 1.3 2005/09/28 00:10:07 rickd PMCC4_3_1B $ + */ + +#ifndef _INC_COMET_H_ +#define _INC_COMET_H_ + +/*----------------------------------------------------------------------------- + * comet.h - + * + * Copyright (C) 2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + * + * For further information, contact via email: support@sbei.com + * SBE, Inc. San Ramon, California U.S.A. + *----------------------------------------------------------------------------- + * RCS info: + * RCS revision: $Revision: 1.3 $ + * Last changed on $Date: 2005/09/28 00:10:07 $ + * Changed by $Author: rickd $ + *----------------------------------------------------------------------------- + * $Log: comet.h,v $ + * Revision 1.3 2005/09/28 00:10:07 rickd + * Add RCS header. Switch to structure usage. + * + * Revision 1.2 2005/04/28 23:43:03 rickd + * Add RCS tracking heading. + * + *----------------------------------------------------------------------------- + */ + +#if defined(__FreeBSD__) || defined (__NetBSD__) +#include <sys/types.h> +#else +#include <linux/types.h> +#endif + + +#define VINT32 volatile u_int32_t + +struct s_comet_reg +{ + VINT32 gbl_cfg; /* 00 Global Cfg */ + VINT32 clkmon; /* 01 Clk Monitor */ + VINT32 rx_opt; /* 02 RX Options */ + VINT32 rx_line_cfg; /* 03 RX Line Interface Cfg */ + VINT32 tx_line_cfg; /* 04 TX Line Interface Cfg */ + VINT32 tx_frpass; /* 05 TX Framing & Bypass Options */ + VINT32 tx_time; /* 06 TX Timing Options */ + VINT32 intr_1; /* 07 Intr Source #1 */ + VINT32 intr_2; /* 08 Intr Source #2 */ + VINT32 intr_3; /* 09 Intr Source #3 */ + VINT32 mdiag; /* 0A Master Diagnostics */ + VINT32 mtest; /* 0B Master Test */ + VINT32 adiag; /* 0C Analog Diagnostics */ + VINT32 rev_id; /* 0D Rev/Chip Id/Global PMON Update */ +#define pmon rev_id + VINT32 reset; /* 0E Reset */ + VINT32 prgd_phctl; /* 0F PRGD Positioning/Ctl & HDLC Ctl */ + VINT32 cdrc_cfg; /* 10 CDRC Cfg */ + VINT32 cdrc_ien; /* 11 CDRC Intr Enable */ + VINT32 cdrc_ists; /* 12 CDRC Intr Sts */ + VINT32 cdrc_alos; /* 13 CDRC Alternate Loss of Signal */ + + VINT32 rjat_ists; /* 14 RJAT Intr Sts */ + VINT32 rjat_n1clk; /* 15 RJAT Reference Clk Divisor (N1) Ctl */ + VINT32 rjat_n2clk; /* 16 RJAT Output Clk Divisor (N2) Ctl */ + VINT32 rjat_cfg; /* 17 RJAT Cfg */ + + VINT32 tjat_ists; /* 18 TJAT Intr Sts */ + VINT32 tjat_n1clk; /* 19 TJAT Reference Clk Divisor (N1) Ctl */ + VINT32 tjat_n2clk; /* 1A TJAT Output Clk Divisor (N2) Ctl */ + VINT32 tjat_cfg; /* 1B TJAT Cfg */ + + VINT32 rx_elst_cfg; /* 1C RX-ELST Cfg */ + VINT32 rx_elst_ists; /* 1D RX-ELST Intr Sts */ + VINT32 rx_elst_idle; /* 1E RX-ELST Idle Code */ + VINT32 _rx_elst_res1f; /* 1F RX-ELST Reserved */ + + VINT32 tx_elst_cfg; /* 20 TX-ELST Cfg */ + VINT32 tx_elst_ists; /* 21 TX-ELST Intr Sts */ + VINT32 _tx_elst_res22; /* 22 TX-ELST Reserved */ + VINT32 _tx_elst_res23; /* 23 TX-ELST Reserved */ + VINT32 __res24; /* 24 Reserved */ + VINT32 __res25; /* 25 Reserved */ + VINT32 __res26; /* 26 Reserved */ + VINT32 __res27; /* 27 Reserved */ + + VINT32 rxce1_ctl; /* 28 RXCE RX Data Link 1 Ctl */ + VINT32 rxce1_bits; /* 29 RXCE RX Data Link 1 Bit Select */ + VINT32 rxce2_ctl; /* 2A RXCE RX Data Link 2 Ctl */ + VINT32 rxce2_bits; /* 2B RXCE RX Data Link 2 Bit Select */ + VINT32 rxce3_ctl; /* 2C RXCE RX Data Link 3 Ctl */ + VINT32 rxce3_bits; /* 2D RXCE RX Data Link 3 Bit Select */ + VINT32 _rxce_res2E; /* 2E RXCE Reserved */ + VINT32 _rxce_res2F; /* 2F RXCE Reserved */ + + VINT32 brif_cfg; /* 30 BRIF RX Backplane Cfg */ + VINT32 brif_fpcfg; /* 31 BRIF RX Backplane Frame Pulse Cfg */ + VINT32 brif_pfcfg; /* 32 BRIF RX Backplane Parity/F-Bit Cfg */ + VINT32 brif_tsoff; /* 33 BRIF RX Backplane Time Slot Offset */ + VINT32 brif_boff; /* 34 BRIF RX Backplane Bit Offset */ + VINT32 _brif_res35; /* 35 BRIF RX Backplane Reserved */ + VINT32 _brif_res36; /* 36 BRIF RX Backplane Reserved */ + VINT32 _brif_res37; /* 37 BRIF RX Backplane Reserved */ + + VINT32 txci1_ctl; /* 38 TXCI TX Data Link 1 Ctl */ + VINT32 txci1_bits; /* 39 TXCI TX Data Link 2 Bit Select */ + VINT32 txci2_ctl; /* 3A TXCI TX Data Link 1 Ctl */ + VINT32 txci2_bits; /* 3B TXCI TX Data Link 2 Bit Select */ + VINT32 txci3_ctl; /* 3C TXCI TX Data Link 1 Ctl */ + VINT32 txci3_bits; /* 3D TXCI TX Data Link 2 Bit Select */ + VINT32 _txci_res3E; /* 3E TXCI Reserved */ + VINT32 _txci_res3F; /* 3F TXCI Reserved */ + + VINT32 btif_cfg; /* 40 BTIF TX Backplane Cfg */ + VINT32 btif_fpcfg; /* 41 BTIF TX Backplane Frame Pulse Cfg */ + VINT32 btif_pcfgsts; /* 42 BTIF TX Backplane Parity Cfg & Sts */ + VINT32 btif_tsoff; /* 43 BTIF TX Backplane Time Slot Offset */ + VINT32 btif_boff; /* 44 BTIF TX Backplane Bit Offset */ + VINT32 _btif_res45; /* 45 BTIF TX Backplane Reserved */ + VINT32 _btif_res46; /* 46 BTIF TX Backplane Reserved */ + VINT32 _btif_res47; /* 47 BTIF TX Backplane Reserved */ + VINT32 t1_frmr_cfg; /* 48 T1 FRMR Cfg */ + VINT32 t1_frmr_ien; /* 49 T1 FRMR Intr Enable */ + VINT32 t1_frmr_ists; /* 4A T1 FRMR Intr Sts */ + VINT32 __res_4B; /* 4B Reserved */ + VINT32 ibcd_cfg; /* 4C IBCD Cfg */ + VINT32 ibcd_ies; /* 4D IBCD Intr Enable/Sts */ + VINT32 ibcd_act; /* 4E IBCD Activate Code */ + VINT32 ibcd_deact; /* 4F IBCD Deactivate Code */ + + VINT32 sigx_cfg; /* 50 SIGX Cfg/Change of Signaling State */ + VINT32 sigx_acc_cos; /* 51 SIGX uP Access Sts/Change of Signaling State */ + VINT32 sigx_iac_cos; /* 52 SIGX Channel Indirect + * Addr/Ctl/Change of Signaling State */ + VINT32 sigx_idb_cos; /* 53 SIGX Channel Indirect Data + * Buffer/Change of Signaling State */ + + VINT32 t1_xbas_cfg; /* 54 T1 XBAS Cfg */ + VINT32 t1_xbas_altx; /* 55 T1 XBAS Alarm TX */ + VINT32 t1_xibc_ctl; /* 56 T1 XIBC Ctl */ + VINT32 t1_xibc_lbcode; /* 57 T1 XIBC Loopback Code */ + + VINT32 pmon_ies; /* 58 PMON Intr Enable/Sts */ + VINT32 pmon_fberr; /* 59 PMON Framing Bit Err Cnt */ + VINT32 pmon_feb_lsb; /* 5A PMON OFF/COFA/Far End Block Err Cnt (LSB) */ + VINT32 pmon_feb_msb; /* 5B PMON OFF/COFA/Far End Block Err Cnt (MSB) */ + VINT32 pmon_bed_lsb; /* 5C PMON Bit/Err/CRCE Cnt (LSB) */ + VINT32 pmon_bed_msb; /* 5D PMON Bit/Err/CRCE Cnt (MSB) */ + VINT32 pmon_lvc_lsb; /* 5E PMON LVC Cnt (LSB) */ + VINT32 pmon_lvc_msb; /* 5F PMON LVC Cnt (MSB) */ + + VINT32 t1_almi_cfg; /* 60 T1 ALMI Cfg */ + VINT32 t1_almi_ien; /* 61 T1 ALMI Intr Enable */ + VINT32 t1_almi_ists; /* 62 T1 ALMI Intr Sts */ + VINT32 t1_almi_detsts; /* 63 T1 ALMI Alarm Detection Sts */ + + VINT32 _t1_pdvd_res64; /* 64 T1 PDVD Reserved */ + VINT32 t1_pdvd_ies; /* 65 T1 PDVD Intr Enable/Sts */ + VINT32 _t1_xboc_res66; /* 66 T1 XBOC Reserved */ + VINT32 t1_xboc_code; /* 67 T1 XBOC Code */ + VINT32 _t1_xpde_res68; /* 68 T1 XPDE Reserved */ + VINT32 t1_xpde_ies; /* 69 T1 XPDE Intr Enable/Sts */ + + VINT32 t1_rboc_ena; /* 6A T1 RBOC Enable */ + VINT32 t1_rboc_sts; /* 6B T1 RBOC Code Sts */ + + VINT32 t1_tpsc_cfg; /* 6C TPSC Cfg */ + VINT32 t1_tpsc_sts; /* 6D TPSC uP Access Sts */ + VINT32 t1_tpsc_ciaddr; /* 6E TPSC Channel Indirect + * Addr/Ctl */ + VINT32 t1_tpsc_cidata; /* 6F TPSC Channel Indirect Data + * Buffer */ + VINT32 t1_rpsc_cfg; /* 70 RPSC Cfg */ + VINT32 t1_rpsc_sts; /* 71 RPSC uP Access Sts */ + VINT32 t1_rpsc_ciaddr; /* 72 RPSC Channel Indirect + * Addr/Ctl */ + VINT32 t1_rpsc_cidata; /* 73 RPSC Channel Indirect Data + * Buffer */ + VINT32 __res74; /* 74 Reserved */ + VINT32 __res75; /* 75 Reserved */ + VINT32 __res76; /* 76 Reserved */ + VINT32 __res77; /* 77 Reserved */ + + VINT32 t1_aprm_cfg; /* 78 T1 APRM Cfg/Ctl */ + VINT32 t1_aprm_load; /* 79 T1 APRM Manual Load */ + VINT32 t1_aprm_ists; /* 7A T1 APRM Intr Sts */ + VINT32 t1_aprm_1sec_2; /* 7B T1 APRM One Second Content Octet 2 */ + VINT32 t1_aprm_1sec_3; /* 7C T1 APRM One Second Content Octet 3 */ + VINT32 t1_aprm_1sec_4; /* 7D T1 APRM One Second Content Octet 4 */ + VINT32 t1_aprm_1sec_5; /* 7E T1 APRM One Second Content MSB (Octect 5) */ + VINT32 t1_aprm_1sec_6; /* 7F T1 APRM One Second Content MSB (Octect 6) */ + + VINT32 e1_tran_cfg; /* 80 E1 TRAN Cfg */ + VINT32 e1_tran_txalarm; /* 81 E1 TRAN TX Alarm/Diagnostic Ctl */ + VINT32 e1_tran_intctl; /* 82 E1 TRAN International Ctl */ + VINT32 e1_tran_extrab; /* 83 E1 TRAN Extra Bits Ctl */ + VINT32 e1_tran_ien; /* 84 E1 TRAN Intr Enable */ + VINT32 e1_tran_ists; /* 85 E1 TRAN Intr Sts */ + VINT32 e1_tran_nats; /* 86 E1 TRAN National Bit Codeword + * Select */ + VINT32 e1_tran_nat; /* 87 E1 TRAN National Bit Codeword */ + VINT32 __res88; /* 88 Reserved */ + VINT32 __res89; /* 89 Reserved */ + VINT32 __res8A; /* 8A Reserved */ + VINT32 __res8B; /* 8B Reserved */ + + VINT32 _t1_frmr_res8C; /* 8C T1 FRMR Reserved */ + VINT32 _t1_frmr_res8D; /* 8D T1 FRMR Reserved */ + VINT32 __res8E; /* 8E Reserved */ + VINT32 __res8F; /* 8F Reserved */ + + VINT32 e1_frmr_aopts; /* 90 E1 FRMR Frame Alignment Options */ + VINT32 e1_frmr_mopts; /* 91 E1 FRMR Maintenance Mode Options */ + VINT32 e1_frmr_ien; /* 92 E1 FRMR Framing Sts Intr Enable */ + VINT32 e1_frmr_mien; /* 93 E1 FRMR Maintenance/Alarm Sts Intr Enable */ + VINT32 e1_frmr_ists; /* 94 E1 FRMR Framing Sts Intr Indication */ + VINT32 e1_frmr_mists; /* 95 E1 FRMR Maintenance/Alarm Sts Indication Enable */ + VINT32 e1_frmr_sts; /* 96 E1 FRMR Framing Sts */ + VINT32 e1_frmr_masts; /* 97 E1 FRMR Maintenance/Alarm Sts */ + VINT32 e1_frmr_nat_bits; /* 98 E1 FRMR International/National Bits */ + VINT32 e1_frmr_crc_lsb; /* 99 E1 FRMR CRC Err Cnt - LSB */ + VINT32 e1_frmr_crc_msb; /* 9A E1 FRMR CRC Err Cnt - MSB */ + VINT32 e1_frmr_nat_ien; /* 9B E1 FRMR National Bit Codeword Intr Enables */ + VINT32 e1_frmr_nat_ists; /* 9C E1 FRMR National Bit Codeword Intr/Sts */ + VINT32 e1_frmr_nat; /* 9D E1 FRMR National Bit Codewords */ + VINT32 e1_frmr_fp_ien; /* 9E E1 FRMR Frame Pulse/Alarm Intr Enables */ + VINT32 e1_frmr_fp_ists; /* 9F E1 FRMR Frame Pulse/Alarm Intr/Sts */ + + VINT32 __resA0; /* A0 Reserved */ + VINT32 __resA1; /* A1 Reserved */ + VINT32 __resA2; /* A2 Reserved */ + VINT32 __resA3; /* A3 Reserved */ + VINT32 __resA4; /* A4 Reserved */ + VINT32 __resA5; /* A5 Reserved */ + VINT32 __resA6; /* A6 Reserved */ + VINT32 __resA7; /* A7 Reserved */ + + VINT32 tdpr1_cfg; /* A8 TDPR #1 Cfg */ + VINT32 tdpr1_utl; /* A9 TDPR #1 Upper TX Threshold */ + VINT32 tdpr1_ltl; /* AA TDPR #1 Lower TX Threshold */ + VINT32 tdpr1_ien; /* AB TDPR #1 Intr Enable */ + VINT32 tdpr1_ists; /* AC TDPR #1 Intr Sts/UDR Clear */ + VINT32 tdpr1_data; /* AD TDPR #1 TX Data */ + VINT32 __resAE; /* AE Reserved */ + VINT32 __resAF; /* AF Reserved */ + VINT32 tdpr2_cfg; /* B0 TDPR #2 Cfg */ + VINT32 tdpr2_utl; /* B1 TDPR #2 Upper TX Threshold */ + VINT32 tdpr2_ltl; /* B2 TDPR #2 Lower TX Threshold */ + VINT32 tdpr2_ien; /* B3 TDPR #2 Intr Enable */ + VINT32 tdpr2_ists; /* B4 TDPR #2 Intr Sts/UDR Clear */ + VINT32 tdpr2_data; /* B5 TDPR #2 TX Data */ + VINT32 __resB6; /* B6 Reserved */ + VINT32 __resB7; /* B7 Reserved1 */ + VINT32 tdpr3_cfg; /* B8 TDPR #3 Cfg */ + VINT32 tdpr3_utl; /* B9 TDPR #3 Upper TX Threshold */ + VINT32 tdpr3_ltl; /* BA TDPR #3 Lower TX Threshold */ + VINT32 tdpr3_ien; /* BB TDPR #3 Intr Enable */ + VINT32 tdpr3_ists; /* BC TDPR #3 Intr Sts/UDR Clear */ + VINT32 tdpr3_data; /* BD TDPR #3 TX Data */ + VINT32 __resBE; /* BE Reserved */ + VINT32 __resBF; /* BF Reserved */ + + VINT32 rdlc1_cfg; /* C0 RDLC #1 Cfg */ + VINT32 rdlc1_intctl; /* C1 RDLC #1 Intr Ctl */ + VINT32 rdlc1_sts; /* C2 RDLC #1 Sts */ + VINT32 rdlc1_data; /* C3 RDLC #1 Data */ + VINT32 rdlc1_paddr; /* C4 RDLC #1 Primary Addr Match */ + VINT32 rdlc1_saddr; /* C5 RDLC #1 Secondary Addr Match */ + VINT32 __resC6; /* C6 Reserved */ + VINT32 __resC7; /* C7 Reserved */ + VINT32 rdlc2_cfg; /* C8 RDLC #2 Cfg */ + VINT32 rdlc2_intctl; /* C9 RDLC #2 Intr Ctl */ + VINT32 rdlc2_sts; /* CA RDLC #2 Sts */ + VINT32 rdlc2_data; /* CB RDLC #2 Data */ + VINT32 rdlc2_paddr; /* CC RDLC #2 Primary Addr Match */ + VINT32 rdlc2_saddr; /* CD RDLC #2 Secondary Addr Match */ + VINT32 __resCE; /* CE Reserved */ + VINT32 __resCF; /* CF Reserved */ + VINT32 rdlc3_cfg; /* D0 RDLC #3 Cfg */ + VINT32 rdlc3_intctl; /* D1 RDLC #3 Intr Ctl */ + VINT32 rdlc3_sts; /* D2 RDLC #3 Sts */ + VINT32 rdlc3_data; /* D3 RDLC #3 Data */ + VINT32 rdlc3_paddr; /* D4 RDLC #3 Primary Addr Match */ + VINT32 rdlc3_saddr; /* D5 RDLC #3 Secondary Addr Match */ + + VINT32 csu_cfg; /* D6 CSU Cfg */ + VINT32 _csu_resD7; /* D7 CSU Reserved */ + + VINT32 rlps_idata3; /* D8 RLPS Indirect Data, 24-31 */ + VINT32 rlps_idata2; /* D9 RLPS Indirect Data, 16-23 */ + VINT32 rlps_idata1; /* DA RLPS Indirect Data, 8-15 */ + VINT32 rlps_idata0; /* DB RLPS Indirect Data, 0-7 */ + VINT32 rlps_eqvr; /* DC RLPS Equalizer Voltage Reference + * (E1 missing) */ + VINT32 _rlps_resDD; /* DD RLPS Reserved */ + VINT32 _rlps_resDE; /* DE RLPS Reserved */ + VINT32 _rlps_resDF; /* DF RLPS Reserved */ + + VINT32 prgd_ctl; /* E0 PRGD Ctl */ + VINT32 prgd_ies; /* E1 PRGD Intr Enable/Sts */ + VINT32 prgd_shift_len; /* E2 PRGD Shift Length */ + VINT32 prgd_tap; /* E3 PRGD Tap */ + VINT32 prgd_errin; /* E4 PRGD Err Insertion */ + VINT32 _prgd_resE5; /* E5 PRGD Reserved */ + VINT32 _prgd_resE6; /* E6 PRGD Reserved */ + VINT32 _prgd_resE7; /* E7 PRGD Reserved */ + VINT32 prgd_patin1; /* E8 PRGD Pattern Insertion #1 */ + VINT32 prgd_patin2; /* E9 PRGD Pattern Insertion #2 */ + VINT32 prgd_patin3; /* EA PRGD Pattern Insertion #3 */ + VINT32 prgd_patin4; /* EB PRGD Pattern Insertion #4 */ + VINT32 prgd_patdet1; /* EC PRGD Pattern Detector #1 */ + VINT32 prgd_patdet2; /* ED PRGD Pattern Detector #2 */ + VINT32 prgd_patdet3; /* EE PRGD Pattern Detector #3 */ + VINT32 prgd_patdet4; /* EF PRGD Pattern Detector #4 */ + + VINT32 xlpg_cfg; /* F0 XLPG Line Driver Cfg */ + VINT32 xlpg_ctlsts; /* F1 XLPG Ctl/Sts */ + VINT32 xlpg_pwave_addr; /* F2 XLPG Pulse Waveform Storage Write Addr */ + VINT32 xlpg_pwave_data; /* F3 XLPG Pulse Waveform Storage Data */ + VINT32 xlpg_atest_pctl; /* F4 XLPG Analog Test Positive Ctl */ + VINT32 xlpg_atest_nctl; /* F5 XLPG Analog Test Negative Ctl */ + VINT32 xlpg_fdata_sel; /* F6 XLPG Fuse Data Select */ + VINT32 _xlpg_resF7; /* F7 XLPG Reserved */ + + VINT32 rlps_cfgsts; /* F8 RLPS Cfg & Sts */ + VINT32 rlps_alos_thresh; /* F9 RLPS ALOS Detection/Clearance Threshold */ + VINT32 rlps_alos_dper; /* FA RLPS ALOS Detection Period */ + VINT32 rlps_alos_cper; /* FB RLPS ALOS Clearance Period */ + VINT32 rlps_eq_iaddr; /* FC RLPS Equalization Indirect Addr */ + VINT32 rlps_eq_rwsel; /* FD RLPS Equalization Read/WriteB Select */ + VINT32 rlps_eq_ctlsts; /* FE RLPS Equalizer Loop Sts & Ctl */ + VINT32 rlps_eq_cfg; /* FF RLPS Equalizer Cfg */ +}; + +typedef struct s_comet_reg comet_t; + +/* 00AH: MDIAG Register bit definitions */ +#define COMET_MDIAG_ID5 0x40 +#define COMET_MDIAG_LBMASK 0x3F +#define COMET_MDIAG_PAYLB 0x20 +#define COMET_MDIAG_LINELB 0x10 +#define COMET_MDIAG_RAIS 0x08 +#define COMET_MDIAG_DDLB 0x04 +#define COMET_MDIAG_TXMFP 0x02 +#define COMET_MDIAG_TXLOS 0x01 +#define COMET_MDIAG_LBOFF 0x00 + +#undef VINT32 + +#ifdef __KERNEL__ +extern void +init_comet (void *, comet_t *, u_int32_t, int, u_int8_t); +#endif + +#endif /* _INC_COMET_H_ */ diff --git a/drivers/staging/cxt1e1/comet_tables.c b/drivers/staging/cxt1e1/comet_tables.c new file mode 100644 index 000000000000..db1293c71a6d --- /dev/null +++ b/drivers/staging/cxt1e1/comet_tables.c @@ -0,0 +1,561 @@ +/* + * $Id: comet_tables.c,v 1.2 2005/10/17 23:55:27 rickd PMCC4_3_1B $ + */ + +/*----------------------------------------------------------------------------- + * comet_tables.c - waveform tables for the PM4351 'COMET' + * + * Copyright (C) 2003-2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + * + * For further information, contact via email: support@sbei.com + * SBE, Inc. San Ramon, California U.S.A. + *----------------------------------------------------------------------------- + * RCS info: + * RCS revision: $Revision: 1.2 $ + * Last changed on $Date: 2005/10/17 23:55:27 $ + * Changed by $Author: rickd $ + *----------------------------------------------------------------------------- + * $Log: comet_tables.c,v $ + * Revision 1.2 2005/10/17 23:55:27 rickd + * Note that 75 Ohm transmit waveform is not supported on PMCC4. + * + * Revision 1.1 2005/09/28 00:10:05 rickd + * Cosmetic alignment of tables for readability. + * + * Revision 1.0 2005/05/10 22:47:53 rickd + * Initial revision + * + *----------------------------------------------------------------------------- + */ + +char SBEid_pmcc4_comet_tblc[] = + "@(#)comet_tables.c - $Revision: 1.2 $ (c) Copyright 2004-2005 SBE, Inc."; + + +#include <linux/types.h> + +/***************************************************************************** +* +* Array names: +* +* TWVLongHaul0DB +* TWVLongHaul7_5DB +* TWVLongHaul15DB +* TWVLongHaul22_5DB +* TWVShortHaul0 +* TWVShortHaul1 +* TWVShortHaul2 +* TWVShortHaul3 +* TWVShortHaul4 +* TWVShortHaul5 +* TWV_E1_120Ohm +* TWV_E1_75Ohm <not supported> +* T1_Equalizer +* E1_Equalizer +* +*****************************************************************************/ + +u_int8_t TWVLongHaul0DB[25][5] =/* T1 Long Haul 0 DB */ +{ + {0x00, 0x44, 0x00, 0x00, 0x00}, /* Sample 0 */ + {0x0A, 0x44, 0x00, 0x00, 0x00}, /* Sample 1 */ + {0x20, 0x43, 0x00, 0x00, 0x00}, /* Sample 2 */ + {0x32, 0x43, 0x00, 0x00, 0x00}, /* Sample 3 */ + {0x3E, 0x42, 0x00, 0x00, 0x00}, /* Sample 4 */ + {0x3D, 0x42, 0x00, 0x00, 0x00}, /* Sample 5 */ + {0x3C, 0x41, 0x00, 0x00, 0x00}, /* Sample 6 */ + {0x3B, 0x41, 0x00, 0x00, 0x00}, /* Sample 7 */ + {0x3A, 0x00, 0x00, 0x00, 0x00}, /* Sample 8 */ + {0x39, 0x00, 0x00, 0x00, 0x00}, /* Sample 9 */ + {0x39, 0x00, 0x00, 0x00, 0x00}, /* Sample 10 */ + {0x38, 0x00, 0x00, 0x00, 0x00}, /* Sample 11 */ + {0x37, 0x00, 0x00, 0x00, 0x00}, /* Sample 12 */ + {0x36, 0x00, 0x00, 0x00, 0x00}, /* Sample 13 */ + {0x34, 0x00, 0x00, 0x00, 0x00}, /* Sample 14 */ + {0x29, 0x00, 0x00, 0x00, 0x00}, /* Sample 15 */ + {0x4F, 0x00, 0x00, 0x00, 0x00}, /* Sample 16 */ + {0x4C, 0x00, 0x00, 0x00, 0x00}, /* Sample 17 */ + {0x4A, 0x00, 0x00, 0x00, 0x00}, /* Sample 18 */ + {0x49, 0x00, 0x00, 0x00, 0x00}, /* Sample 19 */ + {0x47, 0x00, 0x00, 0x00, 0x00}, /* Sample 20 */ + {0x47, 0x00, 0x00, 0x00, 0x00}, /* Sample 21 */ + {0x46, 0x00, 0x00, 0x00, 0x00}, /* Sample 22 */ + {0x46, 0x00, 0x00, 0x00, 0x00}, /* Sample 23 */ + {0x0C} /* PMC's suggested value */ +/* {0x14} Output Amplitude */ +}; + +u_int8_t TWVLongHaul7_5DB[25][5] = /* T1 Long Haul 7.5 DB */ +{ + {0x00, 0x10, 0x00, 0x00, 0x00}, /* Sample 0 */ + {0x01, 0x0E, 0x00, 0x00, 0x00}, /* Sample 1 */ + {0x02, 0x0C, 0x00, 0x00, 0x00}, /* Sample 2 */ + {0x04, 0x0A, 0x00, 0x00, 0x00}, /* Sample 3 */ + {0x08, 0x08, 0x00, 0x00, 0x00}, /* Sample 4 */ + {0x0C, 0x06, 0x00, 0x00, 0x00}, /* Sample 5 */ + {0x10, 0x04, 0x00, 0x00, 0x00}, /* Sample 6 */ + {0x16, 0x02, 0x00, 0x00, 0x00}, /* Sample 7 */ + {0x1A, 0x01, 0x00, 0x00, 0x00}, /* Sample 8 */ + {0x1E, 0x00, 0x00, 0x00, 0x00}, /* Sample 9 */ + {0x22, 0x00, 0x00, 0x00, 0x00}, /* Sample 10 */ + {0x26, 0x00, 0x00, 0x00, 0x00}, /* Sample 11 */ + {0x2A, 0x00, 0x00, 0x00, 0x00}, /* Sample 12 */ + {0x2B, 0x00, 0x00, 0x00, 0x00}, /* Sample 13 */ + {0x2C, 0x00, 0x00, 0x00, 0x00}, /* Sample 14 */ + {0x2D, 0x00, 0x00, 0x00, 0x00}, /* Sample 15 */ + {0x2C, 0x00, 0x00, 0x00, 0x00}, /* Sample 16 */ + {0x28, 0x00, 0x00, 0x00, 0x00}, /* Sample 17 */ + {0x24, 0x00, 0x00, 0x00, 0x00}, /* Sample 18 */ + {0x20, 0x00, 0x00, 0x00, 0x00}, /* Sample 19 */ + {0x1C, 0x00, 0x00, 0x00, 0x00}, /* Sample 20 */ + {0x18, 0x00, 0x00, 0x00, 0x00}, /* Sample 21 */ + {0x14, 0x00, 0x00, 0x00, 0x00}, /* Sample 22 */ + {0x12, 0x00, 0x00, 0x00, 0x00}, /* Sample 23 */ + {0x07} /* PMC's suggested value */ +/* { 0x0A } Output Amplitude */ +}; + +u_int8_t TWVLongHaul15DB[25][5] = /* T1 Long Haul 15 DB */ +{ + {0x00, 0x2A, 0x09, 0x01, 0x00}, /* Sample 0 */ + {0x00, 0x28, 0x08, 0x01, 0x00}, /* Sample 1 */ + {0x00, 0x26, 0x08, 0x01, 0x00}, /* Sample 2 */ + {0x00, 0x24, 0x07, 0x01, 0x00}, /* Sample 3 */ + {0x01, 0x22, 0x07, 0x01, 0x00}, /* Sample 4 */ + {0x02, 0x20, 0x06, 0x01, 0x00}, /* Sample 5 */ + {0x04, 0x1E, 0x06, 0x01, 0x00}, /* Sample 6 */ + {0x07, 0x1C, 0x05, 0x00, 0x00}, /* Sample 7 */ + {0x0A, 0x1B, 0x05, 0x00, 0x00}, /* Sample 8 */ + {0x0D, 0x19, 0x05, 0x00, 0x00}, /* Sample 9 */ + {0x10, 0x18, 0x04, 0x00, 0x00}, /* Sample 10 */ + {0x14, 0x16, 0x04, 0x00, 0x00}, /* Sample 11 */ + {0x18, 0x15, 0x04, 0x00, 0x00}, /* Sample 12 */ + {0x1B, 0x13, 0x03, 0x00, 0x00}, /* Sample 13 */ + {0x1E, 0x12, 0x03, 0x00, 0x00}, /* Sample 14 */ + {0x21, 0x10, 0x03, 0x00, 0x00}, /* Sample 15 */ + {0x24, 0x0F, 0x03, 0x00, 0x00}, /* Sample 16 */ + {0x27, 0x0D, 0x03, 0x00, 0x00}, /* Sample 17 */ + {0x2A, 0x0D, 0x02, 0x00, 0x00}, /* Sample 18 */ + {0x2D, 0x0B, 0x02, 0x00, 0x00}, /* Sample 19 */ + {0x30, 0x0B, 0x02, 0x00, 0x00}, /* Sample 20 */ + {0x30, 0x0A, 0x02, 0x00, 0x00}, /* Sample 21 */ + {0x2E, 0x0A, 0x02, 0x00, 0x00}, /* Sample 22 */ + {0x2C, 0x09, 0x02, 0x00, 0x00}, /* Sample 23 */ + {0x03} /* Output Amplitude */ +}; + +u_int8_t TWVLongHaul22_5DB[25][5] = /* T1 Long Haul 22.5 DB */ +{ + {0x00, 0x1F, 0x16, 0x06, 0x01}, /* Sample 0 */ + {0x00, 0x20, 0x15, 0x05, 0x01}, /* Sample 1 */ + {0x00, 0x21, 0x15, 0x05, 0x01}, /* Sample 2 */ + {0x00, 0x22, 0x14, 0x05, 0x01}, /* Sample 3 */ + {0x00, 0x22, 0x13, 0x04, 0x00}, /* Sample 4 */ + {0x00, 0x23, 0x12, 0x04, 0x00}, /* Sample 5 */ + {0x01, 0x23, 0x12, 0x04, 0x00}, /* Sample 6 */ + {0x01, 0x24, 0x11, 0x03, 0x00}, /* Sample 7 */ + {0x01, 0x23, 0x10, 0x03, 0x00}, /* Sample 8 */ + {0x02, 0x23, 0x10, 0x03, 0x00}, /* Sample 9 */ + {0x03, 0x22, 0x0F, 0x03, 0x00}, /* Sample 10 */ + {0x05, 0x22, 0x0E, 0x03, 0x00}, /* Sample 11 */ + {0x07, 0x21, 0x0E, 0x02, 0x00}, /* Sample 12 */ + {0x09, 0x20, 0x0D, 0x02, 0x00}, /* Sample 13 */ + {0x0B, 0x1E, 0x0C, 0x02, 0x00}, /* Sample 14 */ + {0x0E, 0x1D, 0x0C, 0x02, 0x00}, /* Sample 15 */ + {0x10, 0x1B, 0x0B, 0x02, 0x00}, /* Sample 16 */ + {0x13, 0x1B, 0x0A, 0x02, 0x00}, /* Sample 17 */ + {0x15, 0x1A, 0x0A, 0x02, 0x00}, /* Sample 18 */ + {0x17, 0x19, 0x09, 0x01, 0x00}, /* Sample 19 */ + {0x19, 0x19, 0x08, 0x01, 0x00}, /* Sample 20 */ + {0x1B, 0x18, 0x08, 0x01, 0x00}, /* Sample 21 */ + {0x1D, 0x17, 0x07, 0x01, 0x00}, /* Sample 22 */ + {0x1E, 0x17, 0x06, 0x01, 0x00}, /* Sample 23 */ + {0x02} /* Output Amplitude */ +}; + +u_int8_t TWVShortHaul0[25][5] = /* T1 Short Haul 0 - 110 ft */ +{ + {0x00, 0x45, 0x00, 0x00, 0x00}, /* Sample 0 */ + {0x0A, 0x44, 0x00, 0x00, 0x00}, /* Sample 1 */ + {0x20, 0x43, 0x00, 0x00, 0x00}, /* Sample 2 */ + {0x3F, 0x43, 0x00, 0x00, 0x00}, /* Sample 3 */ + {0x3F, 0x42, 0x00, 0x00, 0x00}, /* Sample 4 */ + {0x3F, 0x42, 0x00, 0x00, 0x00}, /* Sample 5 */ + {0x3C, 0x41, 0x00, 0x00, 0x00}, /* Sample 6 */ + {0x3B, 0x41, 0x00, 0x00, 0x00}, /* Sample 7 */ + {0x3A, 0x00, 0x00, 0x00, 0x00}, /* Sample 8 */ + {0x39, 0x00, 0x00, 0x00, 0x00}, /* Sample 9 */ + {0x39, 0x00, 0x00, 0x00, 0x00}, /* Sample 10 */ + {0x38, 0x00, 0x00, 0x00, 0x00}, /* Sample 11 */ + {0x37, 0x00, 0x00, 0x00, 0x00}, /* Sample 12 */ + {0x36, 0x00, 0x00, 0x00, 0x00}, /* Sample 13 */ + {0x34, 0x00, 0x00, 0x00, 0x00}, /* Sample 14 */ + {0x29, 0x00, 0x00, 0x00, 0x00}, /* Sample 15 */ + {0x59, 0x00, 0x00, 0x00, 0x00}, /* Sample 16 */ + {0x55, 0x00, 0x00, 0x00, 0x00}, /* Sample 17 */ + {0x50, 0x00, 0x00, 0x00, 0x00}, /* Sample 18 */ + {0x4D, 0x00, 0x00, 0x00, 0x00}, /* Sample 19 */ + {0x4A, 0x00, 0x00, 0x00, 0x00}, /* Sample 20 */ + {0x48, 0x00, 0x00, 0x00, 0x00}, /* Sample 21 */ + {0x46, 0x00, 0x00, 0x00, 0x00}, /* Sample 22 */ + {0x46, 0x00, 0x00, 0x00, 0x00}, /* Sample 23 */ + {0x0C} /* Output Amplitude */ +}; + +u_int8_t TWVShortHaul1[25][5] = /* T1 Short Haul 110 - 220 ft */ +{ + {0x00, 0x44, 0x00, 0x00, 0x00}, /* Sample 0 */ + {0x0A, 0x44, 0x00, 0x00, 0x00}, /* Sample 1 */ + {0x3F, 0x43, 0x00, 0x00, 0x00}, /* Sample 2 */ + {0x3F, 0x43, 0x00, 0x00, 0x00}, /* Sample 3 */ + {0x36, 0x42, 0x00, 0x00, 0x00}, /* Sample 4 */ + {0x34, 0x42, 0x00, 0x00, 0x00}, /* Sample 5 */ + {0x30, 0x41, 0x00, 0x00, 0x00}, /* Sample 6 */ + {0x2F, 0x41, 0x00, 0x00, 0x00}, /* Sample 7 */ + {0x2E, 0x00, 0x00, 0x00, 0x00}, /* Sample 8 */ + {0x2D, 0x00, 0x00, 0x00, 0x00}, /* Sample 9 */ + {0x2C, 0x00, 0x00, 0x00, 0x00}, /* Sample 10 */ + {0x2B, 0x00, 0x00, 0x00, 0x00}, /* Sample 11 */ + {0x2A, 0x00, 0x00, 0x00, 0x00}, /* Sample 12 */ + {0x28, 0x00, 0x00, 0x00, 0x00}, /* Sample 13 */ + {0x26, 0x00, 0x00, 0x00, 0x00}, /* Sample 14 */ + {0x4A, 0x00, 0x00, 0x00, 0x00}, /* Sample 15 */ + {0x68, 0x00, 0x00, 0x00, 0x00}, /* Sample 16 */ + {0x54, 0x00, 0x00, 0x00, 0x00}, /* Sample 17 */ + {0x4F, 0x00, 0x00, 0x00, 0x00}, /* Sample 18 */ + {0x4A, 0x00, 0x00, 0x00, 0x00}, /* Sample 19 */ + {0x49, 0x00, 0x00, 0x00, 0x00}, /* Sample 20 */ + {0x47, 0x00, 0x00, 0x00, 0x00}, /* Sample 21 */ + {0x47, 0x00, 0x00, 0x00, 0x00}, /* Sample 22 */ + {0x46, 0x00, 0x00, 0x00, 0x00}, /* Sample 23 */ + {0x10} /* Output Amplitude */ +}; + +u_int8_t TWVShortHaul2[25][5] = /* T1 Short Haul 220 - 330 ft */ +{ + {0x00, 0x44, 0x00, 0x00, 0x00}, /* Sample 0 */ + {0x0A, 0x44, 0x00, 0x00, 0x00}, /* Sample 1 */ + {0x3F, 0x43, 0x00, 0x00, 0x00}, /* Sample 2 */ + {0x3A, 0x43, 0x00, 0x00, 0x00}, /* Sample 3 */ + {0x3A, 0x42, 0x00, 0x00, 0x00}, /* Sample 4 */ + {0x38, 0x42, 0x00, 0x00, 0x00}, /* Sample 5 */ + {0x30, 0x41, 0x00, 0x00, 0x00}, /* Sample 6 */ + {0x2F, 0x41, 0x00, 0x00, 0x00}, /* Sample 7 */ + {0x2E, 0x00, 0x00, 0x00, 0x00}, /* Sample 8 */ + {0x2D, 0x00, 0x00, 0x00, 0x00}, /* Sample 9 */ + {0x2C, 0x00, 0x00, 0x00, 0x00}, /* Sample 10 */ + {0x2B, 0x00, 0x00, 0x00, 0x00}, /* Sample 11 */ + {0x2A, 0x00, 0x00, 0x00, 0x00}, /* Sample 12 */ + {0x29, 0x00, 0x00, 0x00, 0x00}, /* Sample 13 */ + {0x23, 0x00, 0x00, 0x00, 0x00}, /* Sample 14 */ + {0x4A, 0x00, 0x00, 0x00, 0x00}, /* Sample 15 */ + {0x6C, 0x00, 0x00, 0x00, 0x00}, /* Sample 16 */ + {0x60, 0x00, 0x00, 0x00, 0x00}, /* Sample 17 */ + {0x4F, 0x00, 0x00, 0x00, 0x00}, /* Sample 18 */ + {0x4A, 0x00, 0x00, 0x00, 0x00}, /* Sample 19 */ + {0x49, 0x00, 0x00, 0x00, 0x00}, /* Sample 20 */ + {0x47, 0x00, 0x00, 0x00, 0x00}, /* Sample 21 */ + {0x47, 0x00, 0x00, 0x00, 0x00}, /* Sample 22 */ + {0x46, 0x00, 0x00, 0x00, 0x00}, /* Sample 23 */ + {0x11} /* Output Amplitude */ +}; + +u_int8_t TWVShortHaul3[25][5] = /* T1 Short Haul 330 - 440 ft */ +{ + {0x00, 0x44, 0x00, 0x00, 0x00}, /* Sample 0 */ + {0x0A, 0x44, 0x00, 0x00, 0x00}, /* Sample 1 */ + {0x3F, 0x43, 0x00, 0x00, 0x00}, /* Sample 2 */ + {0x3F, 0x43, 0x00, 0x00, 0x00}, /* Sample 3 */ + {0x3F, 0x42, 0x00, 0x00, 0x00}, /* Sample 4 */ + {0x3F, 0x42, 0x00, 0x00, 0x00}, /* Sample 5 */ + {0x2F, 0x41, 0x00, 0x00, 0x00}, /* Sample 6 */ + {0x2E, 0x41, 0x00, 0x00, 0x00}, /* Sample 7 */ + {0x2D, 0x00, 0x00, 0x00, 0x00}, /* Sample 8 */ + {0x2C, 0x00, 0x00, 0x00, 0x00}, /* Sample 9 */ + {0x2B, 0x00, 0x00, 0x00, 0x00}, /* Sample 10 */ + {0x2A, 0x00, 0x00, 0x00, 0x00}, /* Sample 11 */ + {0x29, 0x00, 0x00, 0x00, 0x00}, /* Sample 12 */ + {0x28, 0x00, 0x00, 0x00, 0x00}, /* Sample 13 */ + {0x19, 0x00, 0x00, 0x00, 0x00}, /* Sample 14 */ + {0x4A, 0x00, 0x00, 0x00, 0x00}, /* Sample 15 */ + {0x7F, 0x00, 0x00, 0x00, 0x00}, /* Sample 16 */ + {0x60, 0x00, 0x00, 0x00, 0x00}, /* Sample 17 */ + {0x4F, 0x00, 0x00, 0x00, 0x00}, /* Sample 18 */ + {0x4A, 0x00, 0x00, 0x00, 0x00}, /* Sample 19 */ + {0x49, 0x00, 0x00, 0x00, 0x00}, /* Sample 20 */ + {0x47, 0x00, 0x00, 0x00, 0x00}, /* Sample 21 */ + {0x47, 0x00, 0x00, 0x00, 0x00}, /* Sample 22 */ + {0x46, 0x00, 0x00, 0x00, 0x00}, /* Sample 23 */ + {0x12} /* Output Amplitude */ +}; + +u_int8_t TWVShortHaul4[25][5] = /* T1 Short Haul 440 - 550 ft */ +{ + {0x00, 0x44, 0x00, 0x00, 0x00}, /* Sample 0 */ + {0x0A, 0x44, 0x00, 0x00, 0x00}, /* Sample 1 */ + {0x3F, 0x43, 0x00, 0x00, 0x00}, /* Sample 2 */ + {0x3F, 0x43, 0x00, 0x00, 0x00}, /* Sample 3 */ + {0x3F, 0x42, 0x00, 0x00, 0x00}, /* Sample 4 */ + {0x3F, 0x42, 0x00, 0x00, 0x00}, /* Sample 5 */ + {0x30, 0x41, 0x00, 0x00, 0x00}, /* Sample 6 */ + {0x2B, 0x41, 0x00, 0x00, 0x00}, /* Sample 7 */ + {0x2A, 0x00, 0x00, 0x00, 0x00}, /* Sample 8 */ + {0x29, 0x00, 0x00, 0x00, 0x00}, /* Sample 9 */ + {0x28, 0x00, 0x00, 0x00, 0x00}, /* Sample 10 */ + {0x27, 0x00, 0x00, 0x00, 0x00}, /* Sample 11 */ + {0x26, 0x00, 0x00, 0x00, 0x00}, /* Sample 12 */ + {0x26, 0x00, 0x00, 0x00, 0x00}, /* Sample 13 */ + {0x24, 0x00, 0x00, 0x00, 0x00}, /* Sample 14 */ + {0x4A, 0x00, 0x00, 0x00, 0x00}, /* Sample 15 */ + {0x7F, 0x00, 0x00, 0x00, 0x00}, /* Sample 16 */ + {0x7F, 0x00, 0x00, 0x00, 0x00}, /* Sample 17 */ + {0x4F, 0x00, 0x00, 0x00, 0x00}, /* Sample 18 */ + {0x4A, 0x00, 0x00, 0x00, 0x00}, /* Sample 19 */ + {0x49, 0x00, 0x00, 0x00, 0x00}, /* Sample 20 */ + {0x47, 0x00, 0x00, 0x00, 0x00}, /* Sample 21 */ + {0x47, 0x00, 0x00, 0x00, 0x00}, /* Sample 22 */ + {0x46, 0x00, 0x00, 0x00, 0x00}, /* Sample 23 */ + {0x14} /* Output Amplitude */ +}; + +u_int8_t TWVShortHaul5[25][5] = /* T1 Short Haul 550 - 660 ft */ +{ + {0x00, 0x44, 0x00, 0x00, 0x00}, /* Sample 0 */ + {0x0A, 0x44, 0x00, 0x00, 0x00}, /* Sample 1 */ + {0x3F, 0x43, 0x00, 0x00, 0x00}, /* Sample 2 */ + {0x3F, 0x43, 0x00, 0x00, 0x00}, /* Sample 3 */ + {0x3F, 0x42, 0x00, 0x00, 0x00}, /* Sample 4 */ + {0x3F, 0x42, 0x00, 0x00, 0x00}, /* Sample 5 */ + {0x3F, 0x41, 0x00, 0x00, 0x00}, /* Sample 6 */ + {0x30, 0x41, 0x00, 0x00, 0x00}, /* Sample 7 */ + {0x2A, 0x00, 0x00, 0x00, 0x00}, /* Sample 8 */ + {0x29, 0x00, 0x00, 0x00, 0x00}, /* Sample 9 */ + {0x28, 0x00, 0x00, 0x00, 0x00}, /* Sample 10 */ + {0x27, 0x00, 0x00, 0x00, 0x00}, /* Sample 11 */ + {0x26, 0x00, 0x00, 0x00, 0x00}, /* Sample 12 */ + {0x25, 0x00, 0x00, 0x00, 0x00}, /* Sample 13 */ + {0x24, 0x00, 0x00, 0x00, 0x00}, /* Sample 14 */ + {0x4A, 0x00, 0x00, 0x00, 0x00}, /* Sample 15 */ + {0x7F, 0x00, 0x00, 0x00, 0x00}, /* Sample 16 */ + {0x7F, 0x00, 0x00, 0x00, 0x00}, /* Sample 17 */ + {0x5F, 0x00, 0x00, 0x00, 0x00}, /* Sample 18 */ + {0x50, 0x00, 0x00, 0x00, 0x00}, /* Sample 19 */ + {0x49, 0x00, 0x00, 0x00, 0x00}, /* Sample 20 */ + {0x47, 0x00, 0x00, 0x00, 0x00}, /* Sample 21 */ + {0x47, 0x00, 0x00, 0x00, 0x00}, /* Sample 22 */ + {0x46, 0x00, 0x00, 0x00, 0x00}, /* Sample 23 */ + {0x15} /* Output Amplitude */ +}; + +u_int8_t TWV_E1_120Ohm[25][5] = /* E1 120 Ohm */ +{ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 0 */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 1 */ + {0x0A, 0x00, 0x00, 0x00, 0x00}, /* Sample 2 */ + {0x3F, 0x00, 0x00, 0x00, 0x00}, /* Sample 3 */ + {0x3F, 0x00, 0x00, 0x00, 0x00}, /* Sample 4 */ + {0x39, 0x00, 0x00, 0x00, 0x00}, /* Sample 5 */ + {0x38, 0x00, 0x00, 0x00, 0x00}, /* Sample 6 */ + {0x36, 0x00, 0x00, 0x00, 0x00}, /* Sample 7 */ + {0x36, 0x00, 0x00, 0x00, 0x00}, /* Sample 8 */ + {0x35, 0x00, 0x00, 0x00, 0x00}, /* Sample 9 */ + {0x35, 0x00, 0x00, 0x00, 0x00}, /* Sample 10 */ + {0x35, 0x00, 0x00, 0x00, 0x00}, /* Sample 11 */ + {0x35, 0x00, 0x00, 0x00, 0x00}, /* Sample 12 */ + {0x35, 0x00, 0x00, 0x00, 0x00}, /* Sample 13 */ + {0x35, 0x00, 0x00, 0x00, 0x00}, /* Sample 14 */ + {0x2D, 0x00, 0x00, 0x00, 0x00}, /* Sample 15 */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 16 */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 17 */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 18 */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 19 */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 20 */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 21 */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 22 */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 23 */ + {0x0C} /* PMC's suggested value */ +/* { 0x10 } Output Amplitude */ +}; + + + +u_int8_t TWV_E1_75Ohm[25][5] = /* E1 75 Ohm */ +{ +#ifdef PMCC4_DOES_NOT_SUPPORT + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 0 */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 1 */ + {0x0A, 0x00, 0x00, 0x00, 0x00}, /* Sample 2 */ + {0x28, 0x00, 0x00, 0x00, 0x00}, /* Sample 3 */ + {0x3A, 0x00, 0x00, 0x00, 0x00}, /* Sample 4 */ + {0x3A, 0x00, 0x00, 0x00, 0x00}, /* Sample 5 */ + {0x3A, 0x00, 0x00, 0x00, 0x00}, /* Sample 6 */ + {0x3A, 0x00, 0x00, 0x00, 0x00}, /* Sample 7 */ + {0x3A, 0x00, 0x00, 0x00, 0x00}, /* Sample 8 */ + {0x3A, 0x00, 0x00, 0x00, 0x00}, /* Sample 9 */ + {0x3A, 0x00, 0x00, 0x00, 0x00}, /* Sample 10 */ + {0x3A, 0x00, 0x00, 0x00, 0x00}, /* Sample 11 */ + {0x3A, 0x00, 0x00, 0x00, 0x00}, /* Sample 12 */ + {0x3A, 0x00, 0x00, 0x00, 0x00}, /* Sample 13 */ + {0x32, 0x00, 0x00, 0x00, 0x00}, /* Sample 14 */ + {0x14, 0x00, 0x00, 0x00, 0x00}, /* Sample 15 */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 16 */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 17 */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 18 */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 19 */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 20 */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 21 */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 22 */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* Sample 23 */ +#endif + {0x0C} /* Output Amplitude */ +}; + + +u_int32_t T1_Equalizer[256] = /* T1 Receiver Equalizer */ +{ + 0x03FE1840, 0x03F61840, 0x03EE1840, 0x03E61840, /* 000 - 003 */ + 0x03DE1840, 0x03D61840, 0x03D61840, 0x03D61840, /* 004 - 007 */ + 0x03CE1840, 0x03CE1840, 0x03CE1840, 0x03CE1840, /* 008 - 011 */ + 0x03C61840, 0x03C61840, 0x03C61840, 0x0BBE1840, /* 012 - 015 */ + 0x0BBE1840, 0x0BBE1840, 0x0BBE1840, 0x0BB61840, /* 016 - 019 */ + 0x0BB61840, 0x0BB61840, 0x0BB61840, 0x13AE1838, /* 020 - 023 */ + 0x13AE183C, 0x13AE1840, 0x13AE1840, 0x13AE1840, /* 024 - 027 */ + 0x13AE1840, 0x1BB618B8, 0x1BAE18B8, 0x1BAE18BC, /* 028 - 031 */ + 0x1BAE18C0, 0x1BAE18C0, 0x23A618C0, 0x23A618C0, /* 032 - 035 */ + 0x23A618C0, 0x23A618C0, 0x23A618C0, 0x239E18C0, /* 036 - 039 */ + 0x239E18C0, 0x239E18C0, 0x239E18C0, 0x239E18C0, /* 040 - 043 */ + 0x2B9618C0, 0x2B9618C0, 0x2B9618C0, 0x33961940, /* 044 - 047 */ + 0x37961940, 0x37961940, 0x37961940, 0x3F9E19C0, /* 048 - 051 */ + 0x3F9E19C0, 0x3F9E19C0, 0x3FA61A40, 0x3FA61A40, /* 052 - 055 */ + 0x3FA61A40, 0x3FA61A40, 0x3F9619C0, 0x3F9619C0, /* 056 - 059 */ + 0x3F9619C0, 0x3F9619C0, 0x479E1A40, 0x479E1A40, /* 060 - 063 */ + 0x479E1A40, 0x47961A40, 0x47961A40, 0x47961A40, /* 064 - 067 */ + 0x47961A40, 0x4F8E1A40, 0x4F8E1A40, 0x4F8E1A40, /* 068 - 071 */ + 0x4F8E1A40, 0x4F8E1A40, 0x57861A40, 0x57861A40, /* 072 - 075 */ + 0x57861A40, 0x57861A40, 0x57861A40, 0x5F861AC0, /* 076 - 079 */ + 0x5F861AC0, 0x5F861AC0, 0x5F861AC0, 0x5F861AC0, /* 080 - 083 */ + 0x5F861AC0, 0x5F7E1AC0, 0x5F7E1AC0, 0x5F7E1AC0, /* 084 - 087 */ + 0x5F7E1AC0, 0x5F7E1AC0, 0x677E2AC0, 0x677E2AC0, /* 088 - 091 */ + 0x677E2AC0, 0x677E2AC0, 0x67762AC0, 0x67762AC0, /* 092 - 095 */ + 0x67762AC0, 0x67762AC0, 0x67762AC0, 0x6F6E2AC0, /* 096 - 099 */ + 0x6F6E2AC0, 0x6F6E2AC0, 0x6F6E2AC0, 0x776E3AC0, /* 100 - 103 */ + 0x776E3AC0, 0x776E3AC0, 0x776E3AC0, 0x7F663AC0, /* 104 - 107 */ + 0x7F663AC0, 0x7F664AC0, 0x7F664AC0, 0x7F664AC0, /* 108 - 111 */ + 0x7F664AC0, 0x87665AC0, 0x87665AC0, 0x87665AC0, /* 112 - 115 */ + 0x87665AC0, 0x87665AC0, 0x875E5AC0, 0x875E5AC0, /* 116 - 119 */ + 0x875E5AC0, 0x875E5AC0, 0x875E5AC0, 0x8F5E6AC0, /* 120 - 123 */ + 0x8F5E6AC0, 0x8F5E6AC0, 0x8F5E6AC0, 0x975E7AC0, /* 124 - 127 */ + 0x975E7AC0, 0x975E7AC0, 0x975E7AC0, 0x9F5E8AC0, /* 128 - 131 */ + 0x9F5E8AC0, 0x9F5E8AC0, 0x9F5E8AC0, 0x9F5E8AC0, /* 132 - 135 */ + 0xA7569AC0, 0xA7569AC0, 0xA7569AC0, 0xA7569AC0, /* 136 - 139 */ + 0xA756AAC0, 0xA756AAC0, 0xA756AAC0, 0xAF4EAAC0, /* 140 - 143 */ + 0xAF4EAAC0, 0xAF4EAAC0, 0xAF4EAAC0, 0xAF4EAAC0, /* 144 - 147 */ + 0xB746AAC0, 0xB746AAC0, 0xB746AAC0, 0xB746AAC0, /* 148 - 151 */ + 0xB746AAC0, 0xB746AAC0, 0xB746AAC0, 0xB746BAC0, /* 152 - 155 */ + 0xB746BAC0, 0xB746BAC0, 0xBF4EBB40, 0xBF4EBB40, /* 156 - 159 */ + 0xBF4EBB40, 0xBF4EBB40, 0xBF4EBB40, 0xBF4EBB40, /* 160 - 163 */ + 0xBF4EBB40, 0xBF4EBB40, 0xBF4EBB40, 0xBE46CB40, /* 164 - 167 */ + 0xBE46CB40, 0xBE46CB40, 0xBE46CB40, 0xBE46CB40, /* 168 - 171 */ + 0xBE46CB40, 0xBE46DB40, 0xBE46DB40, 0xBE46DB40, /* 172 - 175 */ + 0xC63ECB40, 0xC63ECB40, 0xC63EDB40, 0xC63EDB40, /* 176 - 179 */ + 0xC63EDB40, 0xC644DB40, 0xC644DB40, 0xC644DB40, /* 180 - 183 */ + 0xC644DB40, 0xC63CDB40, 0xC63CDB40, 0xC63CDB40, /* 184 - 187 */ + 0xC63CDB40, 0xD634DB40, 0xD634DB40, 0xD634DB40, /* 188 - 191 */ + 0xD634DB40, 0xD634DB40, 0xDE2CDB3C, 0xDE2CDB3C, /* 192 - 195 */ + 0xDE2CDB3C, 0xE62CDB40, 0xE62CDB40, 0xE62CDB40, /* 196 - 199 */ + 0xE62CDB40, 0xE62CDB40, 0xE62CEB40, 0xE62CEB40, /* 200 - 203 */ + 0xE62CEB40, 0xEE2CFB40, 0xEE2CFB40, 0xEE2CFB40, /* 204 - 207 */ + 0xEE2D0B40, 0xEE2D0B40, 0xEE2D0B40, 0xEE2D0B40, /* 208 - 211 */ + 0xEE2D0B40, 0xF5250B38, 0xF5250B3C, 0xF5250B40, /* 212 - 215 */ + 0xF5251B40, 0xF5251B40, 0xF5251B40, 0xF5251B40, /* 216 - 219 */ + 0xF5251B40, 0xFD252B40, 0xFD252B40, 0xFD252B40, /* 220 - 223 */ + 0xFD252B40, 0xFD252740, 0xFD252740, 0xFD252740, /* 224 - 227 */ + 0xFD252340, 0xFD252340, 0xFD252340, 0xFD253340, /* 228 - 231 */ + 0xFD253340, 0xFD253340, 0xFD253340, 0xFD253340, /* 232 - 235 */ + 0xFD253340, 0xFD253340, 0xFD253340, 0xFC254340, /* 236 - 239 */ + 0xFD254340, 0xFD254340, 0xFD254344, 0xFC254348, /* 240 - 243 */ + 0xFC25434C, 0xFD2543BC, 0xFD2543C0, 0xFC2543C0, /* 244 - 247 */ + 0xFC2343C0, 0xFC2343C0, 0xFD2343C0, 0xFC2143C0, /* 248 - 251 */ + 0xFC2143C0, 0xFC2153C0, 0xFD2153C0, 0xFC2153C0 /* 252 - 255 */ +}; + + +u_int32_t E1_Equalizer[256] = /* E1 Receiver Equalizer */ +{ + 0x07DE182C, 0x07DE182C, 0x07D6182C, 0x07D6182C, /* 000 - 003 */ + 0x07D6182C, 0x07CE182C, 0x07CE182C, 0x07CE182C, /* 004 - 007 */ + 0x07C6182C, 0x07C6182C, 0x07C6182C, 0x07BE182C, /* 008 - 011 */ + 0x07BE182C, 0x07BE182C, 0x07BE182C, 0x07BE182C, /* 012 - 015 */ + 0x07B6182C, 0x07B6182C, 0x07B6182C, 0x07B6182C, /* 016 - 019 */ + 0x07B6182C, 0x07AE182C, 0x07AE182C, 0x07AE182C, /* 020 - 023 */ + 0x07AE182C, 0x07AE182C, 0x07B618AC, 0x07AE18AC, /* 024 - 027 */ + 0x07AE18AC, 0x07AE18AC, 0x07AE18AC, 0x07A618AC, /* 028 - 031 */ + 0x07A618AC, 0x07A618AC, 0x07A618AC, 0x079E18AC, /* 032 - 035 */ + 0x07A6192C, 0x07A6192C, 0x07A6192C, 0x0FA6192C, /* 036 - 039 */ + 0x0FA6192C, 0x0F9E192C, 0x0F9E192C, 0x0F9E192C, /* 040 - 043 */ + 0x179E192C, 0x17A619AC, 0x179E19AC, 0x179E19AC, /* 044 - 047 */ + 0x179619AC, 0x1F9619AC, 0x1F9619AC, 0x1F8E19AC, /* 048 - 051 */ + 0x1F8E19AC, 0x1F8E19AC, 0x278E19AC, 0x278E1A2C, /* 052 - 055 */ + 0x278E1A2C, 0x278E1A2C, 0x278E1A2C, 0x2F861A2C, /* 056 - 059 */ + 0x2F861A2C, 0x2F861A2C, 0x2F7E1A2C, 0x2F7E1A2C, /* 060 - 063 */ + 0x2F7E1A2C, 0x377E1A2C, 0x377E1AAC, 0x377E1AAC, /* 064 - 067 */ + 0x377E1AAC, 0x377E1AAC, 0x3F7E2AAC, 0x3F7E2AAC, /* 068 - 071 */ + 0x3F762AAC, 0x3F862B2C, 0x3F7E2B2C, 0x477E2B2C, /* 072 - 075 */ + 0x477E2F2C, 0x477E2F2C, 0x477E2F2C, 0x47762F2C, /* 076 - 079 */ + 0x4F762F2C, 0x4F762F2C, 0x4F6E2F2C, 0x4F6E2F2C, /* 080 - 083 */ + 0x4F6E2F2C, 0x576E2F2C, 0x576E2F2C, 0x576E3F2C, /* 084 - 087 */ + 0x576E3F2C, 0x576E3F2C, 0x5F6E3F2C, 0x5F6E4F2C, /* 088 - 091 */ + 0x5F6E4F2C, 0x5F6E4F2C, 0x5F664F2C, 0x67664F2C, /* 092 - 095 */ + 0x67664F2C, 0x675E4F2C, 0x675E4F2C, 0x67664F2C, /* 096 - 099 */ + 0x67664F2C, 0x67665F2C, 0x6F6E5F2C, 0x6F6E6F2C, /* 100 - 103 */ + 0x6F6E6F2C, 0x6F6E7F2C, 0x6F6E7F2C, 0x6F6E7F2C, /* 104 - 107 */ + 0x77667F2C, 0x77667F2C, 0x775E6F2C, 0x775E7F2C, /* 108 - 111 */ + 0x775E7F2C, 0x7F5E7F2C, 0x7F5E8F2C, 0x7F5E8F2C, /* 112 - 115 */ + 0x7F5E8F2C, 0x87568F2C, 0x87568F2C, 0x87568F2C, /* 116 - 119 */ + 0x874E8F2C, 0x874E8F2C, 0x874E8F2C, 0x8F4E9F2C, /* 120 - 123 */ + 0x8F4E9F2C, 0x8F4EAF2C, 0x8F4EAF2C, 0x8F4EAF2C, /* 124 - 127 */ + 0x974EAF2C, 0x974EAF2C, 0x974EAB2C, 0x974EAB2C, /* 128 - 131 */ + 0x974EAB2C, 0x9F4EAB2C, 0x9F4EBB2C, 0x9F4EBB2C, /* 132 - 135 */ + 0x9F4EBB2C, 0x9F4ECB2C, 0xA74ECB2C, 0xA74ECB2C, /* 136 - 139 */ + 0xA746CB2C, 0xA746CB2C, 0xA746CB2C, 0xA746DB2C, /* 140 - 143 */ + 0xAF46DB2C, 0xAF46EB2C, 0xAF46EB2C, 0xAF4EEB2C, /* 144 - 147 */ + 0xAE4EEB2C, 0xAE4EEB2C, 0xB546FB2C, 0xB554FB2C, /* 148 - 151 */ + 0xB54CEB2C, 0xB554FB2C, 0xB554FB2C, 0xBD54FB2C, /* 152 - 155 */ + 0xBD4CFB2C, 0xBD4CFB2C, 0xBD4CFB2C, 0xBD44EB2C, /* 156 - 159 */ + 0xC544FB2C, 0xC544FB2C, 0xC544FB2C, 0xC5450B2C, /* 160 - 163 */ + 0xC5450B2C, 0xC5450B2C, 0xCD450B2C, 0xCD450B2C, /* 164 - 167 */ + 0xCD3D0B2C, 0xCD3D0B2C, 0xCD3D0B2C, 0xD53D0B2C, /* 168 - 171 */ + 0xD53D0B2C, 0xD53D1B2C, 0xD53D1B2C, 0xD53D1B2C, /* 172 - 175 */ + 0xDD3D1B2C, 0xDD3D1B2C, 0xDD351B2C, 0xDD351B2C, /* 176 - 179 */ + 0xDD351B2C, 0xE5351B2C, 0xE5351B2C, 0xE52D1B2C, /* 180 - 183 */ + 0xE52D1B2C, 0xE52D3B2C, 0xED2D4B2C, 0xED2D1BA8, /* 184 - 187 */ + 0xED2D1BAC, 0xED2D17AC, 0xED2D17AC, 0xED2D27AC, /* 188 - 191 */ + 0xF52D27AC, 0xF52D27AC, 0xF52D2BAC, 0xF52D2BAC, /* 192 - 195 */ + 0xF52D2BAC, 0xFD2D2BAC, 0xFD2B2BAC, 0xFD2B2BAC, /* 196 - 199 */ + 0xFD2B2BAC, 0xFD2B2BAC, 0xFD232BAC, 0xFD232BAC, /* 200 - 203 */ + 0xFD232BAC, 0xFD212BAC, 0xFD212BAC, 0xFD292BAC, /* 204 - 207 */ + 0xFD292BAC, 0xFD2927AC, 0xFD2937AC, 0xFD2923AC, /* 208 - 211 */ + 0xFD2923AC, 0xFD2923AC, 0xFD2923AC, 0xFD2123AC, /* 212 - 215 */ + 0xFD2123AC, 0xFD2123AC, 0xFD2133AC, 0xFD2133AC, /* 216 - 219 */ + 0xFD2133AC, 0xFD2143AC, 0xFD2143AC, 0xFD2143AC, /* 220 - 223 */ + 0xFC2143AC, 0xFC2143AC, 0xFC1943AC, 0xFC1943AC, /* 224 - 227 */ + 0xFC1943AC, 0xFC1943AC, 0xFC1953AC, 0xFC1953AC, /* 228 - 231 */ + 0xFC1953AC, 0xFC1953AC, 0xFC1963AC, 0xFC1963AC, /* 232 - 235 */ + 0xFC1963AC, 0xFC1973AC, 0xFC1973AC, 0xFC1973AC, /* 236 - 239 */ + 0xFC1973AC, 0xFC1973AC, 0xFC1983AC, 0xFC1983AC, /* 240 - 243 */ + 0xFC1983AC, 0xFC1983AC, 0xFC1983AC, 0xFC1993AC, /* 244 - 247 */ + 0xFC1993AC, 0xFC1993AC, 0xFC19A3AC, 0xFC19A3AC, /* 248 - 251 */ + 0xFC19B3AC, 0xFC19B3AC, 0xFC19B3AC, 0xFC19B3AC /* 252 - 255 */ +}; + +/*** End-of-Files ***/ diff --git a/drivers/staging/cxt1e1/comet_tables.h b/drivers/staging/cxt1e1/comet_tables.h new file mode 100644 index 000000000000..80424a26a169 --- /dev/null +++ b/drivers/staging/cxt1e1/comet_tables.h @@ -0,0 +1,85 @@ +/* + * $Id: comet_tables.h,v 1.5 2006/01/02 22:37:31 rickd PMCC4_3_1B $ + */ + +#ifndef _INC_COMET_TBLS_H_ +#define _INC_COMET_TBLS_H_ + +/*----------------------------------------------------------------------------- + * comet_tables.h - Waveform Tables for the PM4351 'COMET' + * + * Copyright (C) 2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + * + * For further information, contact via email: support@sbei.com + * SBE, Inc. San Ramon, California U.S.A. + *----------------------------------------------------------------------------- + * RCS info: + * RCS revision: $Revision: 1.5 $ + * Last changed on $Date: 2006/01/02 22:37:31 $ + * Changed by $Author: rickd $ + *----------------------------------------------------------------------------- + * $Log: comet_tables.h,v $ + * Revision 1.5 2006/01/02 22:37:31 rickd + * Double indexed arrays need sizings to avoid CC errors under + * gcc 4.0.0 + * + * Revision 1.4 2005/10/17 23:55:28 rickd + * The 75 Ohm transmit waveform is not supported on PMCC4. + * + * Revision 1.3 2005/09/28 00:10:08 rickd + * Add GNU License info. Structures moved to -C- file. + * + * Revision 1.2 2005/04/28 23:43:04 rickd + * Add RCS tracking heading. + * + *----------------------------------------------------------------------------- + */ + + +/***************************************************************************** +* +* Array names: +* +* TWVLongHaul0DB +* TWVLongHaul7_5DB +* TWVLongHaul15DB +* TWVLongHaul22_5DB +* TWVShortHaul0 +* TWVShortHaul1 +* TWVShortHaul2 +* TWVShortHaul3 +* TWVShortHaul4 +* TWVShortHaul5 +* TWV_E1_120Ohm +* TWV_E1_75Ohm <not supported> +* T1_Equalizer +* E1_Equalizer +* +*****************************************************************************/ + +extern u_int8_t TWVLongHaul0DB[25][5]; /* T1 Long Haul 0 DB */ +extern u_int8_t TWVLongHaul7_5DB[25][5]; /* T1 Long Haul 7.5 DB */ +extern u_int8_t TWVLongHaul15DB[25][5]; /* T1 Long Haul 15 DB */ +extern u_int8_t TWVLongHaul22_5DB[25][5]; /* T1 Long Haul 22.5 DB */ +extern u_int8_t TWVShortHaul0[25][5]; /* T1 Short Haul 0-110 ft */ +extern u_int8_t TWVShortHaul1[25][5]; /* T1 Short Haul 110-220 ft */ +extern u_int8_t TWVShortHaul2[25][5]; /* T1 Short Haul 220-330 ft */ +extern u_int8_t TWVShortHaul3[25][5]; /* T1 Short Haul 330-440 ft */ +extern u_int8_t TWVShortHaul4[25][5]; /* T1 Short Haul 440-550 ft */ +extern u_int8_t TWVShortHaul5[25][5]; /* T1 Short Haul 550-660 ft */ +extern u_int8_t TWV_E1_75Ohm[25][5]; /* E1 75 Ohm */ +extern u_int8_t TWV_E1_120Ohm[25][5]; /* E1 120 Ohm */ +extern u_int32_t T1_Equalizer[256]; /* T1 Receiver Equalizer */ +extern u_int32_t E1_Equalizer[256]; /* E1 Receiver Equalizer */ + +#endif /* _INC_COMET_TBLS_H_ */ diff --git a/drivers/staging/cxt1e1/functions.c b/drivers/staging/cxt1e1/functions.c new file mode 100644 index 000000000000..c95c62dfb04b --- /dev/null +++ b/drivers/staging/cxt1e1/functions.c @@ -0,0 +1,366 @@ +/* Copyright (C) 2003-2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + */ + +#include <linux/slab.h> +#include <asm/io.h> +#include <asm/byteorder.h> +#include <linux/netdevice.h> +#include <linux/delay.h> +#include <linux/hdlc.h> +#include "pmcc4_sysdep.h" +#include "sbecom_inline_linux.h" +#include "libsbew.h" +#include "pmcc4.h" + + +#ifdef SBE_INCLUDE_SYMBOLS +#define STATIC +#else +#define STATIC static +#endif + +#if defined(CONFIG_SBE_HDLC_V7) || defined(CONFIG_SBE_WAN256T3_HDLC_V7) || \ + defined(CONFIG_SBE_HDLC_V7_MODULE) || defined(CONFIG_SBE_WAN256T3_HDLC_V7_MODULE) +#define _v7_hdlc_ 1 +#else +#define _v7_hdlc_ 0 +#endif + +#if _v7_hdlc_ +#define V7(x) (x ## _v7) +extern int hdlc_netif_rx_v7 (hdlc_device *, struct sk_buff *); +extern int register_hdlc_device_v7 (hdlc_device *); +extern int unregister_hdlc_device_v7 (hdlc_device *); + +#else +#define V7(x) x +#endif + + +#ifndef USE_MAX_INT_DELAY +static int dummy = 0; + +#endif + +extern int log_level; +extern int drvr_state; + + +#if 1 +u_int32_t +pci_read_32 (u_int32_t *p) +{ +#ifdef FLOW_DEBUG + u_int32_t v; + + FLUSH_PCI_READ (); + v = le32_to_cpu (*p); + if (log_level >= LOG_DEBUG) + printk ("pci_read : %x = %x\n", (u_int32_t) p, v); + return v; +#else + FLUSH_PCI_READ (); /* */ + return le32_to_cpu (*p); +#endif +} + +void +pci_write_32 (u_int32_t *p, u_int32_t v) +{ +#ifdef FLOW_DEBUG + if (log_level >= LOG_DEBUG) + printk ("pci_write: %x = %x\n", (u_int32_t) p, v); +#endif + *p = cpu_to_le32 (v); + FLUSH_PCI_WRITE (); /* This routine is called from routines + * which do multiple register writes + * which themselves need flushing between + * writes in order to guarantee write + * ordering. It is less code-cumbersome + * to flush here-in then to investigate + * and code the many other register + * writing routines. */ +} +#endif + + +void +pci_flush_write (ci_t * ci) +{ + volatile u_int32_t v; + + /* issue a PCI read to flush PCI write thru bridge */ + v = *(u_int32_t *) &ci->reg->glcd; /* any address would do */ + + /* + * return nothing, this just reads PCI bridge interface to flush + * previously written data + */ +} + + +STATIC void +watchdog_func (unsigned long arg) +{ + struct watchdog *wd = (void *) arg; + + if (drvr_state != SBE_DRVR_AVAILABLE) + { + if (log_level >= LOG_MONITOR) + printk (KERN_WARNING "watchdog_func: drvr not available (%x)\n", 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); +} + +int OS_init_watchdog(struct watchdog *wdp, void (*f) (void *), void *c, int usec) +{ + wdp->func = f; + wdp->softc = c; + wdp->ticks = (HZ) * (usec / 1000) / 1000; + INIT_WORK(&wdp->work, (void *)f); + init_timer (&wdp->h); + { + ci_t *ci = (ci_t *) c; + + wdp->h.data = (unsigned long) &ci->wd; + } + wdp->h.function = watchdog_func; + return 0; +} + +void +OS_uwait (int usec, char *description) +{ + int tmp; + + if (usec >= 1000) + { + mdelay (usec / 1000); + /* now delay residual */ + tmp = (usec / 1000) * 1000; /* round */ + tmp = usec - tmp; /* residual */ + if (tmp) + { /* wait on residual */ + udelay (tmp); + } + } else + { + udelay (usec); + } +} + +/* dummy short delay routine called as a subroutine so that compiler + * does not optimize/remove its intent (a short delay) + */ + +void +OS_uwait_dummy (void) +{ +#ifndef USE_MAX_INT_DELAY + dummy++; +#else + udelay (1); +#endif +} + + +void +OS_sem_init (void *sem, int state) +{ + switch (state) + { + case SEM_TAKEN: + init_MUTEX_LOCKED ((struct semaphore *) sem); + break; + case SEM_AVAILABLE: + init_MUTEX ((struct semaphore *) sem); + break; + default: /* otherwise, set sem.count to state's + * value */ + sema_init (sem, state); + break; + } +} + + +int +sd_line_is_ok (void *user) +{ + struct net_device *ndev = (struct net_device *) user; + + return (netif_carrier_ok (ndev)); +} + +void +sd_line_is_up (void *user) +{ + struct net_device *ndev = (struct net_device *) user; + + netif_carrier_on (ndev); + return; +} + +void +sd_line_is_down (void *user) +{ + struct net_device *ndev = (struct net_device *) user; + + netif_carrier_off (ndev); + return; +} + +void +sd_disable_xmit (void *user) +{ + struct net_device *dev = (struct net_device *) user; + + netif_stop_queue (dev); + return; +} + +void +sd_enable_xmit (void *user) +{ + struct net_device *dev = (struct net_device *) user; + + netif_wake_queue (dev); + return; +} + +int +sd_queue_stopped (void *user) +{ + struct net_device *ndev = (struct net_device *) user; + + return (netif_queue_stopped (ndev)); +} + +void sd_recv_consume(void *token, size_t len, void *user) +{ + struct net_device *ndev = user; + struct sk_buff *skb = token; + + skb->dev = ndev; + skb_put (skb, len); + skb->protocol = hdlc_type_trans(skb, ndev); + netif_rx(skb); +} + + +/** + ** Read some reserved location w/in the COMET chip as a usable + ** VMETRO trigger point or other trace marking event. + **/ + +#include "comet.h" + +extern ci_t *CI; /* dummy pointer to board ZERO's data */ +void +VMETRO_TRACE (void *x) +{ + u_int32_t y = (u_int32_t) x; + + pci_write_32 ((u_int32_t *) &CI->cpldbase->leds, y); +} + + +void +VMETRO_TRIGGER (ci_t * ci, int x) +{ + comet_t *comet; + volatile u_int32_t data; + + comet = ci->port[0].cometbase; /* default to COMET # 0 */ + + switch (x) + { + default: + case 0: + data = pci_read_32 ((u_int32_t *) &comet->__res24); /* 0x90 */ + break; + case 1: + data = pci_read_32 ((u_int32_t *) &comet->__res25); /* 0x94 */ + break; + case 2: + data = pci_read_32 ((u_int32_t *) &comet->__res26); /* 0x98 */ + break; + case 3: + data = pci_read_32 ((u_int32_t *) &comet->__res27); /* 0x9C */ + break; + case 4: + data = pci_read_32 ((u_int32_t *) &comet->__res88); /* 0x220 */ + break; + case 5: + data = pci_read_32 ((u_int32_t *) &comet->__res89); /* 0x224 */ + break; + case 6: + data = pci_read_32 ((u_int32_t *) &comet->__res8A); /* 0x228 */ + break; + case 7: + data = pci_read_32 ((u_int32_t *) &comet->__res8B); /* 0x22C */ + break; + case 8: + data = pci_read_32 ((u_int32_t *) &comet->__resA0); /* 0x280 */ + break; + case 9: + data = pci_read_32 ((u_int32_t *) &comet->__resA1); /* 0x284 */ + break; + case 10: + data = pci_read_32 ((u_int32_t *) &comet->__resA2); /* 0x288 */ + break; + case 11: + data = pci_read_32 ((u_int32_t *) &comet->__resA3); /* 0x28C */ + break; + case 12: + data = pci_read_32 ((u_int32_t *) &comet->__resA4); /* 0x290 */ + break; + case 13: + data = pci_read_32 ((u_int32_t *) &comet->__resA5); /* 0x294 */ + break; + case 14: + data = pci_read_32 ((u_int32_t *) &comet->__resA6); /* 0x298 */ + break; + case 15: + data = pci_read_32 ((u_int32_t *) &comet->__resA7); /* 0x29C */ + break; + case 16: + data = pci_read_32 ((u_int32_t *) &comet->__res74); /* 0x1D0 */ + break; + case 17: + data = pci_read_32 ((u_int32_t *) &comet->__res75); /* 0x1D4 */ + break; + case 18: + data = pci_read_32 ((u_int32_t *) &comet->__res76); /* 0x1D8 */ + break; + case 19: + data = pci_read_32 ((u_int32_t *) &comet->__res77); /* 0x1DC */ + break; + } +} + + +/*** End-of-File ***/ diff --git a/drivers/staging/cxt1e1/hwprobe.c b/drivers/staging/cxt1e1/hwprobe.c new file mode 100644 index 000000000000..0f9d6539a9a6 --- /dev/null +++ b/drivers/staging/cxt1e1/hwprobe.c @@ -0,0 +1,400 @@ +/* Copyright (C) 2007 One Stop Systems + * Copyright (C) 2003-2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + */ + +#include <linux/netdevice.h> +#include <linux/hdlc.h> +#include <linux/if_arp.h> +#include <asm/uaccess.h> +#include <linux/rtnetlink.h> +#include <linux/pci.h> +#include "pmcc4_sysdep.h" +#include "sbecom_inline_linux.h" +#include "libsbew.h" +#include "pmcc4_private.h" +#include "pmcc4.h" +#include "pmcc4_ioctls.h" +#include "pmc93x6_eeprom.h" +#ifdef CONFIG_PROC_FS +#include "sbeproc.h" +#endif + +#ifdef SBE_INCLUDE_SYMBOLS +#define STATIC +#else +#define STATIC static +#endif + +extern int log_level; +extern int error_flag; +extern int drvr_state; + +/* forward references */ +void c4_stopwd (ci_t *); +struct net_device * __init c4_add_dev (hdw_info_t *, int, unsigned long, unsigned long, int, int); + + +struct s_hdw_info hdw_info[MAX_BOARDS]; + + +void __init +show_two (hdw_info_t * hi, int brdno) +{ + ci_t *ci; + struct pci_dev *pdev; + char *bid; + char *bp, banner[80]; + char sn[6]; + + bp = banner; + memset (banner, 0, 80); /* clear print buffer */ + + ci = (ci_t *)(netdev_priv(hi->ndev)); + bid = sbeid_get_bdname (ci); + switch (hi->promfmt) + { + case PROM_FORMAT_TYPE1: + memcpy (sn, (FLD_TYPE1 *) (hi->mfg_info.pft1.Serial), 6); + break; + case PROM_FORMAT_TYPE2: + memcpy (sn, (FLD_TYPE2 *) (hi->mfg_info.pft2.Serial), 6); + break; + default: + memset (sn, 0, 6); + break; + } + + sprintf (banner, "%s: %s S/N %06X, MUSYCC Rev %02X", + hi->devname, bid, + ((sn[3] << 16) & 0xff0000) | + ((sn[4] << 8) & 0x00ff00) | + (sn[5] & 0x0000ff), + (u_int8_t) hi->revid[0]); + + printk ("%s\n", banner); + + pdev = hi->pdev[0]; + printk ("%s: %s at v/p=%lx/%lx (%02x:%02x.%x) irq %d\n", + hi->devname, "MUSYCC", + (unsigned long) hi->addr_mapped[0], hi->addr[0], + hi->pci_busno, (u_int8_t) PCI_SLOT (pdev->devfn), + (u_int8_t) PCI_FUNC (pdev->devfn), pdev->irq); + + pdev = hi->pdev[1]; + printk ("%s: %s at v/p=%lx/%lx (%02x:%02x.%x) irq %d\n", + hi->devname, "EBUS ", + (unsigned long) hi->addr_mapped[1], hi->addr[1], + hi->pci_busno, (u_int8_t) PCI_SLOT (pdev->devfn), + (u_int8_t) PCI_FUNC (pdev->devfn), pdev->irq); +} + + +void __init +hdw_sn_get (hdw_info_t * hi, int brdno) +{ + /* obtain hardware EEPROM information */ + long addr; + + addr = (long) hi->addr_mapped[1] + EEPROM_OFFSET; + + /* read EEPROM with largest known format size... */ + pmc_eeprom_read_buffer (addr, 0, (char *) hi->mfg_info.data, sizeof (FLD_TYPE2)); + +#if 0 + { + unsigned char *ucp = (unsigned char *) &hi->mfg_info.data; + + printk ("eeprom[00]: %02x %02x %02x %02x %02x %02x %02x %02x\n", + *(ucp + 0), *(ucp + 1), *(ucp + 2), *(ucp + 3), *(ucp + 4), *(ucp + 5), *(ucp + 6), *(ucp + 7)); + printk ("eeprom[08]: %02x %02x %02x %02x %02x %02x %02x %02x\n", + *(ucp + 8), *(ucp + 9), *(ucp + 10), *(ucp + 11), *(ucp + 12), *(ucp + 13), *(ucp + 14), *(ucp + 15)); + printk ("eeprom[16]: %02x %02x %02x %02x %02x %02x %02x %02x\n", + *(ucp + 16), *(ucp + 17), *(ucp + 18), *(ucp + 19), *(ucp + 20), *(ucp + 21), *(ucp + 22), *(ucp + 23)); + printk ("eeprom[24]: %02x %02x %02x %02x %02x %02x %02x %02x\n", + *(ucp + 24), *(ucp + 25), *(ucp + 26), *(ucp + 27), *(ucp + 28), *(ucp + 29), *(ucp + 30), *(ucp + 31)); + printk ("eeprom[32]: %02x %02x %02x %02x %02x %02x %02x %02x\n", + *(ucp + 32), *(ucp + 33), *(ucp + 34), *(ucp + 35), *(ucp + 36), *(ucp + 37), *(ucp + 38), *(ucp + 39)); + printk ("eeprom[40]: %02x %02x %02x %02x %02x %02x %02x %02x\n", + *(ucp + 40), *(ucp + 41), *(ucp + 42), *(ucp + 43), *(ucp + 44), *(ucp + 45), *(ucp + 46), *(ucp + 47)); + } +#endif +#if 0 + printk ("sn: %x %x %x %x %x %x\n", + hi->mfg_info.Serial[0], + hi->mfg_info.Serial[1], + hi->mfg_info.Serial[2], + hi->mfg_info.Serial[3], + hi->mfg_info.Serial[4], + hi->mfg_info.Serial[5]); +#endif + + if ((hi->promfmt = pmc_verify_cksum (&hi->mfg_info.data)) == PROM_FORMAT_Unk) + { + /* bad crc, data is suspect */ + if (log_level >= LOG_WARN) + printk ("%s: EEPROM cksum error\n", hi->devname); + hi->mfg_info_sts = EEPROM_CRCERR; + } else + hi->mfg_info_sts = EEPROM_OK; +} + + +void __init +prep_hdw_info (void) +{ + hdw_info_t *hi; + int i; + + for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++) + { + hi->pci_busno = 0xff; + hi->pci_slot = 0xff; + hi->pci_pin[0] = 0; + hi->pci_pin[1] = 0; + hi->ndev = 0; + hi->addr[0] = 0L; + hi->addr[1] = 0L; + hi->addr_mapped[0] = 0L; + hi->addr_mapped[1] = 0L; + } +} + +void +cleanup_ioremap (void) +{ + hdw_info_t *hi; + int i; + + for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++) + { + if (hi->pci_slot == 0xff) + break; + if (hi->addr_mapped[0]) + { + iounmap ((void *) (hi->addr_mapped[0])); + release_mem_region ((long) hi->addr[0], hi->len[0]); + hi->addr_mapped[0] = 0; + } + if (hi->addr_mapped[1]) + { + iounmap ((void *) (hi->addr_mapped[1])); + release_mem_region ((long) hi->addr[1], hi->len[1]); + hi->addr_mapped[1] = 0; + } + } +} + + +void +cleanup_devs (void) +{ + hdw_info_t *hi; + int i; + + for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++) + { + if (hi->pci_slot == 0xff || !hi->ndev) + break; + c4_stopwd(netdev_priv(hi->ndev)); +#ifdef CONFIG_PROC_FS + sbecom_proc_brd_cleanup(netdev_priv(hi->ndev)); +#endif + unregister_netdev (hi->ndev); + free_irq (hi->pdev[0]->irq, hi->ndev); +#ifdef CONFIG_SBE_PMCC4_NCOMM + free_irq (hi->pdev[1]->irq, hi->ndev); +#endif + OS_kfree (hi->ndev); + } +} + + +STATIC int __init +c4_hdw_init (struct pci_dev * pdev, int found) +{ + hdw_info_t *hi; + int i; + int fun, slot; + unsigned char busno = 0xff; + + /* our MUSYCC chip supports two functions, 0 & 1 */ + if ((fun = PCI_FUNC (pdev->devfn)) > 1) + { + printk (KERN_WARNING "%s: unexpected devfun: 0x%x\n", THIS_MODULE->name, pdev->devfn); + return 0; + } + if (pdev->bus) /* obtain bus number */ + busno = pdev->bus->number; + else + busno = 0; /* default for system PCI inconsistency */ + slot = pdev->devfn & ~0x07; + + /* + * Functions 0 & 1 for a given board (identified by same bus(busno) and + * slot(slot)) are placed into the same 'hardware' structure. The first + * part of the board's functionality will be placed into an unpopulated + * element, identified by "slot==(0xff)". The second part of a board's + * functionality will match the previously loaded slot/busno. + */ + for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++) + { + /* + * match with board's first found interface, otherwise this is first + * found + */ + if ((hi->pci_slot == 0xff) || /* new board */ + ((hi->pci_slot == slot) && (hi->bus == pdev->bus))) + break; /* found for-loop exit */ + } + if (i == MAX_BOARDS) /* no match in above loop means MAX + * exceeded */ + { + printk (KERN_WARNING "%s: exceeded number of allowed devices (>%d)?\n", + THIS_MODULE->name, MAX_BOARDS); + return 0; + } + if (pdev->bus) + hi->pci_busno = pdev->bus->number; + else + hi->pci_busno = 0; /* default for system PCI inconsistency */ + hi->pci_slot = slot; + pci_read_config_byte (pdev, PCI_INTERRUPT_PIN, &hi->pci_pin[fun]); + pci_read_config_byte (pdev, PCI_REVISION_ID, &hi->revid[fun]); + hi->bus = pdev->bus; + hi->addr[fun] = pci_resource_start (pdev, 0); + hi->len[fun] = pci_resource_end (pdev, 0) - hi->addr[fun] + 1; + hi->pdev[fun] = pdev; + + { + /* + * create device name from module name, plus add the appropriate + * board number + */ + char *cp = hi->devname; + + strcpy (cp, THIS_MODULE->name); + cp += strlen (cp); /* reposition */ + *cp++ = '-'; + *cp++ = '0' + (found / 2); /* there are two found interfaces per + * board */ + *cp = 0; /* termination */ + } + + return 1; +} + + +status_t __init +c4hw_attach_all (void) +{ + hdw_info_t *hi; + struct pci_dev *pdev = NULL; + int found = 0, i, j; + + 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++; + } + if (!found) + { + printk (KERN_WARNING "%s: No boards found.\n", THIS_MODULE->name); + return ENODEV; + } + /* sanity check for consistant hardware found */ + for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++) + { + if (hi->pci_slot != 0xff && (!hi->addr[0] || !hi->addr[1])) + { + printk (KERN_WARNING "%s: something very wrong with pci_get_device.\n", hi->devname); + return EIO; + } + } + /* bring board's memory regions on/line */ + for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++) + { + if (hi->pci_slot == 0xff) + break; + for (j = 0; j < 2; j++) + { + if (request_mem_region (hi->addr[j], hi->len[j], hi->devname) == 0) + { + printk (KERN_WARNING "%s: memory in use, addr=0x%lx, len=0x%lx ?\n", + hi->devname, hi->addr[j], hi->len[j]); + cleanup_ioremap (); + return ENOMEM; + } + hi->addr_mapped[j] = (unsigned long) ioremap (hi->addr[j], hi->len[j]); + if (!hi->addr_mapped[j]) + { + printk (KERN_WARNING "%s: ioremap fails, addr=0x%lx, len=0x%lx ?\n", + hi->devname, hi->addr[j], hi->len[j]); + cleanup_ioremap (); + return ENOMEM; + } +#ifdef SBE_MAP_DEBUG + printk (KERN_WARNING "%s: io remapped from phys %x to virt %x\n", + hi->devname, (u_int32_t) hi->addr[j], (u_int32_t) hi->addr_mapped[j]); +#endif + } + } + + drvr_state = SBE_DRVR_AVAILABLE; + + /* Have now memory mapped all boards. Now allow board's access to system */ + for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++) + { + if (hi->pci_slot == 0xff) + break; + if (pci_enable_device (hi->pdev[0]) || + pci_enable_device (hi->pdev[1])) + { + drvr_state = SBE_DRVR_DOWN; + printk (KERN_WARNING "%s: failed to enable card %d slot %d\n", + hi->devname, i, hi->pci_slot); + cleanup_devs (); + cleanup_ioremap (); + return EIO; + } + pci_set_master (hi->pdev[0]); + pci_set_master (hi->pdev[1]); + if (!(hi->ndev = c4_add_dev (hi, i, (long) hi->addr_mapped[0], + (long) hi->addr_mapped[1], + hi->pdev[0]->irq, + hi->pdev[1]->irq))) + { + drvr_state = SBE_DRVR_DOWN; + cleanup_ioremap (); + /* NOTE: c4_add_dev() does its own device cleanup */ +#if 0 + cleanup_devs (); +#endif + return error_flag; /* error_flag set w/in add_dev() */ + } + show_two (hi, i); /* displays found information */ + } + return 0; +} + +/*** End-of-File ***/ diff --git a/drivers/staging/cxt1e1/libsbew.h b/drivers/staging/cxt1e1/libsbew.h new file mode 100644 index 000000000000..5c99646cd103 --- /dev/null +++ b/drivers/staging/cxt1e1/libsbew.h @@ -0,0 +1,581 @@ +/* + * $Id: libsbew.h,v 2.1 2005/10/27 18:54:19 rickd PMCC4_3_1B $ + */ + +#ifndef _INC_LIBSBEW_H_ +#define _INC_LIBSBEW_H_ + +/*----------------------------------------------------------------------------- + * libsbew.h - common library elements, charge across mulitple boards + * + * This file contains common Ioctl structures and contents definitions. + * + * Copyright (C) 2004-2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + * + * For further information, contact via email: support@sbei.com + * SBE, Inc. San Ramon, California U.S.A. + *----------------------------------------------------------------------------- + * RCS info: + * RCS revision: $Revision: 2.1 $ + * Last changed on $Date: 2005/10/27 18:54:19 $ + * Changed by $Author: rickd $ + *----------------------------------------------------------------------------- + * $Log: libsbew.h,v $ + * Revision 2.1 2005/10/27 18:54:19 rickd + * Add E1PLAIN support. + * + * Revision 2.0 2005/09/28 00:10:08 rickd + * Customized for PMCC4 comet-per-port design. + * + * Revision 1.15 2005/03/29 00:51:31 rickd + * File imported from C1T3 port, Revision 1.15 + *----------------------------------------------------------------------------- + */ + +#ifndef __KERNEL__ +#include <sys/types.h> +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +/********************************/ +/** set driver logging level **/ +/********************************/ + +/* routine/ioctl: wancfg_set_loglevel() - SBE_IOC_SET_LOGLEVEL */ + +#define LOG_NONE 0 +#define LOG_ERROR 1 +#define LOG_SBEBUG3 3 /* hidden, for development/debug usage */ +#define LOG_LSCHANGE 5 /* line state change logging */ +#define LOG_LSIMMEDIATE 6 /* line state change logging w/o hysterisis */ +#define LOG_WARN 8 +#define LOG_MONITOR 10 +#define LOG_SBEBUG12 12 /* hidden, for development/debug usage */ +#define LOG_MONITOR2 14 /* hidden, for development/debug usage */ +#define LOG_DEBUG 16 + + /* TEMPORARY DEFINES *//* RLD DEBUG */ +#define c4_LOG_NONE LOG_NONE +#define c4_LOG_ERROR LOG_ERROR +#define c4_LOG_WARN LOG_WARN +#define c4_LOG_sTrace LOG_MONITOR /* do some trace logging into + * functions */ +#define c4_LOG_DEBUG LOG_DEBUG +#define c4_LOG_MAX LOG_DEBUG + + + +/******************************/ +/** get driver information **/ +/******************************/ + +/* routine/ioctl: wancfg_get_drvinfo() - SBE_IOC_GET_DRVINFO */ + +#define REL_STRLEN 80 + struct sbe_drv_info + { + int rel_strlen; + char release[REL_STRLEN]; + }; + + +/*****************************/ +/** get board information **/ +/*****************************/ + +/* routine/ioctl: wancfg_get_brdinfo() - SBE_IOC_GET_BRDINFO */ + +#define CHNM_STRLEN 16 + struct sbe_brd_info + { + u_int32_t brd_id; /* SBE's unique PCI VENDOR/DEVID */ + u_int32_t brd_sn; + int brd_chan_cnt; /* number of channels being used */ + int brd_port_cnt; /* number of ports being used */ + unsigned char brdno; /* our board number */ + unsigned char brd_pci_speed; /* PCI speed, 33/66Mhz */ + u_int8_t brd_mac_addr[6]; + char first_iname[CHNM_STRLEN]; /* first assigned channel's + * interface name */ + char last_iname[CHNM_STRLEN]; /* last assigned channel's + * interface name */ + u_int8_t brd_hdw_id; /* on/board unique hdw ID */ + u_int8_t reserved8[3]; /* alignment preservation */ + u_int32_t reserved32[3]; /* size preservation */ + }; + +/* These IDs are sometimes available thru pci_ids.h, but not currently. */ + +#define PCI_VENDOR_ID_SBE 0x1176 +#define PCI_DEVICE_ID_WANPMC_C4T1E1 0x0701 /* BID 0x0X, BTYP 0x0X */ +#define PCI_DEVICE_ID_WANPTMC_C4T1E1 0x0702 /* BID 0x41 */ +#define PCI_DEVICE_ID_WANADAPT_HC4T1E1 0x0703 /* BID 0x44 */ +#define PCI_DEVICE_ID_WANPTMC_256T3_T1 0x0704 /* BID 0x42 (T1 Version) */ +#define PCI_DEVICE_ID_WANPCI_C4T1E1 0x0705 /* BID 0x1X, BTYP 0x0X */ +#define PCI_DEVICE_ID_WANPMC_C1T3 0x0706 /* BID 0x45 */ +#define PCI_DEVICE_ID_WANPCI_C2T1E1 0x0707 /* BID 0x1X, BTYP 0x2X */ +#define PCI_DEVICE_ID_WANPCI_C1T1E1 0x0708 /* BID 0x1X, BTYP 0x1X */ +#define PCI_DEVICE_ID_WANPMC_C2T1E1 0x0709 /* BID 0x0X, BTYP 0x2X */ +#define PCI_DEVICE_ID_WANPMC_C1T1E1 0x070A /* BID 0x0X, BTYP 0x1X */ +#define PCI_DEVICE_ID_WANPTMC_256T3_E1 0x070B /* BID 0x46 (E1 Version) */ +#define PCI_DEVICE_ID_WANPTMC_C24TE1 0x070C /* BID 0x47 */ +#define PCI_DEVICE_ID_WANPMC_C4T1E1_L 0x070D /* BID 0x2X, BTYPE 0x0X w/FP + * LEDs */ +#define PCI_DEVICE_ID_WANPMC_C2T1E1_L 0x070E /* BID 0x2X, BTYPE 0x2X w/FP + * LEDs */ +#define PCI_DEVICE_ID_WANPMC_C1T1E1_L 0x070F /* BID 0x2X, BTYPE 0x1X w/FP + * LEDs */ +#define PCI_DEVICE_ID_WANPMC_2SSI 0x0801 +#define PCI_DEVICE_ID_WANPCI_4SSI 0x0802 +#define PCI_DEVICE_ID_WANPMC_2T3E3 0x0900 /* BID 0x43 */ +#define SBE_BOARD_ID(v,id) ((v<<16) | id) + +#define BINFO_PCI_SPEED_unk 0 +#define BINFO_PCI_SPEED_33 1 +#define BINFO_PCI_SPEED_66 2 + +/***************************/ +/** obtain interface ID **/ +/***************************/ + +/* routine/ioctl: wancfg_get_iid() - SBE_IOC_IID_GET */ + + struct sbe_iid_info + { + u_int32_t channum; /* channel requested */ + char iname[CHNM_STRLEN]; /* channel's interface name */ + }; + +/**************************************/ +/** get board address information **/ +/**************************************/ + +/* routine/ioctl: wancfg_get_brdaddr() - SBE_IOC_BRDADDR_GET */ + + struct sbe_brd_addr + { + unsigned char func; /* select PCI address space function */ + unsigned char brdno; /* returns brdno requested */ + unsigned char irq; + unsigned char size; /* returns size of address */ +#define BRDADDR_SIZE_64 1 +#define BRDADDR_SIZE_32 2 + int reserved1; /* mod64 align, reserved for future use */ + + union + { + unsigned long virt64; /* virtual/mapped address */ + u_int32_t virt32[2]; + } v; + union + { + unsigned long phys64; /* physical bus address */ + u_int32_t phys32[2]; + } p; + int reserved2[4]; /* reserved for future use */ + }; + +/**********************************/ +/** read/write board registers **/ +/**********************************/ + +/* routine/ioctl: wancfg_read_vec() - SBE_IOC_READ_VEC */ +/* routine/ioctl: wancfg_write_vec() - SBE_IOC_WRITE_VEC */ + + struct sbecom_wrt_vec + { + u_int32_t reg; + u_int32_t data; + }; + +#define C1T3_CHIP_MSCC_32 0x01000000 +#define C1T3_CHIP_TECT3_8 0x02000000 +#define C1T3_CHIP_CPLD_8 0x03000000 +#define C1T3_CHIP_EEPROM_8 0x04000000 + +#define W256T3_CHIP_MUSYCC_32 0x02000000 +#define W256T3_CHIP_TEMUX_8 0x10000000 +#define W256T3_CHIP_T8110_8 0x20000000 +#define W256T3_CHIP_T8110_32 0x22000000 +#define W256T3_CHIP_CPLD_8 0x30000000 +#define W256T3_CHIP_EEPROM_8 0x40000000 + + +/**********************************/ +/** read write port parameters **/ +/**********************************/ + +/* routine/ioctl: wancfg_getset_port_param() - SBE_IOC_PORT_GET */ +/* routine/ioctl: wancfg_set_port_param() - SBE_IOC_PORT_SET */ + +/* NOTE: this structure supports hardware which supports individual per/port control */ + +struct sbecom_port_param +{ + u_int8_t portnum; + u_int8_t port_mode; /* variations of T1 or E1 mode */ + u_int8_t portStatus; + u_int8_t portP; /* more port parameters (clock source - 0x80; + * and LBO - 0xf; */ + /* bits 0x70 are reserved for future use ) */ +#ifdef SBE_PMCC4_ENABLE + u_int32_t hypersize; /* RLD DEBUG - add this in until I learn how to make this entry obsolete */ +#endif + int reserved[3-1]; /* reserved for future use */ + int _res[4]; +}; + +#define CFG_CLK_PORT_MASK 0x80 /* Loop timing */ +#define CFG_CLK_PORT_INTERNAL 0x80 /* Loop timing */ +#define CFG_CLK_PORT_EXTERNAL 0x00 /* Loop timing */ + +#define CFG_LBO_MASK 0x0F +#define CFG_LBO_unk 0 /* <not defined> */ +#define CFG_LBO_LH0 1 /* T1 Long Haul (default) */ +#define CFG_LBO_LH7_5 2 /* T1 Long Haul */ +#define CFG_LBO_LH15 3 /* T1 Long Haul */ +#define CFG_LBO_LH22_5 4 /* T1 Long Haul */ +#define CFG_LBO_SH110 5 /* T1 Short Haul */ +#define CFG_LBO_SH220 6 /* T1 Short Haul */ +#define CFG_LBO_SH330 7 /* T1 Short Haul */ +#define CFG_LBO_SH440 8 /* T1 Short Haul */ +#define CFG_LBO_SH550 9 /* T1 Short Haul */ +#define CFG_LBO_SH660 10 /* T1 Short Haul */ +#define CFG_LBO_E75 11 /* E1 75 Ohm */ +#define CFG_LBO_E120 12 /* E1 120 Ohm (default) */ + + +/*************************************/ +/** read write channel parameters **/ +/*************************************/ + +/* routine/ioctl: wancfg_getset_chan_param() - SBE_IOC_CHAN_GET */ +/* routine/ioctl: wancfg_set_chan_param() - SBE_IOC_CHAN_SET */ + +/* NOTE: this structure supports hardware which supports individual per/channel control */ + + struct sbecom_chan_param + { + u_int32_t channum; /* 0: */ +#ifdef SBE_PMCC4_ENABLE + u_int32_t card; /* RLD DEBUG - add this in until I learn how to make this entry obsolete */ + u_int32_t port; /* RLD DEBUG - add this in until I learn how to make this entry obsolete */ + u_int8_t bitmask[32]; +#endif + u_int32_t intr_mask; /* 4: interrupt mask, specify ored + * (SS7_)INTR_* to disable */ + u_int8_t status; /* 8: channel transceiver status (TX_ENABLED, + * RX_ENABLED) */ + u_int8_t chan_mode; /* 9: protocol mode */ + u_int8_t idlecode; /* A: idle code, in (FLAG_7E, FLAG_FF, + * FLAG_00) */ + u_int8_t pad_fill_count; /* B: pad fill count (1-127), 0 - pad + * fill disabled */ + u_int8_t data_inv; /* C: channel data inversion selection */ + u_int8_t mode_56k; /* D: 56kbps mode */ + u_int8_t reserved[2 + 8]; /* E: */ + }; + +/* SS7 interrupt signals <intr_mask> */ +#define SS7_INTR_SFILT 0x00000020 +#define SS7_INTR_SDEC 0x00000040 +#define SS7_INTR_SINC 0x00000080 +#define SS7_INTR_SUERR 0x00000100 +/* Other interrupts that can be masked */ +#define INTR_BUFF 0x00000002 +#define INTR_EOM 0x00000004 +#define INTR_MSG 0x00000008 +#define INTR_IDLE 0x00000010 + +/* transceiver status flags <status> */ +#define TX_ENABLED 0x01 +#define RX_ENABLED 0x02 + +/* Protocol modes <mode> */ +#define CFG_CH_PROTO_TRANS 0 +#define CFG_CH_PROTO_SS7 1 +#define CFG_CH_PROTO_HDLC_FCS16 2 +#define CFG_CH_PROTO_HDLC_FCS32 3 +#define CFG_CH_PROTO_ISLP_MODE 4 + +/* Possible idle code assignments <idlecode> */ +#define CFG_CH_FLAG_7E 0 +#define CFG_CH_FLAG_FF 1 +#define CFG_CH_FLAG_00 2 + +/* data inversion selection <data_inv> */ +#define CFG_CH_DINV_NONE 0x00 +#define CFG_CH_DINV_RX 0x01 +#define CFG_CH_DINV_TX 0x02 + + +/* Posssible resettable chipsets/functions */ +#define RESET_DEV_TEMUX 1 +#define RESET_DEV_TECT3 RESET_DEV_TEMUX +#define RESET_DEV_PLL 2 + + +/*********************************************/ +/** read reset channel thruput statistics **/ +/*********************************************/ + +/* routine/ioctl: wancfg_get_chan_stats() - SBE_IOC_CHAN_GET_STAT */ +/* routine/ioctl: wancfg_del_chan_stats() - SBE_IOC_CHAN_DEL_STAT */ +/* routine/ioctl: wancfg_get_card_chan_stats() - SBE_IOC_CARD_CHAN_STAT */ + + struct sbecom_chan_stats + { + unsigned long rx_packets; /* total packets received */ + unsigned long tx_packets; /* total packets transmitted */ + unsigned long rx_bytes; /* total bytes received */ + unsigned long tx_bytes; /* total bytes transmitted */ + unsigned long rx_errors;/* bad packets received */ + unsigned long tx_errors;/* packet transmit problems */ + unsigned long rx_dropped; /* no space in linux buffers */ + unsigned long tx_dropped; /* no space available in linux */ + + /* detailed rx_errors: */ + unsigned long rx_length_errors; + unsigned long rx_over_errors; /* receiver ring buff overflow */ + unsigned long rx_crc_errors; /* recved pkt with crc error */ + unsigned long rx_frame_errors; /* recv'd frame alignment error */ + unsigned long rx_fifo_errors; /* recv'r fifo overrun */ + unsigned long rx_missed_errors; /* receiver missed packet */ + + /* detailed tx_errors */ + unsigned long tx_aborted_errors; + unsigned long tx_fifo_errors; + unsigned long tx_pending; + }; + + +/****************************************/ +/** read write card level parameters **/ +/****************************************/ + + /* NOTE: this structure supports hardware which supports per/card control */ + + struct sbecom_card_param + { + u_int8_t framing_type; /* 0: CBP or M13 */ + u_int8_t loopback; /* 1: one of LOOPBACK_* */ + u_int8_t line_build_out; /* 2: boolean */ + u_int8_t receive_eq; /* 3: boolean */ + u_int8_t transmit_ones; /* 4: boolean */ + u_int8_t clock; /* 5: 0 - internal, i>0 - external (recovered + * from framer i) */ + u_int8_t h110enable; /* 6: */ + u_int8_t disable_leds; /* 7: */ + u_int8_t reserved1; /* 8: available - old 256t3 hypersized, but + * never used */ + u_int8_t rear_io; /* 9: rear I/O off/on */ + u_int8_t disable_tx; /* A: disable TX off/on */ + u_int8_t mute_los; /* B: mute LOS off/on */ + u_int8_t los_threshold; /* C: LOS threshold norm/low + * (default: norm) */ + u_int8_t ds1_mode; /* D: DS1 mode T1/E1 (default: T1) */ + u_int8_t ds3_unchan; /* E: DS3 unchannelized mode off/on */ + u_int8_t reserved[1 + 16]; /* reserved for expansion - must be + * ZERO filled */ + }; + +/* framing types <framing_type> */ +#define FRAMING_M13 0 +#define FRAMING_CBP 1 + +/* card level loopback options <loopback> */ +#define CFG_CARD_LOOPBACK_NONE 0x00 +#define CFG_CARD_LOOPBACK_DIAG 0x01 +#define CFG_CARD_LOOPBACK_LINE 0x02 +#define CFG_CARD_LOOPBACK_PAYLOAD 0x03 + +/* line level loopback options <loopback> */ +#define CFG_LIU_LOOPBACK_NONE 0x00 +#define CFG_LIU_LOOPBACK_ANALOG 0x10 +#define CFG_LIU_LOOPBACK_DIGITAL 0x11 +#define CFG_LIU_LOOPBACK_REMOTE 0x12 + +/* card level clock options <clock> */ +#define CFG_CLK_INTERNAL 0x00 +#define CFG_CLK_EXTERNAL 0x01 + +/* legacy 256T3 loopback values */ +#define LOOPBACK_NONE 0 +#define LOOPBACK_LIU_ANALOG 1 +#define LOOPBACK_LIU_DIGITAL 2 +#define LOOPBACK_FRAMER_DS3 3 +#define LOOPBACK_FRAMER_T1 4 +#define LOOPBACK_LIU_REMOTE 5 + +/* DS1 mode <ds1_mode> */ +#define CFG_DS1_MODE_MASK 0x0f +#define CFG_DS1_MODE_T1 0x00 +#define CFG_DS1_MODE_E1 0x01 +#define CFG_DS1_MODE_CHANGE 0x80 + +/* DS3 unchannelized values <ds1_unchan> */ +#define CFG_DS3_UNCHAN_MASK 0x01 +#define CFG_DS3_UNCHAN_OFF 0x00 +#define CFG_DS3_UNCHAN_ON 0x01 + + +/************************************/ +/** read write framer parameters **/ +/************************************/ + +/* routine/ioctl: wancfg_get_framer() - SBE_IOC_FRAMER_GET */ +/* routine/ioctl: wancfg_set_framer() - SBE_IOC_FRAMER_SET */ + + struct sbecom_framer_param + { + u_int8_t framer_num; + u_int8_t frame_type; /* SF, ESF, E1PLAIN, E1CAS, E1CRC, E1CRC+CAS */ + u_int8_t loopback_type; /* DIGITAL, LINE, PAYLOAD */ + u_int8_t auto_alarms;/* auto alarms */ + u_int8_t reserved[12]; /* reserved for expansion - must be + * ZERO filled */ + }; + +/* frame types <frame_type> */ +#define CFG_FRAME_NONE 0 +#define CFG_FRAME_SF 1 /* T1 B8ZS */ +#define CFG_FRAME_ESF 2 /* T1 B8ZS */ +#define CFG_FRAME_E1PLAIN 3 /* HDB3 w/o CAS,CRC */ +#define CFG_FRAME_E1CAS 4 /* HDB3 */ +#define CFG_FRAME_E1CRC 5 /* HDB3 */ +#define CFG_FRAME_E1CRC_CAS 6 /* HDB3 */ +#define CFG_FRAME_SF_AMI 7 /* T1 AMI */ +#define CFG_FRAME_ESF_AMI 8 /* T1 AMI */ +#define CFG_FRAME_E1PLAIN_AMI 9 /* E1 AMI w/o CAS,CRC */ +#define CFG_FRAME_E1CAS_AMI 10 /* E1 AMI */ +#define CFG_FRAME_E1CRC_AMI 11 /* E1 AMI */ +#define CFG_FRAME_E1CRC_CAS_AMI 12 /* E1 AMI */ + +#define IS_FRAME_ANY_T1(field) \ + (((field) == CFG_FRAME_NONE) || \ + ((field) == CFG_FRAME_SF) || \ + ((field) == CFG_FRAME_ESF) || \ + ((field) == CFG_FRAME_SF_AMI) || \ + ((field) == CFG_FRAME_ESF_AMI)) + +#define IS_FRAME_ANY_T1ESF(field) \ + (((field) == CFG_FRAME_ESF) || \ + ((field) == CFG_FRAME_ESF_AMI)) + +#define IS_FRAME_ANY_E1(field) \ + (((field) == CFG_FRAME_E1PLAIN) || \ + ((field) == CFG_FRAME_E1CAS) || \ + ((field) == CFG_FRAME_E1CRC) || \ + ((field) == CFG_FRAME_E1CRC_CAS) || \ + ((field) == CFG_FRAME_E1PLAIN_AMI) || \ + ((field) == CFG_FRAME_E1CAS_AMI) || \ + ((field) == CFG_FRAME_E1CRC_AMI) || \ + ((field) == CFG_FRAME_E1CRC_CAS_AMI)) + +#define IS_FRAME_ANY_AMI(field) \ + (((field) == CFG_FRAME_SF_AMI) || \ + ((field) == CFG_FRAME_ESF_AMI) || \ + ((field) == CFG_FRAME_E1PLAIN_AMI) || \ + ((field) == CFG_FRAME_E1CAS_AMI) || \ + ((field) == CFG_FRAME_E1CRC_AMI) || \ + ((field) == CFG_FRAME_E1CRC_CAS_AMI)) + +/* frame level loopback options <loopback_type> */ +#define CFG_FRMR_LOOPBACK_NONE 0 +#define CFG_FRMR_LOOPBACK_DIAG 1 +#define CFG_FRMR_LOOPBACK_LINE 2 +#define CFG_FRMR_LOOPBACK_PAYLOAD 3 + + +/****************************************/ +/** read reset card error statistics **/ +/****************************************/ + +/* routine/ioctl: wancfg_get_card_stats() - SBE_IOC_CARD_GET_STAT */ +/* routine/ioctl: wancfg_del_card_stats() - SBE_IOC_CARD_DEL_STAT */ + + struct temux_card_stats + { + struct temux_stats + { + /* TEMUX DS3 PMON counters */ + u_int32_t lcv; + u_int32_t err_framing; + u_int32_t febe; + u_int32_t err_cpbit; + u_int32_t err_parity; + /* TEMUX DS3 FRMR status */ + u_int8_t los; + u_int8_t oof; + u_int8_t red; + u_int8_t yellow; + u_int8_t idle; + u_int8_t ais; + u_int8_t cbit; + /* TEMUX DS3 FEAC receiver */ + u_int8_t feac; + u_int8_t feac_last; + } t; + u_int32_t tx_pending; /* total */ + }; + +/**************************************************************/ + + struct wancfg + { + int cs, ds; + char *p; + }; + typedef struct wancfg wcfg_t; + + extern wcfg_t *wancfg_init (char *, char *); + extern int wancfg_card_blink (wcfg_t *, int); + extern int wancfg_ctl (wcfg_t *, int, void *, int, void *, int); + extern int wancfg_del_card_stats (wcfg_t *); + extern int wancfg_del_chan_stats (wcfg_t *, int); + extern int wancfg_enable_ports (wcfg_t *, int); + extern int wancfg_free (wcfg_t *); + extern int wancfg_get_brdaddr (wcfg_t *, struct sbe_brd_addr *); + extern int wancfg_get_brdinfo (wcfg_t *, struct sbe_brd_info *); + extern int wancfg_get_card (wcfg_t *, struct sbecom_card_param *); + extern int wancfg_get_card_chan_stats (wcfg_t *, struct sbecom_chan_stats *); + extern int wancfg_get_card_sn (wcfg_t *); + extern int wancfg_get_card_stats (wcfg_t *, struct temux_card_stats *); + extern int wancfg_get_chan (wcfg_t *, int, struct sbecom_chan_param *); + extern int wancfg_get_chan_stats (wcfg_t *, int, struct sbecom_chan_stats *); + extern int wancfg_get_drvinfo (wcfg_t *, int, struct sbe_drv_info *); + extern int wancfg_get_framer (wcfg_t *, int, struct sbecom_framer_param *); + extern int wancfg_get_iid (wcfg_t *, int, struct sbe_iid_info *); + extern int wancfg_get_sn (wcfg_t *, unsigned int *); + extern int wancfg_read (wcfg_t *, int, struct sbecom_wrt_vec *); + extern int wancfg_reset_device (wcfg_t *, int); + extern int wancfg_set_card (wcfg_t *, struct sbecom_card_param *); + extern int wancfg_set_chan (wcfg_t *, int, struct sbecom_chan_param *); + extern int wancfg_set_framer (wcfg_t *, int, struct sbecom_framer_param *); + extern int wancfg_set_loglevel (wcfg_t *, uint); + extern int wancfg_write (wcfg_t *, int, struct sbecom_wrt_vec *); + +#ifdef NOT_YET_COMMON + extern int wancfg_get_tsioc (wcfg_t *, struct wanc1t3_ts_hdr *, struct wanc1t3_ts_param *); + extern int wancfg_set_tsioc (wcfg_t *, struct wanc1t3_ts_param *); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*** _INC_LIBSBEW_H_ ***/ diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c new file mode 100644 index 000000000000..aee7018f9d3f --- /dev/null +++ b/drivers/staging/cxt1e1/linux.c @@ -0,0 +1,1354 @@ +/* Copyright (C) 2007-2008 One Stop Systems + * Copyright (C) 2003-2006 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + */ + +#include <linux/types.h> +#include <linux/netdevice.h> +#include <linux/hdlc.h> +#include <linux/if_arp.h> +#include <linux/init.h> +#include <asm/uaccess.h> +#include <linux/rtnetlink.h> +#include <linux/skbuff.h> +#include "pmcc4_sysdep.h" +#include "sbecom_inline_linux.h" +#include "libsbew.h" +#include "pmcc4.h" +#include "pmcc4_ioctls.h" +#include "pmcc4_private.h" +#include "sbeproc.h" + +/***************************************************************************************** + * Error out early if we have compiler trouble. + * + * (This section is included from the kernel's init/main.c as a friendly + * spiderman recommendation...) + * + * Versions of gcc older than that listed below may actually compile and link + * okay, but the end product can have subtle run time bugs. To avoid associated + * bogus bug reports, we flatly refuse to compile with a gcc that is known to be + * too old from the very beginning. + */ +#if (__GNUC__ < 3) || (__GNUC__ == 3 && __GNUC_MINOR__ < 2) +#error Sorry, your GCC is too old. It builds incorrect kernels. +#endif + +#if __GNUC__ == 4 && __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ == 0 +#warning gcc-4.1.0 is known to miscompile the kernel. A different compiler version is recommended. +#endif + +/*****************************************************************************************/ + +#ifdef SBE_INCLUDE_SYMBOLS +#define STATIC +#else +#define STATIC static +#endif + +#define CHANNAME "hdlc" + +/*******************************************************************/ +/* forward references */ +status_t c4_chan_work_init (mpi_t *, mch_t *); +void musycc_wq_chan_restart (void *); +status_t __init c4_init (ci_t *, u_char *, u_char *); +status_t __init c4_init2 (ci_t *); +ci_t *__init c4_new (void *); +int __init c4hw_attach_all (void); +void __init hdw_sn_get (hdw_info_t *, int); + +#ifdef CONFIG_SBE_PMCC4_NCOMM +irqreturn_t c4_ebus_intr_th_handler (void *); + +#endif +int c4_frame_rw (ci_t *, struct sbecom_port_param *); +status_t c4_get_port (ci_t *, int); +int c4_loop_port (ci_t *, int, u_int8_t); +int c4_musycc_rw (ci_t *, struct c4_musycc_param *); +int c4_new_chan (ci_t *, int, int, void *); +status_t c4_set_port (ci_t *, int); +int c4_pld_rw (ci_t *, struct sbecom_port_param *); +void cleanup_devs (void); +void cleanup_ioremap (void); +status_t musycc_chan_down (ci_t *, int); +irqreturn_t musycc_intr_th_handler (void *); +int musycc_start_xmit (ci_t *, int, void *); + +extern char pmcc4_OSSI_release[]; +extern ci_t *CI; +extern struct s_hdw_info hdw_info[]; + +#if defined(CONFIG_SBE_HDLC_V7) || defined(CONFIG_SBE_WAN256T3_HDLC_V7) || \ + defined(CONFIG_SBE_HDLC_V7_MODULE) || defined(CONFIG_SBE_WAN256T3_HDLC_V7_MODULE) +#define _v7_hdlc_ 1 +#else +#define _v7_hdlc_ 0 +#endif + +#if _v7_hdlc_ +#define V7(x) (x ## _v7) +extern int hdlc_netif_rx_v7 (hdlc_device *, struct sk_buff *); +extern int register_hdlc_device_v7 (hdlc_device *); +extern int unregister_hdlc_device_v7 (hdlc_device *); + +#else +#define V7(x) x +#endif + +int error_flag; /* module load error reporting */ +int log_level = LOG_ERROR; +int log_level_default = LOG_ERROR; +module_param(log_level, int, 0444); + +int max_mru = MUSYCC_MRU; +int max_mru_default = MUSYCC_MRU; +module_param(max_mru, int, 0444); + +int max_mtu = MUSYCC_MTU; +int max_mtu_default = MUSYCC_MTU; +module_param(max_mtu, int, 0444); + +int max_txdesc_used = MUSYCC_TXDESC_MIN; +int max_txdesc_default = MUSYCC_TXDESC_MIN; +module_param(max_txdesc_used, int, 0444); + +int max_rxdesc_used = MUSYCC_RXDESC_MIN; +int max_rxdesc_default = MUSYCC_RXDESC_MIN; +module_param(max_rxdesc_used, int, 0444); + +/****************************************************************************/ +/****************************************************************************/ +/****************************************************************************/ + +void * +getuserbychan (int channum) +{ + mch_t *ch; + + ch = c4_find_chan (channum); + return ch ? ch->user : 0; +} + + +#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) +{ + struct c4_priv *priv = hdlc->priv; + struct net_device *dev = getuserbychan (priv->channum); + + return dev->name; +} +#endif + + +static status_t +mkret (int bsd) +{ + if (bsd > 0) + return -bsd; + else + return bsd; +} + +/***************************************************************************/ +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41) +#include <linux/workqueue.h> + +/*** + * One workqueue (wq) per port (since musycc allows simultaneous group + * commands), with individual data for each channel: + * + * mpi_t -> struct workqueue_struct *wq_port; (dynamically allocated using + * create_workqueue()) + * + * With work structure (work) statically allocated for each channel: + * + * mch_t -> struct work_struct ch_work; (statically allocated using ???) + * + ***/ + + +/* + * Called by the start transmit routine when a channel TX_ENABLE is to be + * issued. This queues the transmission start request among other channels + * within a port's group. + */ +void +c4_wk_chan_restart (mch_t * ch) +{ + mpi_t *pi = ch->up; + +#ifdef RLD_RESTART_DEBUG + printk (">> c4_wk_chan_restart: queueing Port %d Chan %d, mch_t @ %p\n", pi->portnum, ch->channum, ch); +#endif + + /* create new entry w/in workqueue for this channel and let'er rip */ + + /** queue_work (struct workqueue_struct *queue, + ** struct work_struct *work); + **/ + queue_work (pi->wq_port, &ch->ch_work); +} + +status_t +c4_wk_chan_init (mpi_t * pi, mch_t * ch) +{ + /* + * this will be used to restart a stopped channel + */ + + /** INIT_WORK (struct work_struct *work, + ** void (*function)(void *), + ** void *data); + **/ + INIT_WORK(&ch->ch_work, (void *)musycc_wq_chan_restart); + return 0; /* success */ +} + +status_t +c4_wq_port_init (mpi_t * pi) +{ + + char name[16], *np; /* NOTE: name of the queue limited by system + * to 10 characters */ + + if (pi->wq_port) + return 0; /* already initialized */ + + np = name; + memset (name, 0, 16); + sprintf (np, "%s%d", pi->up->devname, pi->portnum); /* IE pmcc4-01) */ + +#ifdef RLD_RESTART_DEBUG + printk (">> c4_wq_port_init: creating workqueue <%s> for Port %d.\n", name, pi->portnum); /* RLD DEBUG */ +#endif + if (!(pi->wq_port = create_singlethread_workqueue (name))) + return ENOMEM; + return 0; /* success */ +} + +void +c4_wq_port_cleanup (mpi_t * pi) +{ + /* + * PORT POINT: cannot call this if WQ is statically allocated w/in + * structure since it calls kfree(wq); + */ + if (pi->wq_port) + { + destroy_workqueue (pi->wq_port); /* this also calls + * flush_workqueue() */ + pi->wq_port = 0; + } +} +#endif + +/***************************************************************************/ + +irqreturn_t +c4_linux_interrupt (int irq, void *dev_instance) +{ + struct net_device *ndev = dev_instance; + + return musycc_intr_th_handler(netdev_priv(ndev)); +} + + +#ifdef CONFIG_SBE_PMCC4_NCOMM +irqreturn_t +c4_ebus_interrupt (int irq, void *dev_instance) +{ + struct net_device *ndev = dev_instance; + + return c4_ebus_intr_th_handler(netdev_priv(ndev)); +} +#endif + + +static int +void_open (struct net_device * ndev) +{ + printk ("%s: trying to open master device !\n", ndev->name); + return -1; +} + + +#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))) + { + printk ("%s: hdlc_open failure, err %d.\n", THIS_MODULE->name, 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) +{ + hdlc_device *hdlc = dev_to_hdlc (ndev); + const struct c4_priv *priv = hdlc->priv; + int ret; + + if ((ret = hdlc_open (ndev))) + { + printk ("%s: hdlc_open failure, err %d.\n", THIS_MODULE->name, ret); + return ret; + } + if ((ret = c4_chan_up (priv->ci, priv->channum))) + return -ret; + try_module_get (THIS_MODULE); + 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) +{ + hdlc_device *hdlc = dev_to_hdlc (ndev); + const struct c4_priv *priv = hdlc->priv; + + netif_stop_queue (ndev); + musycc_chan_down ((ci_t *) 0, priv->channum); + hdlc_close (ndev); + module_put (THIS_MODULE); + return 0; +} +#endif + + +#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) +{ + return hdlc_ioctl (dev, ifr, 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 */ +} +#endif + + +STATIC struct net_device_stats * +chan_get_stats (struct net_device * ndev) +{ + mch_t *ch; + struct net_device_stats *nstats; + 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) + return NULL; + + nstats = &ndev->stats; + stats = &ch->s; + + memset (nstats, 0, sizeof (struct net_device_stats)); + nstats->rx_packets = stats->rx_packets; + nstats->tx_packets = stats->tx_packets; + nstats->rx_bytes = stats->rx_bytes; + nstats->tx_bytes = stats->tx_bytes; + nstats->rx_errors = stats->rx_length_errors + + stats->rx_over_errors + + stats->rx_crc_errors + + stats->rx_frame_errors + + stats->rx_fifo_errors + + stats->rx_missed_errors; + nstats->tx_errors = stats->tx_dropped + + stats->tx_aborted_errors + + stats->tx_fifo_errors; + nstats->rx_dropped = stats->rx_dropped; + nstats->tx_dropped = stats->tx_dropped; + + nstats->rx_length_errors = stats->rx_length_errors; + nstats->rx_over_errors = stats->rx_over_errors; + nstats->rx_crc_errors = stats->rx_crc_errors; + nstats->rx_frame_errors = stats->rx_frame_errors; + nstats->rx_fifo_errors = stats->rx_fifo_errors; + nstats->rx_missed_errors = stats->rx_missed_errors; + + nstats->tx_aborted_errors = stats->tx_aborted_errors; + nstats->tx_fifo_errors = stats->tx_fifo_errors; + + return nstats; +} + + +static ci_t * +get_ci_by_dev (struct net_device * ndev) +{ + return (ci_t *)(netdev_priv(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) +{ + 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; +} +#endif /* GENERIC_HDLC_VERSION */ + +static const struct net_device_ops chan_ops = { + .ndo_open = chan_open, + .ndo_stop = chan_close, + .ndo_start_xmit = c4_linux_xmit, + .ndo_do_ioctl = chan_dev_ioctl, + .ndo_get_stats = chan_get_stats, +}; + +STATIC struct net_device * +create_chan (struct net_device * ndev, ci_t * ci, + struct sbecom_chan_param * cp) +{ + hdlc_device *hdlc; + struct net_device *dev; + hdw_info_t *hi; + int ret; + + if (c4_find_chan (cp->channum)) + return 0; /* channel already exists */ + + { + struct c4_priv *priv; + + /* allocate then fill in private data structure */ + priv = OS_kmalloc (sizeof (struct c4_priv)); + if (!priv) + { + printk (KERN_WARNING "%s: no memory for net_device !\n", ci->devname); + return 0; + } + dev = alloc_hdlcdev (priv); + if (!dev) + { + printk (KERN_WARNING "%s: no memory for hdlc_device !\n", ci->devname); + OS_kfree (priv); + return 0; + } + priv->ci = ci; + priv->channum = cp->channum; + } + + hdlc = dev_to_hdlc (dev); + + dev->base_addr = 0; /* not I/O mapped */ + dev->irq = ndev->irq; + dev->type = ARPHRD_RAWHDLC; + *dev->name = 0; /* default ifconfig name = "hdlc" */ + + hi = (hdw_info_t *) ci->hdw_info; + if (hi->mfg_info_sts == EEPROM_OK) + { + switch (hi->promfmt) + { + case PROM_FORMAT_TYPE1: + memcpy (dev->dev_addr, (FLD_TYPE1 *) (hi->mfg_info.pft1.Serial), 6); + break; + case PROM_FORMAT_TYPE2: + memcpy (dev->dev_addr, (FLD_TYPE2 *) (hi->mfg_info.pft2.Serial), 6); + break; + default: + memset (dev->dev_addr, 0, 6); + break; + } + } else + { + memset (dev->dev_addr, 0, 6); + } + + hdlc->xmit = c4_linux_xmit; + + dev->netdev_ops = &chan_ops; + /* + * The native hdlc stack calls this 'attach' routine during + * hdlc_raw_ioctl(), passing parameters for line encoding and parity. + * Since hdlc_raw_ioctl() stack does not interrogate whether an 'attach' + * routine is actually registered or not, we supply a dummy routine which + * does nothing (since encoding and parity are setup for our driver via a + * special configuration application). + */ + + hdlc->attach = chan_attach_noop; + + rtnl_unlock (); /* needed due to Ioctl calling sequence */ + ret = register_hdlc_device (dev); + /* NOTE: <stats> setting must occur AFTER registration in order to "take" */ + dev->tx_queue_len = MAX_DEFAULT_IFQLEN; + + rtnl_lock (); /* needed due to Ioctl calling sequence */ + if (ret) + { + if (log_level >= LOG_WARN) + printk ("%s: create_chan[%d] registration error = %d.\n", + ci->devname, cp->channum, ret); + free_netdev (dev); /* cleanup */ + return 0; /* failed to register */ + } + return dev; +} + + +/* the idea here is to get port information and pass it back (using pointer) */ +STATIC status_t +do_get_port (struct net_device * ndev, void *data) +{ + int ret; + ci_t *ci; /* ci stands for card information */ + struct sbecom_port_param pp;/* copy data to kernel land */ + + if (copy_from_user (&pp, data, sizeof (struct sbecom_port_param))) + return -EFAULT; + if (pp.portnum >= MUSYCC_NPORTS) + return -EFAULT; + ci = get_ci_by_dev (ndev); + if (!ci) + return -EINVAL; /* get card info */ + + ret = mkret (c4_get_port (ci, pp.portnum)); + if (ret) + return ret; + if (copy_to_user (data, &ci->port[pp.portnum].p, + sizeof (struct sbecom_port_param))) + return -EFAULT; + return 0; +} + +/* this function copys the user data and then calls the real action function */ +STATIC status_t +do_set_port (struct net_device * ndev, void *data) +{ + ci_t *ci; /* ci stands for card information */ + struct sbecom_port_param pp;/* copy data to kernel land */ + + if (copy_from_user (&pp, data, sizeof (struct sbecom_port_param))) + return -EFAULT; + if (pp.portnum >= MUSYCC_NPORTS) + return -EFAULT; + ci = get_ci_by_dev (ndev); + if (!ci) + return -EINVAL; /* get card info */ + + if (pp.portnum >= ci->max_port) /* sanity check */ + return ENXIO; + + memcpy (&ci->port[pp.portnum].p, &pp, sizeof (struct sbecom_port_param)); + return mkret (c4_set_port (ci, pp.portnum)); +} + +/* work the port loopback mode as per directed */ +STATIC status_t +do_port_loop (struct net_device * ndev, void *data) +{ + struct sbecom_port_param pp; + ci_t *ci; + + if (copy_from_user (&pp, data, sizeof (struct sbecom_port_param))) + return -EFAULT; + ci = get_ci_by_dev (ndev); + if (!ci) + return -EINVAL; + return mkret (c4_loop_port (ci, pp.portnum, pp.port_mode)); +} + +/* set the specified register with the given value / or just read it */ +STATIC status_t +do_framer_rw (struct net_device * ndev, void *data) +{ + struct sbecom_port_param pp; + ci_t *ci; + int ret; + + if (copy_from_user (&pp, data, sizeof (struct sbecom_port_param))) + return -EFAULT; + ci = get_ci_by_dev (ndev); + if (!ci) + return -EINVAL; + ret = mkret (c4_frame_rw (ci, &pp)); + if (ret) + return ret; + if (copy_to_user (data, &pp, sizeof (struct sbecom_port_param))) + return -EFAULT; + return 0; +} + +/* set the specified register with the given value / or just read it */ +STATIC status_t +do_pld_rw (struct net_device * ndev, void *data) +{ + struct sbecom_port_param pp; + ci_t *ci; + int ret; + + if (copy_from_user (&pp, data, sizeof (struct sbecom_port_param))) + return -EFAULT; + ci = get_ci_by_dev (ndev); + if (!ci) + return -EINVAL; + ret = mkret (c4_pld_rw (ci, &pp)); + if (ret) + return ret; + if (copy_to_user (data, &pp, sizeof (struct sbecom_port_param))) + return -EFAULT; + return 0; +} + +/* set the specified register with the given value / or just read it */ +STATIC status_t +do_musycc_rw (struct net_device * ndev, void *data) +{ + struct c4_musycc_param mp; + ci_t *ci; + int ret; + + if (copy_from_user (&mp, data, sizeof (struct c4_musycc_param))) + return -EFAULT; + ci = get_ci_by_dev (ndev); + if (!ci) + return -EINVAL; + ret = mkret (c4_musycc_rw (ci, &mp)); + if (ret) + return ret; + if (copy_to_user (data, &mp, sizeof (struct c4_musycc_param))) + return -EFAULT; + return 0; +} + +STATIC status_t +do_get_chan (struct net_device * ndev, void *data) +{ + struct sbecom_chan_param cp; + int ret; + + if (copy_from_user (&cp, data, + sizeof (struct sbecom_chan_param))) + return -EFAULT; + + if ((ret = mkret (c4_get_chan (cp.channum, &cp)))) + return ret; + + if (copy_to_user (data, &cp, sizeof (struct sbecom_chan_param))) + return -EFAULT; + return 0; +} + +STATIC status_t +do_set_chan (struct net_device * ndev, void *data) +{ + struct sbecom_chan_param cp; + int ret; + ci_t *ci; + + if (copy_from_user (&cp, data, sizeof (struct sbecom_chan_param))) + return -EFAULT; + ci = get_ci_by_dev (ndev); + if (!ci) + return -EINVAL; + switch (ret = mkret (c4_set_chan (cp.channum, &cp))) + { + case 0: + return 0; + default: + return ret; + } +} + +STATIC status_t +do_create_chan (struct net_device * ndev, void *data) +{ + ci_t *ci; + struct net_device *dev; + struct sbecom_chan_param cp; + int ret; + + if (copy_from_user (&cp, data, sizeof (struct sbecom_chan_param))) + return -EFAULT; + ci = get_ci_by_dev (ndev); + if (!ci) + return -EINVAL; + dev = create_chan (ndev, ci, &cp); + if (!dev) + return -EBUSY; + 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; +} + +STATIC status_t +do_get_chan_stats (struct net_device * ndev, void *data) +{ + struct c4_chan_stats_wrap ccs; + int ret; + + if (copy_from_user (&ccs, data, + sizeof (struct c4_chan_stats_wrap))) + return -EFAULT; + switch (ret = mkret (c4_get_chan_stats (ccs.channum, &ccs.stats))) + { + case 0: + break; + default: + return ret; + } + if (copy_to_user (data, &ccs, + sizeof (struct c4_chan_stats_wrap))) + return -EFAULT; + return 0; +} +STATIC status_t +do_set_loglevel (struct net_device * ndev, void *data) +{ + unsigned int log_level; + + if (copy_from_user (&log_level, data, sizeof (int))) + return -EFAULT; + sbecom_set_loglevel (log_level); + return 0; +} + +STATIC status_t +do_deluser (struct net_device * ndev, int lockit) +{ + if (ndev->flags & IFF_UP) + return -EBUSY; + + { + ci_t *ci; + mch_t *ch; + 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; + + ch = c4_find_chan (channum); + if (ch == NULL) + return -ENOENT; + 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; +} + +int +do_del_chan (struct net_device * musycc_dev, void *data) +{ + struct sbecom_chan_param cp; + char buf[sizeof (CHANNAME) + 3]; + struct net_device *dev; + int ret; + + if (copy_from_user (&cp, data, + sizeof (struct sbecom_chan_param))) + return -EFAULT; + sprintf (buf, CHANNAME "%d", cp.channum); + if (!(dev = dev_get_by_name (&init_net, buf))) + return -ENOENT; + dev_put (dev); + ret = do_deluser (dev, 1); + if (ret) + return ret; + return c4_del_chan (cp.channum); +} +int c4_reset_board (void *); + +int +do_reset (struct net_device * musycc_dev, void *data) +{ + const struct c4_priv *priv; + int i; + + for (i = 0; i < 128; i++) + { + struct net_device *ndev; + char buf[sizeof (CHANNAME) + 3]; + + sprintf (buf, CHANNAME "%d", i); + if (!(ndev = dev_get_by_name(&init_net, buf))) + continue; + priv = dev_to_hdlc (ndev)->priv; + + if ((unsigned long) (priv->ci) == + (unsigned long) (netdev_priv(musycc_dev))) + { + ndev->flags &= ~IFF_UP; + dev_put (ndev); + netif_stop_queue (ndev); + do_deluser (ndev, 1); + } else + dev_put (ndev); + } + return 0; +} + +int +do_reset_chan_stats (struct net_device * musycc_dev, void *data) +{ + struct sbecom_chan_param cp; + + if (copy_from_user (&cp, data, + sizeof (struct sbecom_chan_param))) + return -EFAULT; + return mkret (c4_del_chan_stats (cp.channum)); +} + +STATIC status_t +c4_ioctl (struct net_device * ndev, struct ifreq * ifr, int cmd) +{ + ci_t *ci; + void *data; + int iocmd, iolen; + status_t ret; + static struct data + { + union + { + u_int8_t c; + u_int32_t i; + struct sbe_brd_info bip; + struct sbe_drv_info dip; + struct sbe_iid_info iip; + struct sbe_brd_addr bap; + struct sbecom_chan_stats stats; + struct sbecom_chan_param param; + struct temux_card_stats cards; + struct sbecom_card_param cardp; + struct sbecom_framer_param frp; + } u; + } arg; + + + if (!capable (CAP_SYS_ADMIN)) + return -EPERM; + if (cmd != SIOCDEVPRIVATE + 15) + return -EINVAL; + if (!(ci = get_ci_by_dev (ndev))) + return -EINVAL; + if (ci->state != C_RUNNING) + return -ENODEV; + if (copy_from_user (&iocmd, ifr->ifr_data, sizeof (iocmd))) + return -EFAULT; +#if 0 + if (copy_from_user (&len, ifr->ifr_data + sizeof (iocmd), sizeof (len))) + return -EFAULT; +#endif + +#if 0 + printk ("c4_ioctl: iocmd %x, dir %x type %x nr %x iolen %d.\n", iocmd, + _IOC_DIR (iocmd), _IOC_TYPE (iocmd), _IOC_NR (iocmd), + _IOC_SIZE (iocmd)); +#endif + iolen = _IOC_SIZE (iocmd); + data = ifr->ifr_data + sizeof (iocmd); + if (copy_from_user (&arg, data, iolen)) + return -EFAULT; + + ret = 0; + switch (iocmd) + { + case SBE_IOC_PORT_GET: + //printk (">> SBE_IOC_PORT_GET Ioctl...\n"); + ret = do_get_port (ndev, data); + break; + case SBE_IOC_PORT_SET: + //printk (">> SBE_IOC_PORT_SET Ioctl...\n"); + ret = do_set_port (ndev, data); + break; + case SBE_IOC_CHAN_GET: + //printk (">> SBE_IOC_CHAN_GET Ioctl...\n"); + ret = do_get_chan (ndev, data); + break; + case SBE_IOC_CHAN_SET: + //printk (">> SBE_IOC_CHAN_SET Ioctl...\n"); + ret = do_set_chan (ndev, data); + break; + case C4_DEL_CHAN: + //printk (">> C4_DEL_CHAN Ioctl...\n"); + ret = do_del_chan (ndev, data); + break; + case SBE_IOC_CHAN_NEW: + ret = do_create_chan (ndev, data); + break; + case SBE_IOC_CHAN_GET_STAT: + ret = do_get_chan_stats (ndev, data); + break; + case SBE_IOC_LOGLEVEL: + ret = do_set_loglevel (ndev, data); + break; + case SBE_IOC_RESET_DEV: + ret = do_reset (ndev, data); + break; + case SBE_IOC_CHAN_DEL_STAT: + ret = do_reset_chan_stats (ndev, data); + break; + case C4_LOOP_PORT: + ret = do_port_loop (ndev, data); + break; + case C4_RW_FRMR: + ret = do_framer_rw (ndev, data); + break; + case C4_RW_MSYC: + ret = do_musycc_rw (ndev, data); + break; + case C4_RW_PLD: + ret = do_pld_rw (ndev, data); + break; + case SBE_IOC_IID_GET: + ret = (iolen == sizeof (struct sbe_iid_info)) ? c4_get_iidinfo (ci, &arg.u.iip) : -EFAULT; + if (ret == 0) /* no error, copy data */ + if (copy_to_user (data, &arg, iolen)) + return -EFAULT; + break; + default: + //printk (">> c4_ioctl: EINVAL - unknown iocmd <%x>\n", iocmd); + ret = -EINVAL; + break; + } + return mkret (ret); +} + +static const struct net_device_ops c4_ops = { + .ndo_open = void_open, + .ndo_start_xmit = c4_linux_xmit, + .ndo_do_ioctl = c4_ioctl, +}; + +static void c4_setup(struct net_device *dev) +{ + dev->type = ARPHRD_VOID; + dev->netdev_ops = &c4_ops; +} + +struct net_device *__init +c4_add_dev (hdw_info_t * hi, int brdno, unsigned long f0, unsigned long f1, + int irq0, int irq1) +{ + struct net_device *ndev; + ci_t *ci; + + ndev = alloc_netdev(sizeof(ci_t), SBE_IFACETMPL, c4_setup); + if (!ndev) + { + printk (KERN_WARNING "%s: no memory for struct net_device !\n", hi->devname); + error_flag = ENOMEM; + return 0; + } + ci = (ci_t *)(netdev_priv(ndev)); + ndev->irq = irq0; + + ci->hdw_info = hi; + ci->state = C_INIT; /* mark as hardware not available */ + ci->next = c4_list; + c4_list = ci; + ci->brdno = ci->next ? ci->next->brdno + 1 : 0; + + if (CI == 0) + CI = ci; /* DEBUG, only board 0 usage */ + + strcpy (ci->devname, hi->devname); + ci->release = &pmcc4_OSSI_release[0]; + + /* tasklet */ +#if defined(SBE_ISR_TASKLET) + tasklet_init (&ci->ci_musycc_isr_tasklet, + (void (*) (unsigned long)) musycc_intr_bh_tasklet, + (unsigned long) ci); + + if (atomic_read (&ci->ci_musycc_isr_tasklet.count) == 0) + tasklet_disable_nosync (&ci->ci_musycc_isr_tasklet); +#elif defined(SBE_ISR_IMMEDIATE) + ci->ci_musycc_isr_tq.routine = (void *) (unsigned long) musycc_intr_bh_tasklet; + ci->ci_musycc_isr_tq.data = ci; +#endif + + + if (register_netdev (ndev) || + (c4_init (ci, (u_char *) f0, (u_char *) f1) != SBE_DRVR_SUCCESS)) + { + OS_kfree (netdev_priv(ndev)); + OS_kfree (ndev); + error_flag = ENODEV; + return 0; + } + /************************************************************* + * int request_irq(unsigned int irq, + * void (*handler)(int, void *, struct pt_regs *), + * unsigned long flags, const char *dev_name, void *dev_id); + * wherein: + * irq -> The interrupt number that is being requested. + * handler -> Pointer to handling function being installed. + * flags -> A bit mask of options related to interrupt management. + * dev_name -> String used in /proc/interrupts to show owner of interrupt. + * dev_id -> Pointer (for shared interrupt lines) to point to its own + * private data area (to identify which device is interrupting). + * + * extern void free_irq(unsigned int irq, void *dev_id); + **************************************************************/ + + if (request_irq (irq0, &c4_linux_interrupt, +#if defined(SBE_ISR_TASKLET) + IRQF_DISABLED | IRQF_SHARED, +#elif defined(SBE_ISR_IMMEDIATE) + IRQF_DISABLED | IRQF_SHARED, +#elif defined(SBE_ISR_INLINE) + IRQF_SHARED, +#endif + ndev->name, ndev)) + { + printk (KERN_WARNING "%s: MUSYCC could not get irq: %d\n", + ndev->name, irq0); + unregister_netdev (ndev); + OS_kfree (netdev_priv(ndev)); + OS_kfree (ndev); + error_flag = EIO; + return 0; + } +#ifdef CONFIG_SBE_PMCC4_NCOMM + if (request_irq (irq1, &c4_ebus_interrupt, IRQF_SHARED, ndev->name, ndev)) + { + printk (KERN_WARNING "%s: EBUS could not get irq: %d\n", + hi->devname, irq1); + unregister_netdev (ndev); + free_irq (irq0, ndev); + OS_kfree (netdev_priv(ndev)); + OS_kfree (ndev); + error_flag = EIO; + return 0; + } +#endif + + /* setup board identification information */ + + { + u_int32_t tmp; + + hdw_sn_get (hi, brdno); /* also sets PROM format type (promfmt) + * for later usage */ + + switch (hi->promfmt) + { + case PROM_FORMAT_TYPE1: + memcpy (ndev->dev_addr, (FLD_TYPE1 *) (hi->mfg_info.pft1.Serial), 6); + memcpy (&tmp, (FLD_TYPE1 *) (hi->mfg_info.pft1.Id), 4); /* unaligned data + * acquisition */ + ci->brd_id = cpu_to_be32 (tmp); + break; + case PROM_FORMAT_TYPE2: + memcpy (ndev->dev_addr, (FLD_TYPE2 *) (hi->mfg_info.pft2.Serial), 6); + memcpy (&tmp, (FLD_TYPE2 *) (hi->mfg_info.pft2.Id), 4); /* unaligned data + * acquisition */ + ci->brd_id = cpu_to_be32 (tmp); + break; + default: + ci->brd_id = 0; + memset (ndev->dev_addr, 0, 6); + break; + } + +#if 1 + sbeid_set_hdwbid (ci); /* requires bid to be preset */ +#else + sbeid_set_bdtype (ci); /* requires hdw_bid to be preset */ +#endif + + } + +#ifdef CONFIG_PROC_FS + sbecom_proc_brd_init (ci); +#endif +#if defined(SBE_ISR_TASKLET) + tasklet_enable (&ci->ci_musycc_isr_tasklet); +#endif + + + if ((error_flag = c4_init2 (ci)) != SBE_DRVR_SUCCESS) + { +#ifdef CONFIG_PROC_FS + sbecom_proc_brd_cleanup (ci); +#endif + unregister_netdev (ndev); + free_irq (irq1, ndev); + free_irq (irq0, ndev); + OS_kfree (netdev_priv(ndev)); + OS_kfree (ndev); + return 0; /* failure, error_flag is set */ + } + return ndev; +} + +STATIC int __init +c4_mod_init (void) +{ + int rtn; + + printk (KERN_WARNING "%s: %s\n", THIS_MODULE->name, pmcc4_OSSI_release); + if ((rtn = c4hw_attach_all ())) + return -rtn; /* installation failure - see system log */ + + /* housekeeping notifications */ + if (log_level != log_level_default) + printk (KERN_INFO "%s NOTE: driver parameter <log_level> changed from default %d to %d.\n", + THIS_MODULE->name, log_level_default, log_level); + if (max_mru != max_mru_default) + printk (KERN_INFO "%s NOTE: driver parameter <max_mru> changed from default %d to %d.\n", + THIS_MODULE->name, max_mru_default, max_mru); + if (max_mtu != max_mtu_default) + printk (KERN_INFO "%s NOTE: driver parameter <max_mtu> changed from default %d to %d.\n", + THIS_MODULE->name, max_mtu_default, max_mtu); + if (max_rxdesc_used != max_rxdesc_default) + { + if (max_rxdesc_used > 2000) + max_rxdesc_used = 2000; /* out-of-bounds reset */ + printk (KERN_INFO "%s NOTE: driver parameter <max_rxdesc_used> changed from default %d to %d.\n", + THIS_MODULE->name, max_rxdesc_default, max_rxdesc_used); + } + if (max_txdesc_used != max_txdesc_default) + { + if (max_txdesc_used > 1000) + max_txdesc_used = 1000; /* out-of-bounds reset */ + printk (KERN_INFO "%s NOTE: driver parameter <max_txdesc_used> changed from default %d to %d.\n", + THIS_MODULE->name, max_txdesc_default, max_txdesc_used); + } + return 0; /* installation success */ +} + + + /* + * find any still allocated hdlc registrations and unregister via call to + * do_deluser() + */ + +STATIC void __exit +cleanup_hdlc (void) +{ + hdw_info_t *hi; + ci_t *ci; + struct net_device *ndev; + int i, j, k; + + for (i = 0, hi = hdw_info; i < MAX_BOARDS; i++, hi++) + { + if (hi->ndev) /* a board has been attached */ + { + ci = (ci_t *)(netdev_priv(hi->ndev)); + for (j = 0; j < ci->max_port; j++) + for (k = 0; k < MUSYCC_NCHANS; k++) + if ((ndev = ci->port[j].chan[k]->user)) + { + do_deluser (ndev, 0); + } + } + } +} + + +STATIC void __exit +c4_mod_remove (void) +{ + cleanup_hdlc (); /* delete any missed channels */ + cleanup_devs (); + c4_cleanup (); + cleanup_ioremap (); + printk (KERN_INFO "SBE %s - driver removed.\n", THIS_MODULE->name); +} + +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 <support@sbei.com>"); +MODULE_DESCRIPTION ("wanPCI-CxT1E1 Generic HDLC WAN Driver module"); +#ifdef MODULE_LICENSE +MODULE_LICENSE ("GPL"); +#endif + +/*** End-of-File ***/ diff --git a/drivers/staging/cxt1e1/musycc.c b/drivers/staging/cxt1e1/musycc.c new file mode 100644 index 000000000000..650c9c02f223 --- /dev/null +++ b/drivers/staging/cxt1e1/musycc.c @@ -0,0 +1,2180 @@ +/* + * $Id: musycc.c,v 2.1 2007/08/15 23:32:17 rickd PMCC4_3_1B $ + */ + +unsigned int max_intcnt = 0; +unsigned int max_bh = 0; + +/*----------------------------------------------------------------------------- + * musycc.c - + * + * Copyright (C) 2007 One Stop Systems, Inc. + * Copyright (C) 2003-2006 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + * + * For further information, contact via email: support@onestopsystems.com + * One Stop Systems, Inc. Escondido, California U.S.A. + *----------------------------------------------------------------------------- + * RCS info: + * RCS revision: $Revision: 2.1 $ + * Last changed on $Date: 2007/08/15 23:32:17 $ + * Changed by $Author: rickd $ + *----------------------------------------------------------------------------- + * $Log: musycc.c,v $ + * Revision 2.1 2007/08/15 23:32:17 rickd + * Use 'if 0' instead of GNU comment delimeter to avoid line wrap induced compiler errors. + * + * Revision 2.0 2007/08/15 22:13:20 rickd + * Update to printf pointer %p usage and correct some UINT to ULONG for + * 64bit comptibility. + * + * Revision 1.7 2006/04/21 00:56:40 rickd + * workqueue files now prefixed with <sbecom> prefix. + * + * Revision 1.6 2005/10/27 18:54:19 rickd + * Clean out old code. Default to HDLC_FCS16, not TRANS. + * + * Revision 1.5 2005/10/17 23:55:28 rickd + * Initial port of NCOMM support patches from original work found + * in pmc_c4t1e1 as updated by NCOMM. Ref: CONFIG_SBE_PMCC4_NCOMM. + * + * Revision 1.4 2005/10/13 20:35:25 rickd + * Cleanup warning for unused <flags> variable. + * + * Revision 1.3 2005/10/13 19:19:22 rickd + * Disable redundant driver removal cleanup code. + * + * Revision 1.2 2005/10/11 18:36:16 rickd + * Clean up warning messages caused by de-implemented some <flags> associated + * with spin_lock() removals. + * + * Revision 1.1 2005/10/05 00:45:28 rickd + * Re-enable xmit on flow-controlled and full channel to fix restart hang. + * Add some temp spin-lock debug code (rld_spin_owner). + * + * Revision 1.0 2005/09/28 00:10:06 rickd + * Initial release for C4T1E1 support. Lots of transparent + * mode updates. + * + *----------------------------------------------------------------------------- + */ + +char SBEid_pmcc4_musyccc[] = +"@(#)musycc.c - $Revision: 2.1 $ (c) Copyright 2004-2006 SBE, Inc."; + + +#include <linux/types.h> +#include "pmcc4_sysdep.h" +#include <linux/kernel.h> +#include <linux/errno.h> +#include <linux/init.h> +#include "sbecom_inline_linux.h" +#include "libsbew.h" +#include "pmcc4_private.h" +#include "pmcc4.h" +#include "musycc.h" + +#ifdef SBE_INCLUDE_SYMBOLS +#define STATIC +#else +#define STATIC static +#endif + +#define sd_find_chan(ci,ch) c4_find_chan(ch) + + +/*******************************************************************/ +/* global driver variables */ +extern ci_t *c4_list; +extern int drvr_state; +extern int log_level; + +extern int max_mru; +extern int max_mtu; +extern int max_rxdesc_used; +extern int max_txdesc_used; +extern ci_t *CI; /* dummy pointr to board ZEROE's data - DEBUG + * USAGE */ + + +/*******************************************************************/ +/* forward references */ +void c4_fifo_free (mpi_t *, int); +void c4_wk_chan_restart (mch_t *); +void musycc_bh_tx_eom (mpi_t *, int); +int musycc_chan_up (ci_t *, int); +status_t __init musycc_init (ci_t *); +STATIC void __init musycc_init_port (mpi_t *); +void musycc_intr_bh_tasklet (ci_t *); +void musycc_serv_req (mpi_t *, u_int32_t); +void musycc_update_timeslots (mpi_t *); + +/*******************************************************************/ + +#if 1 +STATIC int +musycc_dump_rxbuffer_ring (mch_t * ch, int lockit) +{ + struct mdesc *m; + unsigned long flags = 0; + + u_int32_t status; + int n; + + if (lockit) + { + spin_lock_irqsave (&ch->ch_rxlock, flags); + } + if (ch->rxd_num == 0) + { + printk (" ZERO receive buffers allocated for this channel."); + } else + { + FLUSH_MEM_READ (); + m = &ch->mdr[ch->rxix_irq_srv]; + for (n = ch->rxd_num; n; n--) + { + status = le32_to_cpu (m->status); + { + printk ("%c %08lx[%2d]: sts %08x (%c%c%c%c:%d.) Data [%08x] Next [%08x]\n", + (m == &ch->mdr[ch->rxix_irq_srv]) ? 'F' : ' ', + (unsigned long) m, n, + status, + m->data ? (status & HOST_RX_OWNED ? 'H' : 'M') : '-', + status & POLL_DISABLED ? 'P' : '-', + status & EOBIRQ_ENABLE ? 'b' : '-', + status & EOMIRQ_ENABLE ? 'm' : '-', + status & LENGTH_MASK, + le32_to_cpu (m->data), le32_to_cpu (m->next)); +#ifdef RLD_DUMP_BUFDATA + { + u_int32_t *dp; + int len = status & LENGTH_MASK; + +#if 1 + if (m->data && (status & HOST_RX_OWNED)) +#else + if (m->data) /* always dump regardless of valid RX + * data */ +#endif + { + dp = (u_int32_t *) OS_phystov ((void *) (le32_to_cpu (m->data))); + if (len >= 0x10) + printk (" %x[%x]: %08X %08X %08X %08x\n", (u_int32_t) dp, len, + *dp, *(dp + 1), *(dp + 2), *(dp + 3)); + else if (len >= 0x08) + printk (" %x[%x]: %08X %08X\n", (u_int32_t) dp, len, + *dp, *(dp + 1)); + else + printk (" %x[%x]: %08X\n", (u_int32_t) dp, len, *dp); + } + } +#endif + } + m = m->snext; + } + } /* -for- */ + printk ("\n"); + + if (lockit) + { + spin_unlock_irqrestore (&ch->ch_rxlock, flags); + } + return 0; +} +#endif + +#if 1 +STATIC int +musycc_dump_txbuffer_ring (mch_t * ch, int lockit) +{ + struct mdesc *m; + unsigned long flags = 0; + u_int32_t status; + int n; + + if (lockit) + { + spin_lock_irqsave (&ch->ch_txlock, flags); + } + if (ch->txd_num == 0) + { + printk (" ZERO transmit buffers allocated for this channel."); + } else + { + FLUSH_MEM_READ (); + m = ch->txd_irq_srv; + for (n = ch->txd_num; n; n--) + { + status = le32_to_cpu (m->status); + { + printk ("%c%c %08lx[%2d]: sts %08x (%c%c%c%c:%d.) Data [%08x] Next [%08x]\n", + (m == ch->txd_usr_add) ? 'F' : ' ', + (m == ch->txd_irq_srv) ? 'L' : ' ', + (unsigned long) m, n, + status, + m->data ? (status & MUSYCC_TX_OWNED ? 'M' : 'H') : '-', + status & POLL_DISABLED ? 'P' : '-', + status & EOBIRQ_ENABLE ? 'b' : '-', + status & EOMIRQ_ENABLE ? 'm' : '-', + status & LENGTH_MASK, + le32_to_cpu (m->data), le32_to_cpu (m->next)); +#ifdef RLD_DUMP_BUFDATA + { + u_int32_t *dp; + int len = status & LENGTH_MASK; + + if (m->data) + { + dp = (u_int32_t *) OS_phystov ((void *) (le32_to_cpu (m->data))); + if (len >= 0x10) + printk (" %x[%x]: %08X %08X %08X %08x\n", (u_int32_t) dp, len, + *dp, *(dp + 1), *(dp + 2), *(dp + 3)); + else if (len >= 0x08) + printk (" %x[%x]: %08X %08X\n", (u_int32_t) dp, len, + *dp, *(dp + 1)); + else + printk (" %x[%x]: %08X\n", (u_int32_t) dp, len, *dp); + } + } +#endif + } + m = m->snext; + } + } /* -for- */ + printk ("\n"); + + if (lockit) + { + spin_unlock_irqrestore (&ch->ch_txlock, flags); + } + return 0; +} +#endif + + +/* + * The following supports a backdoor debug facility which can be used to + * display the state of a board's channel. + */ + +status_t +musycc_dump_ring (ci_t * ci, unsigned int chan) +{ + mch_t *ch; + + if (chan >= MAX_CHANS_USED) + { + return SBE_DRVR_FAIL; /* E2BIG */ + } + { + int bh; + + bh = atomic_read (&ci->bh_pending); + printk (">> bh_pend %d [%d] ihead %d itail %d [%d] th_cnt %d bh_cnt %d wdcnt %d note %d\n", + bh, max_bh, ci->iqp_headx, ci->iqp_tailx, max_intcnt, + ci->intlog.drvr_intr_thcount, + ci->intlog.drvr_intr_bhcount, + ci->wdcount, ci->wd_notify); + max_bh = 0; /* reset counter */ + max_intcnt = 0; /* reset counter */ + } + + if (!(ch = sd_find_chan (dummy, chan))) + { + printk (">> musycc_dump_ring: channel %d not up.\n", chan); + return ENOENT; + } + printk (">> CI %p CHANNEL %3d @ %p: state %x status/p %x/%x\n", ci, chan, ch, ch->state, + ch->status, ch->p.status); + printk ("--------------------------------\nTX Buffer Ring - Channel %d, txd_num %d. (bd/ch pend %d %d), TXD required %d, txpkt %lu\n", + chan, ch->txd_num, + (u_int32_t) atomic_read (&ci->tx_pending), (u_int32_t) atomic_read (&ch->tx_pending), ch->txd_required, ch->s.tx_packets); + printk ("++ User 0x%p IRQ_SRV 0x%p USR_ADD 0x%p QStopped %x, start_tx %x tx_full %d txd_free %d mode %x\n", + ch->user, ch->txd_irq_srv, ch->txd_usr_add, + sd_queue_stopped (ch->user), + ch->ch_start_tx, ch->tx_full, ch->txd_free, ch->p.chan_mode); + musycc_dump_txbuffer_ring (ch, 1); + printk ("RX Buffer Ring - Channel %d, rxd_num %d. IRQ_SRV[%d] 0x%p, start_rx %x rxpkt %lu\n", + chan, ch->rxd_num, ch->rxix_irq_srv, + &ch->mdr[ch->rxix_irq_srv], ch->ch_start_rx, ch->s.rx_packets); + musycc_dump_rxbuffer_ring (ch, 1); + + return SBE_DRVR_SUCCESS; +} + + +status_t +musycc_dump_rings (ci_t * ci, unsigned int start_chan) +{ + unsigned int chan; + + for (chan = start_chan; chan < (start_chan + 5); chan++) + musycc_dump_ring (ci, chan); + return SBE_DRVR_SUCCESS; +} + + +/* + * NOTE on musycc_init_mdt(): These MUSYCC writes are only operational after + * a MUSYCC GROUP_INIT command has been issued. + */ + +void +musycc_init_mdt (mpi_t * pi) +{ + u_int32_t *addr, cfg; + int i; + + /* + * This Idle Code insertion takes effect prior to channel's first + * transmitted message. After that, each message contains its own Idle + * Code information which is to be issued after the message is + * transmitted (Ref.MUSYCC 5.2.2.3: MCENBL bit in Group Configuration + * Descriptor). + */ + + addr = (u_int32_t *) ((u_long) pi->reg + MUSYCC_MDT_BASE03_ADDR); + cfg = CFG_CH_FLAG_7E << IDLE_CODE; + + for (i = 0; i < 32; addr++, i++) + { + pci_write_32 (addr, cfg); + } +} + + +/* Set TX thp to the next unprocessed md */ + +void +musycc_update_tx_thp (mch_t * ch) +{ + struct mdesc *md; + unsigned long flags; + + spin_lock_irqsave (&ch->ch_txlock, flags); + while (1) + { + md = ch->txd_irq_srv; + FLUSH_MEM_READ (); + if (!md->data) + { + /* No MDs with buffers to process */ + spin_unlock_irqrestore (&ch->ch_txlock, flags); + return; + } + if ((le32_to_cpu (md->status)) & MUSYCC_TX_OWNED) + { + /* this is the MD to restart TX with */ + break; + } + /* + * Otherwise, we have a valid, host-owned message descriptor which + * has been successfully transmitted and whose buffer can be freed, + * so... process this MD, it's owned by the host. (This might give + * as a new, updated txd_irq_srv.) + */ + musycc_bh_tx_eom (ch->up, ch->gchan); + } + md = ch->txd_irq_srv; + ch->up->regram->thp[ch->gchan] = cpu_to_le32 (OS_vtophys (md)); + FLUSH_MEM_WRITE (); + + if (ch->tx_full) + { + ch->tx_full = 0; + ch->txd_required = 0; + sd_enable_xmit (ch->user); /* re-enable to catch flow controlled + * channel */ + } + spin_unlock_irqrestore (&ch->ch_txlock, flags); + +#ifdef RLD_TRANS_DEBUG + printk ("++ musycc_update_tx_thp[%d]: setting thp = %p, sts %x\n", ch->channum, md, md->status); +#endif +} + + +#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 + * upon the channel's ch_start_tx and ch_start_rx variables. This routine + * is implemented as a work queue so that the call to the service request is + * able to sleep, awaiting an interrupt acknowledgment response (SACK) from + * the hardware. + */ + +void +musycc_wq_chan_restart (void *arg) /* channel private structure */ +{ + mch_t *ch; + mpi_t *pi; + struct mdesc *md; +#if 0 + unsigned long flags; +#endif + + ch = container_of(arg, struct c4_chan_info, ch_work); + pi = ch->up; + +#ifdef RLD_TRANS_DEBUG + printk ("wq_chan_restart[%d]: start_RT[%d/%d] status %x\n", + ch->channum, ch->ch_start_rx, ch->ch_start_tx, ch->status); + +#endif + + /**********************************/ + /** check for RX restart request **/ + /**********************************/ + + if ((ch->ch_start_rx) && (ch->status & RX_ENABLED)) + { + + ch->ch_start_rx = 0; +#if defined(RLD_TRANS_DEBUG) || defined(RLD_RXACT_DEBUG) + { + static int hereb4 = 7; + + if (hereb4) /* RLD DEBUG */ + { + hereb4--; +#ifdef RLD_TRANS_DEBUG + md = &ch->mdr[ch->rxix_irq_srv]; + printk ("++ musycc_wq_chan_restart[%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); +#elif defined(RLD_RXACT_DEBUG) + md = &ch->mdr[ch->rxix_irq_srv]; + printk ("++ musycc_wq_chan_restart[%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 + } + } +#endif + musycc_serv_req (pi, SR_CHANNEL_ACTIVATE | SR_RX_DIRECTION | ch->gchan); + } + /**********************************/ + /** check for TX restart request **/ + /**********************************/ + + if ((ch->ch_start_tx) && (ch->status & TX_ENABLED)) + { + /* 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) + { +#ifdef RLD_TRANS_DEBUG + printk ("-- musycc_wq_chan_restart[%d]: WARNING, starting NULL md\n", ch->channum); +#endif +#if 0 + spin_unlock_irqrestore (&ch->ch_txlock, flags); +#endif + } else if (md->data && ((le32_to_cpu (md->status)) & MUSYCC_TX_OWNED)) + { + ch->ch_start_tx = 0; +#if 0 + spin_unlock_irqrestore (&ch->ch_txlock, flags); /* allow interrupts for service request */ +#endif +#ifdef RLD_TRANS_DEBUG + printk ("++ musycc_wq_chan_restart() CHAN TX ACTIVATE: chan %d txd_irq_srv %p = sts %x, txpkt %lu\n", + ch->channum, ch->txd_irq_srv, ch->txd_irq_srv->status, ch->s.tx_packets); +#endif + musycc_serv_req (pi, SR_CHANNEL_ACTIVATE | SR_TX_DIRECTION | ch->gchan); + } +#ifdef RLD_RESTART_DEBUG + else + { + /* retain request to start until retried and we have data to xmit */ + printk ("-- musycc_wq_chan_restart[%d]: DELAYED due to md %p sts %x data %x, start_tx %x\n", + ch->channum, md, + le32_to_cpu (md->status), + le32_to_cpu (md->data), ch->ch_start_tx); + musycc_dump_txbuffer_ring (ch, 0); +#if 0 + spin_unlock_irqrestore (&ch->ch_txlock, flags); /* allow interrupts for service request */ +#endif + } +#endif + } +} +#endif + + + /* + * Channel restart either fires of a workqueue request (2.6) or lodges a + * watchdog activation sequence (2.4). + */ + +void +musycc_chan_restart (mch_t * ch) +{ +#ifdef RLD_RESTART_DEBUG + printk ("++ musycc_chan_restart[%d]: txd_irq_srv @ %p = sts %x\n", + 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 + printk (">> musycc_chan_restart: scheduling Chan %x workQ @ %p\n", ch->channum, &ch->ch_work); +#endif + 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 + printk (">> 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) +{ + static u_int32_t led = 0; + + if (ledval == 0) + led = 0; + else + led |= ledval; + + pci_write_32 ((u_int32_t *) &pi->up->cpldbase->leds, led); /* RLD DEBUG TRANHANG */ +} + + +#define MUSYCC_SR_RETRY_CNT 9 + +void +musycc_serv_req (mpi_t * pi, u_int32_t req) +{ + volatile u_int32_t r; + int rcnt; + + /* + * PORT NOTE: Semaphore protect service loop guarantees only a single + * operation at a time. Per MUSYCC Manual - "Issuing service requests to + * the same channel group without first receiving ACK from each request + * may cause the host to lose track of which service request has been + * acknowledged." + */ + + SD_SEM_TAKE (&pi->sr_sem_busy, "serv"); /* only 1 thru here, per + * group */ + + if (pi->sr_last == req) + { +#ifdef RLD_TRANS_DEBUG + printk (">> same SR, Port %d Req %x\n", pi->portnum, req); +#endif + + /* + * The most likely repeated request is the channel activation command + * which follows the occurrence of a Transparent mode TX ONR or a + * BUFF error. If the previous command was a CHANNEL ACTIVATE, + * precede it with a NOOP command in order maintain coherent control + * of this current (re)ACTIVATE. + */ + + r = (pi->sr_last & ~SR_GCHANNEL_MASK); + if ((r == (SR_CHANNEL_ACTIVATE | SR_TX_DIRECTION)) || + (r == (SR_CHANNEL_ACTIVATE | SR_RX_DIRECTION))) + { +#ifdef RLD_TRANS_DEBUG + printk (">> same CHAN ACT SR, Port %d Req %x => issue SR_NOOP CMD\n", pi->portnum, req); +#endif + SD_SEM_GIVE (&pi->sr_sem_busy); /* allow this next request */ + musycc_serv_req (pi, SR_NOOP); + SD_SEM_TAKE (&pi->sr_sem_busy, "serv"); /* relock & continue w/ + * original req */ + } else if (req == SR_NOOP) + { + /* no need to issue back-to-back SR_NOOP commands at this time */ +#ifdef RLD_TRANS_DEBUG + printk (">> same Port SR_NOOP skipped, Port %d\n", pi->portnum); +#endif + SD_SEM_GIVE (&pi->sr_sem_busy); /* allow this next request */ + return; + } + } + rcnt = 0; + pi->sr_last = req; +rewrite: + pci_write_32 ((u_int32_t *) &pi->reg->srd, req); + FLUSH_MEM_WRITE (); + + /* + * Per MUSYCC Manual, Section 6.1,2 - "When writing an SCR service + * request, the host must ensure at least one PCI bus clock cycle has + * elapsed before writing another service request. To meet this minimum + * elapsed service request write timing interval, it is recommended that + * the host follow any SCR write with another operation which reads from + * the same address." + */ + r = pci_read_32 ((u_int32_t *) &pi->reg->srd); /* adhere to write + * timing imposition */ + + + if ((r != req) && (req != SR_CHIP_RESET) && (++rcnt <= MUSYCC_SR_RETRY_CNT)) + { + if (log_level >= LOG_MONITOR) + printk ("%s: %d - reissue srv req/last %x/%x (hdw reads %x), Chan %d.\n", + pi->up->devname, rcnt, req, pi->sr_last, r, + (pi->portnum * MUSYCC_NCHANS) + (req & 0x1f)); + OS_uwait_dummy (); /* this delay helps reduce reissue counts + * (reason not yet researched) */ + goto rewrite; + } + if (rcnt > MUSYCC_SR_RETRY_CNT) + { + printk (KERN_WARNING "%s: failed service request (#%d)= %x, group %d.\n", + pi->up->devname, MUSYCC_SR_RETRY_CNT, req, pi->portnum); + SD_SEM_GIVE (&pi->sr_sem_busy); /* allow any next request */ + return; + } + if (req == SR_CHIP_RESET) + { + /* + * PORT NOTE: the CHIP_RESET command is NOT ack'd by the MUSYCC, thus + * the upcoming delay is used. Though the MUSYCC documentation + * suggests a read-after-write would supply the required delay, it's + * unclear what CPU/BUS clock speeds might have been assumed when + * suggesting this 'lack of ACK' workaround. Thus the use of uwait. + */ + OS_uwait (100000, "icard"); /* 100ms */ + } else + { + FLUSH_MEM_READ (); + SD_SEM_TAKE (&pi->sr_sem_wait, "sakack"); /* sleep until SACK + * interrupt occurs */ + } + SD_SEM_GIVE (&pi->sr_sem_busy); /* allow any next request */ +} + + +#ifdef SBE_PMCC4_ENABLE +void +musycc_update_timeslots (mpi_t * pi) +{ + int i, ch; + char e1mode = IS_FRAME_ANY_E1 (pi->p.port_mode); + + for (i = 0; i < 32; i++) + { + int usedby = 0, last = 0, ts, j, bits[8]; + + u_int8_t lastval = 0; + + if (((i == 0) && e1mode) || /* disable if E1 mode */ + ((i == 16) && ((pi->p.port_mode == CFG_FRAME_E1CRC_CAS) || (pi->p.port_mode == CFG_FRAME_E1CRC_CAS_AMI))) + || ((i > 23) && (!e1mode))) /* disable if T1 mode */ + { + pi->tsm[i] = 0xff; /* make tslot unavailable for this mode */ + } else + { + pi->tsm[i] = 0x00; /* make tslot available for assignment */ + } + for (j = 0; j < 8; j++) + bits[j] = -1; + for (ch = 0; ch < MUSYCC_NCHANS; ch++) + { + if ((pi->chan[ch]->state == UP) && (pi->chan[ch]->p.bitmask[i])) + { + usedby++; + last = ch; + lastval = pi->chan[ch]->p.bitmask[i]; + for (j = 0; j < 8; j++) + if (lastval & (1 << j)) + bits[j] = ch; + pi->tsm[i] |= lastval; + } + } + if (!usedby) + ts = 0; + else if ((usedby == 1) && (lastval == 0xff)) + ts = (4 << 5) | last; + else if ((usedby == 1) && (lastval == 0x7f)) + ts = (5 << 5) | last; + else + { + int idx; + + if (bits[0] < 0) + ts = (6 << 5) | (idx = last); + else + ts = (7 << 5) | (idx = bits[0]); + for (j = 1; j < 8; j++) + { + pi->regram->rscm[idx * 8 + j] = (bits[j] < 0) ? 0 : (0x80 | bits[j]); + pi->regram->tscm[idx * 8 + j] = (bits[j] < 0) ? 0 : (0x80 | bits[j]); + } + } + pi->regram->rtsm[i] = ts; + pi->regram->ttsm[i] = ts; + } + FLUSH_MEM_WRITE (); + + musycc_serv_req (pi, SR_TIMESLOT_MAP | SR_RX_DIRECTION); + musycc_serv_req (pi, SR_TIMESLOT_MAP | SR_TX_DIRECTION); + musycc_serv_req (pi, SR_SUBCHANNEL_MAP | SR_RX_DIRECTION); + musycc_serv_req (pi, SR_SUBCHANNEL_MAP | SR_TX_DIRECTION); +} +#endif + + +#ifdef SBE_WAN256T3_ENABLE +void +musycc_update_timeslots (mpi_t * pi) +{ + mch_t *ch; + + u_int8_t ts, hmask, tsen; + int gchan; + int i; + +#ifdef SBE_PMCC4_ENABLE + hmask = (0x1f << pi->up->p.hypersize) & 0x1f; +#endif +#ifdef SBE_WAN256T3_ENABLE + hmask = (0x1f << hyperdummy) & 0x1f; +#endif + for (i = 0; i < 128; i++) + { + gchan = ((pi->portnum * MUSYCC_NCHANS) + (i & hmask)) % MUSYCC_NCHANS; + ch = pi->chan[gchan]; + if (ch->p.mode_56k) + tsen = MODE_56KBPS; + else + tsen = MODE_64KBPS; /* also the default */ + ts = ((pi->portnum % 4) == (i / 32)) ? (tsen << 5) | (i & hmask) : 0; + pi->regram->rtsm[i] = ts; + pi->regram->ttsm[i] = ts; + } + FLUSH_MEM_WRITE (); + musycc_serv_req (pi, SR_TIMESLOT_MAP | SR_RX_DIRECTION); + musycc_serv_req (pi, SR_TIMESLOT_MAP | SR_TX_DIRECTION); +} +#endif + + + /* + * This routine converts a generic library channel configuration parameter + * into a hardware specific register value (IE. MUSYCC CCD Register). + */ +u_int32_t +musycc_chan_proto (int proto) +{ + int reg; + + switch (proto) + { + case CFG_CH_PROTO_TRANS: /* 0 */ + reg = MUSYCC_CCD_TRANS; + break; + case CFG_CH_PROTO_SS7: /* 1 */ + reg = MUSYCC_CCD_SS7; + break; + default: + case CFG_CH_PROTO_ISLP_MODE: /* 4 */ + case CFG_CH_PROTO_HDLC_FCS16: /* 2 */ + reg = MUSYCC_CCD_HDLC_FCS16; + break; + case CFG_CH_PROTO_HDLC_FCS32: /* 3 */ + reg = MUSYCC_CCD_HDLC_FCS32; + break; + } + + return reg; +} + +#ifdef SBE_WAN256T3_ENABLE +STATIC void __init +musycc_init_port (mpi_t * pi) +{ + pci_write_32 ((u_int32_t *) &pi->reg->gbp, OS_vtophys (pi->regram)); + + pi->regram->grcd = + __constant_cpu_to_le32 (MUSYCC_GRCD_RX_ENABLE | + MUSYCC_GRCD_TX_ENABLE | + MUSYCC_GRCD_SF_ALIGN | + MUSYCC_GRCD_SUBCHAN_DISABLE | + MUSYCC_GRCD_OOFMP_DISABLE | + MUSYCC_GRCD_COFAIRQ_DISABLE | + MUSYCC_GRCD_MC_ENABLE | + (MUSYCC_GRCD_POLLTH_32 << MUSYCC_GRCD_POLLTH_SHIFT)); + + pi->regram->pcd = + __constant_cpu_to_le32 (MUSYCC_PCD_E1X4_MODE | + MUSYCC_PCD_TXDATA_RISING | + MUSYCC_PCD_TX_DRIVEN); + + /* Message length descriptor */ + pi->regram->mld = __constant_cpu_to_le32 (max_mru | (max_mru << 16)); + FLUSH_MEM_WRITE (); + + musycc_serv_req (pi, SR_GROUP_INIT | SR_RX_DIRECTION); + musycc_serv_req (pi, SR_GROUP_INIT | SR_TX_DIRECTION); + + musycc_init_mdt (pi); + + musycc_update_timeslots (pi); +} +#endif + + +status_t __init +musycc_init (ci_t * ci) +{ + char *regaddr; /* temp for address boundary calculations */ + int i, gchan; + + OS_sem_init (&ci->sem_wdbusy, SEM_AVAILABLE); /* watchdog exclusion */ + + /* + * Per MUSYCC manual, Section 6.3.4 - "The host must allocate a dword + * aligned memory segment for interrupt queue pointers." + */ + +#define INT_QUEUE_BOUNDARY 4 + + regaddr = OS_kmalloc ((INT_QUEUE_SIZE + 1) * sizeof (u_int32_t)); + if (regaddr == 0) + return ENOMEM; + ci->iqd_p_saved = regaddr; /* save orig value for free's usage */ + ci->iqd_p = (u_int32_t *) ((unsigned long) (regaddr + INT_QUEUE_BOUNDARY - 1) & + (~(INT_QUEUE_BOUNDARY - 1))); /* this calculates + * closest boundary */ + + for (i = 0; i < INT_QUEUE_SIZE; i++) + { + ci->iqd_p[i] = __constant_cpu_to_le32 (INT_EMPTY_ENTRY); + } + + for (i = 0; i < ci->max_port; i++) + { + mpi_t *pi = &ci->port[i]; + + /* + * Per MUSYCC manual, Section 6.3.2 - "The host must allocate a 2KB + * bound memory segment for Channel Group 0." + */ + +#define GROUP_BOUNDARY 0x800 + + regaddr = OS_kmalloc (sizeof (struct musycc_groupr) + GROUP_BOUNDARY); + if (regaddr == 0) + { + for (gchan = 0; gchan < i; gchan++) + { + pi = &ci->port[gchan]; + OS_kfree (pi->reg); + pi->reg = 0; + } + return ENOMEM; + } + pi->regram_saved = regaddr; /* save orig value for free's usage */ + pi->regram = (struct musycc_groupr *) ((unsigned long) (regaddr + GROUP_BOUNDARY - 1) & + (~(GROUP_BOUNDARY - 1))); /* this calculates + * closest boundary */ + } + + /* any board centric MUSYCC commands will use group ZERO as its "home" */ + ci->regram = ci->port[0].regram; + musycc_serv_req (&ci->port[0], SR_CHIP_RESET); + + pci_write_32 ((u_int32_t *) &ci->reg->gbp, OS_vtophys (ci->regram)); + pci_flush_write (ci); +#ifdef CONFIG_SBE_PMCC4_NCOMM + ci->regram->__glcd = __constant_cpu_to_le32 (GCD_MAGIC); +#else + /* standard driver POLLS for INTB via CPLD register */ + ci->regram->__glcd = __constant_cpu_to_le32 (GCD_MAGIC | MUSYCC_GCD_INTB_DISABLE); +#endif + + ci->regram->__iqp = cpu_to_le32 (OS_vtophys (&ci->iqd_p[0])); + ci->regram->__iql = __constant_cpu_to_le32 (INT_QUEUE_SIZE - 1); + pci_write_32 ((u_int32_t *) &ci->reg->dacbp, 0); + FLUSH_MEM_WRITE (); + + ci->state = C_RUNNING; /* mark as full interrupt processing + * available */ + + musycc_serv_req (&ci->port[0], SR_GLOBAL_INIT); /* FIRST INTERRUPT ! */ + + /* sanity check settable parameters */ + + if (max_mru > 0xffe) + { + printk (KERN_WARNING "%s: Maximum allowed MRU exceeded, resetting %d to %d.\n", + THIS_MODULE->name, max_mru, 0xffe); + max_mru = 0xffe; + } + if (max_mtu > 0xffe) + { + printk (KERN_WARNING "%s: Maximum allowed MTU exceeded, resetting %d to %d.\n", + THIS_MODULE->name, max_mtu, 0xffe); + max_mtu = 0xffe; + } +#ifdef SBE_WAN256T3_ENABLE + for (i = 0; i < MUSYCC_NPORTS; i++) + musycc_init_port (&ci->port[i]); +#endif + + return SBE_DRVR_SUCCESS; /* no error */ +} + + +void +musycc_bh_tx_eom (mpi_t * pi, int gchan) +{ + mch_t *ch; + struct mdesc *md; + +#if 0 +#ifndef SBE_ISR_INLINE + unsigned long flags; + +#endif +#endif + volatile u_int32_t status; + + ch = pi->chan[gchan]; + if (ch == 0 || ch->state != UP) + { + if (log_level >= LOG_ERROR) + printk ("%s: intr: xmit EOM on uninitialized channel %d\n", pi->up->devname, gchan); + } + if (ch == 0 || ch->mdt == 0) + return; /* note: mdt==0 implies a malloc() + * failure w/in chan_up() routine */ + +#if 0 +#ifdef SBE_ISR_INLINE + spin_lock_irq (&ch->ch_txlock); +#else + spin_lock_irqsave (&ch->ch_txlock, flags); +#endif +#endif + do + { + FLUSH_MEM_READ (); + md = ch->txd_irq_srv; + status = le32_to_cpu (md->status); + + /* + * Note: Per MUSYCC Ref 6.4.9, the host does not poll a host-owned + * Transmit Buffer Descriptor during Transparent Mode. + */ + if (status & MUSYCC_TX_OWNED) + { + int readCount, loopCount; + + /***********************************************************/ + /* HW Bug Fix */ + /* ---------- */ + /* Under certain PCI Bus loading conditions, the data */ + /* associated with an update of Shared Memory is delayed */ + /* relative to its PCI Interrupt. This is caught when */ + /* the host determines it does not yet OWN the descriptor. */ + /***********************************************************/ + + readCount = 0; + while (status & MUSYCC_TX_OWNED) + { + for (loopCount = 0; loopCount < 0x30; loopCount++) + OS_uwait_dummy (); /* use call to avoid optimization + * removal of dummy delay */ + FLUSH_MEM_READ (); + status = le32_to_cpu (md->status); + if (readCount++ > 40) + break; /* don't wait any longer */ + } + if (status & MUSYCC_TX_OWNED) + { + if (log_level >= LOG_MONITOR) + { + printk ("%s: Port %d Chan %2d - unexpected TX msg ownership intr (md %p sts %x)\n", + pi->up->devname, pi->portnum, ch->channum, md, status); + printk ("++ User 0x%p IRQ_SRV 0x%p USR_ADD 0x%p QStopped %x, start_tx %x tx_full %d txd_free %d mode %x\n", + ch->user, ch->txd_irq_srv, ch->txd_usr_add, + sd_queue_stopped (ch->user), + ch->ch_start_tx, ch->tx_full, ch->txd_free, ch->p.chan_mode); + musycc_dump_txbuffer_ring (ch, 0); + } + break; /* Not our mdesc, done */ + } else + { + if (log_level >= LOG_MONITOR) + printk ("%s: Port %d Chan %2d - recovered TX msg ownership [%d] (md %p sts %x)\n", + pi->up->devname, pi->portnum, ch->channum, readCount, md, status); + } + } + ch->txd_irq_srv = md->snext; + + md->data = 0; + if (md->mem_token != 0) + { + /* upcount channel */ + atomic_sub (OS_mem_token_tlen (md->mem_token), &ch->tx_pending); + /* upcount card */ + atomic_sub (OS_mem_token_tlen (md->mem_token), &pi->up->tx_pending); +#ifdef SBE_WAN256T3_ENABLE + if (!atomic_read (&pi->up->tx_pending)) + wan256t3_led (pi->up, LED_TX, 0); +#endif + +#ifdef CONFIG_SBE_WAN256T3_NCOMM + /* callback that our packet was sent */ + { + int hdlcnum = (pi->portnum * 32 + gchan); + + if (hdlcnum >= 228) + { + if (nciProcess_TX_complete) + (*nciProcess_TX_complete) (hdlcnum, + getuserbychan (gchan)); + } + } +#endif /*** CONFIG_SBE_WAN256T3_NCOMM ***/ + + OS_mem_token_free_irq (md->mem_token); + md->mem_token = 0; + } + md->status = 0; +#ifdef RLD_TXFULL_DEBUG + if (log_level >= LOG_MONITOR2) + printk ("~~ tx_eom: tx_full %x txd_free %d -> %d\n", ch->tx_full, ch->txd_free, ch->txd_free + 1); +#endif + ++ch->txd_free; + FLUSH_MEM_WRITE (); + + if ((ch->p.chan_mode != CFG_CH_PROTO_TRANS) && (status & EOBIRQ_ENABLE)) + { + if (log_level >= LOG_MONITOR) + printk ("%s: Mode (%x) incorrect EOB status (%x)\n", + pi->up->devname, ch->p.chan_mode, status); + if ((status & EOMIRQ_ENABLE) == 0) + break; + } + } + while ((ch->p.chan_mode != CFG_CH_PROTO_TRANS) && ((status & EOMIRQ_ENABLE) == 0)); + /* + * NOTE: (The above 'while' is coupled w/ previous 'do', way above.) Each + * Transparent data buffer has the EOB bit, and NOT the EOM bit, set and + * will furthermore have a separate IQD associated with each messages + * buffer. + */ + + FLUSH_MEM_READ (); + /* + * Smooth flow control hysterisis by maintaining task stoppage until half + * the available write buffers are available. + */ + if (ch->tx_full && (ch->txd_free >= (ch->txd_num / 2))) + { + /* + * Then, only releave task stoppage if we actually have enough + * buffers to service the last requested packet. It may require MORE + * than half the available! + */ + if (ch->txd_free >= ch->txd_required) + { + +#ifdef RLD_TXFULL_DEBUG + if (log_level >= LOG_MONITOR2) + printk ("tx_eom[%d]: enable xmit tx_full no more, txd_free %d txd_num/2 %d\n", + ch->channum, + ch->txd_free, ch->txd_num / 2); +#endif + ch->tx_full = 0; + ch->txd_required = 0; + sd_enable_xmit (ch->user); /* re-enable to catch flow controlled + * channel */ + } + } +#ifdef RLD_TXFULL_DEBUG + else if (ch->tx_full) + { + if (log_level >= LOG_MONITOR2) + printk ("tx_eom[%d]: bypass TX enable though room available? (txd_free %d txd_num/2 %d)\n", + ch->channum, + ch->txd_free, ch->txd_num / 2); + } +#endif + + FLUSH_MEM_WRITE (); +#if 0 +#ifdef SBE_ISR_INLINE + spin_unlock_irq (&ch->ch_txlock); +#else + spin_unlock_irqrestore (&ch->ch_txlock, flags); +#endif +#endif +} + + +STATIC void +musycc_bh_rx_eom (mpi_t * pi, int gchan) +{ + mch_t *ch; + void *m, *m2; + struct mdesc *md; + volatile u_int32_t status; + u_int32_t error; + + ch = pi->chan[gchan]; + if (ch == 0 || ch->state != UP) + { + if (log_level > LOG_ERROR) + printk ("%s: intr: receive EOM on uninitialized channel %d\n", pi->up->devname, gchan); + return; + } + if (ch->mdr == 0) + return; /* can this happen ? */ + + for (;;) + { + FLUSH_MEM_READ (); + md = &ch->mdr[ch->rxix_irq_srv]; + status = le32_to_cpu (md->status); + if (!(status & HOST_RX_OWNED)) + break; /* Not our mdesc, done */ + m = md->mem_token; + error = (status >> 16) & 0xf; + if (error == 0) + { +#ifdef CONFIG_SBE_WAN256T3_NCOMM + int hdlcnum = (pi->portnum * 32 + gchan); + + /* + * if the packet number belongs to NCOMM, then send it to the TMS + * driver + */ + if (hdlcnum >= 228) + { + if (nciProcess_RX_packet) + (*nciProcess_RX_packet) (hdlcnum, status & 0x3fff, m, ch->user); + } else +#endif /*** CONFIG_SBE_WAN256T3_NCOMM ***/ + + { + if ((m2 = OS_mem_token_alloc (max_mru))) + { + /* substitute the mbuf+cluster */ + md->mem_token = m2; + md->data = cpu_to_le32 (OS_vtophys (OS_mem_token_data (m2))); + + /* pass the received mbuf upward */ + sd_recv_consume (m, status & LENGTH_MASK, ch->user); + ch->s.rx_packets++; + ch->s.rx_bytes += status & LENGTH_MASK; + } else + { + ch->s.rx_dropped++; + } + } + } else if (error == ERR_FCS) + { + ch->s.rx_crc_errors++; + } else if (error == ERR_ALIGN) + { + ch->s.rx_missed_errors++; + } else if (error == ERR_ABT) + { + ch->s.rx_missed_errors++; + } else if (error == ERR_LNG) + { + ch->s.rx_length_errors++; + } else if (error == ERR_SHT) + { + ch->s.rx_length_errors++; + } + FLUSH_MEM_WRITE (); + status = max_mru; + if (ch->p.chan_mode == CFG_CH_PROTO_TRANS) + status |= EOBIRQ_ENABLE; + md->status = cpu_to_le32 (status); + + /* Check next mdesc in the ring */ + if (++ch->rxix_irq_srv >= ch->rxd_num) + ch->rxix_irq_srv = 0; + FLUSH_MEM_WRITE (); + } +} + + +irqreturn_t +musycc_intr_th_handler (void *devp) +{ + ci_t *ci = (ci_t *) devp; + volatile u_int32_t status, currInt = 0; + u_int32_t nextInt, intCnt; + + /* + * Hardware not available, potential interrupt hang. But since interrupt + * might be shared, just return. + */ + if (ci->state == C_INIT) + { + return IRQ_NONE; + } + /* + * Marked as hardware available. Don't service interrupts, just clear the + * event. + */ + + if (ci->state == C_IDLE) + { + status = pci_read_32 ((u_int32_t *) &ci->reg->isd); + + /* clear the interrupt but process nothing else */ + pci_write_32 ((u_int32_t *) &ci->reg->isd, status); + return IRQ_HANDLED; + } + FLUSH_PCI_READ (); + FLUSH_MEM_READ (); + + status = pci_read_32 ((u_int32_t *) &ci->reg->isd); + nextInt = INTRPTS_NEXTINT (status); + intCnt = INTRPTS_INTCNT (status); + ci->intlog.drvr_intr_thcount++; + + /*********************************************************/ + /* HW Bug Fix */ + /* ---------- */ + /* Under certain PCI Bus loading conditions, the */ + /* MUSYCC looses the data associated with an update */ + /* of its ISD and erroneously returns the immediately */ + /* preceding 'nextInt' value. However, the 'intCnt' */ + /* value appears to be correct. By not starting service */ + /* where the 'missing' 'nextInt' SHOULD point causes */ + /* the IQD not to be serviced - the 'not serviced' */ + /* entries then remain and continue to increase as more */ + /* incorrect ISD's are encountered. */ + /*********************************************************/ + + if (nextInt != INTRPTS_NEXTINT (ci->intlog.this_status_new)) + { + if (log_level >= LOG_MONITOR) + { + printk ("%s: note - updated ISD from %08x to %08x\n", + ci->devname, status, + (status & (~INTRPTS_NEXTINT_M)) | ci->intlog.this_status_new); + } + /* + * Replace bogus status with software corrected value. + * + * It's not known whether, during this problem occurrence, if the + * INTFULL bit is correctly reported or not. + */ + status = (status & (~INTRPTS_NEXTINT_M)) | (ci->intlog.this_status_new); + nextInt = INTRPTS_NEXTINT (status); + } + /**********************************************/ + /* Cn847x Bug Fix */ + /* -------------- */ + /* Fix for inability to write back same index */ + /* as read for a full interrupt queue. */ + /**********************************************/ + + if (intCnt == INT_QUEUE_SIZE) + { + currInt = ((intCnt - 1) + nextInt) & (INT_QUEUE_SIZE - 1); + } else + /************************************************/ + /* Interrupt Write Location Issues */ + /* ------------------------------- */ + /* When the interrupt status descriptor is */ + /* written, the interrupt line is de-asserted */ + /* by the Cn847x. In the case of MIPS */ + /* microprocessors, this must occur at the */ + /* beginning of the interrupt handler so that */ + /* the interrupt handle is not re-entered due */ + /* to interrupt dis-assertion latency. */ + /* In the case of all other processors, this */ + /* action should occur at the end of the */ + /* interrupt handler to avoid overwriting the */ + /* interrupt queue. */ + /************************************************/ + + if (intCnt) + { + currInt = (intCnt + nextInt) & (INT_QUEUE_SIZE - 1); + } else + { + /* + * NOTE: Servicing an interrupt whose ISD contains a count of ZERO + * can be indicative of a Shared Interrupt chain. Our driver can be + * called from the system's interrupt handler as a matter of the OS + * walking the chain. As the chain is walked, the interrupt will + * eventually be serviced by the correct driver/handler. + */ +#if 0 + /* chained interrupt = not ours */ + printk (">> %s: intCnt NULL, sts %x, possibly a chained interrupt!\n", + ci->devname, status); +#endif + return IRQ_NONE; + } + + ci->iqp_tailx = currInt; + + currInt <<= INTRPTS_NEXTINT_S; + ci->intlog.last_status_new = ci->intlog.this_status_new; + ci->intlog.this_status_new = currInt; + + if ((log_level >= LOG_WARN) && (status & INTRPTS_INTFULL_M)) + { + printk ("%s: Interrupt queue full condition occurred\n", ci->devname); + } + if (log_level >= LOG_DEBUG) + printk ("%s: interrupts pending, isd @ 0x%p: %x curr %d cnt %d NEXT %d\n", + ci->devname, &ci->reg->isd, + status, nextInt, intCnt, (intCnt + nextInt) & (INT_QUEUE_SIZE - 1)); + + FLUSH_MEM_WRITE (); +#if defined(SBE_ISR_TASKLET) + pci_write_32 ((u_int32_t *) &ci->reg->isd, currInt); + atomic_inc (&ci->bh_pending); + tasklet_schedule (&ci->ci_musycc_isr_tasklet); +#elif defined(SBE_ISR_IMMEDIATE) + pci_write_32 ((u_int32_t *) &ci->reg->isd, currInt); + atomic_inc (&ci->bh_pending); + queue_task (&ci->ci_musycc_isr_tq, &tq_immediate); + mark_bh (IMMEDIATE_BH); +#elif defined(SBE_ISR_INLINE) + (void) musycc_intr_bh_tasklet (ci); + pci_write_32 ((u_int32_t *) &ci->reg->isd, currInt); +#endif + return IRQ_HANDLED; +} + + +#if defined(SBE_ISR_IMMEDIATE) +unsigned long +#else +void +#endif +musycc_intr_bh_tasklet (ci_t * ci) +{ + mpi_t *pi; + mch_t *ch; + unsigned int intCnt; + volatile u_int32_t currInt = 0; + volatile unsigned int headx, tailx; + int readCount, loopCount; + int group, gchan, event, err, tx; + u_int32_t badInt = INT_EMPTY_ENTRY; + u_int32_t badInt2 = INT_EMPTY_ENTRY2; + + /* + * Hardware not available, potential interrupt hang. But since interrupt + * might be shared, just return. + */ + if ((drvr_state != SBE_DRVR_AVAILABLE) || (ci->state == C_INIT)) + { +#if defined(SBE_ISR_IMMEDIATE) + return 0L; +#else + return; +#endif + } +#if defined(SBE_ISR_TASKLET) || defined(SBE_ISR_IMMEDIATE) + if (drvr_state != SBE_DRVR_AVAILABLE) + { +#if defined(SBE_ISR_TASKLET) + return; +#elif defined(SBE_ISR_IMMEDIATE) + return 0L; +#endif + } +#elif defined(SBE_ISR_INLINE) + /* no semaphore taken, no double checks */ +#endif + + ci->intlog.drvr_intr_bhcount++; + FLUSH_MEM_READ (); + { + unsigned int bh = atomic_read (&ci->bh_pending); + + max_bh = max (bh, max_bh); + } + atomic_set (&ci->bh_pending, 0);/* if here, no longer pending */ + while ((headx = ci->iqp_headx) != (tailx = ci->iqp_tailx)) + { + intCnt = (tailx >= headx) ? (tailx - headx) : (tailx - headx + INT_QUEUE_SIZE); + currInt = le32_to_cpu (ci->iqd_p[headx]); + + max_intcnt = max (intCnt, max_intcnt); /* RLD DEBUG */ + + /**************************************************/ + /* HW Bug Fix */ + /* ---------- */ + /* The following code checks for the condition */ + /* of interrupt assertion before interrupt */ + /* queue update. This is a problem on several */ + /* PCI-Local bridge chips found on some products. */ + /**************************************************/ + + readCount = 0; + if ((currInt == badInt) || (currInt == badInt2)) + ci->intlog.drvr_int_failure++; + + while ((currInt == badInt) || (currInt == badInt2)) + { + for (loopCount = 0; loopCount < 0x30; loopCount++) + OS_uwait_dummy (); /* use call to avoid optimization removal + * of dummy delay */ + FLUSH_MEM_READ (); + currInt = le32_to_cpu (ci->iqd_p[headx]); + if (readCount++ > 20) + break; + } + + if ((currInt == badInt) || (currInt == badInt2)) /* catch failure of Bug + * Fix checking */ + { + if (log_level >= LOG_WARN) + printk ("%s: Illegal Interrupt Detected @ 0x%p, mod %d.)\n", + ci->devname, &ci->iqd_p[headx], headx); + + /* + * If the descriptor has not recovered, then leaving the EMPTY + * entry set will not signal to the MUSYCC that this descriptor + * has been serviced. The Interrupt Queue can then start loosing + * available descriptors and MUSYCC eventually encounters and + * reports the INTFULL condition. Per manual, changing any bit + * marks descriptor as available, thus the use of different + * EMPTY_ENTRY values. + */ + + if (currInt == badInt) + { + ci->iqd_p[headx] = __constant_cpu_to_le32 (INT_EMPTY_ENTRY2); + } else + { + ci->iqd_p[headx] = __constant_cpu_to_le32 (INT_EMPTY_ENTRY); + } + ci->iqp_headx = (headx + 1) & (INT_QUEUE_SIZE - 1); /* insure wrapness */ + FLUSH_MEM_WRITE (); + FLUSH_MEM_READ (); + continue; + } + group = INTRPT_GRP (currInt); + gchan = INTRPT_CH (currInt); + event = INTRPT_EVENT (currInt); + err = INTRPT_ERROR (currInt); + tx = currInt & INTRPT_DIR_M; + + ci->iqd_p[headx] = __constant_cpu_to_le32 (INT_EMPTY_ENTRY); + FLUSH_MEM_WRITE (); + + if (log_level >= LOG_DEBUG) + { + if (err != 0) + printk (" %08x -> err: %2d,", currInt, err); + + printk ("+ interrupt event: %d, grp: %d, chan: %2d, side: %cX\n", + event, group, gchan, tx ? 'T' : 'R'); + } + pi = &ci->port[group]; /* notice that here we assume 1-1 group - + * port mapping */ + ch = pi->chan[gchan]; + switch (event) + { + case EVE_SACK: /* Service Request Acknowledge */ + if (log_level >= LOG_DEBUG) + { + volatile u_int32_t r; + + r = pci_read_32 ((u_int32_t *) &pi->reg->srd); + printk ("- SACK cmd: %08x (hdw= %08x)\n", pi->sr_last, r); + } + SD_SEM_GIVE (&pi->sr_sem_wait); /* wake up waiting process */ + break; + case EVE_CHABT: /* Change To Abort Code (0x7e -> 0xff) */ + case EVE_CHIC: /* Change To Idle Code (0xff -> 0x7e) */ + break; + case EVE_EOM: /* End Of Message */ + case EVE_EOB: /* End Of Buffer (Transparent mode) */ + if (tx) + { + musycc_bh_tx_eom (pi, gchan); + } else + { + musycc_bh_rx_eom (pi, gchan); + } +#if 0 + break; +#else + /* + * MUSYCC Interrupt Descriptor section states that EOB and EOM + * can be combined with the NONE error (as well as others). So + * drop thru to catch this... + */ +#endif + case EVE_NONE: + if (err == ERR_SHT) + { + ch->s.rx_length_errors++; + } + break; + default: + if (log_level >= LOG_WARN) + printk ("%s: unexpected interrupt event: %d, iqd[%d]: %08x, port: %d\n", ci->devname, + event, headx, currInt, group); + break; + } /* switch on event */ + + + /* + * Per MUSYCC Manual, Section 6.4.8.3 [Transmit Errors], TX errors + * are service-affecting and require action to resume normal + * bit-level processing. + */ + + switch (err) + { + case ERR_ONR: + /* + * Per MUSYCC manual, Section 6.4.8.3 [Transmit Errors], this + * error requires Transmit channel reactivation. + * + * Per MUSYCC manual, Section 6.4.8.4 [Receive Errors], this error + * requires Receive channel reactivation. + */ + if (tx) + { + + /* + * TX ONR Error only occurs when channel is configured for + * Transparent Mode. However, this code will catch and + * re-activate on ANY TX ONR error. + */ + + /* + * Set flag to re-enable on any next transmit attempt. + */ + ch->ch_start_tx = CH_START_TX_ONR; + + { +#ifdef RLD_TRANS_DEBUG + if (1 || log_level >= LOG_MONITOR) +#else + if (log_level >= LOG_MONITOR) +#endif + { + printk ("%s: TX buffer underflow [ONR] on channel %d, mode %x QStopped %x free %d\n", + ci->devname, ch->channum, ch->p.chan_mode, sd_queue_stopped (ch->user), ch->txd_free); +#ifdef RLD_DEBUG + if (ch->p.chan_mode == 2) /* problem = ONR on HDLC + * mode */ + { + printk ("++ Failed Last %x Next %x QStopped %x, start_tx %x tx_full %d txd_free %d mode %x\n", + (u_int32_t) ch->txd_irq_srv, (u_int32_t) ch->txd_usr_add, + sd_queue_stopped (ch->user), + ch->ch_start_tx, ch->tx_full, ch->txd_free, ch->p.chan_mode); + musycc_dump_txbuffer_ring (ch, 0); + } +#endif + } + } + } else /* RX buffer overrun */ + { + /* + * Per MUSYCC manual, Section 6.4.8.4 [Receive Errors], + * channel recovery for this RX ONR error IS required. It is + * also suggested to increase the number of receive buffers + * for this channel. Receive channel reactivation IS + * required, and data has been lost. + */ + ch->s.rx_over_errors++; + ch->ch_start_rx = CH_START_RX_ONR; + + if (log_level >= LOG_WARN) + { + printk ("%s: RX buffer overflow [ONR] on channel %d, mode %x\n", + ci->devname, ch->channum, ch->p.chan_mode); + //musycc_dump_rxbuffer_ring (ch, 0); /* RLD DEBUG */ + } + } + musycc_chan_restart (ch); + break; + case ERR_BUF: + if (tx) + { + ch->s.tx_fifo_errors++; + ch->ch_start_tx = CH_START_TX_BUF; + /* + * Per MUSYCC manual, Section 6.4.8.3 [Transmit Errors], + * this BUFF error requires Transmit channel reactivation. + */ + if (log_level >= LOG_MONITOR) + printk ("%s: TX buffer underrun [BUFF] on channel %d, mode %x\n", + ci->devname, ch->channum, ch->p.chan_mode); + } else /* RX buffer overrun */ + { + ch->s.rx_over_errors++; + /* + * Per MUSYCC manual, Section 6.4.8.4 [Receive Errors], HDLC + * mode requires NO recovery for this RX BUFF error is + * required. It is suggested to increase the FIFO buffer + * space for this channel. Receive channel reactivation is + * not required, but data has been lost. + */ + if (log_level >= LOG_WARN) + printk ("%s: RX buffer overrun [BUFF] on channel %d, mode %x\n", + ci->devname, ch->channum, ch->p.chan_mode); + /* + * Per MUSYCC manual, Section 6.4.9.4 [Receive Errors], + * Transparent mode DOES require recovery for the RX BUFF + * error. It is suggested to increase the FIFO buffer space + * for this channel. Receive channel reactivation IS + * required and data has been lost. + */ + if (ch->p.chan_mode == CFG_CH_PROTO_TRANS) + ch->ch_start_rx = CH_START_RX_BUF; + } + + if (tx || (ch->p.chan_mode == CFG_CH_PROTO_TRANS)) + musycc_chan_restart (ch); + break; + default: + break; + } /* switch on err */ + + /* Check for interrupt lost condition */ + if ((currInt & INTRPT_ILOST_M) && (log_level >= LOG_ERROR)) + { + printk ("%s: Interrupt queue overflow - ILOST asserted\n", + ci->devname); + } + ci->iqp_headx = (headx + 1) & (INT_QUEUE_SIZE - 1); /* insure wrapness */ + FLUSH_MEM_WRITE (); + FLUSH_MEM_READ (); + } /* while */ + if ((log_level >= LOG_MONITOR2) && (ci->iqp_headx != ci->iqp_tailx)) + { + int bh; + + bh = atomic_read (&CI->bh_pending); + printk ("_bh_: late arrivals, head %d != tail %d, pending %d\n", + ci->iqp_headx, ci->iqp_tailx, bh); + } +#if defined(SBE_ISR_IMMEDIATE) + return 0L; +#endif + /* else, nothing returned */ +} + +#if 0 +int __init +musycc_new_chan (ci_t * ci, int channum, void *user) +{ + mch_t *ch; + + ch = ci->port[channum / MUSYCC_NCHANS].chan[channum % MUSYCC_NCHANS]; + + if (ch->state != UNASSIGNED) + return EEXIST; + /* NOTE: mch_t already cleared during OS_kmalloc() */ + ch->state = DOWN; + ch->user = user; +#if 0 + ch->status = 0; + ch->p.status = 0; + ch->p.intr_mask = 0; +#endif + ch->p.chan_mode = CFG_CH_PROTO_HDLC_FCS16; + ch->p.idlecode = CFG_CH_FLAG_7E; + ch->p.pad_fill_count = 2; + spin_lock_init (&ch->ch_rxlock); + spin_lock_init (&ch->ch_txlock); + + return 0; +} +#endif + + +#ifdef SBE_PMCC4_ENABLE +status_t +musycc_chan_down (ci_t * dummy, int channum) +{ + mpi_t *pi; + mch_t *ch; + int i, gchan; + + if (!(ch = sd_find_chan (dummy, 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->mdr); + ch->mdr = 0; + ch->rxd_num = 0; + OS_kfree (ch->mdt); + ch->mdt = 0; + ch->txd_num = 0; + + musycc_update_timeslots (pi); + c4_fifo_free (pi, ch->gchan); + + pi->openchans--; + return 0; +} +#endif + + +int +musycc_del_chan (ci_t * ci, int channum) +{ + 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; + if (ch->state == UP) + musycc_chan_down (ci, channum); + ch->state = UNASSIGNED; + return 0; +} + + +int +musycc_del_chan_stats (ci_t * ci, int channum) +{ + 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; + + memset (&ch->s, 0, sizeof (struct sbecom_chan_stats)); + return 0; +} + + +int +musycc_start_xmit (ci_t * ci, int channum, void *mem_token) +{ + mch_t *ch; + struct mdesc *md; + void *m2; +#if 0 + unsigned long flags; +#endif + int txd_need_cnt; + u_int32_t len; + + if (!(ch = sd_find_chan (ci, channum))) + return ENOENT; + + if (ci->state != C_RUNNING) /* full interrupt processing available */ + return EINVAL; + if (ch->state != UP) + return EINVAL; + + if (!(ch->status & TX_ENABLED)) + return EROFS; /* how else to flag unwritable state ? */ + +#ifdef RLD_TRANS_DEBUGx + if (1 || log_level >= LOG_MONITOR2) +#else + if (log_level >= LOG_MONITOR2) +#endif + { + printk ("++ start_xmt[%d]: state %x start %x full %d free %d required %d stopped %x\n", + channum, ch->state, ch->ch_start_tx, ch->tx_full, + ch->txd_free, ch->txd_required, sd_queue_stopped (ch->user)); + } + /***********************************************/ + /** Determine total amount of data to be sent **/ + /***********************************************/ + m2 = mem_token; + txd_need_cnt = 0; + for (len = OS_mem_token_tlen (m2); len > 0; + m2 = (void *) OS_mem_token_next (m2)) + { + if (!OS_mem_token_len (m2)) + continue; + txd_need_cnt++; + len -= OS_mem_token_len (m2); + } + + if (txd_need_cnt == 0) + { + if (log_level >= LOG_MONITOR2) + printk ("%s channel %d: no TX data in User buffer\n", ci->devname, channum); + OS_mem_token_free (mem_token); + return 0; /* no data to send */ + } + /*************************************************/ + /** Are there sufficient descriptors available? **/ + /*************************************************/ + if (txd_need_cnt > ch->txd_num) /* never enough descriptors for this + * large a buffer */ + { + if (log_level >= LOG_DEBUG) + { + printk ("start_xmit: discarding buffer, insufficient descriptor cnt %d, need %d.\n", + ch->txd_num, txd_need_cnt + 1); + } + ch->s.tx_dropped++; + OS_mem_token_free (mem_token); + return 0; + } +#if 0 + spin_lock_irqsave (&ch->ch_txlock, flags); +#endif + /************************************************************/ + /** flow control the line if not enough descriptors remain **/ + /************************************************************/ + if (txd_need_cnt > ch->txd_free) + { + if (log_level >= LOG_MONITOR2) + { + printk ("start_xmit[%d]: EBUSY - need more descriptors, have %d of %d need %d\n", + channum, ch->txd_free, ch->txd_num, txd_need_cnt); + } + ch->tx_full = 1; + ch->txd_required = txd_need_cnt; + sd_disable_xmit (ch->user); +#if 0 + spin_unlock_irqrestore (&ch->ch_txlock, flags); +#endif + return EBUSY; /* tell user to try again later */ + } + /**************************************************/ + /** Put the user data into MUSYCC data buffer(s) **/ + /**************************************************/ + m2 = mem_token; + md = ch->txd_usr_add; /* get current available descriptor */ + + for (len = OS_mem_token_tlen (m2); len > 0; m2 = OS_mem_token_next (m2)) + { + int u = OS_mem_token_len (m2); + + if (!u) + continue; + len -= u; + + /* + * Enable following chunks, yet wait to enable the FIRST chunk until + * after ALL subsequent chunks are setup. + */ + if (md != ch->txd_usr_add) /* not first chunk */ + u |= MUSYCC_TX_OWNED; /* transfer ownership from HOST to MUSYCC */ + + if (len) /* not last chunk */ + u |= EOBIRQ_ENABLE; + else if (ch->p.chan_mode == CFG_CH_PROTO_TRANS) + { + /* + * Per MUSYCC Ref 6.4.9 for Transparent Mode, the host must + * always clear EOMIRQ_ENABLE in every Transmit Buffer Descriptor + * (IE. don't set herein). + */ + u |= EOBIRQ_ENABLE; + } else + u |= EOMIRQ_ENABLE; /* EOM, last HDLC chunk */ + + + /* last chunk in hdlc mode */ + u |= (ch->p.idlecode << IDLE_CODE); + if (ch->p.pad_fill_count) + { +#if 0 + /* NOOP NOTE: u_int8_t cannot be > 0xFF */ + /* sanitize pad_fill_count for maximums allowed by hardware */ + if (ch->p.pad_fill_count > EXTRA_FLAGS_MASK) + ch->p.pad_fill_count = EXTRA_FLAGS_MASK; +#endif + u |= (PADFILL_ENABLE | (ch->p.pad_fill_count << EXTRA_FLAGS)); + } + md->mem_token = len ? 0 : mem_token; /* Fill in mds on last + * segment, others set ZERO + * so that entire token is + * removed ONLY when ALL + * segments have been + * transmitted. */ + + md->data = cpu_to_le32 (OS_vtophys (OS_mem_token_data (m2))); + FLUSH_MEM_WRITE (); + md->status = cpu_to_le32 (u); + --ch->txd_free; + md = md->snext; + } + FLUSH_MEM_WRITE (); + + + /* + * Now transfer ownership of first chunk from HOST to MUSYCC in order to + * fire-off this XMIT. + */ + ch->txd_usr_add->status |= __constant_cpu_to_le32 (MUSYCC_TX_OWNED); + FLUSH_MEM_WRITE (); + ch->txd_usr_add = md; + + len = OS_mem_token_tlen (mem_token); + atomic_add (len, &ch->tx_pending); + 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); +#endif + return 0; +} + + +#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/musycc.h b/drivers/staging/cxt1e1/musycc.h new file mode 100644 index 000000000000..d2c91ef686d1 --- /dev/null +++ b/drivers/staging/cxt1e1/musycc.h @@ -0,0 +1,460 @@ +/* + * $Id: musycc.h,v 1.3 2005/09/28 00:10:08 rickd PMCC4_3_1B $ + */ + +#ifndef _INC_MUSYCC_H_ +#define _INC_MUSYCC_H_ + +/*----------------------------------------------------------------------------- + * musycc.h - Multichannel Synchronous Communications Controller + * CN8778/8474A/8472A/8471A + * + * Copyright (C) 2002-2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + * + * For further information, contact via email: support@sbei.com + * SBE, Inc. San Ramon, California U.S.A. + *----------------------------------------------------------------------------- + * RCS info: + * RCS revision: $Revision: 1.3 $ + * Last changed on $Date: 2005/09/28 00:10:08 $ + * Changed by $Author: rickd $ + *----------------------------------------------------------------------------- + * $Log: musycc.h,v $ + * Revision 1.3 2005/09/28 00:10:08 rickd + * Add GNU license info. Add PMCC4 PCI/DevIDs. Implement new + * musycc reg&bits namings. Use PORTMAP_0 GCD grouping. + * + * Revision 1.2 2005/04/28 23:43:04 rickd + * Add RCS tracking heading. + * + *----------------------------------------------------------------------------- + */ + +#if defined (__FreeBSD__) || defined (__NetBSD__) +#include <sys/types.h> +#else +#include <linux/types.h> +#endif + +#define VINT8 volatile u_int8_t +#define VINT32 volatile u_int32_t + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "pmcc4_defs.h" + + +/*------------------------------------------------------------------------ +// Vendor, Board Identification definitions +//------------------------------------------------------------------------ +*/ + +#define PCI_VENDOR_ID_CONEXANT 0x14f1 +#define PCI_DEVICE_ID_CN8471 0x8471 +#define PCI_DEVICE_ID_CN8472 0x8472 +#define PCI_DEVICE_ID_CN8474 0x8474 +#define PCI_DEVICE_ID_CN8478 0x8478 +#define PCI_DEVICE_ID_CN8500 0x8500 +#define PCI_DEVICE_ID_CN8501 0x8501 +#define PCI_DEVICE_ID_CN8502 0x8502 +#define PCI_DEVICE_ID_CN8503 0x8503 + +#define INT_QUEUE_SIZE MUSYCC_NIQD + +/* RAM image of MUSYCC registers layed out as a C structure */ + struct musycc_groupr + { + VINT32 thp[32]; /* Transmit Head Pointer [5-29] */ + VINT32 tmp[32]; /* Transmit Message Pointer [5-30] */ + VINT32 rhp[32]; /* Receive Head Pointer [5-29] */ + VINT32 rmp[32]; /* Receive Message Pointer [5-30] */ + VINT8 ttsm[128]; /* Time Slot Map [5-22] */ + VINT8 tscm[256]; /* Subchannel Map [5-24] */ + VINT32 tcct[32]; /* Channel Configuration [5-26] */ + VINT8 rtsm[128]; /* Time Slot Map [5-22] */ + VINT8 rscm[256]; /* Subchannel Map [5-24] */ + VINT32 rcct[32]; /* Channel Configuration [5-26] */ + VINT32 __glcd; /* Global Configuration Descriptor [5-10] */ + VINT32 __iqp; /* Interrupt Queue Pointer [5-36] */ + VINT32 __iql; /* Interrupt Queue Length [5-36] */ + VINT32 grcd; /* Group Configuration Descriptor [5-16] */ + VINT32 mpd; /* Memory Protection Descriptor [5-18] */ + VINT32 mld; /* Message Length Descriptor [5-20] */ + VINT32 pcd; /* Port Configuration Descriptor [5-19] */ + }; + +/* hardware MUSYCC registers layed out as a C structure */ + struct musycc_globalr + { + VINT32 gbp; /* Group Base Pointer */ + VINT32 dacbp; /* Dual Address Cycle Base Pointer */ + VINT32 srd; /* Service Request Descriptor */ + VINT32 isd; /* Interrupt Service Descriptor */ + /* + * adjust __thp due to above 4 registers, which are not contained + * within musycc_groupr[]. All __XXX[] are just place holders, + * anyhow. + */ + VINT32 __thp[32 - 4]; /* Transmit Head Pointer [5-29] */ + VINT32 __tmp[32]; /* Transmit Message Pointer [5-30] */ + VINT32 __rhp[32]; /* Receive Head Pointer [5-29] */ + VINT32 __rmp[32]; /* Receive Message Pointer [5-30] */ + VINT8 ttsm[128]; /* Time Slot Map [5-22] */ + VINT8 tscm[256]; /* Subchannel Map [5-24] */ + VINT32 tcct[32]; /* Channel Configuration [5-26] */ + VINT8 rtsm[128]; /* Time Slot Map [5-22] */ + VINT8 rscm[256]; /* Subchannel Map [5-24] */ + VINT32 rcct[32]; /* Channel Configuration [5-26] */ + VINT32 glcd; /* Global Configuration Descriptor [5-10] */ + VINT32 iqp; /* Interrupt Queue Pointer [5-36] */ + VINT32 iql; /* Interrupt Queue Length [5-36] */ + VINT32 grcd; /* Group Configuration Descriptor [5-16] */ + VINT32 mpd; /* Memory Protection Descriptor [5-18] */ + VINT32 mld; /* Message Length Descriptor [5-20] */ + VINT32 pcd; /* Port Configuration Descriptor [5-19] */ + VINT32 rbist; /* Receive BIST status [5-4] */ + VINT32 tbist; /* Receive BIST status [5-4] */ + }; + +/* Global Config Descriptor bit macros */ +#define MUSYCC_GCD_ECLK_ENABLE 0x00000800 /* EBUS clock enable */ +#define MUSYCC_GCD_INTEL_SELECT 0x00000400 /* MPU type select */ +#define MUSYCC_GCD_INTA_DISABLE 0x00000008 /* PCI INTA disable */ +#define MUSYCC_GCD_INTB_DISABLE 0x00000004 /* PCI INTB disable */ +#define MUSYCC_GCD_BLAPSE 12 /* Position index for BLAPSE bit + * field */ +#define MUSYCC_GCD_ALAPSE 8 /* Position index for ALAPSE bit + * field */ +#define MUSYCC_GCD_ELAPSE 4 /* Position index for ELAPSE bit + * field */ +#define MUSYCC_GCD_PORTMAP_3 3 /* Reserved */ +#define MUSYCC_GCD_PORTMAP_2 2 /* Port 0=>Grp 0,1,2,3; Port 1=>Grp + * 4,5,6,7 */ +#define MUSYCC_GCD_PORTMAP_1 1 /* Port 0=>Grp 0,1; Port 1=>Grp 2,3, + * etc... */ +#define MUSYCC_GCD_PORTMAP_0 0 /* Port 0=>Grp 0; Port 1=>Grp 2, + * etc... */ + +/* and board specific assignments... */ +#ifdef SBE_WAN256T3_ENABLE +#define BLAPSE_VAL 0 +#define ALAPSE_VAL 0 +#define ELAPSE_VAL 7 +#define PORTMAP_VAL MUSYCC_GCD_PORTMAP_2 +#endif + +#ifdef SBE_PMCC4_ENABLE +#define BLAPSE_VAL 7 +#define ALAPSE_VAL 3 +#define ELAPSE_VAL 7 +#define PORTMAP_VAL MUSYCC_GCD_PORTMAP_0 +#endif + +#define GCD_MAGIC (((BLAPSE_VAL)<<(MUSYCC_GCD_BLAPSE)) | \ + ((ALAPSE_VAL)<<(MUSYCC_GCD_ALAPSE)) | \ + ((ELAPSE_VAL)<<(MUSYCC_GCD_ELAPSE)) | \ + (MUSYCC_GCD_ECLK_ENABLE) | PORTMAP_VAL) + +/* Group Config Descriptor bit macros */ +#define MUSYCC_GRCD_RX_ENABLE 0x00000001 /* Enable receive processing */ +#define MUSYCC_GRCD_TX_ENABLE 0x00000002 /* Enable transmit processing */ +#define MUSYCC_GRCD_SUBCHAN_DISABLE 0x00000004 /* Master disable for + * subchanneling */ +#define MUSYCC_GRCD_OOFMP_DISABLE 0x00000008 /* Out of Frame message + * processing disabled all + * channels */ +#define MUSYCC_GRCD_OOFIRQ_DISABLE 0x00000010 /* Out of Frame/In Frame irqs + * disabled */ +#define MUSYCC_GRCD_COFAIRQ_DISABLE 0x00000020 /* Change of Frame Alignment + * irq disabled */ +#define MUSYCC_GRCD_INHRBSD 0x00000100 /* Receive Buffer Status + * overwrite disabled */ +#define MUSYCC_GRCD_INHTBSD 0x00000200 /* Transmit Buffer Status + * overwrite disabled */ +#define MUSYCC_GRCD_SF_ALIGN 0x00008000 /* External frame sync */ +#define MUSYCC_GRCD_MC_ENABLE 0x00000040 /* Message configuration bits + * copy enable. Conexant sez + * turn this on */ +#define MUSYCC_GRCD_POLLTH_16 0x00000001 /* Poll every 16th frame */ +#define MUSYCC_GRCD_POLLTH_32 0x00000002 /* Poll every 32nd frame */ +#define MUSYCC_GRCD_POLLTH_64 0x00000003 /* Poll every 64th frame */ +#define MUSYCC_GRCD_POLLTH_SHIFT 10 /* Position index for poll throttle + * bit field */ +#define MUSYCC_GRCD_SUERM_THRESH_SHIFT 16 /* Position index for SUERM + * count threshold */ + +/* Port Config Descriptor bit macros */ +#define MUSYCC_PCD_E1X2_MODE 2 /* Port mode in bits 0-2. T1 and E1 */ +#define MUSYCC_PCD_E1X4_MODE 3 /* are defined in cn847x.h */ +#define MUSYCC_PCD_NX64_MODE 4 +#define MUSYCC_PCD_TXDATA_RISING 0x00000010 /* Sample Tx data on TCLK + * rising edge */ +#define MUSYCC_PCD_TXSYNC_RISING 0x00000020 /* Sample Tx frame sync on + * TCLK rising edge */ +#define MUSYCC_PCD_RXDATA_RISING 0x00000040 /* Sample Rx data on RCLK + * rising edge */ +#define MUSYCC_PCD_RXSYNC_RISING 0x00000080 /* Sample Rx frame sync on + * RCLK rising edge */ +#define MUSYCC_PCD_ROOF_RISING 0x00000100 /* Sample Rx Out Of Frame + * signal on RCLK rising edge */ +#define MUSYCC_PCD_TX_DRIVEN 0x00000200 /* No mapped timeslots causes + * logic 1 on output, else + * tristate */ +#define MUSYCC_PCD_PORTMODE_MASK 0xfffffff8 /* For changing the port mode + * between E1 and T1 */ + +/* Time Slot Descriptor bit macros */ +#define MUSYCC_TSD_MODE_64KBPS 4 +#define MUSYCC_TSD_MODE_56KBPS 5 +#define MUSYCC_TSD_SUBCHANNEL_WO_FIRST 6 +#define MUSYCC_TSD_SUBCHANNEL_WITH_FIRST 7 + +/* Message Descriptor bit macros */ +#define MUSYCC_MDT_BASE03_ADDR 0x00006000 + +/* Channel Config Descriptor bit macros */ +#define MUSYCC_CCD_BUFIRQ_DISABLE 0x00000002 /* BUFF and ONR irqs disabled */ +#define MUSYCC_CCD_EOMIRQ_DISABLE 0x00000004 /* EOM irq disabled */ +#define MUSYCC_CCD_MSGIRQ_DISABLE 0x00000008 /* LNG, FCS, ALIGN, and ABT + * irqs disabled */ +#define MUSYCC_CCD_IDLEIRQ_DISABLE 0x00000010 /* CHABT, CHIC, and SHT irqs + * disabled */ +#define MUSYCC_CCD_FILTIRQ_DISABLE 0x00000020 /* SFILT irq disabled */ +#define MUSYCC_CCD_SDECIRQ_DISABLE 0x00000040 /* SDEC irq disabled */ +#define MUSYCC_CCD_SINCIRQ_DISABLE 0x00000080 /* SINC irq disabled */ +#define MUSYCC_CCD_SUERIRQ_DISABLE 0x00000100 /* SUERR irq disabled */ +#define MUSYCC_CCD_FCS_XFER 0x00000200 /* Propagate FCS along with + * received data */ +#define MUSYCC_CCD_PROTO_SHIFT 12 /* Position index for protocol bit + * field */ +#define MUSYCC_CCD_TRANS 0 /* Protocol mode in bits 12-14 */ +#define MUSYCC_CCD_SS7 1 +#define MUSYCC_CCD_HDLC_FCS16 2 +#define MUSYCC_CCD_HDLC_FCS32 3 +#define MUSYCC_CCD_EOPIRQ_DISABLE 0x00008000 /* EOP irq disabled */ +#define MUSYCC_CCD_INVERT_DATA 0x00800000 /* Invert data */ +#define MUSYCC_CCD_MAX_LENGTH 10 /* Position index for max length bit + * field */ +#define MUSYCC_CCD_BUFFER_LENGTH 16 /* Position index for internal data + * buffer length */ +#define MUSYCC_CCD_BUFFER_LOC 24 /* Position index for internal data + * buffer starting location */ + +/**************************************************************************** + * Interrupt Descriptor Information */ + +#define INT_EMPTY_ENTRY 0xfeedface +#define INT_EMPTY_ENTRY2 0xdeadface + +/**************************************************************************** + * Interrupt Status Descriptor + * + * NOTE: One must first fetch the value of the interrupt status descriptor + * into a local variable, then pass that value into the read macros. This + * is required to avoid race conditions. + ***/ + +#define INTRPTS_NEXTINT_M 0x7FFF0000 +#define INTRPTS_NEXTINT_S 16 +#define INTRPTS_NEXTINT(x) ((x & INTRPTS_NEXTINT_M) >> INTRPTS_NEXTINT_S) + +#define INTRPTS_INTFULL_M 0x00008000 +#define INTRPTS_INTFULL_S 15 +#define INTRPTS_INTFULL(x) ((x & INTRPTS_INTFULL_M) >> INTRPTS_INTFULL_S) + +#define INTRPTS_INTCNT_M 0x00007FFF +#define INTRPTS_INTCNT_S 0 +#define INTRPTS_INTCNT(x) ((x & INTRPTS_INTCNT_M) >> INTRPTS_INTCNT_S) + + +/**************************************************************************** + * Interrupt Descriptor + ***/ + +#define INTRPT_DIR_M 0x80000000 +#define INTRPT_DIR_S 31 +#define INTRPT_DIR(x) ((x & INTRPT_DIR_M) >> INTRPT_DIR_S) + +#define INTRPT_GRP_M 0x60000000 +#define INTRPT_GRP_MSB_M 0x00004000 +#define INTRPT_GRP_S 29 +#define INTRPT_GRP_MSB_S 12 +#define INTRPT_GRP(x) (((x & INTRPT_GRP_M) >> INTRPT_GRP_S) | \ + ((x & INTRPT_GRP_MSB_M) >> INTRPT_GRP_MSB_S)) + +#define INTRPT_CH_M 0x1F000000 +#define INTRPT_CH_S 24 +#define INTRPT_CH(x) ((x & INTRPT_CH_M) >> INTRPT_CH_S) + +#define INTRPT_EVENT_M 0x00F00000 +#define INTRPT_EVENT_S 20 +#define INTRPT_EVENT(x) ((x & INTRPT_EVENT_M) >> INTRPT_EVENT_S) + +#define INTRPT_ERROR_M 0x000F0000 +#define INTRPT_ERROR_S 16 +#define INTRPT_ERROR(x) ((x & INTRPT_ERROR_M) >> INTRPT_ERROR_S) + +#define INTRPT_ILOST_M 0x00008000 +#define INTRPT_ILOST_S 15 +#define INTRPT_ILOST(x) ((x & INTRPT_ILOST_M) >> INTRPT_ILOST_S) + +#define INTRPT_PERR_M 0x00004000 +#define INTRPT_PERR_S 14 +#define INTRPT_PERR(x) ((x & INTRPT_PERR_M) >> INTRPT_PERR_S) + +#define INTRPT_BLEN_M 0x00003FFF +#define INTRPT_BLEN_S 0 +#define INTRPT_BLEN(x) ((x & INTRPT_BLEN_M) >> INTRPT_BLEN_S) + + +/* Buffer Descriptor bit macros */ +#define OWNER_BIT 0x80000000 /* Set for MUSYCC owner on xmit, host + * owner on receive */ +#define HOST_TX_OWNED 0x00000000 /* Host owns descriptor */ +#define MUSYCC_TX_OWNED 0x80000000 /* MUSYCC owns descriptor */ +#define HOST_RX_OWNED 0x80000000 /* Host owns descriptor */ +#define MUSYCC_RX_OWNED 0x00000000 /* MUSYCC owns descriptor */ + +#define POLL_DISABLED 0x40000000 /* MUSYCC not allowed to poll buffer + * for ownership */ +#define EOMIRQ_ENABLE 0x20000000 /* This buffer contains the end of + * the message */ +#define EOBIRQ_ENABLE 0x10000000 /* EOB irq enabled */ +#define PADFILL_ENABLE 0x01000000 /* Enable padfill */ +#define REPEAT_BIT 0x00008000 /* Bit on for FISU descriptor */ +#define LENGTH_MASK 0X3fff /* This part of status descriptor is + * length */ +#define IDLE_CODE 25 /* Position index for idle code (2 + * bits) */ +#define EXTRA_FLAGS 16 /* Position index for minimum flags + * between messages (8 bits) */ +#define IDLE_CODE_MASK 0x03 /* Gets rid of garbage before the + * pattern is OR'd in */ +#define EXTRA_FLAGS_MASK 0xff /* Gets rid of garbage before the + * pattern is OR'd in */ +#define PCI_PERMUTED_OWNER_BIT 0x00000080 /* For flipping the bit on + * the polled mode descriptor */ + +/* Service Request Descriptor bit macros */ +#define SREQ 8 /* Position index for service request bit + * field */ +#define SR_NOOP (0<<(SREQ)) /* No Operation. Generates SACK */ +#define SR_CHIP_RESET (1<<(SREQ)) /* Soft chip reset */ +#define SR_GROUP_RESET (2<<(SREQ)) /* Group reset */ +#define SR_GLOBAL_INIT (4<<(SREQ)) /* Global init: read global + * config deswc and interrupt + * queue desc */ +#define SR_GROUP_INIT (5<<(SREQ)) /* Group init: read Timeslot + * and Subchannel maps, + * Channel Config, */ + /* + * Group Config, Memory Protect, Message Length, and Port Config + * Descriptors + */ +#define SR_CHANNEL_ACTIVATE (8<<(SREQ)) /* Init channel, read Head + * Pointer, process first + * Message Descriptor */ +#define SR_GCHANNEL_MASK 0x001F /* channel portion (gchan) */ +#define SR_CHANNEL_DEACTIVATE (9<<(SREQ)) /* Stop channel processing */ +#define SR_JUMP (10<<(SREQ)) /* a: Process new Message + * List */ +#define SR_CHANNEL_CONFIG (11<<(SREQ)) /* b: Read channel + * Configuration Descriptor */ +#define SR_GLOBAL_CONFIG (16<<(SREQ)) /* 10: Read Global + * Configuration Descriptor */ +#define SR_INTERRUPT_Q (17<<(SREQ)) /* 11: Read Interrupt Queue + * Descriptor */ +#define SR_GROUP_CONFIG (18<<(SREQ)) /* 12: Read Group + * Configuration Descriptor */ +#define SR_MEMORY_PROTECT (19<<(SREQ)) /* 13: Read Memory Protection + * Descriptor */ +#define SR_MESSAGE_LENGTH (20<<(SREQ)) /* 14: Read Message Length + * Descriptor */ +#define SR_PORT_CONFIG (21<<(SREQ)) /* 15: Read Port + * Configuration Descriptor */ +#define SR_TIMESLOT_MAP (24<<(SREQ)) /* 18: Read Timeslot Map */ +#define SR_SUBCHANNEL_MAP (25<<(SREQ)) /* 19: Read Subchannel Map */ +#define SR_CHAN_CONFIG_TABLE (26<<(SREQ)) /* 20: Read Channel + * Configuration Table for + * the group */ +#define SR_TX_DIRECTION 0x00000020 /* Transmit direction bit. + * Bit off indicates receive + * direction */ +#define SR_RX_DIRECTION 0x00000000 + +/* Interrupt Descriptor bit macros */ +#define GROUP10 29 /* Position index for the 2 LS group + * bits */ +#define CHANNEL 24 /* Position index for channel bits */ +#define INT_IQD_TX 0x80000000 +#define INT_IQD_GRP 0x60000000 +#define INT_IQD_CHAN 0x1f000000 +#define INT_IQD_EVENT 0x00f00000 +#define INT_IQD_ERROR 0x000f0000 +#define INT_IQD_ILOST 0x00008000 +#define INT_IQD_PERR 0x00004000 +#define INT_IQD_BLEN 0x00003fff + +/* Interrupt Descriptor Events */ +#define EVE_EVENT 20 /* Position index for event bits */ +#define EVE_NONE 0 /* No event to report in this + * interrupt */ +#define EVE_SACK 1 /* Service Request acknowledge */ +#define EVE_EOB 2 /* End of Buffer */ +#define EVE_EOM 3 /* End of Message */ +#define EVE_EOP 4 /* End of Padfill */ +#define EVE_CHABT 5 /* Change to Abort Code */ +#define EVE_CHIC 6 /* Change to Idle Code */ +#define EVE_FREC 7 /* Frame Recovery */ +#define EVE_SINC 8 /* MTP2 SUERM Increment */ +#define EVE_SDEC 9 /* MTP2 SUERM Decrement */ +#define EVE_SFILT 10 /* MTP2 SUERM Filtered Message */ +/* Interrupt Descriptor Errors */ +#define ERR_ERRORS 16 /* Position index for error bits */ +#define ERR_BUF 1 /* Buffer Error */ +#define ERR_COFA 2 /* Change of Frame Alignment Error */ +#define ERR_ONR 3 /* Owner Bit Error */ +#define ERR_PROT 4 /* Memory Protection Error */ +#define ERR_OOF 8 /* Out of Frame Error */ +#define ERR_FCS 9 /* FCS Error */ +#define ERR_ALIGN 10 /* Octet Alignment Error */ +#define ERR_ABT 11 /* Abort Termination */ +#define ERR_LNG 12 /* Long Message Error */ +#define ERR_SHT 13 /* Short Message Error */ +#define ERR_SUERR 14 /* SUERM threshold exceeded */ +#define ERR_PERR 15 /* PCI Parity Error */ +/* Other Stuff */ +#define TRANSMIT_DIRECTION 0x80000000 /* Transmit direction bit. Bit off + * indicates receive direction */ +#define ILOST 0x00008000 /* Interrupt Lost */ +#define GROUPMSB 0x00004000 /* Group number MSB */ +#define SACK_IMAGE 0x00100000 /* Used in IRQ for semaphore test */ +#define INITIAL_STATUS 0x10000 /* IRQ status should be this after + * reset */ + +/* This must be defined on an entire channel group (Port) basis */ +#define SUERM_THRESHOLD 0x1f + +#ifdef __cplusplus +} +#endif + +#undef VINT32 +#undef VINT8 + +#endif /*** _INC_MUSYCC_H_ ***/ + +/*** End-of-File ***/ diff --git a/drivers/staging/cxt1e1/ossiRelease.c b/drivers/staging/cxt1e1/ossiRelease.c new file mode 100644 index 000000000000..a56029866c2d --- /dev/null +++ b/drivers/staging/cxt1e1/ossiRelease.c @@ -0,0 +1,39 @@ +/* + * $Id: ossiRelease.c,v 1.2 2008/05/08 20:14:03 rdobbs PMCC4_3_1B $ + */ + +/*----------------------------------------------------------------------------- + * ossiRelease.c - + * + * This string will be embedded into the executable and will track the + * release. The embedded string may be displayed using the following: + * + * strings <filename> | grep \$Rel + * + * Copyright (C) 2002-2008 One Stop Systems, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + * + * For further information, contact via email: support@onestopsystems.com + * One Stop Systems, Inc. Escondido, California U.S.A. + * + *----------------------------------------------------------------------------- + * RCS info: + * RCS revision: $Revision: 1.2 $ + * Last changed on $Date: 2008/05/08 20:14:03 $ + * Changed by $Author: rdobbs $ + *----------------------------------------------------------------------------- + */ + + +char pmcc4_OSSI_release[] = "$Release: PMCC4_3_1B, Copyright (c) 2008 One Stop Systems$"; + +/*** End-of-File ***/ diff --git a/drivers/staging/cxt1e1/pmc93x6_eeprom.c b/drivers/staging/cxt1e1/pmc93x6_eeprom.c new file mode 100644 index 000000000000..02c829b318b4 --- /dev/null +++ b/drivers/staging/cxt1e1/pmc93x6_eeprom.c @@ -0,0 +1,559 @@ +/* pmc93x6_eeprom.c - PMC's 93LC46 EEPROM Device + * + * The 93LC46 is a low-power, serial Electrically Erasable and + * Programmable Read Only Memory organized as 128 8-bit bytes. + * + * Accesses to the 93LC46 are done in a bit serial stream, organized + * in a 3 wire format. Writes are internally timed by the device + * (the In data bit is pulled low until the write is complete and + * then is pulled high) and take about 6 milliseconds. + * + * Copyright (C) 2003-2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + */ + +#include <linux/types.h> +#include "pmcc4_sysdep.h" +#include "sbecom_inline_linux.h" +#include "pmcc4.h" +#include "sbe_promformat.h" + +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif + +#ifdef SBE_INCLUDE_SYMBOLS +#define STATIC +#else +#define STATIC static +#endif + + +/*------------------------------------------------------------------------ + * EEPROM address definitions + *------------------------------------------------------------------------ + * + * The offset in the definitions below allows the test to skip over + * areas of the EEPROM that other programs (such a VxWorks) are + * using. + */ + +#define EE_MFG (long)0 /* Index to manufacturing record */ +#define EE_FIRST 0x28 /* Index to start testing at */ +#define EE_LIMIT 128 /* Index to end testing at */ + + +/* Bit Ordering for Instructions +** +** A0, A1, A2, A3, A4, A5, A6, OP0, OP1, SB (lsb, or 1st bit out) +** +*/ + +#define EPROM_EWEN 0x0019 /* Erase/Write enable (reversed) */ +#define EPROM_EWDS 0x0001 /* Erase/Write disable (reversed) */ +#define EPROM_READ 0x0003 /* Read (reversed) */ +#define EPROM_WRITE 0x0005 /* Write (reversed) */ +#define EPROM_ERASE 0x0007 /* Erase (reversed) */ +#define EPROM_ERAL 0x0009 /* Erase All (reversed) */ +#define EPROM_WRAL 0x0011 /* Write All (reversed) */ + +#define EPROM_ADR_SZ 7 /* Number of bits in offset address */ +#define EPROM_OP_SZ 3 /* Number of bits in command */ +#define SIZE_ADDR_OP (EPROM_ADR_SZ + EPROM_OP_SZ) +#define LC46A_MAX_OPS 10 /* Number of bits in Instruction */ +#define NUM_OF_BITS 8 /* Number of bits in data */ + + +/* EEPROM signal bits */ +#define EPROM_ACTIVE_OUT_BIT 0x0001 /* Out data bit */ +#define EPROM_ACTIVE_IN_BIT 0x0002 /* In data bit */ +#define ACTIVE_IN_BIT_SHIFT 0x0001 /* Shift In data bit to LSB */ +#define EPROM_ENCS 0x0004 /* Set EEPROM CS during operation */ + + +/*------------------------------------------------------------------------ + * The ByteReverse table is used to reverses the 8 bits within a byte + *------------------------------------------------------------------------ + */ + +static unsigned char ByteReverse[256]; +static int ByteReverseBuilt = FALSE; + + +/*------------------------------------------------------------------------ + * mfg_template - initial serial EEPROM data structure + *------------------------------------------------------------------------ + */ + +short mfg_template[sizeof (FLD_TYPE2)] = +{ + PROM_FORMAT_TYPE2, /* type; */ + 0x00, 0x1A, /* length[2]; */ + 0x00, 0x00, 0x00, 0x00, /* Crc32[4]; */ + 0x11, 0x76, /* Id[2]; */ + 0x07, 0x05, /* SubId[2] E1; */ + 0x00, 0xA0, 0xD6, 0x00, 0x00, 0x00, /* Serial[6]; */ + 0x00, 0x00, 0x00, 0x00, /* CreateTime[4]; */ + 0x00, 0x00, 0x00, 0x00, /* HeatRunTime[4]; */ + 0x00, 0x00, 0x00, 0x00, /* HeatRunIterations[4]; */ + 0x00, 0x00, 0x00, 0x00, /* HeatRunErrors[4]; */ +}; + + +/*------------------------------------------------------------------------ + * BuildByteReverse - build the 8-bit reverse table + *------------------------------------------------------------------------ + * + * The 'ByteReverse' table reverses the 8 bits within a byte + * (the MSB becomes the LSB etc.). + */ + +STATIC void +BuildByteReverse (void) +{ + long half; /* Used to build by powers to 2 */ + int i; + + ByteReverse[0] = 0; + + for (half = 1; half < sizeof (ByteReverse); half <<= 1) + for (i = 0; i < half; i++) + ByteReverse[half + i] = (char) (ByteReverse[i] | (0x80 / half)); + + ByteReverseBuilt = TRUE; +} + + +/*------------------------------------------------------------------------ + * eeprom_delay - small delay for EEPROM timing + *------------------------------------------------------------------------ + */ + +STATIC void +eeprom_delay (void) +{ + int timeout; + + for (timeout = 20; timeout; --timeout) + { + OS_uwait_dummy (); + } +} + + +/*------------------------------------------------------------------------ + * eeprom_put_byte - Send a byte to the EEPROM serially + *------------------------------------------------------------------------ + * + * Given the PCI address and the data, this routine serially sends + * the data to the EEPROM. + */ + +void +eeprom_put_byte (long addr, long data, int count) +{ + u_int32_t output; + + while (--count >= 0) + { + output = (data & EPROM_ACTIVE_OUT_BIT) ? 1 : 0; /* Get next data bit */ + output |= EPROM_ENCS; /* Add Chip Select */ + data >>= 1; + + eeprom_delay (); + pci_write_32 ((u_int32_t *) addr, output); /* Output it */ + } +} + + +/*------------------------------------------------------------------------ + * eeprom_get_byte - Receive a byte from the EEPROM serially + *------------------------------------------------------------------------ + * + * Given the PCI address, this routine serially fetches the data + * from the EEPROM. + */ + +u_int32_t +eeprom_get_byte (long addr) +{ + u_int32_t input; + u_int32_t data; + int count; + +/* Start the Reading of DATA +** +** The first read is a dummy as the data is latched in the +** EPLD and read on the next read access to the EEPROM. +*/ + + input = pci_read_32 ((u_int32_t *) addr); + + data = 0; + count = NUM_OF_BITS; + while (--count >= 0) + { + eeprom_delay (); + input = pci_read_32 ((u_int32_t *) addr); + + data <<= 1; /* Shift data over */ + data |= (input & EPROM_ACTIVE_IN_BIT) ? 1 : 0; + + } + + return data; +} + + +/*------------------------------------------------------------------------ + * disable_pmc_eeprom - Disable writes to the EEPROM + *------------------------------------------------------------------------ + * + * Issue the EEPROM command to disable writes. + */ + +STATIC void +disable_pmc_eeprom (long addr) +{ + eeprom_put_byte (addr, EPROM_EWDS, SIZE_ADDR_OP); + + pci_write_32 ((u_int32_t *) addr, 0); /* this removes Chip Select + * from EEPROM */ +} + + +/*------------------------------------------------------------------------ + * enable_pmc_eeprom - Enable writes to the EEPROM + *------------------------------------------------------------------------ + * + * Issue the EEPROM command to enable writes. + */ + +STATIC void +enable_pmc_eeprom (long addr) +{ + eeprom_put_byte (addr, EPROM_EWEN, SIZE_ADDR_OP); + + pci_write_32 ((u_int32_t *) addr, 0); /* this removes Chip Select + * from EEPROM */ +} + + +/*------------------------------------------------------------------------ + * pmc_eeprom_read - EEPROM location read + *------------------------------------------------------------------------ + * + * Given a EEPROM PCI address and location offset, this routine returns + * the contents of the specified location to the calling routine. + */ + +u_int32_t +pmc_eeprom_read (long addr, long mem_offset) +{ + u_int32_t data; /* Data from chip */ + + if (!ByteReverseBuilt) + BuildByteReverse (); + + mem_offset = ByteReverse[0x7F & mem_offset]; /* Reverse address */ + /* + * NOTE: The max offset address is 128 or half the reversal table. So the + * LSB is always zero and counts as a built in shift of one bit. So even + * though we need to shift 3 bits to make room for the command, we only + * need to shift twice more because of the built in shift. + */ + mem_offset <<= 2; /* Shift for command */ + mem_offset |= EPROM_READ; /* Add command */ + + eeprom_put_byte (addr, mem_offset, SIZE_ADDR_OP); /* Output chip address */ + + data = eeprom_get_byte (addr); /* Read chip data */ + + pci_write_32 ((u_int32_t *) addr, 0); /* Remove Chip Select from + * EEPROM */ + + return (data & 0x000000FF); +} + + +/*------------------------------------------------------------------------ + * pmc_eeprom_write - EEPROM location write + *------------------------------------------------------------------------ + * + * Given a EEPROM PCI address, location offset and value, this + * routine writes the value to the specified location. + * + * Note: it is up to the caller to determine if the write + * operation succeeded. + */ + +int +pmc_eeprom_write (long addr, long mem_offset, u_int32_t data) +{ + volatile u_int32_t temp; + int count; + + if (!ByteReverseBuilt) + BuildByteReverse (); + + mem_offset = ByteReverse[0x7F & mem_offset]; /* Reverse address */ + /* + * NOTE: The max offset address is 128 or half the reversal table. So the + * LSB is always zero and counts as a built in shift of one bit. So even + * though we need to shift 3 bits to make room for the command, we only + * need to shift twice more because of the built in shift. + */ + mem_offset <<= 2; /* Shift for command */ + mem_offset |= EPROM_WRITE; /* Add command */ + + eeprom_put_byte (addr, mem_offset, SIZE_ADDR_OP); /* Output chip address */ + + data = ByteReverse[0xFF & data];/* Reverse data */ + eeprom_put_byte (addr, data, NUM_OF_BITS); /* Output chip data */ + + pci_write_32 ((u_int32_t *) addr, 0); /* Remove Chip Select from + * EEPROM */ + +/* +** Must see Data In at a low state before completing this transaction. +** +** Afterwards, the data bit will return to a high state, ~6 ms, terminating +** the operation. +*/ + pci_write_32 ((u_int32_t *) addr, EPROM_ENCS); /* Re-enable Chip Select */ + temp = pci_read_32 ((u_int32_t *) addr); /* discard first read */ + temp = pci_read_32 ((u_int32_t *) addr); + if (temp & EPROM_ACTIVE_IN_BIT) + { + temp = pci_read_32 ((u_int32_t *) addr); + if (temp & EPROM_ACTIVE_IN_BIT) + { + pci_write_32 ((u_int32_t *) addr, 0); /* Remove Chip Select + * from EEPROM */ + return (1); + } + } + count = 1000; + while (count--) + { + for (temp = 0; temp < 0x10; temp++) + OS_uwait_dummy (); + + if (pci_read_32 ((u_int32_t *) addr) & EPROM_ACTIVE_IN_BIT) + break; + } + + if (count == -1) + return (2); + + return (0); +} + + +/*------------------------------------------------------------------------ + * pmcGetBuffValue - read the specified value from buffer + *------------------------------------------------------------------------ + */ + +long +pmcGetBuffValue (char *ptr, int size) +{ + long value = 0; + int index; + + for (index = 0; index < size; ++index) + { + value <<= 8; + value |= ptr[index] & 0xFF; + } + + return value; +} + + +/*------------------------------------------------------------------------ + * pmcSetBuffValue - save the specified value to buffer + *------------------------------------------------------------------------ + */ + +void +pmcSetBuffValue (char *ptr, long value, int size) +{ + int index = size; + + while (--index >= 0) + { + ptr[index] = (char) (value & 0xFF); + value >>= 8; + } +} + + +/*------------------------------------------------------------------------ + * pmc_eeprom_read_buffer - read EEPROM data into specified buffer + *------------------------------------------------------------------------ + */ + +void +pmc_eeprom_read_buffer (long addr, long mem_offset, char *dest_ptr, int size) +{ + while (--size >= 0) + *dest_ptr++ = (char) pmc_eeprom_read (addr, mem_offset++); +} + + +/*------------------------------------------------------------------------ + * pmc_eeprom_write_buffer - write EEPROM data from specified buffer + *------------------------------------------------------------------------ + */ + +void +pmc_eeprom_write_buffer (long addr, long mem_offset, char *dest_ptr, int size) +{ + enable_pmc_eeprom (addr); + + while (--size >= 0) + pmc_eeprom_write (addr, mem_offset++, *dest_ptr++); + + disable_pmc_eeprom (addr); +} + + +/*------------------------------------------------------------------------ + * pmcCalcCrc - calculate the CRC for the serial EEPROM structure + *------------------------------------------------------------------------ + */ + +u_int32_t +pmcCalcCrc_T01 (void *bufp) +{ + FLD_TYPE2 *buf = bufp; + u_int32_t crc; /* CRC of the structure */ + + /* Calc CRC for type and length fields */ + sbeCrc ( + (u_int8_t *) &buf->type, + (u_int32_t) STRUCT_OFFSET (FLD_TYPE1, Crc32), + (u_int32_t) 0, + (u_int32_t *) &crc); + +#ifdef EEPROM_TYPE_DEBUG + printk ("sbeCrc: crc 1 calculated as %08x\n", crc); /* RLD DEBUG */ +#endif + return ~crc; +} + +u_int32_t +pmcCalcCrc_T02 (void *bufp) +{ + FLD_TYPE2 *buf = bufp; + u_int32_t crc; /* CRC of the structure */ + + /* Calc CRC for type and length fields */ + sbeCrc ( + (u_int8_t *) &buf->type, + (u_int32_t) STRUCT_OFFSET (FLD_TYPE2, Crc32), + (u_int32_t) 0, + (u_int32_t *) &crc); + + /* Calc CRC for remaining fields */ + sbeCrc ( + (u_int8_t *) &buf->Id[0], + (u_int32_t) (sizeof (FLD_TYPE2) - STRUCT_OFFSET (FLD_TYPE2, Id)), + (u_int32_t) crc, + (u_int32_t *) &crc); + +#ifdef EEPROM_TYPE_DEBUG + printk ("sbeCrc: crc 2 calculated as %08x\n", crc); /* RLD DEBUG */ +#endif + return crc; +} + + +/*------------------------------------------------------------------------ + * pmc_init_seeprom - initialize the serial EEPROM structure + *------------------------------------------------------------------------ + * + * At the front of the serial EEPROM there is a record that contains + * manufacturing information. If the info does not already exist, it + * is created. The only field modifiable by the operator is the + * serial number field. + */ + +void +pmc_init_seeprom (u_int32_t addr, u_int32_t serialNum) +{ + PROMFORMAT buffer; /* Memory image of structure */ + u_int32_t crc; /* CRC of structure */ + 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) + buffer.bytes[i] = mfg_template[i]; + + /* Update serial number field in buffer */ + pmcSetBuffValue (&buffer.fldType2.Serial[3], serialNum, 3); + + /* Update create time field in buffer */ + pmcSetBuffValue (&buffer.fldType2.CreateTime[0], createTime, 4); + + /* Update CRC field in buffer */ + crc = pmcCalcCrc_T02 (&buffer); + pmcSetBuffValue (&buffer.fldType2.Crc32[0], crc, 4); + +#ifdef DEBUG + for (i = 0; i < sizeof (FLD_TYPE2); ++i) + printk ("[%02X] = %02X\n", i, buffer.bytes[i] & 0xFF); +#endif + + /* Write structure to serial EEPROM */ + pmc_eeprom_write_buffer (addr, EE_MFG, (char *) &buffer, sizeof (FLD_TYPE2)); +} + + +char +pmc_verify_cksum (void *bufp) +{ + FLD_TYPE1 *buf1 = bufp; + FLD_TYPE2 *buf2 = bufp; + u_int32_t crc1, crc2; /* CRC read from EEPROM */ + + /* Retrieve contents of CRC field */ + crc1 = pmcGetBuffValue (&buf1->Crc32[0], sizeof (buf1->Crc32)); +#ifdef EEPROM_TYPE_DEBUG + printk ("EEPROM: chksum 1 reads as %08x\n", crc1); /* RLD DEBUG */ +#endif + if ((buf1->type == PROM_FORMAT_TYPE1) && + (pmcCalcCrc_T01 ((void *) buf1) == crc1)) + return PROM_FORMAT_TYPE1; /* checksum type 1 verified */ + + crc2 = pmcGetBuffValue (&buf2->Crc32[0], sizeof (buf2->Crc32)); +#ifdef EEPROM_TYPE_DEBUG + printk ("EEPROM: chksum 2 reads as %08x\n", crc2); /* RLD DEBUG */ +#endif + if ((buf2->type == PROM_FORMAT_TYPE2) && + (pmcCalcCrc_T02 ((void *) buf2) == crc2)) + return PROM_FORMAT_TYPE2; /* checksum type 2 verified */ + + return PROM_FORMAT_Unk; /* failed to validate */ +} + + +/*** End-of-File ***/ diff --git a/drivers/staging/cxt1e1/pmc93x6_eeprom.h b/drivers/staging/cxt1e1/pmc93x6_eeprom.h new file mode 100644 index 000000000000..c3ada87efd26 --- /dev/null +++ b/drivers/staging/cxt1e1/pmc93x6_eeprom.h @@ -0,0 +1,60 @@ +/* + * $Id: pmc93x6_eeprom.h,v 1.1 2005/09/28 00:10:08 rickd PMCC4_3_1B $ + */ + +#ifndef _INC_PMC93X6_EEPROM_H_ +#define _INC_PMC93X6_EEPROM_H_ + +/*----------------------------------------------------------------------------- + * pmc93x6_eeprom.h - + * + * Copyright (C) 2002-2004 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + * + * For further information, contact via email: support@sbei.com + * SBE, Inc. San Ramon, California U.S.A. + *----------------------------------------------------------------------------- + * RCS info: + *----------------------------------------------------------------------------- + * $Log: pmc93x6_eeprom.h,v $ + * Revision 1.1 2005/09/28 00:10:08 rickd + * pmc_verify_cksum return value is char. + * + * Revision 1.0 2005/05/04 17:20:51 rickd + * Initial revision + * + * Revision 1.0 2005/04/22 23:48:48 rickd + * Initial revision + * + *----------------------------------------------------------------------------- + */ + +#if defined (__FreeBSD__) || defined (__NetBSD__) +#include <sys/types.h> +#else +#include <linux/types.h> +#endif + +#ifdef __KERNEL__ + +#include "pmcc4_private.h" + +void pmc_eeprom_read_buffer (long, long, char *, int); +void pmc_eeprom_write_buffer (long, long, char *, int); +void pmc_init_seeprom (u_int32_t, u_int32_t); +char pmc_verify_cksum (void *); + +#endif /*** __KERNEL__ ***/ + +#endif + +/*** End-of-File ***/ diff --git a/drivers/staging/cxt1e1/pmcc4.h b/drivers/staging/cxt1e1/pmcc4.h new file mode 100644 index 000000000000..26c1f0ea72e9 --- /dev/null +++ b/drivers/staging/cxt1e1/pmcc4.h @@ -0,0 +1,155 @@ +/* + * $Id: pmcc4.h,v 1.4 2005/11/01 19:24:48 rickd PMCC4_3_1B $ + */ + +#ifndef _INC_PMCC4_H_ +#define _INC_PMCC4_H_ + +/*----------------------------------------------------------------------------- + * pmcc4.h - + * + * Copyright (C) 2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + * + * For further information, contact via email: support@sbei.com + * SBE, Inc. San Ramon, California U.S.A. + *----------------------------------------------------------------------------- + * RCS info: + * RCS revision: $Revision: 1.4 $ + * Last changed on $Date: 2005/11/01 19:24:48 $ + * Changed by $Author: rickd $ + *----------------------------------------------------------------------------- + * $Log: pmcc4.h,v $ + * Revision 1.4 2005/11/01 19:24:48 rickd + * Remove de-implement function prototypes. Several <int> to + * <status_t> changes for consistant usage of same. + * + * Revision 1.3 2005/09/28 00:10:08 rickd + * Add GNU license info. Use config params from libsbew.h + * + * Revision 1.2 2005/04/28 23:43:03 rickd + * Add RCS tracking heading. + * + *----------------------------------------------------------------------------- + */ + + +#if defined(__FreeBSD__) || defined(__NetBSD__) +#include <sys/types.h> +#else +#ifndef __KERNEL__ +#include <sys/types.h> +#else +#include <linux/types.h> +#endif +#endif + + + +typedef int status_t; + +#define SBE_DRVR_FAIL 0 +#define SBE_DRVR_SUCCESS 1 + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/********************/ +/* PMCC4 memory Map */ +/********************/ + +#define COMET_OFFSET(x) (0x80000+(x)*0x10000) +#define EEPROM_OFFSET 0xC0000 +#define CPLD_OFFSET 0xD0000 + + struct pmcc4_timeslot_param + { + u_int8_t card; /* the card number */ + u_int8_t port; /* the port number */ + u_int8_t _reserved1; + u_int8_t _reserved2; + + /* + * each byte in bitmask below represents one timeslot (bitmask[0] is + * for timeslot 0 and so on), each bit in the byte selects timeslot + * bits for this channel (0xff - whole timeslot, 0x7f - 56kbps mode) + */ + u_int8_t bitmask[32]; + }; + + struct c4_musycc_param + { + u_int8_t RWportnum; + u_int16_t offset; + u_int32_t value; + }; + +/*Alarm values */ +#define sbeE1RMAI 0x100 +#define sbeYelAlm 0x04 +#define sbeRedAlm 0x02 +#define sbeAISAlm 0x01 + +#define sbeE1errSMF 0x02 +#define sbeE1CRC 0x01 + +#ifdef __cplusplus +} +#endif + +#ifdef __KERNEL__ + +/* + * Device Driver interface, routines are for internal use only. + */ + +#include "pmcc4_private.h" + +#if !(LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) +char *get_hdlc_name (hdlc_device *); + +#endif + + +/* + * external interface + */ + +void c4_cleanup (void); +status_t c4_chan_up (ci_t *, int channum); +status_t c4_del_chan_stats (int channum); +status_t c4_del_chan (int channum); +status_t c4_get_iidinfo (ci_t * ci, struct sbe_iid_info * iip); +int c4_is_chan_up (int channum); + +void *getuserbychan (int channum); +void pci_flush_write (ci_t * ci); +void sbecom_set_loglevel (int debuglevel); +char *sbeid_get_bdname (ci_t * ci); +void sbeid_set_bdtype (ci_t * ci); +void sbeid_set_hdwbid (ci_t * ci); +u_int32_t sbeCrc (u_int8_t *, u_int32_t, u_int32_t, u_int32_t *); + +void VMETRO_TRACE (void *); /* put data into 8 LEDs */ +void VMETRO_TRIGGER (ci_t *, int); /* Note: int = 0(default) + * thru 15 */ + +#if defined (SBE_ISR_TASKLET) +void musycc_intr_bh_tasklet (ci_t *); + +#endif + +#endif /*** __KERNEL __ ***/ +#endif /* _INC_PMCC4_H_ */ diff --git a/drivers/staging/cxt1e1/pmcc4_cpld.h b/drivers/staging/cxt1e1/pmcc4_cpld.h new file mode 100644 index 000000000000..6d8f0337aa3e --- /dev/null +++ b/drivers/staging/cxt1e1/pmcc4_cpld.h @@ -0,0 +1,124 @@ +/* + * $Id: pmcc4_cpld.h,v 1.0 2005/09/28 00:10:08 rickd PMCC4_3_1B $ + */ + +#ifndef _INC_PMCC4_CPLD_H_ +#define _INC_PMCC4_CPLD_H_ + +/*----------------------------------------------------------------------------- + * pmcc4_cpld.h - + * + * Copyright (C) 2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + * + * For further information, contact via email: support@sbei.com + * SBE, Inc. San Ramon, California U.S.A. + *----------------------------------------------------------------------------- + * RCS info: + * RCS revision: $Revision: 1.0 $ + * Last changed on $Date: 2005/09/28 00:10:08 $ + * Changed by $Author: rickd $ + *----------------------------------------------------------------------------- + * $Log: pmcc4_cpld.h,v $ + * Revision 1.0 2005/09/28 00:10:08 rickd + * Initial revision + * + *----------------------------------------------------------------------------- + */ + + +#if defined(__FreeBSD__) || defined(__NetBSD__) +#include <sys/types.h> +#else +#ifndef __KERNEL__ +#include <sys/types.h> +#else +#include <linux/types.h> +#endif +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + + +/********************************/ +/* iSPLD control chip registers */ +/********************************/ + +#if 0 +#define CPLD_MCSR 0x0 +#define CPLD_MCLK 0x1 +#define CPLD_LEDS 0x2 +#define CPLD_INTR 0x3 +#endif + + struct c4_cpld + { + volatile u_int32_t mcsr;/* r/w: Master Clock Source Register */ + volatile u_int32_t mclk;/* r/w: Master Clock Register */ + volatile u_int32_t leds;/* r/w: LED Register */ + volatile u_int32_t intr;/* r: Interrupt Register */ + }; + + typedef struct c4_cpld c4cpld_t; + +/* mcsr note: sourcing COMET must be initialized to Master Mode */ +#define PMCC4_CPLD_MCSR_IND 0 /* ports used individual BP Clk as + * source, no slaves */ +#define PMCC4_CPLD_MCSR_CMT_1 1 /* COMET 1 BP Clk is source, 2,3,4 + * are Clk slaves */ +#define PMCC4_CPLD_MCSR_CMT_2 2 /* COMET 2 BP Clk is source, 1,3,4 + * are Clk slaves */ +#define PMCC4_CPLD_MCSR_CMT_3 3 /* COMET 3 BP Clk is source, 1,2,4 + * are Clk slaves */ +#define PMCC4_CPLD_MCSR_CMT_4 4 /* COMET 4 BP Clk is source, 1,2,3 + * are Clk slaves */ + +#define PMCC4_CPLD_MCLK_MASK 0x0f +#define PMCC4_CPLD_MCLK_P1 0x1 +#define PMCC4_CPLD_MCLK_P2 0x2 +#define PMCC4_CPLD_MCLK_P3 0x4 +#define PMCC4_CPLD_MCLK_P4 0x8 +#define PMCC4_CPLD_MCLK_T1 0x00 +#define PMCC4_CPLD_MCLK_P1_E1 0x01 +#define PMCC4_CPLD_MCLK_P2_E1 0x02 +#define PMCC4_CPLD_MCLK_P3_E1 0x04 +#define PMCC4_CPLD_MCLK_P4_E1 0x08 + +#define PMCC4_CPLD_LED_OFF 0 +#define PMCC4_CPLD_LED_ON 1 +#define PMCC4_CPLD_LED_GP0 0x01 /* port 0, green */ +#define PMCC4_CPLD_LED_YP0 0x02 /* port 0, yellow */ +#define PMCC4_CPLD_LED_GP1 0x04 /* port 1, green */ +#define PMCC4_CPLD_LED_YP1 0x08 /* port 1, yellow */ +#define PMCC4_CPLD_LED_GP2 0x10 /* port 2, green */ +#define PMCC4_CPLD_LED_YP2 0x20 /* port 2, yellow */ +#define PMCC4_CPLD_LED_GP3 0x40 /* port 3, green */ +#define PMCC4_CPLD_LED_YP3 0x80 /* port 3, yellow */ +#define PMCC4_CPLD_LED_GREEN (PMCC4_CPLD_LED_GP0 | PMCC4_CPLD_LED_GP1 | \ + PMCC4_CPLD_LED_GP2 | PMCC4_CPLD_LED_GP3 ) +#define PMCC4_CPLD_LED_YELLOW (PMCC4_CPLD_LED_YP0 | PMCC4_CPLD_LED_YP1 | \ + PMCC4_CPLD_LED_YP2 | PMCC4_CPLD_LED_YP3) + +#define PMCC4_CPLD_INTR_MASK 0x0f +#define PMCC4_CPLD_INTR_CMT_1 0x01 +#define PMCC4_CPLD_INTR_CMT_2 0x02 +#define PMCC4_CPLD_INTR_CMT_3 0x04 +#define PMCC4_CPLD_INTR_CMT_4 0x08 + +#ifdef __cplusplus +} +#endif + +#endif /* _INC_PMCC4_CPLD_H_ */ diff --git a/drivers/staging/cxt1e1/pmcc4_defs.h b/drivers/staging/cxt1e1/pmcc4_defs.h new file mode 100644 index 000000000000..186347b8d565 --- /dev/null +++ b/drivers/staging/cxt1e1/pmcc4_defs.h @@ -0,0 +1,82 @@ +/* + * $Id: pmcc4_defs.h,v 1.0 2005/09/28 00:10:09 rickd PMCC4_3_1B $ + */ + +#ifndef _INC_PMCC4_DEFS_H_ +#define _INC_PMCC4_DEFS_H_ + +/*----------------------------------------------------------------------------- + * c4_defs.h - + * + * Implementation elements of the wanPMC-C4T1E1 device driver + * + * Copyright (C) 2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + * + * For further information, contact via email: support@sbei.com + * SBE, Inc. San Ramon, California U.S.A. + *----------------------------------------------------------------------------- + * RCS info: + * RCS revision: $Revision: 1.0 $ + * Last changed on $Date: 2005/09/28 00:10:09 $ + * Changed by $Author: rickd $ + *----------------------------------------------------------------------------- + * $Log: pmcc4_defs.h,v $ + * Revision 1.0 2005/09/28 00:10:09 rickd + * Initial revision + * + *----------------------------------------------------------------------------- + */ + + +#define MAX_BOARDS 8 +#define MAX_CHANS_USED 128 + +#ifdef SBE_PMCC4_ENABLE +#define MUSYCC_NPORTS 4 /* CN8474 */ +#endif +#ifdef SBE_WAN256T3_ENABLE +#define MUSYCC_NPORTS 8 /* CN8478 */ +#endif +#define MUSYCC_NCHANS 32 /* actually, chans per port */ + +#define MUSYCC_NIQD 0x1000 /* power of 2 */ +#define MUSYCC_MRU 2048 /* default */ +#define MUSYCC_MTU 2048 /* default */ +#define MUSYCC_TXDESC_MIN 10 /* HDLC mode default */ +#define MUSYCC_RXDESC_MIN 18 /* HDLC mode default */ +#define MUSYCC_TXDESC_TRANS 4 /* Transparent mode minumum # of TX descriptors */ +#define MUSYCC_RXDESC_TRANS 12 /* Transparent mode minumum # of RX descriptors */ + +#define MAX_DEFAULT_IFQLEN 32 /* network qlen */ + + +#define SBE_IFACETMPL "pmcc4-%d" +#ifdef IFNAMSIZ +#define SBE_IFACETMPL_SIZE IFNAMSIZ +#else +#define SBE_IFACETMPL_SIZE 16 +#endif + +/* we want the PMCC4 watchdog to fire off every 250ms */ +#define WATCHDOG_TIMEOUT 250000 + +/* if we restart the watchdog every 250ms, then we'll time out + * an additional 300ms later */ +#define WATCHDOG_UTIMEOUT (WATCHDOG_TIMEOUT+300000) + +#if !defined(SBE_ISR_TASKLET) && !defined(SBE_ISR_IMMEDIATE) && !defined(SBE_ISR_INLINE) +#define SBE_ISR_TASKLET +#endif + +#endif /*** _INC_PMCC4_DEFS_H_ ***/ + diff --git a/drivers/staging/cxt1e1/pmcc4_drv.c b/drivers/staging/cxt1e1/pmcc4_drv.c new file mode 100644 index 000000000000..ada80d0b6059 --- /dev/null +++ b/drivers/staging/cxt1e1/pmcc4_drv.c @@ -0,0 +1,1855 @@ +/* + * $Id: pmcc4_drv.c,v 3.1 2007/08/15 23:32:17 rickd PMCC4_3_1B $ + */ + + +/*----------------------------------------------------------------------------- + * pmcc4_drv.c - + * + * Copyright (C) 2007 One Stop Systems, Inc. + * Copyright (C) 2002-2006 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + * + * For further information, contact via email: support@onestopsystems.com + * One Stop Systems, Inc. Escondido, California U.S.A. + *----------------------------------------------------------------------------- + * RCS info: + * RCS revision: $Revision: 3.1 $ + * Last changed on $Date: 2007/08/15 23:32:17 $ + * Changed by $Author: rickd $ + *----------------------------------------------------------------------------- + * $Log: pmcc4_drv.c,v $ + * Revision 3.1 2007/08/15 23:32:17 rickd + * Use 'if 0' instead of GNU comment delimeter to avoid line wrap induced compiler errors. + * + * Revision 3.0 2007/08/15 22:19:55 rickd + * Correct sizeof() castings and pi->regram to support 64bit compatibility. + * + * Revision 2.10 2006/04/21 00:56:40 rickd + * workqueue files now prefixed with <sbecom> prefix. + * + * Revision 2.9 2005/11/01 19:22:49 rickd + * Add sanity checks against max_port for ioctl functions. + * + * Revision 2.8 2005/10/27 18:59:25 rickd + * Code cleanup. Default channel config to HDLC_FCS16. + * + * Revision 2.7 2005/10/18 18:16:30 rickd + * Further NCOMM code repairs - (1) interrupt matrix usage inconsistant + * for indexing into nciInterrupt[][], code missing double parameters. + * (2) check input of ncomm interrupt registration cardID for correct + * boundary values. + * + * Revision 2.6 2005/10/17 23:55:28 rickd + * Initial port of NCOMM support patches from original work found + * in pmc_c4t1e1 as updated by NCOMM. Ref: CONFIG_SBE_PMCC4_NCOMM. + * Corrected NCOMMs wanpmcC4T1E1_getBaseAddress() to correctly handle + * multiple boards. + * + * Revision 2.5 2005/10/13 23:01:28 rickd + * Correct panic for illegal address reference w/in get_brdinfo on + * first_if/last_if name acquistion under Linux 2.6 + * + * Revision 2.4 2005/10/13 21:20:19 rickd + * Correction of c4_cleanup() wherein next should be acquired before + * ci_t structure is free'd. + * + * Revision 2.3 2005/10/13 19:20:10 rickd + * Correct driver removal cleanup code for multiple boards. + * + * Revision 2.2 2005/10/11 18:34:04 rickd + * New routine added to determine number of ports (comets) on board. + * + * Revision 2.1 2005/10/05 00:48:13 rickd + * Add some RX activation trace code. + * + * Revision 2.0 2005/09/28 00:10:06 rickd + * Implement 2.6 workqueue for TX/RX restart. Correction to + * hardware register boundary checks allows expanded access of MUSYCC. + * Implement new musycc reg&bits namings. + * + *----------------------------------------------------------------------------- + */ + +char OSSIid_pmcc4_drvc[] = +"@(#)pmcc4_drv.c - $Revision: 3.1 $ (c) Copyright 2002-2007 One Stop Systems, Inc."; + + +#if defined (__FreeBSD__) || defined (__NetBSD__) +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/errno.h> +#else +#include <linux/types.h> +#include "pmcc4_sysdep.h" +#include <linux/errno.h> +#include <linux/kernel.h> +#include <linux/sched.h> /* include for timer */ +#include <linux/timer.h> /* include for timer */ +#include <linux/hdlc.h> +#include <asm/io.h> +#endif + +#include "sbecom_inline_linux.h" +#include "libsbew.h" +#include "pmcc4_private.h" +#include "pmcc4.h" +#include "pmcc4_ioctls.h" +#include "musycc.h" +#include "comet.h" +#include "sbe_bid.h" + +#ifdef SBE_INCLUDE_SYMBOLS +#define STATIC +#else +#define STATIC static +#endif + + +#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); + +u_int32_t musycc_chan_proto (int); +status_t musycc_dump_ring (ci_t *, unsigned int); +status_t __init musycc_init (ci_t *); +void musycc_init_mdt (mpi_t *); +void musycc_serv_req (mpi_t *, u_int32_t); +void musycc_update_timeslots (mpi_t *); + +extern void musycc_update_tx_thp (mch_t *); +extern int log_level; +extern int max_mru; +extern int max_mtu; +extern int max_rxdesc_used, max_rxdesc_default; +extern int max_txdesc_used, max_txdesc_default; + +#if defined (__powerpc__) +extern void *memset (void *s, int c, size_t n); + +#endif + +int drvr_state = SBE_DRVR_INIT; +ci_t *c4_list = 0; +ci_t *CI; /* dummy pointer to board ZEROE's data - + * DEBUG USAGE */ + + +void +sbecom_set_loglevel (int d) +{ + /* + * The code within the following -if- clause is a backdoor debug facility + * which can be used to display the state of a board's channel. + */ + if (d > LOG_DEBUG) + { + unsigned int channum = d - (LOG_DEBUG + 1); /* convert to ZERO + * relativity */ + + (void) musycc_dump_ring ((ci_t *) CI, channum); /* CI implies support + * for card 0 only */ + } else + { + if (log_level != d) + { + printk ("%s: log level changed from %d to %d\n", THIS_MODULE->name, log_level, d); + log_level = d; /* set new */ + } else + printk ("%s: log level is %d\n", THIS_MODULE->name, log_level); + } +} + + +mch_t * +c4_find_chan (int channum) +{ + ci_t *ci; + mch_t *ch; + int portnum, gchan; + + for (ci = c4_list; ci; ci = ci->next) + for (portnum = 0; portnum < ci->max_port; portnum++) + for (gchan = 0; gchan < MUSYCC_NCHANS; gchan++) + { + if ((ch = ci->port[portnum].chan[gchan])) + { + if ((ch->state != UNASSIGNED) && + (ch->channum == channum)) + return (ch); + } + } + return 0; +} + + +ci_t *__init +c4_new (void *hi) +{ + ci_t *ci; + +#ifdef SBE_MAP_DEBUG + printk (KERN_WARNING "%s: c4_new() entered, ci needs %u.\n", + THIS_MODULE->name, (unsigned int) sizeof (ci_t)); +#endif + + ci = (ci_t *) OS_kmalloc (sizeof (ci_t)); + if (ci) + { + ci->hdw_info = hi; + ci->state = C_INIT; /* mark as hardware not available */ + ci->next = c4_list; + c4_list = ci; + ci->brdno = ci->next ? ci->next->brdno + 1 : 0; + } else + printk (KERN_WARNING "%s: failed CI malloc, size %u.\n", + THIS_MODULE->name, (unsigned int) sizeof (ci_t)); + + if (CI == 0) + CI = ci; /* DEBUG, only board 0 usage */ + return ci; +} + + +/*** + * Check port state and set LED states using watchdog or ioctl... + * also check for in-band SF loopback commands (& cause results if they are there) + * + * Alarm function depends on comet bits indicating change in + * link status (linkMask) to keep the link status indication straight. + * + * Indications are only LED and system log -- except when ioctl is invoked. + * + * "alarmed" record (a.k.a. copyVal, in some cases below) decodes as: + * + * RMAI (E1 only) 0x100 + * alarm LED on 0x80 + * link LED on 0x40 + * link returned 0x20 (link was down, now it's back and 'port get' hasn't run) + * change in LED 0x10 (update LED register because value has changed) + * link is down 0x08 + * YelAlm(RAI) 0x04 + * RedAlm 0x02 + * AIS(blue)Alm 0x01 + * + * note "link has returned" indication is reset on read + * (e.g. by use of the c4_control port get command) + */ + +#define sbeLinkMask 0x41 /* change in signal status (lost/recovered) + + * state */ +#define sbeLinkChange 0x40 +#define sbeLinkDown 0x01 +#define sbeAlarmsMask 0x07 /* red / yellow / blue alarm conditions */ +#define sbeE1AlarmsMask 0x107 /* alarm conditions */ + +#define COMET_LBCMD_READ 0x80 /* read only (do not set, return read value) */ + +void +checkPorts (ci_t * ci) +{ +#ifndef CONFIG_SBE_PMCC4_NCOMM + /* + * PORT POINT - NCOMM needs to avoid this code since the polling of + * alarms conflicts with NCOMM's interrupt servicing implementation. + */ + + comet_t *comet; + volatile u_int32_t value; + u_int32_t copyVal, LEDval; + + u_int8_t portnum; + + LEDval = 0; + for (portnum = 0; portnum < ci->max_port; portnum++) + { + copyVal = 0x12f & (ci->alarmed[portnum]); /* port's alarm record */ + comet = ci->port[portnum].cometbase; + value = pci_read_32 ((u_int32_t *) &comet->cdrc_ists) & sbeLinkMask; /* link loss reg */ + + if (value & sbeLinkChange) /* is there a change in the link stuff */ + { + /* if there's been a change (above) and yet it's the same (below) */ + if (!(((copyVal >> 3) & sbeLinkDown) ^ (value & sbeLinkDown))) + { + if (value & sbeLinkDown) + printk (KERN_WARN "%s: Port %d momentarily recovered.\n", + ci->devname, portnum); + else + printk (KERN_WARN + "%s: Warning: Port %d link was briefly down.\n", + ci->devname, portnum); + } else if (value & sbeLinkDown) + printk (KERN_WARN "%s: Warning: Port %d link is down.\n", + ci->devname, portnum); + else + { + printk (KERN_WARN "%s: Port %d link has recovered.\n", + ci->devname, portnum); + copyVal |= 0x20; /* record link transition to up */ + } + copyVal |= 0x10; /* change (link) --> update LEDs */ + } + copyVal &= 0x137; /* clear LED & link old history bits & + * save others */ + if (value & sbeLinkDown) + copyVal |= 0x08; /* record link status (now) */ + else + { /* if link is up, do this */ + copyVal |= 0x40; /* LED indicate link is up */ + /* Alarm things & the like ... first if E1, then if T1 */ + if (IS_FRAME_ANY_E1 (ci->port[portnum].p.port_mode)) + { + /* + * first check Codeword (SaX) changes & CRC and + * sub-multi-frame errors + */ + /* + * note these errors are printed every time they are detected + * vs. alarms + */ + value = pci_read_32 ((u_int32_t *) &comet->e1_frmr_nat_ists); /* codeword */ + if (value & 0x1f) + { /* if errors (crc or smf only) */ + if (value & 0x10) + printk (KERN_WARN + "%s: E1 Port %d Codeword Sa4 change detected.\n", + ci->devname, portnum); + if (value & 0x08) + printk (KERN_WARN + "%s: E1 Port %d Codeword Sa5 change detected.\n", + ci->devname, portnum); + if (value & 0x04) + printk (KERN_WARN + "%s: E1 Port %d Codeword Sa6 change detected.\n", + ci->devname, portnum); + if (value & 0x02) + printk (KERN_WARN + "%s: E1 Port %d Codeword Sa7 change detected.\n", + ci->devname, portnum); + if (value & 0x01) + printk (KERN_WARN + "%s: E1 Port %d Codeword Sa8 change detected.\n", + ci->devname, portnum); + } + value = pci_read_32 ((u_int32_t *) &comet->e1_frmr_mists); /* crc & smf */ + if (value & 0x3) + { /* if errors (crc or smf only) */ + if (value & sbeE1CRC) + printk (KERN_WARN "%s: E1 Port %d CRC-4 error(s) detected.\n", + ci->devname, portnum); + if (value & sbeE1errSMF) /* error in sub-multiframe */ + printk (KERN_WARN "%s: E1 Port %d received errored SMF.\n", + ci->devname, portnum); + } + value = pci_read_32 ((u_int32_t *) &comet->e1_frmr_masts) & 0xcc; /* alarms */ + /* + * pack alarms together (bitmiser), and construct similar to + * T1 + */ + /* RAI,RMAI,.,.,LOF,AIS,.,. ==> RMAI,.,.,.,.,.,RAI,LOF,AIS */ + /* see 0x97 */ + value = (value >> 2); + if (value & 0x30) + { + if (value & 0x20) + value |= 0x40; /* RAI */ + if (value & 0x10) + value |= 0x100; /* RMAI */ + value &= ~0x30; + } /* finished packing alarm in handy order */ + if (value != (copyVal & sbeE1AlarmsMask)) + { /* if alarms changed */ + copyVal |= 0x10;/* change LED status */ + if ((copyVal & sbeRedAlm) && !(value & sbeRedAlm)) + { + copyVal &= ~sbeRedAlm; + printk (KERN_WARN "%s: E1 Port %d LOF alarm ended.\n", + ci->devname, portnum); + } else if (!(copyVal & sbeRedAlm) && (value & sbeRedAlm)) + { + copyVal |= sbeRedAlm; + printk (KERN_WARN "%s: E1 Warning: Port %d LOF alarm.\n", + ci->devname, portnum); + } else if ((copyVal & sbeYelAlm) && !(value & sbeYelAlm)) + { + copyVal &= ~sbeYelAlm; + printk (KERN_WARN "%s: E1 Port %d RAI alarm ended.\n", + ci->devname, portnum); + } else if (!(copyVal & sbeYelAlm) && (value & sbeYelAlm)) + { + copyVal |= sbeYelAlm; + printk (KERN_WARN "%s: E1 Warning: Port %d RAI alarm.\n", + ci->devname, portnum); + } else if ((copyVal & sbeE1RMAI) && !(value & sbeE1RMAI)) + { + copyVal &= ~sbeE1RMAI; + printk (KERN_WARN "%s: E1 Port %d RMAI alarm ended.\n", + ci->devname, portnum); + } else if (!(copyVal & sbeE1RMAI) && (value & sbeE1RMAI)) + { + copyVal |= sbeE1RMAI; + printk (KERN_WARN "%s: E1 Warning: Port %d RMAI alarm.\n", + ci->devname, portnum); + } else if ((copyVal & sbeAISAlm) && !(value & sbeAISAlm)) + { + copyVal &= ~sbeAISAlm; + printk (KERN_WARN "%s: E1 Port %d AIS alarm ended.\n", + ci->devname, portnum); + } else if (!(copyVal & sbeAISAlm) && (value & sbeAISAlm)) + { + copyVal |= sbeAISAlm; + printk (KERN_WARN "%s: E1 Warning: Port %d AIS alarm.\n", + ci->devname, portnum); + } + } + /* end of E1 alarm code */ + } else + { /* if a T1 mode */ + value = pci_read_32 ((u_int32_t *) &comet->t1_almi_ists); /* alarms */ + value &= sbeAlarmsMask; + if (value != (copyVal & sbeAlarmsMask)) + { /* if alarms changed */ + copyVal |= 0x10;/* change LED status */ + if ((copyVal & sbeRedAlm) && !(value & sbeRedAlm)) + { + copyVal &= ~sbeRedAlm; + printk (KERN_WARN "%s: Port %d red alarm ended.\n", + ci->devname, portnum); + } else if (!(copyVal & sbeRedAlm) && (value & sbeRedAlm)) + { + copyVal |= sbeRedAlm; + printk (KERN_WARN "%s: Warning: Port %d red alarm.\n", + ci->devname, portnum); + } else if ((copyVal & sbeYelAlm) && !(value & sbeYelAlm)) + { + copyVal &= ~sbeYelAlm; + printk (KERN_WARN "%s: Port %d yellow (RAI) alarm ended.\n", + ci->devname, portnum); + } else if (!(copyVal & sbeYelAlm) && (value & sbeYelAlm)) + { + copyVal |= sbeYelAlm; + printk (KERN_WARN "%s: Warning: Port %d yellow (RAI) alarm.\n", + ci->devname, portnum); + } else if ((copyVal & sbeAISAlm) && !(value & sbeAISAlm)) + { + copyVal &= ~sbeAISAlm; + printk (KERN_WARN "%s: Port %d blue (AIS) alarm ended.\n", + ci->devname, portnum); + } else if (!(copyVal & sbeAISAlm) && (value & sbeAISAlm)) + { + copyVal |= sbeAISAlm; + printk (KERN_WARN "%s: Warning: Port %d blue (AIS) alarm.\n", + ci->devname, portnum); + } + } + } /* end T1 mode alarm checks */ + } + if (copyVal & sbeAlarmsMask) + copyVal |= 0x80; /* if alarm turn yel LED on */ + if (copyVal & 0x10) + LEDval |= 0x100; /* tag if LED values have changed */ + LEDval |= ((copyVal & 0xc0) >> (6 - (portnum * 2))); + + ci->alarmed[portnum] &= 0xfffff000; /* out with the old (it's fff + * ... foo) */ + ci->alarmed[portnum] |= (copyVal); /* in with the new */ + + /* + * enough with the alarms and LED's, now let's check for loopback + * requests + */ + + if (IS_FRAME_ANY_T1 (ci->port[portnum].p.port_mode)) + { /* if a T1 mode */ + /* + * begin in-band (SF) loopback code detection -- start by reading + * command + */ + value = pci_read_32 ((u_int32_t *) &comet->ibcd_ies); /* detect reg. */ + value &= 0x3; /* trim to handy bits */ + if (value & 0x2) + { /* activate loopback (sets for deactivate + * code length) */ + copyVal = c4_loop_port (ci, portnum, COMET_LBCMD_READ); /* read line loopback + * mode */ + if (copyVal != COMET_MDIAG_LINELB) /* don't do it again if + * already in that mode */ + c4_loop_port (ci, portnum, COMET_MDIAG_LINELB); /* put port in line + * loopback mode */ + } + if (value & 0x1) + { /* deactivate loopback (sets for activate + * code length) */ + copyVal = c4_loop_port (ci, portnum, COMET_LBCMD_READ); /* read line loopback + * mode */ + if (copyVal != COMET_MDIAG_LBOFF) /* don't do it again if + * already in that mode */ + c4_loop_port (ci, portnum, COMET_MDIAG_LBOFF); /* take port out of any + * loopback mode */ + } + } + if (IS_FRAME_ANY_T1ESF (ci->port[portnum].p.port_mode)) + { /* if a T1 ESF mode */ + /* begin ESF loopback code */ + value = pci_read_32 ((u_int32_t *) &comet->t1_rboc_sts) & 0x3f; /* read command */ + if (value == 0x07) + c4_loop_port (ci, portnum, COMET_MDIAG_LINELB); /* put port in line + * loopback mode */ + if (value == 0x0a) + c4_loop_port (ci, portnum, COMET_MDIAG_PAYLB); /* put port in payload + * loopbk mode */ + if ((value == 0x1c) || (value == 0x19) || (value == 0x12)) + c4_loop_port (ci, portnum, COMET_MDIAG_LBOFF); /* take port out of any + * loopbk mode */ + if (log_level >= LOG_DEBUG) + if (value != 0x3f) + printk (KERN_WARN "%s: BOC value = %x on Port %d\n", + ci->devname, value, portnum); + /* end ESF loopback code */ + } + } + + /* if something is new, update LED's */ + if (LEDval & 0x100) + pci_write_32 ((u_int32_t *) &ci->cpldbase->leds, LEDval & 0xff); +#endif /*** CONFIG_SBE_PMCC4_NCOMM ***/ +} + + +STATIC void +c4_watchdog (ci_t * ci) +{ +#if 0 + //unsigned long flags; +#endif + + if (drvr_state != SBE_DRVR_AVAILABLE) + { + if (log_level >= LOG_MONITOR) + printk ("%s: drvr not available (%x)\n", THIS_MODULE->name, 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 + printk ("%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 + printk ("++ 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]; + printk ("++ 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) + { + printk ("-- c4_watchdog[%d]: WARNING, starting NULL md\n", ch->channum); + printk ("-- 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 + printk ("++ 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 + printk ("++ 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 +} + + +void +c4_cleanup (void) +{ + ci_t *ci, *next; + mpi_t *pi; + int portnum, j; + + ci = c4_list; + while (ci) + { + next = ci->next; /* protect <next> from upcoming <free> */ + pci_write_32 ((u_int32_t *) &ci->cpldbase->leds, PMCC4_CPLD_LED_OFF); + 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]) + 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); + ci = next; /* cleanup next board, if any */ + } +} + + +/* + * This function issues a write to all comet chips and expects the same data + * to be returned from the subsequent read. This determines the board build + * to be a 1-port, 2-port, or 4-port build. The value returned represents a + * bit-mask of the found ports. Only certain configurations are considered + * VALID or LEGAL builds. + */ + +int +c4_get_portcfg (ci_t * ci) +{ + comet_t *comet; + int portnum, mask; + u_int32_t wdata, rdata; + + wdata = COMET_MDIAG_LBOFF; /* take port out of any loopback mode */ + + mask = 0; + for (portnum = 0; portnum < MUSYCC_NPORTS; portnum++) + { + comet = ci->port[portnum].cometbase; + pci_write_32 ((u_int32_t *) &comet->mdiag, wdata); + rdata = pci_read_32 ((u_int32_t *) &comet->mdiag) & COMET_MDIAG_LBMASK; + if (wdata == rdata) + mask |= 1 << portnum; + } + return mask; +} + + +/* nothing herein should generate interrupts */ + +status_t __init +c4_init (ci_t * ci, u_char *func0, u_char *func1) +{ + mpi_t *pi; + mch_t *ch; + static u_int32_t count = 0; + int portnum, j; + + ci->state = C_INIT; + ci->brdno = count++; + ci->intlog.this_status_new = 0; + atomic_set (&ci->bh_pending, 0); + + ci->reg = (struct musycc_globalr *) func0; + ci->eeprombase = (u_int32_t *) (func1 + EEPROM_OFFSET); + ci->cpldbase = (c4cpld_t *) ((u_int32_t *) (func1 + ISPLD_OFFSET)); + + /*** PORT POINT - the following is the first access of any type to the hardware ***/ +#ifdef CONFIG_SBE_PMCC4_NCOMM + /* NCOMM driver uses INTB interrupt to monitor CPLD register */ + pci_write_32 ((u_int32_t *) &ci->reg->glcd, GCD_MAGIC); +#else + /* standard driver POLLS for INTB via CPLD register */ + pci_write_32 ((u_int32_t *) &ci->reg->glcd, GCD_MAGIC | MUSYCC_GCD_INTB_DISABLE); +#endif + + { + int pmsk; + + /* need comet addresses available for determination of hardware build */ + for (portnum = 0; portnum < MUSYCC_NPORTS; portnum++) + { + pi = &ci->port[portnum]; + pi->cometbase = (comet_t *) ((u_int32_t *) (func1 + COMET_OFFSET (portnum))); + pi->reg = (struct musycc_globalr *) ((u_char *) ci->reg + (portnum * 0x800)); + pi->portnum = portnum; + pi->p.portnum = portnum; + pi->openchans = 0; +#ifdef SBE_MAP_DEBUG + printk ("Comet-%d: addr = %p\n", portnum, pi->cometbase); +#endif + } + pmsk = c4_get_portcfg (ci); + switch (pmsk) + { + case 0x1: + ci->max_port = 1; + break; + case 0x3: + ci->max_port = 2; + break; +#if 0 + case 0x7: /* not built, but could be... */ + ci->max_port = 3; + break; +#endif + case 0xf: + ci->max_port = 4; + break; + default: + ci->max_port = 0; + printk (KERN_WARNING "%s: illegal port configuration (%x)\n", ci->devname, pmsk); + return SBE_DRVR_FAIL; + } +#ifdef SBE_MAP_DEBUG + printk (">> %s: c4_get_build - pmsk %x max_port %x\n", ci->devname, pmsk, ci->max_port); +#endif + } + + for (portnum = 0; portnum < ci->max_port; portnum++) + { + pi = &ci->port[portnum]; + pi->up = ci; + pi->sr_last = 0xffffffff; + pi->p.port_mode = CFG_FRAME_SF; /* T1 B8ZS, the default */ + pi->p.portP = (CFG_CLK_PORT_EXTERNAL | CFG_LBO_LH0); /* T1 defaults */ + + OS_sem_init (&pi->sr_sem_busy, SEM_AVAILABLE); + OS_sem_init (&pi->sr_sem_wait, SEM_TAKEN); + + for (j = 0; j < 32; j++) + { + pi->fifomap[j] = -1; + pi->tsm[j] = 0; /* no assignments, all available */ + } + + /* allocate channel structures for this port */ + for (j = 0; j < MUSYCC_NCHANS; j++) + { + ch = OS_kmalloc (sizeof (mch_t)); + if (ch) + { + pi->chan[j] = ch; + ch->state = UNASSIGNED; + ch->up = pi; + ch->gchan = (-1); /* channel assignment not yet known */ + ch->channum = (-1); /* channel assignment not yet known */ + ch->p.card = ci->brdno; + ch->p.port = portnum; + ch->p.channum = (-1); /* channel assignment not yet known */ + ch->p.mode_56k = 0; /* default is 64kbps mode */ + } else + { + printk (KERN_WARNING "%s: failed mch_t malloc, port %d channel %d size %u.\n", + THIS_MODULE->name, portnum, j, (unsigned int) sizeof (mch_t)); + break; + } + } + } + + + { + /* + * Set LEDs through their paces to supply visual proof that LEDs are + * functional and not burnt out nor broken. + * + * YELLOW + GREEN -> OFF. + */ + + pci_write_32 ((u_int32_t *) &ci->cpldbase->leds, + PMCC4_CPLD_LED_GREEN | PMCC4_CPLD_LED_YELLOW); + OS_uwait (750000, "leds"); + pci_write_32 ((u_int32_t *) &ci->cpldbase->leds, PMCC4_CPLD_LED_OFF); + } + + OS_init_watchdog (&ci->wd, (void (*) (void *)) c4_watchdog, ci, WATCHDOG_TIMEOUT); + return SBE_DRVR_SUCCESS; +} + + +/* better be fully setup to handle interrupts when you call this */ + +status_t __init +c4_init2 (ci_t * ci) +{ + status_t ret; + + /* PORT POINT: this routine generates first interrupt */ + if ((ret = musycc_init (ci)) != SBE_DRVR_SUCCESS) + return ret; + +#if 0 + ci->p.framing_type = FRAMING_CBP; + ci->p.h110enable = 1; +#if 0 + ci->p.hypersize = 0; +#else + hyperdummy = 0; +#endif + ci->p.clock = 0; /* Use internal clocking until set to + * external */ + c4_card_set_params (ci, &ci->p); +#endif + OS_start_watchdog (&ci->wd); + return SBE_DRVR_SUCCESS; +} + + +/* This function sets the loopback mode (or clears it, as the case may be). */ + +int +c4_loop_port (ci_t * ci, int portnum, u_int8_t cmd) +{ + comet_t *comet; + volatile u_int32_t loopValue; + + comet = ci->port[portnum].cometbase; + loopValue = pci_read_32 ((u_int32_t *) &comet->mdiag) & COMET_MDIAG_LBMASK; + + if (cmd & COMET_LBCMD_READ) + return loopValue; /* return the read value */ + + if (loopValue != cmd) + { + switch (cmd) + { + case COMET_MDIAG_LINELB: + /* set(SF)loopback down (turn off) code length to 6 bits */ + pci_write_32 ((u_int32_t *) &comet->ibcd_cfg, 0x05); + break; + case COMET_MDIAG_LBOFF: + /* set (SF) loopback up (turn on) code length to 5 bits */ + pci_write_32 ((u_int32_t *) &comet->ibcd_cfg, 0x00); + break; + } + + pci_write_32 ((u_int32_t *) &comet->mdiag, cmd); + if (log_level >= LOG_WARN) + printk ("%s: loopback mode changed to %2x from %2x on Port %d\n", + ci->devname, cmd, loopValue, portnum); + loopValue = pci_read_32 ((u_int32_t *) &comet->mdiag) & COMET_MDIAG_LBMASK; + if (loopValue != cmd) + { + if (log_level >= LOG_ERROR) + printk ("%s: write to loop register failed, unknown state for Port %d\n", + ci->devname, portnum); + } + } else + { + if (log_level >= LOG_WARN) + printk ("%s: loopback already in that mode (%2x)\n", ci->devname, loopValue); + } + return 0; +} + + +/* c4_frame_rw: read or write the comet register specified + * (modifies use of port_param to non-standard use of struct) + * Specifically: + * pp.portnum (one guess) + * pp.port_mode offset of register + * pp.portP write (or not, i.e. read) + * pp.portStatus write value + * BTW: + * pp.portStatus also used to return read value + * pp.portP also used during write, to return old reg value + */ + +status_t +c4_frame_rw (ci_t * ci, struct sbecom_port_param * pp) +{ + comet_t *comet; + volatile u_int32_t data; + + if (pp->portnum >= ci->max_port)/* sanity check */ + return ENXIO; + + comet = ci->port[pp->portnum].cometbase; + data = pci_read_32 ((u_int32_t *) comet + pp->port_mode) & 0xff; + + if (pp->portP) + { /* control says this is a register + * _write_ */ + if (pp->portStatus == data) + printk ("%s: Port %d already that value! Writing again anyhow.\n", + ci->devname, pp->portnum); + pp->portP = (u_int8_t) data; + pci_write_32 ((u_int32_t *) comet + pp->port_mode, + pp->portStatus); + data = pci_read_32 ((u_int32_t *) comet + pp->port_mode) & 0xff; + } + pp->portStatus = (u_int8_t) data; + return 0; +} + + +/* c4_pld_rw: read or write the pld register specified + * (modifies use of port_param to non-standard use of struct) + * Specifically: + * pp.port_mode offset of register + * pp.portP write (or not, i.e. read) + * pp.portStatus write value + * BTW: + * pp.portStatus also used to return read value + * pp.portP also used during write, to return old reg value + */ + +status_t +c4_pld_rw (ci_t * ci, struct sbecom_port_param * pp) +{ + volatile u_int32_t *regaddr; + volatile u_int32_t data; + int regnum = pp->port_mode; + + regaddr = (u_int32_t *) ci->cpldbase + regnum; + data = pci_read_32 ((u_int32_t *) regaddr) & 0xff; + + if (pp->portP) + { /* control says this is a register + * _write_ */ + pp->portP = (u_int8_t) data; + pci_write_32 ((u_int32_t *) regaddr, pp->portStatus); + data = pci_read_32 ((u_int32_t *) regaddr) & 0xff; + } + pp->portStatus = (u_int8_t) data; + return 0; +} + +/* c4_musycc_rw: read or write the musycc register specified + * (modifies use of port_param to non-standard use of struct) + * Specifically: + * mcp.RWportnum port number and write indication bit (0x80) + * mcp.offset offset of register + * mcp.value write value going in and read value returning + */ + +/* PORT POINT: TX Subchannel Map registers are write-only + * areas within the MUSYCC and always return FF */ +/* PORT POINT: regram and reg structures are minorly different and <offset> ioctl + * settings are aligned with the <reg> struct musycc_globalr{} usage. + * Also, regram is separately allocated shared memory, allocated for each port. + * PORT POINT: access offsets of 0x6000 for Msg Cfg Desc Tbl are for 4-port MUSYCC + * only. (An 8-port MUSYCC has 0x16000 offsets for accessing its upper 4 tables.) + */ + +status_t +c4_musycc_rw (ci_t * ci, struct c4_musycc_param * mcp) +{ + mpi_t *pi; + volatile u_int32_t *dph; /* hardware implemented register */ + u_int32_t *dpr = 0; /* RAM image of registers for group command + * usage */ + int offset = mcp->offset % 0x800; /* group relative address + * offset, mcp->portnum is + * not used */ + int portnum, ramread = 0; + volatile u_int32_t data; + + /* + * Sanity check hardware accessibility. The 0x6000 portion handles port + * numbers associated with Msg Descr Tbl decoding. + */ + portnum = (mcp->offset % 0x6000) / 0x800; + if (portnum >= ci->max_port) + return ENXIO; + pi = &ci->port[portnum]; + if (mcp->offset >= 0x6000) + offset += 0x6000; /* put back in MsgCfgDesc address offset */ + dph = (u_int32_t *) ((u_long) pi->reg + offset); + + /* read of TX are from RAM image, since hardware returns FF */ + dpr = (u_int32_t *) ((u_long) pi->regram + offset); + if (mcp->offset < 0x6000) /* non MsgDesc Tbl accesses might require + * RAM access */ + { + if (offset >= 0x200 && offset < 0x380) + ramread = 1; + if (offset >= 0x10 && offset < 0x200) + ramread = 1; + } + /* read register from RAM or hardware, depending... */ + if (ramread) + { + data = *dpr; + //printk ("c4_musycc_rw: RAM addr %p read data %x (portno %x offset %x RAM ramread %x)\n", dpr, data, portnum, offset, ramread); /* RLD DEBUG */ + } else + { + data = pci_read_32 ((u_int32_t *) dph); + //printk ("c4_musycc_rw: REG addr %p read data %x (portno %x offset %x RAM ramread %x)\n", dph, data, portnum, offset, ramread); /* RLD DEBUG */ + } + + + if (mcp->RWportnum & 0x80) + { /* control says this is a register + * _write_ */ + if (mcp->value == data) + printk ("%s: musycc grp%d already that value! writing again anyhow.\n", + ci->devname, (mcp->RWportnum & 0x7)); + /* write register RAM */ + if (ramread) + *dpr = mcp->value; + /* write hardware register */ + pci_write_32 ((u_int32_t *) dph, mcp->value); + } + mcp->value = data; /* return the read value (or the 'old + * value', if is write) */ + return 0; +} + +status_t +c4_get_port (ci_t * ci, int portnum) +{ + if (portnum >= ci->max_port) /* sanity check */ + return ENXIO; + + SD_SEM_TAKE (&ci->sem_wdbusy, "_wd_"); /* only 1 thru here, per + * board */ + checkPorts (ci); + ci->port[portnum].p.portStatus = (u_int8_t) ci->alarmed[portnum]; + ci->alarmed[portnum] &= 0xdf; + SD_SEM_GIVE (&ci->sem_wdbusy); /* release per-board hold */ + return 0; +} + +status_t +c4_set_port (ci_t * ci, int portnum) +{ + mpi_t *pi; + struct sbecom_port_param *pp; + int e1mode; + u_int8_t clck; + int i; + + if (portnum >= ci->max_port) /* sanity check */ + return ENXIO; + + pi = &ci->port[portnum]; + pp = &ci->port[portnum].p; + e1mode = IS_FRAME_ANY_E1 (pp->port_mode); + if (log_level >= LOG_MONITOR2) + { + printk ("%s: c4_set_port[%d]: entered, e1mode = %x, openchans %d.\n", + ci->devname, + portnum, e1mode, pi->openchans); + } + if (pi->openchans) + return EBUSY; /* group needs initialization only for + * first channel of a group */ + +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,41) + { + status_t ret; + + if ((ret = c4_wq_port_init (pi))) /* create/init + * 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; + if (e1mode) + clck |= 1 << portnum; + else + clck &= 0xf ^ (1 << portnum); + + pci_write_32 ((u_int32_t *) &ci->cpldbase->mclk, clck); + pci_write_32 ((u_int32_t *) &ci->cpldbase->mcsr, PMCC4_CPLD_MCSR_IND); + pci_write_32 ((u_int32_t *) &pi->reg->gbp, OS_vtophys (pi->regram)); + + /*********************************************************************/ + /* ERRATA: If transparent mode is used, do not set OOFMP_DISABLE bit */ + /*********************************************************************/ + + pi->regram->grcd = + __constant_cpu_to_le32 (MUSYCC_GRCD_RX_ENABLE | + MUSYCC_GRCD_TX_ENABLE | + MUSYCC_GRCD_OOFMP_DISABLE | + MUSYCC_GRCD_SF_ALIGN | /* per MUSYCC ERRATA, + * for T1 * fix */ + MUSYCC_GRCD_COFAIRQ_DISABLE | + MUSYCC_GRCD_MC_ENABLE | + (MUSYCC_GRCD_POLLTH_32 << MUSYCC_GRCD_POLLTH_SHIFT)); + + pi->regram->pcd = + __constant_cpu_to_le32 ((e1mode ? 1 : 0) | + MUSYCC_PCD_TXSYNC_RISING | + MUSYCC_PCD_RXSYNC_RISING | + MUSYCC_PCD_RXDATA_RISING); + + /* Message length descriptor */ + pi->regram->mld = __constant_cpu_to_le32 (max_mru | (max_mru << 16)); + + /* tsm algorithm */ + for (i = 0; i < 32; i++) + { + + /*** ASSIGNMENT NOTES: ***/ + /*** Group's channel ZERO unavailable if E1. ***/ + /*** Group's channel 16 unavailable if E1 CAS. ***/ + /*** Group's channels 24-31 unavailable if T1. ***/ + + if (((i == 0) && e1mode) || + ((i == 16) && ((pp->port_mode == CFG_FRAME_E1CRC_CAS) || (pp->port_mode == CFG_FRAME_E1CRC_CAS_AMI))) + || ((i > 23) && (!e1mode))) + { + pi->tsm[i] = 0xff; /* make tslot unavailable for this mode */ + } else + { + pi->tsm[i] = 0x00; /* make tslot available for assignment */ + } + } + for (i = 0; i < MUSYCC_NCHANS; i++) + { + pi->regram->ttsm[i] = 0; + pi->regram->rtsm[i] = 0; + } + FLUSH_MEM_WRITE (); + musycc_serv_req (pi, SR_GROUP_INIT | SR_RX_DIRECTION); + musycc_serv_req (pi, SR_GROUP_INIT | SR_TX_DIRECTION); + + musycc_init_mdt (pi); + + pi->group_is_set = 1; + pi->p = *pp; + return 0; +} + + +unsigned int max_int = 0; + +status_t +c4_new_chan (ci_t * ci, int portnum, int channum, void *user) +{ + mpi_t *pi; + mch_t *ch; + int gchan; + + if (c4_find_chan (channum)) /* a new channel shouldn't already exist */ + return EEXIST; + + if (portnum >= ci->max_port) /* sanity check */ + return ENXIO; + + pi = &(ci->port[portnum]); + /* find any available channel within this port */ + for (gchan = 0; gchan < MUSYCC_NCHANS; gchan++) + { + ch = pi->chan[gchan]; + if (ch && ch->state == UNASSIGNED) /* no assignment is good! */ + break; + } + if (gchan == MUSYCC_NCHANS) /* exhausted table, all were assigned */ + return ENFILE; + + ch->up = pi; + + /* NOTE: mch_t already cleared during OS_kmalloc() */ + ch->state = DOWN; + ch->user = user; + ch->gchan = gchan; + ch->channum = channum; /* mark our channel assignment */ + ch->p.channum = channum; +#if 1 + ch->p.card = ci->brdno; + ch->p.port = portnum; +#endif + ch->p.chan_mode = CFG_CH_PROTO_HDLC_FCS16; + ch->p.idlecode = CFG_CH_FLAG_7E; + ch->p.pad_fill_count = 2; + 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 + * be the lowest channel */ + { + ci->first_if = ci->last_if = user; + ci->first_channum = ci->last_channum = channum; + } else + { + ci->last_if = user; + if (ci->last_channum < channum) /* higher number channel found */ + ci->last_channum = channum; + } + return 0; +} + +status_t +c4_del_chan (int channum) +{ + mch_t *ch; + + if (!(ch = c4_find_chan (channum))) + return ENOENT; + if (ch->state == UP) + musycc_chan_down ((ci_t *) 0, channum); + ch->state = UNASSIGNED; + ch->gchan = (-1); + ch->channum = (-1); + ch->p.channum = (-1); + return 0; +} + +status_t +c4_del_chan_stats (int channum) +{ + mch_t *ch; + + if (!(ch = c4_find_chan (channum))) + return ENOENT; + + memset (&ch->s, 0, sizeof (struct sbecom_chan_stats)); + return 0; +} + + +status_t +c4_set_chan (int channum, struct sbecom_chan_param * p) +{ + mch_t *ch; + int i, x = 0; + + if (!(ch = c4_find_chan (channum))) + return ENOENT; + +#if 1 + if (ch->p.card != p->card || + ch->p.port != p->port || + ch->p.channum != p->channum) + return EINVAL; +#endif + + if (!(ch->up->group_is_set)) + { + return EIO; /* out of order, SET_PORT command + * required prior to first group's + * SET_CHAN command */ + } + /* + * Check for change of parameter settings in order to invoke closing of + * channel prior to hardware poking. + */ + + if (ch->p.status != p->status || ch->p.chan_mode != p->chan_mode || + ch->p.data_inv != p->data_inv || ch->p.intr_mask != p->intr_mask || + ch->txd_free < ch->txd_num) /* to clear out queued messages */ + x = 1; /* we have a change requested */ + for (i = 0; i < 32; i++) /* check for timeslot mapping changes */ + if (ch->p.bitmask[i] != p->bitmask[i]) + x = 1; /* we have a change requested */ + ch->p = *p; + if (x && (ch->state == UP)) /* if change request and channel is + * open... */ + { + status_t ret; + + if ((ret = musycc_chan_down ((ci_t *) 0, channum))) + return ret; + if ((ret = c4_chan_up (ch->up->up, channum))) + return ret; + sd_enable_xmit (ch->user); /* re-enable to catch flow controlled + * channel */ + } + return 0; +} + + +status_t +c4_get_chan (int channum, struct sbecom_chan_param * p) +{ + mch_t *ch; + + if (!(ch = c4_find_chan (channum))) + return ENOENT; + *p = ch->p; + return 0; +} + +status_t +c4_get_chan_stats (int channum, struct sbecom_chan_stats * p) +{ + mch_t *ch; + + if (!(ch = c4_find_chan (channum))) + return ENOENT; + *p = ch->s; + p->tx_pending = atomic_read (&ch->tx_pending); + return 0; +} + +STATIC int +c4_fifo_alloc (mpi_t * pi, int chan, int *len) +{ + int i, l = 0, start = 0, max = 0, maxstart = 0; + + for (i = 0; i < 32; i++) + { + if (pi->fifomap[i] != -1) + { + l = 0; + start = i + 1; + continue; + } + ++l; + if (l > max) + { + max = l; + maxstart = start; + } + if (max == *len) + break; + } + if (max != *len) + { + if (log_level >= LOG_WARN) + printk ( + "%s: wanted to allocate %d fifo space, but got only %d\n", + pi->up->devname, *len, max); + *len = max; + } + if (log_level >= LOG_DEBUG) + printk ("%s: allocated %d fifo at %d for channel %d/%d\n", + pi->up->devname, max, start, chan, pi->p.portnum); + for (i = maxstart; i < (maxstart + max); i++) + pi->fifomap[i] = chan; + return start; +} + +void +c4_fifo_free (mpi_t * pi, int chan) +{ + int i; + + if (log_level >= LOG_DEBUG) + printk ("%s: deallocated fifo for channel %d/%d\n", + pi->up->devname, chan, pi->p.portnum); + for (i = 0; i < 32; i++) + if (pi->fifomap[i] == chan) + pi->fifomap[i] = -1; +} + + +status_t +c4_chan_up (ci_t * ci, int channum) +{ + mpi_t *pi; + mch_t *ch; + struct mbuf *m; + struct mdesc *md; + int nts, nbuf, txnum, rxnum; + int addr, i, j, gchan; + u_int32_t tmp; /* for optimizing conversion across BE + * platform */ + + if (!(ch = c4_find_chan (channum))) + return ENOENT; + if (ch->state == UP) + { + if (log_level >= LOG_MONITOR) + printk ("%s: channel already UP, graceful early exit\n", ci->devname); + return 0; + } + pi = ch->up; + gchan = ch->gchan; + /* find nts ('number of timeslots') */ + nts = 0; + for (i = 0; i < 32; i++) + { + if (ch->p.bitmask[i] & pi->tsm[i]) + { + if (1 || log_level >= LOG_WARN) + { + printk ("%s: c4_chan_up[%d] EINVAL (attempt to cfg in-use or unavailable TimeSlot[%d])\n", + ci->devname, channum, i); + printk ("+ ask4 %x, currently %x\n", ch->p.bitmask[i], pi->tsm[i]); + } + return EINVAL; + } + for (j = 0; j < 8; j++) + if (ch->p.bitmask[i] & (1 << j)) + nts++; + } + + nbuf = nts / 8 ? nts / 8 : 1; + if (!nbuf) + { + /* if( log_level >= LOG_WARN) */ + printk ("%s: c4_chan_up[%d] ENOBUFS (no TimeSlots assigned)\n", ci->devname, channum); + return ENOBUFS; /* this should not happen */ + } + addr = c4_fifo_alloc (pi, gchan, &nbuf); + ch->state = UP; + + /* Setup the Time Slot Map */ + musycc_update_timeslots (pi); + + /* ch->tx_limit = nts; */ + ch->s.tx_pending = 0; + + /* Set Channel Configuration Descriptors */ + { + u_int32_t ccd; + + ccd = musycc_chan_proto (ch->p.chan_mode) << MUSYCC_CCD_PROTO_SHIFT; + if ((ch->p.chan_mode == CFG_CH_PROTO_ISLP_MODE) || + (ch->p.chan_mode == CFG_CH_PROTO_TRANS)) + { + ccd |= MUSYCC_CCD_FCS_XFER; /* Non FSC Mode */ + } + ccd |= 2 << MUSYCC_CCD_MAX_LENGTH; /* Select second MTU */ + ccd |= ch->p.intr_mask; + ccd |= addr << MUSYCC_CCD_BUFFER_LOC; + if (ch->p.chan_mode == CFG_CH_PROTO_TRANS) + ccd |= (nbuf) << MUSYCC_CCD_BUFFER_LENGTH; + else + ccd |= (nbuf - 1) << MUSYCC_CCD_BUFFER_LENGTH; + + if (ch->p.data_inv & CFG_CH_DINV_TX) + ccd |= MUSYCC_CCD_INVERT_DATA; /* Invert data */ + pi->regram->tcct[gchan] = cpu_to_le32 (ccd); + + if (ch->p.data_inv & CFG_CH_DINV_RX) + ccd |= MUSYCC_CCD_INVERT_DATA; /* Invert data */ + else + ccd &= ~MUSYCC_CCD_INVERT_DATA; /* take away data inversion */ + pi->regram->rcct[gchan] = cpu_to_le32 (ccd); + FLUSH_MEM_WRITE (); + } + + /* Reread the Channel Configuration Descriptor for this channel */ + musycc_serv_req (pi, SR_CHANNEL_CONFIG | SR_RX_DIRECTION | gchan); + musycc_serv_req (pi, SR_CHANNEL_CONFIG | SR_TX_DIRECTION | gchan); + + /* + * Figure out how many buffers we want. If the customer has changed from + * the defaults, then use the changed values. Otherwise, use Transparent + * mode's specific minimum default settings. + */ + if (ch->p.chan_mode == CFG_CH_PROTO_TRANS) + { + if (max_rxdesc_used == max_rxdesc_default) /* use default setting */ + max_rxdesc_used = MUSYCC_RXDESC_TRANS; + if (max_txdesc_used == max_txdesc_default) /* use default setting */ + max_txdesc_used = MUSYCC_TXDESC_TRANS; + } + /* + * Increase counts when hyperchanneling, since this implies an increase + * in throughput per channel + */ + rxnum = max_rxdesc_used + (nts / 4); + txnum = max_txdesc_used + (nts / 4); + +#if 0 + /* DEBUG INFO */ + if (log_level >= LOG_MONITOR) + printk ("%s: mode %x rxnum %d (rxused %d def %d) txnum %d (txused %d def %d)\n", + ci->devname, ch->p.chan_mode, + rxnum, max_rxdesc_used, max_rxdesc_default, + txnum, max_txdesc_used, max_txdesc_default); +#endif + + ch->rxd_num = rxnum; + ch->txd_num = txnum; + ch->rxix_irq_srv = 0; + + ch->mdr = OS_kmalloc (sizeof (struct mdesc) * rxnum); + ch->mdt = OS_kmalloc (sizeof (struct mdesc) * txnum); + if (ch->p.chan_mode == CFG_CH_PROTO_TRANS) + tmp = __constant_cpu_to_le32 (max_mru | EOBIRQ_ENABLE); + else + tmp = __constant_cpu_to_le32 (max_mru); + + for (i = 0, md = ch->mdr; i < rxnum; i++, md++) + { + if (i == (rxnum - 1)) + { + md->snext = &ch->mdr[0];/* wrapness */ + } else + { + md->snext = &ch->mdr[i + 1]; + } + md->next = cpu_to_le32 (OS_vtophys (md->snext)); + + if (!(m = OS_mem_token_alloc (max_mru))) + { + if (log_level >= LOG_MONITOR) + printk ("%s: c4_chan_up[%d] - token alloc failure, size = %d.\n", ci->devname, channum, max_mru); + goto errfree; + } + md->mem_token = m; + md->data = cpu_to_le32 (OS_vtophys (OS_mem_token_data (m))); + md->status = tmp | MUSYCC_RX_OWNED; /* MUSYCC owns RX descriptor ** + * CODING NOTE: + * MUSYCC_RX_OWNED = 0 so no + * need to byteSwap */ + } + + for (i = 0, md = ch->mdt; i < txnum; i++, md++) + { + md->status = HOST_TX_OWNED; /* Host owns TX descriptor ** CODING + * NOTE: HOST_TX_OWNED = 0 so no need to + * byteSwap */ + md->mem_token = 0; + md->data = 0; + if (i == (txnum - 1)) + { + md->snext = &ch->mdt[0];/* wrapness */ + } else + { + md->snext = &ch->mdt[i + 1]; + } + md->next = cpu_to_le32 (OS_vtophys (md->snext)); + } + ch->txd_irq_srv = ch->txd_usr_add = &ch->mdt[0]; + ch->txd_free = txnum; + ch->tx_full = 0; + ch->txd_required = 0; + + /* Configure it into the chip */ + tmp = cpu_to_le32 (OS_vtophys (&ch->mdt[0])); + pi->regram->thp[gchan] = tmp; + pi->regram->tmp[gchan] = tmp; + + tmp = cpu_to_le32 (OS_vtophys (&ch->mdr[0])); + pi->regram->rhp[gchan] = tmp; + pi->regram->rmp[gchan] = tmp; + + /* Activate the Channel */ + FLUSH_MEM_WRITE (); + if (ch->p.status & RX_ENABLED) + { +#ifdef RLD_TRANS_DEBUG + printk ("++ c4_chan_up() CHAN RX ACTIVATE: chan %d\n", ch->channum); +#endif + ch->ch_start_rx = 0; /* we are restarting RX... */ + musycc_serv_req (pi, SR_CHANNEL_ACTIVATE | SR_RX_DIRECTION | gchan); + } + if (ch->p.status & TX_ENABLED) + { +#ifdef RLD_TRANS_DEBUG + printk ("++ c4_chan_up() CHAN TX ACTIVATE: chan %d <delayed>\n", ch->channum); +#endif + ch->ch_start_tx = CH_START_TX_1ST; /* we are delaying start + * until receipt from user of + * first packet to transmit. */ + } + ch->status = ch->p.status; + pi->openchans++; + return 0; + +errfree: + while (i > 0) + { + /* Don't leak all the previously allocated mbufs in this loop */ + i--; + OS_mem_token_free (ch->mdr[i].mem_token); + } + OS_kfree (ch->mdt); + ch->mdt = 0; + ch->txd_num = 0; + OS_kfree (ch->mdr); + ch->mdr = 0; + ch->rxd_num = 0; + ch->state = DOWN; + return ENOBUFS; +} + +/* stop the hardware from servicing & interrupting */ + +void +c4_stopwd (ci_t * ci) +{ + OS_stop_watchdog (&ci->wd); + SD_SEM_TAKE (&ci->sem_wdbusy, "_stop_"); /* ensure WD not running */ + SD_SEM_GIVE (&ci->sem_wdbusy); +} + + +void +sbecom_get_brdinfo (ci_t * ci, struct sbe_brd_info * bip, u_int8_t *bsn) +{ + char *np; + u_int32_t sn = 0; + int i; + + bip->brdno = ci->brdno; /* our board number */ + bip->brd_id = ci->brd_id; + bip->brd_hdw_id = ci->hdw_bid; + bip->brd_chan_cnt = MUSYCC_NCHANS * ci->max_port; /* number of channels + * being used */ + bip->brd_port_cnt = ci->max_port; /* number of ports being used */ + bip->brd_pci_speed = BINFO_PCI_SPEED_unk; /* PCI speed not yet + * determinable */ + + 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, "<NULL>"); + 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, "<NULL>"); + + if (bsn) + { + for (i = 0; i < 3; i++) + { + bip->brd_mac_addr[i] = *bsn++; + } + for (; i < 6; i++) + { + bip->brd_mac_addr[i] = *bsn; + sn = (sn << 8) | *bsn++; + } + } else + { + for (i = 0; i < 6; i++) + bip->brd_mac_addr[i] = 0; + } + bip->brd_sn = sn; +} + + +status_t +c4_get_iidinfo (ci_t * ci, struct sbe_iid_info * iip) +{ + struct net_device *dev; + char *np; + + 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; +} + + +#ifdef CONFIG_SBE_PMCC4_NCOMM +void (*nciInterrupt[MAX_BOARDS][4]) (void); +extern void wanpmcC4T1E1_hookInterrupt (int cardID, int deviceID, void *handler); + +void +wanpmcC4T1E1_hookInterrupt (int cardID, int deviceID, void *handler) +{ + if (cardID < MAX_BOARDS) /* sanity check */ + nciInterrupt[cardID][deviceID] = handler; +} + +irqreturn_t +c4_ebus_intr_th_handler (void *devp) +{ + ci_t *ci = (ci_t *) devp; + volatile u_int32_t ists; + int handled = 0; + int brdno; + + /* which COMET caused the interrupt */ + brdno = ci->brdno; + ists = pci_read_32 ((u_int32_t *) &ci->cpldbase->intr); + if (ists & PMCC4_CPLD_INTR_CMT_1) + { + handled = 0x1; + if (nciInterrupt[brdno][0] != NULL) + (*nciInterrupt[brdno][0]) (); + } + if (ists & PMCC4_CPLD_INTR_CMT_2) + { + handled |= 0x2; + if (nciInterrupt[brdno][1] != NULL) + (*nciInterrupt[brdno][1]) (); + } + if (ists & PMCC4_CPLD_INTR_CMT_3) + { + handled |= 0x4; + if (nciInterrupt[brdno][2] != NULL) + (*nciInterrupt[brdno][2]) (); + } + if (ists & PMCC4_CPLD_INTR_CMT_4) + { + handled |= 0x8; + if (nciInterrupt[brdno][3] != NULL) + (*nciInterrupt[brdno][3]) (); + } +#if 0 + /*** Test code just de-implements the asserted interrupt. Alternate + vendor will supply COMET interrupt handling code herein or such. + ***/ + 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 +} + + +unsigned long +wanpmcC4T1E1_getBaseAddress (int cardID, int deviceID) +{ + ci_t *ci; + unsigned long base = 0; + + ci = c4_list; + while (ci) + { + if (ci->brdno == cardID) /* found valid device */ + { + if (deviceID < ci->max_port) /* comet is supported */ + base = ((unsigned long) ci->port[deviceID].cometbase); + break; + } + ci = ci->next; /* next board, if any */ + } + return (base); +} + +#endif /*** CONFIG_SBE_PMCC4_NCOMM ***/ + + +/*** End-of-File ***/ diff --git a/drivers/staging/cxt1e1/pmcc4_ioctls.h b/drivers/staging/cxt1e1/pmcc4_ioctls.h new file mode 100644 index 000000000000..6b8d65673c78 --- /dev/null +++ b/drivers/staging/cxt1e1/pmcc4_ioctls.h @@ -0,0 +1,81 @@ +/* RCSid: $Header: /home/rickd/projects/pmcc4/include/pmcc4_ioctls.h,v 2.0 2005/09/28 00:10:09 rickd PMCC4_3_1B $ + */ + +#ifndef _INC_PMCC4_IOCTLS_H_ +#define _INC_PMCC4_IOCTLS_H_ + +/*----------------------------------------------------------------------------- + * pmcc4_ioctls.h - + * + * Copyright (C) 2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + * + * For further information, contact via email: support@sbei.com + * SBE, Inc. San Ramon, California U.S.A. + *----------------------------------------------------------------------------- + * RCS info: + * RCS revision: $Revision: 2.0 $ + * Last changed on $Date: 2005/09/28 00:10:09 $ + * Changed by $Author: rickd $ + *----------------------------------------------------------------------------- + * $Log: pmcc4_ioctls.h,v $ + * Revision 2.0 2005/09/28 00:10:09 rickd + * Add GNU license info. Switch Ioctls to sbe_ioc.h usage. + * + * Revision 1.2 2005/04/28 23:43:03 rickd + * Add RCS tracking heading. + * + *----------------------------------------------------------------------------- + */ + +#include "sbew_ioc.h" + +enum +{ + // C4_GET_PORT = 0, + // C4_SET_PORT, + // C4_GET_CHAN, + // C4_SET_CHAN, + C4_DEL_CHAN = 0, + // C4_CREATE_CHAN, + // C4_GET_CHAN_STATS, + // C4_RESET, + // C4_DEBUG, + C4_RESET_STATS, + C4_LOOP_PORT, + C4_RW_FRMR, + C4_RW_MSYC, + C4_RW_PLD +}; + +#define C4_GET_PORT SBE_IOC_PORT_GET +#define C4_SET_PORT SBE_IOC_PORT_SET +#define C4_GET_CHAN SBE_IOC_CHAN_GET +#define C4_SET_CHAN SBE_IOC_CHAN_SET +// #define C4_DEL_CHAN XXX +#define C4_CREATE_CHAN SBE_IOC_CHAN_NEW +#define C4_GET_CHAN_STATS SBE_IOC_CHAN_GET_STAT +#define C4_RESET SBE_IOC_RESET_DEV +#define C4_DEBUG SBE_IOC_LOGLEVEL +// #define C4_RESET_STATS XXX +// #define C4_LOOP_PORT XXX +// #define C4_RW_FRMR XXX +// #define C4_RW_MSYC XXX +// #define C4_RW_PLD XXX + +struct c4_chan_stats_wrap +{ + int channum; + struct sbecom_chan_stats stats; +}; + +#endif /* _INC_PMCC4_IOCTLS_H_ */ diff --git a/drivers/staging/cxt1e1/pmcc4_private.h b/drivers/staging/cxt1e1/pmcc4_private.h new file mode 100644 index 000000000000..0ae18c444a75 --- /dev/null +++ b/drivers/staging/cxt1e1/pmcc4_private.h @@ -0,0 +1,295 @@ +#ifndef _INC_PMCC4_PRIVATE_H_ +#define _INC_PMCC4_PRIVATE_H_ + +/*----------------------------------------------------------------------------- + * pmcc4_private.h - + * + * Copyright (C) 2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + */ + + +#include <linux/kernel.h> +#include <linux/sched.h> +#include <linux/spinlock.h> +#include <linux/interrupt.h> /* support for tasklets */ +#include <linux/timer.h> /* support for timer */ +#include <linux/workqueue.h> +#include <linux/hdlc.h> + +#include "libsbew.h" +#include "pmcc4_defs.h" +#include "pmcc4_cpld.h" +#include "musycc.h" +#include "sbe_promformat.h" +#include "comet.h" + + +/* driver state */ +#define SBE_DRVR_INIT 0x0 +#define SBE_DRVR_AVAILABLE 0x69734F4E +#define SBE_DRVR_DOWN 0x1 + +/****************************************************************************** + * MUSYCC Message Descriptor - coupled to hardware implementation, the first + * three u_int32 must not be reordered. + */ + +struct mdesc +{ + volatile u_int32_t status; /* Buffer Descriptor */ + u_int32_t data; /* Data Pointer */ + u_int32_t next; /* MUSYCC view of Next Pointer */ + void *mem_token; /* Data */ + struct mdesc *snext; +}; + + +/************************************************************************* + * Private driver data structures, internal use only. + */ + +struct c4_chan_info +{ + int gchan; /* channel number within group/port 0-31 */ + int channum; /* absolute channel number 0-128 */ + u_int8_t status; +#define TX_RECOVERY_MASK 0x0f +#define TX_ONR_RECOVERY 0x01 +#define TX_BUFF_RECOVERY 0x02 +#define RX_RECOVERY_MASK 0xf0 +#define RX_ONR_RECOVERY 0x10 + + unsigned char ch_start_rx; +#define CH_START_RX_NOW 1 +#define CH_START_RX_ONR 2 +#define CH_START_RX_BUF 3 + + unsigned char ch_start_tx; +#define CH_START_TX_1ST 1 +#define CH_START_TX_ONR 2 +#define CH_START_TX_BUF 3 + + char tx_full; /* boolean */ + short txd_free; /* count of TX Desc available */ + short txd_required; /* count of TX Desc needed by mesg */ + unsigned short rxd_num; /* must support range up to 2000 */ + unsigned short txd_num; /* must support range up to 1000 */ + int rxix_irq_srv; + + enum + { + UNASSIGNED, /* AVAILABLE, NOTINUSE */ + DOWN, /* ASSIGNED, NOTINUSE */ + UP /* ASSIGNED and INUSE */ + } state; + + struct c4_port_info *up; + void *user; + + struct work_struct ch_work; + struct mdesc *mdt; + struct mdesc *mdr; + struct mdesc *txd_irq_srv; + struct mdesc *txd_usr_add; + +#if 0 + /* + * FUTURE CODE MIGHT SEPARATE TIMESLOT MAP SETUPS INTO SINGLE IOCTL and + * REMOVE MAPS FROM CHANNEL PARAMETER STRUCTURE + */ + /* + * each byte in bitmask below represents one timeslot (bitmask[0] is for + * timeslot 0 and so on), each bit in the byte selects timeslot bits for + * this channel (0xff - whole timeslot, 0x7f - 56kbps mode) + */ + + u_int8_t ts_bitmask[32]; +#endif + spinlock_t ch_rxlock; + spinlock_t ch_txlock; + atomic_t tx_pending; + + struct sbecom_chan_stats s; + struct sbecom_chan_param p; +}; +typedef struct c4_chan_info mch_t; + +struct c4_port_info +{ + + struct musycc_globalr *reg; + struct musycc_groupr *regram; + void *regram_saved; /* Original malloc value may have non-2KB + * boundary. Need to save for use when + * freeing. */ + comet_t *cometbase; + struct sbe_card_info *up; + + /* + * The workqueue is used for TX restart of ONR'd channels when in + * Transparent mode. + */ + + struct workqueue_struct *wq_port; /* chan restart work queue */ + struct semaphore sr_sem_busy; /* service request exclusion + * semaphore */ + struct semaphore sr_sem_wait; /* service request handshake + * semaphore */ + u_int32_t sr_last; + short openchans; + char portnum; + char group_is_set; /* GROUP_INIT command issued to MUSYCC, + * otherwise SET_CHAN Ioctl fails */ + + mch_t *chan[MUSYCC_NCHANS]; + struct sbecom_port_param p; + + /* + * The MUSYCC timeslot mappings are maintained within the driver and are + * modified and reloaded as each of a group's channels are configured. + */ + u_int8_t tsm[32]; /* tsm (time slot map) */ + int fifomap[32]; +}; +typedef struct c4_port_info mpi_t; + + +#define COMET_OFFSET(x) (0x80000+(x)*0x10000) +#define EEPROM_OFFSET 0xC0000 +#define ISPLD_OFFSET 0xD0000 + +/* iSPLD control chip registers */ +#define ISPLD_MCSR 0x0 +#define ISPLD_MCLK 0x1 +#define ISPLD_LEDS 0x2 +#define ISPLD_INTR 0x3 +#define ISPLD_MAX 0x3 + +struct sbe_card_info +{ + struct musycc_globalr *reg; + struct musycc_groupr *regram; + u_int32_t *iqd_p; /* pointer to dword aligned interrupt queue + * descriptors */ + void *iqd_p_saved; /* Original malloc value may have non-dword + * aligned boundary. Need to save for use + * when freeing. */ + unsigned int iqp_headx, iqp_tailx; + + struct semaphore sem_wdbusy;/* watchdog exclusion semaphore */ + struct watchdog wd; /* statically allocated watchdog structure */ + atomic_t bh_pending; /* bh queued, but not yet running */ + u_int32_t brd_id; /* unique PCI ID */ + u_int16_t hdw_bid; /* on/board hardware ID */ + unsigned short wdcount; + unsigned char max_port; + unsigned char brdno; /* our board number */ + unsigned char wd_notify; +#define WD_NOTIFY_1TX 1 +#define WD_NOTIFY_BUF 2 +#define WD_NOTIFY_ONR 4 + enum /* state as regards interrupt processing */ + { + C_INIT, /* of-board-address not configured or are in + * process of being removed, don't access + * hardware */ + C_IDLE, /* off-board-addresses are configured, but + * don't service interrupts, just clear them + * from hardware */ + C_RUNNING /* life is good, service away */ + } state; + + struct sbe_card_info *next; + u_int32_t *eeprombase; /* mapped address of board's EEPROM */ + c4cpld_t *cpldbase; /* mapped address of board's CPLD hardware */ + char *release; /* SBE ID string w/in sbeRelease.c */ + void *hdw_info; +#ifdef CONFIG_PROC_FS + struct proc_dir_entry *dir_dev; +#endif + + /* saved off interface assignments which bound a board */ + hdlc_device *first_if; + hdlc_device *last_if; + short first_channum, last_channum; + + struct intlog + { + u_int32_t this_status_new; + u_int32_t last_status_new; + u_int32_t drvr_intr_thcount; + u_int32_t drvr_intr_bhcount; + u_int32_t drvr_int_failure; + } intlog; + + mpi_t port[MUSYCC_NPORTS]; + char devname[SBE_IFACETMPL_SIZE + 1]; + atomic_t tx_pending; + u_int32_t alarmed[4]; /* dpm211 */ + +#if defined(SBE_ISR_TASKLET) + struct tasklet_struct ci_musycc_isr_tasklet; +#elif defined(SBE_ISR_IMMEDIATE) + struct tq_struct ci_musycc_isr_tq; +#endif +}; +typedef struct sbe_card_info ci_t; + +struct s_hdw_info +{ + u_int8_t pci_busno; + u_int8_t pci_slot; + u_int8_t pci_pin[2]; + u_int8_t revid[2]; + u_int8_t mfg_info_sts; +#define EEPROM_OK 0x00 +#define EEPROM_CRCERR 0x01 + char promfmt; /* prom type, from sbe_promformat.h */ + + char devname[SBE_IFACETMPL_SIZE]; + struct pci_bus *bus; + struct net_device *ndev; + struct pci_dev *pdev[2]; + + unsigned long addr[2]; + unsigned long addr_mapped[2]; + unsigned long len[2]; + + union + { + char data[128]; + FLD_TYPE1 pft1; /* prom field, type #1 */ + FLD_TYPE2 pft2; /* prom field, type #2 */ + } mfg_info; +}; +typedef struct s_hdw_info hdw_info_t; + +/*****************************************************************/ + +struct c4_priv +{ + int channum; + struct sbe_card_info *ci; +}; + + +/*****************************************************************/ + +extern ci_t *c4_list; + +mch_t *c4_find_chan (int); +int c4_set_chan (int channum, struct sbecom_chan_param *); +int c4_get_chan (int channum, struct sbecom_chan_param *); +int c4_get_chan_stats (int channum, struct sbecom_chan_stats *); + +#endif /* _INC_PMCC4_PRIVATE_H_ */ diff --git a/drivers/staging/cxt1e1/pmcc4_sysdep.h b/drivers/staging/cxt1e1/pmcc4_sysdep.h new file mode 100644 index 000000000000..697f1943670f --- /dev/null +++ b/drivers/staging/cxt1e1/pmcc4_sysdep.h @@ -0,0 +1,62 @@ +#ifndef _INC_PMCC4_SYSDEP_H_ +#define _INC_PMCC4_SYSDEP_H_ + +/*----------------------------------------------------------------------------- + * pmcc4_sysdep.h - + * + * Copyright (C) 2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + */ + +/* reduce multiple autoconf entries to a single definition */ + +#ifdef CONFIG_SBE_PMCC4_HDLC_V7_MODULE +#undef CONFIG_SBE_PMCC4_HDLC_V7 +#define CONFIG_SBE_PMCC4_HDLC_V7 1 +#endif + +#ifdef CONFIG_SBE_PMCC4_NCOMM_MODULE +#undef CONFIG_SBE_PMCC4_NCOMM +#define CONFIG_SBE_PMCC4_NCOMM 1 +#endif + + +/* FLUSH MACROS - if using ioremap_nocache(), then these can be NOOPS, + * otherwise a memory barrier needs to be inserted. + */ + +#define FLUSH_PCI_READ() rmb() +#define FLUSH_PCI_WRITE() wmb() +#define FLUSH_MEM_READ() rmb() +#define FLUSH_MEM_WRITE() wmb() + + +/* + * System dependent callbacks routines, not inlined... + * For inlined system dependent routines, see include/sbecom_inlinux_linux.h + */ + +/* + * passes received memory token back to the system, <user> is parameter from + * sd_new_chan() used to create the channel which the data arrived on + */ + +void sd_recv_consume(void *token, size_t len, void *user); + +void sd_disable_xmit (void *user); +void sd_enable_xmit (void *user); +int sd_line_is_ok (void *user); +void sd_line_is_up (void *user); +void sd_line_is_down (void *user); +int sd_queue_stopped (void *user); + +#endif /*** _INC_PMCC4_SYSDEP_H_ ***/ diff --git a/drivers/staging/cxt1e1/sbe_bid.h b/drivers/staging/cxt1e1/sbe_bid.h new file mode 100644 index 000000000000..1f49b4061fb7 --- /dev/null +++ b/drivers/staging/cxt1e1/sbe_bid.h @@ -0,0 +1,61 @@ +/* + * $Id: sbe_bid.h,v 1.0 2005/09/28 00:10:09 rickd PMCC4_3_1B $ + */ + +#ifndef _INC_SBEBID_H_ +#define _INC_SBEBID_H_ + +/*----------------------------------------------------------------------------- + * sbe_bid.h - + * + * Copyright (C) 2004-2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + * + * For further information, contact via email: support@sbei.com + * SBE, Inc. San Ramon, California U.S.A. + * + *----------------------------------------------------------------------------- + * RCS info: + * RCS revision: $Revision: 1.0 $ + * Last changed on $Date: 2005/09/28 00:10:09 $ + * Changed by $Author: rickd $ + *----------------------------------------------------------------------------- + * $Log: sbe_bid.h,v $ + * Revision 1.0 2005/09/28 00:10:09 rickd + * Initial revision + * + *----------------------------------------------------------------------------- + */ + +#define SBE_BID_REG 0x00000000 /* Board ID Register */ + +#define SBE_BID_256T3_E1 0x46 /* SBE wanPTMC-256T3 (E1 Version) */ +#define SBE_BID_256T3_T1 0x42 /* SBE wanPTMC-256T3 (T1 Version) */ +#define SBE_BID_2T3E3 0x43 /* SBE wanPMC-2T3E3 */ +#define SBE_BID_C1T3 0x45 /* SBE wanPMC-C1T3 */ +#define SBE_BID_C24TE1 0x47 /* SBE wanPTMC-C24TE1 */ +#define SBE_BID_C24TE1_RTM_24 0x48 /* C24TE1 RTM (24 Port) */ +#define SBE_BID_C24TE1_RTM_12 0x49 /* C24TE1 RTM (12 Port) */ +#define SBE_BID_C24TE1_RTM_12DSU 0x4A /* C24TE1 RTM (12 Port/DSU) */ +#define SBE_BID_C24TE1_RTM_T3 0x4B /* C24TE1 RTM (T3) */ +#define SBE_BID_C4T1E1 0x41 /* SBE wanPTMC-C4T1E1 */ +#define SBE_BID_HC4T1E1 0x44 /* SBE wanADAPT-HC4T1E1 */ + +/* bogus temporary usage values */ +#define SBE_BID_PMC_C4T1E1 0xC4 /* SBE wanPMC-C4T1E1 (4 Port) */ +#define SBE_BID_PMC_C2T1E1 0xC2 /* SBE wanPMC-C2T1E1 (2 Port) */ +#define SBE_BID_PMC_C1T1E1 0xC1 /* SBE wanPMC-C1T1E1 (1 Port) */ +#define SBE_BID_PCI_C4T1E1 0x04 /* SBE wanPCI-C4T1E1 (4 Port) */ +#define SBE_BID_PCI_C2T1E1 0x02 /* SBE wanPCI-C2T1E1 (2 Port) */ +#define SBE_BID_PCI_C1T1E1 0x01 /* SBE wanPCI-C1T1E1 (1 Port) */ + +#endif /*** _INC_SBEBID_H_ ***/ diff --git a/drivers/staging/cxt1e1/sbe_promformat.h b/drivers/staging/cxt1e1/sbe_promformat.h new file mode 100644 index 000000000000..746f81b15c73 --- /dev/null +++ b/drivers/staging/cxt1e1/sbe_promformat.h @@ -0,0 +1,157 @@ +/* + * $Id: sbe_promformat.h,v 2.2 2005/09/28 00:10:09 rickd PMCC4_3_1B $ + */ + +#ifndef _INC_SBE_PROMFORMAT_H_ +#define _INC_SBE_PROMFORMAT_H_ + +/*----------------------------------------------------------------------------- + * sbe_promformat.h - Contents of seeprom used by dvt and manufacturing tests + * + * Copyright (C) 2002-2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + * + * For further information, contact via email: support@sbei.com + * SBE, Inc. San Ramon, California U.S.A. + * + *----------------------------------------------------------------------------- + * RCS info: + * RCS revision: $Revision: 2.2 $ + * Last changed on $Date: 2005/09/28 00:10:09 $ + * Changed by $Author: rickd $ + *----------------------------------------------------------------------------- + * $Log: sbe_promformat.h,v $ + * Revision 2.2 2005/09/28 00:10:09 rickd + * Add EEPROM sample from C4T1E1 board. + * + * Revision 2.1 2005/05/04 17:18:24 rickd + * Initial CI. + * + *----------------------------------------------------------------------------- + */ + + +/*** + * PMCC4 SAMPLE EEPROM IMAGE + * + * eeprom[00]: 01 11 76 07 01 00 a0 d6 + * eeprom[08]: 22 34 56 3e 5b c1 1c 3e + * eeprom[16]: 5b e1 b6 00 00 00 01 00 + * eeprom[24]: 00 08 46 d3 7b 5e a8 fb + * eeprom[32]: f7 ef df bf 7f 55 00 01 + * eeprom[40]: 02 04 08 10 20 40 80 ff + * eeprom[48]: fe fd fb f7 ef df bf 7f + * + ***/ + + +/*------------------------------------------------------------------------ + * Type 1 Format + * byte: + * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 + * ------------------------------------------------------------------------- + * 01 11 76 SS SS 00 0A D6 <SERIAL NUM> <Create TIME> <Heatrun TIME> + * SBE SUB SERIAL # (BCD) (time_t) (time_t) + * ID VENDOR (format) (format) + * + * 19 20 21 22 23 24 25 26 + * Heat Run Heat Run + * Iterations Errors + *------------------------------------------------------------------------ + * + * + * + * Type 2 Format - Added length, CRC in fixed position + * byte: + * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 + * ------------------------------------------------------------------------- + * 02 00 1A CC CC CC CC 11 76 07 03 00 0A D6 <SERIAL NUM> + * Payload SBE Crc32 SUB System System SERIAL/MAC + * Length VENDOR ID ID + * + * 17 18 19 20 21 22 23 24 25 26 27 28 29 39 31 32 + * -------------------------------------------------------------------------- + * <Create TIME> <Heatrun TIME> Heat Run Heat Run + * (time_t) (time_t) Iterations Errors + * + */ + +#ifdef __cplusplus +extern "C" +{ +#endif + + +#define STRUCT_OFFSET(type, symbol) ((long)&(((type *)0)->symbol)) + +/*------------------------------------------------------------------------ + * Historically different Prom format types. + * + * For diagnostic and failure purposes, do not create a type 0x00 or a + * type 0xff + *------------------------------------------------------------------------ + */ +#define PROM_FORMAT_Unk (-1) +#define PROM_FORMAT_TYPE1 1 +#define PROM_FORMAT_TYPE2 2 + + +/****** bit fields for a type 1 formatted seeprom **************************/ + typedef struct + { + char type; /* 0x00 */ + char Id[2]; /* 0x01-0x02 */ + char SubId[2]; /* 0x03-0x04 */ + char Serial[6]; /* 0x05-0x0a */ + char CreateTime[4]; /* 0x0b-0x0e */ + char HeatRunTime[4]; /* 0x0f-0x12 */ + char HeatRunIterations[4]; /* 0x13-0x16 */ + char HeatRunErrors[4]; /* 0x17-0x1a */ + char Crc32[4]; /* 0x1b-0x1e */ + } FLD_TYPE1; + + +/****** bit fields for a type 2 formatted seeprom **************************/ + typedef struct + { + char type; /* 0x00 */ + char length[2]; /* 0x01-0x02 */ + char Crc32[4]; /* 0x03-0x06 */ + char Id[2]; /* 0x07-0x08 */ + char SubId[2]; /* 0x09-0x0a */ + char Serial[6]; /* 0x0b-0x10 */ + char CreateTime[4]; /* 0x11-0x14 */ + char HeatRunTime[4]; /* 0x15-0x18 */ + char HeatRunIterations[4]; /* 0x19-0x1c */ + char HeatRunErrors[4]; /* 0x1d-0x20 */ + } FLD_TYPE2; + + + +/***** this union allows us to access the seeprom as an array of bytes ***/ +/***** or as individual fields ***/ + +#define SBE_EEPROM_SIZE 128 +#define SBE_MFG_INFO_SIZE sizeof(FLD_TYPE2) + + typedef union + { + char bytes[128]; + FLD_TYPE1 fldType1; + FLD_TYPE2 fldType2; + } PROMFORMAT; + +#ifdef __cplusplus +} +#endif + +#endif /*** _INC_SBE_PROMFORMAT_H_ ***/ diff --git a/drivers/staging/cxt1e1/sbecom_inline_linux.h b/drivers/staging/cxt1e1/sbecom_inline_linux.h new file mode 100644 index 000000000000..2ab1eb12ed38 --- /dev/null +++ b/drivers/staging/cxt1e1/sbecom_inline_linux.h @@ -0,0 +1,310 @@ +/* + * $Id: sbecom_inline_linux.h,v 1.2 2007/08/15 22:51:35 rickd PMCC4_3_1B $ + */ + +#ifndef _INC_SBECOM_INLNX_H_ +#define _INC_SBECOM_INLNX_H_ + +/*----------------------------------------------------------------------------- + * sbecom_inline_linux.h - SBE common Linux inlined routines + * + * Copyright (C) 2007 One Stop Systems, Inc. + * Copyright (C) 2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + * + * For further information, contact via email: support@onestopsystems.com + * One Stop Systems, Inc. Escondido, California U.S.A. + *----------------------------------------------------------------------------- + * RCS info: + * RCS revision: $Revision: 1.2 $ + * Last changed on $Date: 2007/08/15 22:51:35 $ + * Changed by $Author: rickd $ + *----------------------------------------------------------------------------- + * $Log: sbecom_inline_linux.h,v $ + * Revision 1.2 2007/08/15 22:51:35 rickd + * Remove duplicate version.h entry. + * + * Revision 1.1 2007/08/15 22:50:29 rickd + * Update linux/config for 2.6.18 and later. + * + * Revision 1.0 2005/09/28 00:10:09 rickd + * Initial revision + * + *----------------------------------------------------------------------------- + */ + + +#if defined (__FreeBSD__) || defined (__NetBSD__) +#include <sys/types.h> +#else +#include <linux/types.h> +#include <linux/version.h> +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) +#include <linux/config.h> +#endif +#if defined(CONFIG_SMP) && ! defined(__SMP__) +#define __SMP__ +#endif +#if defined(CONFIG_MODVERSIONS) && defined(MODULE) && ! defined(MODVERSIONS) +#define MODVERSIONS +#endif + +#ifdef MODULE +#ifdef MODVERSIONS +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) +#include <linux/modversions.h> +#else +#include <config/modversions.h> +#endif +#endif +#include <linux/module.h> +#endif +#endif + +#include <linux/kernel.h> /* resolves kmalloc references */ +#include <linux/skbuff.h> /* resolves skb references */ +#include <linux/netdevice.h> /* resolves dev_kree_skb_any */ +#include <asm/byteorder.h> /* resolves cpu_to_le32 */ + +#if 0 + +/*** PORT POINT WARNING + *** + *** Under Linux 2.6 it has been found that compiler is re-ordering + *** in-lined pci_write_32() functions to the detrement of correct + *** hardware setup. Therefore, inlining of PCI accesses has been + *** de-implemented, and subroutine calls have been implemented. + ***/ + +static inline u_int32_t +pci_read_32 (u_int32_t *p) +{ +#ifdef FLOW_DEBUG + u_int32_t v; + + FLUSH_PCI_READ (); + v = le32_to_cpu (*p); + if (log_level >= LOG_DEBUG) + printk ("pci_read : %x = %x\n", (u_int32_t) p, v); + return v; +#else + FLUSH_PCI_READ (); /* */ + return le32_to_cpu (*p); +#endif +} + +static inline void +pci_write_32 (u_int32_t *p, u_int32_t v) +{ +#ifdef FLOW_DEBUG + if (log_level >= LOG_DEBUG) + printk ("pci_write: %x = %x\n", (u_int32_t) p, v); +#endif + *p = cpu_to_le32 (v); + FLUSH_PCI_WRITE (); /* This routine is called from routines + * which do multiple register writes + * which themselves need flushing between + * writes in order to guarantee write + * ordering. It is less code-cumbersome + * to flush here-in then to investigate + * and code the many other register + * writing routines. */ +} +#else +/* forward reference */ +u_int32_t pci_read_32 (u_int32_t *p); +void pci_write_32 (u_int32_t *p, u_int32_t v); + +#endif + + +/* + * system dependent callbacks + */ + +/**********/ +/* malloc */ +/**********/ + +static inline void * +OS_kmalloc (size_t size) +{ + char *ptr = kmalloc (size, GFP_KERNEL | GFP_DMA); + + if (ptr) + memset (ptr, 0, size); + return ptr; +} + +static inline void +OS_kfree (void *x) +{ + kfree (x); +} + + +/****************/ +/* memory token */ +/****************/ + +static inline void * +OS_mem_token_alloc (size_t size) +{ + struct sk_buff *skb; + + skb = dev_alloc_skb (size); + if (!skb) + { + //printk (KERN_WARNING "no mem in OS_mem_token_alloc !"); + return 0; + } + return skb; +} + + +static inline void +OS_mem_token_free (void *token) +{ + dev_kfree_skb_any (token); +} + + +static inline void +OS_mem_token_free_irq (void *token) +{ + dev_kfree_skb_irq (token); +} + + +static inline void * +OS_mem_token_data (void *token) +{ + return ((struct sk_buff *) token)->data; +} + + +static inline void * +OS_mem_token_next (void *token) +{ + return 0; +} + + +static inline int +OS_mem_token_len (void *token) +{ + return ((struct sk_buff *) token)->len; +} + + +static inline int +OS_mem_token_tlen (void *token) +{ + return ((struct sk_buff *) token)->len; +} + + +/***************************************/ +/* virtual to physical addr conversion */ +/***************************************/ + +static inline u_long +OS_phystov (void *addr) +{ + return (u_long) __va (addr); +} + + +static inline u_long +OS_vtophys (void *addr) +{ + return __pa (addr); +} + + +/**********/ +/* semops */ +/**********/ + +void OS_sem_init (void *, int); + + +static inline void +OS_sem_free (void *sem) +{ + /* + * NOOP - since semaphores structures predeclared w/in structures, no + * longer malloc'd + */ +} + +#define SD_SEM_TAKE(sem,desc) down(sem) +#define SD_SEM_GIVE(sem) up(sem) +#define SEM_AVAILABLE 1 +#define SEM_TAKEN 0 + + +/**********************/ +/* watchdog functions */ +/**********************/ + +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; + int init_tq; +}; + + +static inline int +OS_start_watchdog (struct watchdog * wd) +{ + wd->h.expires = jiffies + wd->ticks; + add_timer (&wd->h); + return 0; +} + + +static inline int +OS_stop_watchdog (struct watchdog * wd) +{ + del_timer_sync (&wd->h); + return 0; +} + + +static inline int +OS_free_watchdog (struct watchdog * wd) +{ + OS_stop_watchdog (wd); + OS_kfree (wd); + return 0; +} + + +/* sleep in microseconds */ +void OS_uwait (int usec, char *description); +void OS_uwait_dummy (void); + + +/* watchdog functions */ +int OS_init_watchdog(struct watchdog *wdp, void (*f) (void *), void *ci, int usec); + + +#endif /*** _INC_SBECOM_INLNX_H_ ***/ diff --git a/drivers/staging/cxt1e1/sbecrc.c b/drivers/staging/cxt1e1/sbecrc.c new file mode 100644 index 000000000000..51232948091f --- /dev/null +++ b/drivers/staging/cxt1e1/sbecrc.c @@ -0,0 +1,137 @@ +/* Based on "File Verification Using CRC" by Mark R. Nelson in Dr. Dobbs' + * Journal, May 1992, pp. 64-67. This algorithm generates the same CRC + * values as ZMODEM and PKZIP + * + * Copyright (C) 2002-2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + */ + +#include <linux/types.h> +#include "pmcc4_sysdep.h" +#include "sbecom_inline_linux.h" +#include "sbe_promformat.h" + +/* defines */ +#define CRC32_POLYNOMIAL 0xEDB88320L +#define CRC_TABLE_ENTRIES 256 + + + +static u_int32_t crcTableInit; + +#ifdef STATIC_CRC_TABLE +static u_int32_t CRCTable[CRC_TABLE_ENTRIES]; + +#endif + + +/*************************************************************************** +* +* genCrcTable - fills in CRCTable, as used by sbeCrc() +* +* RETURNS: N/A +* +* ERRNO: N/A +***************************************************************************/ + +static void +genCrcTable (u_int32_t *CRCTable) +{ + int ii, jj; + u_int32_t crc; + + for (ii = 0; ii < CRC_TABLE_ENTRIES; ii++) + { + crc = ii; + for (jj = 8; jj > 0; jj--) + { + if (crc & 1) + crc = (crc >> 1) ^ CRC32_POLYNOMIAL; + else + crc >>= 1; + } + CRCTable[ii] = crc; + } + + crcTableInit++; +} + + +/*************************************************************************** +* +* sbeCrc - generates a CRC on a given buffer, and initial CRC +* +* This routine calculates the CRC for a buffer of data using the +* table lookup method. It accepts an original value for the crc, +* and returns the updated value. This permits "catenation" of +* discontiguous buffers. An original value of 0 for the "first" +* buffer is the norm. +* +* Based on "File Verification Using CRC" by Mark R. Nelson in Dr. Dobb's +* Journal, May 1992, pp. 64-67. This algorithm generates the same CRC +* values as ZMODEM and PKZIP. +* +* RETURNS: calculated crc of block +* +*/ + +void +sbeCrc (u_int8_t *buffer, /* data buffer to crc */ + u_int32_t count, /* length of block in bytes */ + u_int32_t initialCrc, /* starting CRC */ + u_int32_t *result) +{ + u_int32_t *tbl = 0; + u_int32_t temp1, temp2, crc; + + /* + * if table not yet created, do so. Don't care about "extra" time + * checking this everytime sbeCrc() is called, since CRC calculations are + * already time consuming + */ + if (!crcTableInit) + { +#ifdef STATIC_CRC_TABLE + tbl = &CRCTable; + genCrcTable (tbl); +#else + tbl = (u_int32_t *) OS_kmalloc (CRC_TABLE_ENTRIES * sizeof (u_int32_t)); + if (tbl == 0) + { + *result = 0; /* dummy up return value due to malloc + * failure */ + return; + } + genCrcTable (tbl); +#endif + } + /* inverting bits makes ZMODEM & PKZIP compatible */ + crc = initialCrc ^ 0xFFFFFFFFL; + + while (count-- != 0) + { + temp1 = (crc >> 8) & 0x00FFFFFFL; + temp2 = tbl[((int) crc ^ *buffer++) & 0xff]; + crc = temp1 ^ temp2; + } + + crc ^= 0xFFFFFFFFL; + + *result = crc; + +#ifndef STATIC_CRC_TABLE + crcTableInit = 0; + OS_kfree (tbl); +#endif +} + +/*** End-of-File ***/ diff --git a/drivers/staging/cxt1e1/sbeid.c b/drivers/staging/cxt1e1/sbeid.c new file mode 100644 index 000000000000..a2243b10ef05 --- /dev/null +++ b/drivers/staging/cxt1e1/sbeid.c @@ -0,0 +1,217 @@ +/* Copyright (C) 2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + */ + +#include <linux/types.h> +#include "pmcc4_sysdep.h" +#include "sbecom_inline_linux.h" +#include "libsbew.h" +#include "pmcc4_private.h" +#include "pmcc4.h" +#include "sbe_bid.h" + +#ifdef SBE_INCLUDE_SYMBOLS +#define STATIC +#else +#define STATIC static +#endif + + +char * +sbeid_get_bdname (ci_t * ci) +{ + char *np = 0; + + switch (ci->brd_id) + { + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_E1): + np = "wanPTMC-256T3 <E1>"; + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_T1): + np = "wanPTMC-256T3 <T1>"; + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C4T1E1): + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C4T1E1_L): + np = "wanPMC-C4T1E1"; + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C2T1E1): + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C2T1E1_L): + np = "wanPMC-C2T1E1"; + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T1E1): + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T1E1_L): + np = "wanPMC-C1T1E1"; + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C4T1E1): + np = "wanPCI-C4T1E1"; + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C2T1E1): + np = "wanPCI-C2T1E1"; + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C1T1E1): + np = "wanPCI-C1T1E1"; + break; + default: + /*** np = "<unknown>"; ***/ + np = "wanPCI-CxT1E1"; + break; + } + + return np; +} + + +/* given the presetting of brd_id, set the corresponding hdw_id */ + +void +sbeid_set_hdwbid (ci_t * ci) +{ + /* + * set SBE's unique hardware identification (for legacy boards might not + * have this register implemented) + */ + + switch (ci->brd_id) + { + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_E1): + ci->hdw_bid = SBE_BID_256T3_E1; /* 0x46 - SBE wanPTMC-256T3 (E1 + * Version) */ + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_T1): + ci->hdw_bid = SBE_BID_256T3_T1; /* 0x42 - SBE wanPTMC-256T3 (T1 + * Version) */ + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C4T1E1): + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C4T1E1_L): + /* + * This Board ID is a generic identification. Use the found number + * of ports to further define this hardware. + */ + switch (ci->max_port) + { + default: /* shouldn't need a default, but have one + * anyway */ + case 4: + ci->hdw_bid = SBE_BID_PMC_C4T1E1; /* 0xC4 - SBE wanPMC-C4T1E1 */ + break; + case 2: + ci->hdw_bid = SBE_BID_PMC_C2T1E1; /* 0xC2 - SBE wanPMC-C2T1E1 */ + ci->brd_id = SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C2T1E1); + break; + case 1: + ci->hdw_bid = SBE_BID_PMC_C1T1E1; /* 0xC1 - SBE wanPMC-C1T1E1 */ + ci->brd_id = SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T1E1); + break; + } + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C2T1E1): + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C2T1E1_L): + ci->hdw_bid = SBE_BID_PMC_C2T1E1; /* 0xC2 - SBE wanPMC-C2T1E1 */ + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T1E1): + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T1E1_L): + ci->hdw_bid = SBE_BID_PMC_C1T1E1; /* 0xC1 - SBE wanPMC-C1T1E1 */ + break; +#ifdef SBE_PMCC4_ENABLE + /* + * This case is entered as a result of the inability to obtain the + * <bid> from the board's EEPROM. Assume a PCI board and set + * <hdsbid> according to the number ofr found ports. + */ + case 0: + /* start by assuming 4-port for ZERO casing */ + ci->brd_id = SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C4T1E1); + /* drop thru to set hdw_bid and alternate PCI CxT1E1 settings */ +#endif + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C4T1E1): + /* + * This Board ID is a generic identification. Use the number of + * found ports to further define this hardware. + */ + switch (ci->max_port) + { + default: /* shouldn't need a default, but have one + * anyway */ + case 4: + ci->hdw_bid = SBE_BID_PCI_C4T1E1; /* 0x04 - SBE wanPCI-C4T1E1 */ + break; + case 2: + ci->hdw_bid = SBE_BID_PCI_C2T1E1; /* 0x02 - SBE wanPCI-C2T1E1 */ + ci->brd_id = SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C2T1E1); + break; + case 1: + ci->hdw_bid = SBE_BID_PCI_C1T1E1; /* 0x01 - SBE wanPCI-C1T1E1 */ + ci->brd_id = SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C1T1E1); + break; + } + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C2T1E1): + ci->hdw_bid = SBE_BID_PCI_C2T1E1; /* 0x02 - SBE wanPCI-C2T1E1 */ + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C1T1E1): + ci->hdw_bid = SBE_BID_PCI_C1T1E1; /* 0x01 - SBE wanPCI-C1T1E1 */ + break; + default: + /*** bid = "<unknown>"; ***/ + ci->hdw_bid = SBE_BID_PMC_C4T1E1; /* 0x41 - SBE wanPTMC-C4T1E1 */ + break; + } +} + +/* given the presetting of hdw_bid, set the corresponding brd_id */ + +void +sbeid_set_bdtype (ci_t * ci) +{ + /* set SBE's unique PCI VENDOR/DEVID */ + switch (ci->hdw_bid) + { + case SBE_BID_C1T3: /* SBE wanPMC-C1T3 */ + ci->brd_id = SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T3); + break; + case SBE_BID_C24TE1: /* SBE wanPTMC-C24TE1 */ + ci->brd_id = SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_C24TE1); + break; + case SBE_BID_256T3_E1: /* SBE wanPTMC-256T3 E1 Version */ + ci->brd_id = SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_E1); + break; + case SBE_BID_256T3_T1: /* SBE wanPTMC-256T3 T1 Version */ + ci->brd_id = SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_T1); + break; + case SBE_BID_PMC_C4T1E1: /* 0xC4 - SBE wanPMC-C4T1E1 */ + ci->brd_id = SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C4T1E1); + break; + case SBE_BID_PMC_C2T1E1: /* 0xC2 - SBE wanPMC-C2T1E1 */ + ci->brd_id = SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C2T1E1); + break; + case SBE_BID_PMC_C1T1E1: /* 0xC1 - SBE wanPMC-C1T1E1 */ + ci->brd_id = SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T1E1); + break; + case SBE_BID_PCI_C4T1E1: /* 0x04 - SBE wanPCI-C4T1E1 */ + ci->brd_id = SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C4T1E1); + break; + case SBE_BID_PCI_C2T1E1: /* 0x02 - SBE wanPCI-C2T1E1 */ + ci->brd_id = SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C2T1E1); + break; + case SBE_BID_PCI_C1T1E1: /* 0x01 - SBE wanPCI-C1T1E1 */ + ci->brd_id = SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C1T1E1); + break; + + default: + /*** hdw_bid = "<unknown>"; ***/ + ci->brd_id = SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C4T1E1); + break; + } +} + + +/*** End-of-File ***/ diff --git a/drivers/staging/cxt1e1/sbeproc.c b/drivers/staging/cxt1e1/sbeproc.c new file mode 100644 index 000000000000..61ca639c184f --- /dev/null +++ b/drivers/staging/cxt1e1/sbeproc.c @@ -0,0 +1,358 @@ +/* Copyright (C) 2004-2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + */ + +#include <linux/types.h> +#include <linux/module.h> +#include <linux/errno.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/proc_fs.h> +#include <linux/sched.h> +#include <asm/uaccess.h> +#include "pmcc4_sysdep.h" +#include "sbecom_inline_linux.h" +#include "pmcc4_private.h" +#include "sbeproc.h" + +/* forwards */ +void sbecom_get_brdinfo (ci_t *, struct sbe_brd_info *, u_int8_t *); +extern struct s_hdw_info hdw_info[MAX_BOARDS]; + +#ifdef CONFIG_PROC_FS + +/********************************************************************/ +/* procfs stuff */ +/********************************************************************/ + + +void +sbecom_proc_brd_cleanup (ci_t * ci) +{ + if (ci->dir_dev) + { + char dir[7 + SBE_IFACETMPL_SIZE + 1]; + snprintf(dir, sizeof(dir), "driver/%s", ci->devname); + remove_proc_entry("info", ci->dir_dev); + remove_proc_entry(dir, NULL); + ci->dir_dev = NULL; + } +} + + +static int +sbecom_proc_get_sbe_info (char *buffer, char **start, off_t offset, + int length, int *eof, void *priv) +{ + ci_t *ci = (ci_t *) priv; + int len = 0; + char *spd; + struct sbe_brd_info *bip; + + if (!(bip = OS_kmalloc (sizeof (struct sbe_brd_info)))) + { + return -ENOMEM; + } +#if 0 + /** RLD DEBUG **/ + printk (">> sbecom_proc_get_sbe_info: entered, offset %d. length %d.\n", + (int) offset, (int) length); +#endif + + { + hdw_info_t *hi = &hdw_info[ci->brdno]; + + u_int8_t *bsn = 0; + + switch (hi->promfmt) + { + case PROM_FORMAT_TYPE1: + bsn = (u_int8_t *) hi->mfg_info.pft1.Serial; + break; + case PROM_FORMAT_TYPE2: + bsn = (u_int8_t *) hi->mfg_info.pft2.Serial; + break; + } + + sbecom_get_brdinfo (ci, bip, bsn); + } + +#if 0 + /** RLD DEBUG **/ + printk (">> sbecom_get_brdinfo: returned, first_if %p <%s> last_if %p <%s>\n", + (char *) &bip->first_iname, (char *) &bip->first_iname, + (char *) &bip->last_iname, (char *) &bip->last_iname); +#endif + len += sprintf (buffer + len, "Board Type: "); + switch (bip->brd_id) + { + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T3): + len += sprintf (buffer + len, "wanPMC-C1T3"); + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_E1): + len += sprintf (buffer + len, "wanPTMC-256T3 <E1>"); + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_256T3_T1): + len += sprintf (buffer + len, "wanPTMC-256T3 <T1>"); + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPTMC_C24TE1): + len += sprintf (buffer + len, "wanPTMC-C24TE1"); + break; + + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C4T1E1): + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C4T1E1_L): + len += sprintf (buffer + len, "wanPMC-C4T1E1"); + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C2T1E1): + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C2T1E1_L): + len += sprintf (buffer + len, "wanPMC-C2T1E1"); + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T1E1): + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPMC_C1T1E1_L): + len += sprintf (buffer + len, "wanPMC-C1T1E1"); + break; + + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C4T1E1): + len += sprintf (buffer + len, "wanPCI-C4T1E1"); + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C2T1E1): + len += sprintf (buffer + len, "wanPCI-C2T1E1"); + break; + case SBE_BOARD_ID (PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_WANPCI_C1T1E1): + len += sprintf (buffer + len, "wanPCI-C1T1E1"); + break; + + default: + len += sprintf (buffer + len, "unknown"); + break; + } + len += sprintf (buffer + len, " [%08X]\n", bip->brd_id); + + len += sprintf (buffer + len, "Board Number: %d\n", bip->brdno); + len += sprintf (buffer + len, "Hardware ID: 0x%02X\n", ci->hdw_bid); + len += sprintf (buffer + len, "Board SN: %06X\n", bip->brd_sn); + len += sprintf (buffer + len, "Board MAC: %02X-%02X-%02X-%02X-%02X-%02X\n", + bip->brd_mac_addr[0], bip->brd_mac_addr[1], bip->brd_mac_addr[2], + bip->brd_mac_addr[3], bip->brd_mac_addr[4], bip->brd_mac_addr[5]); + len += sprintf (buffer + len, "Ports: %d\n", ci->max_port); + len += sprintf (buffer + len, "Channels: %d\n", bip->brd_chan_cnt); +#if 1 + len += sprintf (buffer + len, "Interface: %s -> %s\n", + (char *) &bip->first_iname, (char *) &bip->last_iname); +#else + len += sprintf (buffer + len, "Interface: <not available> 1st %p lst %p\n", + (char *) &bip->first_iname, (char *) &bip->last_iname); +#endif + + switch (bip->brd_pci_speed) + { + case BINFO_PCI_SPEED_33: + spd = "33Mhz"; + break; + case BINFO_PCI_SPEED_66: + spd = "66Mhz"; + break; + default: + spd = "<not available>"; + break; + } + len += sprintf (buffer + len, "PCI Bus Speed: %s\n", spd); + len += sprintf (buffer + len, "Release: %s\n", ci->release); + +#ifdef SBE_PMCC4_ENABLE + { + extern int max_mru; +#if 0 + extern int max_chans_used; + extern int max_mtu; +#endif + extern int max_rxdesc_used, max_txdesc_used; + + len += sprintf (buffer + len, "\nmax_mru: %d\n", max_mru); +#if 0 + len += sprintf (buffer + len, "\nmax_chans_used: %d\n", max_chans_used); + len += sprintf (buffer + len, "max_mtu: %d\n", max_mtu); +#endif + len += sprintf (buffer + len, "max_rxdesc_used: %d\n", max_rxdesc_used); + len += sprintf (buffer + len, "max_txdesc_used: %d\n", max_txdesc_used); + } +#endif + + OS_kfree (bip); /* cleanup */ + + /*** + * How to be a proc read function + * ------------------------------ + * Prototype: + * int f(char *buffer, char **start, off_t offset, + * int count, int *peof, void *dat) + * + * Assume that the buffer is "count" bytes in size. + * + * If you know you have supplied all the data you + * have, set *peof. + * + * You have three ways to return data: + * 0) Leave *start = NULL. (This is the default.) + * Put the data of the requested offset at that + * offset within the buffer. Return the number (n) + * of bytes there are from the beginning of the + * buffer up to the last byte of data. If the + * number of supplied bytes (= n - offset) is + * greater than zero and you didn't signal eof + * and the reader is prepared to take more data + * you will be called again with the requested + * offset advanced by the number of bytes + * absorbed. This interface is useful for files + * no larger than the buffer. + * 1) Set *start = an unsigned long value less than + * the buffer address but greater than zero. + * Put the data of the requested offset at the + * beginning of the buffer. Return the number of + * bytes of data placed there. If this number is + * greater than zero and you didn't signal eof + * and the reader is prepared to take more data + * you will be called again with the requested + * offset advanced by *start. This interface is + * useful when you have a large file consisting + * of a series of blocks which you want to count + * and return as wholes. + * (Hack by Paul.Russell@rustcorp.com.au) + * 2) Set *start = an address within the buffer. + * Put the data of the requested offset at *start. + * Return the number of bytes of data placed there. + * If this number is greater than zero and you + * didn't signal eof and the reader is prepared to + * take more data you will be called again with the + * requested offset advanced by the number of bytes + * absorbed. + */ + +#if 1 + /* #4 - intepretation of above = set EOF, return len */ + *eof = 1; +#endif + +#if 0 + /* + * #1 - from net/wireless/atmel.c RLD NOTE -there's something wrong with + * this plagarized code which results in this routine being called TWICE. + * The second call returns ZERO, resulting in hidden failure, but at + * least only a single message set is being displayed. + */ + if (len <= offset + length) + *eof = 1; + *start = buffer + offset; + len -= offset; + if (len > length) + len = length; + if (len < 0) + len = 0; +#endif + +#if 0 /* #2 from net/tokenring/olympic.c + + * lanstreamer.c */ + { + off_t begin = 0; + int size = 0; + off_t pos = 0; + + size = len; + pos = begin + size; + if (pos < offset) + { + len = 0; + begin = pos; + } + *start = buffer + (offset - begin); /* Start of wanted data */ + len -= (offset - begin); /* Start slop */ + if (len > length) + len = length; /* Ending slop */ + } +#endif + +#if 0 /* #3 from + * char/ftape/lowlevel/ftape-proc.c */ + len = strlen (buffer); + *start = NULL; + if (offset + length >= len) + *eof = 1; + else + *eof = 0; +#endif + +#if 0 + printk (">> proc_fs: returned len = %d., start %p\n", len, start); /* RLD DEBUG */ +#endif + +/*** + using NONE: returns = 314.314.314. + using #1 : returns = 314, 0. + using #2 : returns = 314, 0, 0. + using #3 : returns = 314, 314. + using #4 : returns = 314, 314. +***/ + + return len; +} + +/* initialize the /proc subsystem for the specific SBE driver */ + +int __init +sbecom_proc_brd_init (ci_t * ci) +{ + struct proc_dir_entry *e; + char dir[7 + SBE_IFACETMPL_SIZE + 1]; + + /* create a directory in the root procfs */ + snprintf(dir, sizeof(dir), "driver/%s", ci->devname); + ci->dir_dev = proc_mkdir(dir, NULL); + if (!ci->dir_dev) + { + printk (KERN_ERR "%s: Unable to create directory /proc/driver/%s\n", + THIS_MODULE->name, ci->devname); + goto fail; + } + e = create_proc_read_entry ("info", S_IFREG | S_IRUGO, + ci->dir_dev, sbecom_proc_get_sbe_info, ci); + if (!e) + { + printk (KERN_ERR "%s: Unable to create entry /proc/driver/%s/info\n", + THIS_MODULE->name, ci->devname); + goto fail; + } + return 0; + +fail: + sbecom_proc_brd_cleanup (ci); + return 1; +} + +#else /*** ! CONFIG_PROC_FS ***/ + +/* stubbed off dummy routines */ + +void +sbecom_proc_brd_cleanup (ci_t * ci) +{ +} + +int __init +sbecom_proc_brd_init (ci_t * ci) +{ + return 0; +} + +#endif /*** CONFIG_PROC_FS ***/ + + +/*** End-of-File ***/ diff --git a/drivers/staging/cxt1e1/sbeproc.h b/drivers/staging/cxt1e1/sbeproc.h new file mode 100644 index 000000000000..4aa53f44ec0b --- /dev/null +++ b/drivers/staging/cxt1e1/sbeproc.h @@ -0,0 +1,52 @@ +/* + * $Id: sbeproc.h,v 1.2 2005/10/17 23:55:28 rickd PMCC4_3_1B $ + */ + +#ifndef _INC_SBEPROC_H_ +#define _INC_SBEPROC_H_ + +/*----------------------------------------------------------------------------- + * sbeproc.h - + * + * Copyright (C) 2004-2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + * + * For further information, contact via email: support@sbei.com + * SBE, Inc. San Ramon, California U.S.A. + *----------------------------------------------------------------------------- + * RCS info: + * RCS revision: $Revision: 1.2 $ + * Last changed on $Date: 2005/10/17 23:55:28 $ + * Changed by $Author: rickd $ + *----------------------------------------------------------------------------- + * $Log: sbeproc.h,v $ + * Revision 1.2 2005/10/17 23:55:28 rickd + * sbecom_proc_brd_init() is an declared an __init function. + * + * Revision 1.1 2005/09/28 00:10:09 rickd + * Remove unneeded inclusion of c4_private.h. + * + * Revision 1.0 2005/05/10 22:21:46 rickd + * Initial check-in. + * + *----------------------------------------------------------------------------- + */ + + +#ifdef CONFIG_PROC_FS +#ifdef __KERNEL__ +void sbecom_proc_brd_cleanup (ci_t *); +int __init sbecom_proc_brd_init (ci_t *); + +#endif /*** __KERNEL__ ***/ +#endif /*** CONFIG_PROC_FS ***/ +#endif /*** _INC_SBEPROC_H_ ***/ diff --git a/drivers/staging/cxt1e1/sbew_ioc.h b/drivers/staging/cxt1e1/sbew_ioc.h new file mode 100644 index 000000000000..14d371904d1f --- /dev/null +++ b/drivers/staging/cxt1e1/sbew_ioc.h @@ -0,0 +1,136 @@ +/* + * $Id: sbew_ioc.h,v 1.0 2005/09/28 00:10:10 rickd PMCC4_3_1B $ + */ + +#ifndef _INC_SBEWIOC_H_ +#define _INC_SBEWIOC_H_ + +/*----------------------------------------------------------------------------- + * sbew_ioc.h - + * + * Copyright (C) 2002-2005 SBE, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This 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. + * + * For further information, contact via email: support@sbei.com + * SBE, Inc. San Ramon, California U.S.A. + * + *----------------------------------------------------------------------------- + * RCS info: + * RCS revision: $Revision: 1.0 $ + * Last changed on $Date: 2005/09/28 00:10:10 $ + * Changed by $Author: rickd $ + *----------------------------------------------------------------------------- + * $Log: sbew_ioc.h,v $ + * Revision 1.0 2005/09/28 00:10:10 rickd + * Initial revision + * + * Revision 1.6 2005/01/11 18:41:01 rickd + * Add BRDADDR_GET Ioctl. + * + * Revision 1.5 2004/09/16 18:55:59 rickd + * Start setting up for generic framer configuration Ioctl by switch + * from tect3_framer_param[] to sbecom_framer_param[]. + * + * Revision 1.4 2004/06/28 17:58:15 rickd + * Rename IOC_TSMAP_[GS] to IOC_TSIOC_[GS] to support need for + * multiple formats of data when setting up TimeSlots. + * + * Revision 1.3 2004/06/22 21:18:13 rickd + * read_vec now() ONLY handles a single common wrt_vec array. + * + * Revision 1.1 2004/06/10 18:11:34 rickd + * Add IID_GET Ioctl reference. + * + * Revision 1.0 2004/06/08 22:59:38 rickd + * Initial revision + * + * Revision 2.0 2004/06/07 17:49:47 rickd + * Initial library release following merge of wanc1t3/wan256 into + * common elements for lib. + * + *----------------------------------------------------------------------------- + */ + +#ifndef __KERNEL__ +#include <sys/types.h> +#endif +#ifdef SunOS +#include <sys/ioccom.h> +#else +#include <linux/ioctl.h> +#endif + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define SBE_LOCKFILE "/tmp/.sbewan.LCK" + +#define SBE_IOC_COOKIE 0x19780926 +#define SBE_IOC_MAGIC ('s') + +/* IOW write - data has to go into driver from application */ +/* IOR read - data has to be returned to application from driver */ + +/* + * Note: for an IOWR Ioctl, the read and write data do not have to + * be the same size, but the entity declared within the IOC must be + * the larger of the two. + */ + +#define SBE_IOC_LOGLEVEL _IOW(SBE_IOC_MAGIC, 0x00, int) +#define SBE_IOC_CHAN_NEW _IOW(SBE_IOC_MAGIC, 0x01,int) /* unused */ +#define SBE_IOC_CHAN_UP _IOW(SBE_IOC_MAGIC, 0x02,int) /* unused */ +#define SBE_IOC_CHAN_DOWN _IOW(SBE_IOC_MAGIC, 0x03,int) /* unused */ +#define SBE_IOC_CHAN_GET _IOWR(SBE_IOC_MAGIC,0x04, struct sbecom_chan_param) +#define SBE_IOC_CHAN_SET _IOW(SBE_IOC_MAGIC, 0x05, struct sbecom_chan_param) +#define SBE_IOC_CHAN_GET_STAT _IOWR(SBE_IOC_MAGIC,0x06, struct sbecom_chan_stats) +#define SBE_IOC_CHAN_DEL_STAT _IOW(SBE_IOC_MAGIC, 0x07, int) +#define SBE_IOC_PORTS_ENABLE _IOW(SBE_IOC_MAGIC, 0x0A, int) +#define SBE_IOC_PORT_GET _IOWR(SBE_IOC_MAGIC,0x0C, struct sbecom_port_param) +#define SBE_IOC_PORT_SET _IOW(SBE_IOC_MAGIC, 0x0D, struct sbecom_port_param) +#define SBE_IOC_READ_VEC _IOWR(SBE_IOC_MAGIC,0x10, struct sbecom_wrt_vec) +#define SBE_IOC_WRITE_VEC _IOWR(SBE_IOC_MAGIC,0x11, struct sbecom_wrt_vec) +#define SBE_IOC_GET_SN _IOR(SBE_IOC_MAGIC, 0x12, u_int32_t) +#define SBE_IOC_RESET_DEV _IOW(SBE_IOC_MAGIC, 0x13, int) +#define SBE_IOC_FRAMER_GET _IOWR(SBE_IOC_MAGIC,0x14, struct sbecom_framer_param) +#define SBE_IOC_FRAMER_SET _IOW(SBE_IOC_MAGIC, 0x15, struct sbecom_framer_param) +#define SBE_IOC_CARD_GET _IOR(SBE_IOC_MAGIC, 0x20, struct sbecom_card_param) +#define SBE_IOC_CARD_SET _IOW(SBE_IOC_MAGIC, 0x21, struct sbecom_card_param) +#define SBE_IOC_CARD_GET_STAT _IOR(SBE_IOC_MAGIC, 0x22, struct temux_card_stats) +#define SBE_IOC_CARD_DEL_STAT _IO(SBE_IOC_MAGIC, 0x23) +#define SBE_IOC_CARD_CHAN_STAT _IOR(SBE_IOC_MAGIC, 0x24, struct sbecom_chan_stats) +#define SBE_IOC_CARD_BLINK _IOW(SBE_IOC_MAGIC, 0x30, int) +#define SBE_IOC_DRVINFO_GET _IOWR(SBE_IOC_MAGIC,0x31, struct sbe_drv_info) +#define SBE_IOC_BRDINFO_GET _IOR(SBE_IOC_MAGIC, 0x32, struct sbe_brd_info) +#define SBE_IOC_IID_GET _IOWR(SBE_IOC_MAGIC,0x33, struct sbe_iid_info) +#define SBE_IOC_BRDADDR_GET _IOWR(SBE_IOC_MAGIC, 0x34, struct sbe_brd_addr) + +#ifdef NOT_YET_COMMON +#define SBE_IOC_TSIOC_GET _IOWR(SBE_IOC_MAGIC,0x16, struct wanc1t3_ts_param) +#define SBE_IOC_TSIOC_SET _IOW(SBE_IOC_MAGIC, 0x17, struct wanc1t3_ts_param) +#endif + +/* + * Restrict SBE_IOC_WRITE_VEC & READ_VEC to a single parameter pair, application + * then must issue multiple Ioctls for large blocks of contiguous data. + */ + +#define SBE_IOC_MAXVEC 1 + + +#ifdef __cplusplus +} +#endif + +#endif /*** _INC_SBEWIOC_H_ ***/ diff --git a/drivers/staging/dream/Kconfig b/drivers/staging/dream/Kconfig index 4afa081c870c..707cc71a8a6a 100644 --- a/drivers/staging/dream/Kconfig +++ b/drivers/staging/dream/Kconfig @@ -1,16 +1,14 @@ config DREAM - tristate "HTC Dream support" - depends on BROKEN + tristate "HTC Dream support" + depends on MACH_TROUT +if DREAM source "drivers/staging/dream/smd/Kconfig" source "drivers/staging/dream/camera/Kconfig" - config INPUT_GPIO tristate "GPIO driver support" help Say Y here if you want to support gpio based keys, wheels etc... - - - +endif diff --git a/drivers/staging/dream/Makefile b/drivers/staging/dream/Makefile index 2b7915197078..43d1eec8e257 100644 --- a/drivers/staging/dream/Makefile +++ b/drivers/staging/dream/Makefile @@ -1,3 +1,4 @@ +EXTRA_CFLAGS=-Idrivers/staging/dream/include obj-$(CONFIG_MSM_ADSP) += qdsp5/ smd/ obj-$(CONFIG_MSM_CAMERA) += camera/ obj-$(CONFIG_INPUT_GPIO) += gpio_axis.o gpio_event.o gpio_input.o gpio_matrix.o gpio_output.o diff --git a/drivers/staging/dream/TODO b/drivers/staging/dream/TODO index c07c8803f07c..dcd3ba808655 100644 --- a/drivers/staging/dream/TODO +++ b/drivers/staging/dream/TODO @@ -1,4 +1,3 @@ -* remove support for wakelocks since those are not in mainline * camera driver uses old V4L API diff --git a/drivers/staging/dream/pmem.c b/drivers/staging/dream/pmem.c index 6edfdd4ef804..dbd2b1d14c4f 100644 --- a/drivers/staging/dream/pmem.c +++ b/drivers/staging/dream/pmem.c @@ -38,17 +38,17 @@ * the file should not be released until put_pmem_file is called */ #define PMEM_FLAGS_BUSY 0x1 /* indicates that this is a suballocation of a larger master range */ -#define PMEM_FLAGS_CONNECTED ( 0x1 << 1 ) +#define PMEM_FLAGS_CONNECTED (0x1 << 1) /* indicates this is a master and not a sub allocation and that it is mmaped */ -#define PMEM_FLAGS_MASTERMAP ( 0x1 << 2 ) +#define PMEM_FLAGS_MASTERMAP (0x1 << 2) /* submap and unsubmap flags indicate: * 00: subregion has never been mmaped * 10: subregion has been mmaped, reference to the mm was taken * 11: subretion has ben released, refernece to the mm still held * 01: subretion has been released, reference to the mm has been released */ -#define PMEM_FLAGS_SUBMAP ( 0x1 << 3 ) -#define PMEM_FLAGS_UNSUBMAP ( 0x1 << 4 ) +#define PMEM_FLAGS_SUBMAP (0x1 << 3) +#define PMEM_FLAGS_UNSUBMAP (0x1 << 4) struct pmem_data { @@ -153,7 +153,7 @@ struct pmem_info { static struct pmem_info pmem[PMEM_MAX_DEVICES]; static int id_count; -#define PMEM_IS_FREE(id, index) ( !(pmem[id].bitmap[index].allocated) ) +#define PMEM_IS_FREE(id, index) (!(pmem[id].bitmap[index].allocated)) #define PMEM_ORDER(id, index) pmem[id].bitmap[index].order #define PMEM_BUDDY_INDEX(id, index) (index ^ (1 << PMEM_ORDER(id, index))) #define PMEM_NEXT_INDEX(id, index) (index + (1 << PMEM_ORDER(id, index))) @@ -845,8 +845,8 @@ static int pmem_connect(unsigned long connect, struct file *file) src_data = (struct pmem_data *)src_file->private_data; if (has_allocation(file) && (data->index != src_data->index)) { - printk(KERN_INFO "pmem: file is already mapped but doesn't match this" - " src_file!\n"); + printk(KERN_INFO "pmem: file is already mapped but doesn't " + "match this src_file!\n"); ret = -EINVAL; goto err_bad_file; } @@ -935,8 +935,8 @@ int pmem_remap(struct pmem_region *region, struct file *file, if (unlikely(!PMEM_IS_PAGE_ALIGNED(region->offset) || !PMEM_IS_PAGE_ALIGNED(region->len))) { #if PMEM_DEBUG - printk(KERN_DEBUG "pmem: request for unaligned pmem suballocation " - "%lx %lx\n", region->offset, region->len); + printk(KERN_DEBUG "pmem: request for unaligned pmem " + "suballocation %lx %lx\n", region->offset, region->len); #endif return -EINVAL; } @@ -1086,8 +1086,8 @@ static long pmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg) region.offset = pmem_start_addr(id, data); region.len = pmem_len(id, data); } - printk(KERN_INFO "pmem: request for physical address of pmem region " - "from process %d.\n", current->pid); + printk(KERN_INFO "pmem: request for physical address " + "of pmem region from process %d.\n", current->pid); if (copy_to_user((void __user *)arg, ®ion, sizeof(struct pmem_region))) return -EFAULT; diff --git a/drivers/staging/dream/qdsp5/audio_out.c b/drivers/staging/dream/qdsp5/audio_out.c index fe7809dd4401..76d7fa5667d5 100644 --- a/drivers/staging/dream/qdsp5/audio_out.c +++ b/drivers/staging/dream/qdsp5/audio_out.c @@ -182,9 +182,6 @@ struct audio { int stopped; /* set when stopped, cleared on flush */ unsigned volume; - struct wake_lock wakelock; - struct wake_lock idlelock; - int adrc_enable; struct adrc_filter adrc; @@ -198,14 +195,10 @@ struct audio { static void audio_prevent_sleep(struct audio *audio) { printk(KERN_INFO "++++++++++++++++++++++++++++++\n"); - wake_lock(&audio->wakelock); - wake_lock(&audio->idlelock); } static void audio_allow_sleep(struct audio *audio) { - wake_unlock(&audio->wakelock); - wake_unlock(&audio->idlelock); printk(KERN_INFO "------------------------------\n"); } @@ -840,8 +833,6 @@ static int __init audio_init(void) mutex_init(&the_audio.write_lock); spin_lock_init(&the_audio.dsp_lock); init_waitqueue_head(&the_audio.wait); - wake_lock_init(&the_audio.wakelock, WAKE_LOCK_SUSPEND, "audio_pcm"); - wake_lock_init(&the_audio.idlelock, WAKE_LOCK_IDLE, "audio_pcm_idle"); return (misc_register(&audio_misc) || misc_register(&audpp_misc)); } diff --git a/drivers/staging/dream/smd/smd_private.h b/drivers/staging/dream/smd/smd_private.h index c0eb3de1be54..1b2e1c89ea2e 100644 --- a/drivers/staging/dream/smd/smd_private.h +++ b/drivers/staging/dream/smd/smd_private.h @@ -16,24 +16,21 @@ #ifndef _ARCH_ARM_MACH_MSM_MSM_SMD_PRIVATE_H_ #define _ARCH_ARM_MACH_MSM_MSM_SMD_PRIVATE_H_ -struct smem_heap_info -{ +struct smem_heap_info { unsigned initialized; unsigned free_offset; unsigned heap_remaining; unsigned reserved; }; -struct smem_heap_entry -{ +struct smem_heap_entry { unsigned allocated; unsigned offset; unsigned size; unsigned reserved; }; -struct smem_proc_comm -{ +struct smem_proc_comm { unsigned command; unsigned status; unsigned data1; @@ -49,22 +46,19 @@ struct smem_proc_comm #define VERSION_APPS 8 #define VERSION_MODEM 9 -struct smem_shared -{ +struct smem_shared { struct smem_proc_comm proc_comm[4]; unsigned version[32]; struct smem_heap_info heap_info; struct smem_heap_entry heap_toc[128]; }; -struct smsm_shared -{ +struct smsm_shared { unsigned host; unsigned state; }; -struct smsm_interrupt_info -{ +struct smsm_interrupt_info { uint32_t aArm_en_mask; uint32_t aArm_interrupts_pending; uint32_t aArm_wakeup_reason; @@ -108,8 +102,7 @@ void smsm_print_sleep_info(void); #define SMEM_NUM_SMD_CHANNELS 64 -typedef enum -{ +typedef enum { /* fixed items */ SMEM_PROC_COMM = 0, SMEM_HEAP_INFO, diff --git a/drivers/staging/dream/smd/smd_qmi.c b/drivers/staging/dream/smd/smd_qmi.c index 687db142904c..76fce5142d9e 100644 --- a/drivers/staging/dream/smd/smd_qmi.c +++ b/drivers/staging/dream/smd/smd_qmi.c @@ -25,7 +25,7 @@ #include <linux/miscdevice.h> #include <linux/workqueue.h> -#include <asm/uaccess.h> +#include <linux/uaccess.h> #include <mach/msm_smd.h> #define QMI_CTL 0x00 @@ -211,11 +211,10 @@ static int qmi_send(struct qmi_ctxt *ctxt, struct qmi_msg *msg) qmi_dump_msg(msg, "send"); - if (msg->service == QMI_CTL) { + if (msg->service == QMI_CTL) hlen = QMUX_HEADER - 1; - } else { + else hlen = QMUX_HEADER; - } /* QMUX length is total header + total payload - IFC selector */ len = hlen + msg->size - 1; @@ -248,11 +247,10 @@ static int qmi_send(struct qmi_ctxt *ctxt, struct qmi_msg *msg) /* len + 1 takes the interface selector into account */ r = smd_write(ctxt->ch, msg->tlv - hlen, len + 1); - if (r != len) { + if (r != len) return -1; - } else { + else return 0; - } } static void qmi_process_ctl_msg(struct qmi_ctxt *ctxt, struct qmi_msg *msg) @@ -376,7 +374,7 @@ static void qmi_process_broadcast_wds_msg(struct qmi_ctxt *ctxt, static void qmi_process_wds_msg(struct qmi_ctxt *ctxt, struct qmi_msg *msg) { - printk("wds: %04x @ %02x\n", msg->type, msg->client_id); + printk(KERN_INFO "wds: %04x @ %02x\n", msg->type, msg->client_id); if (msg->client_id == ctxt->wds_client_id) { qmi_process_unicast_wds_msg(ctxt, msg); } else if (msg->client_id == 0xff) { @@ -504,9 +502,8 @@ static void qmi_notify(void *priv, unsigned event) case SMD_EVENT_DATA: { int sz; sz = smd_cur_packet_size(ctxt->ch); - if ((sz > 0) && (sz <= smd_read_avail(ctxt->ch))) { + if ((sz > 0) && (sz <= smd_read_avail(ctxt->ch))) queue_work(qmi_wq, &ctxt->read_work); - } break; } case SMD_EVENT_OPEN: @@ -643,11 +640,10 @@ static int qmi_print_state(struct qmi_ctxt *ctxt, char *buf, int max) } i = scnprintf(buf, max, "STATE=%s\n", statename); - i += scnprintf(buf + i, max - i, "CID=%d\n",ctxt->wds_client_id); + i += scnprintf(buf + i, max - i, "CID=%d\n", ctxt->wds_client_id); - if (ctxt->state != STATE_ONLINE){ + if (ctxt->state != STATE_ONLINE) return i; - } i += scnprintf(buf + i, max - i, "ADDR=%d.%d.%d.%d\n", ctxt->addr[0], ctxt->addr[1], ctxt->addr[2], ctxt->addr[3]); diff --git a/drivers/staging/dream/smd/smd_rpcrouter_servers.c b/drivers/staging/dream/smd/smd_rpcrouter_servers.c index 1b152abb2783..bec3ee9371b3 100644 --- a/drivers/staging/dream/smd/smd_rpcrouter_servers.c +++ b/drivers/staging/dream/smd/smd_rpcrouter_servers.c @@ -42,7 +42,6 @@ static struct msm_rpc_endpoint *endpoint; static LIST_HEAD(rpc_server_list); static DEFINE_MUTEX(rpc_server_list_lock); static int rpc_servers_active; -static struct wake_lock rpc_servers_wake_lock; static void rpc_server_register(struct msm_rpc_server *server) { @@ -136,10 +135,8 @@ static int rpc_servers_thread(void *data) int rc; for (;;) { - wake_unlock(&rpc_servers_wake_lock); rc = wait_event_interruptible(endpoint->wait_q, !list_empty(&endpoint->read_q)); - wake_lock(&rpc_servers_wake_lock); rc = msm_rpc_read(endpoint, &buffer, -1, -1); if (rc < 0) { printk(KERN_ERR "%s: could not read: %d\n", @@ -219,7 +216,6 @@ static struct platform_driver rpcservers_driver = { static int __init rpc_servers_init(void) { - wake_lock_init(&rpc_servers_wake_lock, WAKE_LOCK_SUSPEND, "rpc_server"); return platform_driver_register(&rpcservers_driver); } diff --git a/drivers/staging/dream/synaptics_i2c_rmi.c b/drivers/staging/dream/synaptics_i2c_rmi.c index d2ca116a1c25..1f020dad6234 100644 --- a/drivers/staging/dream/synaptics_i2c_rmi.c +++ b/drivers/staging/dream/synaptics_i2c_rmi.c @@ -109,9 +109,7 @@ static void decode_report(struct synaptics_ts_data *ts, u8 *buf) int f, a; int base = 2; int z = buf[1]; - int w = buf[0] >> 4; int finger = buf[0] & 7; - int finger2_pressed; for (f = 0; f < 2; f++) { u32 flip_flag = SYNAPTICS_FLIP_X; @@ -151,14 +149,7 @@ static void decode_report(struct synaptics_ts_data *ts, u8 *buf) input_report_abs(ts->input_dev, ABS_Y, pos[0][1]); } input_report_abs(ts->input_dev, ABS_PRESSURE, z); - input_report_abs(ts->input_dev, ABS_TOOL_WIDTH, w); input_report_key(ts->input_dev, BTN_TOUCH, finger); - finger2_pressed = finger > 1 && finger != 7; - input_report_key(ts->input_dev, BTN_2, finger2_pressed); - if (finger2_pressed) { - input_report_abs(ts->input_dev, ABS_HAT0X, pos[1][0]); - input_report_abs(ts->input_dev, ABS_HAT0Y, pos[1][1]); - } input_sync(ts->input_dev); } @@ -208,8 +199,6 @@ static void synaptics_ts_work_func(struct work_struct *work) decode_report(ts, buf); } - if (ts->use_irq) - enable_irq(ts->client->irq); } static enum hrtimer_restart synaptics_ts_timer_func(struct hrtimer *timer) @@ -227,8 +216,7 @@ static irqreturn_t synaptics_ts_irq_handler(int irq, void *dev_id) { struct synaptics_ts_data *ts = dev_id; - disable_irq_nosync(ts->client->irq); - queue_work(synaptics_wq, &ts->work); + synaptics_ts_work_func(&ts->work); return IRQ_HANDLED; } @@ -347,11 +335,6 @@ static void compute_areas(struct synaptics_ts_data *ts, -inactive_area_top, max_y + inactive_area_bottom, fuzz_y, 0); input_set_abs_params(ts->input_dev, ABS_PRESSURE, 0, 255, fuzz_p, 0); - input_set_abs_params(ts->input_dev, ABS_TOOL_WIDTH, 0, 15, fuzz_w, 0); - input_set_abs_params(ts->input_dev, ABS_HAT0X, -inactive_area_left, - max_x + inactive_area_right, fuzz_x, 0); - input_set_abs_params(ts->input_dev, ABS_HAT0Y, -inactive_area_top, - max_y + inactive_area_bottom, fuzz_y, 0); } static struct synaptics_i2c_rmi_platform_data fake_pdata; @@ -487,7 +470,6 @@ static int __devinit synaptics_ts_probe( __set_bit(EV_SYN, ts->input_dev->evbit); __set_bit(EV_KEY, ts->input_dev->evbit); __set_bit(BTN_TOUCH, ts->input_dev->keybit); - __set_bit(BTN_2, ts->input_dev->keybit); __set_bit(EV_ABS, ts->input_dev->evbit); compute_areas(ts, pdata, max_x, max_y); @@ -500,8 +482,10 @@ static int __devinit synaptics_ts_probe( goto err_input_register_device_failed; } if (client->irq) { - ret = request_irq(client->irq, synaptics_ts_irq_handler, - 0, client->name, ts); + ret = request_threaded_irq(client->irq, NULL, + synaptics_ts_irq_handler, + IRQF_TRIGGER_LOW|IRQF_ONESHOT, + client->name, ts); if (ret == 0) { ret = i2c_set(ts, 0xf1, 0x01, "enable abs int"); if (ret) @@ -535,6 +519,7 @@ err_input_register_device_failed: err_input_dev_alloc_failed: err_detect_failed: err_power_failed: + i2c_set_clientdata(client, NULL); kfree(ts); err_alloc_data_failed: err_check_functionality_failed: @@ -552,6 +537,7 @@ static int synaptics_ts_remove(struct i2c_client *client) else hrtimer_cancel(&ts->timer); input_unregister_device(ts->input_dev); + i2c_set_clientdata(client, NULL); kfree(ts); return 0; } diff --git a/drivers/staging/dt3155/allocator.c b/drivers/staging/dt3155/allocator.c index db382ef90217..bd5adbc2a238 100644 --- a/drivers/staging/dt3155/allocator.c +++ b/drivers/staging/dt3155/allocator.c @@ -45,7 +45,6 @@ # define MODULE #endif -#include <linux/version.h> #include <linux/sched.h> #include <linux/kernel.h> @@ -59,6 +58,8 @@ #include <asm/page.h> +#include "allocator.h" + /*#define ALL_DEBUG*/ #define ALL_MSG "allocator: " @@ -84,9 +85,9 @@ /*#define PDEBUGG(fmt, args...) printk( KERN_DEBUG ALL_MSG fmt, ## args)*/ -int allocator_himem = 1; /* 0 = probe, pos. = megs, neg. = disable */ -int allocator_step = 1; /* This is the step size in MB */ -int allocator_probe = 1; /* This is a flag -- 1=probe, 0=don't probe */ +static int allocator_himem = 1; /* 0 = probe, pos. = megs, neg. = disable */ +static int allocator_step = 1; /* This is the step size in MB */ +static int allocator_probe = 1; /* This is a flag -- 1=probe, 0=don't probe */ static unsigned long allocator_buffer; /* physical address */ static unsigned long allocator_buffer_size; /* kilobytes */ @@ -102,8 +103,7 @@ struct allocator_struct { struct allocator_struct *next; }; -struct allocator_struct *allocator_list; - +static struct allocator_struct *allocator_list; #ifdef ALL_DEBUG static int dump_list(void) @@ -125,7 +125,7 @@ static int dump_list(void) * be used straight ahead for DMA, but needs remapping for program use). */ -unsigned long allocator_allocate_dma(unsigned long kilobytes, int prio) +unsigned long allocator_allocate_dma(unsigned long kilobytes, gfp_t flags) { struct allocator_struct *ptr = allocator_list, *newptr; unsigned long bytes = kilobytes << 10; @@ -148,7 +148,7 @@ unsigned long allocator_allocate_dma(unsigned long kilobytes, int prio) PDEBUG("alloc failed\n"); return 0; /* end of list */ } - newptr = kmalloc(sizeof(struct allocator_struct), prio); + newptr = kmalloc(sizeof(struct allocator_struct), flags); if (!newptr) return 0; diff --git a/drivers/staging/dt3155/allocator.h b/drivers/staging/dt3155/allocator.h index bdf3268ca52d..425b70fcd500 100644 --- a/drivers/staging/dt3155/allocator.h +++ b/drivers/staging/dt3155/allocator.h @@ -22,7 +22,7 @@ * */ -void allocator_free_dma(unsigned long address); -unsigned long allocator_allocate_dma(unsigned long kilobytes, int priority); +int allocator_free_dma(unsigned long address); +unsigned long allocator_allocate_dma(unsigned long kilobytes, gfp_t flags); int allocator_init(u32 *); void allocator_cleanup(void); diff --git a/drivers/staging/dt3155/dt3155.h b/drivers/staging/dt3155/dt3155.h index 1bf786364eec..793e2fcf4466 100644 --- a/drivers/staging/dt3155/dt3155.h +++ b/drivers/staging/dt3155/dt3155.h @@ -34,19 +34,9 @@ MA 02111-1307 USA #ifndef _DT3155_INC #define _DT3155_INC -#ifdef __KERNEL__ #include <linux/types.h> #include <linux/time.h> /* struct timeval */ -#else -#include <sys/ioctl.h> -#include <sys/param.h> -#include <sys/time.h> -#include <unistd.h> -#endif - -#define TRUE 1 -#define FALSE 0 /* Uncomment this for 50Hz CCIR */ #define CCIR 1 @@ -62,15 +52,15 @@ MA 02111-1307 USA #ifdef CCIR #define DT3155_MAX_ROWS 576 #define DT3155_MAX_COLS 768 -#define FORMAT50HZ TRUE +#define FORMAT50HZ 1 #else #define DT3155_MAX_ROWS 480 #define DT3155_MAX_COLS 640 -#define FORMAT50HZ FALSE +#define FORMAT50HZ 0 #endif /* Configuration structure */ -struct dt3155_config_s { +struct dt3155_config { u32 acq_mode; u32 cols, rows; u32 continuous; @@ -78,20 +68,20 @@ struct dt3155_config_s { /* hold data for each frame */ -typedef struct { +struct frame_info { u32 addr; /* address of the buffer with the frame */ u32 tag; /* unique number for the frame */ struct timeval time; /* time that capture took place */ -} frame_info_t; +}; /* * Structure for interrupt and buffer handling. * This is the setup for 1 card */ -struct dt3155_fbuffer_s { +struct dt3155_fbuffer { int nbuffers; - frame_info_t frame_info[BOARD_MAX_BUFFS]; + struct frame_info frame_info[BOARD_MAX_BUFFS]; int empty_buffers[BOARD_MAX_BUFFS]; /* indexes empty frames */ int empty_len; /* Number of empty buffers */ @@ -120,20 +110,20 @@ struct dt3155_fbuffer_s { #define DT3155_ACQ 2 /* There is one status structure for each card. */ -typedef struct dt3155_status_s { +struct dt3155_status { int fixed_mode; /* if 1, we are in fixed frame mode */ u32 reg_addr; /* Register address for a single card */ u32 mem_addr; /* Buffer start addr for this card */ u32 mem_size; /* This is the amount of mem available */ u32 irq; /* this card's irq */ - struct dt3155_config_s config; /* configuration struct */ - struct dt3155_fbuffer_s fbuffer; /* frame buffer state struct */ + struct dt3155_config config; /* configuration struct */ + struct dt3155_fbuffer fbuffer; /* frame buffer state struct */ u32 state; /* this card's state */ u32 device_installed; /* Flag if installed. 1=installed */ -} dt3155_status_t; +}; /* Reference to global status structure */ -extern struct dt3155_status_s dt3155_status[MAXBOARDS]; +extern struct dt3155_status dt3155_status[MAXBOARDS]; #define DT3155_STATE_IDLE 0x00 #define DT3155_STATE_FRAME 0x01 @@ -144,8 +134,8 @@ extern struct dt3155_status_s dt3155_status[MAXBOARDS]; #define DT3155_IOC_MAGIC '!' -#define DT3155_SET_CONFIG _IOW(DT3155_IOC_MAGIC, 1, struct dt3155_config_s) -#define DT3155_GET_CONFIG _IOR(DT3155_IOC_MAGIC, 2, struct dt3155_status_s) +#define DT3155_SET_CONFIG _IOW(DT3155_IOC_MAGIC, 1, struct dt3155_config) +#define DT3155_GET_CONFIG _IOR(DT3155_IOC_MAGIC, 2, struct dt3155_status) #define DT3155_STOP _IO(DT3155_IOC_MAGIC, 3) #define DT3155_START _IO(DT3155_IOC_MAGIC, 4) #define DT3155_FLUSH _IO(DT3155_IOC_MAGIC, 5) @@ -160,12 +150,12 @@ extern struct dt3155_status_s dt3155_status[MAXBOARDS]; #define DT_ERR_MASK 0xff0000/* not used but it might be one day */ /* User code will probably want to declare one of these for each card */ -typedef struct dt3155_read_s { +struct dt3155_read { u32 offset; u32 frame_seq; u32 state; - frame_info_t frame_info; -} dt3155_read_t; + struct frame_info frame_info; +}; #endif /* _DT3155_inc */ diff --git a/drivers/staging/dt3155/dt3155_drv.c b/drivers/staging/dt3155/dt3155_drv.c index 7ac2c6d8e9a3..40ef97f3feb5 100644 --- a/drivers/staging/dt3155/dt3155_drv.c +++ b/drivers/staging/dt3155/dt3155_drv.c @@ -63,6 +63,7 @@ extern void printques(int); #include <linux/types.h> #include <linux/poll.h> #include <linux/sched.h> +#include <linux/smp_lock.h> #include <asm/io.h> #include <asm/uaccess.h> @@ -94,7 +95,7 @@ int dt3155_errno = 0; #endif /* wait queue for interrupts */ -wait_queue_head_t dt3155_read_wait_queue[ MAXBOARDS ]; +wait_queue_head_t dt3155_read_wait_queue[MAXBOARDS]; #define DT_3155_SUCCESS 0 #define DT_3155_FAILURE -EIO @@ -111,10 +112,10 @@ int dt3155_major = 0; /* Global structures and variables */ /* Status of each device */ -struct dt3155_status_s dt3155_status[ MAXBOARDS ]; +struct dt3155_status dt3155_status[MAXBOARDS]; /* kernel logical address of the board */ -u8 *dt3155_lbase[ MAXBOARDS ] = { NULL +u8 *dt3155_lbase[MAXBOARDS] = { NULL #if MAXBOARDS == 2 , NULL #endif @@ -122,7 +123,7 @@ u8 *dt3155_lbase[ MAXBOARDS ] = { NULL /* DT3155 registers */ u8 *dt3155_bbase = NULL; /* kernel logical address of the * * buffer region */ -u32 dt3155_dev_open[ MAXBOARDS ] = {0 +u32 dt3155_dev_open[MAXBOARDS] = {0 #if MAXBOARDS == 2 , 0 #endif @@ -141,17 +142,17 @@ static void quick_stop (int minor) { // TODO: scott was here #if 1 - ReadMReg((dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg); + ReadMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg); /* disable interrupts */ int_csr_r.fld.FLD_END_EVE_EN = 0; int_csr_r.fld.FLD_END_ODD_EN = 0; - WriteMReg((dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg ); + WriteMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg); - dt3155_status[ minor ].state &= ~(DT3155_STATE_STOP|0xff); + dt3155_status[minor].state &= ~(DT3155_STATE_STOP|0xff); /* mark the system stopped: */ - dt3155_status[ minor ].state |= DT3155_STATE_IDLE; - dt3155_fbuffer[ minor ]->stop_acquire = 0; - dt3155_fbuffer[ minor ]->even_stopped = 0; + dt3155_status[minor].state |= DT3155_STATE_IDLE; + dt3155_fbuffer[minor]->stop_acquire = 0; + dt3155_fbuffer[minor]->even_stopped = 0; #else dt3155_status[minor].state |= DT3155_STATE_STOP; dt3155_status[minor].fbuffer.stop_acquire = 1; @@ -167,7 +168,7 @@ static void quick_stop (int minor) * - Assumes irq's are disabled, via SA_INTERRUPT flag * being set in request_irq() call from init_module() *****************************************************/ -static inline void dt3155_isr( int irq, void *dev_id, struct pt_regs *regs ) +static void dt3155_isr(int irq, void *dev_id, struct pt_regs *regs) { int minor = -1; int index; @@ -175,8 +176,8 @@ static inline void dt3155_isr( int irq, void *dev_id, struct pt_regs *regs ) u32 buffer_addr; /* find out who issued the interrupt */ - for ( index = 0; index < ndevices; index++ ) { - if( dev_id == (void*) &dt3155_status[ index ]) + for (index = 0; index < ndevices; index++) { + if(dev_id == (void*) &dt3155_status[index]) { minor = index; break; @@ -184,15 +185,15 @@ static inline void dt3155_isr( int irq, void *dev_id, struct pt_regs *regs ) } /* hopefully we should not get here */ - if ( minor < 0 || minor >= MAXBOARDS ) { + if (minor < 0 || minor >= MAXBOARDS) { printk(KERN_ERR "dt3155_isr called with invalid dev_id\n"); return; } /* Check for corruption and set a flag if so */ - ReadMReg( (dt3155_lbase[ minor ] + CSR1), csr1_r.reg ); + ReadMReg((dt3155_lbase[minor] + CSR1), csr1_r.reg); - if ( (csr1_r.fld.FLD_CRPT_EVE) || (csr1_r.fld.FLD_CRPT_ODD) ) + if ((csr1_r.fld.FLD_CRPT_EVE) || (csr1_r.fld.FLD_CRPT_ODD)) { /* TODO: this should probably stop acquisition */ /* and set some flags so that dt3155_read */ @@ -202,27 +203,27 @@ static inline void dt3155_isr( int irq, void *dev_id, struct pt_regs *regs ) return; } - ReadMReg((dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg); + ReadMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg); /* Handle the even field ... */ if (int_csr_r.fld.FLD_END_EVE) { - if ( (dt3155_status[ minor ].state & DT3155_STATE_MODE) == - DT3155_STATE_FLD ) + if ((dt3155_status[minor].state & DT3155_STATE_MODE) == + DT3155_STATE_FLD) { - dt3155_fbuffer[ minor ]->frame_count++; + dt3155_fbuffer[minor]->frame_count++; } - ReadI2C(dt3155_lbase[ minor ], EVEN_CSR, &i2c_even_csr.reg); + ReadI2C(dt3155_lbase[minor], EVEN_CSR, &i2c_even_csr.reg); /* Clear the interrupt? */ int_csr_r.fld.FLD_END_EVE = 1; /* disable the interrupt if last field */ - if (dt3155_fbuffer[ minor ]->stop_acquire) + if (dt3155_fbuffer[minor]->stop_acquire) { printk("dt3155: even stopped.\n"); - dt3155_fbuffer[ minor ]->even_stopped = 1; + dt3155_fbuffer[minor]->even_stopped = 1; if (i2c_even_csr.fld.SNGL_EVE) { int_csr_r.fld.FLD_END_EVE_EN = 0; @@ -233,75 +234,75 @@ static inline void dt3155_isr( int irq, void *dev_id, struct pt_regs *regs ) } } - WriteMReg( (dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg ); + WriteMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg); /* Set up next DMA if we are doing FIELDS */ - if ( (dt3155_status[ minor ].state & DT3155_STATE_MODE ) == + if ((dt3155_status[minor].state & DT3155_STATE_MODE) == DT3155_STATE_FLD) { /* GCS (Aug 2, 2002) -- In field mode, dma the odd field into the lower half of the buffer */ - const u32 stride = dt3155_status[ minor ].config.cols; - buffer_addr = dt3155_fbuffer[ minor ]-> - frame_info[ dt3155_fbuffer[ minor ]->active_buf ].addr + const u32 stride = dt3155_status[minor].config.cols; + buffer_addr = dt3155_fbuffer[minor]-> + frame_info[dt3155_fbuffer[minor]->active_buf].addr + (DT3155_MAX_ROWS / 2) * stride; local_save_flags(flags); local_irq_disable(); - wake_up_interruptible( &dt3155_read_wait_queue[ minor ] ); + wake_up_interruptible(&dt3155_read_wait_queue[minor]); /* Set up the DMA address for the next field */ local_irq_restore(flags); - WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_START), buffer_addr); + WriteMReg((dt3155_lbase[minor] + ODD_DMA_START), buffer_addr); } /* Check for errors. */ i2c_even_csr.fld.DONE_EVE = 1; - if ( i2c_even_csr.fld.ERROR_EVE ) + if (i2c_even_csr.fld.ERROR_EVE) dt3155_errno = DT_ERR_OVERRUN; - WriteI2C( dt3155_lbase[ minor ], EVEN_CSR, i2c_even_csr.reg ); + WriteI2C(dt3155_lbase[minor], EVEN_CSR, i2c_even_csr.reg); /* Note that we actually saw an even field meaning */ /* that subsequent odd field complete the frame */ - dt3155_fbuffer[ minor ]->even_happened = 1; + dt3155_fbuffer[minor]->even_happened = 1; /* recording the time that the even field finished, this should be */ /* about time in the middle of the frame */ - do_gettimeofday( &(dt3155_fbuffer[ minor ]-> - frame_info[ dt3155_fbuffer[ minor ]-> - active_buf ].time) ); + do_gettimeofday(&(dt3155_fbuffer[minor]-> + frame_info[dt3155_fbuffer[minor]-> + active_buf].time)); return; } /* ... now handle the odd field */ - if ( int_csr_r.fld.FLD_END_ODD ) + if (int_csr_r.fld.FLD_END_ODD) { - ReadI2C( dt3155_lbase[ minor ], ODD_CSR, &i2c_odd_csr.reg ); + ReadI2C(dt3155_lbase[minor], ODD_CSR, &i2c_odd_csr.reg); /* Clear the interrupt? */ int_csr_r.fld.FLD_END_ODD = 1; - if (dt3155_fbuffer[ minor ]->even_happened || - (dt3155_status[ minor ].state & DT3155_STATE_MODE) == + if (dt3155_fbuffer[minor]->even_happened || + (dt3155_status[minor].state & DT3155_STATE_MODE) == DT3155_STATE_FLD) { - dt3155_fbuffer[ minor ]->frame_count++; + dt3155_fbuffer[minor]->frame_count++; } - if ( dt3155_fbuffer[ minor ]->stop_acquire && - dt3155_fbuffer[ minor ]->even_stopped ) + if (dt3155_fbuffer[minor]->stop_acquire && + dt3155_fbuffer[minor]->even_stopped) { printk(KERN_DEBUG "dt3155: stopping odd..\n"); - if ( i2c_odd_csr.fld.SNGL_ODD ) + if (i2c_odd_csr.fld.SNGL_ODD) { /* disable interrupts */ int_csr_r.fld.FLD_END_ODD_EN = 0; - dt3155_status[ minor ].state &= ~(DT3155_STATE_STOP|0xff); + dt3155_status[minor].state &= ~(DT3155_STATE_STOP|0xff); /* mark the system stopped: */ - dt3155_status[ minor ].state |= DT3155_STATE_IDLE; - dt3155_fbuffer[ minor ]->stop_acquire = 0; - dt3155_fbuffer[ minor ]->even_stopped = 0; + dt3155_status[minor].state |= DT3155_STATE_IDLE; + dt3155_fbuffer[minor]->stop_acquire = 0; + dt3155_fbuffer[minor]->even_stopped = 0; printk(KERN_DEBUG "dt3155: state is now %x\n", dt3155_status[minor].state); @@ -312,104 +313,104 @@ static inline void dt3155_isr( int irq, void *dev_id, struct pt_regs *regs ) } } - WriteMReg( (dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg ); + WriteMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg); /* if the odd field has been acquired, then */ /* change the next dma location for both fields */ /* and wake up the process if sleeping */ - if ( dt3155_fbuffer[ minor ]->even_happened || - (dt3155_status[ minor ].state & DT3155_STATE_MODE) == - DT3155_STATE_FLD ) + if (dt3155_fbuffer[minor]->even_happened || + (dt3155_status[minor].state & DT3155_STATE_MODE) == + DT3155_STATE_FLD) { local_save_flags(flags); local_irq_disable(); #ifdef DEBUG_QUES_B - printques( minor ); + printques(minor); #endif - if ( dt3155_fbuffer[ minor ]->nbuffers > 2 ) + if (dt3155_fbuffer[minor]->nbuffers > 2) { - if ( !are_empty_buffers( minor ) ) + if (!are_empty_buffers(minor)) { /* The number of active + locked buffers is * at most 2, and since there are none empty, there * must be at least nbuffers-2 ready buffers. * This is where we 'drop frames', oldest first. */ - push_empty( pop_ready( minor ), minor ); + push_empty(pop_ready(minor), minor); } /* The ready_que can't be full, since we know * there is one active buffer right now, so it's safe * to push the active buf on the ready_que. */ - push_ready( minor, dt3155_fbuffer[ minor ]->active_buf ); + push_ready(minor, dt3155_fbuffer[minor]->active_buf); /* There's at least 1 empty -- make it active */ - dt3155_fbuffer[ minor ]->active_buf = pop_empty( minor ); - dt3155_fbuffer[ minor ]-> - frame_info[ dt3155_fbuffer[ minor ]-> - active_buf ].tag = ++unique_tag; + dt3155_fbuffer[minor]->active_buf = pop_empty(minor); + dt3155_fbuffer[minor]-> + frame_info[dt3155_fbuffer[minor]-> + active_buf].tag = ++unique_tag; } else /* nbuffers == 2, special case */ { /* There is 1 active buffer. * If there is a locked buffer, keep the active buffer * the same -- that means we drop a frame. */ - if ( dt3155_fbuffer[ minor ]->locked_buf < 0 ) + if (dt3155_fbuffer[minor]->locked_buf < 0) { - push_ready( minor, - dt3155_fbuffer[ minor ]->active_buf ); - if (are_empty_buffers( minor ) ) + push_ready(minor, + dt3155_fbuffer[minor]->active_buf); + if (are_empty_buffers(minor)) { - dt3155_fbuffer[ minor ]->active_buf = - pop_empty( minor ); + dt3155_fbuffer[minor]->active_buf = + pop_empty(minor); } else { /* no empty or locked buffers, so use a readybuf */ - dt3155_fbuffer[ minor ]->active_buf = - pop_ready( minor ); + dt3155_fbuffer[minor]->active_buf = + pop_ready(minor); } } } #ifdef DEBUG_QUES_B - printques( minor ); + printques(minor); #endif - dt3155_fbuffer[ minor ]->even_happened = 0; + dt3155_fbuffer[minor]->even_happened = 0; - wake_up_interruptible( &dt3155_read_wait_queue[ minor ] ); + wake_up_interruptible(&dt3155_read_wait_queue[minor]); local_irq_restore(flags); } /* Set up the DMA address for the next frame/field */ - buffer_addr = dt3155_fbuffer[ minor ]-> - frame_info[ dt3155_fbuffer[ minor ]->active_buf ].addr; - if ( (dt3155_status[ minor ].state & DT3155_STATE_MODE) == - DT3155_STATE_FLD ) + buffer_addr = dt3155_fbuffer[minor]-> + frame_info[dt3155_fbuffer[minor]->active_buf].addr; + if ((dt3155_status[minor].state & DT3155_STATE_MODE) == + DT3155_STATE_FLD) { - WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_START), buffer_addr); + WriteMReg((dt3155_lbase[minor] + EVEN_DMA_START), buffer_addr); } else { - WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_START), buffer_addr); + WriteMReg((dt3155_lbase[minor] + EVEN_DMA_START), buffer_addr); - WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_START), buffer_addr - + dt3155_status[ minor ].config.cols); + WriteMReg((dt3155_lbase[minor] + ODD_DMA_START), buffer_addr + + dt3155_status[minor].config.cols); } /* Do error checking */ i2c_odd_csr.fld.DONE_ODD = 1; - if ( i2c_odd_csr.fld.ERROR_ODD ) + if (i2c_odd_csr.fld.ERROR_ODD) dt3155_errno = DT_ERR_OVERRUN; - WriteI2C(dt3155_lbase[ minor ], ODD_CSR, i2c_odd_csr.reg ); + WriteI2C(dt3155_lbase[minor], ODD_CSR, i2c_odd_csr.reg); return; } /* If we get here, the Odd Field wasn't it either... */ - printk( "neither even nor odd. shared perhaps?\n"); + printk("neither even nor odd. shared perhaps?\n"); } /***************************************************** @@ -420,22 +421,22 @@ static inline void dt3155_isr( int irq, void *dev_id, struct pt_regs *regs ) *****************************************************/ static void dt3155_init_isr(int minor) { - const u32 stride = dt3155_status[ minor ].config.cols; + const u32 stride = dt3155_status[minor].config.cols; - switch (dt3155_status[ minor ].state & DT3155_STATE_MODE) + switch (dt3155_status[minor].state & DT3155_STATE_MODE) { case DT3155_STATE_FLD: { - even_dma_start_r = dt3155_status[ minor ]. - fbuffer.frame_info[ dt3155_status[ minor ].fbuffer.active_buf ].addr; + even_dma_start_r = dt3155_status[minor]. + fbuffer.frame_info[dt3155_status[minor].fbuffer.active_buf].addr; even_dma_stride_r = 0; odd_dma_stride_r = 0; - WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_START), + WriteMReg((dt3155_lbase[minor] + EVEN_DMA_START), even_dma_start_r); - WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_STRIDE), + WriteMReg((dt3155_lbase[minor] + EVEN_DMA_STRIDE), even_dma_stride_r); - WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_STRIDE), + WriteMReg((dt3155_lbase[minor] + ODD_DMA_STRIDE), odd_dma_stride_r); break; } @@ -443,19 +444,19 @@ static void dt3155_init_isr(int minor) case DT3155_STATE_FRAME: default: { - even_dma_start_r = dt3155_status[ minor ]. - fbuffer.frame_info[ dt3155_status[ minor ].fbuffer.active_buf ].addr; + even_dma_start_r = dt3155_status[minor]. + fbuffer.frame_info[dt3155_status[minor].fbuffer.active_buf].addr; odd_dma_start_r = even_dma_start_r + stride; even_dma_stride_r = stride; odd_dma_stride_r = stride; - WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_START), + WriteMReg((dt3155_lbase[minor] + EVEN_DMA_START), even_dma_start_r); - WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_START), + WriteMReg((dt3155_lbase[minor] + ODD_DMA_START), odd_dma_start_r); - WriteMReg((dt3155_lbase[ minor ] + EVEN_DMA_STRIDE), + WriteMReg((dt3155_lbase[minor] + EVEN_DMA_STRIDE), even_dma_stride_r); - WriteMReg((dt3155_lbase[ minor ] + ODD_DMA_STRIDE), + WriteMReg((dt3155_lbase[minor] + ODD_DMA_STRIDE), odd_dma_stride_r); break; } @@ -464,9 +465,9 @@ static void dt3155_init_isr(int minor) /* 50/60 Hz should be set before this point but let's make sure it is */ /* right anyway */ - ReadI2C(dt3155_lbase[ minor ], CSR2, &i2c_csr2.reg); + ReadI2C(dt3155_lbase[minor], CSR2, &i2c_csr2.reg); i2c_csr2.fld.HZ50 = FORMAT50HZ; - WriteI2C(dt3155_lbase[ minor ], CSR2, i2c_csr2.reg); + WriteI2C(dt3155_lbase[minor], CSR2, i2c_csr2.reg); /* enable busmaster chip, clear flags */ @@ -486,7 +487,7 @@ static void dt3155_init_isr(int minor) csr1_r.fld.FLD_CRPT_EVE = 1; /* writing a 1 clears flags */ csr1_r.fld.FLD_CRPT_ODD = 1; - WriteMReg((dt3155_lbase[ minor ] + CSR1),csr1_r.reg); + WriteMReg((dt3155_lbase[minor] + CSR1),csr1_r.reg); /* Enable interrupts at the end of each field */ @@ -495,14 +496,14 @@ static void dt3155_init_isr(int minor) int_csr_r.fld.FLD_END_ODD_EN = 1; int_csr_r.fld.FLD_START_EN = 0; - WriteMReg((dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg); + WriteMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg); /* start internal BUSY bits */ - ReadI2C(dt3155_lbase[ minor ], CSR2, &i2c_csr2.reg); + ReadI2C(dt3155_lbase[minor], CSR2, &i2c_csr2.reg); i2c_csr2.fld.BUSY_ODD = 1; i2c_csr2.fld.BUSY_EVE = 1; - WriteI2C(dt3155_lbase[ minor ], CSR2, i2c_csr2.reg); + WriteI2C(dt3155_lbase[minor], CSR2, i2c_csr2.reg); /* Now its up to the interrupt routine!! */ @@ -521,7 +522,7 @@ static int dt3155_ioctl(struct inode *inode, { int minor = MINOR(inode->i_rdev); /* What device are we ioctl()'ing? */ - if ( minor >= MAXBOARDS || minor < 0 ) + if (minor >= MAXBOARDS || minor < 0) return -ENODEV; /* make sure it is valid command */ @@ -545,7 +546,7 @@ static int dt3155_ioctl(struct inode *inode, return -EBUSY; { - struct dt3155_config_s tmp; + struct dt3155_config tmp; if (copy_from_user((void *)&tmp, (void *) arg, sizeof(tmp))) return -EFAULT; /* check for valid settings */ @@ -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], - sizeof(dt3155_status_t) )) + sizeof(struct dt3155_status))) return -EFAULT; return 0; } @@ -586,7 +587,7 @@ static int dt3155_ioctl(struct inode *inode, quick_stop(minor); if (copy_to_user((void *) arg, (void *) &dt3155_status[minor], - sizeof(dt3155_status_t))) + sizeof(struct dt3155_status))) return -EFAULT; return 0; } @@ -609,8 +610,8 @@ static int dt3155_ioctl(struct inode *inode, } dt3155_init_isr(minor); - if (copy_to_user( (void *) arg, (void *) &dt3155_status[minor], - sizeof(dt3155_status_t))) + if (copy_to_user((void *) arg, (void *) &dt3155_status[minor], + sizeof(struct dt3155_status))) return -EFAULT; return 0; } @@ -681,36 +682,36 @@ static int dt3155_mmap (struct file * file, struct vm_area_struct * vma) * MOD_INC_USE_COUNT make sure that the driver memory is not freed * while the device is in use. *****************************************************/ -static int dt3155_open( struct inode* inode, struct file* filep) +static int dt3155_open(struct inode* inode, struct file* filep) { int minor = MINOR(inode->i_rdev); /* what device are we opening? */ - if (dt3155_dev_open[ minor ]) { + if (dt3155_dev_open[minor]) { printk ("DT3155: Already opened by another process.\n"); return -EBUSY; } - if (dt3155_status[ minor ].device_installed==0) + if (dt3155_status[minor].device_installed==0) { printk("DT3155 Open Error: No such device dt3155 minor number %d\n", minor); return -EIO; } - if (dt3155_status[ minor ].state != DT3155_STATE_IDLE) { + if (dt3155_status[minor].state != DT3155_STATE_IDLE) { printk ("DT3155: Not in idle state (state = %x)\n", - dt3155_status[ minor ].state); + dt3155_status[minor].state); return -EBUSY; } printk("DT3155: Device opened.\n"); - dt3155_dev_open[ minor ] = 1 ; + dt3155_dev_open[minor] = 1 ; - dt3155_flush( minor ); + dt3155_flush(minor); /* Disable ALL interrupts */ int_csr_r.reg = 0; - WriteMReg( (dt3155_lbase[ minor ] + INT_CSR), int_csr_r.reg ); + WriteMReg((dt3155_lbase[minor] + INT_CSR), int_csr_r.reg); init_waitqueue_head(&(dt3155_read_wait_queue[minor])); @@ -724,20 +725,20 @@ static int dt3155_open( struct inode* inode, struct file* filep) * Now decrement the use count. * *****************************************************/ -static int dt3155_close( struct inode *inode, struct file *filep) +static int dt3155_close(struct inode *inode, struct file *filep) { int minor; minor = MINOR(inode->i_rdev); /* which device are we closing */ - if (!dt3155_dev_open[ minor ]) + if (!dt3155_dev_open[minor]) { printk("DT3155: attempt to CLOSE a not OPEN device\n"); } else { - dt3155_dev_open[ minor ] = 0; + dt3155_dev_open[minor] = 0; - if (dt3155_status[ minor ].state != DT3155_STATE_IDLE) + if (dt3155_status[minor].state != DT3155_STATE_IDLE) { quick_stop(minor); } @@ -756,11 +757,11 @@ static ssize_t dt3155_read(struct file *filep, char __user *buf, int minor = MINOR(filep->f_dentry->d_inode->i_rdev); u32 offset; int frame_index; - frame_info_t *frame_info_p; + struct frame_info *frame_info; /* TODO: this should check the error flag and */ /* return an error on hardware failures */ - if (count != sizeof(dt3155_read_t)) + if (count != sizeof(struct dt3155_read)) { printk("DT3155 ERROR (NJC): count is not right\n"); return -EINVAL; @@ -781,7 +782,7 @@ static ssize_t dt3155_read(struct file *filep, char __user *buf, if (filep->f_flags & O_NDELAY) { if ((frame_index = dt3155_get_ready_buffer(minor)) < 0) { - /*printk( "dt3155: no buffers available (?)\n");*/ + /*printk("dt3155: no buffers available (?)\n");*/ /* printques(minor); */ return -EAGAIN; } @@ -806,21 +807,21 @@ static ssize_t dt3155_read(struct file *filep, char __user *buf, } } - frame_info_p = &dt3155_status[minor].fbuffer.frame_info[frame_index]; + frame_info = &dt3155_status[minor].fbuffer.frame_info[frame_index]; /* make this an offset */ - offset = frame_info_p->addr - dt3155_status[minor].mem_addr; + offset = frame_info->addr - dt3155_status[minor].mem_addr; put_user(offset, (unsigned int *) 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 *) buf); buf += sizeof(u32); put_user(dt3155_status[minor].state, (unsigned int *) buf); buf += sizeof(u32); - if (copy_to_user(buf, frame_info_p, sizeof(frame_info_t))) + if (copy_to_user(buf, frame_info, sizeof(*frame_info))) return -EFAULT; - return sizeof(dt3155_read_t); + return sizeof(struct dt3155_read); } static unsigned int dt3155_poll (struct file * filp, poll_table *wait) @@ -835,6 +836,17 @@ static unsigned int dt3155_poll (struct file * filp, poll_table *wait) return 0; } +static long +dt3155_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + int ret; + + lock_kernel(); + ret = dt3155_ioctl(file->f_path.dentry->d_inode, file, cmd, arg); + unlock_kernel(); + + return ret; +} /***************************************************** * file operations supported by DT3155 driver @@ -842,12 +854,12 @@ static unsigned int dt3155_poll (struct file * filp, poll_table *wait) * register_chrdev *****************************************************/ static struct file_operations dt3155_fops = { - read: dt3155_read, - ioctl: dt3155_ioctl, - mmap: dt3155_mmap, - poll: dt3155_poll, - open: dt3155_open, - release: dt3155_close + .read = dt3155_read, + .unlocked_ioctl = dt3155_unlocked_ioctl, + .mmap = dt3155_mmap, + .poll = dt3155_poll, + .open = dt3155_open, + .release = dt3155_close }; @@ -889,7 +901,7 @@ static int find_PCI (void) /* Now, just go out and make sure that this/these device(s) is/are actually mapped into the kernel address space */ - if ((error = pci_read_config_dword( pci_dev, PCI_BASE_ADDRESS_0, + if ((error = pci_read_config_dword(pci_dev, PCI_BASE_ADDRESS_0, (u32 *) &base))) { printk("DT3155: Was not able to find device \n"); @@ -901,26 +913,26 @@ static int find_PCI (void) /* Remap the base address to a logical address through which we * can access it. */ - dt3155_lbase[ pci_index - 1 ] = ioremap(base,PCI_PAGE_SIZE); - dt3155_status[ pci_index - 1 ].reg_addr = base; + dt3155_lbase[pci_index - 1] = ioremap(base,PCI_PAGE_SIZE); + dt3155_status[pci_index - 1].reg_addr = base; DT_3155_DEBUG_MSG("DT3155: New logical address is %p \n", dt3155_lbase[pci_index-1]); - if ( !dt3155_lbase[pci_index-1] ) + if (!dt3155_lbase[pci_index-1]) { printk("DT3155: Unable to remap control registers\n"); goto err; } - if ( (error = pci_read_config_byte( pci_dev, PCI_INTERRUPT_LINE, &irq)) ) + if ((error = pci_read_config_byte(pci_dev, PCI_INTERRUPT_LINE, &irq))) { printk("DT3155: Was not able to find device \n"); goto err; } DT_3155_DEBUG_MSG("DT3155: IRQ is %d \n",irq); - dt3155_status[ pci_index-1 ].irq = irq; + dt3155_status[pci_index-1].irq = irq; /* Set flag: kth device found! */ - dt3155_status[ pci_index-1 ].device_installed = 1; + dt3155_status[pci_index-1].device_installed = 1; printk("DT3155: Installing device %d w/irq %d and address %p\n", pci_index, dt3155_status[pci_index-1].irq, @@ -945,89 +957,89 @@ int init_module(void) { int index; int rcode = 0; - char *devname[ MAXBOARDS ]; + char *devname[MAXBOARDS]; - devname[ 0 ] = "dt3155a"; + devname[0] = "dt3155a"; #if MAXBOARDS == 2 - devname[ 1 ] = "dt3155b"; + devname[1] = "dt3155b"; #endif printk("DT3155: Loading module...\n"); /* Register the device driver */ - rcode = register_chrdev( dt3155_major, "dt3155", &dt3155_fops ); - if( rcode < 0 ) + rcode = register_chrdev(dt3155_major, "dt3155", &dt3155_fops); + if(rcode < 0) { - printk( KERN_INFO "DT3155: register_chrdev failed \n"); + printk(KERN_INFO "DT3155: register_chrdev failed \n"); return rcode; } - if( dt3155_major == 0 ) + if(dt3155_major == 0) dt3155_major = rcode; /* dynamic */ /* init the status variables. */ /* DMA memory is taken care of in setup_buffers() */ - for ( index = 0; index < MAXBOARDS; index++ ) + for (index = 0; index < MAXBOARDS; index++) { - dt3155_status[ index ].config.acq_mode = DT3155_MODE_FRAME; - dt3155_status[ index ].config.continuous = DT3155_ACQ; - dt3155_status[ index ].config.cols = DT3155_MAX_COLS; - dt3155_status[ index ].config.rows = DT3155_MAX_ROWS; - dt3155_status[ index ].state = DT3155_STATE_IDLE; + dt3155_status[index].config.acq_mode = DT3155_MODE_FRAME; + dt3155_status[index].config.continuous = DT3155_ACQ; + dt3155_status[index].config.cols = DT3155_MAX_COLS; + dt3155_status[index].config.rows = DT3155_MAX_ROWS; + dt3155_status[index].state = DT3155_STATE_IDLE; /* find_PCI() will check if devices are installed; */ /* first assume they're not: */ - dt3155_status[ index ].mem_addr = 0; - dt3155_status[ index ].mem_size = 0; - dt3155_status[ index ].state = DT3155_STATE_IDLE; - dt3155_status[ index ].device_installed = 0; + dt3155_status[index].mem_addr = 0; + dt3155_status[index].mem_size = 0; + dt3155_status[index].state = DT3155_STATE_IDLE; + dt3155_status[index].device_installed = 0; } /* 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()) != DT_3155_SUCCESS) { printk("DT3155 error: find_PCI() failed to find dt3155 board(s)\n"); - unregister_chrdev( dt3155_major, "dt3155" ); + unregister_chrdev(dt3155_major, "dt3155"); return rcode; } } /* Ok, time to setup the frame buffers */ - if( (rcode = dt3155_setup_buffers(&allocatorAddr)) < 0 ) + if((rcode = dt3155_setup_buffers(&allocatorAddr)) < 0) { printk("DT3155: Error: setting up buffer not large enough."); - unregister_chrdev( dt3155_major, "dt3155" ); + unregister_chrdev(dt3155_major, "dt3155"); return rcode; } /* If we are this far, then there is enough RAM */ /* for the buffers: Print the configuration. */ - for( index = 0; index < ndevices; index++ ) + for( index = 0; index < ndevices; index++) { printk("DT3155: Device = %d; acq_mode = %d; " "continuous = %d; cols = %d; rows = %d;\n", index , - dt3155_status[ index ].config.acq_mode, - dt3155_status[ index ].config.continuous, - dt3155_status[ index ].config.cols, - dt3155_status[ index ].config.rows); + dt3155_status[index].config.acq_mode, + dt3155_status[index].config.continuous, + dt3155_status[index].config.cols, + dt3155_status[index].config.rows); printk("DT3155: m_addr = 0x%x; m_size = %ld; " "state = %d; device_installed = %d\n", - dt3155_status[ index ].mem_addr, - (long int)dt3155_status[ index ].mem_size, - dt3155_status[ index ].state, - dt3155_status[ index ].device_installed); + dt3155_status[index].mem_addr, + (long int)dt3155_status[index].mem_size, + dt3155_status[index].state, + dt3155_status[index].device_installed); } /* Disable ALL interrupts */ int_csr_r.reg = 0; - for( index = 0; index < ndevices; index++ ) + for( index = 0; index < ndevices; index++) { - WriteMReg( (dt3155_lbase[ index ] + INT_CSR), int_csr_r.reg ); - if( dt3155_status[ index ].device_installed ) + WriteMReg((dt3155_lbase[index] + INT_CSR), int_csr_r.reg); + if(dt3155_status[index].device_installed) { /* * This driver *looks* like it can handle sharing interrupts, @@ -1036,14 +1048,14 @@ int init_module(void) * as a reminder in case any problems arise. (SS) */ /* in older kernels flags are: SA_SHIRQ | SA_INTERRUPT */ - rcode = request_irq( dt3155_status[ index ].irq, (void *)dt3155_isr, - IRQF_SHARED | IRQF_DISABLED, devname[ index ], + rcode = request_irq(dt3155_status[index].irq, (void *)dt3155_isr, + IRQF_SHARED | IRQF_DISABLED, devname[index], (void*) &dt3155_status[index]); - if( rcode < 0 ) + if(rcode < 0) { printk("DT3155: minor %d request_irq failed for IRQ %d\n", index, dt3155_status[index].irq); - unregister_chrdev( dt3155_major, "dt3155" ); + unregister_chrdev(dt3155_major, "dt3155"); return rcode; } } @@ -1072,15 +1084,15 @@ void cleanup_module(void) allocator_cleanup(); #endif - unregister_chrdev( dt3155_major, "dt3155" ); + unregister_chrdev(dt3155_major, "dt3155"); - for( index = 0; index < ndevices; index++ ) + for(index = 0; index < ndevices; index++) { - if( dt3155_status[ index ].device_installed == 1 ) + if(dt3155_status[index].device_installed == 1) { - printk( "DT3155: Freeing irq %d for device %d\n", - dt3155_status[ index ].irq, index ); - free_irq( dt3155_status[ index ].irq, (void*)&dt3155_status[index] ); + printk("DT3155: Freeing irq %d for device %d\n", + dt3155_status[index].irq, index); + free_irq(dt3155_status[index].irq, (void*)&dt3155_status[index]); } } } diff --git a/drivers/staging/dt3155/dt3155_io.c b/drivers/staging/dt3155/dt3155_io.c index 6b9c68501a61..7792e712d16e 100644 --- a/drivers/staging/dt3155/dt3155_io.c +++ b/drivers/staging/dt3155/dt3155_io.c @@ -74,23 +74,22 @@ u8 i2c_pm_lut_data; * wait_ibsyclr() * * This function handles read/write timing and r/w timeout error - * - * Returns TRUE if NEW_CYCLE clears - * Returns FALSE if NEW_CYCLE doesn't clear in roughly 3 msecs, otherwise - * returns 0 */ static int wait_ibsyclr(u8 *lpReg) { /* wait 100 microseconds */ udelay(100L); /* __delay(loops_per_sec/10000); */ + + ReadMReg(lpReg + IIC_CSR2, iic_csr2_r.reg); if (iic_csr2_r.fld.NEW_CYCLE) { /* if NEW_CYCLE didn't clear */ /* TIMEOUT ERROR */ dt3155_errno = DT_ERR_I2C_TIMEOUT; - return FALSE; - } else - return TRUE; /* no error */ + return -ETIMEDOUT; + } + + return 0; /* no error */ } /* @@ -101,14 +100,9 @@ static int wait_ibsyclr(u8 *lpReg) * 1st parameter is pointer to 32-bit register base address * 2nd parameter is reg. index; * 3rd is value to be written - * - * Returns TRUE - Successful completion - * FALSE - Timeout error - cycle did not complete! */ int WriteI2C(u8 *lpReg, u_short wIregIndex, u8 byVal) { - int writestat; /* status for return */ - /* read 32 bit IIC_CSR2 register data into union */ ReadMReg((lpReg + IIC_CSR2), iic_csr2_r.reg); @@ -126,8 +120,7 @@ int WriteI2C(u8 *lpReg, u_short wIregIndex, u8 byVal) WriteMReg((lpReg + IIC_CSR2), iic_csr2_r.reg); /* wait for IIC cycle to finish */ - writestat = wait_ibsyclr(lpReg); - return writestat; + return wait_ibsyclr(lpReg); } /* @@ -138,9 +131,6 @@ int WriteI2C(u8 *lpReg, u_short wIregIndex, u8 byVal) * 1st parameter is pointer to 32-bit register base address * 2nd parameter is reg. index; * 3rd is adrs of value to be read - * - * Returns TRUE - Successful completion - * FALSE - Timeout error - cycle did not complete! */ int ReadI2C(u8 *lpReg, u_short wIregIndex, u8 *byVal) { diff --git a/drivers/staging/dt3155/dt3155_isr.c b/drivers/staging/dt3155/dt3155_isr.c index 09d7d9b8272d..33ddc9c057ff 100644 --- a/drivers/staging/dt3155/dt3155_isr.c +++ b/drivers/staging/dt3155/dt3155_isr.c @@ -1,7 +1,7 @@ /* Copyright 1996,2002,2005 Gregory D. Hager, Alfred A. Rizzi, Noah J. Cowan, - Jason Lapenta, Scott Smedley, Greg Sharp + Jason Lapenta, Scott Smedley, Greg Sharp This file is part of the DT3155 Device Driver. @@ -22,7 +22,7 @@ MA 02111-1307 USA File: dt3155_isr.c Purpose: Buffer management routines, and other routines for the ISR - (the actual isr is in dt3155_drv.c) + (the actual isr is in dt3155_drv.c) -- Changes -- @@ -30,16 +30,16 @@ Purpose: Buffer management routines, and other routines for the ISR ------------------------------------------------------------------- 03-Jul-2000 JML n/a 02-Apr-2002 SS Mods to make work with separate allocator - module; Merged John Roll's mods to make work with - multiple boards. + module; Merged John Roll's mods to make work with + multiple boards. 10-Jul-2002 GCS Complete rewrite of setup_buffers to disallow - buffers which span a 4MB boundary. + buffers which span a 4MB boundary. 24-Jul-2002 SS GPL licence. 30-Jul-2002 NJC Added support for buffer loop. 31-Jul-2002 NJC Complete rewrite of buffer management 02-Aug-2002 NJC Including slab.h instead of malloc.h (no warning). - Also, allocator_init() now returns allocator_max - so cleaned up allocate_buffers() accordingly. + Also, allocator_init() now returns allocator_max + so cleaned up allocate_buffers() accordingly. 08-Aug-2005 SS port to 2.6 kernel. */ @@ -60,7 +60,7 @@ Purpose: Buffer management routines, and other routines for the ISR /* Pointer into global structure for handling buffers */ -struct dt3155_fbuffer_s *dt3155_fbuffer[MAXBOARDS] = {NULL +struct dt3155_fbuffer *dt3155_fbuffer[MAXBOARDS] = {NULL #if MAXBOARDS == 2 , NULL #endif @@ -77,9 +77,9 @@ struct dt3155_fbuffer_s *dt3155_fbuffer[MAXBOARDS] = {NULL * are_empty_buffers * m is minor # of device ***************************/ -inline bool are_empty_buffers( int m ) +bool are_empty_buffers(int m) { - return ( dt3155_fbuffer[ m ]->empty_len ); + return dt3155_fbuffer[m]->empty_len; } /************************** @@ -92,56 +92,56 @@ inline bool are_empty_buffers( int m ) * given by dt3155_fbuffer[m]->empty_buffers[0]. * empty_buffers should never fill up, though this is not checked. **************************/ -inline void push_empty( int index, int m ) +void push_empty(int index, int m) { - dt3155_fbuffer[m]->empty_buffers[ dt3155_fbuffer[m]->empty_len ] = index; + dt3155_fbuffer[m]->empty_buffers[dt3155_fbuffer[m]->empty_len] = index; dt3155_fbuffer[m]->empty_len++; } /************************** - * pop_empty( m ) + * pop_empty(m) * m is minor # of device **************************/ -inline int pop_empty( int m ) +int pop_empty(int m) { dt3155_fbuffer[m]->empty_len--; - return dt3155_fbuffer[m]->empty_buffers[ dt3155_fbuffer[m]->empty_len ]; + return dt3155_fbuffer[m]->empty_buffers[dt3155_fbuffer[m]->empty_len]; } /************************* - * is_ready_buf_empty( m ) + * is_ready_buf_empty(m) * m is minor # of device *************************/ -inline bool is_ready_buf_empty( int m ) +bool is_ready_buf_empty(int m) { - return ((dt3155_fbuffer[ m ]->ready_len) == 0); + return ((dt3155_fbuffer[m]->ready_len) == 0); } /************************* - * is_ready_buf_full( m ) + * is_ready_buf_full(m) * m is minor # of device * this should *never* be true if there are any active, locked or empty * buffers, since it corresponds to nbuffers ready buffers!! * 7/31/02: total rewrite. --NJC *************************/ -inline bool is_ready_buf_full( int m ) +bool is_ready_buf_full(int m) { - return ( dt3155_fbuffer[ m ]->ready_len == dt3155_fbuffer[ m ]->nbuffers ); + return dt3155_fbuffer[m]->ready_len == dt3155_fbuffer[m]->nbuffers; } /***************************************************** - * push_ready( m, buffer ) + * push_ready(m, buffer) * m is minor # of device * *****************************************************/ -inline void push_ready( int m, int index ) +void push_ready(int m, int index) { int head = dt3155_fbuffer[m]->ready_head; - dt3155_fbuffer[ m ]->ready_que[ head ] = index; - dt3155_fbuffer[ m ]->ready_head = ( (head + 1) % - (dt3155_fbuffer[ m ]->nbuffers) ); - dt3155_fbuffer[ m ]->ready_len++; + dt3155_fbuffer[m]->ready_que[head] = index; + dt3155_fbuffer[m]->ready_head = ((head + 1) % + (dt3155_fbuffer[m]->nbuffers)); + dt3155_fbuffer[m]->ready_len++; } @@ -151,12 +151,12 @@ inline void push_ready( int m, int index ) * * Simply comptutes the tail given the head and the length. *****************************************************/ -static inline int get_tail( int m ) +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)); + return (dt3155_fbuffer[m]->ready_head - + dt3155_fbuffer[m]->ready_len + + dt3155_fbuffer[m]->nbuffers)% + (dt3155_fbuffer[m]->nbuffers); } @@ -168,12 +168,12 @@ static inline int get_tail( int m ) * This assumes that there is a ready buffer ready... should * be checked (e.g. with is_ready_buf_empty() prior to call. *****************************************************/ -inline int pop_ready( int m ) +int pop_ready(int m) { int tail; tail = get_tail(m); - dt3155_fbuffer[ m ]->ready_len--; - return dt3155_fbuffer[ m ]->ready_que[ tail ]; + dt3155_fbuffer[m]->ready_len--; + return dt3155_fbuffer[m]->ready_que[tail]; } @@ -181,35 +181,33 @@ inline int pop_ready( int m ) * printques * m is minor # of device *****************************************************/ -inline void printques( int m ) +void printques(int m) { - int head = dt3155_fbuffer[ m ]->ready_head; + int head = dt3155_fbuffer[m]->ready_head; int tail; - int num = dt3155_fbuffer[ m ]->nbuffers; + int num = dt3155_fbuffer[m]->nbuffers; int frame_index; int index; tail = get_tail(m); printk("\n R:"); - for ( index = tail; index != head; index++, index = index % (num) ) - { - frame_index = dt3155_fbuffer[ m ]->ready_que[ index ]; - printk(" %d ", frame_index ); + for (index = tail; index != head; index++, index = index % (num)) { + frame_index = dt3155_fbuffer[m]->ready_que[index]; + printk(" %d ", frame_index); } printk("\n E:"); - for ( index = 0; index < dt3155_fbuffer[ m ]->empty_len; index++ ) - { - frame_index = dt3155_fbuffer[ m ]->empty_buffers[ index ]; - printk(" %d ", frame_index ); + 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; + frame_index = dt3155_fbuffer[m]->active_buf; printk("\n A: %d", frame_index); - frame_index = dt3155_fbuffer[ m ]->locked_buf; - printk("\n L: %d \n", frame_index ); + frame_index = dt3155_fbuffer[m]->locked_buf; + printk("\n L: %d\n", frame_index); } @@ -220,11 +218,12 @@ inline void printques( int m ) * the start address up to the beginning of the * next 4MB chunk (assuming bufsize < 4MB). *****************************************************/ -u32 adjust_4MB (u32 buf_addr, u32 bufsize) { - if (((buf_addr+bufsize) & UPPER_10_BITS) != (buf_addr & UPPER_10_BITS)) - return (buf_addr+bufsize) & UPPER_10_BITS; - else - return buf_addr; +u32 adjust_4MB(u32 buf_addr, u32 bufsize) +{ + if (((buf_addr+bufsize) & UPPER_10_BITS) != (buf_addr & UPPER_10_BITS)) + return (buf_addr+bufsize) & UPPER_10_BITS; + else + return buf_addr; } @@ -235,7 +234,7 @@ u32 adjust_4MB (u32 buf_addr, u32 bufsize) { * buffers. If there is not enough free space * try for less memory. *****************************************************/ -void allocate_buffers (u32 *buf_addr, u32* total_size_kbs, +void allocate_buffers(u32 *buf_addr, u32* total_size_kbs, u32 bufsize) { /* Compute the minimum amount of memory guaranteed to hold all @@ -268,15 +267,15 @@ void allocate_buffers (u32 *buf_addr, u32* total_size_kbs, printk("DT3155: ...but need at least: %d KB\n", min_size_kbs); printk("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); - *total_size_kbs = size_kbs; - return; + 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); + *total_size_kbs = size_kbs; + return; + } } - } /* If we got here, the allocation failed */ - printk ("DT3155: Allocator failed!\n"); + printk("DT3155: Allocator failed!\n"); *buf_addr = 0; *total_size_kbs = 0; return; @@ -312,28 +311,26 @@ u32 dt3155_setup_buffers(u32 *allocatorAddr) int m; /* minor # of device, looped for all devs */ /* zero the fbuffer status and address structure */ - for ( m = 0; m < ndevices; m++) - { - dt3155_fbuffer[ m ] = &(dt3155_status[ m ].fbuffer); + for (m = 0; m < ndevices; m++) { + dt3155_fbuffer[m] = &(dt3155_status[m].fbuffer); /* Make sure the buffering variables are consistent */ { - u8 *ptr = (u8 *) dt3155_fbuffer[ m ]; - for( index = 0; index < sizeof(struct dt3155_fbuffer_s); index++) - *(ptr++)=0; + u8 *ptr = (u8 *) dt3155_fbuffer[m]; + for (index = 0; index < sizeof(struct dt3155_fbuffer); index++) + *(ptr++) = 0; } } /* allocate a large contiguous chunk of RAM */ - allocate_buffers (&rambuff_addr, &rambuff_size, bufsize); + 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); - if( rambuff_addr == 0 ) - { - printk( KERN_INFO - "DT3155: Error setup_buffers() allocator dma failed \n" ); - return -ENOMEM; + printk(" - rambuf_addr = 0x%x\n", rambuff_addr); + printk(" - length (kb) = %u\n", rambuff_size); + if (rambuff_addr == 0) { + printk(KERN_INFO + "DT3155: Error setup_buffers() allocator dma failed\n"); + return -ENOMEM; } *allocatorAddr = rambuff_addr; rambuff_end = rambuff_addr + 1024 * rambuff_size; @@ -341,70 +338,68 @@ u32 dt3155_setup_buffers(u32 *allocatorAddr) /* after allocation, we need to count how many useful buffers there 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*/ - if (rambuff_acm + bufsize > rambuff_end) - break; - rambuff_acm += bufsize; - } + for (index = 0; index < MAXBUFFERS; index++) { + rambuff_acm = adjust_4MB(rambuff_acm, bufsize);/*avoid spanning 4MB bdry*/ + if (rambuff_acm + bufsize > rambuff_end) + break; + rambuff_acm += bufsize; + } /* Following line is OK, will waste buffers if index * not evenly divisible by ndevices -NJC*/ numbufs = index / ndevices; printk(" - numbufs = %u\n", numbufs); - if (numbufs < 2) { - printk( KERN_INFO - "DT3155: Error setup_buffers() couldn't allocate 2 bufs/board\n" ); - return -ENOMEM; - } + if (numbufs < 2) { + printk(KERN_INFO + "DT3155: Error setup_buffers() couldn't allocate 2 bufs/board\n"); + return -ENOMEM; + } /* now that we have board memory we spit it up */ /* between the boards and the buffers */ - rambuff_acm = rambuff_addr; - for ( m = 0; m < ndevices; m ++) - { - rambuff_acm = adjust_4MB (rambuff_acm, bufsize); - - /* Save the start of this boards buffer space (for mmap). */ - dt3155_status[ m ].mem_addr = rambuff_acm; - - for (index = 0; index < numbufs; index++) - { - rambuff_acm = adjust_4MB (rambuff_acm, bufsize); - if (rambuff_acm + bufsize > rambuff_end) { - /* Should never happen */ - printk ("DT3155 PROGRAM ERROR (GCS)\n" - "Error distributing allocated buffers\n"); - return -ENOMEM; - } - - dt3155_fbuffer[ m ]->frame_info[ index ].addr = rambuff_acm; - push_empty( index, m ); - /* printk(" - Buffer : %lx\n", - * dt3155_fbuffer[ m ]->frame_info[ index ].addr ); - */ - dt3155_fbuffer[ m ]->nbuffers += 1; - rambuff_acm += bufsize; + rambuff_acm = rambuff_addr; + for (m = 0; m < ndevices; m++) { + rambuff_acm = adjust_4MB(rambuff_acm, bufsize); + + /* Save the start of this boards buffer space (for mmap). */ + dt3155_status[m].mem_addr = rambuff_acm; + + for (index = 0; index < numbufs; index++) { + rambuff_acm = adjust_4MB(rambuff_acm, bufsize); + if (rambuff_acm + bufsize > rambuff_end) { + /* Should never happen */ + printk("DT3155 PROGRAM ERROR (GCS)\n" + "Error distributing allocated buffers\n"); + return -ENOMEM; + } + + dt3155_fbuffer[m]->frame_info[index].addr = rambuff_acm; + push_empty(index, m); + /* printk(" - Buffer : %lx\n", + * dt3155_fbuffer[m]->frame_info[index].addr); + */ + dt3155_fbuffer[m]->nbuffers += 1; + rambuff_acm += bufsize; } - /* Make sure there is an active buffer there. */ - dt3155_fbuffer[ m ]->active_buf = pop_empty( m ); - dt3155_fbuffer[ m ]->even_happened = 0; - dt3155_fbuffer[ m ]->even_stopped = 0; + /* Make sure there is an active buffer there. */ + dt3155_fbuffer[m]->active_buf = pop_empty(m); + dt3155_fbuffer[m]->even_happened = 0; + dt3155_fbuffer[m]->even_stopped = 0; - /* make sure there is no locked_buf JML 2/28/00 */ - dt3155_fbuffer[ m ]->locked_buf = -1; + /* make sure there is no locked_buf JML 2/28/00 */ + dt3155_fbuffer[m]->locked_buf = -1; - dt3155_status[ m ].mem_size = - rambuff_acm - dt3155_status[ m ].mem_addr; + dt3155_status[m].mem_size = + rambuff_acm - dt3155_status[m].mem_addr; - /* setup the ready queue */ - dt3155_fbuffer[ m ]->ready_head = 0; - dt3155_fbuffer[ m ]->ready_len = 0; - printk("Available buffers for device %d: %d\n", - m, dt3155_fbuffer[ m ]->nbuffers); + /* setup the ready queue */ + dt3155_fbuffer[m]->ready_head = 0; + dt3155_fbuffer[m]->ready_len = 0; + printk("Available buffers for device %d: %d\n", + m, dt3155_fbuffer[m]->nbuffers); } - return 1; + return 1; } /***************************************************** @@ -415,13 +410,12 @@ u32 dt3155_setup_buffers(u32 *allocatorAddr) * * m is minor number of device *****************************************************/ -static inline void internal_release_locked_buffer( int m ) +static void internal_release_locked_buffer(int m) { /* Pointer into global structure for handling buffers */ - if ( dt3155_fbuffer[ m ]->locked_buf >= 0 ) - { - push_empty( dt3155_fbuffer[ m ]->locked_buf, m ); - dt3155_fbuffer[ m ]->locked_buf = -1; + if (dt3155_fbuffer[m]->locked_buf >= 0) { + push_empty(dt3155_fbuffer[m]->locked_buf, m); + dt3155_fbuffer[m]->locked_buf = -1; } } @@ -433,7 +427,7 @@ static inline void internal_release_locked_buffer( int m ) * The user function of the above. * *****************************************************/ -inline void dt3155_release_locked_buffer( int m ) +void dt3155_release_locked_buffer(int m) { unsigned long int flags; local_save_flags(flags); @@ -448,28 +442,28 @@ inline void dt3155_release_locked_buffer( int m ) * m is minor # of device * *****************************************************/ -inline int dt3155_flush( int m ) +int dt3155_flush(int m) { int index; unsigned long int flags; local_save_flags(flags); local_irq_disable(); - internal_release_locked_buffer( m ); - dt3155_fbuffer[ m ]->empty_len = 0; + internal_release_locked_buffer(m); + dt3155_fbuffer[m]->empty_len = 0; - for ( index = 0; index < dt3155_fbuffer[ m ]->nbuffers; index++ ) - push_empty( index, m ); + for (index = 0; index < dt3155_fbuffer[m]->nbuffers; index++) + push_empty(index, m); /* Make sure there is an active buffer there. */ - dt3155_fbuffer[ m ]->active_buf = pop_empty( m ); + dt3155_fbuffer[m]->active_buf = pop_empty(m); - dt3155_fbuffer[ m ]->even_happened = 0; - dt3155_fbuffer[ m ]->even_stopped = 0; + dt3155_fbuffer[m]->even_happened = 0; + dt3155_fbuffer[m]->even_stopped = 0; /* setup the ready queue */ - dt3155_fbuffer[ m ]->ready_head = 0; - dt3155_fbuffer[ m ]->ready_len = 0; + dt3155_fbuffer[m]->ready_head = 0; + dt3155_fbuffer[m]->ready_len = 0; local_irq_restore(flags); @@ -485,7 +479,7 @@ inline int dt3155_flush( int m ) * If the user has a buffer locked it will unlock * that buffer before returning the new one. *****************************************************/ -inline int dt3155_get_ready_buffer( int m ) +int dt3155_get_ready_buffer(int m) { int frame_index; unsigned long int flags; @@ -493,21 +487,20 @@ inline int dt3155_get_ready_buffer( int m ) local_irq_disable(); #ifdef DEBUG_QUES_A - printques( m ); + printques(m); #endif - internal_release_locked_buffer( m ); + internal_release_locked_buffer(m); - if (is_ready_buf_empty( m )) - frame_index = -1; - else - { - frame_index = pop_ready( m ); - dt3155_fbuffer[ m ]->locked_buf = frame_index; + if (is_ready_buf_empty(m)) + frame_index = -1; + else { + frame_index = pop_ready(m); + dt3155_fbuffer[m]->locked_buf = frame_index; } #ifdef DEBUG_QUES_B - printques( m ); + printques(m); #endif local_irq_restore(flags); diff --git a/drivers/staging/dt3155/dt3155_isr.h b/drivers/staging/dt3155/dt3155_isr.h index 7595cb16c988..7d474cf743d8 100644 --- a/drivers/staging/dt3155/dt3155_isr.h +++ b/drivers/staging/dt3155/dt3155_isr.h @@ -36,7 +36,7 @@ MA 02111-1307 USA #ifndef DT3155_ISR_H #define DT3155_ISR_H -extern struct dt3155_fbuffer_s *dt3155_fbuffer[MAXBOARDS]; +extern struct dt3155_fbuffer *dt3155_fbuffer[MAXBOARDS]; /* User functions for buffering */ /* Initialize the buffering system. This should */ diff --git a/drivers/staging/dt3155v4l/Kconfig b/drivers/staging/dt3155v4l/Kconfig new file mode 100644 index 000000000000..5cef5420d288 --- /dev/null +++ b/drivers/staging/dt3155v4l/Kconfig @@ -0,0 +1,28 @@ +config VIDEO_DT3155 + tristate "DT3155 frame grabber, Video4Linux interface" + depends on PCI && VIDEO_DEV && VIDEO_V4L2 + select VIDEOBUF_DMA_CONTIG + default n + ---help--- + Enables dt3155 device driver for the DataTranslation DT3155 frame grabber. + Say Y here if you have this hardware. + In doubt, say N. + + To compile this driver as a module, choose M here: the + module will be called dt3155_v4l. + +config DT3155_CCIR + bool "Selects CCIR/50Hz vertical refresh" + depends on VIDEO_DT3155 + default y + ---help--- + Select it for CCIR/50Hz (European region), + or leave it unselected for RS-170/60Hz (North America). + +config DT3155_STREAMING + bool "Selects mmap streaming instead of read method" + depends on VIDEO_DT3155 + default y + ---help--- + Select it if you wish to try mmap streaming, or + or leave it unselected for using read method. diff --git a/drivers/staging/dt3155v4l/Makefile b/drivers/staging/dt3155v4l/Makefile new file mode 100644 index 000000000000..3a207ccd3143 --- /dev/null +++ b/drivers/staging/dt3155v4l/Makefile @@ -0,0 +1,4 @@ +obj-$(CONFIG_VIDEO_DT3155) += dt3155_v4l.o +dt3155_v4l-objs := \ + dt3155-bufs.o \ + dt3155v4l.o diff --git a/drivers/staging/dt3155v4l/dt3155-bufs.c b/drivers/staging/dt3155v4l/dt3155-bufs.c new file mode 100644 index 000000000000..f93e431e786b --- /dev/null +++ b/drivers/staging/dt3155v4l/dt3155-bufs.c @@ -0,0 +1,256 @@ +/*************************************************************************** + * Copyright (C) 2006-2010 by Marin Mitov * + * mitov@issp.bas.bg * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "dt3155-bufs.h" + +/** + * dt3155_init_chunks_buf - creates a chunk buffer and allocates memory for it + * + * returns: a pointer to the struct dt3155_buf or NULL if failed + * + * Creates a struct dt3155_buf, then allocates a chunk of memory of + * size DT3155_CHUNK_SIZE and sets all the pages in it as Reserved. + * This is done to be able to use remap_pfn_range() on these buffers + * (which do not work on normal memory if Reserved bit is not set) + */ +struct dt3155_buf * +dt3155_init_chunks_buf(void) +{ /* could sleep */ + struct dt3155_buf *buf; + int i; + + buf = kzalloc(sizeof(*buf), GFP_KERNEL); + if (!buf) + return NULL; + buf->cpu = (void *)__get_free_pages(DT3155_CHUNK_FLAGS, + get_order(DT3155_CHUNK_SIZE)); + if (!buf->cpu) { + kfree(buf); + return NULL; + } + for (i = 0; i < DT3155_CHUNK_SIZE; i += PAGE_SIZE) + SetPageReserved(virt_to_page(buf->cpu + i)); + return buf; /* success */ +} + +/** + * dt3155_free_chunks_buf - destroys the specified buffer + * + * @buf: the buffer to be freed + * + * Clears Reserved bit of all pages in the chunk, frees the chunk memory + * and destroys struct dt3155_buf. + */ +void +dt3155_free_chunks_buf(struct dt3155_buf *buf) +{ + int i; + + for (i = 0; i < DT3155_CHUNK_SIZE; i += PAGE_SIZE) + ClearPageReserved(virt_to_page(buf->cpu + i)); + free_pages((unsigned long)buf->cpu, get_order(DT3155_CHUNK_SIZE)); + kfree(buf); +} + +/** + * dt3155_init_fifo - creates and initializes a fifo + * + * returns: a pointer to the crated and initialized struct dt3155_fifo + * or NULL if failed + */ +struct dt3155_fifo * +dt3155_init_fifo(void) +{ /* could sleep */ + struct dt3155_fifo *fifo = kzalloc(sizeof(*fifo), GFP_KERNEL); + if (fifo) + spin_lock_init(&fifo->lock); + return fifo; +} + +/* dt3155_free_fifo(x) defined as macro in dt3155.h */ + +/** + * dt3155_get_buf - gets a buffer from the fifo + * + * @fifo: the fifo to get a buffer from + * + * returns: a pointer to the buffer or NULL if failed + * + * dt3155_get_buf gets the fifo's spin_lock and returns the + * buffer pointed by the head. Could be used in any context. + */ +struct dt3155_buf * +dt3155_get_buf(struct dt3155_fifo *fifo) +{ + unsigned long flags; + struct dt3155_buf *tmp_buf; + + spin_lock_irqsave(&fifo->lock, flags); + tmp_buf = fifo->head; + if (fifo->head) + fifo->head = fifo->head->next; + if (!fifo->head) + fifo->tail = NULL; + spin_unlock_irqrestore(&fifo->lock, flags); + return tmp_buf; +} + +/** + * dt3155_put_buf - puts a buffer into a fifo + * + * @buf: the buffer to put + * @fifo: the fifo to put the buffer in + * + * dt3155_put_buf gets the fifo's spin_lock and puts the buf + * at the tail of the fifo. Could be used in any context. + */ +void +dt3155_put_buf(struct dt3155_buf *buf, struct dt3155_fifo *fifo) +{ + unsigned long flags; + + spin_lock_irqsave(&fifo->lock, flags); + buf->next = NULL; + if (fifo->tail) + fifo->tail->next = buf; + fifo->tail = buf; + if (!fifo->head) + fifo->head = buf; + spin_unlock_irqrestore(&fifo->lock, flags); +} + +/** + * dt3155_init_chunks_fifo - creates and fills a chunks_fifo + * + * returns: a pointer to the fifo or NULL if failed + * + * dt3155_init_chunks_fifo creates and fills the fifo with + * a number of chunks <= DT3155_CHUNK_NUM. The returned fifo + * contains at least one chunk. + */ +struct dt3155_fifo * +dt3155_init_chunks_fifo(void) +{ /* could sleep */ + int i; + + struct dt3155_fifo *chunks; + struct dt3155_buf *tmp_buf; + + chunks = dt3155_init_fifo(); + if (!chunks) + return NULL; + tmp_buf = dt3155_init_chunks_buf(); + if (!tmp_buf) { + dt3155_free_fifo(chunks); + return NULL; + } + dt3155_put_buf(tmp_buf, chunks); + for (i = 1; i < DT3155_CHUNK_NUM; i++) { + tmp_buf = dt3155_init_chunks_buf(); + if (!tmp_buf) + break; + dt3155_put_buf(tmp_buf, chunks); + } + return chunks; +} + +/** + * dt3155_free_chunks_fifo - empties and destroys the chunks_fifo + * + * @chunks: the chunks_fifo to be freed + * + * dt3155_free_chunks_fifo deallocates all chunks in the fifo and + * destroys it. + */ +void +dt3155_free_chunks_fifo(struct dt3155_fifo *chunks) +{ + int buf_count = 0; + struct dt3155_buf *buf; + + while ((buf = dt3155_get_buf(chunks))) { + dt3155_free_chunks_buf(buf); + buf_count++; + } + dt3155_free_fifo(chunks); + printk(KERN_INFO "dt3155: %i chunks freed\n", buf_count); +} + +/** + * dt3155_init_ibufs_fifo - creates and fills an image buffer fifo + * + * @chunks: chunks_fifo to take memory from + * @buf_size: the size of image buffers + * + * returns: a pointer to the fifo filled with image buffers + * + * dt3155_init_ibufs_fifo takes chunks from chunks_fifo, chops them + * into pieces of size buf_size and fills image fifo with them. + */ +struct dt3155_fifo * +dt3155_init_ibufs_fifo(struct dt3155_fifo *chunks, int buf_size) +{ /* could sleep */ + int i, buf_count = 0; + struct dt3155_buf *tmp_ibuf, *chunks_buf, *last_chunk; + struct dt3155_fifo *tmp_fifo; + + tmp_fifo = dt3155_init_fifo(); + if (!tmp_fifo) + return NULL; + last_chunk = chunks->tail; + do { + chunks_buf = dt3155_get_buf(chunks); + dt3155_put_buf(chunks_buf, chunks); + for (i = 0; i < DT3155_CHUNK_SIZE / buf_size; i++) { + tmp_ibuf = kzalloc(sizeof(*tmp_ibuf), GFP_KERNEL); + if (tmp_ibuf) { + tmp_ibuf->cpu = + chunks_buf->cpu + DT3155_BUF_SIZE * i; + dt3155_put_buf(tmp_ibuf, tmp_fifo); + buf_count++; + } else { + if (buf_count) { + goto print_num_bufs; + } else { + dt3155_free_fifo(tmp_fifo); + return NULL; + } + } + } + } while (chunks_buf != last_chunk); +print_num_bufs: + printk(KERN_INFO "dt3155: %i image buffers available\n", buf_count); + return tmp_fifo; +} + +/** + * dt3155_free_ibufs_fifo - empties and destroys an image fifo + * + * @fifo: the fifo to free + */ +void +dt3155_free_ibufs_fifo(struct dt3155_fifo *fifo) +{ + struct dt3155_buf *tmp_ibuf; + + while ((tmp_ibuf = dt3155_get_buf(fifo))) + kfree(tmp_ibuf); + kfree(fifo); +} diff --git a/drivers/staging/dt3155v4l/dt3155-bufs.h b/drivers/staging/dt3155v4l/dt3155-bufs.h new file mode 100644 index 000000000000..db6d387231b2 --- /dev/null +++ b/drivers/staging/dt3155v4l/dt3155-bufs.h @@ -0,0 +1,88 @@ +/*************************************************************************** + * Copyright (C) 2006-2010 by Marin Mitov * + * mitov@issp.bas.bg * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef _DT3155_BUFS_H_ +#define _DT3155_BUFS_H_ + +#include <linux/pci.h> + +/* 4 chunks of 4MB, 9 buffers each = 36 buffers (> VIDEO_MAX_FRAME) */ +#define DT3155_CHUNK_NUM 4 + +/* DT3155_CHUNK_SIZE should be 4M (2^22) or less, but more than image size */ +#define DT3155_CHUNK_SIZE (1U << 22) +#define DT3155_CHUNK_FLAGS (GFP_KERNEL | GFP_DMA32 | __GFP_COLD | __GFP_NOWARN) + +/* DT3155_BUF_SIZE = 108 * PAGE_SIZE, so each buf is PAGE_SIZE alligned */ +#define DT3155_BUF_SIZE (768 * 576) + +/** + * struct dt3155_buf - image buffer structure + * + * @cpu: virtual kernel address of the buffer + * @dma: dma (bus) address of the buffer + * @next: pointer to the next buffer in the fifo + * @tv: time value when the image has been acquired + */ +struct dt3155_buf { + void *cpu; + dma_addr_t dma; + struct dt3155_buf *next; + struct timeval tv; +}; + +/** + * struct dt3155_fifo - fifo structure + * + * @head: pointer to the head of the fifo + * @tail: pionter to the tail of the fifo + * @lock: spin_lock to protect the fifo + */ +struct dt3155_fifo { + struct dt3155_buf *head; + struct dt3155_buf *tail; + spinlock_t lock; +}; + +struct dt3155_buf * __must_check +dt3155_init_chunks_buf(void); +void +dt3155_free_chunks_buf(struct dt3155_buf *buf); + +struct dt3155_fifo * __must_check +dt3155_init_fifo(void); +#define dt3155_free_fifo(x) kfree(x) + +struct dt3155_buf * __must_check +dt3155_get_buf(struct dt3155_fifo *fifo); +void +dt3155_put_buf(struct dt3155_buf *buf, struct dt3155_fifo *fifo); + +struct dt3155_fifo * __must_check +dt3155_init_chunks_fifo(void); +void +dt3155_free_chunks_fifo(struct dt3155_fifo *chunks); + +struct dt3155_fifo * __must_check +dt3155_init_ibufs_fifo(struct dt3155_fifo *chunks, int buf_size); +void +dt3155_free_ibufs_fifo(struct dt3155_fifo *fifo); + +#endif /* _DT3155_BUFS_H_ */ diff --git a/drivers/staging/dt3155v4l/dt3155v4l.c b/drivers/staging/dt3155v4l/dt3155v4l.c new file mode 100644 index 000000000000..6282b7bbd4eb --- /dev/null +++ b/drivers/staging/dt3155v4l/dt3155v4l.c @@ -0,0 +1,1537 @@ +#include <media/v4l2-dev.h> +#include <media/videobuf-core.h> +#include <media/v4l2-ioctl.h> +#include <linux/pci.h> +#include <linux/version.h> +#include <linux/stringify.h> +#include <media/videobuf-dma-contig.h> +#include <linux/kthread.h> + +#include "dt3155v4l.h" +#include "dt3155-bufs.h" + +#define DT3155_VENDOR_ID 0x8086 +#define DT3155_DEVICE_ID 0x1223 + +/* global initializers (for all boards) */ +#ifdef CONFIG_DT3155_CCIR +static const u8 csr2_init = VT_50HZ; +#define DT3155_CURRENT_NORM V4L2_STD_625_50 +static const unsigned int img_width = 768; +static const unsigned int img_height = 576; +static const unsigned int frames_per_sec = 25; +static const struct v4l2_fmtdesc frame_std[] = { + { + .index = 0, + .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, + .flags = 0, + .description = "CCIR/50Hz 8 bits gray", + .pixelformat = V4L2_PIX_FMT_GREY, + }, +}; +#else +static const u8 csr2_init = VT_60HZ; +#define DT3155_CURRENT_NORM V4L2_STD_525_60 +static const unsigned int img_width = 640; +static const unsigned int img_height = 480; +static const unsigned int frames_per_sec = 30; +static const struct v4l2_fmtdesc frame_std[] = { + { + .index = 0, + .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, + .flags = 0, + .description = "RS-170/60Hz 8 bits gray", + .pixelformat = V4L2_PIX_FMT_GREY, + }, +}; +#endif + +#define NUM_OF_FORMATS ARRAY_SIZE(frame_std) + +static u8 config_init = ACQ_MODE_EVEN; + +/** + * read_i2c_reg - reads an internal i2c register + * + * @addr: dt3155 mmio base address + * @index: index (internal address) of register to read + * @data: pointer to byte the read data will be placed in + * + * returns: zero on success or error code + * + * This function starts reading the specified (by index) register + * and busy waits for the process to finish. The result is placed + * in a byte pointed by data. + */ +static int +read_i2c_reg(void *addr, u8 index, u8 *data) +{ + u32 tmp = index; + + iowrite32((tmp<<17) | IIC_READ, addr + IIC_CSR2); + mmiowb(); + udelay(45); /* wait at least 43 usec for NEW_CYCLE to clear */ + if (ioread32(addr + IIC_CSR2) & NEW_CYCLE) { + /* error: NEW_CYCLE not cleared */ + printk(KERN_ERR "dt3155: NEW_CYCLE not cleared\n"); + return -EIO; + } + tmp = ioread32(addr + IIC_CSR1); + if (tmp & DIRECT_ABORT) { + /* error: DIRECT_ABORT set */ + printk(KERN_ERR "dt3155: DIRECT_ABORT set\n"); + /* reset DIRECT_ABORT bit */ + iowrite32(DIRECT_ABORT, addr + IIC_CSR1); + return -EIO; + } + *data = tmp>>24; + return 0; +} + +/** + * write_i2c_reg - writes to an internal i2c register + * + * @addr: dt3155 mmio base address + * @index: index (internal address) of register to read + * @data: data to be written + * + * returns: zero on success or error code + * + * This function starts writting the specified (by index) register + * and busy waits for the process to finish. + */ +static int +write_i2c_reg(void *addr, u8 index, u8 data) +{ + u32 tmp = index; + + iowrite32((tmp<<17) | IIC_WRITE | data, addr + IIC_CSR2); + mmiowb(); + udelay(65); /* wait at least 63 usec for NEW_CYCLE to clear */ + if (ioread32(addr + IIC_CSR2) & NEW_CYCLE) { + /* error: NEW_CYCLE not cleared */ + printk(KERN_ERR "dt3155: NEW_CYCLE not cleared\n"); + return -EIO; + } + if (ioread32(addr + IIC_CSR1) & DIRECT_ABORT) { + /* error: DIRECT_ABORT set */ + printk(KERN_ERR "dt3155: DIRECT_ABORT set\n"); + /* reset DIRECT_ABORT bit */ + iowrite32(DIRECT_ABORT, addr + IIC_CSR1); + return -EIO; + } + return 0; +} + +/** + * write_i2c_reg_nowait - writes to an internal i2c register + * + * @addr: dt3155 mmio base address + * @index: index (internal address) of register to read + * @data: data to be written + * + * This function starts writting the specified (by index) register + * and then returns. + */ +void +write_i2c_reg_nowait(void *addr, u8 index, u8 data) +{ + u32 tmp = index; + + iowrite32((tmp<<17) | IIC_WRITE | data, addr + IIC_CSR2); + mmiowb(); +} + +/** + * wait_i2c_reg - waits the read/write to finish + * + * @addr: dt3155 mmio base address + * + * returns: zero on success or error code + * + * This function waits reading/writting to finish. + */ +static int +wait_i2c_reg(void *addr) +{ + if (ioread32(addr + IIC_CSR2) & NEW_CYCLE) + udelay(65); /* wait at least 63 usec for NEW_CYCLE to clear */ + if (ioread32(addr + IIC_CSR2) & NEW_CYCLE) { + /* error: NEW_CYCLE not cleared */ + printk(KERN_ERR "dt3155: NEW_CYCLE not cleared\n"); + return -EIO; + } + if (ioread32(addr + IIC_CSR1) & DIRECT_ABORT) { + /* error: DIRECT_ABORT set */ + printk(KERN_ERR "dt3155: DIRECT_ABORT set\n"); + /* reset DIRECT_ABORT bit */ + iowrite32(DIRECT_ABORT, addr + IIC_CSR1); + return -EIO; + } + return 0; +} + +/* + * global pointers to a list of 4MB chunks reserved at driver + * load, broken down to contiguous buffers of 768 * 576 bytes + * each to form a pool of buffers for allocations + * FIXME: add spinlock to protect moves between alloc/free lists + */ +static struct dt3155_fifo *dt3155_chunks; /* list of 4MB chuncks */ +static struct dt3155_fifo *dt3155_free_bufs; /* list of free buffers */ +static struct dt3155_fifo *dt3155_alloc_bufs; /* list of allocated buffers */ + +/* same as in <drivers/media/video/videobuf-dma-contig.c> */ +struct videobuf_dma_contig_memory { + u32 magic; + void *vaddr; + dma_addr_t dma_handle; + unsigned long size; + int is_userptr; +}; + +#define MAGIC_DC_MEM 0x0733ac61 +#define MAGIC_CHECK(is, should) \ + if (unlikely((is) != (should))) { \ + pr_err("magic mismatch: %x expected %x\n", (is), (should)); \ + BUG(); \ + } + +/* helper functions to allocate/free buffers from the pool */ +static void * +dt3155_alloc_buffer(struct device *dev, size_t size, dma_addr_t *dma_handle, + gfp_t flag) +{ + struct dt3155_buf *buf; + + if (size > DT3155_BUF_SIZE) + return NULL; + size = DT3155_BUF_SIZE; /* same for CCIR & RS-170 */ + buf = dt3155_get_buf(dt3155_free_bufs); + if (!buf) + return NULL; + buf->dma = dma_map_single(dev, buf->cpu, size, DMA_FROM_DEVICE); + if (dma_mapping_error(dev, buf->dma)) { + dt3155_put_buf(buf, dt3155_free_bufs); + return NULL; + } + dt3155_put_buf(buf, dt3155_alloc_bufs); + *dma_handle = buf->dma; + return buf->cpu; +} + +static void +dt3155_free_buffer(struct device *dev, size_t size, void *cpu_addr, + dma_addr_t dma_handle) +{ + struct dt3155_buf *buf, *last; + int found = 0; + + if (!cpu_addr) /* to free NULL is OK */ + return; + last = dt3155_get_buf(dt3155_alloc_bufs); + if (!last) { + printk(KERN_ERR "dt3155: %s(): no alloc buffers\n", __func__); + return; + } + dt3155_put_buf(last, dt3155_alloc_bufs); + do { + buf = dt3155_get_buf(dt3155_alloc_bufs); + if (buf->cpu == cpu_addr && buf->dma == dma_handle) { + found = 1; + break; + } + dt3155_put_buf(buf, dt3155_alloc_bufs); + } while (buf != last); + if (!found) { + printk(KERN_ERR "dt3155: %s(): buffer not found\n", __func__); + return; + } + size = DT3155_BUF_SIZE; /* same for CCIR & RS-170 */ + dma_unmap_single(dev, dma_handle, size, DMA_FROM_DEVICE); + dt3155_put_buf(buf, dt3155_free_bufs); +} + +/* same as videobuf_dma_contig_user_get() */ +static int +dt3155_dma_contig_user_get(struct videobuf_dma_contig_memory *mem, + struct videobuf_buffer *vb) +{ + struct mm_struct *mm = current->mm; + struct vm_area_struct *vma; + unsigned long prev_pfn, this_pfn; + unsigned long pages_done, user_address; + int ret; + + mem->size = PAGE_ALIGN(vb->size); + mem->is_userptr = 0; + ret = -EINVAL; + + down_read(&mm->mmap_sem); + + vma = find_vma(mm, vb->baddr); + if (!vma) + goto out_up; + + if ((vb->baddr + mem->size) > vma->vm_end) + goto out_up; + + pages_done = 0; + prev_pfn = 0; /* kill warning */ + user_address = vb->baddr; + + while (pages_done < (mem->size >> PAGE_SHIFT)) { + ret = follow_pfn(vma, user_address, &this_pfn); + if (ret) + break; + + if (pages_done == 0) + mem->dma_handle = this_pfn << PAGE_SHIFT; + else if (this_pfn != (prev_pfn + 1)) + ret = -EFAULT; + + if (ret) + break; + + prev_pfn = this_pfn; + user_address += PAGE_SIZE; + pages_done++; + } + + if (!ret) + mem->is_userptr = 1; + + out_up: + up_read(¤t->mm->mmap_sem); + + return ret; +} + +/* same as videobuf_dma_contig_user_put() */ +static void +dt3155_dma_contig_user_put(struct videobuf_dma_contig_memory *mem) +{ + mem->is_userptr = 0; + mem->dma_handle = 0; + mem->size = 0; +} + +/* same as videobuf_iolock() but uses allocations from the pool */ +static int +dt3155_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb, + struct v4l2_framebuffer *fbuf) +{ + struct videobuf_dma_contig_memory *mem = vb->priv; + + BUG_ON(!mem); + MAGIC_CHECK(mem->magic, MAGIC_DC_MEM); + + switch (vb->memory) { + case V4L2_MEMORY_MMAP: + dev_dbg(q->dev, "%s memory method MMAP\n", __func__); + + /* All handling should be done by __videobuf_mmap_mapper() */ + if (!mem->vaddr) { + dev_err(q->dev, "memory is not alloced/mmapped.\n"); + return -EINVAL; + } + break; + case V4L2_MEMORY_USERPTR: + dev_dbg(q->dev, "%s memory method USERPTR\n", __func__); + + /* handle pointer from user space */ + if (vb->baddr) + return dt3155_dma_contig_user_get(mem, vb); + + /* allocate memory for the read() method */ + mem->size = PAGE_ALIGN(vb->size); + mem->vaddr = dt3155_alloc_buffer(q->dev, mem->size, + &mem->dma_handle, GFP_KERNEL); + if (!mem->vaddr) { + dev_err(q->dev, "dma_alloc_coherent %ld failed\n", + mem->size); + return -ENOMEM; + } + + dev_dbg(q->dev, "dma_alloc_coherent data is at %p (%ld)\n", + mem->vaddr, mem->size); + break; + case V4L2_MEMORY_OVERLAY: + default: + dev_dbg(q->dev, "%s memory method OVERLAY/unknown\n", + __func__); + return -EINVAL; + } + + return 0; +} + +/* same as videobuf_dma_contig_free() but uses the pool */ +void +dt3155_dma_contig_free(struct videobuf_queue *q, struct videobuf_buffer *buf) +{ + struct videobuf_dma_contig_memory *mem = buf->priv; + + /* mmapped memory can't be freed here, otherwise mmapped region + would be released, while still needed. In this case, the memory + release should happen inside videobuf_vm_close(). + So, it should free memory only if the memory were allocated for + read() operation. + */ + if (buf->memory != V4L2_MEMORY_USERPTR) + return; + + if (!mem) + return; + + MAGIC_CHECK(mem->magic, MAGIC_DC_MEM); + + /* handle user space pointer case */ + if (buf->baddr) { + dt3155_dma_contig_user_put(mem); + return; + } + + /* read() method */ + dt3155_free_buffer(q->dev, mem->size, mem->vaddr, mem->dma_handle); + mem->vaddr = NULL; +} + +/* same as videobuf_vm_open() */ +static void +dt3155_vm_open(struct vm_area_struct *vma) +{ + struct videobuf_mapping *map = vma->vm_private_data; + + dev_dbg(map->q->dev, "vm_open %p [count=%u,vma=%08lx-%08lx]\n", + map, map->count, vma->vm_start, vma->vm_end); + + map->count++; +} + +/* same as videobuf_vm_close(), but free to the pool */ +static void +dt3155_vm_close(struct vm_area_struct *vma) +{ + struct videobuf_mapping *map = vma->vm_private_data; + struct videobuf_queue *q = map->q; + int i; + + dev_dbg(map->q->dev, "vm_close %p [count=%u,vma=%08lx-%08lx]\n", + map, map->count, vma->vm_start, vma->vm_end); + + map->count--; + if (0 == map->count) { + struct videobuf_dma_contig_memory *mem; + + dev_dbg(map->q->dev, "munmap %p q=%p\n", map, q); + mutex_lock(&q->vb_lock); + + /* We need first to cancel streams, before unmapping */ + if (q->streaming) + videobuf_queue_cancel(q); + + for (i = 0; i < VIDEO_MAX_FRAME; i++) { + if (NULL == q->bufs[i]) + continue; + + if (q->bufs[i]->map != map) + continue; + + mem = q->bufs[i]->priv; + if (mem) { + /* This callback is called only if kernel has + allocated memory and this memory is mmapped. + In this case, memory should be freed, + in order to do memory unmap. + */ + + MAGIC_CHECK(mem->magic, MAGIC_DC_MEM); + + /* vfree is not atomic - can't be + called with IRQ's disabled + */ + dev_dbg(map->q->dev, "buf[%d] freeing %p\n", + i, mem->vaddr); + + dt3155_free_buffer(q->dev, mem->size, + mem->vaddr, mem->dma_handle); + mem->vaddr = NULL; + } + + q->bufs[i]->map = NULL; + q->bufs[i]->baddr = 0; + } + + kfree(map); + + mutex_unlock(&q->vb_lock); + } +} + +static const struct vm_operations_struct dt3155_vm_ops = { + .open = dt3155_vm_open, + .close = dt3155_vm_close, +}; + +/* same as videobuf_mmap_mapper(), but allocates from the pool */ +static int +dt3155_mmap_mapper(struct videobuf_queue *q, struct vm_area_struct *vma) +{ + struct videobuf_dma_contig_memory *mem; + struct videobuf_mapping *map; + unsigned int first; + int retval; + unsigned long size, offset = vma->vm_pgoff << PAGE_SHIFT; + + dev_dbg(q->dev, "%s\n", __func__); + if (!(vma->vm_flags & VM_WRITE) || !(vma->vm_flags & VM_SHARED)) + return -EINVAL; + + /* look for first buffer to map */ + for (first = 0; first < VIDEO_MAX_FRAME; first++) { + if (!q->bufs[first]) + continue; + + if (V4L2_MEMORY_MMAP != q->bufs[first]->memory) + continue; + if (q->bufs[first]->boff == offset) + break; + } + if (VIDEO_MAX_FRAME == first) { + dev_dbg(q->dev, "invalid user space offset [offset=0x%lx]\n", + offset); + return -EINVAL; + } + + /* create mapping + update buffer list */ + map = kzalloc(sizeof(struct videobuf_mapping), GFP_KERNEL); + if (!map) + return -ENOMEM; + + q->bufs[first]->map = map; + map->start = vma->vm_start; + map->end = vma->vm_end; + map->q = q; + + q->bufs[first]->baddr = vma->vm_start; + + mem = q->bufs[first]->priv; + BUG_ON(!mem); + MAGIC_CHECK(mem->magic, MAGIC_DC_MEM); + + mem->size = PAGE_ALIGN(q->bufs[first]->bsize); + mem->vaddr = dt3155_alloc_buffer(q->dev, mem->size, + &mem->dma_handle, GFP_KERNEL); + if (!mem->vaddr) { + dev_err(q->dev, "dma_alloc_coherent size %ld failed\n", + mem->size); + goto error; + } + dev_dbg(q->dev, "dma_alloc_coherent data is at addr %p (size %ld)\n", + mem->vaddr, mem->size); + + /* Try to remap memory */ + + size = vma->vm_end - vma->vm_start; + size = (size < mem->size) ? size : mem->size; + + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + retval = remap_pfn_range(vma, vma->vm_start, + mem->dma_handle >> PAGE_SHIFT, + size, vma->vm_page_prot); + if (retval) { + dev_err(q->dev, "mmap: remap failed with error %d. ", retval); + dt3155_free_buffer(q->dev, mem->size, + mem->vaddr, mem->dma_handle); + goto error; + } + + vma->vm_ops = &dt3155_vm_ops; + vma->vm_flags |= VM_DONTEXPAND; + vma->vm_private_data = map; + + dev_dbg(q->dev, "mmap %p: q=%p %08lx-%08lx (%lx) pgoff %08lx buf %d\n", + map, q, vma->vm_start, vma->vm_end, + (long int) q->bufs[first]->bsize, + vma->vm_pgoff, first); + + dt3155_vm_open(vma); + + return 0; + +error: + kfree(map); + return -ENOMEM; +} + +static int +dt3155_sync_for_cpu(struct videobuf_queue *q, struct videobuf_buffer *vb) +{ + struct dt3155_priv *pd = q->priv_data; + struct videobuf_dma_contig_memory *mem = vb->priv; + + BUG_ON(!mem); + MAGIC_CHECK(mem->magic, MAGIC_DC_MEM); + + pci_dma_sync_single_for_cpu(pd->pdev, mem->dma_handle, + mem->size, PCI_DMA_FROMDEVICE); + return 0; +} + +static int +dt3155_sync_for_device(struct videobuf_queue *q, struct videobuf_buffer *vb) +{ + struct dt3155_priv *pd = q->priv_data; + struct videobuf_dma_contig_memory *mem = vb->priv; + + BUG_ON(!mem); + MAGIC_CHECK(mem->magic, MAGIC_DC_MEM); + + pci_dma_sync_single_for_device(pd->pdev, mem->dma_handle, + mem->size, PCI_DMA_FROMDEVICE); + return 0; +} + +/* + * same as videobuf_queue_dma_contig_init(), but after + * initialisation overwrites videobuf_iolock() and + * videobuf_mmap_mapper() with our customized versions + * as well as adds sync() method + */ +static void +dt3155_queue_dma_contig_init(struct videobuf_queue *q, + struct videobuf_queue_ops *ops, + struct device *dev, + spinlock_t *irqlock, + enum v4l2_buf_type type, + enum v4l2_field field, + unsigned int msize, + void *priv) +{ + videobuf_queue_dma_contig_init(q, ops, dev, irqlock, + type, field, msize, priv); + /* overwrite with our methods */ + q->int_ops->iolock = dt3155_iolock; + q->int_ops->mmap_mapper = dt3155_mmap_mapper; + q->int_ops->sync = dt3155_sync_for_cpu; +} + +static int +dt3155_start_acq(struct dt3155_priv *pd) +{ + struct videobuf_buffer *vb = pd->curr_buf; + dma_addr_t dma_addr; + + dma_addr = videobuf_to_dma_contig(vb); + iowrite32(dma_addr, pd->regs + EVEN_DMA_START); + iowrite32(dma_addr + vb->width, pd->regs + ODD_DMA_START); + iowrite32(vb->width, pd->regs + EVEN_DMA_STRIDE); + iowrite32(vb->width, pd->regs + ODD_DMA_STRIDE); + /* enable interrupts, clear all irq flags */ + iowrite32(FLD_START_EN | FLD_END_ODD_EN | FLD_START | + FLD_END_EVEN | FLD_END_ODD, pd->regs + INT_CSR); + iowrite32(FIFO_EN | SRST | FLD_CRPT_ODD | FLD_CRPT_EVEN | + FLD_DN_ODD | FLD_DN_EVEN | CAP_CONT_EVEN | CAP_CONT_ODD, + pd->regs + CSR1); + wait_i2c_reg(pd->regs); + write_i2c_reg(pd->regs, CONFIG, pd->config); + write_i2c_reg(pd->regs, EVEN_CSR, CSR_ERROR | CSR_DONE); + write_i2c_reg(pd->regs, ODD_CSR, CSR_ERROR | CSR_DONE); + + /* start the board */ + write_i2c_reg(pd->regs, CSR2, pd->csr2 | BUSY_EVEN | BUSY_ODD); + return 0; /* success */ +} + +static int +dt3155_stop_acq(struct dt3155_priv *pd) +{ + int tmp; + + /* stop the board */ + wait_i2c_reg(pd->regs); + write_i2c_reg(pd->regs, CSR2, pd->csr2); + + /* disable all irqs, clear all irq flags */ + iowrite32(FLD_START | FLD_END_EVEN | FLD_END_ODD, pd->regs + INT_CSR); + write_i2c_reg(pd->regs, EVEN_CSR, CSR_ERROR | CSR_DONE); + write_i2c_reg(pd->regs, ODD_CSR, CSR_ERROR | CSR_DONE); + tmp = ioread32(pd->regs + CSR1) & (FLD_CRPT_EVEN | FLD_CRPT_ODD); + if (tmp) + printk(KERN_ERR "dt3155: corrupted field %u\n", tmp); + iowrite32(FIFO_EN | SRST | FLD_CRPT_ODD | FLD_CRPT_EVEN | + FLD_DN_ODD | FLD_DN_EVEN | CAP_CONT_EVEN | CAP_CONT_ODD, + pd->regs + CSR1); + return 0; +} + +/* Locking: Caller holds q->vb_lock */ +static int +dt3155_buf_setup(struct videobuf_queue *q, unsigned int *count, + unsigned int *size) +{ + *size = img_width * img_height; + return 0; +} + +/* Locking: Caller holds q->vb_lock */ +static int +dt3155_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, + enum v4l2_field field) +{ + int ret = 0; + + vb->width = img_width; + vb->height = img_height; + vb->size = img_width * img_height; + vb->field = field; + if (vb->state == VIDEOBUF_NEEDS_INIT) + ret = videobuf_iolock(q, vb, NULL); + if (ret) { + vb->state = VIDEOBUF_ERROR; + printk(KERN_ERR "ERROR: videobuf_iolock() failed\n"); + videobuf_dma_contig_free(q, vb); + } else + vb->state = VIDEOBUF_PREPARED; + return ret; +} + +/* Locking: Caller holds q->vb_lock & q->irqlock */ +static void +dt3155_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) +{ + struct dt3155_priv *pd = q->priv_data; + + if (vb->state != VIDEOBUF_NEEDS_INIT) { + vb->state = VIDEOBUF_QUEUED; + dt3155_sync_for_device(q, vb); + list_add_tail(&vb->queue, &pd->dmaq); + wake_up_interruptible_sync(&pd->do_dma); + } else + vb->state = VIDEOBUF_ERROR; +} + +/* Locking: Caller holds q->vb_lock */ +static void +dt3155_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb) +{ + if (vb->state == VIDEOBUF_ACTIVE) + videobuf_waiton(vb, 0, 0); /* FIXME: cannot be interrupted */ + dt3155_dma_contig_free(q, vb); + vb->state = VIDEOBUF_NEEDS_INIT; +} + +static struct videobuf_queue_ops vbq_ops = { + .buf_setup = dt3155_buf_setup, + .buf_prepare = dt3155_buf_prepare, + .buf_queue = dt3155_buf_queue, + .buf_release = dt3155_buf_release, +}; + +static irqreturn_t +dt3155_irq_handler_even(int irq, void *dev_id) +{ + struct dt3155_priv *ipd = dev_id; + struct videobuf_buffer *ivb; + dma_addr_t dma_addr; + u32 tmp; + + tmp = ioread32(ipd->regs + INT_CSR) & (FLD_START | FLD_END_ODD); + if (!tmp) + return IRQ_NONE; /* not our irq */ + if ((tmp & FLD_START) && !(tmp & FLD_END_ODD)) { + iowrite32(FLD_START_EN | FLD_END_ODD_EN | FLD_START, + ipd->regs + INT_CSR); + ipd->field_count++; + return IRQ_HANDLED; /* start of field irq */ + } + if ((tmp & FLD_START) && (tmp & FLD_END_ODD)) { + if (!ipd->stats.start_before_end++) + printk(KERN_ERR "dt3155: irq: START before END\n"); + } + /* check for corrupted fields */ +/* write_i2c_reg(ipd->regs, EVEN_CSR, CSR_ERROR | CSR_DONE); */ +/* write_i2c_reg(ipd->regs, ODD_CSR, CSR_ERROR | CSR_DONE); */ + tmp = ioread32(ipd->regs + CSR1) & (FLD_CRPT_EVEN | FLD_CRPT_ODD); + if (tmp) { + if (!ipd->stats.corrupted_fields++) + printk(KERN_ERR "dt3155: corrupted field %u\n", tmp); + iowrite32(FIFO_EN | SRST | FLD_CRPT_ODD | FLD_CRPT_EVEN | + FLD_DN_ODD | FLD_DN_EVEN | + CAP_CONT_EVEN | CAP_CONT_ODD, + ipd->regs + CSR1); + mmiowb(); + } + + spin_lock(&ipd->lock); + if (ipd->curr_buf && ipd->curr_buf->state == VIDEOBUF_ACTIVE) { + if (waitqueue_active(&ipd->curr_buf->done)) { + do_gettimeofday(&ipd->curr_buf->ts); + ipd->curr_buf->field_count = ipd->field_count; + ipd->curr_buf->state = VIDEOBUF_DONE; + wake_up(&ipd->curr_buf->done); + } else { + ivb = ipd->curr_buf; + goto load_dma; + } + } else + goto stop_dma; + if (list_empty(&ipd->dmaq)) + goto stop_dma; + ivb = list_first_entry(&ipd->dmaq, typeof(*ivb), queue); + list_del(&ivb->queue); + if (ivb->state == VIDEOBUF_QUEUED) { + ivb->state = VIDEOBUF_ACTIVE; + ipd->curr_buf = ivb; + } else + goto stop_dma; +load_dma: + dma_addr = videobuf_to_dma_contig(ivb); + iowrite32(dma_addr, ipd->regs + EVEN_DMA_START); + iowrite32(dma_addr + ivb->width, ipd->regs + ODD_DMA_START); + iowrite32(ivb->width, ipd->regs + EVEN_DMA_STRIDE); + iowrite32(ivb->width, ipd->regs + ODD_DMA_STRIDE); + mmiowb(); + /* enable interrupts, clear all irq flags */ + iowrite32(FLD_START_EN | FLD_END_ODD_EN | FLD_START | + FLD_END_EVEN | FLD_END_ODD, ipd->regs + INT_CSR); + spin_unlock(&ipd->lock); + return IRQ_HANDLED; + +stop_dma: + ipd->curr_buf = NULL; + /* stop the board */ + write_i2c_reg_nowait(ipd->regs, CSR2, ipd->csr2); + /* disable interrupts, clear all irq flags */ + iowrite32(FLD_START | FLD_END_EVEN | FLD_END_ODD, ipd->regs + INT_CSR); + spin_unlock(&ipd->lock); + return IRQ_HANDLED; +} + +static int +dt3155_threadfn(void *arg) +{ + struct dt3155_priv *pd = arg; + struct videobuf_buffer *vb; + unsigned long flags; + + while (1) { + wait_event_interruptible(pd->do_dma, + kthread_should_stop() || !list_empty(&pd->dmaq)); + if (kthread_should_stop()) + break; + + spin_lock_irqsave(&pd->lock, flags); + if (pd->curr_buf) /* dma is active */ + goto done; + if (list_empty(&pd->dmaq)) /* no empty biffers */ + goto done; + vb = list_first_entry(&pd->dmaq, typeof(*vb), queue); + list_del(&vb->queue); + if (vb->state == VIDEOBUF_QUEUED) { + vb->state = VIDEOBUF_ACTIVE; + pd->curr_buf = vb; + spin_unlock_irqrestore(&pd->lock, flags); + /* start dma */ + dt3155_start_acq(pd); + continue; + } else + printk(KERN_DEBUG "%s(): This is a BUG\n", __func__); +done: + spin_unlock_irqrestore(&pd->lock, flags); + } + return 0; +} + +static int +dt3155_open(struct file *filp) +{ + int ret = 0; + struct dt3155_priv *pd = video_drvdata(filp); + + printk(KERN_INFO "dt3155: open(): minor: %i\n", pd->vdev->minor); + + if (mutex_lock_interruptible(&pd->mux) == -EINTR) + return -ERESTARTSYS; + if (!pd->users) { + pd->vidq = kzalloc(sizeof(*pd->vidq), GFP_KERNEL); + if (!pd->vidq) { + printk(KERN_ERR "dt3155: error: alloc queue\n"); + ret = -ENOMEM; + goto err_alloc_queue; + } + dt3155_queue_dma_contig_init(pd->vidq, &vbq_ops, + &pd->pdev->dev, &pd->lock, + V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE, + sizeof(struct videobuf_buffer), pd); + /* disable all irqs, clear all irq flags */ + iowrite32(FLD_START | FLD_END_EVEN | FLD_END_ODD, + pd->regs + INT_CSR); + pd->irq_handler = dt3155_irq_handler_even; + ret = request_irq(pd->pdev->irq, pd->irq_handler, + IRQF_SHARED, DT3155_NAME, pd); + if (ret) { + printk(KERN_ERR "dt3155: error: request_irq\n"); + goto err_request_irq; + } + pd->curr_buf = NULL; + pd->thread = kthread_run(dt3155_threadfn, pd, + "dt3155_thread_%i", pd->vdev->minor); + if (IS_ERR(pd->thread)) { + printk(KERN_ERR "dt3155: kthread_run() failed\n"); + ret = PTR_ERR(pd->thread); + goto err_thread; + } + pd->field_count = 0; + } + pd->users++; + goto done; +err_thread: + free_irq(pd->pdev->irq, pd); +err_request_irq: + kfree(pd->vidq); + pd->vidq = NULL; +err_alloc_queue: +done: + mutex_unlock(&pd->mux); + return ret; +} + +static int +dt3155_release(struct file *filp) +{ + struct dt3155_priv *pd = video_drvdata(filp); + struct videobuf_buffer *tmp; + unsigned long flags; + int ret = 0; + + printk(KERN_INFO "dt3155: release(): minor: %i\n", pd->vdev->minor); + + if (mutex_lock_interruptible(&pd->mux) == -EINTR) + return -ERESTARTSYS; + pd->users--; + BUG_ON(pd->users < 0); + if (pd->acq_fp == filp) { + spin_lock_irqsave(&pd->lock, flags); + INIT_LIST_HEAD(&pd->dmaq); /* queue is emptied */ + tmp = pd->curr_buf; + spin_unlock_irqrestore(&pd->lock, flags); + if (tmp) + videobuf_waiton(tmp, 0, 1); /* block, interruptible */ + dt3155_stop_acq(pd); + videobuf_stop(pd->vidq); + pd->acq_fp = NULL; + } + if (!pd->users) { + kthread_stop(pd->thread); + free_irq(pd->pdev->irq, pd); + kfree(pd->vidq); + pd->vidq = NULL; + } + mutex_unlock(&pd->mux); + return ret; +} + +static ssize_t +dt3155_read(struct file *filp, char __user *user, size_t size, loff_t *loff) +{ + struct dt3155_priv *pd = video_drvdata(filp); + int ret; + + if (mutex_lock_interruptible(&pd->mux) == -EINTR) + return -ERESTARTSYS; + if (!pd->acq_fp) + pd->acq_fp = filp; + else if (pd->acq_fp != filp) { + ret = -EBUSY; + goto done; + } + ret = videobuf_read_stream(pd->vidq, user, size, loff, 0, + filp->f_flags & O_NONBLOCK); +done: + mutex_unlock(&pd->mux); + return ret; +} + +static unsigned int +dt3155_poll(struct file *filp, struct poll_table_struct *polltbl) +{ + struct dt3155_priv *pd = video_drvdata(filp); + + return videobuf_poll_stream(filp, pd->vidq, polltbl); +} + +static int +dt3155_mmap(struct file *filp, struct vm_area_struct *vma) +{ + struct dt3155_priv *pd = video_drvdata(filp); + + return videobuf_mmap_mapper(pd->vidq, vma); +} + +static const struct v4l2_file_operations dt3155_fops = { + .owner = THIS_MODULE, + .open = dt3155_open, + .release = dt3155_release, + .read = dt3155_read, + .poll = dt3155_poll, + .unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */ + .mmap = dt3155_mmap, +}; + +static int +dt3155_ioc_streamon(struct file *filp, void *p, enum v4l2_buf_type type) +{ + struct dt3155_priv *pd = video_drvdata(filp); + int ret = -ERESTARTSYS; + + if (mutex_lock_interruptible(&pd->mux) == -EINTR) + return ret; + if (!pd->acq_fp) { + ret = videobuf_streamon(pd->vidq); + if (ret) + goto unlock; + pd->acq_fp = filp; + wake_up_interruptible_sync(&pd->do_dma); + } else if (pd->acq_fp == filp) { + ret = videobuf_streamon(pd->vidq); + if (!ret) + wake_up_interruptible_sync(&pd->do_dma); + } else + ret = -EBUSY; +unlock: + mutex_unlock(&pd->mux); + return ret; +} + +static int +dt3155_ioc_streamoff(struct file *filp, void *p, enum v4l2_buf_type type) +{ + struct dt3155_priv *pd = video_drvdata(filp); + struct videobuf_buffer *tmp; + unsigned long flags; + int ret; + + ret = videobuf_streamoff(pd->vidq); + if (ret) + return ret; + spin_lock_irqsave(&pd->lock, flags); + tmp = pd->curr_buf; + spin_unlock_irqrestore(&pd->lock, flags); + if (tmp) + videobuf_waiton(tmp, 0, 1); /* block, interruptible */ + return ret; +} + +static int +dt3155_ioc_querycap(struct file *filp, void *p, struct v4l2_capability *cap) +{ + struct dt3155_priv *pd = video_drvdata(filp); + + strcpy(cap->driver, DT3155_NAME); + strcpy(cap->card, DT3155_NAME " frame grabber"); + sprintf(cap->bus_info, "PCI:%s", pci_name(pd->pdev)); + cap->version = + KERNEL_VERSION(DT3155_VER_MAJ, DT3155_VER_MIN, DT3155_VER_EXT); + cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | +#ifdef CONFIG_DT3155_STREAMING + V4L2_CAP_STREAMING; +#else + V4L2_CAP_READWRITE; +#endif + return 0; +} + +static int +dt3155_ioc_enum_fmt_vid_cap(struct file *filp, void *p, struct v4l2_fmtdesc *f) +{ + if (f->index >= NUM_OF_FORMATS) + return -EINVAL; + *f = frame_std[f->index]; + return 0; +} + +static int +dt3155_ioc_g_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f) +{ + if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + f->fmt.pix.width = img_width; + f->fmt.pix.height = img_height; + f->fmt.pix.pixelformat = V4L2_PIX_FMT_GREY; + f->fmt.pix.field = V4L2_FIELD_NONE; + f->fmt.pix.bytesperline = f->fmt.pix.width; + f->fmt.pix.sizeimage = f->fmt.pix.width * f->fmt.pix.height; + f->fmt.pix.colorspace = 0; + f->fmt.pix.priv = 0; + return 0; +} + +static int +dt3155_ioc_try_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f) +{ + if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + if (f->fmt.pix.width == img_width && + f->fmt.pix.height == img_height && + f->fmt.pix.pixelformat == V4L2_PIX_FMT_GREY && + f->fmt.pix.field == V4L2_FIELD_NONE && + f->fmt.pix.bytesperline == f->fmt.pix.width && + f->fmt.pix.sizeimage == f->fmt.pix.width * f->fmt.pix.height) + return 0; + else + return -EINVAL; +} + +static int +dt3155_ioc_s_fmt_vid_cap(struct file *filp, void *p, struct v4l2_format *f) +{ + return dt3155_ioc_g_fmt_vid_cap(filp, p, f); +} + +static int +dt3155_ioc_reqbufs(struct file *filp, void *p, struct v4l2_requestbuffers *b) +{ + struct dt3155_priv *pd = video_drvdata(filp); + struct videobuf_queue *q = pd->vidq; + + if (b->memory != V4L2_MEMORY_MMAP) + return -EINVAL; + if (b->count) + return videobuf_reqbufs(q, b); + else { /* FIXME: is it necessary? */ + printk(KERN_DEBUG "dt3155: request to free buffers\n"); + return videobuf_mmap_free(q); + } +} + +static int +dt3155_ioc_querybuf(struct file *filp, void *p, struct v4l2_buffer *b) +{ + struct dt3155_priv *pd = video_drvdata(filp); + struct videobuf_queue *q = pd->vidq; + + return videobuf_querybuf(q, b); +} + +static int +dt3155_ioc_qbuf(struct file *filp, void *p, struct v4l2_buffer *b) +{ + struct dt3155_priv *pd = video_drvdata(filp); + struct videobuf_queue *q = pd->vidq; + + return videobuf_qbuf(q, b); +} + +static int +dt3155_ioc_dqbuf(struct file *filp, void *p, struct v4l2_buffer *b) +{ + struct dt3155_priv *pd = video_drvdata(filp); + struct videobuf_queue *q = pd->vidq; + + return videobuf_dqbuf(q, b, filp->f_flags & O_NONBLOCK); +} + +static int +dt3155_ioc_querystd(struct file *filp, void *p, v4l2_std_id *norm) +{ + *norm = DT3155_CURRENT_NORM; + return 0; +} + +static int +dt3155_ioc_g_std(struct file *filp, void *p, v4l2_std_id *norm) +{ + *norm = DT3155_CURRENT_NORM; + return 0; +} + +static int +dt3155_ioc_s_std(struct file *filp, void *p, v4l2_std_id *norm) +{ + if (*norm & DT3155_CURRENT_NORM) + return 0; + return -EINVAL; +} + +static int +dt3155_ioc_enum_input(struct file *filp, void *p, struct v4l2_input *input) +{ + if (input->index) + return -EINVAL; + strcpy(input->name, "Coax in"); + input->type = V4L2_INPUT_TYPE_CAMERA; + input->std = V4L2_STD_ALL; + input->status = 0;/* FIXME: add sync detection & V4L2_IN_ST_NO_H_LOCK */ + return 0; +} + +static int +dt3155_ioc_g_input(struct file *filp, void *p, unsigned int *i) +{ + *i = 0; + return 0; +} + +static int +dt3155_ioc_s_input(struct file *filp, void *p, unsigned int i) +{ + if (i) + return -EINVAL; + return 0; +} + +static int +dt3155_ioc_g_parm(struct file *filp, void *p, struct v4l2_streamparm *parms) +{ + if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + parms->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; + parms->parm.capture.capturemode = 0; + parms->parm.capture.timeperframe.numerator = 1001; + parms->parm.capture.timeperframe.denominator = frames_per_sec * 1000; + parms->parm.capture.extendedmode = 0; + parms->parm.capture.readbuffers = 1; + return 0; +} + +static int +dt3155_ioc_s_parm(struct file *filp, void *p, struct v4l2_streamparm *parms) +{ + if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + parms->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; + parms->parm.capture.capturemode = 0; + parms->parm.capture.timeperframe.numerator = 1001; + parms->parm.capture.timeperframe.denominator = frames_per_sec * 1000; + parms->parm.capture.extendedmode = 0; + parms->parm.capture.readbuffers = 1; + return 0; +} + +static const struct v4l2_ioctl_ops dt3155_ioctl_ops = { + .vidioc_streamon = dt3155_ioc_streamon, + .vidioc_streamoff = dt3155_ioc_streamoff, + .vidioc_querycap = dt3155_ioc_querycap, +/* + .vidioc_g_priority = dt3155_ioc_g_priority, + .vidioc_s_priority = dt3155_ioc_s_priority, +*/ + .vidioc_enum_fmt_vid_cap = dt3155_ioc_enum_fmt_vid_cap, + .vidioc_try_fmt_vid_cap = dt3155_ioc_try_fmt_vid_cap, + .vidioc_g_fmt_vid_cap = dt3155_ioc_g_fmt_vid_cap, + .vidioc_s_fmt_vid_cap = dt3155_ioc_s_fmt_vid_cap, + .vidioc_reqbufs = dt3155_ioc_reqbufs, + .vidioc_querybuf = dt3155_ioc_querybuf, + .vidioc_qbuf = dt3155_ioc_qbuf, + .vidioc_dqbuf = dt3155_ioc_dqbuf, + .vidioc_querystd = dt3155_ioc_querystd, + .vidioc_g_std = dt3155_ioc_g_std, + .vidioc_s_std = dt3155_ioc_s_std, + .vidioc_enum_input = dt3155_ioc_enum_input, + .vidioc_g_input = dt3155_ioc_g_input, + .vidioc_s_input = dt3155_ioc_s_input, +/* + .vidioc_queryctrl = dt3155_ioc_queryctrl, + .vidioc_g_ctrl = dt3155_ioc_g_ctrl, + .vidioc_s_ctrl = dt3155_ioc_s_ctrl, + .vidioc_querymenu = dt3155_ioc_querymenu, + .vidioc_g_ext_ctrls = dt3155_ioc_g_ext_ctrls, + .vidioc_s_ext_ctrls = dt3155_ioc_s_ext_ctrls, +*/ + .vidioc_g_parm = dt3155_ioc_g_parm, + .vidioc_s_parm = dt3155_ioc_s_parm, +/* + .vidioc_cropcap = dt3155_ioc_cropcap, + .vidioc_g_crop = dt3155_ioc_g_crop, + .vidioc_s_crop = dt3155_ioc_s_crop, + .vidioc_enum_framesizes = dt3155_ioc_enum_framesizes, + .vidioc_enum_frameintervals = dt3155_ioc_enum_frameintervals, +#ifdef CONFIG_VIDEO_V4L1_COMPAT + .vidiocgmbuf = iocgmbuf, +#endif +*/ +}; + +static int __devinit +dt3155_init_board(struct pci_dev *dev) +{ + int i; + u8 tmp; + struct dt3155_buf *buf; + struct dt3155_priv *pd = pci_get_drvdata(dev); + pci_set_master(dev); /* dt3155 needs it */ + + /* resetting the adapter */ + iowrite32(FLD_CRPT_ODD | FLD_CRPT_EVEN | FLD_DN_ODD | FLD_DN_EVEN, + pd->regs + CSR1); + mmiowb(); + msleep(10); + + /* initializing adaper registers */ + iowrite32(FIFO_EN | SRST, pd->regs + CSR1); + mmiowb(); + iowrite32(0xEEEEEE01, pd->regs + EVEN_PIXEL_FMT); + iowrite32(0xEEEEEE01, pd->regs + ODD_PIXEL_FMT); + iowrite32(0x00000020, pd->regs + FIFO_TRIGER); + iowrite32(0x00000103, pd->regs + XFER_MODE); + iowrite32(0, pd->regs + RETRY_WAIT_CNT); + iowrite32(0, pd->regs + INT_CSR); + iowrite32(1, pd->regs + EVEN_FLD_MASK); + iowrite32(1, pd->regs + ODD_FLD_MASK); + iowrite32(0, pd->regs + MASK_LENGTH); + iowrite32(0x0005007C, pd->regs + FIFO_FLAG_CNT); + iowrite32(0x01010101, pd->regs + IIC_CLK_DUR); + mmiowb(); + + /* verifying that we have a DT3155 board (not just a SAA7116 chip) */ + read_i2c_reg(pd->regs, DT_ID, &tmp); + if (tmp != DT3155_ID) + return -ENODEV; + + /* initialize AD LUT */ + write_i2c_reg(pd->regs, AD_ADDR, 0); + for (i = 0; i < 256; i++) + write_i2c_reg(pd->regs, AD_LUT, i); + + /* initialize ADC references */ + /* FIXME: pos_ref & neg_ref depend on VT_50HZ */ + write_i2c_reg(pd->regs, AD_ADDR, AD_CMD_REG); + write_i2c_reg(pd->regs, AD_CMD, VIDEO_CNL_1 | SYNC_CNL_1 | SYNC_LVL_3); + write_i2c_reg(pd->regs, AD_ADDR, AD_POS_REF); + write_i2c_reg(pd->regs, AD_CMD, 34); + write_i2c_reg(pd->regs, AD_ADDR, AD_NEG_REF); + write_i2c_reg(pd->regs, AD_CMD, 0); + + /* initialize PM LUT */ + write_i2c_reg(pd->regs, CONFIG, pd->config | PM_LUT_PGM); + for (i = 0; i < 256; i++) { + write_i2c_reg(pd->regs, PM_LUT_ADDR, i); + write_i2c_reg(pd->regs, PM_LUT_DATA, i); + } + write_i2c_reg(pd->regs, CONFIG, pd->config | PM_LUT_PGM | PM_LUT_SEL); + for (i = 0; i < 256; i++) { + write_i2c_reg(pd->regs, PM_LUT_ADDR, i); + write_i2c_reg(pd->regs, PM_LUT_DATA, i); + } + write_i2c_reg(pd->regs, CONFIG, pd->config); /* ACQ_MODE_EVEN */ + + /* select chanel 1 for input and set sync level */ + write_i2c_reg(pd->regs, AD_ADDR, AD_CMD_REG); + write_i2c_reg(pd->regs, AD_CMD, VIDEO_CNL_1 | SYNC_CNL_1 | SYNC_LVL_3); + + /* allocate and pci_map memory, and initialize the DMA machine */ + buf = dt3155_get_buf(dt3155_free_bufs); + if (!buf) { + printk(KERN_ERR "dt3155: dt3155_get_buf " + "(in dt3155_init_board) failed\n"); + return -ENOMEM; + } + buf->dma = pci_map_single(dev, buf->cpu, + DT3155_BUF_SIZE, PCI_DMA_FROMDEVICE); + if (pci_dma_mapping_error(dev, buf->dma)) { + printk(KERN_ERR "dt3155: pci_map_single failed\n"); + dt3155_put_buf(buf, dt3155_free_bufs); + return -ENOMEM; + } + iowrite32(buf->dma, pd->regs + EVEN_DMA_START); + iowrite32(buf->dma, pd->regs + ODD_DMA_START); + iowrite32(0, pd->regs + EVEN_DMA_STRIDE); + iowrite32(0, pd->regs + ODD_DMA_STRIDE); + + /* Perform a pseudo even field acquire */ + iowrite32(FIFO_EN | SRST | CAP_CONT_ODD, pd->regs + CSR1); + write_i2c_reg(pd->regs, CSR2, pd->csr2 | SYNC_SNTL); + write_i2c_reg(pd->regs, CONFIG, pd->config); + write_i2c_reg(pd->regs, EVEN_CSR, CSR_SNGL); + write_i2c_reg(pd->regs, CSR2, pd->csr2 | BUSY_EVEN | SYNC_SNTL); + msleep(100); + read_i2c_reg(pd->regs, CSR2, &tmp); + write_i2c_reg(pd->regs, EVEN_CSR, CSR_ERROR | CSR_SNGL | CSR_DONE); + write_i2c_reg(pd->regs, ODD_CSR, CSR_ERROR | CSR_SNGL | CSR_DONE); + write_i2c_reg(pd->regs, CSR2, pd->csr2); + iowrite32(FIFO_EN | SRST | FLD_DN_EVEN | FLD_DN_ODD, pd->regs + CSR1); + + /* pci_unmap and deallocate memory */ + pci_unmap_single(dev, buf->dma, DT3155_BUF_SIZE, PCI_DMA_FROMDEVICE); + dt3155_put_buf(buf, dt3155_free_bufs); + if (tmp & BUSY_EVEN) { + printk(KERN_ERR "dt3155: BUSY_EVEN not cleared\n"); + return -EIO; + } + return 0; +} + +static struct video_device dt3155_vdev = { + .name = DT3155_NAME, + .fops = &dt3155_fops, + .ioctl_ops = &dt3155_ioctl_ops, + .minor = -1, + .release = video_device_release, + .tvnorms = V4L2_STD_ALL, + .current_norm = DT3155_CURRENT_NORM, +}; + +static int __devinit +dt3155_probe(struct pci_dev *dev, const struct pci_device_id *id) +{ + int err = -ENODEV; + struct dt3155_priv *pd; + + printk(KERN_INFO "dt3155: probe()\n"); + if (pci_set_dma_mask(dev, DMA_BIT_MASK(32))) { + printk(KERN_ERR "dt3155: cannot set dma_mask\n"); + return -ENODEV; + } + pd = kzalloc(sizeof(*pd), GFP_KERNEL); + if (!pd) { + printk(KERN_ERR "dt3155: cannot allocate dt3155_priv\n"); + return -ENOMEM; + } + pd->vdev = video_device_alloc(); + if (!pd->vdev) { + printk(KERN_ERR "dt3155: cannot allocate vdp structure\n"); + goto err_video_device_alloc; + } + *pd->vdev = dt3155_vdev; + pci_set_drvdata(dev, pd); /* for use in dt3155_remove() */ + video_set_drvdata(pd->vdev, pd); /* for use in video_fops */ + pd->users = 0; + pd->acq_fp = NULL; + pd->pdev = dev; + INIT_LIST_HEAD(&pd->dmaq); + init_waitqueue_head(&pd->do_dma); + mutex_init(&pd->mux); + pd->csr2 = csr2_init; + pd->config = config_init; + err = pci_enable_device(pd->pdev); + if (err) { + printk(KERN_ERR "dt3155: pci_dev not enabled\n"); + goto err_enable_dev; + } + err = pci_request_region(pd->pdev, 0, pci_name(pd->pdev)); + if (err) + goto err_req_region; + pd->regs = pci_iomap(pd->pdev, 0, pci_resource_len(pd->pdev, 0)); + if (!pd->regs) { + err = -ENOMEM; + printk(KERN_ERR "dt3155: pci_iomap failed\n"); + goto err_pci_iomap; + } + err = dt3155_init_board(pd->pdev); + if (err) { + printk(KERN_ERR "dt3155: dt3155_init_board failed\n"); + goto err_init_board; + } + err = video_register_device(pd->vdev, VFL_TYPE_GRABBER, -1); + if (err) { + printk(KERN_ERR "dt3155: Cannot register video device\n"); + goto err_init_board; + } + printk(KERN_INFO "dt3155: /dev/video%i is ready\n", pd->vdev->minor); + return 0; /* success */ + +err_init_board: + pci_iounmap(pd->pdev, pd->regs); +err_pci_iomap: + pci_release_region(pd->pdev, 0); +err_req_region: + pci_disable_device(pd->pdev); +err_enable_dev: + video_device_release(pd->vdev); +err_video_device_alloc: + kfree(pd); + return err; +} + +static void __devexit +dt3155_remove(struct pci_dev *dev) +{ + struct dt3155_priv *pd = pci_get_drvdata(dev); + + printk(KERN_INFO "dt3155: remove()\n"); + video_unregister_device(pd->vdev); + pci_iounmap(dev, pd->regs); + pci_release_region(pd->pdev, 0); + pci_disable_device(pd->pdev); + /* + * video_device_release() is invoked automatically + * see: struct video_device dt3155_vdev + */ + kfree(pd); +} + +static DEFINE_PCI_DEVICE_TABLE(pci_ids) = { + { PCI_DEVICE(DT3155_VENDOR_ID, DT3155_DEVICE_ID) }, + { 0, /* zero marks the end */ }, +}; +MODULE_DEVICE_TABLE(pci, pci_ids); + +static struct pci_driver pci_driver = { + .name = DT3155_NAME, + .id_table = pci_ids, + .probe = dt3155_probe, + .remove = __devexit_p(dt3155_remove), +}; + +static int __init +dt3155_init_module(void) +{ + int err; + + printk(KERN_INFO "dt3155: ==================\n"); + printk(KERN_INFO "dt3155: init()\n"); + dt3155_chunks = dt3155_init_chunks_fifo(); + if (!dt3155_chunks) { + err = -ENOMEM; + printk(KERN_ERR "dt3155: cannot init dt3155_chunks_fifo\n"); + goto err_init_chunks_fifo; + } + dt3155_free_bufs = dt3155_init_ibufs_fifo(dt3155_chunks, + DT3155_BUF_SIZE); + if (!dt3155_free_bufs) { + err = -ENOMEM; + printk(KERN_ERR "dt3155: cannot dt3155_init_ibufs_fifo\n"); + goto err_init_ibufs_fifo; + } + dt3155_alloc_bufs = dt3155_init_fifo(); + if (!dt3155_alloc_bufs) { + err = -ENOMEM; + printk(KERN_ERR "dt3155: cannot dt3155_init_fifo\n"); + goto err_init_fifo; + } + err = pci_register_driver(&pci_driver); + if (err) { + printk(KERN_ERR "dt3155: cannot register pci_driver\n"); + goto err_register_driver; + } + return 0; /* succes */ +err_register_driver: + dt3155_free_fifo(dt3155_alloc_bufs); +err_init_fifo: + dt3155_free_ibufs_fifo(dt3155_free_bufs); +err_init_ibufs_fifo: + dt3155_free_chunks_fifo(dt3155_chunks); +err_init_chunks_fifo: + return err; +} + +static void __exit +dt3155_exit_module(void) +{ + pci_unregister_driver(&pci_driver); + dt3155_free_fifo(dt3155_alloc_bufs); + dt3155_free_ibufs_fifo(dt3155_free_bufs); + dt3155_free_chunks_fifo(dt3155_chunks); + printk(KERN_INFO "dt3155: exit()\n"); + printk(KERN_INFO "dt3155: ==================\n"); +} + +module_init(dt3155_init_module); +module_exit(dt3155_exit_module); + +MODULE_DESCRIPTION("video4linux pci-driver for dt3155 frame grabber"); +MODULE_AUTHOR("Marin Mitov <mitov@issp.bas.bg>"); +MODULE_VERSION(DT3155_VERSION); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/dt3155v4l/dt3155v4l.h b/drivers/staging/dt3155v4l/dt3155v4l.h new file mode 100644 index 000000000000..e5c4ad05b180 --- /dev/null +++ b/drivers/staging/dt3155v4l/dt3155v4l.h @@ -0,0 +1,220 @@ +/*************************************************************************** + * Copyright (C) 2006-2010 by Marin Mitov * + * mitov@issp.bas.bg * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This 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., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +/* DT3155 header file */ +#ifndef _DT3155_H_ +#define _DT3155_H_ + +#ifdef __KERNEL__ + +#include <linux/pci.h> +#include <linux/interrupt.h> + +#define DT3155_NAME "dt3155" +#define DT3155_VER_MAJ 1 +#define DT3155_VER_MIN 0 +#define DT3155_VER_EXT 2 +#define DT3155_VERSION __stringify(DT3155_VER_MAJ) "." \ + __stringify(DT3155_VER_MIN) "." \ + __stringify(DT3155_VER_EXT) + +/* DT3155 Base Register offsets (memory mapped) */ +#define EVEN_DMA_START 0x00 +#define ODD_DMA_START 0x0C +#define EVEN_DMA_STRIDE 0x18 +#define ODD_DMA_STRIDE 0x24 +#define EVEN_PIXEL_FMT 0x30 +#define ODD_PIXEL_FMT 0x34 +#define FIFO_TRIGER 0x38 +#define XFER_MODE 0x3C +#define CSR1 0x40 +#define RETRY_WAIT_CNT 0x44 +#define INT_CSR 0x48 +#define EVEN_FLD_MASK 0x4C +#define ODD_FLD_MASK 0x50 +#define MASK_LENGTH 0x54 +#define FIFO_FLAG_CNT 0x58 +#define IIC_CLK_DUR 0x5C +#define IIC_CSR1 0x60 +#define IIC_CSR2 0x64 + +/* DT3155 Internal Registers indexes (i2c/IIC mapped) */ +#define CSR2 0x10 +#define EVEN_CSR 0x11 +#define ODD_CSR 0x12 +#define CONFIG 0x13 +#define DT_ID 0x1F +#define X_CLIP_START 0x20 +#define Y_CLIP_START 0x22 +#define X_CLIP_END 0x24 +#define Y_CLIP_END 0x26 +#define AD_ADDR 0x30 +#define AD_LUT 0x31 +#define AD_CMD 0x32 +#define DIG_OUT 0x40 +#define PM_LUT_ADDR 0x50 +#define PM_LUT_DATA 0x51 + +/* AD command register values */ +#define AD_CMD_REG 0x00 +#define AD_POS_REF 0x01 +#define AD_NEG_REF 0x02 + +/* CSR1 bit masks */ +#define CRPT_DIS 0x00004000 +#define FLD_CRPT_ODD 0x00000200 +#define FLD_CRPT_EVEN 0x00000100 +#define FIFO_EN 0x00000080 +#define SRST 0x00000040 +#define FLD_DN_ODD 0x00000020 +#define FLD_DN_EVEN 0x00000010 +/* These should not be used. + * Use CAP_CONT_ODD/EVEN instead +#define CAP_SNGL_ODD 0x00000008 +#define CAP_SNGL_EVEN 0x00000004 +*/ +#define CAP_CONT_ODD 0x00000002 +#define CAP_CONT_EVEN 0x00000001 + +/* INT_CSR bit masks */ +#define FLD_START_EN 0x00000400 +#define FLD_END_ODD_EN 0x00000200 +#define FLD_END_EVEN_EN 0x00000100 +#define FLD_START 0x00000004 +#define FLD_END_ODD 0x00000002 +#define FLD_END_EVEN 0x00000001 + +/* IIC_CSR1 bit masks */ +#define DIRECT_ABORT 0x00000200 + +/* IIC_CSR2 bit masks */ +#define NEW_CYCLE 0x01000000 +#define DIR_RD 0x00010000 +#define IIC_READ 0x01010000 +#define IIC_WRITE 0x01000000 + +/* CSR2 bit masks */ +#define DISP_PASS 0x40 +#define BUSY_ODD 0x20 +#define BUSY_EVEN 0x10 +#define SYNC_PRESENT 0x08 +#define VT_50HZ 0x04 +#define SYNC_SNTL 0x02 +#define CHROM_FILT 0x01 +#define VT_60HZ 0x00 + +/* CSR_EVEN/ODD bit masks */ +#define CSR_ERROR 0x04 +#define CSR_SNGL 0x02 +#define CSR_DONE 0x01 + +/* CONFIG bit masks */ +#define PM_LUT_PGM 0x80 +#define PM_LUT_SEL 0x40 +#define CLIP_EN 0x20 +#define HSCALE_EN 0x10 +#define EXT_TRIG_UP 0x0C +#define EXT_TRIG_DOWN 0x04 +#define ACQ_MODE_NEXT 0x02 +#define ACQ_MODE_ODD 0x01 +#define ACQ_MODE_EVEN 0x00 + +/* AD_CMD bit masks */ +#define VIDEO_CNL_1 0x00 +#define VIDEO_CNL_2 0x40 +#define VIDEO_CNL_3 0x80 +#define VIDEO_CNL_4 0xC0 +#define SYNC_CNL_1 0x00 +#define SYNC_CNL_2 0x10 +#define SYNC_CNL_3 0x20 +#define SYNC_CNL_4 0x30 +#define SYNC_LVL_1 0x00 +#define SYNC_LVL_2 0x04 +#define SYNC_LVL_3 0x08 +#define SYNC_LVL_4 0x0C + +/* DT3155 identificator */ +#define DT3155_ID 0x20 + +#ifdef CONFIG_DT3155_CCIR +#define DMA_STRIDE 768 +#else +#define DMA_STRIDE 640 +#endif + +/** + * struct dt3155_stats - statistics structure + * + * @free_bufs_empty: no free image buffers + * @corrupted_fields: corrupted fields + * @dma_map_failed: dma mapping failed + * @start_before_end: new started before old ended + */ +struct dt3155_stats { + int free_bufs_empty; + int corrupted_fields; + int dma_map_failed; + int start_before_end; +}; + +/* per board private data structure */ +/** + * struct dt3155_priv - private data structure + * + * @vdev: pointer to video_device structure + * @acq_fp pointer to filp that starts acquisition + * @pdev: pointer to pci_dev structure + * @vidq pointer to videobuf_queue structure + * @curr_buf: pointer to curren buffer + * @thread pointer to worker thraed + * @irq_handler: irq handler for the driver + * @dmaq queue for dma buffers + * @do_dma wait queue of the kernel thread + * @mux: mutex to protect the instance + * @lock spinlock for videobuf queues + * @field_count fields counter + * @stats: statistics structure + * @users open count + * @regs: local copy of mmio base register + * @csr2: local copy of csr2 register + * @config: local copy of config register + */ +struct dt3155_priv { + struct video_device *vdev; + struct file *acq_fp; + struct pci_dev *pdev; + struct videobuf_queue *vidq; + struct videobuf_buffer *curr_buf; + struct task_struct *thread; + irq_handler_t irq_handler; + struct list_head dmaq; + wait_queue_head_t do_dma; + struct mutex mux; + spinlock_t lock; + unsigned int field_count; + struct dt3155_stats stats; + void *regs; + int users; + u8 csr2, config; +}; + +#endif /* __KERNEL__ */ + +#endif /* _DT3155_H_ */ diff --git a/drivers/staging/et131x/et1310_address_map.h b/drivers/staging/et131x/et1310_address_map.h index ea746ba41faf..e6c8cb3828e9 100644 --- a/drivers/staging/et131x/et1310_address_map.h +++ b/drivers/staging/et131x/et1310_address_map.h @@ -117,7 +117,7 @@ /* * Software reset reg at address 0x0028 - * 0: txdma_sw_reset + * 0: txdma_sw_reset * 1: rxdma_sw_reset * 2: txmac_sw_reset * 3: rxmac_sw_reset @@ -1052,7 +1052,7 @@ typedef struct _RXMAC_t { /* Location: */ * 4-0: register */ -#define MII_ADDR(phy,reg) ((phy) << 8 | (reg)) +#define MII_ADDR(phy, reg) ((phy) << 8 | (reg)) /* * structure for MII Management Control reg in mac address map. @@ -1249,8 +1249,7 @@ typedef struct _MAC_t { /* Location: */ /* * MAC STATS Module of JAGCore Address Mapping */ -struct macstat_regs -{ /* Location: */ +struct macstat_regs { /* Location: */ u32 pad[32]; /* 0x6000 - 607C */ /* Tx/Rx 0-64 Byte Frame Counter */ diff --git a/drivers/staging/et131x/et1310_eeprom.c b/drivers/staging/et131x/et1310_eeprom.c index e4d095b0b52a..5a8e6b913dab 100644 --- a/drivers/staging/et131x/et1310_eeprom.c +++ b/drivers/staging/et131x/et1310_eeprom.c @@ -302,7 +302,7 @@ static int eeprom_read(struct et131x_adapter *etdev, u32 addr, u8 *pdata) err = eeprom_wait_ready(pdev, NULL); if (err) return err; - /* + /* * Write to the LBCIF Control Register: bit 7=1, bit 6=0, bit 3=0, * and bits 1:0 both =0. Bit 5 should be set according to the type * of EEPROM being accessed (1=two byte addressing, 0=one byte @@ -383,9 +383,9 @@ int et131x_init_eeprom(struct et131x_adapter *etdev) /* This error could mean that there was an error * reading the eeprom or that the eeprom doesn't exist. - * We will treat each case the same and not try to gather - * additional information that normally would come from the - * eeprom, like MAC Address + * We will treat each case the same and not try to + * gather additional information that normally would + * come from the eeprom, like MAC Address */ etdev->has_eeprom = 0; return -EIO; diff --git a/drivers/staging/et131x/et1310_phy.c b/drivers/staging/et131x/et1310_phy.c index 34cd5d1b586a..a6d9f29ff49c 100644 --- a/drivers/staging/et131x/et1310_phy.c +++ b/drivers/staging/et131x/et1310_phy.c @@ -344,7 +344,7 @@ static void ET1310_PhyDuplexMode(struct et131x_adapter *etdev, u16 duplex) static void ET1310_PhySpeedSelect(struct et131x_adapter *etdev, u16 speed) { u16 data; - static const u16 bits[3]={0x0000, 0x2000, 0x0040}; + static const u16 bits[3] = {0x0000, 0x2000, 0x0040}; /* Read the PHY control register */ MiRead(etdev, PHY_CONTROL, &data); diff --git a/drivers/staging/et131x/et1310_rx.c b/drivers/staging/et131x/et1310_rx.c index 54686e2ace69..8f5dcebda76a 100644 --- a/drivers/staging/et131x/et1310_rx.c +++ b/drivers/staging/et131x/et1310_rx.c @@ -344,7 +344,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) "Cannot alloc memory for Packet Status Ring\n"); return -ENOMEM; } - printk("PSR %lx\n", (unsigned long) rx_ring->pPSRingPa); + printk(KERN_INFO "PSR %lx\n", (unsigned long) rx_ring->pPSRingPa); /* * NOTE : pci_alloc_consistent(), used above to alloc DMA regions, @@ -363,7 +363,7 @@ int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter) return -ENOMEM; } rx_ring->NumRfd = NIC_DEFAULT_NUM_RFD; - printk("PRS %lx\n", (unsigned long)rx_ring->rx_status_bus); + printk(KERN_INFO "PRS %lx\n", (unsigned long)rx_ring->rx_status_bus); /* Recv * pci_pool_create initializes a lookaside list. After successful @@ -445,10 +445,10 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) rx_ring->pFbr1RingVa - rx_ring->Fbr1offset); bufsize = (sizeof(struct fbr_desc) * rx_ring->Fbr1NumEntries) - + 0xfff; + + 0xfff; pci_free_consistent(adapter->pdev, bufsize, - rx_ring->pFbr1RingVa, rx_ring->pFbr1RingPa); + rx_ring->pFbr1RingVa, rx_ring->pFbr1RingPa); rx_ring->pFbr1RingVa = NULL; } @@ -478,7 +478,7 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) rx_ring->pFbr0RingVa - rx_ring->Fbr0offset); bufsize = (sizeof(struct fbr_desc) * rx_ring->Fbr0NumEntries) - + 0xfff; + + 0xfff; pci_free_consistent(adapter->pdev, bufsize, @@ -504,7 +504,7 @@ void et131x_rx_dma_memory_free(struct et131x_adapter *adapter) pci_free_consistent(adapter->pdev, sizeof(struct rx_status_block), rx_ring->rx_status_block, rx_ring->rx_status_bus); - rx_ring->rx_status_block = NULL; + rx_ring->rx_status_block = NULL; } /* Free receive buffer pool */ @@ -713,7 +713,7 @@ void SetRxDmaTimer(struct et131x_adapter *etdev) */ void et131x_rx_dma_disable(struct et131x_adapter *etdev) { - u32 csr; + u32 csr; /* Setup the receive dma configuration register */ writel(0x00002001, &etdev->regs->rxdma.csr); csr = readl(&etdev->regs->rxdma.csr); @@ -743,9 +743,9 @@ void et131x_rx_dma_enable(struct et131x_adapter *etdev) else if (etdev->rx_ring.Fbr1BufferSize == 16384) csr |= 0x1800; #ifdef USE_FBR0 - csr |= 0x0400; /* FBR0 enable */ + csr |= 0x0400; /* FBR0 enable */ if (etdev->rx_ring.Fbr0BufferSize == 256) - csr |= 0x0100; + csr |= 0x0100; else if (etdev->rx_ring.Fbr0BufferSize == 512) csr |= 0x0200; else if (etdev->rx_ring.Fbr0BufferSize == 1024) @@ -757,7 +757,7 @@ void et131x_rx_dma_enable(struct et131x_adapter *etdev) if ((csr & 0x00020000) != 0) { udelay(5); csr = readl(&etdev->regs->rxdma.csr); - if ((csr & 0x00020000) != 0) { + if ((csr & 0x00020000) != 0) { dev_err(&etdev->pdev->dev, "RX Dma failed to exit halt state. CSR 0x%08x\n", csr); @@ -841,8 +841,7 @@ PMP_RFD nic_rx_pkts(struct et131x_adapter *etdev) (rindex == 1 && bindex > rx_local->Fbr1NumEntries - 1)) #else - if (rindex != 1 || - bindex > rx_local->Fbr1NumEntries - 1) + if (rindex != 1 || bindex > rx_local->Fbr1NumEntries - 1) #endif { /* Illegal buffer or ring index cannot be used by S/W*/ @@ -1063,20 +1062,20 @@ void et131x_handle_recv_interrupt(struct et131x_adapter *etdev) static inline u32 bump_fbr(u32 *fbr, u32 limit) { - u32 v = *fbr; - v++; - /* This works for all cases where limit < 1024. The 1023 case - works because 1023++ is 1024 which means the if condition is not - taken but the carry of the bit into the wrap bit toggles the wrap - value correctly */ - if ((v & ET_DMA10_MASK) > limit) { - v &= ~ET_DMA10_MASK; - v ^= ET_DMA10_WRAP; - } - /* For the 1023 case */ - v &= (ET_DMA10_MASK|ET_DMA10_WRAP); - *fbr = v; - return v; + u32 v = *fbr; + v++; + /* This works for all cases where limit < 1024. The 1023 case + works because 1023++ is 1024 which means the if condition is not + taken but the carry of the bit into the wrap bit toggles the wrap + value correctly */ + if ((v & ET_DMA10_MASK) > limit) { + v &= ~ET_DMA10_MASK; + v ^= ET_DMA10_WRAP; + } + /* For the 1023 case */ + v &= (ET_DMA10_MASK|ET_DMA10_WRAP); + *fbr = v; + return v; } /** @@ -1105,7 +1104,7 @@ void nic_return_rfd(struct et131x_adapter *etdev, PMP_RFD rfd) if (ri == 1) { struct fbr_desc *next = (struct fbr_desc *) (rx_local->pFbr1RingVa) + - INDEX10(rx_local->local_Fbr1_full); + INDEX10(rx_local->local_Fbr1_full); /* Handle the Free Buffer Ring advancement here. Write * the PA / Buffer Index for the returned buffer into diff --git a/drivers/staging/et131x/et1310_rx.h b/drivers/staging/et131x/et1310_rx.h index ca84a9146d69..e8c653d37a76 100644 --- a/drivers/staging/et131x/et1310_rx.h +++ b/drivers/staging/et131x/et1310_rx.h @@ -91,8 +91,7 @@ #define ALCATEL_BROADCAST_PKT 0x02000000 /* typedefs for Free Buffer Descriptors */ -struct fbr_desc -{ +struct fbr_desc { u32 addr_lo; u32 addr_hi; u32 word2; /* Bits 10-31 reserved, 0-9 descriptor */ @@ -117,7 +116,7 @@ struct fbr_desc * 9: jp Jumbo Packet * 10: vp VLAN Packet * 11-15: unused - * 16: asw_prev_pkt_dropped e.g. IFG too small on previous + * 16: asw_prev_pkt_dropped e.g. IFG too small on previous * 17: asw_RX_DV_event short receive event detected * 18: asw_false_carrier_event bad carrier since last good packet * 19: asw_code_err one or more nibbles signalled as errors diff --git a/drivers/staging/et131x/et131x_initpci.c b/drivers/staging/et131x/et131x_initpci.c index 1dd5fa5b888b..47baab3e6ea8 100644 --- a/drivers/staging/et131x/et131x_initpci.c +++ b/drivers/staging/et131x/et131x_initpci.c @@ -113,7 +113,13 @@ static u32 et131x_speed_set; module_param(et131x_speed_set, uint, 0); MODULE_PARM_DESC(et131x_speed_set, - "Set Link speed and dublex manually (0-5) [0] \n 1 : 10Mb Half-Duplex \n 2 : 10Mb Full-Duplex \n 3 : 100Mb Half-Duplex \n 4 : 100Mb Full-Duplex \n 5 : 1000Mb Full-Duplex \n 0 : Auto Speed Auto Dublex"); + "Set Link speed and dublex manually (0-5) [0]\n \ + 1 : 10Mb Half-Duplex\n \ + 2 : 10Mb Full-Duplex\n \ + 3 : 100Mb Half-Duplex\n \ + 4 : 100Mb Full-Duplex\n \ + 5 : 1000Mb Full-Duplex\n \ + 0 : Auto Speed Auto Dublex"); /** * et131x_hwaddr_init - set up the MAC Address on the ET1310 @@ -558,7 +564,7 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev, /* Parse configuration parameters into the private adapter struct */ if (et131x_speed_set) dev_info(&etdev->pdev->dev, - "Speed set manually to : %d \n", et131x_speed_set); + "Speed set manually to : %d\n", et131x_speed_set); etdev->SpeedDuplex = et131x_speed_set; etdev->RegistryJumboPacket = 1514; /* 1514-9216 */ @@ -820,7 +826,7 @@ static int __init et131x_init_module(void) if (et131x_speed_set < PARM_SPEED_DUPLEX_MIN || et131x_speed_set > PARM_SPEED_DUPLEX_MAX) { printk(KERN_WARNING "et131x: invalid speed setting ignored.\n"); - et131x_speed_set = 0; + et131x_speed_set = 0; } return pci_register_driver(&et131x_driver); } diff --git a/drivers/staging/et131x/et131x_isr.c b/drivers/staging/et131x/et131x_isr.c index cb7f6775ce0a..36f68fe3e8c9 100644 --- a/drivers/staging/et131x/et131x_isr.c +++ b/drivers/staging/et131x/et131x_isr.c @@ -253,14 +253,12 @@ void et131x_isr_handler(struct work_struct *work) * exit. */ /* Handle all the completed Transmit interrupts */ - if (status & ET_INTR_TXDMA_ISR) { + if (status & ET_INTR_TXDMA_ISR) et131x_handle_send_interrupt(etdev); - } /* Handle all the completed Receives interrupts */ - if (status & ET_INTR_RXDMA_XFR_DONE) { + if (status & ET_INTR_RXDMA_XFR_DONE) et131x_handle_recv_interrupt(etdev); - } status &= 0xffffffd7; diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index abc82c3dad21..106d548982c4 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -426,26 +426,22 @@ void et131x_multicast(struct net_device *netdev) * accordingly */ - if (netdev->flags & IFF_PROMISC) { + if (netdev->flags & IFF_PROMISC) adapter->PacketFilter |= ET131X_PACKET_TYPE_PROMISCUOUS; - } else { + else adapter->PacketFilter &= ~ET131X_PACKET_TYPE_PROMISCUOUS; - } - if (netdev->flags & IFF_ALLMULTI) { + if (netdev->flags & IFF_ALLMULTI) adapter->PacketFilter |= ET131X_PACKET_TYPE_ALL_MULTICAST; - } - if (netdev_mc_count(netdev) > NIC_MAX_MCAST_LIST) { + if (netdev_mc_count(netdev) > NIC_MAX_MCAST_LIST) adapter->PacketFilter |= ET131X_PACKET_TYPE_ALL_MULTICAST; - } if (netdev_mc_count(netdev) < 1) { adapter->PacketFilter &= ~ET131X_PACKET_TYPE_ALL_MULTICAST; adapter->PacketFilter &= ~ET131X_PACKET_TYPE_MULTICAST; - } else { + } else adapter->PacketFilter |= ET131X_PACKET_TYPE_MULTICAST; - } /* Set values in the private adapter struct */ i = 0; diff --git a/drivers/staging/frontier/alphatrack.c b/drivers/staging/frontier/alphatrack.c index a50a21518a8e..4e52105e6070 100644 --- a/drivers/staging/frontier/alphatrack.c +++ b/drivers/staging/frontier/alphatrack.c @@ -134,7 +134,7 @@ MODULE_PARM_DESC(min_interrupt_out_interval, /* Structure to hold all of our device specific stuff */ struct usb_alphatrack { - struct semaphore sem; /* locks this structure */ + struct mutex mtx; /* locks this structure */ struct usb_interface *intf; /* save off the usb interface pointer */ int open_count; /* number of times this port has been opened */ @@ -238,7 +238,7 @@ static void usb_alphatrack_interrupt_in_callback(struct urb *urb) if (urb->actual_length != INPUT_CMD_SIZE) { dev_warn(&dev->intf->dev, "Urb length was %d bytes!!" - "Do something intelligent \n", urb->actual_length); + "Do something intelligent\n", urb->actual_length); } else { alphatrack_ocmd_info(&dev->intf->dev, &(*dev->ring_buffer)[dev->ring_tail].cmd, @@ -347,7 +347,7 @@ static int usb_alphatrack_open(struct inode *inode, struct file *file) } /* lock this device */ - if (down_interruptible(&dev->sem)) { + if (mutex_lock_interruptible(&dev->mtx)) { retval = -ERESTARTSYS; goto unlock_disconnect_exit; } @@ -390,7 +390,7 @@ static int usb_alphatrack_open(struct inode *inode, struct file *file) file->private_data = dev; unlock_exit: - up(&dev->sem); + mutex_unlock(&dev->mtx); unlock_disconnect_exit: mutex_unlock(&disconnect_mutex); @@ -413,7 +413,7 @@ static int usb_alphatrack_release(struct inode *inode, struct file *file) goto exit; } - if (down_interruptible(&dev->sem)) { + if (mutex_lock_interruptible(&dev->mtx)) { retval = -ERESTARTSYS; goto exit; } @@ -425,7 +425,7 @@ static int usb_alphatrack_release(struct inode *inode, struct file *file) if (dev->intf == NULL) { /* the device was unplugged before the file was released */ - up(&dev->sem); + mutex_unlock(&dev->mtx); /* unlock here as usb_alphatrack_delete frees dev */ usb_alphatrack_delete(dev); retval = -ENODEV; @@ -441,7 +441,7 @@ static int usb_alphatrack_release(struct inode *inode, struct file *file) dev->open_count = 0; unlock_exit: - up(&dev->sem); + mutex_unlock(&dev->mtx); exit: return retval; @@ -486,7 +486,7 @@ static ssize_t usb_alphatrack_read(struct file *file, char __user *buffer, goto exit; /* lock this object */ - if (down_interruptible(&dev->sem)) { + if (mutex_lock_interruptible(&dev->mtx)) { retval = -ERESTARTSYS; goto exit; } @@ -532,7 +532,7 @@ static ssize_t usb_alphatrack_read(struct file *file, char __user *buffer, unlock_exit: /* unlock the device */ - up(&dev->sem); + mutex_unlock(&dev->mtx); exit: return retval; @@ -556,7 +556,7 @@ static ssize_t usb_alphatrack_write(struct file *file, goto exit; /* lock this object */ - if (down_interruptible(&dev->sem)) { + if (mutex_lock_interruptible(&dev->mtx)) { retval = -ERESTARTSYS; goto exit; } @@ -599,7 +599,7 @@ static ssize_t usb_alphatrack_write(struct file *file, } if (dev->interrupt_out_endpoint == NULL) { - err("Endpoint should not be be null! \n"); + err("Endpoint should not be be null!\n"); goto unlock_exit; } @@ -627,7 +627,7 @@ static ssize_t usb_alphatrack_write(struct file *file, unlock_exit: /* unlock the device */ - up(&dev->sem); + mutex_unlock(&dev->mtx); exit: return retval; @@ -678,7 +678,7 @@ static int usb_alphatrack_probe(struct usb_interface *intf, dev_err(&intf->dev, "Out of memory\n"); goto exit; } - init_MUTEX(&dev->sem); + mutex_init(&dev->mtx); dev->intf = intf; init_waitqueue_head(&dev->read_wait); init_waitqueue_head(&dev->write_wait); @@ -771,7 +771,7 @@ static int usb_alphatrack_probe(struct usb_interface *intf, kmalloc(sizeof(struct alphatrack_ocmd) * true_size, GFP_KERNEL); if (!dev->write_buffer) { - dev_err(&intf->dev, "Couldn't allocate write_buffer \n"); + dev_err(&intf->dev, "Couldn't allocate write_buffer\n"); goto error; } @@ -835,7 +835,7 @@ static void usb_alphatrack_disconnect(struct usb_interface *intf) dev = usb_get_intfdata(intf); usb_set_intfdata(intf, NULL); - down(&dev->sem); + mutex_lock(&dev->mtx); minor = intf->minor; @@ -844,11 +844,11 @@ static void usb_alphatrack_disconnect(struct usb_interface *intf) /* if the device is not opened, then we clean up right now */ if (!dev->open_count) { - up(&dev->sem); + mutex_unlock(&dev->mtx); usb_alphatrack_delete(dev); } else { dev->intf = NULL; - up(&dev->sem); + mutex_unlock(&dev->mtx); } atomic_set(&dev->writes_pending, 0); diff --git a/drivers/staging/frontier/tranzport.c b/drivers/staging/frontier/tranzport.c index 2f03f43f3a2e..eed74f0fe0b6 100644 --- a/drivers/staging/frontier/tranzport.c +++ b/drivers/staging/frontier/tranzport.c @@ -123,7 +123,7 @@ struct tranzport_cmd { /* Structure to hold all of our device specific stuff */ struct usb_tranzport { - struct semaphore sem; /* locks this structure */ + struct mutex mtx; /* locks this structure */ struct usb_interface *intf; /* save off the usb interface pointer */ int open_count; /* number of times this port opened */ struct tranzport_cmd (*ring_buffer)[RING_BUFFER_SIZE]; @@ -198,7 +198,9 @@ static void usb_tranzport_abort_transfers(struct usb_tranzport *dev) { \ struct usb_interface *intf = to_usb_interface(dev); \ struct usb_tranzport *t = usb_get_intfdata(intf); \ - int temp = simple_strtoul(buf, NULL, 10); \ + unsigned long temp; \ + if (strict_strtoul(buf, 10, &temp)) \ + return -EINVAL; \ t->value = temp; \ return count; \ } \ @@ -255,7 +257,7 @@ static void usb_tranzport_interrupt_in_callback(struct urb *urb) if (urb->actual_length != 8) { dev_warn(&dev->intf->dev, "Urb length was %d bytes!!" - "Do something intelligent \n", + "Do something intelligent\n", urb->actual_length); } else { dbg_info(&dev->intf->dev, @@ -365,7 +367,7 @@ static int usb_tranzport_open(struct inode *inode, struct file *file) } /* lock this device */ - if (down_interruptible(&dev->sem)) { + if (mutex_lock_interruptible(&dev->mtx)) { retval = -ERESTARTSYS; goto unlock_disconnect_exit; } @@ -409,7 +411,7 @@ static int usb_tranzport_open(struct inode *inode, struct file *file) file->private_data = dev; unlock_exit: - up(&dev->sem); + mutex_unlock(&dev->mtx); unlock_disconnect_exit: mutex_unlock(&disconnect_mutex); @@ -432,7 +434,7 @@ static int usb_tranzport_release(struct inode *inode, struct file *file) goto exit; } - if (down_interruptible(&dev->sem)) { + if (mutex_lock_interruptible(&dev->mtx)) { retval = -ERESTARTSYS; goto exit; } @@ -444,7 +446,7 @@ static int usb_tranzport_release(struct inode *inode, struct file *file) if (dev->intf == NULL) { /* the device was unplugged before the file was released */ - up(&dev->sem); + mutex_unlock(&dev->mtx); /* unlock here as usb_tranzport_delete frees dev */ usb_tranzport_delete(dev); retval = -ENODEV; @@ -460,7 +462,7 @@ static int usb_tranzport_release(struct inode *inode, struct file *file) dev->open_count = 0; unlock_exit: - up(&dev->sem); + mutex_unlock(&dev->mtx); exit: return retval; @@ -510,7 +512,7 @@ static ssize_t usb_tranzport_read(struct file *file, char __user *buffer, goto exit; /* lock this object */ - if (down_interruptible(&dev->sem)) { + if (mutex_lock_interruptible(&dev->mtx)) { retval = -ERESTARTSYS; goto exit; } @@ -658,7 +660,7 @@ retval = 8; unlock_exit: /* unlock the device */ -up(&dev->sem); +mutex_unlock(&dev->mtx); exit: return retval; @@ -682,7 +684,7 @@ static ssize_t usb_tranzport_write(struct file *file, goto exit; /* lock this object */ - if (down_interruptible(&dev->sem)) { + if (mutex_lock_interruptible(&dev->mtx)) { retval = -ERESTARTSYS; goto exit; } @@ -724,7 +726,7 @@ static ssize_t usb_tranzport_write(struct file *file, } if (dev->interrupt_out_endpoint == NULL) { - err("Endpoint should not be be null! \n"); + err("Endpoint should not be be null!\n"); goto unlock_exit; } @@ -751,7 +753,7 @@ static ssize_t usb_tranzport_write(struct file *file, unlock_exit: /* unlock the device */ - up(&dev->sem); + mutex_unlock(&dev->mtx); exit: return retval; @@ -800,7 +802,7 @@ static int usb_tranzport_probe(struct usb_interface *intf, dev_err(&intf->dev, "Out of memory\n"); goto exit; } - init_MUTEX(&dev->sem); + mutex_init(&dev->mtx); dev->intf = intf; init_waitqueue_head(&dev->read_wait); init_waitqueue_head(&dev->write_wait); @@ -940,18 +942,18 @@ static void usb_tranzport_disconnect(struct usb_interface *intf) mutex_lock(&disconnect_mutex); dev = usb_get_intfdata(intf); usb_set_intfdata(intf, NULL); - down(&dev->sem); + mutex_lock(&dev->mtx); minor = intf->minor; /* give back our minor */ usb_deregister_dev(intf, &usb_tranzport_class); /* if the device is not opened, then we clean up right now */ if (!dev->open_count) { - up(&dev->sem); + mutex_unlock(&dev->mtx); usb_tranzport_delete(dev); } else { dev->intf = NULL; - up(&dev->sem); + mutex_unlock(&dev->mtx); } mutex_unlock(&disconnect_mutex); diff --git a/drivers/staging/go7007/wis-saa7113.c b/drivers/staging/go7007/wis-saa7113.c index 5c12b4d38459..bd925457f8b7 100644 --- a/drivers/staging/go7007/wis-saa7113.c +++ b/drivers/staging/go7007/wis-saa7113.c @@ -289,6 +289,7 @@ static int wis_saa7113_probe(struct i2c_client *client, if (write_regs(client, initial_registers) < 0) { printk(KERN_ERR "wis-saa7113: error initializing SAA7113\n"); + i2c_set_clientdata(client, NULL); kfree(dec); return -ENODEV; } diff --git a/drivers/staging/go7007/wis-saa7115.c b/drivers/staging/go7007/wis-saa7115.c index 73f2283a8803..b2eb804c1954 100644 --- a/drivers/staging/go7007/wis-saa7115.c +++ b/drivers/staging/go7007/wis-saa7115.c @@ -422,6 +422,7 @@ static int wis_saa7115_probe(struct i2c_client *client, if (write_regs(client, initial_registers) < 0) { printk(KERN_ERR "wis-saa7115: error initializing SAA7115\n"); + i2c_set_clientdata(client, NULL); kfree(dec); return -ENODEV; } diff --git a/drivers/staging/go7007/wis-tw9903.c b/drivers/staging/go7007/wis-tw9903.c index 3ac6f785c4ad..2afea09091b9 100644 --- a/drivers/staging/go7007/wis-tw9903.c +++ b/drivers/staging/go7007/wis-tw9903.c @@ -294,6 +294,7 @@ static int wis_tw9903_probe(struct i2c_client *client, if (write_regs(client, initial_registers) < 0) { printk(KERN_ERR "wis-tw9903: error initializing TW9903\n"); + i2c_set_clientdata(client, NULL); kfree(dec); return -ENODEV; } diff --git a/drivers/staging/hv/Channel.c b/drivers/staging/hv/Channel.c index e69e9ee704ac..328d3a0d0bd8 100644 --- a/drivers/staging/hv/Channel.c +++ b/drivers/staging/hv/Channel.c @@ -65,8 +65,9 @@ static void DumpMonitorPage(struct hv_monitor_page *MonitorPage) } #endif -/** - * VmbusChannelSetEvent - Trigger an event notification on the specified channel. +/* + * VmbusChannelSetEvent - Trigger an event notification on the specified + * channel. */ static void VmbusChannelSetEvent(struct vmbus_channel *Channel) { @@ -120,7 +121,7 @@ static void VmbusChannelClearEvent(struct vmbus_channel *channel) } #endif -/** +/* * VmbusChannelGetDebugInfo -Retrieve various channel debug info */ void VmbusChannelGetDebugInfo(struct vmbus_channel *Channel, @@ -165,7 +166,7 @@ void VmbusChannelGetDebugInfo(struct vmbus_channel *Channel, RingBufferGetDebugInfo(&Channel->Outbound, &DebugInfo->Outbound); } -/** +/* * VmbusChannelOpen - Open the specified channel. */ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize, @@ -283,8 +284,9 @@ Cleanup: return 0; } -/** - * DumpGpadlBody - Dump the gpadl body message to the console for debugging purposes. +/* + * DumpGpadlBody - Dump the gpadl body message to the console for + * debugging purposes. */ static void DumpGpadlBody(struct vmbus_channel_gpadl_body *Gpadl, u32 Len) { @@ -300,8 +302,9 @@ static void DumpGpadlBody(struct vmbus_channel_gpadl_body *Gpadl, u32 Len) i, Gpadl->Pfn[i]); } -/** - * DumpGpadlHeader - Dump the gpadl header message to the console for debugging purposes. +/* + * DumpGpadlHeader - Dump the gpadl header message to the console for + * debugging purposes. */ static void DumpGpadlHeader(struct vmbus_channel_gpadl_header *Gpadl) { @@ -325,7 +328,7 @@ static void DumpGpadlHeader(struct vmbus_channel_gpadl_header *Gpadl) } } -/** +/* * VmbusChannelCreateGpadlHeader - Creates a gpadl for the specified buffer */ static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size, @@ -441,7 +444,7 @@ static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size, return 0; } -/** +/* * VmbusChannelEstablishGpadl - Estabish a GPADL for the specified buffer * * @Channel: a channel @@ -545,7 +548,7 @@ Cleanup: return ret; } -/** +/* * VmbusChannelTeardownGpadl -Teardown the specified GPADL handle */ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle) @@ -598,7 +601,7 @@ int VmbusChannelTeardownGpadl(struct vmbus_channel *Channel, u32 GpadlHandle) return ret; } -/** +/* * VmbusChannelClose - Close the specified channel */ void VmbusChannelClose(struct vmbus_channel *Channel) @@ -663,7 +666,7 @@ void VmbusChannelClose(struct vmbus_channel *Channel) DPRINT_EXIT(VMBUS); } -/** +/* * VmbusChannelSendPacket - Send the specified buffer on the given channel */ int VmbusChannelSendPacket(struct vmbus_channel *Channel, const void *Buffer, @@ -709,8 +712,9 @@ int VmbusChannelSendPacket(struct vmbus_channel *Channel, const void *Buffer, return ret; } -/** - * VmbusChannelSendPacketPageBuffer - Send a range of single-page buffer packets using a GPADL Direct packet type. +/* + * VmbusChannelSendPacketPageBuffer - Send a range of single-page buffer + * packets using a GPADL Direct packet type. */ int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *Channel, struct hv_page_buffer PageBuffers[], @@ -774,8 +778,9 @@ int VmbusChannelSendPacketPageBuffer(struct vmbus_channel *Channel, return ret; } -/** - * VmbusChannelSendPacketMultiPageBuffer - Send a multi-page buffer packet using a GPADL Direct packet type. +/* + * VmbusChannelSendPacketMultiPageBuffer - Send a multi-page buffer packet + * using a GPADL Direct packet type. */ int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *Channel, struct hv_multipage_buffer *MultiPageBuffer, @@ -843,7 +848,7 @@ int VmbusChannelSendPacketMultiPageBuffer(struct vmbus_channel *Channel, return ret; } -/** +/* * VmbusChannelRecvPacket - Retrieve the user packet on the specified channel */ /* TODO: Do we ever receive a gpa direct packet other than the ones we send ? */ @@ -909,7 +914,7 @@ int VmbusChannelRecvPacket(struct vmbus_channel *Channel, void *Buffer, return 0; } -/** +/* * VmbusChannelRecvPacketRaw - Retrieve the raw packet on the specified channel */ int VmbusChannelRecvPacketRaw(struct vmbus_channel *Channel, void *Buffer, @@ -972,7 +977,7 @@ int VmbusChannelRecvPacketRaw(struct vmbus_channel *Channel, void *Buffer, return 0; } -/** +/* * VmbusChannelOnChannelEvent - Channel event callback */ void VmbusChannelOnChannelEvent(struct vmbus_channel *Channel) @@ -985,7 +990,7 @@ void VmbusChannelOnChannelEvent(struct vmbus_channel *Channel) mod_timer(&Channel->poll_timer, jiffies + usecs_to_jiffies(100)); } -/** +/* * VmbusChannelOnTimer - Timer event callback */ void VmbusChannelOnTimer(unsigned long data) @@ -996,7 +1001,7 @@ void VmbusChannelOnTimer(unsigned long data) channel->OnChannelCallback(channel->ChannelCallbackContext); } -/** +/* * DumpVmbusChannel - Dump vmbus channel info to the console */ static void DumpVmbusChannel(struct vmbus_channel *Channel) diff --git a/drivers/staging/hv/ChannelMgmt.c b/drivers/staging/hv/ChannelMgmt.c index 5f92c2102ab4..43f28f23c317 100644 --- a/drivers/staging/hv/ChannelMgmt.c +++ b/drivers/staging/hv/ChannelMgmt.c @@ -71,7 +71,7 @@ static const struct hv_guid }, }; -/** +/* * AllocVmbusChannel - Allocate and initialize a vmbus channel object */ struct vmbus_channel *AllocVmbusChannel(void) @@ -97,7 +97,7 @@ struct vmbus_channel *AllocVmbusChannel(void) return channel; } -/** +/* * ReleaseVmbusChannel - Release the vmbus channel object itself */ static inline void ReleaseVmbusChannel(void *context) @@ -115,7 +115,7 @@ static inline void ReleaseVmbusChannel(void *context) DPRINT_EXIT(VMBUS); } -/** +/* * FreeVmbusChannel - Release the resources used by the vmbus channel object */ void FreeVmbusChannel(struct vmbus_channel *Channel) @@ -131,7 +131,7 @@ void FreeVmbusChannel(struct vmbus_channel *Channel) Channel); } -/** +/* * VmbusChannelProcessOffer - Process the offer by creating a channel/device associated with this offer */ static void VmbusChannelProcessOffer(void *context) @@ -213,7 +213,7 @@ static void VmbusChannelProcessOffer(void *context) DPRINT_EXIT(VMBUS); } -/** +/* * VmbusChannelProcessRescindOffer - Rescind the offer by initiating a device removal */ static void VmbusChannelProcessRescindOffer(void *context) @@ -225,7 +225,7 @@ static void VmbusChannelProcessRescindOffer(void *context) DPRINT_EXIT(VMBUS); } -/** +/* * VmbusChannelOnOffer - Handler for channel offers from vmbus in parent partition. * * We ignore all offers except network and storage offers. For each network and @@ -308,7 +308,7 @@ static void VmbusChannelOnOffer(struct vmbus_channel_message_header *hdr) DPRINT_EXIT(VMBUS); } -/** +/* * VmbusChannelOnOfferRescind - Rescind offer handler. * * We queue a work item to process this offer synchronously @@ -335,7 +335,7 @@ static void VmbusChannelOnOfferRescind(struct vmbus_channel_message_header *hdr) DPRINT_EXIT(VMBUS); } -/** +/* * VmbusChannelOnOffersDelivered - This is invoked when all offers have been delivered. * * Nothing to do here. @@ -347,7 +347,7 @@ static void VmbusChannelOnOffersDelivered( DPRINT_EXIT(VMBUS); } -/** +/* * VmbusChannelOnOpenResult - Open result handler. * * This is invoked when we received a response to our channel open request. @@ -395,7 +395,7 @@ static void VmbusChannelOnOpenResult(struct vmbus_channel_message_header *hdr) DPRINT_EXIT(VMBUS); } -/** +/* * VmbusChannelOnGpadlCreated - GPADL created handler. * * This is invoked when we received a response to our gpadl create request. @@ -447,7 +447,7 @@ static void VmbusChannelOnGpadlCreated(struct vmbus_channel_message_header *hdr) DPRINT_EXIT(VMBUS); } -/** +/* * VmbusChannelOnGpadlTorndown - GPADL torndown handler. * * This is invoked when we received a response to our gpadl teardown request. @@ -495,7 +495,7 @@ static void VmbusChannelOnGpadlTorndown( DPRINT_EXIT(VMBUS); } -/** +/* * VmbusChannelOnVersionResponse - Version response handler * * This is invoked when we received a response to our initiate contact request. @@ -558,7 +558,7 @@ static struct vmbus_channel_message_table_entry {ChannelMessageUnload, NULL}, }; -/** +/* * VmbusOnChannelMessage - Handler for channel protocol messages. * * This is invoked in the vmbus worker thread context. @@ -597,7 +597,7 @@ void VmbusOnChannelMessage(void *Context) DPRINT_EXIT(VMBUS); } -/** +/* * VmbusChannelRequestOffers - Send a request to get all our pending offers. */ int VmbusChannelRequestOffers(void) @@ -651,8 +651,9 @@ Cleanup: return ret; } -/** - * VmbusChannelReleaseUnattachedChannels - Release channels that are unattached/unconnected ie (no drivers associated) +/* + * VmbusChannelReleaseUnattachedChannels - Release channels that are + * unattached/unconnected ie (no drivers associated) */ void VmbusChannelReleaseUnattachedChannels(void) { diff --git a/drivers/staging/hv/Connection.c b/drivers/staging/hv/Connection.c index e0ea9cf90f03..dbf00560e0ac 100644 --- a/drivers/staging/hv/Connection.c +++ b/drivers/staging/hv/Connection.c @@ -34,7 +34,7 @@ struct VMBUS_CONNECTION gVmbusConnection = { .NextGpadlHandle = ATOMIC_INIT(0xE1E10), }; -/** +/* * VmbusConnect - Sends a connect request on the partition service connection */ int VmbusConnect(void) @@ -180,7 +180,7 @@ Cleanup: return ret; } -/** +/* * VmbusDisconnect - Sends a disconnect request on the partition service connection */ int VmbusDisconnect(void) @@ -218,7 +218,7 @@ Cleanup: return ret; } -/** +/* * GetChannelFromRelId - Get the channel object given its child relative id (ie channel id) */ struct vmbus_channel *GetChannelFromRelId(u32 relId) @@ -239,7 +239,7 @@ struct vmbus_channel *GetChannelFromRelId(u32 relId) return foundChannel; } -/** +/* * VmbusProcessChannelEvent - Process a channel event notification */ static void VmbusProcessChannelEvent(void *context) @@ -259,15 +259,15 @@ static void VmbusProcessChannelEvent(void *context) VmbusChannelOnChannelEvent(channel); /* * WorkQueueQueueWorkItem(channel->dataWorkQueue, - * VmbusChannelOnChannelEvent, - * (void*)channel); + * VmbusChannelOnChannelEvent, + * (void*)channel); */ } else { DPRINT_ERR(VMBUS, "channel not found for relid - %d.", relId); } } -/** +/* * VmbusOnEvents - Handler for events */ void VmbusOnEvents(void) @@ -308,7 +308,7 @@ void VmbusOnEvents(void) return; } -/** +/* * VmbusPostMessage - Send a msg on the vmbus's message connection */ int VmbusPostMessage(void *buffer, size_t bufferLen) @@ -320,7 +320,7 @@ int VmbusPostMessage(void *buffer, size_t bufferLen) return HvPostMessage(connId, 1, buffer, bufferLen); } -/** +/* * VmbusSetEvent - Send an event notification to the parent */ int VmbusSetEvent(u32 childRelId) diff --git a/drivers/staging/hv/Hv.c b/drivers/staging/hv/Hv.c index 3a1112d29aeb..62debf867aa4 100644 --- a/drivers/staging/hv/Hv.c +++ b/drivers/staging/hv/Hv.c @@ -35,7 +35,7 @@ struct hv_context gHvContext = { .SignalEventBuffer = NULL, }; -/** +/* * HvQueryHypervisorPresence - Query the cpuid for presense of windows hypervisor */ static int HvQueryHypervisorPresence(void) @@ -56,7 +56,7 @@ static int HvQueryHypervisorPresence(void) return ecx & HV_PRESENT_BIT; } -/** +/* * HvQueryHypervisorInfo - Get version info of the windows hypervisor */ static int HvQueryHypervisorInfo(void) @@ -125,7 +125,7 @@ static int HvQueryHypervisorInfo(void) return maxLeaf; } -/** +/* * HvDoHypercall - Invoke the specified hypercall */ static u64 HvDoHypercall(u64 Control, void *Input, void *Output) @@ -180,7 +180,7 @@ static u64 HvDoHypercall(u64 Control, void *Input, void *Output) #endif /* !x86_64 */ } -/** +/* * HvInit - Main initialization routine. * * This routine must be called before any other routines in here are called @@ -294,7 +294,7 @@ Cleanup: return ret; } -/** +/* * HvCleanup - Cleanup routine. * * This routine is called normally during driver unloading or exiting. @@ -321,7 +321,7 @@ void HvCleanup(void) DPRINT_EXIT(VMBUS); } -/** +/* * HvPostMessage - Post a message using the hypervisor message IPC. * * This involves a hypercall. @@ -362,7 +362,7 @@ u16 HvPostMessage(union hv_connection_id connectionId, } -/** +/* * HvSignalEvent - Signal an event on the specified connection using the hypervisor event IPC. * * This involves a hypercall. @@ -376,7 +376,7 @@ u16 HvSignalEvent(void) return status; } -/** +/* * HvSynicInit - Initialize the Synthethic Interrupt Controller. * * If it is already initialized by another entity (ie x2v shim), we need to @@ -482,7 +482,7 @@ Cleanup: return; } -/** +/* * HvSynicCleanup - Cleanup routine for HvSynicInit(). */ void HvSynicCleanup(void *arg) diff --git a/drivers/staging/hv/NetVsc.c b/drivers/staging/hv/NetVsc.c index e4bf82297504..27516d40b6ed 100644 --- a/drivers/staging/hv/NetVsc.c +++ b/drivers/staging/hv/NetVsc.c @@ -167,7 +167,7 @@ static struct netvsc_device *ReleaseInboundNetDevice(struct hv_device *Device) return netDevice; } -/** +/* * NetVscInitialize - Main entry point */ int NetVscInitialize(struct hv_driver *drv) @@ -705,7 +705,7 @@ static void NetVscDisconnectFromVsp(struct netvsc_device *NetDevice) DPRINT_EXIT(NETVSC); } -/** +/* * NetVscOnDeviceAdd - Callback when the device belonging to this driver is added */ static int NetVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo) @@ -807,7 +807,7 @@ Cleanup: return ret; } -/** +/* * NetVscOnDeviceRemove - Callback when the root bus device is removed */ static int NetVscOnDeviceRemove(struct hv_device *Device) @@ -864,7 +864,7 @@ static int NetVscOnDeviceRemove(struct hv_device *Device) return 0; } -/** +/* * NetVscOnCleanup - Perform any cleanup when the driver is removed */ static void NetVscOnCleanup(struct hv_driver *drv) @@ -1087,7 +1087,7 @@ static void NetVscOnReceive(struct hv_device *Device, } /* Remove the 1st packet to represent the xfer page packet itself */ - xferpagePacket = (struct xferpage_packet*)listHead.next; + xferpagePacket = (struct xferpage_packet *)listHead.next; list_del(&xferpagePacket->ListEntry); /* This is how much we can satisfy */ @@ -1103,7 +1103,7 @@ static void NetVscOnReceive(struct hv_device *Device, /* Each range represents 1 RNDIS pkt that contains 1 ethernet frame */ for (i = 0; i < (count - 1); i++) { - netvscPacket = (struct hv_netvsc_packet*)listHead.next; + netvscPacket = (struct hv_netvsc_packet *)listHead.next; list_del(&netvscPacket->ListEntry); /* Initialize the netvsc packet */ @@ -1286,30 +1286,35 @@ static void NetVscOnReceiveCompletion(void *Context) DPRINT_EXIT(NETVSC); } -void NetVscOnChannelCallback(void *Context) +static void NetVscOnChannelCallback(void *Context) { - const int netPacketSize = 2048; int ret; struct hv_device *device = Context; struct netvsc_device *netDevice; u32 bytesRecvd; u64 requestId; - unsigned char packet[netPacketSize]; + unsigned char *packet; struct vmpacket_descriptor *desc; - unsigned char *buffer = packet; - int bufferlen = netPacketSize; + unsigned char *buffer; + int bufferlen = NETVSC_PACKET_SIZE; DPRINT_ENTER(NETVSC); ASSERT(device); + packet = kzalloc(NETVSC_PACKET_SIZE * sizeof(unsigned char), + GFP_KERNEL); + if (!packet) + return; + buffer = packet; + netDevice = GetInboundNetDevice(device); if (!netDevice) { DPRINT_ERR(NETVSC, "net device (%p) shutting down..." "ignoring inbound packets", netDevice); DPRINT_EXIT(NETVSC); - return; + goto out; } do { @@ -1341,17 +1346,17 @@ void NetVscOnChannelCallback(void *Context) } /* reset */ - if (bufferlen > netPacketSize) { + if (bufferlen > NETVSC_PACKET_SIZE) { kfree(buffer); buffer = packet; - bufferlen = netPacketSize; + bufferlen = NETVSC_PACKET_SIZE; } } else { /* reset */ - if (bufferlen > netPacketSize) { + if (bufferlen > NETVSC_PACKET_SIZE) { kfree(buffer); buffer = packet; - bufferlen = netPacketSize; + bufferlen = NETVSC_PACKET_SIZE; } break; @@ -1375,5 +1380,7 @@ void NetVscOnChannelCallback(void *Context) PutNetDevice(device); DPRINT_EXIT(NETVSC); +out: + kfree(buffer); return; } diff --git a/drivers/staging/hv/NetVsc.h b/drivers/staging/hv/NetVsc.h index 6e0e03494126..a6264db8388a 100644 --- a/drivers/staging/hv/NetVsc.h +++ b/drivers/staging/hv/NetVsc.h @@ -289,6 +289,7 @@ struct nvsp_message { /* Preallocated receive packets */ #define NETVSC_RECEIVE_PACKETLIST_COUNT 256 +#define NETVSC_PACKET_SIZE 2048 /* Per netvsc channel-specific */ struct netvsc_device { diff --git a/drivers/staging/hv/RingBuffer.c b/drivers/staging/hv/RingBuffer.c index 80b8a2c7784f..08b3c5567e9c 100644 --- a/drivers/staging/hv/RingBuffer.c +++ b/drivers/staging/hv/RingBuffer.c @@ -32,7 +32,7 @@ /* Amount of space to write to */ -#define BYTES_AVAIL_TO_WRITE(r, w, z) ((w) >= (r))?((z) - ((w) - (r))):((r) - (w)) +#define BYTES_AVAIL_TO_WRITE(r, w, z) ((w) >= (r)) ? ((z) - ((w) - (r))) : ((r) - (w)) /*++ diff --git a/drivers/staging/hv/StorVsc.c b/drivers/staging/hv/StorVsc.c index e426a23ca537..7372317fe836 100644 --- a/drivers/staging/hv/StorVsc.c +++ b/drivers/staging/hv/StorVsc.c @@ -533,7 +533,7 @@ static int StorVscConnectToVsp(struct hv_device *Device) return ret; } -/** +/* * StorVscOnDeviceAdd - Callback when the device belonging to this driver is added */ static int StorVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo) @@ -554,7 +554,7 @@ static int StorVscOnDeviceAdd(struct hv_device *Device, void *AdditionalInfo) /* Save the channel properties to our storvsc channel */ /* props = (struct vmstorage_channel_properties *) - * channel->offerMsg.Offer.u.Standard.UserDefined; */ + * channel->offerMsg.Offer.u.Standard.UserDefined; */ /* FIXME: */ /* @@ -585,7 +585,7 @@ Cleanup: return ret; } -/** +/* * StorVscOnDeviceRemove - Callback when the our device is being removed */ static int StorVscOnDeviceRemove(struct hv_device *Device) @@ -683,7 +683,7 @@ Cleanup: return ret; } -/** +/* * StorVscOnIORequest - Callback to initiate an I/O request */ static int StorVscOnIORequest(struct hv_device *Device, @@ -717,7 +717,7 @@ static int StorVscOnIORequest(struct hv_device *Device, } /* print_hex_dump_bytes("", DUMP_PREFIX_NONE, Request->Cdb, - * Request->CdbLen); */ + * Request->CdbLen); */ requestExtension->Request = Request; requestExtension->Device = Device; @@ -783,7 +783,7 @@ static int StorVscOnIORequest(struct hv_device *Device, return ret; } -/** +/* * StorVscOnCleanup - Perform any cleanup when the driver is removed */ static void StorVscOnCleanup(struct hv_driver *Driver) @@ -792,7 +792,7 @@ static void StorVscOnCleanup(struct hv_driver *Driver) DPRINT_EXIT(STORVSC); } -/** +/* * StorVscInitialize - Main entry point */ int StorVscInitialize(struct hv_driver *Driver) diff --git a/drivers/staging/hv/TODO b/drivers/staging/hv/TODO index dbfbde937a66..66a89c809dd3 100644 --- a/drivers/staging/hv/TODO +++ b/drivers/staging/hv/TODO @@ -1,7 +1,5 @@ TODO: - fix remaining checkpatch warnings and errors - - use of /** when it is not a kerneldoc header - - remove RingBuffer.c to us in-kernel ringbuffer functions instead. - audit the vmbus to verify it is working properly with the driver model - convert vmbus driver interface function pointer tables @@ -9,7 +7,6 @@ TODO: - see if the vmbus can be merged with the other virtual busses in the kernel - audit the network driver - - use existing net_device_stats struct in network device - checking for carrier inside open is wrong, network device API confusion?? - audit the block driver diff --git a/drivers/staging/hv/VersionInfo.h b/drivers/staging/hv/VersionInfo.h index 10d7b19a485f..82e74b1ab150 100644 --- a/drivers/staging/hv/VersionInfo.h +++ b/drivers/staging/hv/VersionInfo.h @@ -29,11 +29,11 @@ * * Definition of versioning is as follows; * - * Major Number Changes for these scenarios; + * Major Number Changes for these scenarios; * 1. When a new version of Windows Hyper-V * is released. * 2. A Major change has occurred in the - * Linux IC's. + * Linux IC's. * (For example the merge for the first time * into the kernel) Every time the Major Number * changes, the Revision number is reset to 0. diff --git a/drivers/staging/hv/Vmbus.c b/drivers/staging/hv/Vmbus.c index 2f84bf7c0a9f..90b14beec3aa 100644 --- a/drivers/staging/hv/Vmbus.c +++ b/drivers/staging/hv/Vmbus.c @@ -52,7 +52,7 @@ static const struct hv_guid gVmbusDeviceId = { static struct hv_driver *gDriver; /* vmbus driver object */ static struct hv_device *gDevice; /* vmbus root device */ -/** +/* * VmbusGetChannelOffers - Retrieve the channel offers from the parent partition */ static void VmbusGetChannelOffers(void) @@ -62,7 +62,7 @@ static void VmbusGetChannelOffers(void) DPRINT_EXIT(VMBUS); } -/** +/* * VmbusGetChannelInterface - Get the channel interface */ static void VmbusGetChannelInterface(struct vmbus_channel_interface *Interface) @@ -70,7 +70,7 @@ static void VmbusGetChannelInterface(struct vmbus_channel_interface *Interface) GetChannelInterface(Interface); } -/** +/* * VmbusGetChannelInfo - Get the device info for the specified device object */ static void VmbusGetChannelInfo(struct hv_device *DeviceObject, @@ -79,7 +79,7 @@ static void VmbusGetChannelInfo(struct hv_device *DeviceObject, GetChannelInfo(DeviceObject, DeviceInfo); } -/** +/* * VmbusCreateChildDevice - Creates the child device on the bus that represents the channel offer */ struct hv_device *VmbusChildDeviceCreate(struct hv_guid *DeviceType, @@ -92,7 +92,7 @@ struct hv_device *VmbusChildDeviceCreate(struct hv_guid *DeviceType, Context); } -/** +/* * VmbusChildDeviceAdd - Registers the child device with the vmbus */ int VmbusChildDeviceAdd(struct hv_device *ChildDevice) @@ -102,7 +102,7 @@ int VmbusChildDeviceAdd(struct hv_device *ChildDevice) return vmbusDriver->OnChildDeviceAdd(gDevice, ChildDevice); } -/** +/* * VmbusChildDeviceRemove Unregisters the child device from the vmbus */ void VmbusChildDeviceRemove(struct hv_device *ChildDevice) @@ -112,7 +112,7 @@ void VmbusChildDeviceRemove(struct hv_device *ChildDevice) vmbusDriver->OnChildDeviceRemove(ChildDevice); } -/** +/* * VmbusOnDeviceAdd - Callback when the root bus device is added */ static int VmbusOnDeviceAdd(struct hv_device *dev, void *AdditionalInfo) @@ -141,7 +141,7 @@ static int VmbusOnDeviceAdd(struct hv_device *dev, void *AdditionalInfo) return ret; } -/** +/* * VmbusOnDeviceRemove - Callback when the root bus device is removed */ static int VmbusOnDeviceRemove(struct hv_device *dev) @@ -157,7 +157,7 @@ static int VmbusOnDeviceRemove(struct hv_device *dev) return ret; } -/** +/* * VmbusOnCleanup - Perform any cleanup when the driver is removed */ static void VmbusOnCleanup(struct hv_driver *drv) @@ -169,7 +169,7 @@ static void VmbusOnCleanup(struct hv_driver *drv) DPRINT_EXIT(VMBUS); } -/** +/* * VmbusOnMsgDPC - DPC routine to handle messages from the hypervisior */ static void VmbusOnMsgDPC(struct hv_driver *drv) @@ -217,7 +217,7 @@ static void VmbusOnMsgDPC(struct hv_driver *drv) } } -/** +/* * VmbusOnEventDPC - DPC routine to handle events from the hypervisior */ static void VmbusOnEventDPC(struct hv_driver *drv) @@ -226,7 +226,7 @@ static void VmbusOnEventDPC(struct hv_driver *drv) VmbusOnEvents(); } -/** +/* * VmbusOnISR - ISR routine */ static int VmbusOnISR(struct hv_driver *drv) @@ -264,7 +264,7 @@ static int VmbusOnISR(struct hv_driver *drv) return ret; } -/** +/* * VmbusInitialize - Main entry point */ int VmbusInitialize(struct hv_driver *drv) diff --git a/drivers/staging/hv/VmbusApi.h b/drivers/staging/hv/VmbusApi.h index d089bb193e7d..4275be3292ce 100644 --- a/drivers/staging/hv/VmbusApi.h +++ b/drivers/staging/hv/VmbusApi.h @@ -84,6 +84,24 @@ struct hv_device_info { struct hv_dev_port_info Outbound; }; +/** + * struct vmbus_channel_interface - Contains member functions for vmbus channel + * @Open: Open the channel + * @Close: Close the channel + * @SendPacket: Send a packet over the channel + * @SendPacketPageBuffer: Send a single page buffer over the channel + * @SendPacketMultiPageBuffer: Send a multiple page buffers + * @RecvPacket: Receive packet + * @RecvPacketRaw: Receive Raw packet + * @EstablishGpadl: Set up GPADL for ringbuffer + * @TeardownGpadl: Teardown GPADL for ringbuffer + * @GetInfo: Get info about the channel + * + * This structure contains function pointer to control vmbus channel + * behavior. None of these functions is externally callable, but they + * are used for normal vmbus channel internal behavior. + * Only used by Hyper-V drivers. + */ struct vmbus_channel_interface { int (*Open)(struct hv_device *Device, u32 SendBufferSize, u32 RecvRingBufferSize, void *UserData, u32 UserDataLen, diff --git a/drivers/staging/hv/blkvsc_drv.c b/drivers/staging/hv/blkvsc_drv.c index 8f1fda3256ad..8f8637e51d9e 100644 --- a/drivers/staging/hv/blkvsc_drv.c +++ b/drivers/staging/hv/blkvsc_drv.c @@ -165,7 +165,7 @@ static struct block_device_operations block_ops = { .ioctl = blkvsc_ioctl, }; -/** +/* * blkvsc_drv_init - BlkVsc driver initialization. */ static int blkvsc_drv_init(int (*drv_init)(struct hv_driver *drv)) @@ -245,7 +245,7 @@ static void blkvsc_drv_exit(void) return; } -/** +/* * blkvsc_probe - Add a new device for this driver */ static int blkvsc_probe(struct device *device) @@ -555,7 +555,7 @@ static int blkvsc_do_inquiry(struct block_device_context *blkdev) blkdev->device_type = UNKNOWN_DEV_TYPE; } - DPRINT_DBG(BLKVSC_DRV, "device type %d \n", device_type); + DPRINT_DBG(BLKVSC_DRV, "device type %d\n", device_type); blkdev->device_id_len = buf[7]; if (blkdev->device_id_len > 64) @@ -733,7 +733,7 @@ static int blkvsc_do_read_capacity16(struct block_device_context *blkdev) return 0; } -/** +/* * blkvsc_remove() - Callback when our device is removed */ static int blkvsc_remove(struct device *device) @@ -940,7 +940,7 @@ static int blkvsc_do_request(struct block_device_context *blkdev, int pending = 0; struct blkvsc_request_group *group = NULL; - DPRINT_DBG(BLKVSC_DRV, "blkdev %p req %p sect %lu \n", blkdev, req, + DPRINT_DBG(BLKVSC_DRV, "blkdev %p req %p sect %lu\n", blkdev, req, (unsigned long)blk_rq_pos(req)); /* Create a group to tie req to list of blkvsc_reqs */ @@ -1144,7 +1144,7 @@ static void blkvsc_request_completion(struct hv_storvsc_request *request) &blkvsc_req->group->blkvsc_req_list, req_entry) { DPRINT_DBG(BLKVSC_DRV, "completing blkvsc_req %p " - "sect_start %lu sect_count %ld \n", + "sect_start %lu sect_count %ld\n", comp_req, (unsigned long)comp_req->sector_start, comp_req->sector_count); @@ -1198,7 +1198,7 @@ static int blkvsc_cancel_pending_reqs(struct block_device_context *blkdev) &pend_req->group->blkvsc_req_list, req_entry) { DPRINT_DBG(BLKVSC_DRV, "completing blkvsc_req %p " - "sect_start %lu sect_count %ld \n", + "sect_start %lu sect_count %ld\n", comp_req, (unsigned long) comp_req->sector_start, comp_req->sector_count); @@ -1276,7 +1276,7 @@ static void blkvsc_request(struct request_queue *queue) struct request *req; int ret = 0; - DPRINT_DBG(BLKVSC_DRV, "- enter \n"); + DPRINT_DBG(BLKVSC_DRV, "- enter\n"); while ((req = blk_peek_request(queue)) != NULL) { DPRINT_DBG(BLKVSC_DRV, "- req %p\n", req); diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c index ab27d9a4446d..bb3edeae93bb 100644 --- a/drivers/staging/hv/netvsc_drv.c +++ b/drivers/staging/hv/netvsc_drv.c @@ -43,7 +43,6 @@ struct net_device_context { /* point back to our device context */ struct vm_device *device_ctx; - struct net_device_stats stats; }; struct netvsc_driver_context { @@ -58,13 +57,6 @@ static int netvsc_ringbuffer_size = NETVSC_DEVICE_RING_BUFFER_SIZE; /* The one and only one */ static struct netvsc_driver_context g_netvsc_drv; -static struct net_device_stats *netvsc_get_stats(struct net_device *net) -{ - struct net_device_context *net_device_ctx = netdev_priv(net); - - return &net_device_ctx->stats; -} - static void netvsc_set_multicast_list(struct net_device *net) { } @@ -78,9 +70,6 @@ static int netvsc_open(struct net_device *net) DPRINT_ENTER(NETVSC_DRV); if (netif_carrier_ok(net)) { - memset(&net_device_ctx->stats, 0, - sizeof(struct net_device_stats)); - /* Open up the device */ ret = RndisFilterOnOpen(device_obj); if (ret != 0) { @@ -224,8 +213,8 @@ retry_send: if (ret == 0) { ret = NETDEV_TX_OK; - net_device_ctx->stats.tx_bytes += skb->len; - net_device_ctx->stats.tx_packets++; + net->stats.tx_bytes += skb->len; + net->stats.tx_packets++; } else { retries++; if (retries < 4) { @@ -241,7 +230,7 @@ retry_send: DPRINT_INFO(NETVSC_DRV, "net device (%p) stopping", net); ret = NETDEV_TX_BUSY; - net_device_ctx->stats.tx_dropped++; + net->stats.tx_dropped++; netif_stop_queue(net); @@ -259,14 +248,14 @@ retry_send: } DPRINT_DBG(NETVSC_DRV, "# of xmits %lu total size %lu", - net_device_ctx->stats.tx_packets, - net_device_ctx->stats.tx_bytes); + net->stats.tx_packets, + net->stats.tx_bytes); DPRINT_EXIT(NETVSC_DRV); return ret; } -/** +/* * netvsc_linkstatus_callback - Link up/down notification */ static void netvsc_linkstatus_callback(struct hv_device *device_obj, @@ -293,8 +282,9 @@ static void netvsc_linkstatus_callback(struct hv_device *device_obj, DPRINT_EXIT(NETVSC_DRV); } -/** - * netvsc_recv_callback - Callback when we receive a packet from the "wire" on the specified device. +/* + * netvsc_recv_callback - Callback when we receive a packet from the + * "wire" on the specified device. */ static int netvsc_recv_callback(struct hv_device *device_obj, struct hv_netvsc_packet *packet) @@ -304,7 +294,6 @@ static int netvsc_recv_callback(struct hv_device *device_obj, struct net_device_context *net_device_ctx; struct sk_buff *skb; void *data; - int ret; int i; unsigned long flags; @@ -318,12 +307,12 @@ static int netvsc_recv_callback(struct hv_device *device_obj, net_device_ctx = netdev_priv(net); - /* Allocate a skb - TODO preallocate this */ - /* Pad 2-bytes to align IP header to 16 bytes */ - skb = dev_alloc_skb(packet->TotalDataBufferLength + 2); - ASSERT(skb); - skb_reserve(skb, 2); - skb->dev = net; + /* Allocate a skb - TODO direct I/O to pages? */ + skb = netdev_alloc_skb_ip_align(net, packet->TotalDataBufferLength); + if (unlikely(!skb)) { + ++net->stats.rx_dropped; + return 0; + } /* for kmap_atomic */ local_irq_save(flags); @@ -348,28 +337,20 @@ static int netvsc_recv_callback(struct hv_device *device_obj, local_irq_restore(flags); skb->protocol = eth_type_trans(skb, net); - skb->ip_summed = CHECKSUM_NONE; + net->stats.rx_packets++; + net->stats.rx_bytes += skb->len; + /* * Pass the skb back up. Network stack will deallocate the skb when it - * is done + * is done. + * TODO - use NAPI? */ - ret = netif_rx(skb); - - switch (ret) { - case NET_RX_DROP: - net_device_ctx->stats.rx_dropped++; - break; - default: - net_device_ctx->stats.rx_packets++; - net_device_ctx->stats.rx_bytes += skb->len; - break; + netif_rx(skb); - } DPRINT_DBG(NETVSC_DRV, "# of recvs %lu total size %lu", - net_device_ctx->stats.rx_packets, - net_device_ctx->stats.rx_bytes); + net->stats.rx_packets, net->stats.rx_bytes); DPRINT_EXIT(NETVSC_DRV); @@ -380,7 +361,6 @@ static const struct net_device_ops device_ops = { .ndo_open = netvsc_open, .ndo_stop = netvsc_close, .ndo_start_xmit = netvsc_start_xmit, - .ndo_get_stats = netvsc_get_stats, .ndo_set_multicast_list = netvsc_set_multicast_list, }; diff --git a/drivers/staging/hv/osd.c b/drivers/staging/hv/osd.c index 9aea31067295..8c3eb278a81f 100644 --- a/drivers/staging/hv/osd.c +++ b/drivers/staging/hv/osd.c @@ -59,6 +59,15 @@ void *osd_VirtualAllocExec(unsigned int size) #endif } +/** + * osd_PageAlloc() - Allocate pages + * @count: Total number of Kernel pages you want to allocate + * + * Tries to allocate @count number of consecutive free kernel pages. + * And if successful, it will set the pages to 0 before returning. + * If successfull it will return pointer to the @count pages. + * Mainly used by Hyper-V drivers. + */ void *osd_PageAlloc(unsigned int count) { void *p; @@ -78,6 +87,14 @@ void *osd_PageAlloc(unsigned int count) } EXPORT_SYMBOL_GPL(osd_PageAlloc); +/** + * osd_PageFree() - Free pages + * @page: Pointer to the first page to be freed + * @count: Total number of Kernel pages you free + * + * Frees the pages allocated by osd_PageAlloc() + * Mainly used by Hyper-V drivers. + */ void osd_PageFree(void *page, unsigned int count) { free_pages((unsigned long)page, get_order(count * PAGE_SIZE)); @@ -86,6 +103,17 @@ void osd_PageFree(void *page, unsigned int count) } EXPORT_SYMBOL_GPL(osd_PageFree); +/** + * osd_WaitEventCreate() - Create the event queue + * + * Allocates memory for a &struct osd_waitevent. And then calls + * init_waitqueue_head to set up the wait queue for the event. + * This structure is usually part of a another structure that contains + * the actual Hyper-V device driver structure. + * + * Returns pointer to &struct osd_waitevent + * Mainly used by Hyper-V drivers. + */ struct osd_waitevent *osd_WaitEventCreate(void) { struct osd_waitevent *wait = kmalloc(sizeof(struct osd_waitevent), @@ -99,6 +127,19 @@ struct osd_waitevent *osd_WaitEventCreate(void) } EXPORT_SYMBOL_GPL(osd_WaitEventCreate); + +/** + * osd_WaitEventSet() - Wake up the process + * @waitEvent: Structure to event to be woken up + * + * @waitevent is of type &struct osd_waitevent + * + * Wake up the sleeping process so it can do some work. + * And set condition indicator in &struct osd_waitevent to indicate + * the process is in a woken state. + * + * Only used by Network and Storage Hyper-V drivers. + */ void osd_WaitEventSet(struct osd_waitevent *waitEvent) { waitEvent->condition = 1; @@ -106,6 +147,20 @@ void osd_WaitEventSet(struct osd_waitevent *waitEvent) } EXPORT_SYMBOL_GPL(osd_WaitEventSet); +/** + * osd_WaitEventWait() - Wait for event till condition is true + * @waitEvent: Structure to event to be put to sleep + * + * @waitevent is of type &struct osd_waitevent + * + * Set up the process to sleep until waitEvent->condition get true. + * And set condition indicator in &struct osd_waitevent to indicate + * the process is in a sleeping state. + * + * Returns the status of 'wait_event_interruptible()' system call + * + * Mainly used by Hyper-V drivers. + */ int osd_WaitEventWait(struct osd_waitevent *waitEvent) { int ret = 0; @@ -117,6 +172,21 @@ int osd_WaitEventWait(struct osd_waitevent *waitEvent) } EXPORT_SYMBOL_GPL(osd_WaitEventWait); +/** + * osd_WaitEventWaitEx() - Wait for event or timeout for process wakeup + * @waitEvent: Structure to event to be put to sleep + * @TimeoutInMs: Total number of Milliseconds to wait before waking up + * + * @waitevent is of type &struct osd_waitevent + * Set up the process to sleep until @waitEvent->condition get true or + * @TimeoutInMs (Time out in Milliseconds) has been reached. + * And set condition indicator in &struct osd_waitevent to indicate + * the process is in a sleeping state. + * + * Returns the status of 'wait_event_interruptible_timeout()' system call + * + * Mainly used by Hyper-V drivers. + */ int osd_WaitEventWaitEx(struct osd_waitevent *waitEvent, u32 TimeoutInMs) { int ret = 0; diff --git a/drivers/staging/hv/rndis.h b/drivers/staging/hv/rndis.h index 7c73277c1f9a..723e1f15b90d 100644 --- a/drivers/staging/hv/rndis.h +++ b/drivers/staging/hv/rndis.h @@ -622,7 +622,7 @@ struct rndis_message { /* get the size of an RNDIS message. Pass in the message type, */ /* struct rndis_set_request, struct rndis_packet for example */ #define RNDIS_MESSAGE_SIZE(Message) \ - (sizeof(Message) + (sizeof(struct rndis_message) - \ + (sizeof(Message) + (sizeof(struct rndis_message) - \ sizeof(union rndis_message_container))) /* get pointer to info buffer with message pointer */ diff --git a/drivers/staging/hv/storvsc_drv.c b/drivers/staging/hv/storvsc_drv.c index 8a58272b8039..5e28e4c36434 100644 --- a/drivers/staging/hv/storvsc_drv.c +++ b/drivers/staging/hv/storvsc_drv.c @@ -112,7 +112,7 @@ static struct scsi_host_template scsi_driver = { .slave_configure = storvsc_device_configure, .cmd_per_lun = 1, /* 64 max_queue * 1 target */ - .can_queue = STORVSC_MAX_IO_REQUESTS*STORVSC_MAX_TARGETS, + .can_queue = STORVSC_MAX_IO_REQUESTS*STORVSC_MAX_TARGETS, .this_id = -1, /* no use setting to 0 since ll_blk_rw reset it to 1 */ /* currently 32 */ @@ -130,7 +130,7 @@ static struct scsi_host_template scsi_driver = { }; -/** +/* * storvsc_drv_init - StorVsc driver initialization. */ static int storvsc_drv_init(int (*drv_init)(struct hv_driver *drv)) @@ -223,7 +223,7 @@ static void storvsc_drv_exit(void) return; } -/** +/* * storvsc_probe - Add a new device for this driver */ static int storvsc_probe(struct device *device) @@ -319,7 +319,7 @@ static int storvsc_probe(struct device *device) return ret; } -/** +/* * storvsc_remove - Callback when our device is removed */ static int storvsc_remove(struct device *device) @@ -372,7 +372,7 @@ static int storvsc_remove(struct device *device) return ret; } -/** +/* * storvsc_commmand_completion - Command completion processing */ static void storvsc_commmand_completion(struct hv_storvsc_request *request) @@ -623,7 +623,7 @@ static unsigned int copy_from_bounce_buffer(struct scatterlist *orig_sgl, return total_copied; } -/** +/* * storvsc_queuecommand - Initiate command processing */ static int storvsc_queuecommand(struct scsi_cmnd *scmnd, @@ -767,7 +767,7 @@ static int storvsc_queuecommand(struct scsi_cmnd *scmnd, request->DataBuffer.Offset = sgl[0].offset; for (i = 0; i < scsi_sg_count(scmnd); i++) { - DPRINT_DBG(STORVSC_DRV, "sgl[%d] len %d offset %d \n", + DPRINT_DBG(STORVSC_DRV, "sgl[%d] len %d offset %d\n", i, sgl[i].length, sgl[i].offset); request->DataBuffer.PfnArray[i] = page_to_pfn(sg_page((&sgl[i]))); @@ -824,7 +824,7 @@ static int storvsc_merge_bvec(struct request_queue *q, return bvec->bv_len; } -/** +/* * storvsc_device_configure - Configure the specified scsi device */ static int storvsc_device_alloc(struct scsi_device *sdevice) @@ -863,7 +863,7 @@ static int storvsc_device_configure(struct scsi_device *sdevice) return 0; } -/** +/* * storvsc_host_reset_handler - Reset the scsi HBA */ static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd) diff --git a/drivers/staging/hv/vmbus_drv.c b/drivers/staging/hv/vmbus_drv.c index 3397ef08e0aa..d2a82aa3bbd8 100644 --- a/drivers/staging/hv/vmbus_drv.c +++ b/drivers/staging/hv/vmbus_drv.c @@ -129,7 +129,7 @@ static struct vmbus_driver_context g_vmbus_drv = { .bus.dev_attrs = vmbus_device_attrs, }; -/** +/* * vmbus_show_device_attr - Show the device attribute in sysfs. * * This is invoked when user does a @@ -233,17 +233,17 @@ static ssize_t vmbus_show_device_attr(struct device *dev, } } -/** +/* * vmbus_bus_init -Main vmbus driver initialization routine. * * Here, we - * - initialize the vmbus driver context - * - setup various driver entry points - * - invoke the vmbus hv main init routine - * - get the irq resource - * - invoke the vmbus to add the vmbus root device - * - setup the vmbus root device - * - retrieve the channel offers + * - initialize the vmbus driver context + * - setup various driver entry points + * - invoke the vmbus hv main init routine + * - get the irq resource + * - invoke the vmbus to add the vmbus root device + * - setup the vmbus root device + * - retrieve the channel offers */ static int vmbus_bus_init(int (*drv_init)(struct hv_driver *drv)) { @@ -362,7 +362,7 @@ cleanup: return ret; } -/** +/* * vmbus_bus_exit - Terminate the vmbus driver. * * This routine is opposite of vmbus_bus_init() @@ -398,8 +398,18 @@ static void vmbus_bus_exit(void) return; } + /** - * vmbus_child_driver_register - Register a vmbus's child driver + * vmbus_child_driver_register() - Register a vmbus's child driver + * @driver_ctx: Pointer to driver structure you want to register + * + * @driver_ctx is of type &struct driver_context + * + * Registers the given driver with Linux through the 'driver_register()' call + * And sets up the hyper-v vmbus handling for this driver. + * It will return the state of the 'driver_register()' call. + * + * Mainly used by Hyper-V drivers. */ int vmbus_child_driver_register(struct driver_context *driver_ctx) { @@ -425,7 +435,15 @@ int vmbus_child_driver_register(struct driver_context *driver_ctx) EXPORT_SYMBOL(vmbus_child_driver_register); /** - * vmbus_child_driver_unregister Unregister a vmbus's child driver + * vmbus_child_driver_unregister() - Unregister a vmbus's child driver + * @driver_ctx: Pointer to driver structure you want to un-register + * + * @driver_ctx is of type &struct driver_context + * + * Un-register the given driver with Linux through the 'driver_unregister()' + * call. And ungegisters the driver from the Hyper-V vmbus handler. + * + * Mainly used by Hyper-V drivers. */ void vmbus_child_driver_unregister(struct driver_context *driver_ctx) { @@ -443,9 +461,15 @@ void vmbus_child_driver_unregister(struct driver_context *driver_ctx) EXPORT_SYMBOL(vmbus_child_driver_unregister); /** - * vmbus_get_interface - Get the vmbus channel interface. + * vmbus_get_interface() - Get the vmbus channel interface. + * @interface: Pointer to channel interface structure + * + * Get the Hyper-V channel used for the driver. + * + * @interface is of type &struct vmbus_channel_interface + * This is invoked by child/client driver that sits above vmbus. * - * This is invoked by child/client driver that sits above vmbus + * Mainly used by Hyper-V drivers. */ void vmbus_get_interface(struct vmbus_channel_interface *interface) { @@ -455,7 +479,7 @@ void vmbus_get_interface(struct vmbus_channel_interface *interface) } EXPORT_SYMBOL(vmbus_get_interface); -/** +/* * vmbus_child_device_get_info - Get the vmbus child device info. * * This is invoked to display various device attributes in sysfs. @@ -468,8 +492,9 @@ static void vmbus_child_device_get_info(struct hv_device *device_obj, vmbus_drv_obj->GetChannelInfo(device_obj, device_info); } -/** - * vmbus_child_device_create - Creates and registers a new child device on the vmbus. +/* + * vmbus_child_device_create - Creates and registers a new child device + * on the vmbus. */ static struct hv_device *vmbus_child_device_create(struct hv_guid *type, struct hv_guid *instance, @@ -523,7 +548,7 @@ static struct hv_device *vmbus_child_device_create(struct hv_guid *type, return child_device_obj; } -/** +/* * vmbus_child_device_register - Register the child device on the specified bus */ static int vmbus_child_device_register(struct hv_device *root_device_obj, @@ -571,8 +596,9 @@ static int vmbus_child_device_register(struct hv_device *root_device_obj, return ret; } -/** - * vmbus_child_device_unregister - Remove the specified child device from the vmbus. +/* + * vmbus_child_device_unregister - Remove the specified child device + * from the vmbus. */ static void vmbus_child_device_unregister(struct hv_device *device_obj) { @@ -595,7 +621,7 @@ static void vmbus_child_device_unregister(struct hv_device *device_obj) DPRINT_EXIT(VMBUS_DRV); } -/** +/* * vmbus_child_device_destroy - Destroy the specified child device on the vmbus. */ static void vmbus_child_device_destroy(struct hv_device *device_obj) @@ -605,7 +631,7 @@ static void vmbus_child_device_destroy(struct hv_device *device_obj) DPRINT_EXIT(VMBUS_DRV); } -/** +/* * vmbus_uevent - add uevent for our device * * This routine is invoked when a device is added or removed on the vmbus to @@ -684,7 +710,7 @@ static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env) return 0; } -/** +/* * vmbus_match - Attempt to match the specified device to the specified driver */ static int vmbus_match(struct device *device, struct device_driver *driver) @@ -719,7 +745,7 @@ static int vmbus_match(struct device *device, struct device_driver *driver) return match; } -/** +/* * vmbus_probe_failed_cb - Callback when a driver probe failed in vmbus_probe() * * We need a callback because we cannot invoked device_unregister() inside @@ -742,7 +768,7 @@ static void vmbus_probe_failed_cb(struct work_struct *context) DPRINT_EXIT(VMBUS_DRV); } -/** +/* * vmbus_probe - Add the new vmbus's child device */ static int vmbus_probe(struct device *child_device) @@ -778,7 +804,7 @@ static int vmbus_probe(struct device *child_device) return ret; } -/** +/* * vmbus_remove - Remove a vmbus device */ static int vmbus_remove(struct device *child_device) @@ -820,7 +846,7 @@ static int vmbus_remove(struct device *child_device) return 0; } -/** +/* * vmbus_shutdown - Shutdown a vmbus device */ static void vmbus_shutdown(struct device *child_device) @@ -856,7 +882,7 @@ static void vmbus_shutdown(struct device *child_device) return; } -/** +/* * vmbus_bus_release - Final callback release of the vmbus root device */ static void vmbus_bus_release(struct device *device) @@ -870,7 +896,7 @@ static void vmbus_bus_release(struct device *device) DPRINT_EXIT(VMBUS_DRV); } -/** +/* * vmbus_device_release - Final callback release of the vmbus child device */ static void vmbus_device_release(struct device *device) @@ -888,7 +914,7 @@ static void vmbus_device_release(struct device *device) return; } -/** +/* * vmbus_msg_dpc - Tasklet routine to handle hypervisor messages */ static void vmbus_msg_dpc(unsigned long data) @@ -905,7 +931,7 @@ static void vmbus_msg_dpc(unsigned long data) DPRINT_EXIT(VMBUS_DRV); } -/** +/* * vmbus_msg_dpc - Tasklet routine to handle hypervisor events */ static void vmbus_event_dpc(unsigned long data) diff --git a/drivers/staging/hv/vstorage.h b/drivers/staging/hv/vstorage.h index 6d160a53914e..4ea597d7a7d7 100644 --- a/drivers/staging/hv/vstorage.h +++ b/drivers/staging/hv/vstorage.h @@ -28,7 +28,7 @@ #define REVISION_STRING(REVISION_) #REVISION_ #define FILL_VMSTOR_REVISION(RESULT_LVALUE_) \ { \ - char *revisionString = REVISION_STRING($Revision: 6 $) + 11; \ + char *revisionString = REVISION_STRING($Revision : 6 $) + 11; \ RESULT_LVALUE_ = 0; \ while (*revisionString >= '0' && *revisionString <= '9') { \ RESULT_LVALUE_ *= 10; \ diff --git a/drivers/staging/iio/Documentation/lis3l02dqbuffersimple.c b/drivers/staging/iio/Documentation/lis3l02dqbuffersimple.c index 2b5cfc58d78d..08e012fa8460 100644 --- a/drivers/staging/iio/Documentation/lis3l02dqbuffersimple.c +++ b/drivers/staging/iio/Documentation/lis3l02dqbuffersimple.c @@ -19,8 +19,7 @@ #include <sys/dir.h> #include <linux/types.h> -#include <dirent.h> -#include "iio_util.h" +#include "iio_utils.h" static const char *ring_access = "/dev/iio/lis3l02dq_ring_access"; static const char *ring_event = "/dev/iio/lis3l02dq_ring_event"; diff --git a/drivers/staging/iio/Documentation/userspace.txt b/drivers/staging/iio/Documentation/userspace.txt index 661015a0b866..4838818f65ef 100644 --- a/drivers/staging/iio/Documentation/userspace.txt +++ b/drivers/staging/iio/Documentation/userspace.txt @@ -56,5 +56,5 @@ KERNEL="ring_event_line*", ID="spi1.0", DRIVER="lis3l02dq", NAME="iio/lis3l02dq_ KERNEL="event_line*", ID="spi1.0", DRIVER="lis3l02dq", NAME="iio/lis3l02dq_event" KERNEL="ring_access*", ID="spi1.0", DRIVER="lis3l02dq", NAME="iio/lis3l02dq_ring_access" -The files, lis3l02dqbuffersimple.c and iio_util.h in this directory provide an example +The files, lis3l02dqbuffersimple.c and iio_utils.h in this directory provide an example of how to use the ring buffer and event interfaces. diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 1d77082c8531..dce8dcc49a9d 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c @@ -810,7 +810,7 @@ int iio_device_register(struct iio_dev *dev_info) ret = iio_device_register_eventset(dev_info); if (ret) { dev_err(dev_info->dev.parent, - "Failed to register event set \n"); + "Failed to register event set\n"); goto error_free_sysfs; } if (dev_info->modes & INDIO_RING_TRIGGERED) diff --git a/drivers/staging/iio/industrialio-ring.c b/drivers/staging/iio/industrialio-ring.c index e53e214bfeb0..5f48632e4258 100644 --- a/drivers/staging/iio/industrialio-ring.c +++ b/drivers/staging/iio/industrialio-ring.c @@ -266,6 +266,8 @@ void iio_ring_buffer_init(struct iio_ring_buffer *ring, ring->indio_dev = dev_info; ring->ev_int.private = ring; ring->access_handler.private = ring; + ring->shared_ev_pointer.ev_p = 0; + spin_lock_init(&ring->shared_ev_pointer.lock); } EXPORT_SYMBOL(iio_ring_buffer_init); diff --git a/drivers/staging/iio/industrialio-trigger.c b/drivers/staging/iio/industrialio-trigger.c index 35ec80ba444f..3c8f6ffab584 100644 --- a/drivers/staging/iio/industrialio-trigger.c +++ b/drivers/staging/iio/industrialio-trigger.c @@ -156,6 +156,9 @@ struct iio_trigger *iio_trigger_find_by_name(const char *name, size_t len) struct iio_trigger *trig; bool found = false; + if (len && name[len - 1] == '\n') + len--; + mutex_lock(&iio_trigger_list_lock); list_for_each_entry(trig, &iio_trigger_list, list) { if (strncmp(trig->name, name, len) == 0) { diff --git a/drivers/staging/iio/ring_generic.h b/drivers/staging/iio/ring_generic.h index 09044adf7327..75e0fc078d68 100644 --- a/drivers/staging/iio/ring_generic.h +++ b/drivers/staging/iio/ring_generic.h @@ -134,19 +134,17 @@ void iio_ring_buffer_init(struct iio_ring_buffer *ring, struct iio_dev *dev_info); /** - * __iio_init_ring_buffer() - initialize common elements of ring buffers + * __iio_update_ring_buffer() - update common elements of ring buffers * @ring: ring buffer that is the event source * @bytes_per_datum: size of individual datum including timestamp * @length: number of datums in ring **/ -static inline void __iio_init_ring_buffer(struct iio_ring_buffer *ring, - int bytes_per_datum, int length) +static inline void __iio_update_ring_buffer(struct iio_ring_buffer *ring, + int bytes_per_datum, int length) { ring->bpd = bytes_per_datum; ring->length = length; ring->loopcount = 0; - ring->shared_ev_pointer.ev_p = 0; - spin_lock_init(&ring->shared_ev_pointer.lock); } /** diff --git a/drivers/staging/iio/ring_sw.c b/drivers/staging/iio/ring_sw.c index cf22c091668c..c24f93dc95ea 100644 --- a/drivers/staging/iio/ring_sw.c +++ b/drivers/staging/iio/ring_sw.c @@ -14,14 +14,12 @@ #include <linux/workqueue.h> #include "ring_sw.h" -static inline int __iio_init_sw_ring_buffer(struct iio_sw_ring_buffer *ring, - int bytes_per_datum, int length) +static inline int __iio_allocate_sw_ring_buffer(struct iio_sw_ring_buffer *ring, + int bytes_per_datum, int length) { if ((length == 0) || (bytes_per_datum == 0)) return -EINVAL; - - __iio_init_ring_buffer(&ring->buf, bytes_per_datum, length); - spin_lock_init(&ring->use_lock); + __iio_update_ring_buffer(&ring->buf, bytes_per_datum, length); ring->data = kmalloc(length*ring->buf.bpd, GFP_KERNEL); ring->read_p = 0; ring->write_p = 0; @@ -30,6 +28,11 @@ static inline int __iio_init_sw_ring_buffer(struct iio_sw_ring_buffer *ring, return ring->data ? 0 : -ENOMEM; } +static inline void __iio_init_sw_ring_buffer(struct iio_sw_ring_buffer *ring) +{ + spin_lock_init(&ring->use_lock); +} + static inline void __iio_free_sw_ring_buffer(struct iio_sw_ring_buffer *ring) { kfree(ring->data); @@ -123,8 +126,7 @@ int iio_store_to_sw_ring(struct iio_sw_ring_buffer *ring, spin_lock(&ring->buf.shared_ev_pointer.lock); ret = iio_push_or_escallate_ring_event(&ring->buf, - IIO_EVENT_CODE_RING_100_FULL, - timestamp); + IIO_EVENT_CODE_RING_100_FULL, timestamp); spin_unlock(&ring->buf.shared_ev_pointer.lock); if (ret) goto error_ret; @@ -320,7 +322,8 @@ int iio_request_update_sw_rb(struct iio_ring_buffer *r) goto error_ret; } __iio_free_sw_ring_buffer(ring); - ret = __iio_init_sw_ring_buffer(ring, ring->buf.bpd, ring->buf.length); + ret = __iio_allocate_sw_ring_buffer(ring, ring->buf.bpd, + ring->buf.length); error_ret: spin_unlock(&ring->use_lock); return ret; @@ -411,8 +414,8 @@ struct iio_ring_buffer *iio_sw_rb_allocate(struct iio_dev *indio_dev) if (!ring) return 0; buf = &ring->buf; - iio_ring_buffer_init(buf, indio_dev); + __iio_init_sw_ring_buffer(ring); buf->dev.type = &iio_sw_ring_type; device_initialize(&buf->dev); buf->dev.parent = &indio_dev->dev; diff --git a/drivers/staging/iio/trigger/iio-trig-gpio.c b/drivers/staging/iio/trigger/iio-trig-gpio.c index 0c3bad3187f5..e40099ff6230 100644 --- a/drivers/staging/iio/trigger/iio-trig-gpio.c +++ b/drivers/staging/iio/trigger/iio-trig-gpio.c @@ -13,7 +13,6 @@ * TODO: * * Add board config elements to allow specification of startup settings. - * Add configuration settings (irq type etc) */ #include <linux/kernel.h> @@ -31,7 +30,7 @@ DEFINE_MUTEX(iio_gpio_trigger_list_lock); struct iio_gpio_trigger_info { struct mutex in_use; - int gpio; + unsigned int irq; }; /* * Need to reference count these triggers and only enable gpio interrupts @@ -58,78 +57,77 @@ static const struct attribute_group iio_gpio_trigger_attr_group = { .attrs = iio_gpio_trigger_attrs, }; -static int iio_gpio_trigger_probe(struct platform_device *dev) +static int iio_gpio_trigger_probe(struct platform_device *pdev) { - int *pdata = dev->dev.platform_data; struct iio_gpio_trigger_info *trig_info; struct iio_trigger *trig, *trig2; - int i, irq, ret = 0; - if (!pdata) { - printk(KERN_ERR "No IIO gpio trigger platform data found\n"); - goto error_ret; - } - for (i = 0;; i++) { - if (!gpio_is_valid(pdata[i])) - break; - trig = iio_allocate_trigger(); - if (!trig) { - ret = -ENOMEM; - goto error_free_completed_registrations; - } + unsigned long irqflags; + struct resource *irq_res; + int irq, ret = 0, irq_res_cnt = 0; - trig_info = kzalloc(sizeof(*trig_info), GFP_KERNEL); - if (!trig_info) { - ret = -ENOMEM; - goto error_put_trigger; - } - trig->control_attrs = &iio_gpio_trigger_attr_group; - trig->private_data = trig_info; - trig_info->gpio = pdata[i]; - trig->owner = THIS_MODULE; - trig->name = kmalloc(IIO_TRIGGER_NAME_LENGTH, GFP_KERNEL); - if (!trig->name) { - ret = -ENOMEM; - goto error_free_trig_info; + do { + irq_res = platform_get_resource(pdev, + IORESOURCE_IRQ, irq_res_cnt); + + if (irq_res == NULL) { + if (irq_res_cnt == 0) + dev_err(&pdev->dev, "No GPIO IRQs specified"); + break; } - snprintf((char *)trig->name, - IIO_TRIGGER_NAME_LENGTH, - "gpiotrig%d", - pdata[i]); - ret = gpio_request(trig_info->gpio, trig->name); - if (ret) - goto error_free_name; - - ret = gpio_direction_input(trig_info->gpio); - if (ret) - goto error_release_gpio; - - irq = gpio_to_irq(trig_info->gpio); - if (irq < 0) { - ret = irq; - goto error_release_gpio; + irqflags = (irq_res->flags & IRQF_TRIGGER_MASK) | IRQF_SHARED; + + for (irq = irq_res->start; irq <= irq_res->end; irq++) { + + trig = iio_allocate_trigger(); + if (!trig) { + ret = -ENOMEM; + goto error_free_completed_registrations; + } + + trig_info = kzalloc(sizeof(*trig_info), GFP_KERNEL); + if (!trig_info) { + ret = -ENOMEM; + goto error_put_trigger; + } + trig->control_attrs = &iio_gpio_trigger_attr_group; + trig->private_data = trig_info; + trig_info->irq = irq; + trig->owner = THIS_MODULE; + trig->name = kmalloc(IIO_TRIGGER_NAME_LENGTH, + GFP_KERNEL); + if (!trig->name) { + ret = -ENOMEM; + goto error_free_trig_info; + } + snprintf((char *)trig->name, + IIO_TRIGGER_NAME_LENGTH, + "irqtrig%d", irq); + + ret = request_irq(irq, iio_gpio_trigger_poll, + irqflags, trig->name, trig); + if (ret) { + dev_err(&pdev->dev, + "request IRQ-%d failed", irq); + goto error_free_name; + } + + ret = iio_trigger_register(trig); + if (ret) + goto error_release_irq; + + list_add_tail(&trig->alloc_list, + &iio_gpio_trigger_list); } - ret = request_irq(irq, iio_gpio_trigger_poll, - IRQF_TRIGGER_RISING, - trig->name, - trig); - if (ret) - goto error_release_gpio; + irq_res_cnt++; + } while (irq_res != NULL); - ret = iio_trigger_register(trig); - if (ret) - goto error_release_irq; - list_add_tail(&trig->alloc_list, &iio_gpio_trigger_list); - - } return 0; /* First clean up the partly allocated trigger */ error_release_irq: free_irq(irq, trig); -error_release_gpio: - gpio_free(trig_info->gpio); error_free_name: kfree(trig->name); error_free_trig_info: @@ -143,18 +141,16 @@ error_free_completed_registrations: &iio_gpio_trigger_list, alloc_list) { trig_info = trig->private_data; - free_irq(gpio_to_irq(trig_info->gpio), trig); - gpio_free(trig_info->gpio); + free_irq(gpio_to_irq(trig_info->irq), trig); kfree(trig->name); kfree(trig_info); iio_trigger_unregister(trig); } -error_ret: return ret; } -static int iio_gpio_trigger_remove(struct platform_device *dev) +static int iio_gpio_trigger_remove(struct platform_device *pdev) { struct iio_trigger *trig, *trig2; struct iio_gpio_trigger_info *trig_info; @@ -166,8 +162,7 @@ static int iio_gpio_trigger_remove(struct platform_device *dev) alloc_list) { trig_info = trig->private_data; iio_trigger_unregister(trig); - free_irq(gpio_to_irq(trig_info->gpio), trig); - gpio_free(trig_info->gpio); + free_irq(trig_info->irq, trig); kfree(trig->name); kfree(trig_info); iio_put_trigger(trig); diff --git a/drivers/staging/line6/control.h b/drivers/staging/line6/control.h index 2f19665d95a9..47e18ab6d5b0 100644 --- a/drivers/staging/line6/control.h +++ b/drivers/staging/line6/control.h @@ -22,24 +22,44 @@ enum { POD_tweak = 1, POD_wah_position = 4, - POD_compression_gain = 5, /* device: LINE6_BITS_PODXTALL */ + + /* device: LINE6_BITS_PODXTALL */ + POD_compression_gain = 5, + POD_vol_pedal_position = 7, POD_compression_threshold = 9, POD_pan = 10, POD_amp_model_setup = 11, - POD_amp_model = 12, /* firmware: 2.0 */ + POD_amp_model = 12, /* firmware: 2.0 */ POD_drive = 13, POD_bass = 14, - POD_mid = 15, /* device: LINE6_BITS_PODXTALL */ - POD_lowmid = 15, /* device: LINE6_BITS_BASSPODXTALL */ - POD_treble = 16, /* device: LINE6_BITS_PODXTALL */ - POD_highmid = 16, /* device: LINE6_BITS_BASSPODXTALL */ + + /* device: LINE6_BITS_PODXTALL */ + POD_mid = 15, + + /* device: LINE6_BITS_BASSPODXTALL */ + POD_lowmid = 15, + + /* device: LINE6_BITS_PODXTALL */ + POD_treble = 16, + + /* device: LINE6_BITS_BASSPODXTALL */ + POD_highmid = 16, + POD_chan_vol = 17, - POD_reverb_mix = 18, /* device: LINE6_BITS_PODXTALL */ + + /* device: LINE6_BITS_PODXTALL */ + POD_reverb_mix = 18, + POD_effect_setup = 19, POD_band_1_frequency = 20, /* firmware: 2.0 */ - POD_presence = 21, /* device: LINE6_BITS_PODXTALL */ - POD_treble__bass = 21, /* device: LINE6_BITS_BASSPODXTALL */ + + /* device: LINE6_BITS_PODXTALL */ + POD_presence = 21, + + /* device: LINE6_BITS_BASSPODXTALL */ + POD_treble__bass = 21, + POD_noise_gate_enable = 22, POD_gate_threshold = 23, POD_gate_decay_time = 24, @@ -50,78 +70,137 @@ enum { POD_mod_param_1 = 29, POD_delay_param_1 = 30, POD_delay_param_1_note_value = 31, - POD_band_2_frequency__bass = 32, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */ + + /* device: LINE6_BITS_BASSPODXTALL */ + POD_band_2_frequency__bass = 32, /* firmware: 2.0 */ + POD_delay_param_2 = 33, POD_delay_volume_mix = 34, POD_delay_param_3 = 35, - POD_reverb_enable = 36, /* device: LINE6_BITS_PODXTALL */ - POD_reverb_type = 37, /* device: LINE6_BITS_PODXTALL */ - POD_reverb_decay = 38, /* device: LINE6_BITS_PODXTALL */ - POD_reverb_tone = 39, /* device: LINE6_BITS_PODXTALL */ - POD_reverb_pre_delay = 40, /* device: LINE6_BITS_PODXTALL */ - POD_reverb_pre_post = 41, /* device: LINE6_BITS_PODXTALL */ - POD_band_2_frequency = 42, /* device: LINE6_BITS_PODXTALL */ /* firmware: 2.0 */ - POD_band_3_frequency__bass = 42, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */ + + /* device: LINE6_BITS_PODXTALL */ + POD_reverb_enable = 36, + POD_reverb_type = 37, + POD_reverb_decay = 38, + POD_reverb_tone = 39, + POD_reverb_pre_delay = 40, + POD_reverb_pre_post = 41, + POD_band_2_frequency = 42, + + /* device: LINE6_BITS_BASSPODXTALL */ + POD_band_3_frequency__bass = 42, /* firmware: 2.0 */ + POD_wah_enable = 43, - POD_modulation_lo_cut = 44, /* device: LINE6_BITS_BASSPODXTALL */ - POD_delay_reverb_lo_cut = 45, /* device: LINE6_BITS_BASSPODXTALL */ - POD_volume_pedal_minimum = 46, /* device: LINE6_BITS_PODXTALL */ /* firmware: 2.0 */ - POD_eq_pre_post = 46, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */ + + /* device: LINE6_BITS_BASSPODXTALL */ + POD_modulation_lo_cut = 44, + POD_delay_reverb_lo_cut = 45, + + /* device: LINE6_BITS_PODXTALL */ + POD_volume_pedal_minimum = 46, /* firmware: 2.0 */ + + /* device: LINE6_BITS_BASSPODXTALL */ + POD_eq_pre_post = 46, /* firmware: 2.0 */ + POD_volume_pre_post = 47, - POD_di_model = 48, /* device: LINE6_BITS_BASSPODXTALL */ - POD_di_delay = 49, /* device: LINE6_BITS_BASSPODXTALL */ + + /* device: LINE6_BITS_BASSPODXTALL */ + POD_di_model = 48, + POD_di_delay = 49, + POD_mod_enable = 50, POD_mod_param_1_note_value = 51, POD_mod_param_2 = 52, POD_mod_param_3 = 53, POD_mod_param_4 = 54, - POD_mod_param_5 = 55, /* device: LINE6_BITS_BASSPODXTALL */ + + /* device: LINE6_BITS_BASSPODXTALL */ + POD_mod_param_5 = 55, + POD_mod_volume_mix = 56, POD_mod_pre_post = 57, POD_modulation_model = 58, - POD_band_3_frequency = 60, /* device: LINE6_BITS_PODXTALL */ /* firmware: 2.0 */ - POD_band_4_frequency__bass = 60, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */ + + /* device: LINE6_BITS_PODXTALL */ + POD_band_3_frequency = 60, /* firmware: 2.0 */ + + /* device: LINE6_BITS_BASSPODXTALL */ + POD_band_4_frequency__bass = 60, /* firmware: 2.0 */ + POD_mod_param_1_double_precision = 61, POD_delay_param_1_double_precision = 62, POD_eq_enable = 63, /* firmware: 2.0 */ POD_tap = 64, POD_volume_tweak_pedal_assign = 65, - POD_band_5_frequency = 68, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */ + + /* device: LINE6_BITS_BASSPODXTALL */ + POD_band_5_frequency = 68, /* firmware: 2.0 */ + POD_tuner = 69, POD_mic_selection = 70, POD_cabinet_model = 71, POD_stomp_model = 75, POD_roomlevel = 76, - POD_band_4_frequency = 77, /* device: LINE6_BITS_PODXTALL */ /* firmware: 2.0 */ - POD_band_6_frequency = 77, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */ + + /* device: LINE6_BITS_PODXTALL */ + POD_band_4_frequency = 77, /* firmware: 2.0 */ + + /* device: LINE6_BITS_BASSPODXTALL */ + POD_band_6_frequency = 77, /* firmware: 2.0 */ + POD_stomp_param_1_note_value = 78, POD_stomp_param_2 = 79, POD_stomp_param_3 = 80, POD_stomp_param_4 = 81, POD_stomp_param_5 = 82, POD_stomp_param_6 = 83, - POD_amp_switch_select = 84, /* device: LINE6_BITS_LIVE */ + + /* device: LINE6_BITS_LIVE */ + POD_amp_switch_select = 84, + POD_delay_param_4 = 85, POD_delay_param_5 = 86, POD_delay_pre_post = 87, - POD_delay_model = 88, /* device: LINE6_BITS_PODXTALL */ - POD_delay_verb_model = 88, /* device: LINE6_BITS_BASSPODXTALL */ + + /* device: LINE6_BITS_PODXTALL */ + POD_delay_model = 88, + + /* device: LINE6_BITS_BASSPODXTALL */ + POD_delay_verb_model = 88, + POD_tempo_msb = 89, POD_tempo_lsb = 90, POD_wah_model = 91, /* firmware: 3.0 */ POD_bypass_volume = 105, /* firmware: 2.14 */ - POD_fx_loop_on_off = 107, /* device: LINE6_BITS_PRO */ + + /* device: LINE6_BITS_PRO */ + POD_fx_loop_on_off = 107, + POD_tweak_param_select = 108, POD_amp1_engage = 111, POD_band_1_gain = 114, /* firmware: 2.0 */ - POD_band_2_gain__bass = 115, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */ - POD_band_2_gain = 116, /* device: LINE6_BITS_PODXTALL */ /* firmware: 2.0 */ - POD_band_3_gain__bass = 116, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */ - POD_band_3_gain = 117, /* device: LINE6_BITS_PODXTALL */ /* firmware: 2.0 */ - POD_band_4_gain__bass = 117, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */ - POD_band_5_gain__bass = 118, /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */ - POD_band_4_gain = 119, /* device: LINE6_BITS_PODXTALL */ /* firmware: 2.0 */ - POD_band_6_gain__bass = 119 /* device: LINE6_BITS_BASSPODXTALL */ /* firmware: 2.0 */ + + /* device: LINE6_BITS_BASSPODXTALL */ + POD_band_2_gain__bass = 115, /* firmware: 2.0 */ + + /* device: LINE6_BITS_PODXTALL */ + POD_band_2_gain = 116, /* firmware: 2.0 */ + + /* device: LINE6_BITS_BASSPODXTALL */ + POD_band_3_gain__bass = 116, /* firmware: 2.0 */ + + /* device: LINE6_BITS_PODXTALL */ + POD_band_3_gain = 117, /* firmware: 2.0 */ + + /* device: LINE6_BITS_BASSPODXTALL */ + POD_band_4_gain__bass = 117, /* firmware: 2.0 */ + POD_band_5_gain__bass = 118, /* firmware: 2.0 */ + + /* device: LINE6_BITS_PODXTALL */ + POD_band_4_gain = 119, /* firmware: 2.0 */ + + /* device: LINE6_BITS_BASSPODXTALL */ + POD_band_6_gain__bass = 119 /* firmware: 2.0 */ }; /** @@ -139,7 +218,8 @@ enum { VARIAX_pickup2_position = 23, /* type: 24 bit float */ VARIAX_pickup2_angle = 26, /* type: 24 bit float */ VARIAX_pickup2_level = 29, /* type: 24 bit float */ - VARIAX_pickup_phase = 32, /* 0: in phase, 1: out of phase */ + VARIAX_pickup_phase = 32, /* 0: in phase, + 1: out of phase */ VARIAX_capacitance = 33, /* type: 24 bit float */ VARIAX_tone_resistance = 36, /* type: 24 bit float */ VARIAX_volume_resistance = 39, /* type: 24 bit float */ diff --git a/drivers/staging/memrar/Kconfig b/drivers/staging/memrar/Kconfig new file mode 100644 index 000000000000..a5598a86f668 --- /dev/null +++ b/drivers/staging/memrar/Kconfig @@ -0,0 +1,15 @@ +config MRST_RAR_HANDLER + tristate "RAR handler driver for Intel Moorestown platform" + select RAR_REGISTER + ---help--- + This driver provides a memory management interface to + restricted access regions (RAR) available on the Intel + Moorestown platform. + + Once locked down, restricted access regions are only + accessible by specific hardware on the platform. The x86 + CPU is typically not one of those platforms. As such this + driver does not access RAR, and only provides a buffer + allocation/bookkeeping mechanism. + + If unsure, say N. diff --git a/drivers/staging/memrar/Makefile b/drivers/staging/memrar/Makefile new file mode 100644 index 000000000000..a3336c00cc5f --- /dev/null +++ b/drivers/staging/memrar/Makefile @@ -0,0 +1,2 @@ +obj-$(CONFIG_MRST_RAR_HANDLER) += memrar.o +memrar-y := memrar_allocator.o memrar_handler.o diff --git a/drivers/staging/memrar/TODO b/drivers/staging/memrar/TODO new file mode 100644 index 000000000000..0087447d5034 --- /dev/null +++ b/drivers/staging/memrar/TODO @@ -0,0 +1,43 @@ +RAR Handler (memrar) Driver TODO Items +====================================== + +Maintainer: Ossama Othman <ossama.othman@intel.com> + +memrar.h +-------- +1. This header exposes the driver's user space and kernel space + interfaces. It should be moved to <linux/rar/memrar.h>, or + something along those lines, when this memrar driver is moved out + of `staging'. + a. It would be ideal if staging/rar_register/rar_register.h was + moved to the same directory. + +memrar_allocator.[ch] +--------------------- +1. Address potential fragmentation issues with the memrar_allocator. + +2. Hide struct memrar_allocator details/fields. They need not be + exposed to the user. + a. Forward declare struct memrar_allocator. + b. Move all three struct definitions to `memrar_allocator.c' + source file. + c. Add a memrar_allocator_largest_free_area() function, or + something like that to get access to the value of the struct + memrar_allocator "largest_free_area" field. This allows the + struct memrar_allocator fields to be completely hidden from + the user. The memrar_handler code really only needs this for + statistic gathering on-demand. + d. Do the same for the "capacity" field as the + "largest_free_area" field. + +3. Move memrar_allocator.* to kernel `lib' directory since it is HW + neutral. + a. Alternatively, use lib/genalloc.c instead. + b. A kernel port of Doug Lea's malloc() implementation may also + be an option. + +memrar_handler.c +---------------- +1. Split user space interface (ioctl code) from core/kernel code, + e.g.: + memrar_handler.c -> memrar_core.c, memrar_user.c diff --git a/drivers/staging/memrar/memrar-abi b/drivers/staging/memrar/memrar-abi new file mode 100644 index 000000000000..98a6bb158baf --- /dev/null +++ b/drivers/staging/memrar/memrar-abi @@ -0,0 +1,89 @@ +What: /dev/memrar +Date: March 2010 +KernelVersion: Kernel version this feature first showed up in. +Contact: Ossama Othman <ossama.othman@intel.com> +Description: The Intel Moorestown Restricted Access Region (RAR) + Handler driver exposes an ioctl() based interface that + allows a user to reserve and release blocks of RAR + memory. + + Note: A sysfs based one was not appropriate for the + RAR handler's usage model. + + ========================================================= + ioctl() Requests + ========================================================= + RAR_HANDLER_RESERVE + ------------------- + Description: Reserve RAR block. + Type: struct RAR_block_info + Direction: in/out + Errors: EINVAL (invalid RAR type or size) + ENOMEM (not enough RAR memory) + + RAR_HANDLER_STAT + ---------------- + Description: Get RAR statistics. + Type: struct RAR_stat + Direction: in/out + Errors: EINVAL (invalid RAR type) + + RAR_HANDLER_RELEASE + ------------------- + Description: Release previously reserved RAR block. + Type: 32 bit unsigned integer + (e.g. uint32_t), i.e the RAR "handle". + Direction: in + Errors: EINVAL (invalid RAR handle) + + + ========================================================= + ioctl() Request Parameter Types + ========================================================= + The structures referred to above are defined as + follows: + + /** + * struct RAR_block_info - user space struct that + * describes RAR buffer + * @type: Type of RAR memory (e.g., + * RAR_TYPE_VIDEO or RAR_TYPE_AUDIO) [in] + * @size: Requested size of a block in bytes to + * be reserved in RAR. [in] + * @handle: Handle that can be used to refer to + * reserved block. [out] + * + * This is the basic structure exposed to the user + * space that describes a given RAR buffer. It used + * as the parameter for the RAR_HANDLER_RESERVE ioctl. + * The buffer's underlying bus address is not exposed + * to the user. User space code refers to the buffer + * entirely by "handle". + */ + struct RAR_block_info { + __u32 type; + __u32 size; + __u32 handle; + }; + + /** + * struct RAR_stat - RAR statistics structure + * @type: Type of RAR memory (e.g., + * RAR_TYPE_VIDEO or + * RAR_TYPE_AUDIO) [in] + * @capacity: Total size of RAR memory + * region. [out] + * @largest_block_size: Size of the largest reservable + * block. [out] + * + * This structure is used for RAR_HANDLER_STAT ioctl. + */ + struct RAR_stat { + __u32 type; + __u32 capacity; + __u32 largest_block_size; + }; + + Lastly, the RAR_HANDLER_RELEASE ioctl expects a + "handle" to the RAR block of memory. It is a 32 bit + unsigned integer. diff --git a/drivers/staging/memrar/memrar.h b/drivers/staging/memrar/memrar.h new file mode 100644 index 000000000000..0b735b827c09 --- /dev/null +++ b/drivers/staging/memrar/memrar.h @@ -0,0 +1,155 @@ +/* + * RAR Handler (/dev/memrar) internal driver API. + * Copyright (C) 2010 Intel Corporation. All rights reserved. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * The full GNU General Public License is included in this + * distribution in the file called COPYING. + */ + + +#ifndef _MEMRAR_H +#define _MEMRAR_H + +#include <linux/ioctl.h> +#include <linux/types.h> + + +/** + * struct RAR_stat - RAR statistics structure + * @type: Type of RAR memory (e.g., audio vs. video) + * @capacity: Total size of RAR memory region. + * @largest_block_size: Size of the largest reservable block. + * + * This structure is used for RAR_HANDLER_STAT ioctl and for the + * RAR_get_stat() user space wrapper function. + */ +struct RAR_stat { + __u32 type; + __u32 capacity; + __u32 largest_block_size; +}; + + +/** + * struct RAR_block_info - user space struct that describes RAR buffer + * @type: Type of RAR memory (e.g., audio vs. video) + * @size: Requested size of a block to be reserved in RAR. + * @handle: Handle that can be used to refer to reserved block. + * + * This is the basic structure exposed to the user space that + * describes a given RAR buffer. The buffer's underlying bus address + * is not exposed to the user. User space code refers to the buffer + * entirely by "handle". + */ +struct RAR_block_info { + __u32 type; + __u32 size; + __u32 handle; +}; + + +#define RAR_IOCTL_BASE 0xE0 + +/* Reserve RAR block. */ +#define RAR_HANDLER_RESERVE _IOWR(RAR_IOCTL_BASE, 0x00, struct RAR_block_info) + +/* Release previously reserved RAR block. */ +#define RAR_HANDLER_RELEASE _IOW(RAR_IOCTL_BASE, 0x01, __u32) + +/* Get RAR stats. */ +#define RAR_HANDLER_STAT _IOWR(RAR_IOCTL_BASE, 0x02, struct RAR_stat) + + +#ifdef __KERNEL__ + +/* -------------------------------------------------------------- */ +/* Kernel Side RAR Handler Interface */ +/* -------------------------------------------------------------- */ + +/** + * struct RAR_buffer - kernel space struct that describes RAR buffer + * @info: structure containing base RAR buffer information + * @bus_address: buffer bus address + * + * Structure that contains all information related to a given block of + * memory in RAR. It is generally only used when retrieving RAR + * related bus addresses. + * + * Note: This structure is used only by RAR-enabled drivers, and is + * not intended to be exposed to the user space. + */ +struct RAR_buffer { + struct RAR_block_info info; + dma_addr_t bus_address; +}; + +/** + * rar_reserve() - reserve RAR buffers + * @buffers: array of RAR_buffers where type and size of buffers to + * reserve are passed in, handle and bus address are + * passed out + * @count: number of RAR_buffers in the "buffers" array + * + * This function will reserve buffers in the restricted access regions + * of given types. + * + * It returns the number of successfully reserved buffers. Successful + * buffer reservations will have the corresponding bus_address field + * set to a non-zero value in the given buffers vector. + */ +extern size_t rar_reserve(struct RAR_buffer *buffers, + size_t count); + +/** + * rar_release() - release RAR buffers + * @buffers: array of RAR_buffers where handles to buffers to be + * released are passed in + * @count: number of RAR_buffers in the "buffers" array + * + * This function will release RAR buffers that were retrieved through + * a call to rar_reserve() or rar_handle_to_bus() by decrementing the + * reference count. The RAR buffer will be reclaimed when the + * reference count drops to zero. + * + * It returns the number of successfully released buffers. Successful + * releases will have their handle field set to zero in the given + * buffers vector. + */ +extern size_t rar_release(struct RAR_buffer *buffers, + size_t count); + +/** + * rar_handle_to_bus() - convert a vector of RAR handles to bus addresses + * @buffers: array of RAR_buffers containing handles to be + * converted to bus_addresses + * @count: number of RAR_buffers in the "buffers" array + + * This function will retrieve the RAR buffer bus addresses, type and + * size corresponding to the RAR handles provided in the buffers + * vector. + * + * It returns the number of successfully converted buffers. The bus + * address will be set to 0 for unrecognized handles. + * + * The reference count for each corresponding buffer in RAR will be + * incremented. Call rar_release() when done with the buffers. + */ +extern size_t rar_handle_to_bus(struct RAR_buffer *buffers, + size_t count); + + +#endif /* __KERNEL__ */ + +#endif /* _MEMRAR_H */ diff --git a/drivers/staging/memrar/memrar_allocator.c b/drivers/staging/memrar/memrar_allocator.c new file mode 100644 index 000000000000..a4f8c5846a00 --- /dev/null +++ b/drivers/staging/memrar/memrar_allocator.c @@ -0,0 +1,432 @@ +/* + * memrar_allocator 1.0: An allocator for Intel RAR. + * + * Copyright (C) 2010 Intel Corporation. All rights reserved. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * The full GNU General Public License is included in this + * distribution in the file called COPYING. + * + * + * ------------------------------------------------------------------ + * + * This simple allocator implementation provides a + * malloc()/free()-like interface for reserving space within a + * previously reserved block of memory. It is not specific to + * any hardware, nor is it coupled with the lower level paging + * mechanism. + * + * The primary goal of this implementation is to provide a means + * to partition an arbitrary block of memory without actually + * accessing the memory or incurring any hardware side-effects + * (e.g. paging). It is, in effect, a bookkeeping mechanism for + * buffers. + */ + + +#include "memrar_allocator.h" +#include <linux/slab.h> +#include <linux/bug.h> +#include <linux/kernel.h> + + +struct memrar_allocator *memrar_create_allocator(unsigned long base, + size_t capacity, + size_t block_size) +{ + struct memrar_allocator *allocator = NULL; + struct memrar_address_ranges *first_node = NULL; + + /* + * Make sure the base address is aligned on a block_size + * boundary. + * + * @todo Is this necessary? + */ + /* base = ALIGN(base, block_size); */ + + /* Validate parameters. + * + * Make sure we can allocate the entire memory space. Zero + * capacity or block size are obviously invalid. + */ + if (base == 0 + || capacity == 0 + || block_size == 0 + || ULONG_MAX - capacity < base + || capacity < block_size) + return allocator; + + /* + * There isn't much point in creating a memory allocator that + * is only capable of holding one block but we'll allow it, + * and issue a diagnostic. + */ + WARN(capacity < block_size * 2, + "memrar: Only one block available to allocator.\n"); + + allocator = kmalloc(sizeof(*allocator), GFP_KERNEL); + + if (allocator == NULL) + return allocator; + + mutex_init(&allocator->lock); + allocator->base = base; + + /* Round the capacity down to a multiple of block_size. */ + allocator->capacity = (capacity / block_size) * block_size; + + allocator->block_size = block_size; + + allocator->largest_free_area = allocator->capacity; + + /* Initialize the handle and free lists. */ + INIT_LIST_HEAD(&allocator->allocated_list.list); + INIT_LIST_HEAD(&allocator->free_list.list); + + first_node = kmalloc(sizeof(*first_node), GFP_KERNEL); + if (first_node == NULL) { + kfree(allocator); + allocator = NULL; + } else { + /* Full range of blocks is available. */ + first_node->range.begin = base; + first_node->range.end = base + allocator->capacity; + list_add(&first_node->list, + &allocator->free_list.list); + } + + return allocator; +} + +void memrar_destroy_allocator(struct memrar_allocator *allocator) +{ + /* + * Assume that the memory allocator lock isn't held at this + * point in time. Caller must ensure that. + */ + + struct memrar_address_ranges *pos = NULL; + struct memrar_address_ranges *n = NULL; + + if (allocator == NULL) + return; + + mutex_lock(&allocator->lock); + + /* Reclaim free list resources. */ + list_for_each_entry_safe(pos, + n, + &allocator->free_list.list, + list) { + list_del(&pos->list); + kfree(pos); + } + + mutex_unlock(&allocator->lock); + + kfree(allocator); +} + +unsigned long memrar_allocator_alloc(struct memrar_allocator *allocator, + size_t size) +{ + struct memrar_address_ranges *pos = NULL; + + size_t num_blocks; + unsigned long reserved_bytes; + + /* + * Address of allocated buffer. We assume that zero is not a + * valid address. + */ + unsigned long addr = 0; + + if (allocator == NULL || size == 0) + return addr; + + /* Reserve enough blocks to hold the amount of bytes requested. */ + num_blocks = DIV_ROUND_UP(size, allocator->block_size); + + reserved_bytes = num_blocks * allocator->block_size; + + mutex_lock(&allocator->lock); + + if (reserved_bytes > allocator->largest_free_area) { + mutex_unlock(&allocator->lock); + return addr; + } + + /* + * Iterate through the free list to find a suitably sized + * range of free contiguous memory blocks. + * + * We also take the opportunity to reset the size of the + * largest free area size statistic. + */ + list_for_each_entry(pos, &allocator->free_list.list, list) { + struct memrar_address_range * const fr = &pos->range; + size_t const curr_size = fr->end - fr->begin; + + if (curr_size >= reserved_bytes && addr == 0) { + struct memrar_address_range *range = NULL; + struct memrar_address_ranges * const new_node = + kmalloc(sizeof(*new_node), GFP_KERNEL); + + if (new_node == NULL) + break; + + list_add(&new_node->list, + &allocator->allocated_list.list); + + /* + * Carve out area of memory from end of free + * range. + */ + range = &new_node->range; + range->end = fr->end; + fr->end -= reserved_bytes; + range->begin = fr->end; + addr = range->begin; + + /* + * Check if largest area has decreased in + * size. We'll need to continue scanning for + * the next largest area if it has. + */ + if (curr_size == allocator->largest_free_area) + allocator->largest_free_area -= + reserved_bytes; + else + break; + } + + /* + * Reset largest free area size statistic as needed, + * but only if we've actually allocated memory. + */ + if (addr != 0 + && curr_size > allocator->largest_free_area) { + allocator->largest_free_area = curr_size; + break; + } + } + + mutex_unlock(&allocator->lock); + + return addr; +} + +long memrar_allocator_free(struct memrar_allocator *allocator, + unsigned long addr) +{ + struct list_head *pos = NULL; + struct list_head *tmp = NULL; + struct list_head *dst = NULL; + + struct memrar_address_ranges *allocated = NULL; + struct memrar_address_range const *handle = NULL; + + unsigned long old_end = 0; + unsigned long new_chunk_size = 0; + + if (allocator == NULL) + return -EINVAL; + + if (addr == 0) + return 0; /* Ignore "free(0)". */ + + mutex_lock(&allocator->lock); + + /* Find the corresponding handle. */ + list_for_each_entry(allocated, + &allocator->allocated_list.list, + list) { + if (allocated->range.begin == addr) { + handle = &allocated->range; + break; + } + } + + /* No such buffer created by this allocator. */ + if (handle == NULL) { + mutex_unlock(&allocator->lock); + return -EFAULT; + } + + /* + * Coalesce adjacent chunks of memory if possible. + * + * @note This isn't full blown coalescing since we're only + * coalescing at most three chunks of memory. + */ + list_for_each_safe(pos, tmp, &allocator->free_list.list) { + /* @todo O(n) performance. Optimize. */ + + struct memrar_address_range * const chunk = + &list_entry(pos, + struct memrar_address_ranges, + list)->range; + + /* Extend size of existing free adjacent chunk. */ + if (chunk->end == handle->begin) { + /* + * Chunk "less than" than the one we're + * freeing is adjacent. + * + * Before: + * + * +-----+------+ + * |chunk|handle| + * +-----+------+ + * + * After: + * + * +------------+ + * | chunk | + * +------------+ + */ + + struct memrar_address_ranges const * const next = + list_entry(pos->next, + struct memrar_address_ranges, + list); + + chunk->end = handle->end; + + /* + * Now check if next free chunk is adjacent to + * the current extended free chunk. + * + * Before: + * + * +------------+----+ + * | chunk |next| + * +------------+----+ + * + * After: + * + * +-----------------+ + * | chunk | + * +-----------------+ + */ + if (!list_is_singular(pos) + && chunk->end == next->range.begin) { + chunk->end = next->range.end; + list_del(pos->next); + kfree(next); + } + + list_del(&allocated->list); + + new_chunk_size = chunk->end - chunk->begin; + + goto exit_memrar_free; + + } else if (handle->end == chunk->begin) { + /* + * Chunk "greater than" than the one we're + * freeing is adjacent. + * + * +------+-----+ + * |handle|chunk| + * +------+-----+ + * + * After: + * + * +------------+ + * | chunk | + * +------------+ + */ + + struct memrar_address_ranges const * const prev = + list_entry(pos->prev, + struct memrar_address_ranges, + list); + + chunk->begin = handle->begin; + + /* + * Now check if previous free chunk is + * adjacent to the current extended free + * chunk. + * + * + * Before: + * + * +----+------------+ + * |prev| chunk | + * +----+------------+ + * + * After: + * + * +-----------------+ + * | chunk | + * +-----------------+ + */ + if (!list_is_singular(pos) + && prev->range.end == chunk->begin) { + chunk->begin = prev->range.begin; + list_del(pos->prev); + kfree(prev); + } + + list_del(&allocated->list); + + new_chunk_size = chunk->end - chunk->begin; + + goto exit_memrar_free; + + } else if (chunk->end < handle->begin + && chunk->end > old_end) { + /* Keep track of where the entry could be + * potentially moved from the "allocated" list + * to the "free" list if coalescing doesn't + * occur, making sure the "free" list remains + * sorted. + */ + old_end = chunk->end; + dst = pos; + } + } + + /* + * Nothing to coalesce. + * + * Move the entry from the "allocated" list to the "free" + * list. + */ + list_move(&allocated->list, dst); + new_chunk_size = handle->end - handle->begin; + allocated = NULL; + +exit_memrar_free: + + if (new_chunk_size > allocator->largest_free_area) + allocator->largest_free_area = new_chunk_size; + + mutex_unlock(&allocator->lock); + + kfree(allocated); + + return 0; +} + + + +/* + Local Variables: + c-file-style: "linux" + End: +*/ diff --git a/drivers/staging/memrar/memrar_allocator.h b/drivers/staging/memrar/memrar_allocator.h new file mode 100644 index 000000000000..0b80dead710f --- /dev/null +++ b/drivers/staging/memrar/memrar_allocator.h @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2010 Intel Corporation. All rights reserved. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * The full GNU General Public License is included in this + * distribution in the file called COPYING. + */ + +#ifndef MEMRAR_ALLOCATOR_H +#define MEMRAR_ALLOCATOR_H + + +#include <linux/mutex.h> +#include <linux/list.h> +#include <linux/types.h> +#include <linux/kernel.h> + + +/** + * struct memrar_address_range - struct that describes a memory range + * @begin: Beginning of available address range. + * @end: End of available address range, one past the end, + * i.e. [begin, end). + */ +struct memrar_address_range { +/* private: internal use only */ + unsigned long begin; + unsigned long end; +}; + +/** + * struct memrar_address_ranges - list of areas of memory. + * @list: Linked list of address ranges. + * @range: Memory address range corresponding to given list node. + */ +struct memrar_address_ranges { +/* private: internal use only */ + struct list_head list; + struct memrar_address_range range; +}; + +/** + * struct memrar_allocator - encapsulation of the memory allocator state + * @lock: Lock used to synchronize access to the memory + * allocator state. + * @base: Base (start) address of the allocator memory + * space. + * @capacity: Size of the allocator memory space in bytes. + * @block_size: The size in bytes of individual blocks within + * the allocator memory space. + * @largest_free_area: Largest free area of memory in the allocator + * in bytes. + * @allocated_list: List of allocated memory block address + * ranges. + * @free_list: List of free address ranges. + * + * This structure contains all memory allocator state, including the + * base address, capacity, free list, lock, etc. + */ +struct memrar_allocator { +/* private: internal use only */ + struct mutex lock; + unsigned long base; + size_t capacity; + size_t block_size; + size_t largest_free_area; + struct memrar_address_ranges allocated_list; + struct memrar_address_ranges free_list; +}; + +/** + * memrar_create_allocator() - create a memory allocator + * @base: Address at which the memory allocator begins. + * @capacity: Desired size of the memory allocator. This value must + * be larger than the block_size, ideally more than twice + * as large since there wouldn't be much point in using a + * memory allocator otherwise. + * @block_size: The size of individual blocks within the memory + * allocator. This value must smaller than the + * capacity. + * + * Create a memory allocator with the given capacity and block size. + * The capacity will be reduced to be a multiple of the block size, if + * necessary. + * + * Returns an instance of the memory allocator, if creation succeeds, + * otherwise zero if creation fails. Failure may occur if not enough + * kernel memory exists to create the memrar_allocator instance + * itself, or if the capacity and block_size arguments are not + * compatible or make sense. + */ +struct memrar_allocator *memrar_create_allocator(unsigned long base, + size_t capacity, + size_t block_size); + +/** + * memrar_destroy_allocator() - destroy allocator + * @allocator: The allocator being destroyed. + * + * Reclaim resources held by the memory allocator. The caller must + * explicitly free all memory reserved by memrar_allocator_alloc() + * prior to calling this function. Otherwise leaks will occur. + */ +void memrar_destroy_allocator(struct memrar_allocator *allocator); + +/** + * memrar_allocator_alloc() - reserve an area of memory of given size + * @allocator: The allocator instance being used to reserve buffer. + * @size: The size in bytes of the buffer to allocate. + * + * This functions reserves an area of memory managed by the given + * allocator. It returns zero if allocation was not possible. + * Failure may occur if the allocator no longer has space available. + */ +unsigned long memrar_allocator_alloc(struct memrar_allocator *allocator, + size_t size); + +/** + * memrar_allocator_free() - release buffer starting at given address + * @allocator: The allocator instance being used to release the buffer. + * @address: The address of the buffer being released. + * + * Release an area of memory starting at the given address. Failure + * could occur if the given address is not in the address space + * managed by the allocator. Returns zero on success or an errno + * (negative value) on failure. + */ +long memrar_allocator_free(struct memrar_allocator *allocator, + unsigned long address); + +#endif /* MEMRAR_ALLOCATOR_H */ + + +/* + Local Variables: + c-file-style: "linux" + End: +*/ diff --git a/drivers/staging/memrar/memrar_handler.c b/drivers/staging/memrar/memrar_handler.c new file mode 100644 index 000000000000..3e0dfe365769 --- /dev/null +++ b/drivers/staging/memrar/memrar_handler.c @@ -0,0 +1,937 @@ +/* + * memrar_handler 1.0: An Intel restricted access region handler device + * + * Copyright (C) 2010 Intel Corporation. All rights reserved. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * The full GNU General Public License is included in this + * distribution in the file called COPYING. + * + * ------------------------------------------------------------------- + * + * Moorestown restricted access regions (RAR) provide isolated + * areas of main memory that are only acceessible by authorized + * devices. + * + * The Intel Moorestown RAR handler module exposes a kernel space + * RAR memory management mechanism. It is essentially a + * RAR-specific allocator. + * + * Besides providing RAR buffer management, the RAR handler also + * behaves in many ways like an OS virtual memory manager. For + * example, the RAR "handles" created by the RAR handler are + * analogous to user space virtual addresses. + * + * RAR memory itself is never accessed directly by the RAR + * handler. + */ + +#include <linux/miscdevice.h> +#include <linux/fs.h> +#include <linux/slab.h> +#include <linux/kref.h> +#include <linux/mutex.h> +#include <linux/kernel.h> +#include <linux/uaccess.h> +#include <linux/mm.h> +#include <linux/ioport.h> +#include <linux/io.h> + +#include "../rar_register/rar_register.h" + +#include "memrar.h" +#include "memrar_allocator.h" + + +#define MEMRAR_VER "1.0" + +/* + * Moorestown supports three restricted access regions. + * + * We only care about the first two, video and audio. The third, + * reserved for Chaabi and the P-unit, will be handled by their + * respective drivers. + */ +#define MRST_NUM_RAR 2 + +/* ---------------- -------------------- ------------------- */ + +/** + * struct memrar_buffer_info - struct that keeps track of all RAR buffers + * @list: Linked list of memrar_buffer_info objects. + * @buffer: Core RAR buffer information. + * @refcount: Reference count. + * @owner: File handle corresponding to process that reserved the + * block of memory in RAR. This will be zero for buffers + * allocated by other drivers instead of by a user space + * process. + * + * This structure encapsulates a link list of RAR buffers, as well as + * other characteristics specific to a given list node, such as the + * reference count on the corresponding RAR buffer. + */ +struct memrar_buffer_info { + struct list_head list; + struct RAR_buffer buffer; + struct kref refcount; + struct file *owner; +}; + +/** + * struct memrar_rar_info - characteristics of a given RAR + * @base: Base bus address of the RAR. + * @length: Length of the RAR. + * @iobase: Virtual address of RAR mapped into kernel. + * @allocator: Allocator associated with the RAR. Note the allocator + * "capacity" may be smaller than the RAR length if the + * length is not a multiple of the configured allocator + * block size. + * @buffers: Table that keeps track of all reserved RAR buffers. + * @lock: Lock used to synchronize access to RAR-specific data + * structures. + * + * Each RAR has an associated memrar_rar_info structure that describes + * where in memory the RAR is located, how large it is, and a list of + * reserved RAR buffers inside that RAR. Each RAR also has a mutex + * associated with it to reduce lock contention when operations on + * multiple RARs are performed in parallel. + */ +struct memrar_rar_info { + dma_addr_t base; + unsigned long length; + void __iomem *iobase; + struct memrar_allocator *allocator; + struct memrar_buffer_info buffers; + struct mutex lock; +}; + +/* + * Array of RAR characteristics. + */ +static struct memrar_rar_info memrars[MRST_NUM_RAR]; + +/* ---------------- -------------------- ------------------- */ + +/* Validate RAR type. */ +static inline int memrar_is_valid_rar_type(u32 type) +{ + return type == RAR_TYPE_VIDEO || type == RAR_TYPE_AUDIO; +} + +/* Check if an address/handle falls with the given RAR memory range. */ +static inline int memrar_handle_in_range(struct memrar_rar_info *rar, + u32 vaddr) +{ + unsigned long const iobase = (unsigned long) (rar->iobase); + return (vaddr >= iobase && vaddr < iobase + rar->length); +} + +/* Retrieve RAR information associated with the given handle. */ +static struct memrar_rar_info *memrar_get_rar_info(u32 vaddr) +{ + int i; + for (i = 0; i < MRST_NUM_RAR; ++i) { + struct memrar_rar_info * const rar = &memrars[i]; + if (memrar_handle_in_range(rar, vaddr)) + return rar; + } + + return NULL; +} + +/* + * Retrieve bus address from given handle. + * + * Returns address corresponding to given handle. Zero if handle is + * invalid. + */ +static dma_addr_t memrar_get_bus_address( + struct memrar_rar_info *rar, + u32 vaddr) +{ + unsigned long const iobase = (unsigned long) (rar->iobase); + + if (!memrar_handle_in_range(rar, vaddr)) + return 0; + + /* + * An assumption is made that the virtual address offset is + * the same as the bus address offset, at least based on the + * way this driver is implemented. For example, vaddr + 2 == + * baddr + 2. + * + * @todo Is that a valid assumption? + */ + return rar->base + (vaddr - iobase); +} + +/* + * Retrieve physical address from given handle. + * + * Returns address corresponding to given handle. Zero if handle is + * invalid. + */ +static dma_addr_t memrar_get_physical_address( + struct memrar_rar_info *rar, + u32 vaddr) +{ + /* + * @todo This assumes that the bus address and physical + * address are the same. That is true for Moorestown + * but not necessarily on other platforms. This + * deficiency should be addressed at some point. + */ + return memrar_get_bus_address(rar, vaddr); +} + +/* + * Core block release code. + * + * Note: This code removes the node from a list. Make sure any list + * iteration is performed using list_for_each_safe(). + */ +static void memrar_release_block_i(struct kref *ref) +{ + /* + * Last reference is being released. Remove from the table, + * and reclaim resources. + */ + + struct memrar_buffer_info * const node = + container_of(ref, struct memrar_buffer_info, refcount); + + struct RAR_block_info * const user_info = + &node->buffer.info; + + struct memrar_allocator * const allocator = + memrars[user_info->type].allocator; + + list_del(&node->list); + + memrar_allocator_free(allocator, user_info->handle); + + kfree(node); +} + +/* + * Initialize RAR parameters, such as bus addresses, etc. + */ +static int memrar_init_rar_resources(char const *devname) +{ + /* ---- Sanity Checks ---- + * 1. RAR bus addresses in both Lincroft and Langwell RAR + * registers should be the same. + * a. There's no way we can do this through IA. + * + * 2. Secure device ID in Langwell RAR registers should be set + * appropriately, e.g. only LPE DMA for the audio RAR, and + * security for the other Langwell based RAR registers. + * a. There's no way we can do this through IA. + * + * 3. Audio and video RAR registers and RAR access should be + * locked down. If not, enable RAR access control. Except + * for debugging purposes, there is no reason for them to + * be unlocked. + * a. We can only do this for the Lincroft (IA) side. + * + * @todo Should the RAR handler driver even be aware of audio + * and video RAR settings? + */ + + /* + * RAR buffer block size. + * + * We choose it to be the size of a page to simplify the + * /dev/memrar mmap() implementation and usage. Otherwise + * paging is not involved once an RAR is locked down. + */ + static size_t const RAR_BLOCK_SIZE = PAGE_SIZE; + + int z; + int found_rar = 0; + + BUG_ON(MRST_NUM_RAR != ARRAY_SIZE(memrars)); + + for (z = 0; z != MRST_NUM_RAR; ++z) { + dma_addr_t low, high; + struct memrar_rar_info * const rar = &memrars[z]; + + BUG_ON(!memrar_is_valid_rar_type(z)); + + mutex_init(&rar->lock); + + /* + * Initialize the process table before we reach any + * code that exit on failure since the finalization + * code requires an initialized list. + */ + INIT_LIST_HEAD(&rar->buffers.list); + + if (rar_get_address(z, &low, &high) != 0) { + /* No RAR is available. */ + break; + } else if (low == 0 || high == 0) { + /* + * We don't immediately break out of the loop + * since the next type of RAR may be enabled. + */ + rar->base = 0; + rar->length = 0; + rar->iobase = NULL; + rar->allocator = NULL; + continue; + } + + /* + * @todo Verify that LNC and LNW RAR register contents + * addresses, security, etc are compatible and + * consistent). + */ + + rar->length = high - low + 1; + + /* Claim RAR memory as our own. */ + if (request_mem_region(low, rar->length, devname) == NULL) { + rar->length = 0; + + pr_err("%s: Unable to claim RAR[%d] memory.\n", + devname, + z); + pr_err("%s: RAR[%d] disabled.\n", devname, z); + + /* + * Rather than break out of the loop by + * returning -EBUSY, for example, we may be + * able to claim memory of the next RAR region + * as our own. + */ + continue; + } + + rar->base = low; + + /* + * Now map it into the kernel address space. + * + * Note that the RAR memory may only be accessed by IA + * when debugging. Otherwise attempts to access the + * RAR memory when it is locked down will result in + * behavior similar to writing to /dev/null and + * reading from /dev/zero. This behavior is enforced + * by the hardware. Even if we don't access the + * memory, mapping it into the kernel provides us with + * a convenient RAR handle to bus address mapping. + */ + rar->iobase = ioremap_nocache(rar->base, rar->length); + if (rar->iobase == NULL) { + pr_err("%s: Unable to map RAR memory.\n", + devname); + return -ENOMEM; + } + + /* Initialize corresponding memory allocator. */ + rar->allocator = memrar_create_allocator( + (unsigned long) rar->iobase, + rar->length, + RAR_BLOCK_SIZE); + if (rar->allocator == NULL) + return -1; + + /* + * ------------------------------------------------- + * Make sure all RARs handled by us are locked down. + * ------------------------------------------------- + */ + + /* Enable RAR protection on the Lincroft side. */ + if (0) { + /* + * This is mostly a sanity check since the + * vendor should have locked down RAR in the + * SMIP header RAR configuration. + */ + rar_lock(z); + } else { + pr_warning("%s: LNC RAR[%d] no lock sanity check.\n", + devname, + z); + } + + /* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */ + /* |||||||||||||||||||||||||||||||||||||||||||||||||| */ + + /* + * It would be nice if we could verify that RAR + * protection on the Langwell side is enabled, but + * there is no way to do that from here. The + * necessary Langwell RAR registers are not accessible + * from the Lincroft (IA) side. + * + * Hopefully the ODM did the right thing and enabled + * Langwell side RAR protection in the integrated + * firmware SMIP header. + */ + + pr_info("%s: BRAR[%d] bus address range = " + "[0x%lx, 0x%lx]\n", + devname, + z, + (unsigned long) low, + (unsigned long) high); + + pr_info("%s: BRAR[%d] size = %zu KiB\n", + devname, + z, + rar->allocator->capacity / 1024); + + found_rar = 1; + } + + if (!found_rar) { + /* + * No RAR support. Don't bother continuing. + * + * Note that this is not a failure. + */ + pr_info("%s: No Moorestown RAR support available.\n", + devname); + return -ENODEV; + } + + return 0; +} + +/* + * Finalize RAR resources. + */ +static void memrar_fini_rar_resources(void) +{ + int z; + struct memrar_buffer_info *pos; + struct memrar_buffer_info *tmp; + + /* + * @todo Do we need to hold a lock at this point in time? + * (module initialization failure or exit?) + */ + + for (z = MRST_NUM_RAR; z-- != 0; ) { + struct memrar_rar_info * const rar = &memrars[z]; + + /* Clean up remaining resources. */ + + list_for_each_entry_safe(pos, + tmp, + &rar->buffers.list, + list) { + kref_put(&pos->refcount, memrar_release_block_i); + } + + memrar_destroy_allocator(rar->allocator); + rar->allocator = NULL; + + iounmap(rar->iobase); + rar->iobase = NULL; + + release_mem_region(rar->base, rar->length); + rar->base = 0; + + rar->length = 0; + } +} + +static long memrar_reserve_block(struct RAR_buffer *request, + struct file *filp) +{ + struct RAR_block_info * const rinfo = &request->info; + struct RAR_buffer *buffer; + struct memrar_buffer_info *buffer_info; + u32 handle; + struct memrar_rar_info *rar = NULL; + + /* Prevent array overflow. */ + if (!memrar_is_valid_rar_type(rinfo->type)) + return -EINVAL; + + rar = &memrars[rinfo->type]; + + /* Reserve memory in RAR. */ + handle = memrar_allocator_alloc(rar->allocator, rinfo->size); + if (handle == 0) + return -ENOMEM; + + buffer_info = kmalloc(sizeof(*buffer_info), GFP_KERNEL); + + if (buffer_info == NULL) { + memrar_allocator_free(rar->allocator, handle); + return -ENOMEM; + } + + buffer = &buffer_info->buffer; + buffer->info.type = rinfo->type; + buffer->info.size = rinfo->size; + + /* Memory handle corresponding to the bus address. */ + buffer->info.handle = handle; + buffer->bus_address = memrar_get_bus_address(rar, handle); + + /* + * Keep track of owner so that we can later cleanup if + * necessary. + */ + buffer_info->owner = filp; + + kref_init(&buffer_info->refcount); + + mutex_lock(&rar->lock); + list_add(&buffer_info->list, &rar->buffers.list); + mutex_unlock(&rar->lock); + + rinfo->handle = buffer->info.handle; + request->bus_address = buffer->bus_address; + + return 0; +} + +static long memrar_release_block(u32 addr) +{ + struct memrar_buffer_info *pos; + struct memrar_buffer_info *tmp; + struct memrar_rar_info * const rar = memrar_get_rar_info(addr); + long result = -EINVAL; + + if (rar == NULL) + return -EFAULT; + + mutex_lock(&rar->lock); + + /* + * Iterate through the buffer list to find the corresponding + * buffer to be released. + */ + list_for_each_entry_safe(pos, + tmp, + &rar->buffers.list, + list) { + struct RAR_block_info * const info = + &pos->buffer.info; + + /* + * Take into account handle offsets that may have been + * added to the base handle, such as in the following + * scenario: + * + * u32 handle = base + offset; + * rar_handle_to_bus(handle); + * rar_release(handle); + */ + if (addr >= info->handle + && addr < (info->handle + info->size) + && memrar_is_valid_rar_type(info->type)) { + kref_put(&pos->refcount, memrar_release_block_i); + result = 0; + break; + } + } + + mutex_unlock(&rar->lock); + + return result; +} + +static long memrar_get_stat(struct RAR_stat *r) +{ + long result = -EINVAL; + + if (likely(r != NULL) && memrar_is_valid_rar_type(r->type)) { + struct memrar_allocator * const allocator = + memrars[r->type].allocator; + + BUG_ON(allocator == NULL); + + /* + * Allocator capacity doesn't change over time. No + * need to synchronize. + */ + r->capacity = allocator->capacity; + + mutex_lock(&allocator->lock); + + r->largest_block_size = allocator->largest_free_area; + + mutex_unlock(&allocator->lock); + + result = 0; + } + + return result; +} + +static long memrar_ioctl(struct file *filp, + unsigned int cmd, + unsigned long arg) +{ + void __user *argp = (void __user *)arg; + long result = 0; + + struct RAR_buffer buffer; + struct RAR_block_info * const request = &buffer.info; + struct RAR_stat rar_info; + u32 rar_handle; + + switch (cmd) { + case RAR_HANDLER_RESERVE: + if (copy_from_user(request, + argp, + sizeof(*request))) + return -EFAULT; + + result = memrar_reserve_block(&buffer, filp); + if (result != 0) + return result; + + return copy_to_user(argp, request, sizeof(*request)); + + case RAR_HANDLER_RELEASE: + if (copy_from_user(&rar_handle, + argp, + sizeof(rar_handle))) + return -EFAULT; + + return memrar_release_block(rar_handle); + + case RAR_HANDLER_STAT: + if (copy_from_user(&rar_info, + argp, + sizeof(rar_info))) + return -EFAULT; + + /* + * Populate the RAR_stat structure based on the RAR + * type given by the user + */ + if (memrar_get_stat(&rar_info) != 0) + return -EINVAL; + + /* + * @todo Do we need to verify destination pointer + * "argp" is non-zero? Is that already done by + * copy_to_user()? + */ + return copy_to_user(argp, + &rar_info, + sizeof(rar_info)) ? -EFAULT : 0; + + default: + return -ENOTTY; + } + + return 0; +} + +static int memrar_mmap(struct file *filp, struct vm_area_struct *vma) +{ + /* + * This mmap() implementation is predominantly useful for + * debugging since the CPU will be prevented from accessing + * RAR memory by the hardware when RAR is properly locked + * down. + * + * In order for this implementation to be useful RAR memory + * must be not be locked down. However, we only want to do + * that when debugging. DO NOT leave RAR memory unlocked in a + * deployed device that utilizes RAR. + */ + + size_t const size = vma->vm_end - vma->vm_start; + + /* Users pass the RAR handle as the mmap() offset parameter. */ + unsigned long const handle = vma->vm_pgoff << PAGE_SHIFT; + + struct memrar_rar_info * const rar = memrar_get_rar_info(handle); + + unsigned long pfn; + + /* Invalid RAR handle or size passed to mmap(). */ + if (rar == NULL + || handle == 0 + || size > (handle - (unsigned long) rar->iobase)) + return -EINVAL; + + /* + * Retrieve physical address corresponding to the RAR handle, + * and convert it to a page frame. + */ + pfn = memrar_get_physical_address(rar, handle) >> PAGE_SHIFT; + + + pr_debug("memrar: mapping RAR range [0x%lx, 0x%lx) into user space.\n", + handle, + handle + size); + + /* + * Map RAR memory into user space. This is really only useful + * for debugging purposes since the memory won't be + * accessible, i.e. reads return zero and writes are ignored, + * when RAR access control is enabled. + */ + if (remap_pfn_range(vma, + vma->vm_start, + pfn, + size, + vma->vm_page_prot)) + return -EAGAIN; + + /* vma->vm_ops = &memrar_mem_ops; */ + + return 0; +} + +static int memrar_open(struct inode *inode, struct file *filp) +{ + /* Nothing to do yet. */ + + return 0; +} + +static int memrar_release(struct inode *inode, struct file *filp) +{ + /* Free all regions associated with the given file handle. */ + + struct memrar_buffer_info *pos; + struct memrar_buffer_info *tmp; + int z; + + for (z = 0; z != MRST_NUM_RAR; ++z) { + struct memrar_rar_info * const rar = &memrars[z]; + + mutex_lock(&rar->lock); + + list_for_each_entry_safe(pos, + tmp, + &rar->buffers.list, + list) { + if (filp == pos->owner) + kref_put(&pos->refcount, + memrar_release_block_i); + } + + mutex_unlock(&rar->lock); + } + + return 0; +} + +/* + * This function is part of the kernel space memrar driver API. + */ +size_t rar_reserve(struct RAR_buffer *buffers, size_t count) +{ + struct RAR_buffer * const end = + (buffers == NULL ? buffers : buffers + count); + struct RAR_buffer *i; + + size_t reserve_count = 0; + + for (i = buffers; i != end; ++i) { + if (memrar_reserve_block(i, NULL) == 0) + ++reserve_count; + else + i->bus_address = 0; + } + + return reserve_count; +} +EXPORT_SYMBOL(rar_reserve); + +/* + * This function is part of the kernel space memrar driver API. + */ +size_t rar_release(struct RAR_buffer *buffers, size_t count) +{ + struct RAR_buffer * const end = + (buffers == NULL ? buffers : buffers + count); + struct RAR_buffer *i; + + size_t release_count = 0; + + for (i = buffers; i != end; ++i) { + u32 * const handle = &i->info.handle; + if (memrar_release_block(*handle) == 0) { + /* + * @todo We assume we should do this each time + * the ref count is decremented. Should + * we instead only do this when the ref + * count has dropped to zero, and the + * buffer has been completely + * released/unmapped? + */ + *handle = 0; + ++release_count; + } + } + + return release_count; +} +EXPORT_SYMBOL(rar_release); + +/* + * This function is part of the kernel space driver API. + */ +size_t rar_handle_to_bus(struct RAR_buffer *buffers, size_t count) +{ + struct RAR_buffer * const end = + (buffers == NULL ? buffers : buffers + count); + struct RAR_buffer *i; + struct memrar_buffer_info *pos; + + size_t conversion_count = 0; + + /* + * Find all bus addresses corresponding to the given handles. + * + * @todo Not liking this nested loop. Optimize. + */ + for (i = buffers; i != end; ++i) { + struct memrar_rar_info * const rar = + memrar_get_rar_info(i->info.handle); + + /* + * Check if we have a bogus handle, and then continue + * with remaining buffers. + */ + if (rar == NULL) { + i->bus_address = 0; + continue; + } + + mutex_lock(&rar->lock); + + list_for_each_entry(pos, &rar->buffers.list, list) { + struct RAR_block_info * const user_info = + &pos->buffer.info; + + /* + * Take into account handle offsets that may + * have been added to the base handle, such as + * in the following scenario: + * + * u32 handle = base + offset; + * rar_handle_to_bus(handle); + */ + + if (i->info.handle >= user_info->handle + && i->info.handle < (user_info->handle + + user_info->size)) { + u32 const offset = + i->info.handle - user_info->handle; + + i->info.type = user_info->type; + i->info.size = user_info->size - offset; + i->bus_address = + pos->buffer.bus_address + + offset; + + /* Increment the reference count. */ + kref_get(&pos->refcount); + + ++conversion_count; + break; + } else { + i->bus_address = 0; + } + } + + mutex_unlock(&rar->lock); + } + + return conversion_count; +} +EXPORT_SYMBOL(rar_handle_to_bus); + +static const struct file_operations memrar_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = memrar_ioctl, + .mmap = memrar_mmap, + .open = memrar_open, + .release = memrar_release, +}; + +static struct miscdevice memrar_miscdev = { + .minor = MISC_DYNAMIC_MINOR, /* dynamic allocation */ + .name = "memrar", /* /dev/memrar */ + .fops = &memrar_fops +}; + +static char const banner[] __initdata = + KERN_INFO + "Intel RAR Handler: " MEMRAR_VER " initialized.\n"; + +static int memrar_registration_callback(void *ctx) +{ + /* + * We initialize the RAR parameters early on so that we can + * discontinue memrar device initialization and registration + * if suitably configured RARs are not available. + */ + int result = memrar_init_rar_resources(memrar_miscdev.name); + + if (result != 0) + return result; + + result = misc_register(&memrar_miscdev); + + if (result != 0) { + pr_err("%s: misc_register() failed.\n", + memrar_miscdev.name); + + /* Clean up resources previously reserved. */ + memrar_fini_rar_resources(); + } + + return result; +} + +static int __init memrar_init(void) +{ + printk(banner); + + return register_rar(&memrar_registration_callback, 0); +} + +static void __exit memrar_exit(void) +{ + memrar_fini_rar_resources(); + + misc_deregister(&memrar_miscdev); +} + + +module_init(memrar_init); +module_exit(memrar_exit); + + +MODULE_AUTHOR("Ossama Othman <ossama.othman@intel.com>"); +MODULE_DESCRIPTION("Intel Restricted Access Region Handler"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS_MISCDEV(MISC_DYNAMIC_MINOR); +MODULE_VERSION(MEMRAR_VER); + + + +/* + Local Variables: + c-file-style: "linux" + End: +*/ diff --git a/drivers/staging/netwave/netwave_cs.c b/drivers/staging/netwave/netwave_cs.c index f1ee2cbc8407..d770fb1ebf11 100644 --- a/drivers/staging/netwave/netwave_cs.c +++ b/drivers/staging/netwave/netwave_cs.c @@ -1,5 +1,5 @@ /********************************************************************* - * + * * Filename: netwave_cs.c * Version: 0.4.1 * Description: Netwave AirSurfer Wireless LAN PC Card driver @@ -10,27 +10,27 @@ * Created at: A long time ago! * Modified at: Mon Nov 10 11:54:37 1997 * Modified by: Dag Brattli <dagb@cs.uit.no> - * + * * Copyright (c) 1997 University of Tromsø, Norway * * Revision History: * * 08-Nov-97 15:14:47 John Markus Bjørndalen <johnm@cs.uit.no> - * - Fixed some bugs in netwave_rx and cleaned it up a bit. + * - Fixed some bugs in netwave_rx and cleaned it up a bit. * (One of the bugs would have destroyed packets when receiving - * multiple packets per interrupt). - * - Cleaned up parts of newave_hw_xmit. - * - A few general cleanups. + * multiple packets per interrupt). + * - Cleaned up parts of newave_hw_xmit. + * - A few general cleanups. * 24-Oct-97 13:17:36 Dag Brattli <dagb@cs.uit.no> * - Fixed netwave_rx receive function (got updated docs) * Others: - * - Changed name from xircnw to netwave, take a look at + * - Changed name from xircnw to netwave, take a look at * http://www.netwave-wireless.com * - Some reorganizing of the code * - Removed possible race condition between interrupt handler and transmit * function * - Started to add wireless extensions, but still needs some coding - * - Added watchdog for better handling of transmission timeouts + * - Added watchdog for better handling of transmission timeouts * (hopefully this works better) ********************************************************************/ @@ -100,7 +100,7 @@ /* * Commands used in the extended command buffer - * NETWAVE_EREG_CB (0x100-0x10F) + * NETWAVE_EREG_CB (0x100-0x10F) */ #define NETWAVE_CMD_NOP 0x00 #define NETWAVE_CMD_SRC 0x01 @@ -132,7 +132,7 @@ static const unsigned int corConfIENA = 0x01; /* Interrupt enable */ static const unsigned int corConfLVLREQ = 0x40; /* Keep high */ static const unsigned int rxConfRxEna = 0x80; /* Receive Enable */ -static const unsigned int rxConfMAC = 0x20; /* MAC host receive mode*/ +static const unsigned int rxConfMAC = 0x20; /* MAC host receive mode*/ static const unsigned int rxConfPro = 0x10; /* Promiscuous */ static const unsigned int rxConfAMP = 0x08; /* Accept Multicast Packets */ static const unsigned int rxConfBcast = 0x04; /* Accept Broadcast Packets */ @@ -151,15 +151,15 @@ static const unsigned int txConfLoop = 0x01; /* Loopback mode */ /* Choose the domain, default is 0x100 */ static u_int domain = 0x100; -/* Scramble key, range from 0x0 to 0xffff. - * 0x0 is no scrambling. +/* Scramble key, range from 0x0 to 0xffff. + * 0x0 is no scrambling. */ static u_int scramble_key = 0x0; -/* Shared memory speed, in ns. The documentation states that - * the card should not be read faster than every 400ns. - * This timing should be provided by the HBA. If it becomes a - * problem, try setting mem_speed to 400. +/* Shared memory speed, in ns. The documentation states that + * the card should not be read faster than every 400ns. + * This timing should be provided by the HBA. If it becomes a + * problem, try setting mem_speed to 400. */ static int mem_speed; @@ -228,7 +228,7 @@ struct site_survey { u_short length; u_char struct_revision; u_char roaming_state; - + u_char sp_existsFlag; u_char sp_link_quality; u_char sp_max_link_quality; @@ -238,12 +238,12 @@ struct site_survey { u_char sp_goodness; u_char sp_hotheadcount; u_char roaming_condition; - + net_addr sp; u_char numAPs; net_addr nearByAccessPoints[MAX_ESA]; -}; - +}; + typedef struct netwave_private { struct pcmcia_device *p_dev; spinlock_t spinlock; /* Serialize access to the hardware (SMP) */ @@ -260,7 +260,7 @@ typedef struct netwave_private { * The Netwave card is little-endian, so won't work for big endian * systems. */ -static inline unsigned short get_uint16(u_char __iomem *staddr) +static inline unsigned short get_uint16(u_char __iomem *staddr) { return readw(staddr); /* Return only 16 bits */ } @@ -270,38 +270,38 @@ static inline short get_int16(u_char __iomem * staddr) return readw(staddr); } -/* - * Wait until the WOC (Write Operation Complete) bit in the - * ASR (Adapter Status Register) is asserted. - * This should have aborted if it takes too long time. +/* + * Wait until the WOC (Write Operation Complete) bit in the + * ASR (Adapter Status Register) is asserted. + * This should have aborted if it takes too long time. */ static inline void wait_WOC(unsigned int iobase) { /* Spin lock */ - while ((inb(iobase + NETWAVE_REG_ASR) & 0x8) != 0x8) ; + while ((inb(iobase + NETWAVE_REG_ASR) & 0x8) != 0x8) ; } -static void netwave_snapshot(netwave_private *priv, u_char __iomem *ramBase, +static void netwave_snapshot(netwave_private *priv, u_char __iomem *ramBase, unsigned int iobase) { u_short resultBuffer; - /* if time since last snapshot is > 1 sec. (100 jiffies?) then take - * new snapshot, else return cached data. This is the recommended rate. + /* if time since last snapshot is > 1 sec. (100 jiffies?) then take + * new snapshot, else return cached data. This is the recommended rate. */ - if ( jiffies - priv->lastExec > 100) { - /* Take site survey snapshot */ + if ( jiffies - priv->lastExec > 100) { + /* Take site survey snapshot */ /*printk( KERN_DEBUG "Taking new snapshot. %ld\n", jiffies - priv->lastExec); */ - wait_WOC(iobase); - writeb(NETWAVE_CMD_SSS, ramBase + NETWAVE_EREG_CB + 0); - writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 1); - wait_WOC(iobase); - - /* Get result and copy to cach */ - resultBuffer = readw(ramBase + NETWAVE_EREG_CRBP); - copy_from_pc( &priv->nss, ramBase+resultBuffer, - sizeof(struct site_survey)); - } + wait_WOC(iobase); + writeb(NETWAVE_CMD_SSS, ramBase + NETWAVE_EREG_CB + 0); + writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 1); + wait_WOC(iobase); + + /* Get result and copy to cach */ + resultBuffer = readw(ramBase + NETWAVE_EREG_CRBP); + copy_from_pc( &priv->nss, ramBase+resultBuffer, + sizeof(struct site_survey)); + } } /* @@ -311,21 +311,21 @@ static void netwave_snapshot(netwave_private *priv, u_char __iomem *ramBase, * */ static struct iw_statistics *netwave_get_wireless_stats(struct net_device *dev) -{ +{ unsigned long flags; unsigned int iobase = dev->base_addr; netwave_private *priv = netdev_priv(dev); u_char __iomem *ramBase = priv->ramBase; struct iw_statistics* wstats; - + wstats = &priv->iw_stats; spin_lock_irqsave(&priv->spinlock, flags); - + netwave_snapshot( priv, ramBase, iobase); wstats->status = priv->nss.roaming_state; - wstats->qual.qual = readb( ramBase + NETWAVE_EREG_SPCQ); + wstats->qual.qual = readb( ramBase + NETWAVE_EREG_SPCQ); wstats->qual.level = readb( ramBase + NETWAVE_EREG_ISPLQ); wstats->qual.noise = readb( ramBase + NETWAVE_EREG_SPU) & 0x3f; wstats->discard.nwid = 0L; @@ -333,7 +333,7 @@ static struct iw_statistics *netwave_get_wireless_stats(struct net_device *dev) wstats->discard.misc = 0L; spin_unlock_irqrestore(&priv->spinlock, flags); - + return &priv->iw_stats; } @@ -351,8 +351,8 @@ static const struct net_device_ops netwave_netdev_ops = { /* * Function netwave_attach (void) * - * Creates an "instance" of the driver, allocating local data - * structures for one device. The device is registered with Card + * Creates an "instance" of the driver, allocating local data + * structures for one device. The device is registered with Card * Services. * * The dev_link structure is initialized, but we don't actually @@ -377,10 +377,10 @@ static int netwave_probe(struct pcmcia_device *link) /* The io structure describes IO port mapping */ link->io.NumPorts1 = 16; link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; - /* link->io.NumPorts2 = 16; + /* link->io.NumPorts2 = 16; link->io.Attributes2 = IO_DATA_PATH_WIDTH_16; */ link->io.IOAddrLines = 5; - + /* General socket configuration */ link->conf.Attributes = CONF_ENABLE_IRQ; link->conf.IntType = INT_MEMORY_AND_IO; @@ -452,7 +452,7 @@ static int netwave_set_nwid(struct net_device *dev, if(!wrqu->nwid.disabled) { domain = wrqu->nwid.value; - printk( KERN_DEBUG "Setting domain to 0x%x%02x\n", + printk( KERN_DEBUG "Setting domain to 0x%x%02x\n", (domain >> 8) & 0x01, domain & 0xff); wait_WOC(iobase); writeb(NETWAVE_CMD_SMD, ramBase + NETWAVE_EREG_CB + 0); @@ -463,7 +463,7 @@ static int netwave_set_nwid(struct net_device *dev, /* ReEnable interrupts & restore flags */ spin_unlock_irqrestore(&priv->spinlock, flags); - + return 0; } @@ -506,7 +506,7 @@ static int netwave_set_scramble(struct net_device *dev, /* ReEnable interrupts & restore flags */ spin_unlock_irqrestore(&priv->spinlock, flags); - + return 0; } @@ -561,19 +561,19 @@ static int netwave_get_range(struct net_device *dev, /* Set the Wireless Extension versions */ range->we_version_compiled = WIRELESS_EXT; range->we_version_source = 9; /* Nothing for us in v10 and v11 */ - + /* Set information in the range struct */ range->throughput = 450 * 1000; /* don't argue on this ! */ range->min_nwid = 0x0000; range->max_nwid = 0x01FF; range->num_channels = range->num_frequency = 0; - + range->sensitivity = 0x3F; range->max_qual.qual = 255; range->max_qual.level = 255; range->max_qual.noise = 0; - + range->num_bitrates = 1; range->bitrate[0] = 1000000; /* 1 Mb/s */ @@ -609,7 +609,7 @@ static int netwave_get_snap(struct net_device *dev, /* ReEnable interrupts & restore flags */ spin_unlock_irqrestore(&priv->spinlock, flags); - + return(0); } @@ -620,8 +620,8 @@ static int netwave_get_snap(struct net_device *dev, static const struct iw_priv_args netwave_private_args[] = { /*{ cmd, set_args, get_args, name } */ - { SIOCGIPSNAP, 0, - IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | sizeof(struct site_survey), + { SIOCGIPSNAP, 0, + IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | sizeof(struct site_survey), "getsitesurvey" }, }; @@ -693,9 +693,9 @@ static const struct iw_handler_def netwave_handler_def = /* * Function netwave_pcmcia_config (link) * - * netwave_pcmcia_config() is scheduled to run after a CARD_INSERTION + * netwave_pcmcia_config() is scheduled to run after a CARD_INSERTION * event is received, to configure the PCMCIA socket, and to make the - * device available to the system. + * device available to the system. * */ @@ -753,7 +753,7 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) { ret = pcmcia_request_window(link, &req, &link->win); if (ret) goto failed; - mem.CardOffset = 0x20000; mem.Page = 0; + mem.CardOffset = 0x20000; mem.Page = 0; ret = pcmcia_map_mem_page(link, link->win, &mem); if (ret) goto failed; @@ -778,7 +778,7 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) { netwave_doreset(dev->base_addr, ramBase); /* Read the ethernet address and fill in the Netwave registers. */ - for (i = 0; i < 6; i++) + for (i = 0; i < 6; i++) dev->dev_addr[i] = readb(ramBase + NETWAVE_EREG_PA + i); printk(KERN_INFO "%s: Netwave: port %#3lx, irq %d, mem %lx, " @@ -790,7 +790,7 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) { dev->dev_addr); /* get revision words */ - printk(KERN_DEBUG "Netwave_reset: revision %04x %04x\n", + printk(KERN_DEBUG "Netwave_reset: revision %04x %04x\n", get_uint16(ramBase + NETWAVE_EREG_ARW), get_uint16(ramBase + NETWAVE_EREG_ARW+2)); return 0; @@ -859,7 +859,7 @@ static void netwave_doreset(unsigned int ioBase, u_char __iomem *ramBase) /* * Function netwave_reset (dev) * - * Reset and restore all of the netwave registers + * Reset and restore all of the netwave registers */ static void netwave_reset(struct net_device *dev) { /* u_char state; */ @@ -874,24 +874,24 @@ static void netwave_reset(struct net_device *dev) { /* Reset card */ netwave_doreset(iobase, ramBase); printk(KERN_DEBUG "netwave_reset: Done with hardware reset\n"); - + /* Write a NOP to check the card */ wait_WOC(iobase); writeb(NETWAVE_CMD_NOP, ramBase + NETWAVE_EREG_CB + 0); writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 1); - + /* Set receive conf */ wait_WOC(iobase); writeb(NETWAVE_CMD_SRC, ramBase + NETWAVE_EREG_CB + 0); writeb(rxConfRxEna + rxConfBcast, ramBase + NETWAVE_EREG_CB + 1); writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 2); - + /* Set transmit conf */ wait_WOC(iobase); writeb(NETWAVE_CMD_STC, ramBase + NETWAVE_EREG_CB + 0); writeb(txConfTxEna, ramBase + NETWAVE_EREG_CB + 1); writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 2); - + /* Now set the MU Domain */ printk(KERN_DEBUG "Setting domain to 0x%x%02x\n", (domain >> 8) & 0x01, domain & 0xff); wait_WOC(iobase); @@ -899,7 +899,7 @@ static void netwave_reset(struct net_device *dev) { writeb(domain & 0xff, ramBase + NETWAVE_EREG_CB + 1); writeb((domain>>8) & 0x01, ramBase + NETWAVE_EREG_CB + 2); writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 3); - + /* Set scramble key */ printk(KERN_DEBUG "Setting scramble key to 0x%x\n", scramble_key); wait_WOC(iobase); @@ -909,8 +909,8 @@ static void netwave_reset(struct net_device *dev) { writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 3); /* Enable interrupts, bit 4 high to keep unused - * source from interrupting us, bit 2 high to - * set interrupt enable, 567 to enable TxDN, + * source from interrupting us, bit 2 high to + * set interrupt enable, 567 to enable TxDN, * RxErr and RxRdy */ wait_WOC(iobase); @@ -921,29 +921,29 @@ static void netwave_reset(struct net_device *dev) { * skriv 80 til d000:3688 * sjekk om det ble 80 */ - + /* Enable Receiver */ wait_WOC(iobase); writeb(NETWAVE_CMD_ER, ramBase + NETWAVE_EREG_CB + 0); writeb(NETWAVE_CMD_EOC, ramBase + NETWAVE_EREG_CB + 1); - + /* Set the IENA bit in COR */ wait_WOC(iobase); outb(corConfIENA + corConfLVLREQ, iobase + NETWAVE_REG_COR); } /* - * Function netwave_hw_xmit (data, len, dev) + * Function netwave_hw_xmit (data, len, dev) */ static int netwave_hw_xmit(unsigned char* data, int len, struct net_device* dev) { unsigned long flags; unsigned int TxFreeList, curBuff, - MaxData, + MaxData, DataOffset; - int tmpcount; - + int tmpcount; + netwave_private *priv = netdev_priv(dev); u_char __iomem * ramBase = priv->ramBase; unsigned int iobase = dev->base_addr; @@ -974,23 +974,23 @@ static int netwave_hw_xmit(unsigned char* data, int len, TxFreeList = get_uint16(ramBase + NETWAVE_EREG_TDP); MaxData = get_uint16(ramBase + NETWAVE_EREG_TDP+2); DataOffset = get_uint16(ramBase + NETWAVE_EREG_TDP+4); - + pr_debug("TxFreeList %x, MaxData %x, DataOffset %x\n", TxFreeList, MaxData, DataOffset); /* Copy packet to the adapter fragment buffers */ - curBuff = TxFreeList; - tmpcount = 0; + curBuff = TxFreeList; + tmpcount = 0; while (tmpcount < len) { - int tmplen = len - tmpcount; - copy_to_pc(ramBase + curBuff + DataOffset, data + tmpcount, + int tmplen = len - tmpcount; + copy_to_pc(ramBase + curBuff + DataOffset, data + tmpcount, (tmplen < MaxData) ? tmplen : MaxData); tmpcount += MaxData; - + /* Advance to next buffer */ curBuff = get_uint16(ramBase + curBuff); } - + /* Now issue transmit list */ wait_WOC(iobase); writeb(NETWAVE_CMD_TL, ramBase + NETWAVE_EREG_CB + 0); @@ -1015,7 +1015,7 @@ static netdev_tx_t netwave_start_xmit(struct sk_buff *skb, { short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN; unsigned char* buf = skb->data; - + if (netwave_hw_xmit( buf, length, dev) == 1) { /* Some error, let's make them call us another time? */ netif_start_queue(dev); @@ -1023,7 +1023,7 @@ static netdev_tx_t netwave_start_xmit(struct sk_buff *skb, dev->trans_start = jiffies; } dev_kfree_skb(skb); - + return NETDEV_TX_OK; } /* netwave_start_xmit */ @@ -1031,7 +1031,7 @@ static netdev_tx_t netwave_start_xmit(struct sk_buff *skb, * Function netwave_interrupt (irq, dev_id) * * This function is the interrupt handler for the Netwave card. This - * routine will be called whenever: + * routine will be called whenever: * 1. A packet is received. * 2. A packet has successfully been transferred and the unit is * ready to transmit another packet. @@ -1045,29 +1045,29 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id) struct netwave_private *priv = netdev_priv(dev); struct pcmcia_device *link = priv->p_dev; int i; - + if (!netif_device_present(dev)) return IRQ_NONE; - + iobase = dev->base_addr; ramBase = priv->ramBase; - + /* Now find what caused the interrupt, check while interrupts ready */ for (i = 0; i < 10; i++) { u_char status; - - wait_WOC(iobase); + + wait_WOC(iobase); if (!(inb(iobase+NETWAVE_REG_CCSR) & 0x02)) break; /* None of the interrupt sources asserted (normal exit) */ - + status = inb(iobase + NETWAVE_REG_ASR); - + if (!pcmcia_dev_present(link)) { pr_debug("netwave_interrupt: Interrupt with status 0x%x " "from removed or suspended card!\n", status); break; } - + /* RxRdy */ if (status & 0x80) { netwave_rx(dev); @@ -1077,24 +1077,24 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id) /* RxErr */ if (status & 0x40) { u_char rser; - - rser = readb(ramBase + NETWAVE_EREG_RSER); - + + rser = readb(ramBase + NETWAVE_EREG_RSER); + if (rser & 0x04) { ++dev->stats.rx_dropped; ++dev->stats.rx_crc_errors; } if (rser & 0x02) ++dev->stats.rx_frame_errors; - + /* Clear the RxErr bit in RSER. RSER+4 is the - * write part. Also clear the RxCRC (0x04) and + * write part. Also clear the RxCRC (0x04) and * RxBig (0x02) bits if present */ wait_WOC(iobase); writeb(0x40 | (rser & 0x06), ramBase + NETWAVE_EREG_RSER + 4); /* Write bit 6 high to ASCC to clear RxErr in ASR, - * WOC must be set first! + * WOC must be set first! */ wait_WOC(iobase); writeb(0x40, ramBase + NETWAVE_EREG_ASCC); @@ -1109,31 +1109,31 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id) txStatus = readb(ramBase + NETWAVE_EREG_TSER); pr_debug("Transmit done. TSER = %x id %x\n", txStatus, readb(ramBase + NETWAVE_EREG_TSER + 1)); - + if (txStatus & 0x20) { /* Transmitting was okay, clear bits */ wait_WOC(iobase); writeb(0x2f, ramBase + NETWAVE_EREG_TSER + 4); ++dev->stats.tx_packets; } - + if (txStatus & 0xd0) { if (txStatus & 0x80) { ++dev->stats.collisions; /* Because of /proc/net/dev*/ /* ++dev->stats.tx_aborted_errors; */ /* printk("Collision. %ld\n", jiffies - dev->trans_start); */ } - if (txStatus & 0x40) + if (txStatus & 0x40) ++dev->stats.tx_carrier_errors; /* 0x80 TxGU Transmit giveup - nine times and no luck * 0x40 TxNOAP No access point. Discarded packet. - * 0x10 TxErr Transmit error. Always set when + * 0x10 TxErr Transmit error. Always set when * TxGU and TxNOAP is set. (Those are the only ones * to set TxErr). */ pr_debug("netwave_interrupt: TxDN with error status %x\n", txStatus); - + /* Clear out TxGU, TxNOAP, TxErr and TxTrys */ wait_WOC(iobase); writeb(0xdf & txStatus, ramBase+NETWAVE_EREG_TSER+4); @@ -1185,31 +1185,31 @@ static int netwave_rx(struct net_device *dev) int dataCount, dataOffset; int i; u_char *ptr; - + pr_debug("xinw_rx: Receiving ... \n"); /* Receive max 10 packets for now. */ for (i = 0; i < 10; i++) { /* Any packets? */ wait_WOC(iobase); - rxStatus = readb(ramBase + NETWAVE_EREG_RSER); + rxStatus = readb(ramBase + NETWAVE_EREG_RSER); if ( !( rxStatus & 0x80)) /* No more packets */ break; - + /* Check if multicast/broadcast or other */ /* multicast = (rxStatus & 0x20); */ - + /* The receive list pointer and length of the packet */ wait_WOC(iobase); rcvLen = get_int16( ramBase + NETWAVE_EREG_RDP); rcvList = get_uint16( ramBase + NETWAVE_EREG_RDP + 2); - + if (rcvLen < 0) { - printk(KERN_DEBUG "netwave_rx: Receive packet with len %d\n", + printk(KERN_DEBUG "netwave_rx: Receive packet with len %d\n", rcvLen); return 0; } - + skb = dev_alloc_skb(rcvLen+5); if (skb == NULL) { pr_debug("netwave_rx: Could not allocate an sk_buff of " @@ -1228,21 +1228,21 @@ static int netwave_rx(struct net_device *dev) /* Copy packet fragments to the skb data area */ ptr = (u_char*) skb->data; curBuffer = rcvList; - tmpcount = 0; + tmpcount = 0; while ( tmpcount < rcvLen) { /* Get length and offset of current buffer */ dataCount = get_uint16( ramBase+curBuffer+2); dataOffset = get_uint16( ramBase+curBuffer+4); - + copy_from_pc( ptr + tmpcount, ramBase+curBuffer+dataOffset, dataCount); tmpcount += dataCount; - + /* Point to next buffer */ curBuffer = get_uint16(ramBase + curBuffer); } - + skb->protocol = eth_type_trans(skb,dev); /* Queue packet for network layer */ netif_rx(skb); @@ -1264,7 +1264,7 @@ static int netwave_open(struct net_device *dev) { struct pcmcia_device *link = priv->p_dev; dev_dbg(&link->dev, "netwave_open: starting.\n"); - + if (!pcmcia_dev_present(link)) return -ENODEV; @@ -1272,7 +1272,7 @@ static int netwave_open(struct net_device *dev) { netif_start_queue(dev); netwave_reset(dev); - + return 0; } @@ -1331,7 +1331,7 @@ static void set_multicast_list(struct net_device *dev) netwave_private *priv = netdev_priv(dev); u_char __iomem * ramBase = priv->ramBase; u_char rcvMode = 0; - + #ifdef PCMCIA_DEBUG { xstatic int old; @@ -1342,7 +1342,7 @@ static void set_multicast_list(struct net_device *dev) } } #endif - + if (!netdev_mc_empty(dev) || (dev->flags & IFF_ALLMULTI)) { /* Multicast Mode */ rcvMode = rxConfRxEna + rxConfAMP + rxConfBcast; @@ -1353,7 +1353,7 @@ static void set_multicast_list(struct net_device *dev) /* Normal mode */ rcvMode = rxConfRxEna + rxConfBcast; } - + /* printk("netwave set_multicast_list: rcvMode to %x\n", rcvMode);*/ /* Now set receive mode */ wait_WOC(iobase); diff --git a/drivers/staging/otus/80211core/cagg.c b/drivers/staging/otus/80211core/cagg.c index f9514c06c14c..c3cef1a02aa4 100644 --- a/drivers/staging/otus/80211core/cagg.c +++ b/drivers/staging/otus/80211core/cagg.c @@ -2485,7 +2485,7 @@ void zfAggTxRetransmit(zdev_t* dev, struct bufInfo *buf_info, struct aggControl BAW->insert(dev, buf_info->buf, tid_tx->bar_ssn >> 4, aggControl->tid_baw, buf_info->baw_retransmit, &header_r); }*/ - if ((err = zfHpSend(dev, + err = zfHpSend(dev, buf_info->baw_header->header, buf_info->baw_header->headerLen, buf_info->baw_header->snap, @@ -2496,7 +2496,8 @@ void zfAggTxRetransmit(zdev_t* dev, struct bufInfo *buf_info, struct aggControl buf_info->baw_header->removeLen, ZM_EXTERNAL_ALLOC_BUF, (u8_t)tid_tx->ac, - buf_info->baw_header->keyIdx)) != ZM_SUCCESS) + buf_info->baw_header->keyIdx); + if (err != ZM_SUCCESS) { goto zlError; } @@ -2797,9 +2798,10 @@ u16_t zfAggTxSendEth(zdev_t* dev, zbuf_t* buf, u16_t port, u16_t bufType, u8_t f BAW->insert(dev, buf, tid_tx->bar_ssn >> 4, aggControl->tid_baw, 0, &header_r); }*/ - if ((err = zfHpSend(dev, header, headerLen, snap, snapLen, + err = zfHpSend(dev, header, headerLen, snap, snapLen, mic, micLen, frag.buf[i], removeLen, - frag.bufType[i], zcUpToAc[up&0x7], keyIdx)) != ZM_SUCCESS) + frag.bufType[i], zcUpToAc[up&0x7], keyIdx); + if (err != ZM_SUCCESS) { goto zlError; } @@ -2849,7 +2851,8 @@ u16_t zfAggSendAddbaRequest(zdev_t* dev, u16_t *dst, u16_t ac, u16_t up) /* * TBD : Maximum size of management frame */ - if ((buf = zfwBufAllocate(dev, 1024)) == NULL) + buf = zfwBufAllocate(dev, 1024); + if (buf == NULL) { zm_msg0_mm(ZM_LV_0, "Alloc mm buf Fail!"); return ZM_SUCCESS; @@ -2892,8 +2895,9 @@ u16_t zfAggSendAddbaRequest(zdev_t* dev, u16_t *dst, u16_t ac, u16_t up) //zm_msg2_mm(ZM_LV_2, "buf->data=", buf->data); #if 0 - if ((err = zfHpSend(dev, NULL, 0, NULL, 0, NULL, 0, buf, 0, - ZM_INTERNAL_ALLOC_BUF, 0, 0xff)) != ZM_SUCCESS) + err = zfHpSend(dev, NULL, 0, NULL, 0, NULL, 0, buf, 0, + ZM_INTERNAL_ALLOC_BUF, 0, 0xff); + if (err != ZM_SUCCESS) { goto zlError; } @@ -3290,7 +3294,8 @@ u16_t zfAggSendAddbaResponse(zdev_t* dev, struct aggBaFrameParameter *bf) /* * TBD : Maximum size of management frame */ - if ((buf = zfwBufAllocate(dev, 1024)) == NULL) + buf = zfwBufAllocate(dev, 1024); + if (buf == NULL) { zm_msg0_mm(ZM_LV_0, "Alloc mm buf Fail!"); return ZM_SUCCESS; @@ -3337,8 +3342,9 @@ u16_t zfAggSendAddbaResponse(zdev_t* dev, struct aggBaFrameParameter *bf) //zm_msg2_mm(ZM_LV_2, "buf->data=", buf->data); #if 0 - if ((err = zfHpSend(dev, NULL, 0, NULL, 0, NULL, 0, buf, 0, - ZM_INTERNAL_ALLOC_BUF, 0, 0xff)) != ZM_SUCCESS) + err = zfHpSend(dev, NULL, 0, NULL, 0, NULL, 0, buf, 0, + ZM_INTERNAL_ALLOC_BUF, 0, 0xff); + if (err != ZM_SUCCESS) { goto zlError; } @@ -3443,7 +3449,8 @@ u16_t zfAggSendBar(zdev_t* dev, TID_TX tid_tx, struct aggBarControl *aggBarCon /* * TBD : Maximum size of management frame */ - if ((buf = zfwBufAllocate(dev, 1024)) == NULL) + buf = zfwBufAllocate(dev, 1024); + if (buf == NULL) { zm_msg0_mm(ZM_LV_0, "Alloc mm buf Fail!"); return ZM_SUCCESS; @@ -3486,8 +3493,9 @@ u16_t zfAggSendBar(zdev_t* dev, TID_TX tid_tx, struct aggBarControl *aggBarCon //zm_msg2_mm(ZM_LV_2, "buf->data=", buf->data); #if 0 - if ((err = zfHpSend(dev, NULL, 0, NULL, 0, NULL, 0, buf, 0, - ZM_INTERNAL_ALLOC_BUF, 0, 0xff)) != ZM_SUCCESS) + err = zfHpSend(dev, NULL, 0, NULL, 0, NULL, 0, buf, 0, + ZM_INTERNAL_ALLOC_BUF, 0, 0xff); + if (err != ZM_SUCCESS) { goto zlError; } diff --git a/drivers/staging/otus/80211core/ccmd.c b/drivers/staging/otus/80211core/ccmd.c index 3e3d9b500f65..ab300df02014 100644 --- a/drivers/staging/otus/80211core/ccmd.c +++ b/drivers/staging/otus/80211core/ccmd.c @@ -1436,7 +1436,8 @@ u16_t zfiWlanDeauth(zdev_t *dev, u16_t *macAddr, u16_t reason) */ /* - if ((id = zfApFindSta(dev, macAddr)) != 0xffff) + id = zfApFindSta(dev, macAddr); + if (id != 0xffff) { u32_t key[8]; u16_t nullAddr[3] = { 0x0, 0x0, 0x0 }; diff --git a/drivers/staging/otus/80211core/cfunc.c b/drivers/staging/otus/80211core/cfunc.c index e0a9f383c755..3b9341b13c02 100644 --- a/drivers/staging/otus/80211core/cfunc.c +++ b/drivers/staging/otus/80211core/cfunc.c @@ -1072,7 +1072,8 @@ u16_t zfFindCleanFrequency(zdev_t* dev, u32_t adhocMode) zmw_get_wlan_dev(dev); - if ((pBssInfo = wd->sta.bssList.head) == NULL) + pBssInfo = wd->sta.bssList.head; + if (pBssInfo == NULL) { if( adhocMode == ZM_ADHOCBAND_B || adhocMode == ZM_ADHOCBAND_G || adhocMode == ZM_ADHOCBAND_BG || adhocMode == ZM_ADHOCBAND_ABG ) diff --git a/drivers/staging/otus/80211core/cic.c b/drivers/staging/otus/80211core/cic.c index c84f079e3d84..53c09a0935fc 100644 --- a/drivers/staging/otus/80211core/cic.c +++ b/drivers/staging/otus/80211core/cic.c @@ -329,7 +329,8 @@ void zfCoreEvent(zdev_t* dev, u16_t event, u8_t* rsp) if (wd->wlanMode == ZM_MODE_AP) { zmw_enter_critical_section(dev); - if ((i=zfApFindSta(dev, (u16_t*)rsp)) != 0xffff) + i = zfApFindSta(dev, (u16_t*)rsp); + if (i != 0xffff) { zfRateCtrlTxFailEvent(dev, &wd->ap.staTable[i].rcCell, 0,(u32_t)zfPhyCtrlToRate(retryRate)); } @@ -357,7 +358,8 @@ void zfCoreEvent(zdev_t* dev, u16_t event, u8_t* rsp) if (wd->wlanMode == ZM_MODE_AP) { zmw_enter_critical_section(dev); - if ((i=zfApFindSta(dev, (u16_t*)rsp)) != 0xffff) + i = zfApFindSta(dev, (u16_t*)rsp); + if (i != 0xffff) { zfRateCtrlTxFailEvent(dev, &wd->ap.staTable[i].rcCell, 0,(u32_t)zfPhyCtrlToRate(retryRate)); } @@ -387,7 +389,8 @@ void zfCoreEvent(zdev_t* dev, u16_t event, u8_t* rsp) if (wd->wlanMode == ZM_MODE_AP) { zmw_enter_critical_section(dev); - if ((i=zfApFindSta(dev, (u16_t*)rsp)) != 0xffff) + i = zfApFindSta(dev, (u16_t*)rsp); + if (i != 0xffff) { zfRateCtrlTxSuccessEvent(dev, &wd->ap.staTable[i].rcCell, zfPhyCtrlToRate(retryRate)); } diff --git a/drivers/staging/otus/80211core/cinit.c b/drivers/staging/otus/80211core/cinit.c index 5f853ce79309..11823311e9ce 100644 --- a/drivers/staging/otus/80211core/cinit.c +++ b/drivers/staging/otus/80211core/cinit.c @@ -622,7 +622,8 @@ u16_t zfTxGenWlanHeader(zdev_t* dev, zbuf_t* buf, u16_t* header, u16_t seq, phyCtrl = 0xc0001; //PHY control L /* WDS port checking */ - if ((wdsPort = (port - 0x20)) >= ZM_MAX_WDS_SUPPORT) + wdsPort = port - 0x20; + if (wdsPort >= ZM_MAX_WDS_SUPPORT) { wdsPort = 0; } diff --git a/drivers/staging/otus/80211core/cmm.c b/drivers/staging/otus/80211core/cmm.c index 484e753df358..007ef3b606a5 100644 --- a/drivers/staging/otus/80211core/cmm.c +++ b/drivers/staging/otus/80211core/cmm.c @@ -83,7 +83,8 @@ u16_t zfFindElement(zdev_t* dev, zbuf_t* buf, u8_t eid) /* Get offset of first element */ subType = (zmw_rx_buf_readb(dev, buf, 0) >> 4); - if ((offset = zgElementOffsetTable[subType]) == 0xff) + offset = zgElementOffsetTable[subType]; + if (offset == 0xff) { zm_assert(0); } @@ -107,10 +108,12 @@ u16_t zfFindElement(zdev_t* dev, zbuf_t* buf, u8_t eid) while ((offset+2)<bufLen) // including element ID and length (2bytes) { /* Search target element */ - if ((id = zmw_rx_buf_readb(dev, buf, offset)) == eid) + id = zmw_rx_buf_readb(dev, buf, offset); + if (id == eid) { /* Bingo */ - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1))>(bufLen - offset)) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen > bufLen - offset) { /* Element length error */ return 0xffff; @@ -151,7 +154,8 @@ u16_t zfFindElement(zdev_t* dev, zbuf_t* buf, u8_t eid) #if 1 elen = zmw_rx_buf_readb(dev, buf, offset+1); #else - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1)) == 0) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen == 0) { return 0xffff; } @@ -194,7 +198,8 @@ u16_t zfFindWifiElement(zdev_t* dev, zbuf_t* buf, u8_t type, u8_t subtype) /* Get offset of first element */ subType = (zmw_rx_buf_readb(dev, buf, 0) >> 4); - if ((offset = zgElementOffsetTable[subType]) == 0xff) + offset = zgElementOffsetTable[subType]; + if (offset == 0xff) { zm_assert(0); } @@ -207,10 +212,12 @@ u16_t zfFindWifiElement(zdev_t* dev, zbuf_t* buf, u8_t type, u8_t subtype) while ((offset+2)<bufLen) // including element ID and length (2bytes) { /* Search target element */ - if ((id = zmw_rx_buf_readb(dev, buf, offset)) == ZM_WLAN_EID_WIFI_IE) + id = zmw_rx_buf_readb(dev, buf, offset); + if (id == ZM_WLAN_EID_WIFI_IE) { /* Bingo */ - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1))>(bufLen - offset)) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen > bufLen - offset) { /* Element length error */ return 0xffff; @@ -229,7 +236,8 @@ u16_t zfFindWifiElement(zdev_t* dev, zbuf_t* buf, u8_t type, u8_t subtype) { if ( subtype != 0xff ) { - if ( (tmp = zmw_rx_buf_readb(dev, buf, offset+6)) == subtype ) + tmp = zmw_rx_buf_readb(dev, buf, offset+6); + if (tmp == subtype) { return offset; } @@ -241,7 +249,8 @@ u16_t zfFindWifiElement(zdev_t* dev, zbuf_t* buf, u8_t type, u8_t subtype) } } /* Advance to next element */ - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1)) == 0) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen == 0) { return 0xffff; } @@ -348,7 +357,8 @@ u16_t zfFindSuperGElement(zdev_t* dev, zbuf_t* buf, u8_t type) /* Get offset of first element */ subType = (zmw_rx_buf_readb(dev, buf, 0) >> 4); - if ((offset = zgElementOffsetTable[subType]) == 0xff) + offset = zgElementOffsetTable[subType]; + if (offset == 0xff) { zm_assert(0); } @@ -361,10 +371,12 @@ u16_t zfFindSuperGElement(zdev_t* dev, zbuf_t* buf, u8_t type) while ((offset+2)<bufLen) // including element ID and length (2bytes) { /* Search target element */ - if ((id = zmw_rx_buf_readb(dev, buf, offset)) == ZM_WLAN_EID_VENDOR_PRIVATE) + id = zmw_rx_buf_readb(dev, buf, offset); + if (id == ZM_WLAN_EID_VENDOR_PRIVATE) { /* Bingo */ - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1))>(bufLen - offset)) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen > bufLen - offset) { /* Element length error */ return 0xffff; @@ -389,7 +401,8 @@ u16_t zfFindSuperGElement(zdev_t* dev, zbuf_t* buf, u8_t type) #if 1 elen = zmw_rx_buf_readb(dev, buf, offset+1); #else - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1)) == 0) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen == 0) { return 0xffff; } @@ -411,7 +424,8 @@ u16_t zfFindXRElement(zdev_t* dev, zbuf_t* buf, u8_t type) /* Get offset of first element */ subType = (zmw_rx_buf_readb(dev, buf, 0) >> 4); - if ((offset = zgElementOffsetTable[subType]) == 0xff) + offset = zgElementOffsetTable[subType]; + if (offset == 0xff) { zm_assert(0); } @@ -424,10 +438,12 @@ u16_t zfFindXRElement(zdev_t* dev, zbuf_t* buf, u8_t type) while ((offset+2)<bufLen) // including element ID and length (2bytes) { /* Search target element */ - if ((id = zmw_rx_buf_readb(dev, buf, offset)) == ZM_WLAN_EID_VENDOR_PRIVATE) + id = zmw_rx_buf_readb(dev, buf, offset); + if (id == ZM_WLAN_EID_VENDOR_PRIVATE) { /* Bingo */ - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1))>(bufLen - offset)) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen > bufLen - offset) { /* Element length error */ return 0xffff; @@ -447,7 +463,8 @@ u16_t zfFindXRElement(zdev_t* dev, zbuf_t* buf, u8_t type) #if 1 elen = zmw_rx_buf_readb(dev, buf, offset+1); #else - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1)) == 0) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen == 0) { return 0xffff; } @@ -868,7 +885,8 @@ void zfSendMmFrame(zdev_t* dev, u8_t frameType, u16_t* dst, zm_msg2_mm(ZM_LV_2, "Send mm frame, type=", frameType); /* TBD : Maximum size of management frame */ - if ((buf = zfwBufAllocate(dev, 1024)) == NULL) + buf = zfwBufAllocate(dev, 1024); + if (buf == NULL) { zm_msg0_mm(ZM_LV_0, "Alloc mm buf Fail!"); return; @@ -1257,7 +1275,8 @@ void zfSendMmFrame(zdev_t* dev, u8_t frameType, u16_t* dst, { vap = (u16_t) p3; - if ((aid = zfApFindSta(dev, dst)) != 0xffff) + aid = zfApFindSta(dev, dst); + if (aid != 0xffff) { zmw_enter_critical_section(dev); /* Clear STA table */ @@ -1303,8 +1322,9 @@ void zfSendMmFrame(zdev_t* dev, u8_t frameType, u16_t* dst, //zm_msg2_mm(ZM_LV_2, "buf->data=", buf->data); #if 0 - if ((err = zfHpSend(dev, NULL, 0, NULL, 0, NULL, 0, buf, 0, - ZM_INTERNAL_ALLOC_BUF, 0, 0xff)) != ZM_SUCCESS) + err = zfHpSend(dev, NULL, 0, NULL, 0, NULL, 0, buf, 0, + ZM_INTERNAL_ALLOC_BUF, 0, 0xff); + if (err != ZM_SUCCESS) { goto zlError; } @@ -1366,7 +1386,8 @@ void zfProcessManagement(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* AddInf if ((ra[0] & 0x1) != 1) { /* AP : Find virtual AP */ - if ((index = zfApFindSta(dev, ta)) != 0xffff) + index = zfApFindSta(dev, ta); + if (index != 0xffff) { vap = wd->ap.staTable[index].vap; } @@ -1534,7 +1555,8 @@ void zfProcessProbeReq(zdev_t* dev, zbuf_t* buf, u16_t* src) } /* check SSID */ - if ((offset = zfFindElement(dev, buf, ZM_WLAN_EID_SSID)) == 0xffff) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_SSID); + if (offset == 0xffff) { zm_msg0_mm(ZM_LV_3, "probe req SSID not found"); return; @@ -1561,8 +1583,8 @@ void zfProcessProbeReq(zdev_t* dev, zbuf_t* buf, u16_t* src) { for (j=0; j<len; j++) { - if ((ch = zmw_rx_buf_readb(dev, buf, offset+2+j)) - != wd->ap.ssid[i][j]) + ch = zmw_rx_buf_readb(dev, buf, offset+2+j); + if (ch != wd->ap.ssid[i][j]) { break; } @@ -1814,7 +1836,8 @@ u16_t zfFindATHExtCap(zdev_t* dev, zbuf_t* buf, u8_t type, u8_t subtype) /* Get offset of first element */ subType = (zmw_rx_buf_readb(dev, buf, 0) >> 4); - if ((offset = zgElementOffsetTable[subType]) == 0xff) + offset = zgElementOffsetTable[subType]; + if (offset == 0xff) { zm_assert(0); } @@ -1828,10 +1851,12 @@ u16_t zfFindATHExtCap(zdev_t* dev, zbuf_t* buf, u8_t type, u8_t subtype) while ((offset+2)<bufLen) // including element ID and length (2bytes) { /* Search target element */ - if ((id = zmw_rx_buf_readb(dev, buf, offset)) == ZM_WLAN_EID_WIFI_IE) + id = zmw_rx_buf_readb(dev, buf, offset); + if (id == ZM_WLAN_EID_WIFI_IE) { /* Bingo */ - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1))>(bufLen - offset)) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen > bufLen - offset) { /* Element length error */ return 0xffff; @@ -1850,7 +1875,8 @@ u16_t zfFindATHExtCap(zdev_t* dev, zbuf_t* buf, u8_t type, u8_t subtype) { if ( subtype != 0xff ) { - if ( (tmp = zmw_rx_buf_readb(dev, buf, offset+6)) == subtype ) + tmp = zmw_rx_buf_readb(dev, buf, offset+6); + if (tmp == subtype ) { return offset; } @@ -1863,7 +1889,8 @@ u16_t zfFindATHExtCap(zdev_t* dev, zbuf_t* buf, u8_t type, u8_t subtype) } /* Advance to next element */ - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1)) == 0) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen == 0) { return 0xffff; } @@ -1884,7 +1911,8 @@ u16_t zfFindBrdcmMrvlRlnkExtCap(zdev_t* dev, zbuf_t* buf) /* Get offset of first element */ subType = (zmw_rx_buf_readb(dev, buf, 0) >> 4); - if ((offset = zgElementOffsetTable[subType]) == 0xff) + offset = zgElementOffsetTable[subType]; + if (offset == 0xff) { zm_assert(0); } @@ -1898,10 +1926,12 @@ u16_t zfFindBrdcmMrvlRlnkExtCap(zdev_t* dev, zbuf_t* buf) while ((offset+2)<bufLen) // including element ID and length (2bytes) { /* Search target element */ - if ((id = zmw_rx_buf_readb(dev, buf, offset)) == ZM_WLAN_EID_WIFI_IE) + id = zmw_rx_buf_readb(dev, buf, offset); + if (id == ZM_WLAN_EID_WIFI_IE) { /* Bingo */ - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1))>(bufLen - offset)) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen > bufLen - offset) { /* Element length error */ return 0xffff; @@ -1930,7 +1960,8 @@ u16_t zfFindBrdcmMrvlRlnkExtCap(zdev_t* dev, zbuf_t* buf) else if ((id = zmw_rx_buf_readb(dev, buf, offset)) == 0x7F) { /* Bingo */ - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1))>(bufLen - offset)) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen > bufLen - offset) { /* Element length error */ return 0xffff; @@ -1941,7 +1972,8 @@ u16_t zfFindBrdcmMrvlRlnkExtCap(zdev_t* dev, zbuf_t* buf) return 0xffff; } - if ((tmp = zmw_rx_buf_readb(dev, buf, offset+2)) == 0x01) + tmp = zmw_rx_buf_readb(dev, buf, offset+2); + if (tmp == 0x01) { return offset; @@ -1949,7 +1981,8 @@ u16_t zfFindBrdcmMrvlRlnkExtCap(zdev_t* dev, zbuf_t* buf) } /* Advance to next element */ - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1)) == 0) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen == 0) { return 0xffff; } @@ -1970,7 +2003,8 @@ u16_t zfFindMarvelExtCap(zdev_t* dev, zbuf_t* buf) /* Get offset of first element */ subType = (zmw_rx_buf_readb(dev, buf, 0) >> 4); - if ((offset = zgElementOffsetTable[subType]) == 0xff) + offset = zgElementOffsetTable[subType]; + if (offset == 0xff) { zm_assert(0); } @@ -1984,10 +2018,12 @@ u16_t zfFindMarvelExtCap(zdev_t* dev, zbuf_t* buf) while ((offset+2)<bufLen) // including element ID and length (2bytes) { /* Search target element */ - if ((id = zmw_rx_buf_readb(dev, buf, offset)) == ZM_WLAN_EID_WIFI_IE) + id = zmw_rx_buf_readb(dev, buf, offset); + if (id == ZM_WLAN_EID_WIFI_IE) { /* Bingo */ - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1))>(bufLen - offset)) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen>(bufLen - offset)) { /* Element length error */ return 0xffff; @@ -2008,7 +2044,8 @@ u16_t zfFindMarvelExtCap(zdev_t* dev, zbuf_t* buf) } /* Advance to next element */ - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1)) == 0) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen == 0) { return 0xffff; } @@ -2029,7 +2066,8 @@ u16_t zfFindBroadcomExtCap(zdev_t* dev, zbuf_t* buf) /* Get offset of first element */ subType = (zmw_rx_buf_readb(dev, buf, 0) >> 4); - if ((offset = zgElementOffsetTable[subType]) == 0xff) + offset = zgElementOffsetTable[subType]; + if (offset == 0xff) { zm_assert(0); } @@ -2043,10 +2081,12 @@ u16_t zfFindBroadcomExtCap(zdev_t* dev, zbuf_t* buf) while((offset+2) < bufLen) // including element ID and length (2bytes) { /* Search target element */ - if ((id = zmw_rx_buf_readb(dev, buf, offset)) == ZM_WLAN_EID_WIFI_IE) + id = zmw_rx_buf_readb(dev, buf, offset); + if (id == ZM_WLAN_EID_WIFI_IE) { /* Bingo */ - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1)) > (bufLen - offset)) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen > (bufLen - offset)) { /* Element length error */ return 0xffff; @@ -2066,7 +2106,8 @@ u16_t zfFindBroadcomExtCap(zdev_t* dev, zbuf_t* buf) } /* Advance to next element */ - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1)) == 0) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen == 0) { return 0xffff; } @@ -2089,7 +2130,8 @@ u16_t zfFindRlnkExtCap(zdev_t* dev, zbuf_t* buf) /* Get offset of first element */ subType = (zmw_rx_buf_readb(dev, buf, 0) >> 4); - if ((offset = zgElementOffsetTable[subType]) == 0xff) + offset = zgElementOffsetTable[subType]; + if (offset == 0xff) { zm_assert(0); } @@ -2103,10 +2145,12 @@ u16_t zfFindRlnkExtCap(zdev_t* dev, zbuf_t* buf) while((offset+2) < bufLen) // including element ID and length (2bytes) { /* Search target element */ - if ((id = zmw_rx_buf_readb(dev, buf, offset)) == 0x7F) + id = zmw_rx_buf_readb(dev, buf, offset); + if (id == 0x7F) { /* Bingo */ - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1)) > (bufLen - offset)) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen > bufLen - offset) { /* Element length error */ return 0xffff; @@ -2117,7 +2161,8 @@ u16_t zfFindRlnkExtCap(zdev_t* dev, zbuf_t* buf) return 0xffff; } - if ((tmp = zmw_rx_buf_readb(dev, buf, offset+2)) == 0x01) + tmp = zmw_rx_buf_readb(dev, buf, offset+2); + if (tmp == 0x01) { return offset; @@ -2125,7 +2170,8 @@ u16_t zfFindRlnkExtCap(zdev_t* dev, zbuf_t* buf) } /* Advance to next element */ - if ((elen = zmw_rx_buf_readb(dev, buf, offset+1)) == 0) + elen = zmw_rx_buf_readb(dev, buf, offset+1); + if (elen == 0) { return 0xffff; } diff --git a/drivers/staging/otus/80211core/cmmap.c b/drivers/staging/otus/80211core/cmmap.c index 7f09fded459e..8ec3830e8439 100644 --- a/drivers/staging/otus/80211core/cmmap.c +++ b/drivers/staging/otus/80211core/cmmap.c @@ -141,7 +141,8 @@ u16_t zfApGetSTAInfo(zdev_t* dev, u16_t* addr, u16_t* state, u8_t* vap) zmw_enter_critical_section(dev); - if ((id = zfApFindSta(dev, addr)) != 0xffff) + id = zfApFindSta(dev, addr); + if (id != 0xffff) { *vap = wd->ap.staTable[id].vap; *state = wd->ap.staTable[id++].state; @@ -163,7 +164,8 @@ void zfApGetStaQosType(zdev_t* dev, u16_t* addr, u8_t* qosType) zmw_enter_critical_section(dev); - if ((id = zfApFindSta(dev, addr)) != 0xffff) + id = zfApFindSta(dev, addr); + if (id != 0xffff) { *qosType = wd->ap.staTable[id].qosType; } @@ -189,7 +191,8 @@ void zfApGetStaTxRateAndQosType(zdev_t* dev, u16_t* addr, u32_t* phyCtrl, zmw_enter_critical_section(dev); - if ((id = zfApFindSta(dev, addr)) != 0xffff) + id = zfApFindSta(dev, addr); + if (id != 0xffff) { rate = (u8_t)zfRateCtrlGetTxRate(dev, &wd->ap.staTable[id].rcCell, rcProbingFlag); #ifdef ZM_AP_DEBUG @@ -234,7 +237,8 @@ void zfApGetStaEncryType(zdev_t* dev, u16_t* addr, u8_t* encryType) zmw_enter_critical_section(dev); - if ((id = zfApFindSta(dev, addr)) != 0xffff) + id = zfApFindSta(dev, addr); + if (id != 0xffff) { *encryType = wd->ap.staTable[id].encryMode; } @@ -260,7 +264,8 @@ void zfApGetStaWpaIv(zdev_t* dev, u16_t* addr, u16_t* iv16, u32_t* iv32) zmw_enter_critical_section(dev); - if ((id = zfApFindSta(dev, addr)) != 0xffff) + id = zfApFindSta(dev, addr); + if (id != 0xffff) { *iv16 = wd->ap.staTable[id].iv16; *iv32 = wd->ap.staTable[id].iv32; @@ -289,7 +294,8 @@ void zfApSetStaWpaIv(zdev_t* dev, u16_t* addr, u16_t iv16, u32_t iv32) zmw_enter_critical_section(dev); - if ((id = zfApFindSta(dev, addr)) != 0xffff) + id = zfApFindSta(dev, addr); + if (id != 0xffff) { wd->ap.staTable[id].iv16 = iv16; wd->ap.staTable[id].iv32 = iv32; @@ -321,7 +327,8 @@ void zfApClearStaKey(zdev_t* dev, u16_t* addr) zmw_enter_critical_section(dev); - if ((id = zfApFindSta(dev, addr)) != 0xffff) + id = zfApFindSta(dev, addr); + if (id != 0xffff) { /* Turn off STA's key information */ zfHpRemoveKey(dev, id+1); @@ -348,7 +355,8 @@ void zfApGetStaCencIvAndKeyIdx(zdev_t* dev, u16_t* addr, u32_t *iv, u8_t *keyIdx zmw_enter_critical_section(dev); - if ((id = zfApFindSta(dev, addr)) != 0xffff) + id = zfApFindSta(dev, addr); + if (id != 0xffff) { *iv++ = wd->ap.staTable[id].txiv[0]; *iv++ = wd->ap.staTable[id].txiv[1]; @@ -379,7 +387,8 @@ void zfApSetStaCencIv(zdev_t* dev, u16_t* addr, u32_t *iv) zmw_enter_critical_section(dev); - if ((id = zfApFindSta(dev, addr)) != 0xffff) + id = zfApFindSta(dev, addr); + if (id != 0xffff) { wd->ap.staTable[id].txiv[0] = *iv++; wd->ap.staTable[id].txiv[1] = *iv++; @@ -539,7 +548,8 @@ u16_t zfApBufferPsFrame(zdev_t* dev, zbuf_t* buf, u16_t port) { zmw_enter_critical_section(dev); - if ((id = zfApFindSta(dev, addr)) != 0xffff) + id = zfApFindSta(dev, addr); + if (id != 0xffff) { if (wd->ap.staTable[id].psMode == 1) { @@ -603,7 +613,8 @@ u16_t zfApGetSTAInfoAndUpdatePs(zdev_t* dev, u16_t* addr, u16_t* state, //psMode=0; #endif - if ((id = zfApFindSta(dev, addr)) != 0xffff) + id = zfApFindSta(dev, addr); + if (id != 0xffff) { if (psMode != 0) { @@ -648,7 +659,8 @@ u16_t zfApGetSTAInfoAndUpdatePs(zdev_t* dev, u16_t* addr, u16_t* state, while (1) { - if ((psBuf = zfQueueGetWithMac(dev, wd->ap.uapsdQ, (u8_t*)addr, &mb)) != NULL) + psBuf = zfQueueGetWithMac(dev, wd->ap.uapsdQ, (u8_t*)addr, &mb); + if (psBuf != NULL) { zfTxSendEth(dev, psBuf, 0, ZM_EXTERNAL_ALLOC_BUF, 0); } @@ -730,7 +742,8 @@ u16_t zfApAddSta(zdev_t* dev, u16_t* addr, u16_t state, u16_t apId, u8_t type, zmw_enter_critical_section(dev); - if ((index = zfApFindSta(dev, addr)) != 0xffff) + index = zfApFindSta(dev, addr); + if (index != 0xffff) { zm_msg0_mm(ZM_LV_2, "found"); /* Update STA state */ @@ -963,7 +976,8 @@ void zfApProcessBeacon(zdev_t* dev, zbuf_t* buf) zm_msg0_mm(ZM_LV_3, "Rx beacon"); /* update Non-ERP flag(wd->ap.nonErpObss) */ - if ((offset = zfFindElement(dev, buf, ZM_WLAN_EID_ERP)) == 0xffff) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_ERP); + if (offset == 0xffff) { /* 11b OBSS */ wd->ap.protectedObss++; @@ -1046,7 +1060,8 @@ void zfApProcessAuth(zdev_t* dev, zbuf_t* buf, u16_t* src, u16_t apId) if (seq == 1) { /* AP : update STA to auth */ - if ((ret = zfApAddSta(dev, src, ZM_STATE_AUTH, apId, 0, 0, 0)) != 0xffff) + ret = zfApAddSta(dev, src, ZM_STATE_AUTH, apId, 0, 0, 0); + if (ret != 0xffff) { /* AP : call zfwAuthNotify() for host to judge */ //zfwAuthNotify(dev, src); @@ -1177,12 +1192,14 @@ void zfApProcessAsocReq(zdev_t* dev, zbuf_t* buf, u16_t* src, u16_t apId) zmw_get_wlan_dev(dev); /* AP : check SSID */ - if ((offset = zfFindElement(dev, buf, ZM_WLAN_EID_SSID)) != 0xffff) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_SSID); + if (offset != 0xffff) { k = 0; for (j = 0; j < wd->ap.vapNumber; j++) { - if ((tmp = zmw_buf_readb(dev, buf, offset+1)) + tmp = zmw_buf_readb(dev, buf, offset+1); + if (tmp != wd->ap.ssidLen[j]) { k++; @@ -1198,7 +1215,8 @@ void zfApProcessAsocReq(zdev_t* dev, zbuf_t* buf, u16_t* src, u16_t apId) { for (i=0; i<wd->ap.ssidLen[j]; i++) { - if ((tmp = zmw_buf_readb(dev, buf, offset+2+i)) + tmp = zmw_buf_readb(dev, buf, offset+2+i); + if (tmp != wd->ap.ssid[j][i]) { break; @@ -1222,13 +1240,15 @@ void zfApProcessAsocReq(zdev_t* dev, zbuf_t* buf, u16_t* src, u16_t apId) /* TODO : check capability */ /* AP : check support rate */ - if ((offset = zfFindElement(dev, buf, ZM_WLAN_EID_EXTENDED_RATE)) != 0xffff) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_EXTENDED_RATE); + if (offset != 0xffff) { /* 11g STA */ staType = 1; } //CWYang(+) - if ((offset = zfFindElement(dev, buf, ZM_WLAN_EID_HT_CAPABILITY)) != 0xffff) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_HT_CAPABILITY); + if (offset != 0xffff) { /* 11n STA */ staType = 2; @@ -1251,7 +1271,8 @@ void zfApProcessAsocReq(zdev_t* dev, zbuf_t* buf, u16_t* src, u16_t apId) /* AP : check 11h */ /* AP : check WME */ - if ((offset = zfFindWifiElement(dev, buf, 2, 0)) != 0xffff) + offset = zfFindWifiElement(dev, buf, 2, 0); + if (offset != 0xffff) { /* WME STA */ qosType = 1; @@ -1265,7 +1286,8 @@ void zfApProcessAsocReq(zdev_t* dev, zbuf_t* buf, u16_t* src, u16_t apId) if (wd->ap.wpaSupport[apId] == 1) { - if ( (offset = zfFindElement(dev, buf, ZM_WLAN_EID_WPA_IE)) != 0xffff ) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_WPA_IE); + if (offset != 0xffff) { /* get WPA IE */ u8_t length = zmw_rx_buf_readb(dev, buf, offset+1); @@ -1406,12 +1428,14 @@ void zfApStoreAsocReqIe(zdev_t* dev, zbuf_t* buf, u16_t aid) offset = 28; /* supported rates */ - if ((offset = zfFindElement(dev, buf, ZM_WLAN_EID_SUPPORT_RATE)) == 0xffff) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_SUPPORT_RATE); + if (offset == 0xffff) return; length = zmw_rx_buf_readb(dev, buf, offset + 1); /* extended supported rates */ - if ((offset = zfFindElement(dev, buf, ZM_WLAN_EID_EXTENDED_RATE)) == 0xffff) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_EXTENDED_RATE); + if (offset == 0xffff) return; length = zmw_rx_buf_readb(dev, buf, offset + 1); @@ -1426,7 +1450,8 @@ void zfApStoreAsocReqIe(zdev_t* dev, zbuf_t* buf, u16_t aid) /* QoS */ /* HT capabilities: 28 octets */ - if ((offset = zfFindElement(dev, buf, ZM_WLAN_EID_HT_CAPABILITY)) != 0xffff) { + offset = zfFindElement(dev, buf, ZM_WLAN_EID_HT_CAPABILITY); + if (offset != 0xffff) { /* atheros pre n */ htcap = (u8_t *)&wd->ap.ie[aid].HtCap; htcap[0] = zmw_rx_buf_readb(dev, buf, offset); @@ -1479,7 +1504,8 @@ void zfApProcessDeauth(zdev_t* dev, zbuf_t* buf, u16_t* src, u16_t apId) zmw_enter_critical_section(dev); /* AP : if SA=associated STA then deauthenticate STA */ - if ((aid = zfApFindSta(dev, src)) != 0xffff) + aid = zfApFindSta(dev, src); + if (aid != 0xffff) { /* Clear STA table */ wd->ap.staTable[aid].valid = 0; @@ -1500,7 +1526,8 @@ void zfApProcessDisasoc(zdev_t* dev, zbuf_t* buf, u16_t* src, u16_t apId) zmw_enter_critical_section(dev); /* AP : if SA=associated STA then deauthenticate STA */ - if ((aid = zfApFindSta(dev, src)) != 0xffff) + aid = zfApFindSta(dev, src); + if (aid != 0xffff) { /* Clear STA table */ wd->ap.staTable[aid].valid = 0; @@ -1674,7 +1701,8 @@ u16_t zfApAddIeTim(zdev_t* dev, zbuf_t* buf, u16_t offset, u16_t vap) dst[0] = zmw_tx_buf_readh(dev, psBuf, 0); dst[1] = zmw_tx_buf_readh(dev, psBuf, 2); dst[2] = zmw_tx_buf_readh(dev, psBuf, 4); - if ((aid = zfApFindSta(dev, dst)) != 0xffff) + aid = zfApFindSta(dev, dst); + if (aid != 0xffff) { if (wd->ap.staTable[aid].psMode != 0) { @@ -1896,7 +1924,8 @@ void zfApSendBeacon(zdev_t* dev) zm_msg1_mm(ZM_LV_2, "Send beacon, vap=", vap); /* TBD : Maximum size of beacon */ - if ((buf = zfwBufAllocate(dev, 1024)) == NULL) + buf = zfwBufAllocate(dev, 1024); + if (buf == NULL) { zm_msg0_mm(ZM_LV_0, "Alloc beacon buf Fail!"); return; @@ -2101,8 +2130,8 @@ u16_t zfIntrabssForward(zdev_t* dev, zbuf_t* buf, u8_t srcVap) if ((asocFlag == 1) || ((dst[0]&0x1) == 0x1)) { /* Allocate frame */ - if ((txBuf = zfwBufAllocate(dev, ZM_RX_FRAME_SIZE)) - == NULL) + txBuf = zfwBufAllocate(dev, ZM_RX_FRAME_SIZE); + if (txBuf == NULL) { zm_msg0_rx(ZM_LV_1, "Alloc intra-bss buf Fail!"); goto zlAllocError; @@ -2133,7 +2162,8 @@ u16_t zfIntrabssForward(zdev_t* dev, zbuf_t* buf, u8_t srcVap) /* Transmit frame */ /* Return error if port is disabled */ - if ((err = zfTxPortControl(dev, txBuf, vap)) == ZM_PORT_DISABLED) + err = zfTxPortControl(dev, txBuf, vap); + if (err == ZM_PORT_DISABLED) { err = ZM_ERR_TX_PORT_DISABLED; goto zlTxError; @@ -2141,7 +2171,8 @@ u16_t zfIntrabssForward(zdev_t* dev, zbuf_t* buf, u8_t srcVap) #if 1 /* AP : Buffer frame for power saving STA */ - if ((ret = zfApBufferPsFrame(dev, txBuf, vap)) == 0) + ret = zfApBufferPsFrame(dev, txBuf, vap); + if (ret == 0) { /* forward frame if not been buffered */ #if 1 @@ -2177,7 +2208,8 @@ struct zsMicVar* zfApGetRxMicKey(zdev_t* dev, zbuf_t* buf) macAddr[1] = sa[2] + (sa[3] << 8); macAddr[2] = sa[4] + (sa[5] << 8); - if ((id = zfApFindSta(dev, macAddr)) != 0xffff) + id = zfApFindSta(dev, macAddr); + if (id != 0xffff) return (&wd->ap.staTable[id].rxMicKey); return NULL; @@ -2369,7 +2401,8 @@ void zfApSendFailure(zdev_t* dev, u8_t* addr) staAddr[1] = addr[2] + (((u16_t)addr[3])<<8); staAddr[2] = addr[4] + (((u16_t)addr[5])<<8); zmw_enter_critical_section(dev); - if ((id = zfApFindSta(dev, staAddr)) != 0xffff) + id = zfApFindSta(dev, staAddr); + if (id != 0xffff) { /* Send failture : Add 3 minutes to inactive time that will */ /* will make STA been kicked out soon */ diff --git a/drivers/staging/otus/80211core/cmmsta.c b/drivers/staging/otus/80211core/cmmsta.c index c3fd47529c14..0fda30d05ed2 100644 --- a/drivers/staging/otus/80211core/cmmsta.c +++ b/drivers/staging/otus/80211core/cmmsta.c @@ -602,7 +602,8 @@ void zfStaProtErpMonitor(zdev_t* dev, zbuf_t* buf) if (zfRxBufferEqualToStr(dev, buf, bssid, ZM_WLAN_HEADER_A2_OFFSET, 6)) { - if ( (offset=zfFindElement(dev, buf, ZM_WLAN_EID_ERP)) != 0xffff ) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_ERP); + if (offset != 0xffff) { erp = zmw_rx_buf_readb(dev, buf, offset+2); @@ -628,7 +629,8 @@ void zfStaProtErpMonitor(zdev_t* dev, zbuf_t* buf) } //Check the existence of Non-N AP //Follow the check the "pBssInfo->EnableHT" - if ((offset = zfFindElement(dev, buf, ZM_WLAN_EID_HT_CAPABILITY)) != 0xffff) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_HT_CAPABILITY); + if (offset != 0xffff) {} else if ((offset = zfFindElement(dev, buf, ZM_WLAN_PREN2_EID_HTCAPABILITY)) != 0xffff) {} @@ -658,9 +660,11 @@ void zfStaUpdateWmeParameter(zdev_t* dev, zbuf_t* buf) if (wd->sta.wmeConnected != 0) { /* Find WME parameter element */ - if ((offset = zfFindWifiElement(dev, buf, 2, 1)) != 0xffff) + offset = zfFindWifiElement(dev, buf, 2, 1); + if (offset != 0xffff) { - if ((len = zmw_rx_buf_readb(dev, buf, offset+1)) >= 7) + len = zmw_rx_buf_readb(dev, buf, offset+1); + if (len >= 7) { rxWmeParameterSetCount=zmw_rx_buf_readb(dev, buf, offset+8); if (rxWmeParameterSetCount != wd->sta.wmeParameterSetCount) @@ -741,7 +745,8 @@ void zfStaUpdateDot11HDFS(zdev_t* dev, zbuf_t* buf) */ /* get EID(Channel Switch Announcement) */ - if ( (offset = zfFindElement(dev, buf, ZM_WLAN_EID_CHANNEL_SWITCH_ANNOUNCE)) == 0xffff ) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_CHANNEL_SWITCH_ANNOUNCE); + if (offset == 0xffff) { //zm_debug_msg0("EID(Channel Switch Announcement) not found"); return; @@ -1216,7 +1221,8 @@ void zfStaSendBeacon(zdev_t* dev) //zm_debug_msg0("\n"); /* TBD : Maximum size of beacon */ - if ((buf = zfwBufAllocate(dev, 1024)) == NULL) + buf = zfwBufAllocate(dev, 1024); + if (buf == NULL) { zm_debug_msg0("Allocate beacon buffer failed"); return; @@ -1370,7 +1376,8 @@ struct zsBssInfo* zfStaFindBssInfo(zdev_t* dev, zbuf_t* buf, struct zsWlanProbeR zmw_get_wlan_dev(dev); - if ((pBssInfo = wd->sta.bssList.head) == NULL) + pBssInfo = wd->sta.bssList.head; + if (pBssInfo == NULL) { return NULL; } @@ -1420,8 +1427,10 @@ struct zsBssInfo* zfStaFindBssInfo(zdev_t* dev, zbuf_t* buf, struct zsWlanProbeR /* Check channel */ /* Add check channel to solve the bug #31222 */ if (isMatched) { - if ((offset = zfFindElement(dev, buf, ZM_WLAN_EID_DS)) != 0xffff) { - if ((length = zmw_rx_buf_readb(dev, buf, offset+1)) == 1) { + offset = zfFindElement(dev, buf, ZM_WLAN_EID_DS); + if (offset != 0xffff) { + length = zmw_rx_buf_readb(dev, buf, offset+1); + if (length == 1) { channel = zmw_rx_buf_readb(dev, buf, offset+2); if (zfHpIsAllowedChannel(dev, zfChNumToFreq(dev, channel, 0)) == 0) { frequency = 0; @@ -1473,7 +1482,8 @@ u8_t zfStaInitBssInfo(zdev_t* dev, zbuf_t* buf, } /* get SSID */ - if ( (offset = zfFindElement(dev, buf, ZM_WLAN_EID_SSID)) == 0xffff ) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_SSID); + if (offset == 0xffff) { zm_debug_msg0("EID(SSID) not found"); goto zlError; @@ -1506,7 +1516,8 @@ u8_t zfStaInitBssInfo(zdev_t* dev, zbuf_t* buf, zfCopyFromRxBuffer(dev, buf, pBssInfo->ssid, offset, length+2); /* get DS parameter */ - if ( (offset = zfFindElement(dev, buf, ZM_WLAN_EID_DS)) != 0xffff ) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_DS); + if (offset != 0xffff) { length = zmw_rx_buf_readb(dev, buf, offset+1); if ( length != 1 ) @@ -1590,7 +1601,8 @@ u8_t zfStaInitBssInfo(zdev_t* dev, zbuf_t* buf, pBssInfo->frameBodysize = accumulateLen; /* get supported rates */ - if ( (offset = zfFindElement(dev, buf, ZM_WLAN_EID_SUPPORT_RATE)) == 0xffff ) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_SUPPORT_RATE); + if (offset == 0xffff) { zm_debug_msg0("EID(supported rates) not found"); goto zlError; @@ -1607,7 +1619,8 @@ u8_t zfStaInitBssInfo(zdev_t* dev, zbuf_t* buf, /* get Country information */ - if ( (offset = zfFindElement(dev, buf, ZM_WLAN_EID_COUNTRY)) != 0xffff ) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_COUNTRY); + if (offset != 0xffff) { length = zmw_rx_buf_readb(dev, buf, offset+1); if (length > ZM_MAX_COUNTRY_INFO_SIZE) @@ -1625,13 +1638,15 @@ u8_t zfStaInitBssInfo(zdev_t* dev, zbuf_t* buf, } /* get ERP information */ - if ( (offset = zfFindElement(dev, buf, ZM_WLAN_EID_ERP)) != 0xffff ) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_ERP); + if (offset != 0xffff) { pBssInfo->erp = zmw_rx_buf_readb(dev, buf, offset+2); } /* get extended supported rates */ - if ( (offset = zfFindElement(dev, buf, ZM_WLAN_EID_EXTENDED_RATE)) != 0xffff ) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_EXTENDED_RATE); + if (offset != 0xffff) { length = zmw_rx_buf_readb(dev, buf, offset+1); if (length > ZM_MAX_SUPP_RATES_IE_SIZE) @@ -1648,7 +1663,8 @@ u8_t zfStaInitBssInfo(zdev_t* dev, zbuf_t* buf, } /* get WPA IE */ - if ( (offset = zfFindElement(dev, buf, ZM_WLAN_EID_WPA_IE)) != 0xffff ) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_WPA_IE); + if (offset != 0xffff) { length = zmw_rx_buf_readb(dev, buf, offset+1); if (length > ZM_MAX_IE_SIZE) @@ -1664,7 +1680,8 @@ u8_t zfStaInitBssInfo(zdev_t* dev, zbuf_t* buf, } /* get WPS IE */ - if ((offset = zfFindWifiElement(dev, buf, 4, 0xff)) != 0xffff) + offset = zfFindWifiElement(dev, buf, 4, 0xff); + if (offset != 0xffff) { length = zmw_rx_buf_readb(dev, buf, offset+1); if (length > ZM_MAX_WPS_IE_SIZE ) @@ -1679,19 +1696,22 @@ u8_t zfStaInitBssInfo(zdev_t* dev, zbuf_t* buf, } /* get SuperG IE */ - if ((offset = zfFindSuperGElement(dev, buf, ZM_WLAN_EID_VENDOR_PRIVATE)) != 0xffff) + offset = zfFindSuperGElement(dev, buf, ZM_WLAN_EID_VENDOR_PRIVATE); + if (offset != 0xffff) { pBssInfo->apCap |= ZM_SuperG_AP; } /* get XR IE */ - if ((offset = zfFindXRElement(dev, buf, ZM_WLAN_EID_VENDOR_PRIVATE)) != 0xffff) + offset = zfFindXRElement(dev, buf, ZM_WLAN_EID_VENDOR_PRIVATE); + if (offset != 0xffff) { pBssInfo->apCap |= ZM_XR_AP; } /* get RSN IE */ - if ( (offset = zfFindElement(dev, buf, ZM_WLAN_EID_RSN_IE)) != 0xffff ) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_RSN_IE); + if (offset != 0xffff) { length = zmw_rx_buf_readb(dev, buf, offset+1); if (length > ZM_MAX_IE_SIZE) @@ -1707,7 +1727,8 @@ u8_t zfStaInitBssInfo(zdev_t* dev, zbuf_t* buf, } #ifdef ZM_ENABLE_CENC /* get CENC IE */ - if ( (offset = zfFindElement(dev, buf, ZM_WLAN_EID_CENC_IE)) != 0xffff ) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_CENC_IE); + if (offset != 0xffff) { length = zmw_rx_buf_readb(dev, buf, offset+1); if (length > ZM_MAX_IE_SIZE ) @@ -1726,7 +1747,8 @@ u8_t zfStaInitBssInfo(zdev_t* dev, zbuf_t* buf, /* get WME Parameter IE, probe rsp may contain WME parameter element */ //if ( wd->bQoSEnable ) { - if ((offset = zfFindWifiElement(dev, buf, 2, 1)) != 0xffff) + offset = zfFindWifiElement(dev, buf, 2, 1); + if (offset != 0xffff) { apQosInfo = zmw_rx_buf_readb(dev, buf, offset+8) & 0x80; pBssInfo->wmeSupport = 1 | apQosInfo; @@ -1742,7 +1764,8 @@ u8_t zfStaInitBssInfo(zdev_t* dev, zbuf_t* buf, } } //CWYang(+) - if ((offset = zfFindElement(dev, buf, ZM_WLAN_EID_HT_CAPABILITY)) != 0xffff) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_HT_CAPABILITY); + if (offset != 0xffff) { /* 11n AP */ pBssInfo->EnableHT = 1; @@ -1792,7 +1815,8 @@ u8_t zfStaInitBssInfo(zdev_t* dev, zbuf_t* buf, pBssInfo->EnableHT = 0; } /* HT information */ - if ((offset = zfFindElement(dev, buf, ZM_WLAN_EID_EXTENDED_HT_CAPABILITY)) != 0xffff) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_EXTENDED_HT_CAPABILITY); + if (offset != 0xffff) { /* atheros pre n */ pBssInfo->extChOffset = zmw_rx_buf_readb(dev, buf, offset+2) & 0x03; @@ -1848,7 +1872,8 @@ u8_t zfStaInitBssInfo(zdev_t* dev, zbuf_t* buf, } /* get Marvel Extended Capability */ - if ((offset = zfFindMarvelExtCap(dev, buf)) != 0xffff) + offset = zfFindMarvelExtCap(dev, buf); + if (offset != 0xffff) { pBssInfo->marvelAp = 1; } @@ -1858,7 +1883,8 @@ u8_t zfStaInitBssInfo(zdev_t* dev, zbuf_t* buf, } /* get ATIM window */ - if ( (offset = zfFindElement(dev, buf, ZM_WLAN_EID_IBSS)) != 0xffff ) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_IBSS); + if (offset != 0xffff ) { pBssInfo->atimWindow = zmw_rx_buf_readh(dev, buf,offset+2); } @@ -2017,7 +2043,8 @@ zlUpdateRssi: pBssInfo->tick = wd->tick; /* Update ERP information */ - if ( (offset = zfFindElement(dev, buf, ZM_WLAN_EID_ERP)) != 0xffff ) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_ERP); + if (offset != 0xffff) { pBssInfo->erp = zmw_rx_buf_readb(dev, buf, offset+2); } @@ -2116,7 +2143,8 @@ void zfStaProcessBeacon(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* AddInfo #if 0 else if ( wd->sta.oppositeCount == 0 ) { /* IBSS merge if SSID matched */ - if ( (offset = zfFindElement(dev, buf, ZM_WLAN_EID_SSID)) != 0xffff ) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_SSID); + if (offset != 0xffff) { if ( (wd->sta.ssidLen == zmw_buf_readb(dev, buf, offset+1))&& (zfRxBufferEqualToStr(dev, buf, wd->sta.ssid, @@ -2410,7 +2438,8 @@ void zfStaProcessAsocRsp(zdev_t* dev, zbuf_t* buf) if ((wd->sta.wmeEnabled & ZM_STA_WME_ENABLE_BIT) != 0) //WME enabled { /* Asoc rsp may contain WME parameter element */ - if ((offset = zfFindWifiElement(dev, buf, 2, 1)) != 0xffff) + offset = zfFindWifiElement(dev, buf, 2, 1); + if (offset != 0xffff) { zm_debug_msg0("WME enable"); wd->sta.wmeConnected = 1; @@ -2605,7 +2634,8 @@ void zfStaStoreAsocRspIe(zdev_t* dev, zbuf_t* buf) return; } - if ((offset = zfFindElement(dev, buf, ZM_WLAN_EID_HT_CAPABILITY)) != 0xffff) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_HT_CAPABILITY); + if (offset != 0xffff) { /* atheros pre n */ zm_debug_msg0("atheros pre n"); @@ -2645,7 +2675,8 @@ void zfStaStoreAsocRspIe(zdev_t* dev, zbuf_t* buf) asocBw40 = (u8_t)((wd->sta.ie.HtCap.HtCapInfo & HTCAP_SupChannelWidthSet) >> 1); /* HT information */ - if ((offset = zfFindElement(dev, buf, ZM_WLAN_EID_EXTENDED_HT_CAPABILITY)) != 0xffff) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_EXTENDED_HT_CAPABILITY); + if (offset != 0xffff) { /* atheros pre n */ zm_debug_msg0("atheros pre n HTINFO"); @@ -2815,7 +2846,8 @@ void zfStaProcessProbeReq(zdev_t* dev, zbuf_t* buf, u16_t* src) } /* check SSID */ - if ((offset = zfFindElement(dev, buf, ZM_WLAN_EID_SSID)) == 0xffff) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_SSID); + if (offset == 0xffff) { zm_msg0_mm(ZM_LV_3, "probe req SSID not found"); return; @@ -3774,7 +3806,8 @@ static struct zsBssInfo* zfInfraFindAPToConnect(zdev_t* dev, } /* Skip if AP in blocking list */ - if ((ret = zfStaIsApInBlockingList(dev, pBssInfo->bssid)) == TRUE) + ret = zfStaIsApInBlockingList(dev, pBssInfo->bssid); + if (ret == TRUE) { zm_msg0_mm(ZM_LV_0, "Candidate AP in blocking List, skip if there's stilla choice!"); pNowBssInfo = pBssInfo; @@ -5007,7 +5040,8 @@ void zfSendNullData(zdev_t* dev, u8_t type) zmw_get_wlan_dev(dev); - if ((buf = zfwBufAllocate(dev, 1024)) == NULL) + buf = zfwBufAllocate(dev, 1024); + if (buf == NULL) { zm_msg0_mm(ZM_LV_0, "Alloc mm buf Fail!"); return; @@ -5056,8 +5090,9 @@ void zfSendNullData(zdev_t* dev, u8_t type) /*increase unicast frame counter*/ wd->commTally.txUnicastFrm++; - if ((err = zfHpSend(dev, header, hlen, NULL, 0, NULL, 0, buf, 0, - ZM_INTERNAL_ALLOC_BUF, 0, 0xff)) != ZM_SUCCESS) + err = zfHpSend(dev, header, hlen, NULL, 0, NULL, 0, buf, 0, + ZM_INTERNAL_ALLOC_BUF, 0, 0xff); + if (err != ZM_SUCCESS) { goto zlError; } @@ -5083,7 +5118,8 @@ void zfSendPSPoll(zdev_t* dev) zmw_get_wlan_dev(dev); - if ((buf = zfwBufAllocate(dev, 1024)) == NULL) + buf = zfwBufAllocate(dev, 1024); + if (buf == NULL) { zm_msg0_mm(ZM_LV_0, "Alloc mm buf Fail!"); return; @@ -5107,8 +5143,9 @@ void zfSendPSPoll(zdev_t* dev) // goto zlError; //} - if ((err = zfHpSend(dev, header, hlen, NULL, 0, NULL, 0, buf, 0, - ZM_INTERNAL_ALLOC_BUF, 0, 0xff)) != ZM_SUCCESS) + err = zfHpSend(dev, header, hlen, NULL, 0, NULL, 0, buf, 0, + ZM_INTERNAL_ALLOC_BUF, 0, 0xff); + if (err != ZM_SUCCESS) { goto zlError; } @@ -5134,7 +5171,8 @@ void zfSendBA(zdev_t* dev, u16_t start_seq, u8_t *bitmap) zmw_get_wlan_dev(dev); - if ((buf = zfwBufAllocate(dev, 1024)) == NULL) + buf = zfwBufAllocate(dev, 1024); + if (buf == NULL) { zm_msg0_mm(ZM_LV_0, "Alloc mm buf Fail!"); return; @@ -5166,8 +5204,9 @@ void zfSendBA(zdev_t* dev, u16_t start_seq, u8_t *bitmap) offset++; } - if ((err = zfHpSend(dev, header, hlen, NULL, 0, NULL, 0, buf, 0, - ZM_INTERNAL_ALLOC_BUF, 0, 0xff)) != ZM_SUCCESS) + err = zfHpSend(dev, header, hlen, NULL, 0, NULL, 0, buf, 0, + ZM_INTERNAL_ALLOC_BUF, 0, 0xff); + if (err != ZM_SUCCESS) { goto zlError; } diff --git a/drivers/staging/otus/80211core/coid.c b/drivers/staging/otus/80211core/coid.c index 0524e1f36f0d..229aed8f889e 100644 --- a/drivers/staging/otus/80211core/coid.c +++ b/drivers/staging/otus/80211core/coid.c @@ -553,7 +553,8 @@ u8_t zfiWlanSetKey(zdev_t* dev, struct zsKeyInfo keyInfo) if (keyInfo.flag & ZM_KEY_FLAG_PK) { /* Find STA's information */ - if ((id = zfApFindSta(dev, keyInfo.macAddr)) == 0xffff) + id = zfApFindSta(dev, keyInfo.macAddr); + if (id == 0xffff) { /* Can't STA in the staTable */ return ZM_STATUS_FAILURE; diff --git a/drivers/staging/otus/80211core/cpsmgr.c b/drivers/staging/otus/80211core/cpsmgr.c index 98e1f0cc0727..32313beba78d 100644 --- a/drivers/staging/otus/80211core/cpsmgr.c +++ b/drivers/staging/otus/80211core/cpsmgr.c @@ -602,7 +602,8 @@ void zfPowerSavingMgrProcessBeacon(zdev_t* dev, zbuf_t* buf) wd->sta.psMgr.isSleepAllowed = 1; - if ( (offset=zfFindElement(dev, buf, ZM_WLAN_EID_TIM)) != 0xffff ) + offset = zfFindElement(dev, buf, ZM_WLAN_EID_TIM); + if (offset != 0xffff) { length = zmw_rx_buf_readb(dev, buf, offset+1); diff --git a/drivers/staging/otus/80211core/ctxrx.c b/drivers/staging/otus/80211core/ctxrx.c index 4e7f4bd86f47..a127196260e6 100644 --- a/drivers/staging/otus/80211core/ctxrx.c +++ b/drivers/staging/otus/80211core/ctxrx.c @@ -109,7 +109,8 @@ void zfGetRxIvIcvLength(zdev_t* dev, zbuf_t* buf, u8_t vap, u16_t* pIvLen, addr[2] = zmw_rx_buf_readh(dev, buf, ZM_WLAN_HEADER_A2_OFFSET+4); /* Find STA's information */ - if ((id = zfApFindSta(dev, addr)) != 0xffff) + id = zfApFindSta(dev, addr); + if (id != 0xffff) { if (wd->ap.staTable[id].encryMode == ZM_TKIP) { @@ -132,7 +133,8 @@ void zfGetRxIvIcvLength(zdev_t* dev, zbuf_t* buf, u8_t vap, u16_t* pIvLen, } } /* WDS port checking */ - if ((wdsPort = vap - 0x20) >= ZM_MAX_WDS_SUPPORT) + wdsPort = vap - 0x20; + if (wdsPort >= ZM_MAX_WDS_SUPPORT) { wdsPort = 0; } @@ -741,8 +743,9 @@ u16_t zfiTxSend80211Mgmt(zdev_t* dev, zbuf_t* buf, u16_t port) zfwBufRemoveHead(dev, buf, 24); - if ((err = zfHpSend(dev, header, hlen, NULL, 0, NULL, 0, buf, 0, - ZM_EXTERNAL_ALLOC_BUF, 0, 0)) != ZM_SUCCESS) + err = zfHpSend(dev, header, hlen, NULL, 0, NULL, 0, buf, 0, + ZM_EXTERNAL_ALLOC_BUF, 0, 0); + if (err != ZM_SUCCESS) { goto zlError; } @@ -799,7 +802,8 @@ u16_t zfiTxSendEth(zdev_t* dev, zbuf_t* buf, u16_t port) ZM_PERFORMANCE_TX_MSDU(dev, wd->tick); zm_msg1_tx(ZM_LV_2, "zfiTxSendEth(), port=", port); /* Return error if port is disabled */ - if ((err = zfTxPortControl(dev, buf, port)) == ZM_PORT_DISABLED) + err = zfTxPortControl(dev, buf, port); + if (err == ZM_PORT_DISABLED) { err = ZM_ERR_TX_PORT_DISABLED; goto zlError; @@ -809,7 +813,8 @@ u16_t zfiTxSendEth(zdev_t* dev, zbuf_t* buf, u16_t port) if ((wd->wlanMode == ZM_MODE_AP) && (port < 0x20)) { /* AP : Buffer frame for power saving STA */ - if ((ret = zfApBufferPsFrame(dev, buf, port)) == 1) + ret = zfApBufferPsFrame(dev, buf, port); + if (ret == 1) { return ZM_SUCCESS; } @@ -1119,7 +1124,8 @@ u16_t zfTxSendEth(zdev_t* dev, zbuf_t* buf, u16_t port, u16_t bufType, u16_t fla i = 0; while( frameLen > 0 ) { - if ((frag.buf[i] = zfwBufAllocate(dev, fragLen+32)) != NULL) + frag.buf[i] = zfwBufAllocate(dev, fragLen+32); + if (frag.buf[i] != NULL) { frag.bufType[i] = ZM_INTERNAL_ALLOC_BUF; frag.seq[i] = frag.seq[0] + i; @@ -1276,7 +1282,8 @@ void zfCoreRecv(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo) bssid[2] = zmw_buf_readh(dev, buf, 20); /* Validate Rx frame */ - if ((ret = zfWlanRxValidate(dev, buf)) != ZM_SUCCESS) + ret = zfWlanRxValidate(dev, buf); + if (ret != ZM_SUCCESS) { zm_msg1_rx(ZM_LV_1, "Rx invalid:", ret); goto zlError; @@ -1301,7 +1308,8 @@ void zfCoreRecv(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo) #endif /* Filter Rx frame */ - if ((ret = zfWlanRxFilter(dev, buf)) != ZM_SUCCESS) + ret = zfWlanRxFilter(dev, buf); + if (ret != ZM_SUCCESS) { zm_msg1_rx(ZM_LV_1, "Rx duplicated:", ret); goto zlError; @@ -2086,7 +2094,8 @@ void zfiRecv80211(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo) //zm_msg0_rx(ZM_LV_0, "Rx data"); if (wd->wlanMode == ZM_MODE_AP) { - if ((ret = zfApUpdatePsBit(dev, buf, &vap, &uapsdTrig)) != ZM_SUCCESS) + ret = zfApUpdatePsBit(dev, buf, &vap, &uapsdTrig); + if (ret != ZM_SUCCESS) { zfwBufFree(dev, buf, 0); return; @@ -2115,7 +2124,8 @@ void zfiRecv80211(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo) for (ii=0; ii<pktNum; ii++) { //if ((psBuf = zfQueueGet(dev, wd->ap.uapsdQ)) != NULL) - if ((psBuf = zfQueueGetWithMac(dev, wd->ap.uapsdQ, src, &mb)) != NULL) + psBuf = zfQueueGetWithMac(dev, wd->ap.uapsdQ, src, &mb); + if (psBuf != NULL) { if ((ii+1) == pktNum) { @@ -2232,7 +2242,8 @@ void zfiRecv80211(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo) } else { - if ( (buf = zfDefragment(dev, buf, &bIsDefrag, addInfo)) == NULL ) + buf = zfDefragment(dev, buf, &bIsDefrag, addInfo); + if (buf == NULL) { /* In this case, the buffer has been freed in zfDefragment */ return; @@ -2836,7 +2847,8 @@ void zfiRecv80211(zdev_t* dev, zbuf_t* buf, struct zsAdditionInfo* addInfo) zfwBufRemoveHead(dev, buf, 18+offset); #endif // ZM_ENABLE_NATIVE_WIFI #if 1 - if ((ret = zfIntrabssForward(dev, buf, vap)) == 1) + ret = zfIntrabssForward(dev, buf, vap); + if (ret == 1) { /* Free Rx buffer if intra-BSS unicast frame */ zm_msg0_rx(ZM_LV_2, "Free intra-BSS unicast frame"); @@ -3037,7 +3049,8 @@ u16_t zfWlanRxValidate(zdev_t* dev, zbuf_t* buf) } else if ( wd->wlanMode != ZM_MODE_PSEUDO ) { - if ( (ret=zfStaRxValidateFrame(dev, buf))!=ZM_SUCCESS ) + ret = zfStaRxValidateFrame(dev, buf); + if (ret != ZM_SUCCESS) { //zm_debug_msg1("discard frame, code = ", ret); return ret; @@ -3787,12 +3800,14 @@ void zfPushVtxq(zdev_t* dev) /* 2006.12.20, Serve Management queue */ while( zfHpGetFreeTxdCount(dev) > 0 ) { - if ((buf = zfGetVmmq(dev)) != 0) + buf = zfGetVmmq(dev); + if (buf != 0) { txed = 1; //zm_debug_msg2("send buf = ", buf); - if ((err = zfHpSend(dev, NULL, 0, NULL, 0, NULL, 0, buf, 0, - ZM_INTERNAL_ALLOC_BUF, 0, 0xff)) != ZM_SUCCESS) + err = zfHpSend(dev, NULL, 0, NULL, 0, NULL, 0, buf, 0, + ZM_INTERNAL_ALLOC_BUF, 0, 0xff); + if (err != ZM_SUCCESS) { zfwBufFree(dev, buf, 0); } @@ -3831,9 +3846,11 @@ void zfPushVtxq(zdev_t* dev) /* Service VTxQ[3] */ for (i=0; i<4; i++) { - if ((freeTxd = zfHpGetFreeTxdCount(dev)) >= 3) + freeTxd = zfHpGetFreeTxdCount(dev); + if (freeTxd >= 3) { - if ((buf = zfGetVtxq(dev, 3)) != 0) + buf = zfGetVtxq(dev, 3); + if (buf != 0) { txed = 1; //zm_debug_msg2("send buf = ", buf); @@ -3850,9 +3867,11 @@ void zfPushVtxq(zdev_t* dev) /* Service VTxQ[2] */ for (i=0; i<3; i++) { - if ((freeTxd = zfHpGetFreeTxdCount(dev)) >= (zfHpGetMaxTxdCount(dev)*1/4)) + freeTxd = zfHpGetFreeTxdCount(dev); + if (freeTxd >= (zfHpGetMaxTxdCount(dev)*1/4)) { - if ((buf = zfGetVtxq(dev, 2)) != 0) + buf = zfGetVtxq(dev, 2); + if (buf != 0) { txed = 1; zfTxSendEth(dev, buf, 0, ZM_EXTERNAL_ALLOC_BUF, 0); @@ -3860,7 +3879,8 @@ void zfPushVtxq(zdev_t* dev) } if (wd->sta.ac0PriorityHigherThanAc2 == 1) { - if ((buf = zfGetVtxq(dev, 0)) != 0) + buf = zfGetVtxq(dev, 0); + if (buf != 0) { txed = 1; zfTxSendEth(dev, buf, 0, ZM_EXTERNAL_ALLOC_BUF, 0); @@ -3877,9 +3897,11 @@ void zfPushVtxq(zdev_t* dev) /* Service VTxQ[0] */ for (i=0; i<2; i++) { - if ((freeTxd = zfHpGetFreeTxdCount(dev)) >= (zfHpGetMaxTxdCount(dev)*2/4)) + freeTxd = zfHpGetFreeTxdCount(dev); + if (freeTxd >= (zfHpGetMaxTxdCount(dev)*2/4)) { - if ((buf = zfGetVtxq(dev, 0)) != 0) + buf = zfGetVtxq(dev, 0); + if (buf != 0) { txed = 1; zfTxSendEth(dev, buf, 0, ZM_EXTERNAL_ALLOC_BUF, 0); @@ -3894,9 +3916,11 @@ void zfPushVtxq(zdev_t* dev) } /* Service VTxQ[1] */ - if ((freeTxd = zfHpGetFreeTxdCount(dev)) >= (zfHpGetMaxTxdCount(dev)*3/4)) + freeTxd = zfHpGetFreeTxdCount(dev); + if (freeTxd >= (zfHpGetMaxTxdCount(dev)*3/4)) { - if ((buf = zfGetVtxq(dev, 1)) != 0) + buf = zfGetVtxq(dev, 1); + if (buf != 0) { txed = 1; zfTxSendEth(dev, buf, 0, ZM_EXTERNAL_ALLOC_BUF, 0); @@ -3983,9 +4007,10 @@ void zf80211FrameSend(zdev_t* dev, zbuf_t* buf, u16_t* header, u16_t snapLen, } wd->ledStruct.txTraffic++; - if ((err = zfHpSend(dev, header, headerLen, snap, snapLen, + err = zfHpSend(dev, header, headerLen, snap, snapLen, tail, tailLen, buf, offset, - bufType, ac, keyIdx)) != ZM_SUCCESS) + bufType, ac, keyIdx); + if (err != ZM_SUCCESS) { if (bufType == ZM_EXTERNAL_ALLOC_BUF) { diff --git a/drivers/staging/otus/80211core/queue.c b/drivers/staging/otus/80211core/queue.c index d294831b5c36..29be4bdb40a4 100644 --- a/drivers/staging/otus/80211core/queue.c +++ b/drivers/staging/otus/80211core/queue.c @@ -31,8 +31,9 @@ struct zsQueue* zfQueueCreate(zdev_t* dev, u16_t size) { struct zsQueue* q; - if ((q = (struct zsQueue*)zfwMemAllocate(dev, sizeof(struct zsQueue) - + (sizeof(struct zsQueueCell)*(size-1)))) != NULL) + q = (struct zsQueue*)zfwMemAllocate(dev, sizeof(struct zsQueue) + + (sizeof(struct zsQueueCell)*(size-1))); + if (q != NULL) { q->size = size; q->sizeMask = size-1; diff --git a/drivers/staging/otus/80211core/ratectrl.c b/drivers/staging/otus/80211core/ratectrl.c index a43104cd7f51..a1abe2f4f342 100644 --- a/drivers/staging/otus/80211core/ratectrl.c +++ b/drivers/staging/otus/80211core/ratectrl.c @@ -538,7 +538,8 @@ u16_t zfRateCtrlGetTxRate(zdev_t* dev, struct zsRcCell* rcCell, u16_t* probing) ((rcCell->currentRate <= 16) && ((wd->PER[rcCell->currentRate]/2) <= ZM_RATE_PROBING_THRESHOLD))) { - if ((newRate=zfRateCtrlGetHigherRate(rcCell)) != rcCell->currentRate) + newRate = zfRateCtrlGetHigherRate(rcCell); + if (newRate != rcCell->currentRate) { *probing = 1; wd->probeCount++; diff --git a/drivers/staging/otus/hal/hpani.c b/drivers/staging/otus/hal/hpani.c index 0afecd8c2de4..f53e483b394d 100644 --- a/drivers/staging/otus/hal/hpani.c +++ b/drivers/staging/otus/hal/hpani.c @@ -18,8 +18,8 @@ #include "hpusb.h" -extern u16_t zfDelayWriteInternalReg(zdev_t* dev, u32_t addr, u32_t val); -extern u16_t zfFlushDelayWrite(zdev_t* dev); +extern u16_t zfDelayWriteInternalReg(zdev_t *dev, u32_t addr, u32_t val); +extern u16_t zfFlushDelayWrite(zdev_t *dev); /* * Anti noise immunity support. We track phy errors and react @@ -52,13 +52,13 @@ extern u16_t zfFlushDelayWrite(zdev_t* dev); #define ZM_HAL_EP_RND(x, mul) \ ((((x)%(mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul)) -s32_t BEACON_RSSI(zdev_t* dev) +s32_t BEACON_RSSI(zdev_t *dev) { s32_t rssi; struct zsHpPriv *HpPriv; zmw_get_wlan_dev(dev); - HpPriv = (struct zsHpPriv*)wd->hpPrivate; + HpPriv = (struct zsHpPriv *)wd->hpPrivate; rssi = ZM_HAL_EP_RND(HpPriv->stats.ast_nodestats.ns_avgbrssi, ZM_HAL_RSSI_EP_MULTIPLIER); @@ -70,7 +70,7 @@ s32_t BEACON_RSSI(zdev_t* dev) * resets the channel statistics */ -void zfHpAniAttach(zdev_t* dev) +void zfHpAniAttach(zdev_t *dev) { #define N(a) (sizeof(a) / sizeof(a[0])) u32_t i; @@ -82,11 +82,10 @@ void zfHpAniAttach(zdev_t* dev) const int firpwr[] = { -78, -78, -78, -78, -80 }; zmw_get_wlan_dev(dev); - HpPriv = (struct zsHpPriv*)wd->hpPrivate; + HpPriv = (struct zsHpPriv *)wd->hpPrivate; - for (i = 0; i < 5; i++) - { - HpPriv->totalSizeDesired[i] = totalSizeDesired[i]; + for (i = 0; i < 5; i++) { + HpPriv->totalSizeDesired[i] = totalSizeDesired[i]; HpPriv->coarseHigh[i] = coarseHigh[i]; HpPriv->coarseLow[i] = coarseLow[i]; HpPriv->firpwr[i] = firpwr[i]; @@ -96,8 +95,7 @@ void zfHpAniAttach(zdev_t* dev) HpPriv->hasHwPhyCounters = 1; memset((char *)&HpPriv->ani, 0, sizeof(HpPriv->ani)); - for (i = 0; i < N(wd->regulationTable.allowChannel); i++) - { + for (i = 0; i < ARRAY_SIZE(HpPriv->ani); i++) { /* New ANI stuff */ HpPriv->ani[i].ofdmTrigHigh = ZM_HAL_ANI_OFDM_TRIG_HIGH; HpPriv->ani[i].ofdmTrigLow = ZM_HAL_ANI_OFDM_TRIG_LOW; @@ -109,14 +107,12 @@ void zfHpAniAttach(zdev_t* dev) HpPriv->ani[i].cckWeakSigThreshold = ZM_HAL_ANI_CCK_WEAK_SIG_THR; HpPriv->ani[i].spurImmunityLevel = ZM_HAL_ANI_SPUR_IMMUNE_LVL; HpPriv->ani[i].firstepLevel = ZM_HAL_ANI_FIRSTEP_LVL; - if (HpPriv->hasHwPhyCounters) - { + if (HpPriv->hasHwPhyCounters) { HpPriv->ani[i].ofdmPhyErrBase = 0;//AR_PHY_COUNTMAX - ZM_HAL_ANI_OFDM_TRIG_HIGH; HpPriv->ani[i].cckPhyErrBase = 0;//AR_PHY_COUNTMAX - ZM_HAL_ANI_CCK_TRIG_HIGH; } } - if (HpPriv->hasHwPhyCounters) - { + if (HpPriv->hasHwPhyCounters) { //zm_debug_msg2("Setting OfdmErrBase = 0x", HpPriv->ani[0].ofdmPhyErrBase); //zm_debug_msg2("Setting cckErrBase = 0x", HpPriv->ani[0].cckPhyErrBase); //OS_REG_WRITE(ah, AR_PHY_ERR_1, HpPriv->ani[0].ofdmPhyErrBase); @@ -135,7 +131,7 @@ void zfHpAniAttach(zdev_t* dev) /* * Control Adaptive Noise Immunity Parameters */ -u8_t zfHpAniControl(zdev_t* dev, ZM_HAL_ANI_CMD cmd, int param) +u8_t zfHpAniControl(zdev_t *dev, ZM_HAL_ANI_CMD cmd, int param) { #define N(a) (sizeof(a)/sizeof(a[0])) typedef s32_t TABLE[]; @@ -143,7 +139,7 @@ u8_t zfHpAniControl(zdev_t* dev, ZM_HAL_ANI_CMD cmd, int param) struct zsAniState *aniState; zmw_get_wlan_dev(dev); - HpPriv = (struct zsHpPriv*)wd->hpPrivate; + HpPriv = (struct zsHpPriv *)wd->hpPrivate; aniState = HpPriv->curani; switch (cmd) @@ -152,8 +148,7 @@ u8_t zfHpAniControl(zdev_t* dev, ZM_HAL_ANI_CMD cmd, int param) { u32_t level = param; - if (level >= N(HpPriv->totalSizeDesired)) - { + if (level >= N(HpPriv->totalSizeDesired)) { zm_debug_msg1("level out of range, desired level : ", level); zm_debug_msg1("max level : ", N(HpPriv->totalSizeDesired)); return FALSE; diff --git a/drivers/staging/otus/hal/hpani.h b/drivers/staging/otus/hal/hpani.h index 96e69af3c685..b89241371ab1 100644 --- a/drivers/staging/otus/hal/hpani.h +++ b/drivers/staging/otus/hal/hpani.h @@ -99,8 +99,8 @@ typedef enum { ZM_HAL_ANI_PHYERR_RESET, /* reset phy error stats */ } ZM_HAL_ANI_CMD; -#define AR_PHY_COUNTMAX (3 << 22) // Max counted before intr -#define ZM_HAL_PROCESS_ANI 0x00000001 /* ANI state setup */ +#define AR_PHY_COUNTMAX (3 << 22) /* Max counted before intr */ +#define ZM_HAL_PROCESS_ANI 0x00000001 /* ANI state setup */ #define ZM_RSSI_DUMMY_MARKER 0x127 /* PHY registers in ar5416, related base and register offsets @@ -353,7 +353,7 @@ typedef enum { #define AR_PHY_CCK_DETECT 0x1C6208 #define AR_PHY_CCK_DETECT_WEAK_SIG_THR_CCK 0x0000003F #define AR_PHY_CCK_DETECT_WEAK_SIG_THR_CCK_S 0 -#define AR_PHY_CCK_DETECT_ANT_SWITCH_TIME 0x00001FC0 // [12:6] settling time for antenna switch +#define AR_PHY_CCK_DETECT_ANT_SWITCH_TIME 0x00001FC0 /* [12:6] settling time for antenna switch */ #define AR_PHY_CCK_DETECT_ANT_SWITCH_TIME_S 6 #define AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV 0x2000 @@ -392,7 +392,6 @@ typedef enum { #define AR_PHY_TPCRG1_PD_GAIN_2_S 18 #define AR_PHY_TPCRG1_PD_GAIN_3 0x00300000 #define AR_PHY_TPCRG1_PD_GAIN_3_S 20 -// #define AR_PHY_ANALOG_SWAP 0xa268 #define AR_PHY_SWAP_ALT_CHAIN 0x00000040 diff --git a/drivers/staging/otus/hal/hpfw2.c b/drivers/staging/otus/hal/hpfw2.c index baceb0299765..17f405b5db17 100644 --- a/drivers/staging/otus/hal/hpfw2.c +++ b/drivers/staging/otus/hal/hpfw2.c @@ -1015,4 +1015,4 @@ const u32_t zcP2FwImage[] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }; -const u32_t zcP2FwImageSize=15964; +const u32_t zcP2FwImageSize = 15964; diff --git a/drivers/staging/otus/hal/hpfwu.c b/drivers/staging/otus/hal/hpfwu.c index 2b77cbacc6d6..68fabef180af 100644 --- a/drivers/staging/otus/hal/hpfwu.c +++ b/drivers/staging/otus/hal/hpfwu.c @@ -1014,4 +1014,4 @@ const u32_t zcFwImage[] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, }; -const u32_t zcFwImageSize=15936; +const u32_t zcFwImageSize = 15936; diff --git a/drivers/staging/otus/hal/hpfwu_2k.c b/drivers/staging/otus/hal/hpfwu_2k.c index 94e2caca5369..b675d6d556b2 100644 --- a/drivers/staging/otus/hal/hpfwu_2k.c +++ b/drivers/staging/otus/hal/hpfwu_2k.c @@ -1013,4 +1013,4 @@ const u32_t zcFwImage[] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }; -const u32_t zcFwImageSize=15928; +const u32_t zcFwImageSize = 15928; diff --git a/drivers/staging/otus/hal/hpfwu_BA.c b/drivers/staging/otus/hal/hpfwu_BA.c index 0c741571f2b5..f89419b37431 100644 --- a/drivers/staging/otus/hal/hpfwu_BA.c +++ b/drivers/staging/otus/hal/hpfwu_BA.c @@ -871,4 +871,4 @@ const u32_t zcFwImage[] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, }; -const u32_t zcFwImageSize=13656; +const u32_t zcFwImageSize = 13656; diff --git a/drivers/staging/otus/hal/hpfwu_OTUS_RC.c b/drivers/staging/otus/hal/hpfwu_OTUS_RC.c index 089d3e0ad853..accbec4369f7 100644 --- a/drivers/staging/otus/hal/hpfwu_OTUS_RC.c +++ b/drivers/staging/otus/hal/hpfwu_OTUS_RC.c @@ -712,4 +712,4 @@ const u32_t zcFwImage[] = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, }; -const u32_t zcFwImageSize=11104; +const u32_t zcFwImageSize = 11104; diff --git a/drivers/staging/otus/hal/hpfwuinit.c b/drivers/staging/otus/hal/hpfwuinit.c index ed80ffafaffc..5d0dccca080c 100644 --- a/drivers/staging/otus/hal/hpfwuinit.c +++ b/drivers/staging/otus/hal/hpfwuinit.c @@ -237,4 +237,4 @@ const u32_t zcFwImage[] = { 0x45485441, 0x38731652, 0x89ACFF91, 0xEE55D178, 0xEE000D0A, }; -const u32_t zcFwImageSize=3508; +const u32_t zcFwImageSize = 3508; diff --git a/drivers/staging/otus/hal/hpmain.c b/drivers/staging/otus/hal/hpmain.c index 8dff5b97dfe3..5f412e020457 100644 --- a/drivers/staging/otus/hal/hpmain.c +++ b/drivers/staging/otus/hal/hpmain.c @@ -142,8 +142,9 @@ u16_t zfHpInit(zdev_t* dev, u32_t frequency) if (wd->modeMDKEnable) { /* download the MDK firmware */ - if ((ret = zfFirmwareDownload(dev, (u32_t*)zcDKFwImage, - (u32_t)zcDKFwImageSize, ZM_FIRMWARE_WLAN_ADDR)) != ZM_SUCCESS) + ret = zfFirmwareDownload(dev, (u32_t*)zcDKFwImage, + (u32_t)zcDKFwImageSize, ZM_FIRMWARE_WLAN_ADDR); + if (ret != ZM_SUCCESS) { /* TODO : exception handling */ //return 1; @@ -153,8 +154,9 @@ u16_t zfHpInit(zdev_t* dev, u32_t frequency) { #ifndef ZM_OTUS_LINUX_PHASE_2 /* download the normal firmware */ - if ((ret = zfFirmwareDownload(dev, (u32_t*)zcFwImage, - (u32_t)zcFwImageSize, ZM_FIRMWARE_WLAN_ADDR)) != ZM_SUCCESS) + ret = zfFirmwareDownload(dev, (u32_t*)zcFwImage, + (u32_t)zcFwImageSize, ZM_FIRMWARE_WLAN_ADDR); + if (ret != ZM_SUCCESS) { /* TODO : exception handling */ //return 1; @@ -162,16 +164,18 @@ u16_t zfHpInit(zdev_t* dev, u32_t frequency) #else // 1-PH fw: ReadMac() store some global variable - if ((ret = zfFirmwareDownloadNotJump(dev, (u32_t*)zcFwBufImage, - (u32_t)zcFwBufImageSize, 0x102800)) != ZM_SUCCESS) + ret = zfFirmwareDownloadNotJump(dev, (u32_t*)zcFwBufImage, + (u32_t)zcFwBufImageSize, 0x102800); + if (ret != ZM_SUCCESS) { DbgPrint("Dl zcFwBufImage failed!"); } zfwSleep(dev, 1000); - if ((ret = zfFirmwareDownload(dev, (u32_t*)zcFwImage, - (u32_t)zcFwImageSize, ZM_FIRMWARE_WLAN_ADDR)) != ZM_SUCCESS) + ret = zfFirmwareDownload(dev, (u32_t*)zcFwImage, + (u32_t)zcFwImageSize, ZM_FIRMWARE_WLAN_ADDR); + if (ret != ZM_SUCCESS) { DbgPrint("Dl zcFwBufImage failed!"); } @@ -249,15 +253,17 @@ u16_t zfHpReinit(zdev_t* dev, u32_t frequency) #ifndef ZM_OTUS_LINUX_PHASE_2 /* Download firmware */ - if ((ret = zfFirmwareDownload(dev, (u32_t*)zcFwImage, - (u32_t)zcFwImageSize, ZM_FIRMWARE_WLAN_ADDR)) != ZM_SUCCESS) + ret = zfFirmwareDownload(dev, (u32_t*)zcFwImage, + (u32_t)zcFwImageSize, ZM_FIRMWARE_WLAN_ADDR); + if (ret != ZM_SUCCESS) { /* TODO : exception handling */ //return 1; } #else - if ((ret = zfFirmwareDownload(dev, (u32_t*)zcP2FwImage, - (u32_t)zcP2FwImageSize, ZM_FIRMWARE_WLAN_ADDR)) != ZM_SUCCESS) + ret = zfFirmwareDownload(dev, (u32_t*)zcP2FwImage, + (u32_t)zcP2FwImageSize, ZM_FIRMWARE_WLAN_ADDR); + if (ret != ZM_SUCCESS) { /* TODO : exception handling */ //return 1; diff --git a/drivers/staging/otus/hal/hpreg.c b/drivers/staging/otus/hal/hpreg.c index 178777c09dbd..da3b77433874 100644 --- a/drivers/staging/otus/hal/hpreg.c +++ b/drivers/staging/otus/hal/hpreg.c @@ -30,7 +30,7 @@ #include "hpusb.h" /* used throughout this file... */ -#define N(a) (sizeof (a) / sizeof (a[0])) +#define N(a) (sizeof(a) / sizeof(a[0])) #define HAL_MODE_11A_TURBO HAL_MODE_108A #define HAL_MODE_11G_TURBO HAL_MODE_108G @@ -78,7 +78,7 @@ enum { }; #define MKK5GHZ_FLAG1 (DISALLOW_ADHOC_11A_TURB | NEED_NFC | LIMIT_FRAME_4MS) -#define MKK5GHZ_FLAG2 (DISALLOW_ADHOC_11A | DISALLOW_ADHOC_11A_TURB | NEED_NFC| LIMIT_FRAME_4MS) +#define MKK5GHZ_FLAG2 (DISALLOW_ADHOC_11A | DISALLOW_ADHOC_11A_TURB | NEED_NFC | LIMIT_FRAME_4MS) typedef enum { DFS_UNINIT_DOMAIN = 0, /* Uninitialized dfs domain */ @@ -272,7 +272,7 @@ static REG_DMN_PAIR_MAPPING regDomainPairs[] = { /* MKK4 */ {MKK4_MKKB, MKK4, MKKA, MKK5GHZ_FLAG2, NEED_NFC, PSCAN_MKK3 | PSCAN_MKKA | PSCAN_MKKA_G, CTRY_JAPAN10 }, {MKK4_MKKA1, MKK4, MKKA, MKK5GHZ_FLAG1, NEED_NFC, PSCAN_MKK3 | PSCAN_MKKA1 | PSCAN_MKKA1_G, CTRY_JAPAN28 }, - {MKK4_MKKA2, MKK4, MKKA, MKK5GHZ_FLAG1, NEED_NFC, PSCAN_MKK3 |PSCAN_MKKA2 | PSCAN_MKKA2_G, CTRY_JAPAN11 }, + {MKK4_MKKA2, MKK4, MKKA, MKK5GHZ_FLAG1, NEED_NFC, PSCAN_MKK3 | PSCAN_MKKA2 | PSCAN_MKKA2_G, CTRY_JAPAN11 }, {MKK4_MKKC, MKK4, MKKC, MKK5GHZ_FLAG1, NEED_NFC, PSCAN_MKK3, CTRY_JAPAN12 }, {MKK4_FCCA, MKK4, FCCA, MKK5GHZ_FLAG1, NEED_NFC, NO_PSCAN, CTRY_JAPAN29 }, {MKK4_MKKA, MKK4, MKKA, MKK5GHZ_FLAG1, NEED_NFC, PSCAN_MKK3 | PSCAN_MKKA, CTRY_JAPAN36 }, @@ -301,7 +301,7 @@ static REG_DMN_PAIR_MAPPING regDomainPairs[] = { {MKK8_MKKA2, MKK8, MKKA, MKK5GHZ_FLAG1, NEED_NFC, PSCAN_MKK1 | PSCAN_MKK3 | PSCAN_MKKA2 | PSCAN_MKKA2_G, CTRY_JAPAN23 }, {MKK8_MKKC, MKK8, MKKC, MKK5GHZ_FLAG1, NEED_NFC, PSCAN_MKK1 | PSCAN_MKK3 , CTRY_JAPAN24 }, - /* MKK9 */ + /* MKK9 */ {MKK9_MKKA, MKK9, MKKA, MKK5GHZ_FLAG1, NEED_NFC, NO_PSCAN, CTRY_JAPAN34 }, {MKK9_FCCA, MKK9, FCCA, MKK5GHZ_FLAG1, NEED_NFC, NO_PSCAN, CTRY_JAPAN37 }, {MKK9_MKKA1, MKK9, MKKA, MKK5GHZ_FLAG1, NEED_NFC, PSCAN_MKKA1 | PSCAN_MKKA1_G, CTRY_JAPAN38 }, @@ -359,7 +359,7 @@ static REG_DMN_PAIR_MAPPING regDomainPairs[] = { #define COUNTRY_CODE_MASK 0x03ff #define CF_INTERFERENCE (CHANNEL_CW_INT | CHANNEL_RADAR_INT) #define CHANNEL_14 (2484) /* 802.11g operation is not permitted on channel 14 */ -#define IS_11G_CH14(_ch,_cf) \ +#define IS_11G_CH14(_ch, _cf) \ (((_ch) == CHANNEL_14) && ((_cf) == CHANNEL_G)) #define YES TRUE @@ -373,183 +373,183 @@ enum { typedef struct { HAL_CTRY_CODE countryCode; HAL_REG_DOMAIN regDmnEnum; - const char* isoName; - const char* name; + const char *isoName; + const char *name; HAL_BOOL allow11g; HAL_BOOL allow11aTurbo; HAL_BOOL allow11gTurbo; - HAL_BOOL allow11na; /* HT-40 allowed in 5GHz? */ - HAL_BOOL allow11ng; /* HT-40 allowed in 2GHz? */ + HAL_BOOL allow11na; /* HT-40 allowed in 5GHz? */ + HAL_BOOL allow11ng; /* HT-40 allowed in 2GHz? */ u16_t outdoorChanStart; } COUNTRY_CODE_TO_ENUM_RD; static COUNTRY_CODE_TO_ENUM_RD allCountries[] = { - {CTRY_DEBUG, NO_ENUMRD, "DB", "DEBUG", YES, YES, YES, YES, YES, 7000 }, - {CTRY_DEFAULT, DEF_REGDMN, "NA", "NO_COUNTRY_SET", YES, YES, YES, YES, YES, 7000 }, - {CTRY_ALBANIA, NULL1_WORLD, "AL", "ALBANIA", YES, NO, YES, NO, YES, 7000 }, - {CTRY_ALGERIA, NULL1_WORLD, "DZ", "ALGERIA", YES, NO, YES, NO, YES, 7000 }, - {CTRY_ARGENTINA, APL3_WORLD, "AR", "ARGENTINA", YES, NO, NO, NO, NO, 7000 }, - {CTRY_ARMENIA, ETSI4_WORLD, "AM", "ARMENIA", YES, NO, YES, NO, YES, 7000 }, - {CTRY_AUSTRALIA, FCC6_WORLD, "AU", "AUSTRALIA", YES, YES, YES, YES, YES, 7000 }, - {CTRY_AUSTRIA, ETSI2_WORLD, "AT", "AUSTRIA", YES, NO, YES, YES, YES, 7000 }, - {CTRY_AZERBAIJAN, ETSI4_WORLD, "AZ", "AZERBAIJAN", YES, YES, YES, YES, YES, 7000 }, - {CTRY_BAHRAIN, APL6_WORLD, "BH", "BAHRAIN", YES, NO, YES, NO, YES, 7000 }, - {CTRY_BELARUS, ETSI1_WORLD, "BY", "BELARUS", YES, NO, YES, YES, YES, 7000 }, - {CTRY_BELGIUM, ETSI1_WORLD, "BE", "BELGIUM", YES, NO, YES, YES, YES, 7000 }, - {CTRY_BELIZE, APL1_ETSIC, "BZ", "BELIZE", YES, YES, YES, YES, YES, 7000 }, - {CTRY_BOLIVIA, APL1_ETSIC, "BO", "BOLVIA", YES, YES, YES, YES, YES, 7000 }, - {CTRY_BRAZIL, FCC3_WORLD, "BR", "BRAZIL", NO, NO, NO, NO, NO, 7000 }, - {CTRY_BRUNEI_DARUSSALAM,APL1_WORLD,"BN", "BRUNEI DARUSSALAM", YES, YES, YES, YES, YES, 7000 }, - {CTRY_BULGARIA, ETSI6_WORLD, "BG", "BULGARIA", YES, NO, YES, YES, YES, 7000 }, - {CTRY_CANADA, FCC6_FCCA, "CA", "CANADA", YES, YES, YES, YES, YES, 7000 }, - {CTRY_CHILE, APL6_WORLD, "CL", "CHILE", YES, YES, YES, YES, YES, 7000 }, - {CTRY_CHINA, APL1_WORLD, "CN", "CHINA", YES, YES, YES, YES, YES, 7000 }, - {CTRY_COLOMBIA, FCC1_FCCA, "CO", "COLOMBIA", YES, NO, YES, NO, YES, 7000 }, - {CTRY_COSTA_RICA, FCC1_WORLD, "CR", "COSTA RICA", YES, NO, YES, NO, YES, 7000 }, - {CTRY_CROATIA, ETSI3_WORLD, "HR", "CROATIA", YES, NO, YES, NO, YES, 7000 }, - {CTRY_CYPRUS, ETSI3_WORLD, "CY", "CYPRUS", YES, YES, YES, YES, YES, 7000 }, - {CTRY_CZECH, ETSI3_WORLD, "CZ", "CZECH REPUBLIC", YES, NO, YES, YES, YES, 7000 }, - {CTRY_DENMARK, ETSI1_WORLD, "DK", "DENMARK", YES, NO, YES, YES, YES, 7000 }, - {CTRY_DOMINICAN_REPUBLIC,FCC1_FCCA,"DO", "DOMINICAN REPUBLIC", YES, YES, YES, YES, YES, 7000 }, - {CTRY_ECUADOR, FCC1_WORLD, "EC", "ECUADOR", YES, NO, NO, NO, YES, 7000 }, - {CTRY_EGYPT, ETSI3_WORLD, "EG", "EGYPT", YES, NO, YES, NO, YES, 7000 }, - {CTRY_EL_SALVADOR, FCC1_WORLD, "SV", "EL SALVADOR", YES, NO, YES, NO, YES, 7000 }, - {CTRY_ESTONIA, ETSI1_WORLD, "EE", "ESTONIA", YES, NO, YES, YES, YES, 7000 }, - {CTRY_FINLAND, ETSI1_WORLD, "FI", "FINLAND", YES, NO, YES, YES, YES, 7000 }, - {CTRY_FRANCE, ETSI1_WORLD, "FR", "FRANCE", YES, NO, YES, YES, YES, 7000 }, - {CTRY_FRANCE2, ETSI3_WORLD, "F2", "FRANCE_RES", YES, NO, YES, YES, YES, 7000 }, - {CTRY_GEORGIA, ETSI4_WORLD, "GE", "GEORGIA", YES, YES, YES, YES, YES, 7000 }, - {CTRY_GERMANY, ETSI1_WORLD, "DE", "GERMANY", YES, NO, YES, YES, YES, 7000 }, - {CTRY_GREECE, ETSI1_WORLD, "GR", "GREECE", YES, NO, YES, YES, YES, 7000 }, - {CTRY_GUATEMALA, FCC1_FCCA, "GT", "GUATEMALA", YES, YES, YES, YES, YES, 7000 }, - {CTRY_HONDURAS, NULL1_WORLD, "HN", "HONDURAS", YES, NO, YES, NO, YES, 7000 }, - {CTRY_HONG_KONG, FCC2_WORLD, "HK", "HONG KONG", YES, YES, YES, YES, YES, 7000 }, - {CTRY_HUNGARY, ETSI4_WORLD, "HU", "HUNGARY", YES, NO, YES, YES, YES, 7000 }, - {CTRY_ICELAND, ETSI1_WORLD, "IS", "ICELAND", YES, NO, YES, YES, YES, 7000 }, - {CTRY_INDIA, APL6_WORLD, "IN", "INDIA", YES, NO, YES, NO, YES, 7000 }, - {CTRY_INDONESIA, APL1_WORLD, "ID", "INDONESIA", YES, NO, YES, NO, YES, 7000 }, - {CTRY_IRAN, APL1_WORLD, "IR", "IRAN", YES, YES, YES, YES, YES, 7000 }, - {CTRY_IRELAND, ETSI1_WORLD, "IE", "IRELAND", YES, NO, YES, YES, YES, 7000 }, - {CTRY_ISRAEL, ETSI3_WORLD, "IL", "ISRAEL", YES, NO, YES, NO, YES, 7000 }, - {CTRY_ISRAEL2, NULL1_ETSIB, "ISR","ISRAEL_RES", YES, NO, YES, NO, YES, 7000 }, - {CTRY_ITALY, ETSI1_WORLD, "IT", "ITALY", YES, NO, YES, YES, YES, 7000 }, - {CTRY_JAMAICA, ETSI1_WORLD, "JM", "JAMAICA", YES, NO, YES, YES, YES, 7000 }, - {CTRY_JAPAN, MKK1_MKKA, "JP", "JAPAN", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN1, MKK1_MKKB, "J1", "JAPAN1", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN2, MKK1_FCCA, "J2", "JAPAN2", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN3, MKK2_MKKA, "J3", "JAPAN3", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN4, MKK1_MKKA1, "J4", "JAPAN4", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN5, MKK1_MKKA2, "J5", "JAPAN5", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN6, MKK1_MKKC, "J6", "JAPAN6", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN7, MKK3_MKKB, "J7", "JAPAN7", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN8, MKK3_MKKA2, "J8", "JAPAN8", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN9, MKK3_MKKC, "J9", "JAPAN9", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN10, MKK4_MKKB, "J10", "JAPAN10", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN11, MKK4_MKKA2, "J11", "JAPAN11", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN12, MKK4_MKKC, "J12", "JAPAN12", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN13, MKK5_MKKB, "J13", "JAPAN13", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN14, MKK5_MKKA2, "J14", "JAPAN14", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN15, MKK5_MKKC, "J15", "JAPAN15", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN16, MKK6_MKKB, "J16", "JAPAN16", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN17, MKK6_MKKA2, "J17", "JAPAN17", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN18, MKK6_MKKC, "J18", "JAPAN18", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN19, MKK7_MKKB, "J19", "JAPAN19", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN20, MKK7_MKKA, "J20", "JAPAN20", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN21, MKK7_MKKC, "J21", "JAPAN21", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN22, MKK8_MKKB, "J22", "JAPAN22", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN23, MKK8_MKKA2, "J23", "JAPAN23", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN24, MKK8_MKKC, "J24", "JAPAN24", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN25, MKK3_MKKA, "J25", "JAPAN25", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN26, MKK3_MKKA1, "J26", "JAPAN26", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN27, MKK3_FCCA, "J27", "JAPAN27", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN28, MKK4_MKKA1, "J28", "JAPAN28", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN29, MKK4_FCCA, "J29", "JAPAN29", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN30, MKK6_MKKA1, "J30", "JAPAN30", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN31, MKK6_FCCA, "J31", "JAPAN31", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN32, MKK7_MKKA1, "J32", "JAPAN32", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN33, MKK7_FCCA, "J33", "JAPAN33", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN34, MKK9_MKKA, "J34", "JAPAN34", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN35, MKK10_MKKA, "J35", "JAPAN35", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN36, MKK4_MKKA, "J36", "JAPAN36", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN37, MKK9_FCCA, "J37", "JAPAN37", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN38, MKK9_MKKA1, "J38", "JAPAN38", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN39, MKK9_MKKC, "J39", "JAPAN39", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN40, MKK10_MKKA2, "J40", "JAPAN40", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN41, MKK10_FCCA, "J41", "JAPAN41", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN42, MKK10_MKKA1, "J42", "JAPAN42", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN43, MKK10_MKKC, "J43", "JAPAN43", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN44, MKK10_MKKA2, "J44", "JAPAN44", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN45, MKK11_MKKA, "J45", "JAPAN45", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN46, MKK11_FCCA, "J46", "JAPAN46", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN47, MKK11_MKKA1, "J47", "JAPAN47", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN48, MKK11_MKKC, "J48", "JAPAN48", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN49, MKK11_MKKA2, "J49", "JAPAN49", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN50, MKK12_MKKA, "J50", "JAPAN50", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN51, MKK12_FCCA, "J51", "JAPAN51", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN52, MKK12_MKKA1, "J52", "JAPAN52", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN53, MKK12_MKKC, "J53", "JAPAN53", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JAPAN54, MKK12_MKKA2, "J54", "JAPAN54", YES, NO, NO, NO, NO, 7000 }, - {CTRY_JORDAN, ETSI2_WORLD, "JO", "JORDAN", YES, NO, YES, NO, YES, 7000 }, - {CTRY_KAZAKHSTAN, NULL1_WORLD, "KZ", "KAZAKHSTAN", YES, NO, YES, NO, YES, 7000 }, - {CTRY_KOREA_NORTH, APL9_WORLD, "KP", "NORTH KOREA", YES, NO, NO, YES, YES, 7000 }, - {CTRY_KOREA_ROC, APL9_WORLD, "KR", "KOREA REPUBLIC", YES, NO, NO, NO, NO, 7000 }, - {CTRY_KOREA_ROC2, APL2_APLD, "K2", "KOREA REPUBLIC2",YES, NO, NO, NO, NO, 7000 }, - {CTRY_KOREA_ROC3, APL9_WORLD, "K3", "KOREA REPUBLIC3",YES, NO, NO, NO, NO, 7000 }, - {CTRY_KUWAIT, NULL1_WORLD, "KW", "KUWAIT", YES, NO, YES, NO, YES, 7000 }, - {CTRY_LATVIA, ETSI1_WORLD, "LV", "LATVIA", YES, NO, YES, YES, YES, 7000 }, - {CTRY_LEBANON, NULL1_WORLD, "LB", "LEBANON", YES, NO, YES, NO, YES, 7000 }, - {CTRY_LIECHTENSTEIN,ETSI1_WORLD, "LI", "LIECHTENSTEIN", YES, NO, YES, YES, YES, 7000 }, - {CTRY_LITHUANIA, ETSI1_WORLD, "LT", "LITHUANIA", YES, NO, YES, YES, YES, 7000 }, - {CTRY_LUXEMBOURG, ETSI1_WORLD, "LU", "LUXEMBOURG", YES, NO, YES, YES, YES, 7000 }, - {CTRY_MACAU, FCC2_WORLD, "MO", "MACAU", YES, YES, YES, YES, YES, 7000 }, - {CTRY_MACEDONIA, NULL1_WORLD, "MK", "MACEDONIA", YES, NO, YES, NO, YES, 7000 }, - {CTRY_MALAYSIA, APL8_WORLD, "MY", "MALAYSIA", NO, NO, NO, NO, NO, 7000 }, - {CTRY_MALTA, ETSI1_WORLD, "MT", "MALTA", YES, NO, YES, YES, YES, 7000 }, - {CTRY_MEXICO, FCC1_FCCA, "MX", "MEXICO", YES, YES, YES, YES, YES, 7000 }, - {CTRY_MONACO, ETSI4_WORLD, "MC", "MONACO", YES, YES, YES, YES, YES, 7000 }, - {CTRY_MOROCCO, NULL1_WORLD, "MA", "MOROCCO", YES, NO, YES, NO, YES, 7000 }, - {CTRY_NETHERLANDS, ETSI1_WORLD, "NL", "NETHERLANDS", YES, NO, YES, YES, YES, 7000 }, - {CTRY_NETHERLANDS_ANT, ETSI1_WORLD, "AN", "NETHERLANDS-ANTILLES", YES, NO, YES, YES, YES, 7000 }, - {CTRY_NEW_ZEALAND, FCC2_ETSIC, "NZ", "NEW ZEALAND", YES, NO, YES, NO, YES, 7000 }, - {CTRY_NORWAY, ETSI1_WORLD, "NO", "NORWAY", YES, NO, YES, YES, YES, 7000 }, - {CTRY_OMAN, APL6_WORLD, "OM", "OMAN", YES, NO, YES, NO, YES, 7000 }, - {CTRY_PAKISTAN, NULL1_WORLD, "PK", "PAKISTAN", YES, NO, YES, NO, YES, 7000 }, - {CTRY_PANAMA, FCC1_FCCA, "PA", "PANAMA", YES, YES, YES, YES, YES, 7000 }, - {CTRY_PERU, APL1_WORLD, "PE", "PERU", YES, NO, YES, NO, YES, 7000 }, - {CTRY_PHILIPPINES, APL1_WORLD, "PH", "PHILIPPINES", YES, YES, YES, YES, YES, 7000 }, - {CTRY_POLAND, ETSI1_WORLD, "PL", "POLAND", YES, NO, YES, YES, YES, 7000 }, - {CTRY_PORTUGAL, ETSI1_WORLD, "PT", "PORTUGAL", YES, NO, YES, YES, YES, 7000 }, - {CTRY_PUERTO_RICO, FCC1_FCCA, "PR", "PUERTO RICO", YES, YES, YES, YES, YES, 7000 }, - {CTRY_QATAR, NULL1_WORLD, "QA", "QATAR", YES, NO, YES, NO, YES, 7000 }, - {CTRY_ROMANIA, NULL1_WORLD, "RO", "ROMANIA", YES, NO, YES, NO, YES, 7000 }, - {CTRY_RUSSIA, NULL1_WORLD, "RU", "RUSSIA", YES, NO, YES, NO, YES, 7000 }, - {CTRY_SAUDI_ARABIA,NULL1_WORLD, "SA", "SAUDI ARABIA", YES, NO, YES, NO, YES, 7000 }, - {CTRY_SERBIA_MONT, ETSI1_WORLD, "CS", "SERBIA & MONTENEGRO", YES, NO, YES, YES, YES, 7000 }, - {CTRY_SINGAPORE, APL6_WORLD, "SG", "SINGAPORE", YES, YES, YES, YES, YES, 7000 }, - {CTRY_SLOVAKIA, ETSI1_WORLD, "SK", "SLOVAK REPUBLIC",YES, NO, YES, YES, YES, 7000 }, - {CTRY_SLOVENIA, ETSI1_WORLD, "SI", "SLOVENIA", YES, NO, YES, YES, YES, 7000 }, - {CTRY_SOUTH_AFRICA,FCC3_WORLD, "ZA", "SOUTH AFRICA", YES, NO, YES, NO, YES, 7000 }, - {CTRY_SPAIN, ETSI1_WORLD, "ES", "SPAIN", YES, NO, YES, YES, YES, 7000 }, - {CTRY_SRILANKA, FCC3_WORLD, "LK", "SRI LANKA", YES, NO, YES, NO, YES, 7000 }, - {CTRY_SWEDEN, ETSI1_WORLD, "SE", "SWEDEN", YES, NO, YES, YES, YES, 7000 }, - {CTRY_SWITZERLAND, ETSI1_WORLD, "CH", "SWITZERLAND", YES, NO, YES, YES, YES, 7000 }, - {CTRY_SYRIA, NULL1_WORLD, "SY", "SYRIA", YES, NO, YES, NO, YES, 7000 }, - {CTRY_TAIWAN, APL3_FCCA, "TW", "TAIWAN", YES, YES, YES, YES, YES, 7000 }, - {CTRY_THAILAND, NULL1_WORLD, "TH", "THAILAND", YES, NO, YES, NO, YES, 7000 }, - {CTRY_TRINIDAD_Y_TOBAGO,ETSI4_WORLD,"TT", "TRINIDAD & TOBAGO", YES, NO, YES, NO, YES, 7000 }, - {CTRY_TUNISIA, ETSI3_WORLD, "TN", "TUNISIA", YES, NO, YES, NO, YES, 7000 }, - {CTRY_TURKEY, ETSI3_WORLD, "TR", "TURKEY", YES, NO, YES, NO, YES, 7000 }, - {CTRY_UKRAINE, NULL1_WORLD, "UA", "UKRAINE", YES, NO, YES, NO, YES, 7000 }, - {CTRY_UAE, NULL1_WORLD, "AE", "UNITED ARAB EMIRATES", YES, NO, YES, NO, YES, 7000 }, - {CTRY_UNITED_KINGDOM, ETSI1_WORLD,"GB", "UNITED KINGDOM", YES, NO, YES, NO, YES, 7000 }, - {CTRY_UNITED_STATES, FCC3_FCCA, "US", "UNITED STATES", YES, YES, YES, YES, YES, 5825 }, - {CTRY_UNITED_STATES_FCC49, FCC4_FCCA, "PS", "UNITED STATES (PUBLIC SAFETY)", YES, YES, YES, YES, YES, 7000 }, - {CTRY_URUGUAY, FCC1_WORLD, "UY", "URUGUAY", YES, NO, YES, NO, YES, 7000 }, - {CTRY_UZBEKISTAN, FCC3_FCCA, "UZ", "UZBEKISTAN", YES, YES, YES, YES, YES, 7000 }, - {CTRY_VENEZUELA, APL2_ETSIC, "VE", "VENEZUELA", YES, NO, YES, NO, YES, 7000 }, - {CTRY_VIET_NAM, NULL1_WORLD, "VN", "VIET NAM", YES, NO, YES, NO, YES, 7000 }, - {CTRY_YEMEN, NULL1_WORLD, "YE", "YEMEN", YES, NO, YES, NO, YES, 7000 }, - {CTRY_ZIMBABWE, NULL1_WORLD, "ZW", "ZIMBABWE", YES, NO, YES, NO, YES, 7000 } + {CTRY_DEBUG, NO_ENUMRD, "DB", "DEBUG", YES, YES, YES, YES, YES, 7000 }, + {CTRY_DEFAULT, DEF_REGDMN, "NA", "NO_COUNTRY_SET", YES, YES, YES, YES, YES, 7000 }, + {CTRY_ALBANIA, NULL1_WORLD, "AL", "ALBANIA", YES, NO, YES, NO, YES, 7000 }, + {CTRY_ALGERIA, NULL1_WORLD, "DZ", "ALGERIA", YES, NO, YES, NO, YES, 7000 }, + {CTRY_ARGENTINA, APL3_WORLD, "AR", "ARGENTINA", YES, NO, NO, NO, NO, 7000 }, + {CTRY_ARMENIA, ETSI4_WORLD, "AM", "ARMENIA", YES, NO, YES, NO, YES, 7000 }, + {CTRY_AUSTRALIA, FCC6_WORLD, "AU", "AUSTRALIA", YES, YES, YES, YES, YES, 7000 }, + {CTRY_AUSTRIA, ETSI2_WORLD, "AT", "AUSTRIA", YES, NO, YES, YES, YES, 7000 }, + {CTRY_AZERBAIJAN, ETSI4_WORLD, "AZ", "AZERBAIJAN", YES, YES, YES, YES, YES, 7000 }, + {CTRY_BAHRAIN, APL6_WORLD, "BH", "BAHRAIN", YES, NO, YES, NO, YES, 7000 }, + {CTRY_BELARUS, ETSI1_WORLD, "BY", "BELARUS", YES, NO, YES, YES, YES, 7000 }, + {CTRY_BELGIUM, ETSI1_WORLD, "BE", "BELGIUM", YES, NO, YES, YES, YES, 7000 }, + {CTRY_BELIZE, APL1_ETSIC, "BZ", "BELIZE", YES, YES, YES, YES, YES, 7000 }, + {CTRY_BOLIVIA, APL1_ETSIC, "BO", "BOLVIA", YES, YES, YES, YES, YES, 7000 }, + {CTRY_BRAZIL, FCC3_WORLD, "BR", "BRAZIL", NO, NO, NO, NO, NO, 7000 }, + {CTRY_BRUNEI_DARUSSALAM, APL1_WORLD, "BN", "BRUNEI DARUSSALAM", YES, YES, YES, YES, YES, 7000 }, + {CTRY_BULGARIA, ETSI6_WORLD, "BG", "BULGARIA", YES, NO, YES, YES, YES, 7000 }, + {CTRY_CANADA, FCC6_FCCA, "CA", "CANADA", YES, YES, YES, YES, YES, 7000 }, + {CTRY_CHILE, APL6_WORLD, "CL", "CHILE", YES, YES, YES, YES, YES, 7000 }, + {CTRY_CHINA, APL1_WORLD, "CN", "CHINA", YES, YES, YES, YES, YES, 7000 }, + {CTRY_COLOMBIA, FCC1_FCCA, "CO", "COLOMBIA", YES, NO, YES, NO, YES, 7000 }, + {CTRY_COSTA_RICA, FCC1_WORLD, "CR", "COSTA RICA", YES, NO, YES, NO, YES, 7000 }, + {CTRY_CROATIA, ETSI3_WORLD, "HR", "CROATIA", YES, NO, YES, NO, YES, 7000 }, + {CTRY_CYPRUS, ETSI3_WORLD, "CY", "CYPRUS", YES, YES, YES, YES, YES, 7000 }, + {CTRY_CZECH, ETSI3_WORLD, "CZ", "CZECH REPUBLIC", YES, NO, YES, YES, YES, 7000 }, + {CTRY_DENMARK, ETSI1_WORLD, "DK", "DENMARK", YES, NO, YES, YES, YES, 7000 }, + {CTRY_DOMINICAN_REPUBLIC, FCC1_FCCA, "DO", "DOMINICAN REPUBLIC", YES, YES, YES, YES, YES, 7000 }, + {CTRY_ECUADOR, FCC1_WORLD, "EC", "ECUADOR", YES, NO, NO, NO, YES, 7000 }, + {CTRY_EGYPT, ETSI3_WORLD, "EG", "EGYPT", YES, NO, YES, NO, YES, 7000 }, + {CTRY_EL_SALVADOR, FCC1_WORLD, "SV", "EL SALVADOR", YES, NO, YES, NO, YES, 7000 }, + {CTRY_ESTONIA, ETSI1_WORLD, "EE", "ESTONIA", YES, NO, YES, YES, YES, 7000 }, + {CTRY_FINLAND, ETSI1_WORLD, "FI", "FINLAND", YES, NO, YES, YES, YES, 7000 }, + {CTRY_FRANCE, ETSI1_WORLD, "FR", "FRANCE", YES, NO, YES, YES, YES, 7000 }, + {CTRY_FRANCE2, ETSI3_WORLD, "F2", "FRANCE_RES", YES, NO, YES, YES, YES, 7000 }, + {CTRY_GEORGIA, ETSI4_WORLD, "GE", "GEORGIA", YES, YES, YES, YES, YES, 7000 }, + {CTRY_GERMANY, ETSI1_WORLD, "DE", "GERMANY", YES, NO, YES, YES, YES, 7000 }, + {CTRY_GREECE, ETSI1_WORLD, "GR", "GREECE", YES, NO, YES, YES, YES, 7000 }, + {CTRY_GUATEMALA, FCC1_FCCA, "GT", "GUATEMALA", YES, YES, YES, YES, YES, 7000 }, + {CTRY_HONDURAS, NULL1_WORLD, "HN", "HONDURAS", YES, NO, YES, NO, YES, 7000 }, + {CTRY_HONG_KONG, FCC2_WORLD, "HK", "HONG KONG", YES, YES, YES, YES, YES, 7000 }, + {CTRY_HUNGARY, ETSI4_WORLD, "HU", "HUNGARY", YES, NO, YES, YES, YES, 7000 }, + {CTRY_ICELAND, ETSI1_WORLD, "IS", "ICELAND", YES, NO, YES, YES, YES, 7000 }, + {CTRY_INDIA, APL6_WORLD, "IN", "INDIA", YES, NO, YES, NO, YES, 7000 }, + {CTRY_INDONESIA, APL1_WORLD, "ID", "INDONESIA", YES, NO, YES, NO, YES, 7000 }, + {CTRY_IRAN, APL1_WORLD, "IR", "IRAN", YES, YES, YES, YES, YES, 7000 }, + {CTRY_IRELAND, ETSI1_WORLD, "IE", "IRELAND", YES, NO, YES, YES, YES, 7000 }, + {CTRY_ISRAEL, ETSI3_WORLD, "IL", "ISRAEL", YES, NO, YES, NO, YES, 7000 }, + {CTRY_ISRAEL2, NULL1_ETSIB, "ISR", "ISRAEL_RES", YES, NO, YES, NO, YES, 7000 }, + {CTRY_ITALY, ETSI1_WORLD, "IT", "ITALY", YES, NO, YES, YES, YES, 7000 }, + {CTRY_JAMAICA, ETSI1_WORLD, "JM", "JAMAICA", YES, NO, YES, YES, YES, 7000 }, + {CTRY_JAPAN, MKK1_MKKA, "JP", "JAPAN", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN1, MKK1_MKKB, "J1", "JAPAN1", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN2, MKK1_FCCA, "J2", "JAPAN2", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN3, MKK2_MKKA, "J3", "JAPAN3", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN4, MKK1_MKKA1, "J4", "JAPAN4", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN5, MKK1_MKKA2, "J5", "JAPAN5", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN6, MKK1_MKKC, "J6", "JAPAN6", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN7, MKK3_MKKB, "J7", "JAPAN7", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN8, MKK3_MKKA2, "J8", "JAPAN8", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN9, MKK3_MKKC, "J9", "JAPAN9", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN10, MKK4_MKKB, "J10", "JAPAN10", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN11, MKK4_MKKA2, "J11", "JAPAN11", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN12, MKK4_MKKC, "J12", "JAPAN12", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN13, MKK5_MKKB, "J13", "JAPAN13", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN14, MKK5_MKKA2, "J14", "JAPAN14", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN15, MKK5_MKKC, "J15", "JAPAN15", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN16, MKK6_MKKB, "J16", "JAPAN16", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN17, MKK6_MKKA2, "J17", "JAPAN17", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN18, MKK6_MKKC, "J18", "JAPAN18", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN19, MKK7_MKKB, "J19", "JAPAN19", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN20, MKK7_MKKA, "J20", "JAPAN20", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN21, MKK7_MKKC, "J21", "JAPAN21", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN22, MKK8_MKKB, "J22", "JAPAN22", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN23, MKK8_MKKA2, "J23", "JAPAN23", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN24, MKK8_MKKC, "J24", "JAPAN24", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN25, MKK3_MKKA, "J25", "JAPAN25", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN26, MKK3_MKKA1, "J26", "JAPAN26", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN27, MKK3_FCCA, "J27", "JAPAN27", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN28, MKK4_MKKA1, "J28", "JAPAN28", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN29, MKK4_FCCA, "J29", "JAPAN29", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN30, MKK6_MKKA1, "J30", "JAPAN30", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN31, MKK6_FCCA, "J31", "JAPAN31", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN32, MKK7_MKKA1, "J32", "JAPAN32", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN33, MKK7_FCCA, "J33", "JAPAN33", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN34, MKK9_MKKA, "J34", "JAPAN34", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN35, MKK10_MKKA, "J35", "JAPAN35", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN36, MKK4_MKKA, "J36", "JAPAN36", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN37, MKK9_FCCA, "J37", "JAPAN37", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN38, MKK9_MKKA1, "J38", "JAPAN38", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN39, MKK9_MKKC, "J39", "JAPAN39", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN40, MKK10_MKKA2, "J40", "JAPAN40", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN41, MKK10_FCCA, "J41", "JAPAN41", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN42, MKK10_MKKA1, "J42", "JAPAN42", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN43, MKK10_MKKC, "J43", "JAPAN43", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN44, MKK10_MKKA2, "J44", "JAPAN44", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN45, MKK11_MKKA, "J45", "JAPAN45", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN46, MKK11_FCCA, "J46", "JAPAN46", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN47, MKK11_MKKA1, "J47", "JAPAN47", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN48, MKK11_MKKC, "J48", "JAPAN48", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN49, MKK11_MKKA2, "J49", "JAPAN49", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN50, MKK12_MKKA, "J50", "JAPAN50", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN51, MKK12_FCCA, "J51", "JAPAN51", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN52, MKK12_MKKA1, "J52", "JAPAN52", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN53, MKK12_MKKC, "J53", "JAPAN53", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JAPAN54, MKK12_MKKA2, "J54", "JAPAN54", YES, NO, NO, NO, NO, 7000 }, + {CTRY_JORDAN, ETSI2_WORLD, "JO", "JORDAN", YES, NO, YES, NO, YES, 7000 }, + {CTRY_KAZAKHSTAN, NULL1_WORLD, "KZ", "KAZAKHSTAN", YES, NO, YES, NO, YES, 7000 }, + {CTRY_KOREA_NORTH, APL9_WORLD, "KP", "NORTH KOREA", YES, NO, NO, YES, YES, 7000 }, + {CTRY_KOREA_ROC, APL9_WORLD, "KR", "KOREA REPUBLIC", YES, NO, NO, NO, NO, 7000 }, + {CTRY_KOREA_ROC2, APL2_APLD, "K2", "KOREA REPUBLIC2", YES, NO, NO, NO, NO, 7000 }, + {CTRY_KOREA_ROC3, APL9_WORLD, "K3", "KOREA REPUBLIC3", YES, NO, NO, NO, NO, 7000 }, + {CTRY_KUWAIT, NULL1_WORLD, "KW", "KUWAIT", YES, NO, YES, NO, YES, 7000 }, + {CTRY_LATVIA, ETSI1_WORLD, "LV", "LATVIA", YES, NO, YES, YES, YES, 7000 }, + {CTRY_LEBANON, NULL1_WORLD, "LB", "LEBANON", YES, NO, YES, NO, YES, 7000 }, + {CTRY_LIECHTENSTEIN, ETSI1_WORLD, "LI", "LIECHTENSTEIN", YES, NO, YES, YES, YES, 7000 }, + {CTRY_LITHUANIA, ETSI1_WORLD, "LT", "LITHUANIA", YES, NO, YES, YES, YES, 7000 }, + {CTRY_LUXEMBOURG, ETSI1_WORLD, "LU", "LUXEMBOURG", YES, NO, YES, YES, YES, 7000 }, + {CTRY_MACAU, FCC2_WORLD, "MO", "MACAU", YES, YES, YES, YES, YES, 7000 }, + {CTRY_MACEDONIA, NULL1_WORLD, "MK", "MACEDONIA", YES, NO, YES, NO, YES, 7000 }, + {CTRY_MALAYSIA, APL8_WORLD, "MY", "MALAYSIA", NO, NO, NO, NO, NO, 7000 }, + {CTRY_MALTA, ETSI1_WORLD, "MT", "MALTA", YES, NO, YES, YES, YES, 7000 }, + {CTRY_MEXICO, FCC1_FCCA, "MX", "MEXICO", YES, YES, YES, YES, YES, 7000 }, + {CTRY_MONACO, ETSI4_WORLD, "MC", "MONACO", YES, YES, YES, YES, YES, 7000 }, + {CTRY_MOROCCO, NULL1_WORLD, "MA", "MOROCCO", YES, NO, YES, NO, YES, 7000 }, + {CTRY_NETHERLANDS, ETSI1_WORLD, "NL", "NETHERLANDS", YES, NO, YES, YES, YES, 7000 }, + {CTRY_NETHERLANDS_ANT, ETSI1_WORLD, "AN", "NETHERLANDS-ANTILLES", YES, NO, YES, YES, YES, 7000 }, + {CTRY_NEW_ZEALAND, FCC2_ETSIC, "NZ", "NEW ZEALAND", YES, NO, YES, NO, YES, 7000 }, + {CTRY_NORWAY, ETSI1_WORLD, "NO", "NORWAY", YES, NO, YES, YES, YES, 7000 }, + {CTRY_OMAN, APL6_WORLD, "OM", "OMAN", YES, NO, YES, NO, YES, 7000 }, + {CTRY_PAKISTAN, NULL1_WORLD, "PK", "PAKISTAN", YES, NO, YES, NO, YES, 7000 }, + {CTRY_PANAMA, FCC1_FCCA, "PA", "PANAMA", YES, YES, YES, YES, YES, 7000 }, + {CTRY_PERU, APL1_WORLD, "PE", "PERU", YES, NO, YES, NO, YES, 7000 }, + {CTRY_PHILIPPINES, APL1_WORLD, "PH", "PHILIPPINES", YES, YES, YES, YES, YES, 7000 }, + {CTRY_POLAND, ETSI1_WORLD, "PL", "POLAND", YES, NO, YES, YES, YES, 7000 }, + {CTRY_PORTUGAL, ETSI1_WORLD, "PT", "PORTUGAL", YES, NO, YES, YES, YES, 7000 }, + {CTRY_PUERTO_RICO, FCC1_FCCA, "PR", "PUERTO RICO", YES, YES, YES, YES, YES, 7000 }, + {CTRY_QATAR, NULL1_WORLD, "QA", "QATAR", YES, NO, YES, NO, YES, 7000 }, + {CTRY_ROMANIA, NULL1_WORLD, "RO", "ROMANIA", YES, NO, YES, NO, YES, 7000 }, + {CTRY_RUSSIA, NULL1_WORLD, "RU", "RUSSIA", YES, NO, YES, NO, YES, 7000 }, + {CTRY_SAUDI_ARABIA, NULL1_WORLD, "SA", "SAUDI ARABIA", YES, NO, YES, NO, YES, 7000 }, + {CTRY_SERBIA_MONT, ETSI1_WORLD, "CS", "SERBIA & MONTENEGRO", YES, NO, YES, YES, YES, 7000 }, + {CTRY_SINGAPORE, APL6_WORLD, "SG", "SINGAPORE", YES, YES, YES, YES, YES, 7000 }, + {CTRY_SLOVAKIA, ETSI1_WORLD, "SK", "SLOVAK REPUBLIC", YES, NO, YES, YES, YES, 7000 }, + {CTRY_SLOVENIA, ETSI1_WORLD, "SI", "SLOVENIA", YES, NO, YES, YES, YES, 7000 }, + {CTRY_SOUTH_AFRICA, FCC3_WORLD, "ZA", "SOUTH AFRICA", YES, NO, YES, NO, YES, 7000 }, + {CTRY_SPAIN, ETSI1_WORLD, "ES", "SPAIN", YES, NO, YES, YES, YES, 7000 }, + {CTRY_SRILANKA, FCC3_WORLD, "LK", "SRI LANKA", YES, NO, YES, NO, YES, 7000 }, + {CTRY_SWEDEN, ETSI1_WORLD, "SE", "SWEDEN", YES, NO, YES, YES, YES, 7000 }, + {CTRY_SWITZERLAND, ETSI1_WORLD, "CH", "SWITZERLAND", YES, NO, YES, YES, YES, 7000 }, + {CTRY_SYRIA, NULL1_WORLD, "SY", "SYRIA", YES, NO, YES, NO, YES, 7000 }, + {CTRY_TAIWAN, APL3_FCCA, "TW", "TAIWAN", YES, YES, YES, YES, YES, 7000 }, + {CTRY_THAILAND, NULL1_WORLD, "TH", "THAILAND", YES, NO, YES, NO, YES, 7000 }, + {CTRY_TRINIDAD_Y_TOBAGO, ETSI4_WORLD, "TT", "TRINIDAD & TOBAGO", YES, NO, YES, NO, YES, 7000 }, + {CTRY_TUNISIA, ETSI3_WORLD, "TN", "TUNISIA", YES, NO, YES, NO, YES, 7000 }, + {CTRY_TURKEY, ETSI3_WORLD, "TR", "TURKEY", YES, NO, YES, NO, YES, 7000 }, + {CTRY_UKRAINE, NULL1_WORLD, "UA", "UKRAINE", YES, NO, YES, NO, YES, 7000 }, + {CTRY_UAE, NULL1_WORLD, "AE", "UNITED ARAB EMIRATES", YES, NO, YES, NO, YES, 7000 }, + {CTRY_UNITED_KINGDOM, ETSI1_WORLD, "GB", "UNITED KINGDOM", YES, NO, YES, NO, YES, 7000 }, + {CTRY_UNITED_STATES, FCC3_FCCA, "US", "UNITED STATES", YES, YES, YES, YES, YES, 5825 }, + {CTRY_UNITED_STATES_FCC49, FCC4_FCCA, "PS", "UNITED STATES (PUBLIC SAFETY)", YES, YES, YES, YES, YES, 7000 }, + {CTRY_URUGUAY, FCC1_WORLD, "UY", "URUGUAY", YES, NO, YES, NO, YES, 7000 }, + {CTRY_UZBEKISTAN, FCC3_FCCA, "UZ", "UZBEKISTAN", YES, YES, YES, YES, YES, 7000 }, + {CTRY_VENEZUELA, APL2_ETSIC, "VE", "VENEZUELA", YES, NO, YES, NO, YES, 7000 }, + {CTRY_VIET_NAM, NULL1_WORLD, "VN", "VIET NAM", YES, NO, YES, NO, YES, 7000 }, + {CTRY_YEMEN, NULL1_WORLD, "YE", "YEMEN", YES, NO, YES, NO, YES, 7000 }, + {CTRY_ZIMBABWE, NULL1_WORLD, "ZW", "ZIMBABWE", YES, NO, YES, NO, YES, 7000 } }; typedef struct RegDmnFreqBand { @@ -660,7 +660,7 @@ enum { W1_5745_5825, W1_5500_5700, W2_5260_5320, - W2_5180_5240, + W2_5180_5240, W2_5825_5825, }; @@ -1332,8 +1332,8 @@ static REG_DOMAIN regDomains[] = { BMZERO, BMZERO, BMZERO, - BM(F2_2312_2372,F2_2412_2472, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), - BM(G2_2312_2372,G2_2412_2472, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(F2_2312_2372, F2_2412_2472, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(G2_2312_2372, G2_2412_2472, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO, BMZERO, BMZERO}, @@ -1342,9 +1342,9 @@ static REG_DOMAIN regDomains[] = { BMZERO, BMZERO, BMZERO, - BM(F1_2457_2472,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), - BM(G1_2457_2472,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), - BM(T2_2437_2437,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(F1_2457_2472, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(G1_2457_2472, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(T2_2437_2437, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO, BMZERO}, @@ -1352,9 +1352,9 @@ static REG_DOMAIN regDomains[] = { BMZERO, BMZERO, BMZERO, - BM(F1_2432_2442,-1,-1,-1,-1,-1,-1,-1, -1, -1, -1, -1), - BM(G1_2432_2442,-1,-1,-1,-1,-1,-1,-1, -1, -1, -1, -1), - BM(T2_2437_2437,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(F1_2432_2442, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(G1_2432_2442, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(T2_2437_2437, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO, BMZERO}, @@ -1362,9 +1362,9 @@ static REG_DOMAIN regDomains[] = { BMZERO, BMZERO, BMZERO, - BM(F3_2412_2472,-1,-1,-1,-1,-1,-1,-1, -1, -1, -1, -1), - BM(G3_2412_2472,-1,-1,-1,-1,-1,-1,-1, -1, -1, -1, -1), - BM(T2_2437_2437,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(F3_2412_2472, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(G3_2412_2472, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(T2_2437_2437, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO, BMZERO}, @@ -1372,10 +1372,10 @@ static REG_DOMAIN regDomains[] = { BMZERO, BMZERO, BMZERO, - BM(F1_2412_2462,-1,-1,-1,-1,-1,-1,-1, -1, -1, -1, -1), - BM(G1_2412_2462,-1,-1,-1,-1,-1,-1,-1, -1, -1, -1, -1), - BM(T2_2437_2437,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), - BM(NG2_2422_2452,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(F1_2412_2462, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(G1_2412_2462, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(T2_2437_2437, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(NG2_2422_2452, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO}, {MKKA, MKK, NO_DFS, PSCAN_MKKA | PSCAN_MKKA_G | PSCAN_MKKA1 | PSCAN_MKKA1_G | PSCAN_MKKA2 | PSCAN_MKKA2_G, DISALLOW_ADHOC_11A_TURB, @@ -1384,36 +1384,36 @@ static REG_DOMAIN regDomains[] = { BMZERO, BM(F2_2412_2462, F1_2467_2472, F2_2484_2484, -1, -1, -1, -1, -1, -1, -1, -1, -1), BM(G2_2412_2462, G1_2467_2472, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), - BM(T2_2437_2437,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), - BM(NG1_2422_2452,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(T2_2437_2437, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(NG1_2422_2452, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO}, {MKKC, MKK, NO_DFS, NO_PSCAN, NO_REQ, BMZERO, BMZERO, BMZERO, - BM(F2_2412_2472,-1,-1,-1,-1,-1,-1,-1, -1, -1, -1, -1), - BM(G2_2412_2472,-1,-1,-1,-1,-1,-1,-1, -1, -1, -1, -1), - BM(T2_2437_2437,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), - BM(NG1_2422_2452,-1,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(F2_2412_2472, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(G2_2412_2472, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(T2_2437_2437, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(NG1_2422_2452, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO}, {WORLD, ETSI, NO_DFS, NO_PSCAN, NO_REQ, BMZERO, BMZERO, BMZERO, - BM(F2_2412_2472,-1,-1,-1,-1,-1,-1,-1, -1, -1, -1, -1), - BM(G2_2412_2472,-1,-1,-1,-1,-1,-1,-1, -1, -1, -1, -1), - BM(T2_2437_2437,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), - BM(NG1_2422_2452,-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(F2_2412_2472, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(G2_2412_2472, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(T2_2437_2437, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), + BM(NG1_2422_2452, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO}, {WOR0_WORLD, NO_CTL, DFS_FCC3 | DFS_ETSI, PSCAN_WWR, ADHOC_PER_11D, BM(W1_5260_5320, W1_5180_5240, W1_5170_5230, W1_5745_5825, W1_5500_5700, -1, -1, -1, -1, -1, -1, -1), BM(WT1_5210_5250, WT1_5290_5290, WT1_5760_5800, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO, - BM(W1_2412_2412,W1_2437_2442,W1_2462_2462,W1_2472_2472,W1_2417_2432, W1_2447_2457, W1_2467_2467, W1_2484_2484, -1, -1, -1, -1), - BM(WG1_2412_2412,WG1_2437_2442,WG1_2462_2462,WG1_2472_2472,WG1_2417_2432,WG1_2447_2457,WG1_2467_2467, -1, -1, -1, -1, -1), + BM(W1_2412_2412, W1_2437_2442, W1_2462_2462, W1_2472_2472, W1_2417_2432, W1_2447_2457, W1_2467_2467, W1_2484_2484, -1, -1, -1, -1), + BM(WG1_2412_2412, WG1_2437_2442, WG1_2462_2462, WG1_2472_2472, WG1_2417_2432, WG1_2447_2457, WG1_2467_2467, -1, -1, -1, -1, -1), BM(T3_2437_2437, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO, BMZERO}, @@ -1429,21 +1429,21 @@ static REG_DOMAIN regDomains[] = { BMZERO}, {WOR02_WORLD, NO_CTL, DFS_FCC3 | DFS_ETSI, PSCAN_WWR, ADHOC_PER_11D, - BM(W1_5260_5320, W1_5180_5240,W1_5170_5230,W1_5745_5825,W1_5500_5700, -1, -1, -1, -1, -1, -1, -1), + BM(W1_5260_5320, W1_5180_5240, W1_5170_5230, W1_5745_5825, W1_5500_5700, -1, -1, -1, -1, -1, -1, -1), BM(WT1_5210_5250, WT1_5290_5290, WT1_5760_5800, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO, - BM(W1_2412_2412,W1_2437_2442,W1_2462_2462, W1_2472_2472,W1_2417_2432, W1_2447_2457, W1_2467_2467, -1, -1, -1, -1, -1), - BM(WG1_2412_2412,WG1_2437_2442,WG1_2462_2462, WG1_2472_2472,WG1_2417_2432, WG1_2447_2457, WG1_2467_2467, -1, -1, -1, -1, -1), + BM(W1_2412_2412, W1_2437_2442, W1_2462_2462, W1_2472_2472, W1_2417_2432, W1_2447_2457, W1_2467_2467, -1, -1, -1, -1, -1), + BM(WG1_2412_2412, WG1_2437_2442, WG1_2462_2462, WG1_2472_2472, WG1_2417_2432, WG1_2447_2457, WG1_2467_2467, -1, -1, -1, -1, -1), BM(T3_2437_2437, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO, BMZERO}, {EU1_WORLD, NO_CTL, DFS_FCC3 | DFS_ETSI, PSCAN_WWR, ADHOC_PER_11D, - BM(W1_5260_5320, W1_5180_5240,W1_5170_5230,W1_5745_5825,W1_5500_5700, -1, -1, -1, -1, -1, -1, -1), + BM(W1_5260_5320, W1_5180_5240, W1_5170_5230, W1_5745_5825, W1_5500_5700, -1, -1, -1, -1, -1, -1, -1), BM(WT1_5210_5250, WT1_5290_5290, WT1_5760_5800, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO, - BM(W1_2412_2412,W1_2437_2442,W1_2462_2462, W2_2472_2472,W1_2417_2432, W1_2447_2457, W2_2467_2467, -1, -1, -1, -1, -1), - BM(WG1_2412_2412,WG1_2437_2442,WG1_2462_2462, WG2_2472_2472,WG1_2417_2432, WG1_2447_2457, WG2_2467_2467, -1, -1, -1, -1, -1), + BM(W1_2412_2412, W1_2437_2442, W1_2462_2462, W2_2472_2472, W1_2417_2432, W1_2447_2457, W2_2467_2467, -1, -1, -1, -1, -1), + BM(WG1_2412_2412, WG1_2437_2442, WG1_2462_2462, WG2_2472_2472, WG1_2417_2432, WG1_2447_2457, WG2_2467_2467, -1, -1, -1, -1, -1), BM(T3_2437_2437, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO, BMZERO}, @@ -1452,8 +1452,8 @@ static REG_DOMAIN regDomains[] = { BM(W1_5260_5320, W1_5180_5240, W1_5170_5230, W1_5745_5825, W1_5500_5700, -1, -1, -1, -1, -1, -1, -1), BMZERO, BMZERO, - BM(W1_2412_2412,W1_2437_2442,W1_2462_2462,W1_2472_2472,W1_2417_2432, W1_2447_2457, W1_2467_2467, W1_2484_2484, -1, -1, -1, -1), - BM(WG1_2412_2412,WG1_2437_2442,WG1_2462_2462,WG1_2472_2472,WG1_2417_2432,WG1_2447_2457,WG1_2467_2467, -1, -1, -1, -1, -1), + BM(W1_2412_2412, W1_2437_2442, W1_2462_2462, W1_2472_2472, W1_2417_2432, W1_2447_2457, W1_2467_2467, W1_2484_2484, -1, -1, -1, -1), + BM(WG1_2412_2412, WG1_2437_2442, WG1_2462_2462, WG1_2472_2472, WG1_2417_2432, WG1_2447_2457, WG1_2467_2467, -1, -1, -1, -1, -1), BM(T3_2437_2437, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO, BMZERO}, @@ -1462,8 +1462,8 @@ static REG_DOMAIN regDomains[] = { BM(W1_5260_5320, W1_5180_5240, W1_5170_5230, W1_5745_5825, W1_5500_5700, -1, -1, -1, -1, -1, -1, -1), BM(WT1_5210_5250, WT1_5290_5290, WT1_5760_5800, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO, - BM(W1_2412_2412,W1_2437_2442,W1_2462_2462,W1_2472_2472,W1_2417_2432, W1_2447_2457, W1_2467_2467, W1_2484_2484, -1, -1, -1, -1), - BM(WG1_2412_2412,WG1_2437_2442,WG1_2462_2462,WG1_2472_2472,WG1_2417_2432,WG1_2447_2457,WG1_2467_2467, -1, -1, -1, -1, -1), + BM(W1_2412_2412, W1_2437_2442, W1_2462_2462, W1_2472_2472, W1_2417_2432, W1_2447_2457, W1_2467_2467, W1_2484_2484, -1, -1, -1, -1), + BM(WG1_2412_2412, WG1_2437_2442, WG1_2462_2462, WG1_2472_2472, WG1_2417_2432, WG1_2447_2457, WG1_2467_2467, -1, -1, -1, -1, -1), BM(T3_2437_2437, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO, BMZERO}, @@ -1472,8 +1472,8 @@ static REG_DOMAIN regDomains[] = { BM(W1_5260_5320, W1_5180_5240, W1_5170_5230, W1_5745_5825, -1, -1, -1, -1, -1, -1, -1, -1), BM(WT1_5210_5250, WT1_5290_5290, WT1_5760_5800, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO, - BM(W1_2412_2412,W1_2437_2442,W1_2462_2462,W1_2472_2472,W1_2417_2432, W1_2447_2457, W1_2467_2467, -1, -1, -1, -1, -1), - BM(WG1_2412_2412,WG1_2437_2442,WG1_2462_2462,WG1_2472_2472,WG1_2417_2432,WG1_2447_2457,WG1_2467_2467,-1, -1, -1, -1, -1), + BM(W1_2412_2412, W1_2437_2442, W1_2462_2462, W1_2472_2472, W1_2417_2432, W1_2447_2457, W1_2467_2467, -1, -1, -1, -1, -1), + BM(WG1_2412_2412, WG1_2437_2442, WG1_2462_2462, WG1_2472_2472, WG1_2417_2432, WG1_2447_2457, WG1_2467_2467, -1, -1, -1, -1, -1), BM(T3_2437_2437, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO, BMZERO}, @@ -1482,8 +1482,8 @@ static REG_DOMAIN regDomains[] = { BM(W2_5260_5320, W2_5180_5240, F2_5745_5805, W2_5825_5825, -1, -1, -1, -1, -1, -1, -1, -1), BM(WT1_5210_5250, WT1_5290_5290, WT1_5760_5800, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO, - BM(W1_2412_2412,W1_2437_2442,W1_2462_2462, W1_2417_2432,W1_2447_2457,-1, -1, -1, -1, -1, -1, -1), - BM(WG1_2412_2412,WG1_2437_2442,WG1_2462_2462, WG1_2417_2432,WG1_2447_2457,-1, -1, -1, -1, -1, -1, -1), + BM(W1_2412_2412, W1_2437_2442, W1_2462_2462, W1_2417_2432, W1_2447_2457, -1, -1, -1, -1, -1, -1, -1), + BM(WG1_2412_2412, WG1_2437_2442, WG1_2462_2462, WG1_2417_2432, WG1_2447_2457, -1, -1, -1, -1, -1, -1, -1), BM(T3_2437_2437, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1), BMZERO, BMZERO}, @@ -1554,30 +1554,24 @@ static const struct cmode modes[] = { u8_t GetWmRD(u16_t regionCode, u16_t channelFlag, REG_DOMAIN *rd) { s16_t i, found, regDmn; - u64_t flags=NO_REQ; - REG_DMN_PAIR_MAPPING *regPair=NULL; + u64_t flags = NO_REQ; + REG_DMN_PAIR_MAPPING *regPair = NULL; - for (i=0, found=0; (i<N(regDomainPairs))&&(!found); i++) - { - if (regDomainPairs[i].regDmnEnum == regionCode) - { + for (i = 0, found = 0; (i < N(regDomainPairs)) && (!found); i++) { + if (regDomainPairs[i].regDmnEnum == regionCode) { regPair = ®DomainPairs[i]; found = 1; } } - if (!found) - { + if (!found) { zm_debug_msg1("Failed to find reg domain pair ", regionCode); return FALSE; } - if (channelFlag & ZM_REG_FLAG_CHANNEL_2GHZ) - { + if (channelFlag & ZM_REG_FLAG_CHANNEL_2GHZ) { regDmn = regPair->regDmn2GHz; flags = regPair->flags2GHz; - } - else - { + } else { regDmn = regPair->regDmn5GHz; flags = regPair->flags5GHz; } @@ -1587,19 +1581,16 @@ u8_t GetWmRD(u16_t regionCode, u16_t channelFlag, REG_DOMAIN *rd) * unitary reg domain of the pair */ - for (i=0;i<N(regDomains); i++) - { - if (regDomains[i].regDmnEnum == regDmn) - { - if (rd != NULL) - { - zfMemoryCopy((u8_t *)rd, (u8_t *)®Domains[i], - sizeof(REG_DOMAIN)); + for (i = 0 ; i < N(regDomains) ; i++) { + if (regDomains[i].regDmnEnum == regDmn) { + if (rd != NULL) { + zfMemoryCopy((u8_t *)rd, (u8_t *)®Domains[i], + sizeof(REG_DOMAIN)); } } } rd->pscan &= regPair->pscanMask; - rd->flags = (u32_t)flags; + rd->flags = (u32_t)flags; return TRUE; } @@ -1610,7 +1601,7 @@ u8_t isChanBitMaskZero(u64_t *bitmask) { u16_t i; - for (i=0; i<BMLEN; i++) { + for (i = 0; i < BMLEN; i++) { if (bitmask[i] != 0) return FALSE; } @@ -1632,384 +1623,344 @@ u8_t IS_BIT_SET(u32_t bit, u64_t *bitmask) } -void zfHpGetRegulationTable(zdev_t* dev, u16_t regionCode, u16_t c_lo, u16_t c_hi) +void zfHpGetRegulationTable(zdev_t *dev, u16_t regionCode, u16_t c_lo, u16_t c_hi) { REG_DOMAIN rd5GHz, rd2GHz; const struct cmode *cm; - s16_t next=0,b; - struct zsHpPriv* hpPriv; + s16_t next = 0, b; + struct zsHpPriv *hpPriv; - zmw_get_wlan_dev(dev); - hpPriv=wd->hpPrivate; + zmw_get_wlan_dev(dev); + hpPriv = wd->hpPrivate; - zmw_declare_for_critical_section(); + zmw_declare_for_critical_section(); - if (!GetWmRD(regionCode, ~ZM_REG_FLAG_CHANNEL_2GHZ, &rd5GHz)) - { - zm_debug_msg1("couldn't find unitary 5GHz reg domain for Region Code ", regionCode); + if (!GetWmRD(regionCode, ~ZM_REG_FLAG_CHANNEL_2GHZ, &rd5GHz)) { + zm_debug_msg1("couldn't find unitary 5GHz reg domain for Region Code ", regionCode); return; } - if (!GetWmRD(regionCode, ZM_REG_FLAG_CHANNEL_2GHZ, &rd2GHz)) - { - zm_debug_msg1("couldn't find unitary 2GHz reg domain for Region Code ", regionCode); + if (!GetWmRD(regionCode, ZM_REG_FLAG_CHANNEL_2GHZ, &rd2GHz)) { + zm_debug_msg1("couldn't find unitary 2GHz reg domain for Region Code ", regionCode); return; } - if (wd->regulationTable.regionCode == regionCode) - { - zm_debug_msg1("current region code is the same with Region Code ", regionCode); - return; - } - else - { - wd->regulationTable.regionCode = regionCode; - } + if (wd->regulationTable.regionCode == regionCode) { + zm_debug_msg1("current region code is the same with Region Code ", regionCode); + return; + } else + wd->regulationTable.regionCode = regionCode; - next = 0; + next = 0; - zmw_enter_critical_section(dev); + zmw_enter_critical_section(dev); - for (cm = modes; cm < &modes[N(modes)]; cm++) - { + for (cm = modes; cm < &modes[N(modes)]; cm++) { u16_t c; - u64_t *channelBM=NULL; - REG_DOMAIN *rd=NULL; - REG_DMN_FREQ_BAND *fband=NULL,*freqs=NULL; + u64_t *channelBM = NULL; + REG_DOMAIN *rd = NULL; + REG_DMN_FREQ_BAND *fband = NULL, *freqs = NULL; - switch (cm->mode) - { + switch (cm->mode) { case HAL_MODE_TURBO: - //we don't have turbo mode so we disable it - //zm_debug_msg0("CWY - HAL_MODE_TURBO"); - channelBM = NULL; - //rd = &rd5GHz; - //channelBM = rd->chan11a_turbo; - //freqs = ®Dmn5GhzTurboFreq[0]; - //ctl = rd->conformanceTestLimit | CTL_TURBO; + /* we don't have turbo mode so we disable it + //zm_debug_msg0("CWY - HAL_MODE_TURBO"); */ + channelBM = NULL; + /* rd = &rd5GHz; + channelBM = rd->chan11a_turbo; + freqs = ®Dmn5GhzTurboFreq[0]; + ctl = rd->conformanceTestLimit | CTL_TURBO; */ break; case HAL_MODE_11A: - if ((hpPriv->OpFlags & 0x1) != 0) - { - rd = &rd5GHz; - channelBM = rd->chan11a; - freqs = ®Dmn5GhzFreq[0]; - c_lo = 4920; //from channel 184 - c_hi = 5825; //to channel 165 - //ctl = rd->conformanceTestLimit; - //zm_debug_msg2("CWY - HAL_MODE_11A, channelBM = 0x", *channelBM); - } - //else - { - //channelBM = NULL; - } + if ((hpPriv->OpFlags & 0x1) != 0) { + rd = &rd5GHz; + channelBM = rd->chan11a; + freqs = ®Dmn5GhzFreq[0]; + c_lo = 4920; /* from channel 184 */ + c_hi = 5825; /* to channel 165 */ + /* ctl = rd->conformanceTestLimit; + zm_debug_msg2("CWY - HAL_MODE_11A, channelBM = 0x", *channelBM); */ + } + /* else + channelBM = NULL; + */ break; case HAL_MODE_11B: - //Disable 11B mode because it only has difference with 11G in PowerDFS Data, - //and we don't use this now. - //zm_debug_msg0("CWY - HAL_MODE_11B"); + /* Disable 11B mode because it only has difference with 11G in PowerDFS Data, + and we don't use this now. + zm_debug_msg0("CWY - HAL_MODE_11B"); */ channelBM = NULL; - //rd = &rd2GHz; - //channelBM = rd->chan11b; - //freqs = ®Dmn2GhzFreq[0]; - //ctl = rd->conformanceTestLimit | CTL_11B; - //zm_debug_msg2("CWY - HAL_MODE_11B, channelBM = 0x", *channelBM); + /* rd = &rd2GHz; + channelBM = rd->chan11b; + freqs = ®Dmn2GhzFreq[0]; + ctl = rd->conformanceTestLimit | CTL_11B; + zm_debug_msg2("CWY - HAL_MODE_11B, channelBM = 0x", *channelBM); */ break; case HAL_MODE_11G: - if ((hpPriv->OpFlags & 0x2) != 0) - { - rd = &rd2GHz; - channelBM = rd->chan11g; - freqs = ®Dmn2Ghz11gFreq[0]; - c_lo = 2412; //from channel 1 - //c_hi = 2462; //to channel 11 - c_hi = 2472; //to channel 13 - //ctl = rd->conformanceTestLimit | CTL_11G; - //zm_debug_msg2("CWY - HAL_MODE_11G, channelBM = 0x", *channelBM); - } - //else - { - //channelBM = NULL; - } + if ((hpPriv->OpFlags & 0x2) != 0) { + rd = &rd2GHz; + channelBM = rd->chan11g; + freqs = ®Dmn2Ghz11gFreq[0]; + c_lo = 2412; /* from channel 1 */ + /* c_hi = 2462; to channel 11 */ + c_hi = 2472; /* to channel 13 */ + /* ctl = rd->conformanceTestLimit | CTL_11G; */ + /* zm_debug_msg2("CWY - HAL_MODE_11G, channelBM = 0x", *channelBM); */ + } + /* else + channelBM = NULL; + */ break; case HAL_MODE_11G_TURBO: - //we don't have turbo mode so we disable it - //zm_debug_msg0("CWY - HAL_MODE_11G_TURBO"); - channelBM = NULL; - //rd = &rd2GHz; - //channelBM = rd->chan11g_turbo; - //freqs = ®Dmn2Ghz11gTurboFreq[0]; - //ctl = rd->conformanceTestLimit | CTL_108G; + /* we don't have turbo mode so we disable it + zm_debug_msg0("CWY - HAL_MODE_11G_TURBO"); */ + channelBM = NULL; + /* rd = &rd2GHz; + channelBM = rd->chan11g_turbo; + freqs = ®Dmn2Ghz11gTurboFreq[0]; + ctl = rd->conformanceTestLimit | CTL_108G; */ break; case HAL_MODE_11A_TURBO: - //we don't have turbo mode so we disable it - //zm_debug_msg0("CWY - HAL_MODE_11A_TURBO"); - channelBM = NULL; - //rd = &rd5GHz; - //channelBM = rd->chan11a_dyn_turbo; - //freqs = ®Dmn5GhzTurboFreq[0]; - //ctl = rd->conformanceTestLimit | CTL_108G; + /* we don't have turbo mode so we disable it + zm_debug_msg0("CWY - HAL_MODE_11A_TURBO"); */ + channelBM = NULL; + /* rd = &rd5GHz; + channelBM = rd->chan11a_dyn_turbo; + freqs = ®Dmn5GhzTurboFreq[0]; + ctl = rd->conformanceTestLimit | CTL_108G; */ break; default: - zm_debug_msg1("Unkonwn HAL mode ", cm->mode); + zm_debug_msg1("Unkonwn HAL mode ", cm->mode); continue; } - if (channelBM == NULL) - { - //zm_debug_msg0("CWY - channelBM is NULL"); + + if (channelBM == NULL) { + /* zm_debug_msg0("CWY - channelBM is NULL"); */ continue; - } - if (isChanBitMaskZero(channelBM)) - { - //zm_debug_msg0("CWY - BitMask is Zero"); - continue; - } - - // RAY:Is it ok?? - if (freqs == NULL ) - { - continue; - } - - for (b=0;b<64*BMLEN; b++) - { - if (IS_BIT_SET(b,channelBM)) - { + } + + if (isChanBitMaskZero(channelBM)) { + /* zm_debug_msg0("CWY - BitMask is Zero"); */ + continue; + } + + /* RAY:Is it ok?? */ + if (freqs == NULL) + continue; + + for (b = 0 ; b < 64*BMLEN ; b++) { + if (IS_BIT_SET(b, channelBM)) { fband = &freqs[b]; - //zm_debug_msg1("CWY - lowChannel = ", fband->lowChannel); - //zm_debug_msg1("CWY - highChannel = ", fband->highChannel); - //zm_debug_msg1("CWY - channelSep = ", fband->channelSep); - for (c=fband->lowChannel; c <= fband->highChannel; - c += fband->channelSep) - { + /* zm_debug_msg1("CWY - lowChannel = ", fband->lowChannel); + zm_debug_msg1("CWY - highChannel = ", fband->highChannel); + zm_debug_msg1("CWY - channelSep = ", fband->channelSep); */ + for (c = fband->lowChannel; c <= fband->highChannel; + c += fband->channelSep) { ZM_HAL_CHANNEL icv; - //Disable all DFS channel - if ((hpPriv->disableDfsCh==0) || (!(fband->useDfs & rd->dfsMask))) - { - if( fband->channelBW < 20 ) - { - /**************************************************************/ - /* */ - /* Temporary discard channel that BW < 20MHz (5 or 10MHz) */ - /* Our architecture does not implemnt it !!! */ - /* */ - /**************************************************************/ - continue; - } - if ((c >= c_lo) && (c <= c_hi)) - { - icv.channel = c; - icv.channelFlags = cm->flags; - icv.maxRegTxPower = fband->powerDfs; - if (fband->usePassScan & rd->pscan) - icv.channelFlags |= ZM_REG_FLAG_CHANNEL_PASSIVE; - else - icv.channelFlags &= ~ZM_REG_FLAG_CHANNEL_PASSIVE; - if (fband->useDfs & rd->dfsMask) - icv.privFlags = ZM_REG_FLAG_CHANNEL_DFS; - else - icv.privFlags = 0; - - /* For now disable radar for FCC3 */ - if (fband->useDfs & rd->dfsMask & DFS_FCC3) - { - icv.privFlags &= ~ZM_REG_FLAG_CHANNEL_DFS; - icv.privFlags |= ZM_REG_FLAG_CHANNEL_DFS_CLEAR; - } - - if(rd->flags & LIMIT_FRAME_4MS) - icv.privFlags |= ZM_REG_FLAG_CHANNEL_DFS_CLEAR; - - icv.minTxPower = 0; - icv.maxTxPower = 0; - - zm_assert(next < 60); - - wd->regulationTable.allowChannel[next++] = icv; - } + /* Disable all DFS channel */ + if ((hpPriv->disableDfsCh == 0) || (!(fband->useDfs & rd->dfsMask))) { + if (fband->channelBW < 20) { + /**************************************************************/ + /* */ + /* Temporary discard channel that BW < 20MHz (5 or 10MHz) */ + /* Our architecture does not implemnt it !!! */ + /* */ + /**************************************************************/ + continue; + } + if ((c >= c_lo) && (c <= c_hi)) { + icv.channel = c; + icv.channelFlags = cm->flags; + icv.maxRegTxPower = fband->powerDfs; + if (fband->usePassScan & rd->pscan) + icv.channelFlags |= ZM_REG_FLAG_CHANNEL_PASSIVE; + else + icv.channelFlags &= ~ZM_REG_FLAG_CHANNEL_PASSIVE; + if (fband->useDfs & rd->dfsMask) + icv.privFlags = ZM_REG_FLAG_CHANNEL_DFS; + else + icv.privFlags = 0; + + /* For now disable radar for FCC3 */ + if (fband->useDfs & rd->dfsMask & DFS_FCC3) { + icv.privFlags &= ~ZM_REG_FLAG_CHANNEL_DFS; + icv.privFlags |= ZM_REG_FLAG_CHANNEL_DFS_CLEAR; + } + + if (rd->flags & LIMIT_FRAME_4MS) + icv.privFlags |= ZM_REG_FLAG_CHANNEL_DFS_CLEAR; + + icv.minTxPower = 0; + icv.maxTxPower = 0; + + zm_assert(next < 60); + + wd->regulationTable.allowChannel[next++] = icv; + } + } } } } } - } wd->regulationTable.allowChannelCnt = next; - #if 0 - { - /* debug print */ - u32_t i; - DbgPrint("\n-------------------------------------------\n"); - DbgPrint("zfHpGetRegulationTable print all channel info regincode = 0x%x\n", wd->regulationTable.regionCode); - DbgPrint("index channel channelFlags maxRegTxPower privFlags useDFS\n"); - - for (i=0; i<wd->regulationTable.allowChannelCnt; i++) - { - DbgPrint("%02d %d %04x %02d %x %x\n", - i, - wd->regulationTable.allowChannel[i].channel, - wd->regulationTable.allowChannel[i].channelFlags, - wd->regulationTable.allowChannel[i].maxRegTxPower, - wd->regulationTable.allowChannel[i].privFlags, - wd->regulationTable.allowChannel[i].privFlags & ZM_REG_FLAG_CHANNEL_DFS); - } - } - #endif - - zmw_leave_critical_section(dev); + #if 0 + { + /* debug print */ + u32_t i; + DbgPrint("\n-------------------------------------------\n"); + DbgPrint("zfHpGetRegulationTable print all channel info regincode = 0x%x\n", wd->regulationTable.regionCode); + DbgPrint("index channel channelFlags maxRegTxPower privFlags useDFS\n"); + + for (i = 0 ; i < wd->regulationTable.allowChannelCnt ; i++) { + DbgPrint("%02d %d %04x %02d %x %x\n", i, + wd->regulationTable.allowChannel[i].channel, + wd->regulationTable.allowChannel[i].channelFlags, + wd->regulationTable.allowChannel[i].maxRegTxPower, + wd->regulationTable.allowChannel[i].privFlags, + wd->regulationTable.allowChannel[i].privFlags & ZM_REG_FLAG_CHANNEL_DFS); + } + } + #endif + + zmw_leave_critical_section(dev); } -void zfHpGetRegulationTablefromRegionCode(zdev_t* dev, u16_t regionCode) +void zfHpGetRegulationTablefromRegionCode(zdev_t *dev, u16_t regionCode) { - u16_t c_lo = 2000, c_hi = 6000; //default channel is all enable - u8_t isoName[3] = {'N', 'A', 0}; + u16_t c_lo = 2000, c_hi = 6000; /* default channel is all enable */ + u8_t isoName[3] = {'N', 'A', 0}; - zfCoreSetIsoName(dev, isoName); + zfCoreSetIsoName(dev, isoName); - zfHpGetRegulationTable(dev, regionCode, c_lo, c_hi); + zfHpGetRegulationTable(dev, regionCode, c_lo, c_hi); } -void zfHpGetRegulationTablefromCountry(zdev_t* dev, u16_t CountryCode) +void zfHpGetRegulationTablefromCountry(zdev_t *dev, u16_t CountryCode) { - u16_t i; - u16_t c_lo = 2000, c_hi = 6000; //default channel is all enable - u16_t RegDomain; - - zmw_get_wlan_dev(dev); + u16_t i; + u16_t c_lo = 2000, c_hi = 6000; /* default channel is all enable */ + u16_t RegDomain; - zmw_declare_for_critical_section(); + zmw_get_wlan_dev(dev); - for (i = 0; i < N(allCountries); i++) - { - if (CountryCode == allCountries[i].countryCode) - { - RegDomain = allCountries[i].regDmnEnum; + zmw_declare_for_critical_section(); - // read the ACU country code from EEPROM - zfCoreSetIsoName(dev, (u8_t*)allCountries[i].isoName); + for (i = 0; i < N(allCountries); i++) { + if (CountryCode == allCountries[i].countryCode) { + RegDomain = allCountries[i].regDmnEnum; - //zm_debug_msg_s("CWY - Country Name = ", allCountries[i].name); + /* read the ACU country code from EEPROM */ + zfCoreSetIsoName(dev, (u8_t *)allCountries[i].isoName); - if (wd->regulationTable.regionCode != RegDomain) - { - //zm_debug_msg0("CWY - Change regulatory table"); + /* zm_debug_msg_s("CWY - Country Name = ", allCountries[i].name); */ - zfHpGetRegulationTable(dev, RegDomain, c_lo, c_hi); - } - return; - } - } - zm_debug_msg1("Invalid CountryCode = ", CountryCode); + if (wd->regulationTable.regionCode != RegDomain) { + /* zm_debug_msg0("CWY - Change regulatory table"); */ + zfHpGetRegulationTable(dev, RegDomain, c_lo, c_hi); + } + return; + } + } + zm_debug_msg1("Invalid CountryCode = ", CountryCode); } -u8_t zfHpGetRegulationTablefromISO(zdev_t* dev, u8_t *countryInfo, u8_t length) +u8_t zfHpGetRegulationTablefromISO(zdev_t *dev, u8_t *countryInfo, u8_t length) { - u16_t i; - u16_t RegDomain; - u16_t c_lo = 2000, c_hi = 6000; //default channel is all enable - //u8_t strLen = 2; - - zmw_get_wlan_dev(dev); - - zmw_declare_for_critical_section(); - - if (countryInfo[4] != 0x20) - { // with (I)ndoor/(O)utdoor info - //strLen = 3; - } - //zm_debug_msg_s("Desired iso name = ", isoName); - for (i = 0; i < N(allCountries); i++) - { - //zm_debug_msg_s("Current iso name = ", allCountries[i].isoName); - if (zfMemoryIsEqual((u8_t *)allCountries[i].isoName, (u8_t *)&countryInfo[2], length-1)) - { - //DbgPrint("Set current iso name = %s\n", allCountries[i].isoName); - //zm_debug_msg0("iso name hit!!"); - - RegDomain = allCountries[i].regDmnEnum; - - if (wd->regulationTable.regionCode != RegDomain) - { - zfHpGetRegulationTable(dev, RegDomain, c_lo, c_hi); - } - - //while (index < (countryInfo[1]+2)) - //{ - // if (countryInfo[index] <= 14) - // { - // /* calculate 2.4GHz low boundary channel frequency */ - // ch = countryInfo[index]; - // if ( ch == 14 ) - // c_lo = ZM_CH_G_14; - // else - // c_lo = ZM_CH_G_1 + (ch - 1) * 5; - // /* calculate 2.4GHz high boundary channel frequency */ - // ch = countryInfo[index] + countryInfo[index + 1] - 1; - // if ( ch == 14 ) - // c_hi = ZM_CH_G_14; - // else - // c_hi = ZM_CH_G_1 + (ch - 1) * 5; - // } - // else - // { - // /* calculate 5GHz low boundary channel frequency */ - // ch = countryInfo[index]; - // if ( (ch >= 184)&&(ch <= 196) ) - // c_lo = 4000 + ch*5; - // else - // c_lo = 5000 + ch*5; - // /* calculate 5GHz high boundary channel frequency */ - // ch = countryInfo[index] + countryInfo[index + 1] - 1; - // if ( (ch >= 184)&&(ch <= 196) ) - // c_hi = 4000 + ch*5; - // else - // c_hi = 5000 + ch*5; - // } - // - // zfHpGetRegulationTable(dev, RegDomain, c_lo, c_hi); - // - // index+=3; - //} - - return 0; - } - } - //zm_debug_msg_s("Invalid iso name = ", &countryInfo[2]); - return 1; + u16_t i; + u16_t RegDomain; + u16_t c_lo = 2000, c_hi = 6000; /* default channel is all enable */ + /* u8_t strLen = 2; */ + + zmw_get_wlan_dev(dev); + + zmw_declare_for_critical_section(); + + if (countryInfo[4] != 0x20) { + /* with (I)ndoor/(O)utdoor info + strLen = 3; */ + } + /* zm_debug_msg_s("Desired iso name = ", isoName); */ + for (i = 0; i < N(allCountries); i++) { + /* zm_debug_msg_s("Current iso name = ", allCountries[i].isoName); */ + if (zfMemoryIsEqual((u8_t *)allCountries[i].isoName, (u8_t *)&countryInfo[2], length-1)) { + /* DbgPrint("Set current iso name = %s\n", allCountries[i].isoName); */ + /* zm_debug_msg0("iso name hit!!"); */ + + RegDomain = allCountries[i].regDmnEnum; + + if (wd->regulationTable.regionCode != RegDomain) + zfHpGetRegulationTable(dev, RegDomain, c_lo, c_hi); + /* + while (index < (countryInfo[1]+2)) { + if (countryInfo[index] <= 14) { + // calculate 2.4GHz low boundary channel frequency + ch = countryInfo[index]; + if ( ch == 14 ) + c_lo = ZM_CH_G_14; + else + c_lo = ZM_CH_G_1 + (ch - 1) * 5; + // calculate 2.4GHz high boundary channel frequency + ch = countryInfo[index] + countryInfo[index + 1] - 1; + if ( ch == 14 ) + c_hi = ZM_CH_G_14; + else + c_hi = ZM_CH_G_1 + (ch - 1) * 5; + } else { + // calculate 5GHz low boundary channel frequency + ch = countryInfo[index]; + if ( (ch >= 184)&&(ch <= 196) ) + c_lo = 4000 + ch*5; + else + c_lo = 5000 + ch*5; + // calculate 5GHz high boundary channel frequency + ch = countryInfo[index] + countryInfo[index + 1] - 1; + if ( (ch >= 184)&&(ch <= 196) ) + c_hi = 4000 + ch*5; + else + c_hi = 5000 + ch*5; + } + + zfHpGetRegulationTable(dev, RegDomain, c_lo, c_hi); + + index+=3; + } + */ + return 0; + } + } + /* zm_debug_msg_s("Invalid iso name = ", &countryInfo[2]); */ + return 1; } -const char* zfHpGetisoNamefromregionCode(zdev_t* dev, u16_t regionCode) +const char *zfHpGetisoNamefromregionCode(zdev_t *dev, u16_t regionCode) { - u16_t i; - - for (i = 0; i < N(allCountries); i++) - { - if (allCountries[i].regDmnEnum == regionCode) - { - return allCountries[i].isoName; - } - } - /* no matching item, return default */ - return allCountries[0].isoName; + u16_t i; + + for (i = 0; i < N(allCountries); i++) { + if (allCountries[i].regDmnEnum == regionCode) + return allCountries[i].isoName; + } + /* no matching item, return default */ + return allCountries[0].isoName; } -u16_t zfHpGetRegionCodeFromIsoName(zdev_t* dev, u8_t *countryIsoName) +u16_t zfHpGetRegionCodeFromIsoName(zdev_t *dev, u8_t *countryIsoName) { - u16_t i; - u16_t regionCode; - - /* if no matching item, return default */ - regionCode = DEF_REGDMN; - - for (i = 0; i < N(allCountries); i++) - { - if (zfMemoryIsEqual((u8_t *)allCountries[i].isoName, countryIsoName, 2)) - { - regionCode = allCountries[i].regDmnEnum; - break; - } - } - - return regionCode; + u16_t i; + u16_t regionCode; + + /* if no matching item, return default */ + regionCode = DEF_REGDMN; + + for (i = 0; i < N(allCountries); i++) { + if (zfMemoryIsEqual((u8_t *)allCountries[i].isoName, countryIsoName, 2)) { + regionCode = allCountries[i].regDmnEnum; + break; + } + } + + return regionCode; } /************************************************************************/ @@ -2029,323 +1980,294 @@ u16_t zfHpGetRegionCodeFromIsoName(zdev_t* dev, u8_t *countryIsoName) /* Chao-Wen Yang ZyDAS Technology Corporation 2007.3 */ /* */ /************************************************************************/ -u16_t zfHpDeleteAllowChannel(zdev_t* dev, u16_t freq) +u16_t zfHpDeleteAllowChannel(zdev_t *dev, u16_t freq) { - u16_t i, bandIndex = 0; - u16_t dfs5GBand[][2] = {{5150, 5240}, {5260, 5350}, {5450, 5700}, {5725, 5825}}; - - zmw_get_wlan_dev(dev); - /* Find which band does this frequency belong */ - for (i = 0; i < 4; i++) - { - if ((freq >= dfs5GBand[i][0]) && (freq <= dfs5GBand[i][1])) - bandIndex = i + 1; - } - - if (bandIndex == 0) - { - /* 2.4G, don't care */ - return 0; - } - else - { - bandIndex--; - } - /* Set all channels in this band to passive scan */ - for (i = 0; i < wd->regulationTable.allowChannelCnt; i++) - { - if ((wd->regulationTable.allowChannel[i].channel >= dfs5GBand[bandIndex][0]) && - (wd->regulationTable.allowChannel[i].channel <= dfs5GBand[bandIndex][1])) - { - /* if channel is not passive, set it to be passive and mark it */ - if ((wd->regulationTable.allowChannel[i].channelFlags & - ZM_REG_FLAG_CHANNEL_PASSIVE) == 0) - { - wd->regulationTable.allowChannel[i].channelFlags |= - (ZM_REG_FLAG_CHANNEL_PASSIVE | ZM_REG_FLAG_CHANNEL_CSA); - } - } - } - - return 0; + u16_t i, bandIndex = 0; + u16_t dfs5GBand[][2] = { {5150, 5240}, {5260, 5350}, {5450, 5700}, {5725, 5825} }; + + zmw_get_wlan_dev(dev); + /* Find which band does this frequency belong */ + for (i = 0; i < 4; i++) { + if ((freq >= dfs5GBand[i][0]) && (freq <= dfs5GBand[i][1])) + bandIndex = i + 1; + } + + if (bandIndex == 0) { + /* 2.4G, don't care */ + return 0; + } else + bandIndex--; + /* Set all channels in this band to passive scan */ + for (i = 0; i < wd->regulationTable.allowChannelCnt; i++) { + if ((wd->regulationTable.allowChannel[i].channel >= dfs5GBand[bandIndex][0]) && + (wd->regulationTable.allowChannel[i].channel <= dfs5GBand[bandIndex][1])) { + /* if channel is not passive, set it to be passive and mark it */ + if ((wd->regulationTable.allowChannel[i].channelFlags & + ZM_REG_FLAG_CHANNEL_PASSIVE) == 0) { + wd->regulationTable.allowChannel[i].channelFlags |= + (ZM_REG_FLAG_CHANNEL_PASSIVE | ZM_REG_FLAG_CHANNEL_CSA); + } + } + } + + return 0; } -u16_t zfHpAddAllowChannel(zdev_t* dev, u16_t freq) +u16_t zfHpAddAllowChannel(zdev_t *dev, u16_t freq) { - u16_t i, j, arrayIndex; + u16_t i, j, arrayIndex; - zmw_get_wlan_dev(dev); + zmw_get_wlan_dev(dev); - for (i = 0; i < wd->regulationTable.allowChannelCnt; i++) - { - if (wd->regulationTable.allowChannel[i].channel == freq) - break; - } + for (i = 0; i < wd->regulationTable.allowChannelCnt; i++) { + if (wd->regulationTable.allowChannel[i].channel == freq) + break; + } - if ( i == wd->regulationTable.allowChannelCnt) - { - for (j = 0; j < wd->regulationTable.allowChannelCnt; j++) - { - if (wd->regulationTable.allowChannel[j].channel > freq) - break; - } + if (i == wd->regulationTable.allowChannelCnt) { + for (j = 0; j < wd->regulationTable.allowChannelCnt; j++) { + if (wd->regulationTable.allowChannel[j].channel > freq) + break; + } - //zm_debug_msg1("CWY - add frequency = ", freq); - //zm_debug_msg1("CWY - channel array index = ", j); + /* zm_debug_msg1("CWY - add frequency = ", freq); + zm_debug_msg1("CWY - channel array index = ", j); */ - arrayIndex = j; + arrayIndex = j; - if (arrayIndex < wd->regulationTable.allowChannelCnt) - { - for (j = wd->regulationTable.allowChannelCnt; j > arrayIndex; j--) - wd->regulationTable.allowChannel[j] = wd->regulationTable.allowChannel[j - 1]; - } - wd->regulationTable.allowChannel[arrayIndex].channel = freq; + if (arrayIndex < wd->regulationTable.allowChannelCnt) { + for (j = wd->regulationTable.allowChannelCnt; j > arrayIndex; j--) + wd->regulationTable.allowChannel[j] = wd->regulationTable.allowChannel[j - 1]; + } + wd->regulationTable.allowChannel[arrayIndex].channel = freq; - wd->regulationTable.allowChannelCnt++; - } + wd->regulationTable.allowChannelCnt++; + } - return 0; + return 0; } -u16_t zfHpIsDfsChannelNCS(zdev_t* dev, u16_t freq) +u16_t zfHpIsDfsChannelNCS(zdev_t *dev, u16_t freq) { - u8_t flag = ZM_REG_FLAG_CHANNEL_DFS; - u16_t i; - zmw_get_wlan_dev(dev); - - for (i = 0; i < wd->regulationTable.allowChannelCnt; i++) - { - //DbgPrint("DFS:freq=%d, chan=%d", freq, wd->regulationTable.allowChannel[i].channel); - if (wd->regulationTable.allowChannel[i].channel == freq) - { - flag = wd->regulationTable.allowChannel[i].privFlags; - break; - } - } - - return (flag & (ZM_REG_FLAG_CHANNEL_DFS|ZM_REG_FLAG_CHANNEL_DFS_CLEAR)); + u8_t flag = ZM_REG_FLAG_CHANNEL_DFS; + u16_t i; + zmw_get_wlan_dev(dev); + + for (i = 0; i < wd->regulationTable.allowChannelCnt; i++) { + /* DbgPrint("DFS:freq=%d, chan=%d", freq, wd->regulationTable.allowChannel[i].channel); */ + if (wd->regulationTable.allowChannel[i].channel == freq) { + flag = wd->regulationTable.allowChannel[i].privFlags; + break; } + } + + return flag & (ZM_REG_FLAG_CHANNEL_DFS|ZM_REG_FLAG_CHANNEL_DFS_CLEAR); } -u16_t zfHpIsDfsChannel(zdev_t* dev, u16_t freq) +u16_t zfHpIsDfsChannel(zdev_t *dev, u16_t freq) { - u8_t flag = ZM_REG_FLAG_CHANNEL_DFS; - u16_t i; - zmw_get_wlan_dev(dev); + u8_t flag = ZM_REG_FLAG_CHANNEL_DFS; + u16_t i; + zmw_get_wlan_dev(dev); - zmw_declare_for_critical_section(); + zmw_declare_for_critical_section(); - zmw_enter_critical_section(dev); + zmw_enter_critical_section(dev); - for (i = 0; i < wd->regulationTable.allowChannelCnt; i++) - { - //DbgPrint("DFS:freq=%d, chan=%d", freq, wd->regulationTable.allowChannel[i].channel); - if (wd->regulationTable.allowChannel[i].channel == freq) - { - flag = wd->regulationTable.allowChannel[i].privFlags; - break; - } - } + for (i = 0; i < wd->regulationTable.allowChannelCnt; i++) { + /* DbgPrint("DFS:freq=%d, chan=%d", freq, wd->regulationTable.allowChannel[i].channel); */ + if (wd->regulationTable.allowChannel[i].channel == freq) { + flag = wd->regulationTable.allowChannel[i].privFlags; + break; + } + } - zmw_leave_critical_section(dev); + zmw_leave_critical_section(dev); - return (flag & (ZM_REG_FLAG_CHANNEL_DFS|ZM_REG_FLAG_CHANNEL_DFS_CLEAR)); + return flag & (ZM_REG_FLAG_CHANNEL_DFS|ZM_REG_FLAG_CHANNEL_DFS_CLEAR); } -u16_t zfHpIsAllowedChannel(zdev_t* dev, u16_t freq) +u16_t zfHpIsAllowedChannel(zdev_t *dev, u16_t freq) { - u16_t i; - zmw_get_wlan_dev(dev); - - for (i = 0; i < wd->regulationTable.allowChannelCnt; i++) - { - if (wd->regulationTable.allowChannel[i].channel == freq) - { - return 1; - } - } - - return 0; + u16_t i; + zmw_get_wlan_dev(dev); + + for (i = 0; i < wd->regulationTable.allowChannelCnt; i++) { + if (wd->regulationTable.allowChannel[i].channel == freq) + return 1; + } + + return 0; } -u16_t zfHpFindFirstNonDfsChannel(zdev_t* dev, u16_t aBand) +u16_t zfHpFindFirstNonDfsChannel(zdev_t *dev, u16_t aBand) { - u16_t chan = 2412; - u16_t i; - zmw_get_wlan_dev(dev); - - zmw_declare_for_critical_section(); - - zmw_enter_critical_section(dev); - - for (i = 0; i < wd->regulationTable.allowChannelCnt; i++) - { - if ((wd->regulationTable.allowChannel[i].privFlags & ZM_REG_FLAG_CHANNEL_DFS) != 0) - { - if (aBand) - { - if (wd->regulationTable.allowChannel[i].channel > 3000) - { - chan = wd->regulationTable.allowChannel[i].channel; - break; - } - } - else - { - if (wd->regulationTable.allowChannel[i].channel < 3000) - { - chan = wd->regulationTable.allowChannel[i].channel; - break; - } - } - } - } - - zmw_leave_critical_section(dev); - - return chan; + u16_t chan = 2412; + u16_t i; + zmw_get_wlan_dev(dev); + + zmw_declare_for_critical_section(); + + zmw_enter_critical_section(dev); + + for (i = 0; i < wd->regulationTable.allowChannelCnt; i++) { + if ((wd->regulationTable.allowChannel[i].privFlags & ZM_REG_FLAG_CHANNEL_DFS) != 0) { + if (aBand) { + if (wd->regulationTable.allowChannel[i].channel > 3000) { + chan = wd->regulationTable.allowChannel[i].channel; + break; + } + } else { + if (wd->regulationTable.allowChannel[i].channel < 3000) { + chan = wd->regulationTable.allowChannel[i].channel; + break; + } + } + } + } + + zmw_leave_critical_section(dev); + + return chan; } /* porting from ACU */ /* save RegulatoryDomain in hpriv */ -u8_t zfHpGetRegulatoryDomain(zdev_t* dev) +u8_t zfHpGetRegulatoryDomain(zdev_t *dev) { - zmw_get_wlan_dev(dev); - - switch (wd->regulationTable.regionCode) - { - case NO_ENUMRD: - return 0; - break; - case FCC1_FCCA: - case FCC1_WORLD: - case FCC4_FCCA: - case FCC5_FCCA: - case FCC2_WORLD: - case FCC2_ETSIC: - case FCC3_FCCA: - case FCC3_WORLD: - case FCC1: - case FCC2: - case FCC3: - case FCC4: - case FCC5: - case FCCA: - return 0x10;//WG_AMERICAS DOT11_REG_DOMAIN_FCC United States - break; - - case FCC2_FCCA: - return 0x20;//DOT11_REG_DOMAIN_DOC Canada - break; - - case ETSI1_WORLD: - case ETSI3_ETSIA: - case ETSI2_WORLD: - case ETSI3_WORLD: - case ETSI4_WORLD: - case ETSI4_ETSIC: - case ETSI5_WORLD: - case ETSI6_WORLD: - case ETSI_RESERVED: - case ETSI1: - case ETSI2: - case ETSI3: - case ETSI4: - case ETSI5: - case ETSI6: - case ETSIA: - case ETSIB: - case ETSIC: - return 0x30;//WG_EMEA DOT11_REG_DOMAIN_ETSI Most of Europe - break; - - case MKK1_MKKA: - case MKK1_MKKB: - case MKK2_MKKA: - case MKK1_FCCA: - case MKK1_MKKA1: - case MKK1_MKKA2: - case MKK1_MKKC: - case MKK3_MKKB: - case MKK3_MKKA2: - case MKK3_MKKC: - case MKK4_MKKB: - case MKK4_MKKA2: - case MKK4_MKKC: - case MKK5_MKKB: - case MKK5_MKKA2: - case MKK5_MKKC: - case MKK6_MKKB: - case MKK6_MKKA2: - case MKK6_MKKC: - case MKK7_MKKB: - case MKK7_MKKA: - case MKK7_MKKC: - case MKK8_MKKB: - case MKK8_MKKA2: - case MKK8_MKKC: - case MKK6_MKKA1: - case MKK6_FCCA: - case MKK7_MKKA1: - case MKK7_FCCA: - case MKK9_FCCA: - case MKK9_MKKA1: - case MKK9_MKKC: - case MKK9_MKKA2: - case MKK10_FCCA: - case MKK10_MKKA1: - case MKK10_MKKC: - case MKK10_MKKA2: - case MKK11_MKKA: - case MKK11_FCCA: - case MKK11_MKKA1: - case MKK11_MKKC: - case MKK11_MKKA2: - case MKK12_MKKA: - case MKK12_FCCA: - case MKK12_MKKA1: - case MKK12_MKKC: - case MKK12_MKKA2: - case MKK3_MKKA: - case MKK3_MKKA1: - case MKK3_FCCA: - case MKK4_MKKA: - case MKK4_MKKA1: - case MKK4_FCCA: - case MKK9_MKKA: - case MKK10_MKKA: - case MKK1: - case MKK2: - case MKK3: - case MKK4: - case MKK5: - case MKK6: - case MKK7: - case MKK8: - case MKK9: - case MKK10: - case MKK11: - case MKK12: - case MKKA: - case MKKC: - return 0x40;//WG_JAPAN DOT11_REG_DOMAIN_MKK Japan - break; - - default: - break; - } - return 0xFF;// Didn't input RegDmn by mean to distinguish by customer + zmw_get_wlan_dev(dev); + + switch (wd->regulationTable.regionCode) { + case NO_ENUMRD: + return 0; + break; + case FCC1_FCCA: + case FCC1_WORLD: + case FCC4_FCCA: + case FCC5_FCCA: + case FCC2_WORLD: + case FCC2_ETSIC: + case FCC3_FCCA: + case FCC3_WORLD: + case FCC1: + case FCC2: + case FCC3: + case FCC4: + case FCC5: + case FCCA: + return 0x10;/* WG_AMERICAS DOT11_REG_DOMAIN_FCC United States */ + break; + + case FCC2_FCCA: + return 0x20;/* DOT11_REG_DOMAIN_DOC Canada */ + break; + + case ETSI1_WORLD: + case ETSI3_ETSIA: + case ETSI2_WORLD: + case ETSI3_WORLD: + case ETSI4_WORLD: + case ETSI4_ETSIC: + case ETSI5_WORLD: + case ETSI6_WORLD: + case ETSI_RESERVED: + case ETSI1: + case ETSI2: + case ETSI3: + case ETSI4: + case ETSI5: + case ETSI6: + case ETSIA: + case ETSIB: + case ETSIC: + return 0x30;/* WG_EMEA DOT11_REG_DOMAIN_ETSI Most of Europe */ + break; + + case MKK1_MKKA: + case MKK1_MKKB: + case MKK2_MKKA: + case MKK1_FCCA: + case MKK1_MKKA1: + case MKK1_MKKA2: + case MKK1_MKKC: + case MKK3_MKKB: + case MKK3_MKKA2: + case MKK3_MKKC: + case MKK4_MKKB: + case MKK4_MKKA2: + case MKK4_MKKC: + case MKK5_MKKB: + case MKK5_MKKA2: + case MKK5_MKKC: + case MKK6_MKKB: + case MKK6_MKKA2: + case MKK6_MKKC: + case MKK7_MKKB: + case MKK7_MKKA: + case MKK7_MKKC: + case MKK8_MKKB: + case MKK8_MKKA2: + case MKK8_MKKC: + case MKK6_MKKA1: + case MKK6_FCCA: + case MKK7_MKKA1: + case MKK7_FCCA: + case MKK9_FCCA: + case MKK9_MKKA1: + case MKK9_MKKC: + case MKK9_MKKA2: + case MKK10_FCCA: + case MKK10_MKKA1: + case MKK10_MKKC: + case MKK10_MKKA2: + case MKK11_MKKA: + case MKK11_FCCA: + case MKK11_MKKA1: + case MKK11_MKKC: + case MKK11_MKKA2: + case MKK12_MKKA: + case MKK12_FCCA: + case MKK12_MKKA1: + case MKK12_MKKC: + case MKK12_MKKA2: + case MKK3_MKKA: + case MKK3_MKKA1: + case MKK3_FCCA: + case MKK4_MKKA: + case MKK4_MKKA1: + case MKK4_FCCA: + case MKK9_MKKA: + case MKK10_MKKA: + case MKK1: + case MKK2: + case MKK3: + case MKK4: + case MKK5: + case MKK6: + case MKK7: + case MKK8: + case MKK9: + case MKK10: + case MKK11: + case MKK12: + case MKKA: + case MKKC: + return 0x40;/* WG_JAPAN DOT11_REG_DOMAIN_MKK Japan */ + break; + + default: + break; + } + return 0xFF; /* Didn't input RegDmn by mean to distinguish by customer */ } - -void zfHpDisableDfsChannel(zdev_t* dev, u8_t disableFlag) +void zfHpDisableDfsChannel(zdev_t *dev, u8_t disableFlag) { - struct zsHpPriv* hpPriv; + struct zsHpPriv *hpPriv; - zmw_get_wlan_dev(dev); - hpPriv=wd->hpPrivate; - hpPriv->disableDfsCh = disableFlag; - return; + zmw_get_wlan_dev(dev); + hpPriv = wd->hpPrivate; + hpPriv->disableDfsCh = disableFlag; + return; } diff --git a/drivers/staging/otus/ioctl.c b/drivers/staging/otus/ioctl.c index 84be4b2cd692..a48c8e4a9ea7 100644 --- a/drivers/staging/otus/ioctl.c +++ b/drivers/staging/otus/ioctl.c @@ -30,34 +30,34 @@ #include "usbdrv.h" -#define ZD_IOCTL_WPA (SIOCDEVPRIVATE + 1) -#define ZD_IOCTL_PARAM (SIOCDEVPRIVATE + 2) -#define ZD_IOCTL_GETWPAIE (SIOCDEVPRIVATE + 3) +#define ZD_IOCTL_WPA (SIOCDEVPRIVATE + 1) +#define ZD_IOCTL_PARAM (SIOCDEVPRIVATE + 2) +#define ZD_IOCTL_GETWPAIE (SIOCDEVPRIVATE + 3) #ifdef ZM_ENABLE_CENC -#define ZM_IOCTL_CENC (SIOCDEVPRIVATE + 4) +#define ZM_IOCTL_CENC (SIOCDEVPRIVATE + 4) #endif /* ZM_ENABLE_CENC */ -#define ZD_PARAM_ROAMING 0x0001 -#define ZD_PARAM_PRIVACY 0x0002 -#define ZD_PARAM_WPA 0x0003 +#define ZD_PARAM_ROAMING 0x0001 +#define ZD_PARAM_PRIVACY 0x0002 +#define ZD_PARAM_WPA 0x0003 #define ZD_PARAM_COUNTERMEASURES 0x0004 #define ZD_PARAM_DROPUNENCRYPTED 0x0005 -#define ZD_PARAM_AUTH_ALGS 0x0006 -#define ZD_PARAM_WPS_FILTER 0x0007 +#define ZD_PARAM_AUTH_ALGS 0x0006 +#define ZD_PARAM_WPS_FILTER 0x0007 #ifdef ZM_ENABLE_CENC #define P80211_PACKET_CENCFLAG 0x0001 #endif /* ZM_ENABLE_CENC */ -#define P80211_PACKET_SETKEY 0x0003 +#define P80211_PACKET_SETKEY 0x0003 #define ZD_CMD_SET_ENCRYPT_KEY 0x0001 -#define ZD_CMD_SET_MLME 0x0002 -#define ZD_CMD_SCAN_REQ 0x0003 +#define ZD_CMD_SET_MLME 0x0002 +#define ZD_CMD_SCAN_REQ 0x0003 #define ZD_CMD_SET_GENERIC_ELEMENT 0x0004 -#define ZD_CMD_GET_TSC 0x0005 +#define ZD_CMD_GET_TSC 0x0005 #define ZD_CRYPT_ALG_NAME_LEN 16 -#define ZD_MAX_KEY_SIZE 32 -#define ZD_MAX_GENERIC_SIZE 64 +#define ZD_MAX_KEY_SIZE 32 +#define ZD_MAX_GENERIC_SIZE 64 #include <net/iw_handler.h> @@ -867,6 +867,7 @@ int usbdrvwext_giwscan(struct net_device *dev, char *current_ev = extra; char *end_buf; int i; + struct zsBssListV1 *pBssList; /* BssList = wd->sta.pBssList; */ /* zmw_get_wlan_dev(dev); */ @@ -874,8 +875,10 @@ int usbdrvwext_giwscan(struct net_device *dev, return 0; /* struct zsBssList BssList; */ - struct zsBssListV1 *pBssList = kmalloc(sizeof(struct zsBssListV1), - GFP_KERNEL); + pBssList = kmalloc(sizeof(struct zsBssListV1), GFP_KERNEL); + if (pBssList == NULL) + return -ENOMEM; + if (data->length == 0) end_buf = extra + IW_SCAN_MAX_DATA; else diff --git a/drivers/staging/otus/usbdrv.c b/drivers/staging/otus/usbdrv.c index 0ce65b5b9456..165a82b9ab85 100644 --- a/drivers/staging/otus/usbdrv.c +++ b/drivers/staging/otus/usbdrv.c @@ -350,7 +350,8 @@ int usbdrv_open(struct net_device *dev) } size = zfiGlobalDataSize(dev); - if ((mem = kmalloc(size, GFP_KERNEL)) == NULL) + mem = kmalloc(size, GFP_KERNEL); + if (mem == NULL) { rc = -EBUSY; goto exit; @@ -698,7 +699,8 @@ void usbdrv_remove1(struct pci_dev *pcid) struct net_device *dev; struct usbdrv_private *macp; - if (!(dev = (struct net_device *) pci_get_drvdata(pcid))) + dev = (struct net_device *)pci_get_drvdata(pcid); + if (!dev) return; macp = dev->ml_priv; diff --git a/drivers/staging/otus/wwrap.c b/drivers/staging/otus/wwrap.c index a74f7eea56e4..b02eb42cd796 100644 --- a/drivers/staging/otus/wwrap.c +++ b/drivers/staging/otus/wwrap.c @@ -956,7 +956,6 @@ int zfLnxCencSendMsg(struct sock *netlink_sk, u_int8_t *msg, int len) /*ÌîдÊý¾Ý±¨Ïà¹ØÐÅÏ¢*/ nlh = NLMSG_PUT(skb, 0, 0, WAI_K_MSG, size-sizeof(*nlh)); pos = NLMSG_DATA(nlh); - memset(pos, 0, len); /*´«Êäµ½Óû§¿Õ¼äµÄÊý¾Ý*/ memcpy(pos, msg, len); diff --git a/drivers/staging/otus/zdusb.c b/drivers/staging/otus/zdusb.c index bb89d85a4c7c..6509bc565e65 100644 --- a/drivers/staging/otus/zdusb.c +++ b/drivers/staging/otus/zdusb.c @@ -95,7 +95,8 @@ static int zfLnxProbe(struct usb_interface *interface, printk(KERN_NOTICE "USB 1.1 Host\n"); #endif - if (!(macp = kmalloc(sizeof(struct usbdrv_private), GFP_KERNEL))) + macp = kmalloc(sizeof(struct usbdrv_private), GFP_KERNEL); + if (!macp) { printk(KERN_ERR "out of memory allocating device structure\n"); result = -ENOMEM; diff --git a/drivers/staging/phison/phison.c b/drivers/staging/phison/phison.c index 0c495eacb75b..42783d7367e3 100644 --- a/drivers/staging/phison/phison.c +++ b/drivers/staging/phison/phison.c @@ -23,7 +23,7 @@ #define PHISON_DEBUG #define DRV_NAME "phison_e-box" /* #0003 */ -#define DRV_VERSION "0.91" /* #0003 */ +#define DRV_VERSION "0.91" /* #0003 */ #define PCI_VENDOR_ID_PHISON 0x1987 #define PCI_DEVICE_ID_PS5000 0x5000 @@ -56,7 +56,7 @@ static int phison_init_one(struct pci_dev *pdev, const struct pci_device_id *id) .pio_mask = 0x1f, .mwdma_mask = 0x07, - .udma_mask = ATA_UDMA5, + .udma_mask = ATA_UDMA5, .port_ops = &phison_ops, }; diff --git a/drivers/staging/poch/Kconfig b/drivers/staging/poch/Kconfig deleted file mode 100644 index b3b33b984a57..000000000000 --- a/drivers/staging/poch/Kconfig +++ /dev/null @@ -1,6 +0,0 @@ -config POCH - tristate "Redrapids Pocket Change CardBus support" - depends on PCI && UIO - default N - ---help--- - Enable support for Redrapids Pocket Change CardBus devices. diff --git a/drivers/staging/poch/Makefile b/drivers/staging/poch/Makefile deleted file mode 100644 index d2b96805cb9e..000000000000 --- a/drivers/staging/poch/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-$(CONFIG_POCH) += poch.o diff --git a/drivers/staging/poch/README b/drivers/staging/poch/README deleted file mode 100644 index ac76ff969a2f..000000000000 --- a/drivers/staging/poch/README +++ /dev/null @@ -1,136 +0,0 @@ -TODO: - - Rx block size is limited to < 2048, hardware bug? - - Group size is limited to < page size, kernel alloc/mmap API issues - - test whether Tx is transmitting data from provided buffers - - handle device unplug case - - handle temperature above threshold - - use bus address instead of physical address for DMA - - support for snapshot mode - - audit userspace interfaces - - get reserved major/minor if needed - -Sample Code: - -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/mman.h> -#include <sys/ioctl.h> -#include <poll.h> -#include <stdio.h> -#include <error.h> -#include <errno.h> -#include <fcntl.h> -#include <stdint.h> - -#include <sysfs/libsysfs.h> - -#include <poch.h> - -struct pconsume { - uint32_t * offsets; - uint32_t nfetch; - uint32_t nflush; -}; - -uint32_t offsets[10]; - -void process_group(unsigned char *buf, uint32_t size) -{ - uint16_t *buf16 = (uint16_t *)buf; - - printf("RX: %p %u %04x %04x %04x %04x %04x %04x\n", buf, size, - buf16[0], buf16[1], buf16[2], buf16[3], buf16[4], buf16[5]); -} - -int main() -{ - struct sysfs_attribute *attr; - char *path; - int ret; - unsigned long mmap_size; - int fd; - unsigned char *cbuf; - - uint32_t nflush; - struct pollfd poll_fds; - int count = 0; - int i; - - path = "/sys/class/pocketchange/poch0/ch0/block_size"; - attr = sysfs_open_attribute(path); - ret = sysfs_write_attribute(attr, "256", strlen("256")); - if (ret == -1) - error(1, errno, "error writing attribute %s", path); - sysfs_close_attribute(attr); - - path = "/sys/class/pocketchange/poch0/ch0/group_size"; - attr = sysfs_open_attribute(path); - ret = sysfs_write_attribute(attr, "4096", strlen("4096")); - if (ret == -1) - error(1, errno, "error writing attribute %s", path); - sysfs_close_attribute(attr); - - path = "/sys/class/pocketchange/poch0/ch0/group_count"; - attr = sysfs_open_attribute(path); - ret = sysfs_write_attribute(attr, "64", strlen("64")); - if (ret == -1) - error(1, errno, "error writing attribute %s", path); - sysfs_close_attribute(attr); - - fd = open("/dev/ch0", O_RDWR); - if (fd == -1) - error(1, errno, "error opening device node"); - - path = "/sys/class/pocketchange/poch0/ch0/mmap_size"; - attr = sysfs_open_attribute(path); - ret = sysfs_read_attribute(attr); - if (ret == -1) - error(1, errno, "error reading attribute %s", path); - printf("%s", attr->value); - sscanf(attr->value, "%lu", &mmap_size); - sysfs_close_attribute(attr); - - cbuf = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, - MAP_PRIVATE, fd, 0); - if (cbuf == MAP_FAILED) - error(1, errno, "error mapping DMA buffers"); - - ret = ioctl(fd, POCH_IOC_TRANSFER_START, 0); - if (ret == -1) - error(1, errno, "error starting transfer"); - - nflush = 0; - while (1) { - struct pconsume consume; - - consume.offsets = offsets; - consume.nfetch = 10; - consume.nflush = nflush; - - ret = ioctl(fd, POCH_IOC_CONSUME, &consume); - if (ret == -1) - error(1, errno, "error consuming groups"); - - nflush = consume.nfetch; - - for (i = 0; i < nflush; i++) { - process_group(cbuf + consume.offsets[i], 4096); - - count++; - if (count == 1000) - break; - } - - if (count == 1000) - break; - } - - ret = ioctl(fd, POCH_IOC_TRANSFER_STOP, 0); - if (ret == -1) - error(1, errno, "error starting transfer"); - - return 0; -} - -Please send patches to Greg Kroah-Hartman <greg@kroah.com> and -Vijay Kumar <vijaykumar@bravegnu.org> and Jaya Kumar <jayakumar.lkml@gmail.com> diff --git a/drivers/staging/poch/poch.c b/drivers/staging/poch/poch.c deleted file mode 100644 index f940a34c1a0c..000000000000 --- a/drivers/staging/poch/poch.c +++ /dev/null @@ -1,1443 +0,0 @@ -/* - * User-space DMA and UIO based Redrapids Pocket Change CardBus driver - * - * Copyright 2008 Vijay Kumar <vijaykumar@bravegnu.org> - * - * Licensed under GPL version 2 only. - */ - -#include <linux/device.h> -#include <linux/module.h> -#include <linux/pci.h> -#include <linux/uio_driver.h> -#include <linux/spinlock.h> -#include <linux/cdev.h> -#include <linux/delay.h> -#include <linux/sysfs.h> -#include <linux/poll.h> -#include <linux/idr.h> -#include <linux/interrupt.h> -#include <linux/init.h> -#include <linux/ioctl.h> -#include <linux/io.h> -#include <linux/sched.h> -#include <linux/slab.h> - -#include "poch.h" - -#include <asm/cacheflush.h> - -#ifndef PCI_VENDOR_ID_RRAPIDS -#define PCI_VENDOR_ID_RRAPIDS 0x17D2 -#endif - -#ifndef PCI_DEVICE_ID_RRAPIDS_POCKET_CHANGE -#define PCI_DEVICE_ID_RRAPIDS_POCKET_CHANGE 0x0351 -#endif - -#define POCH_NCHANNELS 2 - -#define MAX_POCH_CARDS 8 -#define MAX_POCH_DEVICES (MAX_POCH_CARDS * POCH_NCHANNELS) - -#define DRV_NAME "poch" -#define PFX DRV_NAME ": " - -/* - * BAR0 Bridge Register Definitions - */ - -#define BRIDGE_REV_REG 0x0 -#define BRIDGE_INT_MASK_REG 0x4 -#define BRIDGE_INT_STAT_REG 0x8 - -#define BRIDGE_INT_ACTIVE (0x1 << 31) -#define BRIDGE_INT_FPGA (0x1 << 2) -#define BRIDGE_INT_TEMP_FAIL (0x1 << 1) -#define BRIDGE_INT_TEMP_WARN (0x1 << 0) - -#define BRIDGE_FPGA_RESET_REG 0xC - -#define BRIDGE_CARD_POWER_REG 0x10 -#define BRIDGE_CARD_POWER_EN (0x1 << 0) -#define BRIDGE_CARD_POWER_PROG_DONE (0x1 << 31) - -#define BRIDGE_JTAG_REG 0x14 -#define BRIDGE_DMA_GO_REG 0x18 -#define BRIDGE_STAT_0_REG 0x1C -#define BRIDGE_STAT_1_REG 0x20 -#define BRIDGE_STAT_2_REG 0x24 -#define BRIDGE_STAT_3_REG 0x28 -#define BRIDGE_TEMP_STAT_REG 0x2C -#define BRIDGE_TEMP_THRESH_REG 0x30 -#define BRIDGE_EEPROM_REVSEL_REG 0x34 -#define BRIDGE_CIS_STRUCT_REG 0x100 -#define BRIDGE_BOARDREV_REG 0x124 - -/* - * BAR1 FPGA Register Definitions - */ - -#define FPGA_IFACE_REV_REG 0x0 -#define FPGA_RX_BLOCK_SIZE_REG 0x8 -#define FPGA_TX_BLOCK_SIZE_REG 0xC -#define FPGA_RX_BLOCK_COUNT_REG 0x10 -#define FPGA_TX_BLOCK_COUNT_REG 0x14 -#define FPGA_RX_CURR_DMA_BLOCK_REG 0x18 -#define FPGA_TX_CURR_DMA_BLOCK_REG 0x1C -#define FPGA_RX_GROUP_COUNT_REG 0x20 -#define FPGA_TX_GROUP_COUNT_REG 0x24 -#define FPGA_RX_CURR_GROUP_REG 0x28 -#define FPGA_TX_CURR_GROUP_REG 0x2C -#define FPGA_RX_CURR_PCI_REG 0x38 -#define FPGA_TX_CURR_PCI_REG 0x3C -#define FPGA_RX_GROUP0_START_REG 0x40 -#define FPGA_TX_GROUP0_START_REG 0xC0 -#define FPGA_DMA_DESC_1_REG 0x140 -#define FPGA_DMA_DESC_2_REG 0x144 -#define FPGA_DMA_DESC_3_REG 0x148 -#define FPGA_DMA_DESC_4_REG 0x14C - -#define FPGA_DMA_INT_STAT_REG 0x150 -#define FPGA_DMA_INT_MASK_REG 0x154 -#define FPGA_DMA_INT_RX (1 << 0) -#define FPGA_DMA_INT_TX (1 << 1) - -#define FPGA_RX_GROUPS_PER_INT_REG 0x158 -#define FPGA_TX_GROUPS_PER_INT_REG 0x15C -#define FPGA_DMA_ADR_PAGE_REG 0x160 -#define FPGA_FPGA_REV_REG 0x200 - -#define FPGA_ADC_CLOCK_CTL_REG 0x204 -#define FPGA_ADC_CLOCK_CTL_OSC_EN (0x1 << 3) -#define FPGA_ADC_CLOCK_LOCAL_CLK (0x1 | FPGA_ADC_CLOCK_CTL_OSC_EN) -#define FPGA_ADC_CLOCK_EXT_SAMP_CLK 0X0 - -#define FPGA_ADC_DAC_EN_REG 0x208 -#define FPGA_ADC_DAC_EN_DAC_OFF (0x1 << 1) -#define FPGA_ADC_DAC_EN_ADC_OFF (0x1 << 0) - -#define FPGA_INT_STAT_REG 0x20C -#define FPGA_INT_MASK_REG 0x210 -#define FPGA_INT_PLL_UNLOCKED (0x1 << 9) -#define FPGA_INT_DMA_CORE (0x1 << 8) -#define FPGA_INT_TX_FF_EMPTY (0x1 << 7) -#define FPGA_INT_RX_FF_EMPTY (0x1 << 6) -#define FPGA_INT_TX_FF_OVRFLW (0x1 << 3) -#define FPGA_INT_RX_FF_OVRFLW (0x1 << 2) -#define FPGA_INT_TX_ACQ_DONE (0x1 << 1) -#define FPGA_INT_RX_ACQ_DONE (0x1) - -#define FPGA_RX_CTL_REG 0x214 -#define FPGA_RX_CTL_FIFO_FLUSH (0x1 << 9) -#define FPGA_RX_CTL_SYNTH_DATA (0x1 << 8) -#define FPGA_RX_CTL_CONT_CAP (0x0 << 1) -#define FPGA_RX_CTL_SNAP_CAP (0x1 << 1) - -#define FPGA_RX_ARM_REG 0x21C - -#define FPGA_DOM_REG 0x224 -#define FPGA_DOM_DCM_RESET (0x1 << 5) -#define FPGA_DOM_SOFT_RESET (0x1 << 4) -#define FPGA_DOM_DUAL_M_SG_DMA (0x0) -#define FPGA_DOM_TARGET_ACCESS (0x1) - -#define FPGA_TX_CTL_REG 0x228 -#define FPGA_TX_CTL_FIFO_FLUSH (0x1 << 9) -#define FPGA_TX_CTL_OUTPUT_ZERO (0x0 << 2) -#define FPGA_TX_CTL_OUTPUT_CARDBUS (0x1 << 2) -#define FPGA_TX_CTL_OUTPUT_ADC (0x2 << 2) -#define FPGA_TX_CTL_OUTPUT_SNAPSHOT (0x3 << 2) -#define FPGA_TX_CTL_LOOPBACK (0x1 << 0) - -#define FPGA_ENDIAN_MODE_REG 0x22C -#define FPGA_RX_FIFO_COUNT_REG 0x28C -#define FPGA_TX_ENABLE_REG 0x298 -#define FPGA_TX_TRIGGER_REG 0x29C -#define FPGA_TX_DATAMEM_COUNT_REG 0x2A8 -#define FPGA_CAP_FIFO_REG 0x300 -#define FPGA_TX_SNAPSHOT_REG 0x8000 - -/* - * Channel Index Definitions - */ - -enum { - CHNO_RX_CHANNEL, - CHNO_TX_CHANNEL, -}; - -struct poch_dev; - -enum channel_dir { - CHANNEL_DIR_RX, - CHANNEL_DIR_TX, -}; - -struct poch_group_info { - struct page *pg; - dma_addr_t dma_addr; - unsigned long user_offset; -}; - -struct channel_info { - unsigned int chno; - - atomic_t sys_block_size; - atomic_t sys_group_size; - atomic_t sys_group_count; - - enum channel_dir dir; - - unsigned long block_size; - unsigned long group_size; - unsigned long group_count; - - /* Contains the DMA address and VM offset of each group. */ - struct poch_group_info *groups; - - /* Contains the header and circular buffer exported to userspace. */ - spinlock_t group_offsets_lock; - - /* Last group consumed by user space. */ - unsigned int consumed; - /* Last group indicated as 'complete' to user space. */ - unsigned int transfer; - - wait_queue_head_t wq; - - union { - unsigned int data_available; - unsigned int space_available; - }; - - void __iomem *bridge_iomem; - void __iomem *fpga_iomem; - spinlock_t *iomem_lock; - - atomic_t free; - atomic_t inited; - - /* Error counters */ - struct poch_counters counters; - spinlock_t counters_lock; - - struct device *dev; -}; - -struct poch_dev { - struct uio_info uio; - struct pci_dev *pci_dev; - unsigned int nchannels; - struct channel_info channels[POCH_NCHANNELS]; - struct cdev cdev; - - /* Counts the no. of channels that have been opened. On first - * open, the card is powered on. On last channel close, the - * card is powered off. - */ - atomic_t usage; - - void __iomem *bridge_iomem; - void __iomem *fpga_iomem; - spinlock_t iomem_lock; - - struct device *dev; -}; - -static int synth_rx; -module_param(synth_rx, bool, 0600); -MODULE_PARM_DESC(synth_rx, - "Synthesize received values using a counter. Default: No"); - -static int loopback; -module_param(loopback, bool, 0600); -MODULE_PARM_DESC(loopback, - "Enable hardware loopback of trasnmitted data. Default: No"); - -static dev_t poch_first_dev; -static struct class *poch_cls; -static DEFINE_IDR(poch_ids); - -static ssize_t store_block_size(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct channel_info *channel = dev_get_drvdata(dev); - unsigned long block_size; - - sscanf(buf, "%lu", &block_size); - atomic_set(&channel->sys_block_size, block_size); - - return count; -} -static DEVICE_ATTR(block_size, S_IWUSR|S_IWGRP, NULL, store_block_size); - -static ssize_t store_group_size(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct channel_info *channel = dev_get_drvdata(dev); - unsigned long group_size; - - sscanf(buf, "%lu", &group_size); - atomic_set(&channel->sys_group_size, group_size); - - return count; -} -static DEVICE_ATTR(group_size, S_IWUSR|S_IWGRP, NULL, store_group_size); - -static ssize_t store_group_count(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct channel_info *channel = dev_get_drvdata(dev); - unsigned long group_count; - - sscanf(buf, "%lu", &group_count); - atomic_set(&channel->sys_group_count, group_count); - - return count; -} -static DEVICE_ATTR(group_count, S_IWUSR|S_IWGRP, NULL, store_group_count); - -static ssize_t show_direction(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct channel_info *channel = dev_get_drvdata(dev); - int len; - - len = sprintf(buf, "%s\n", (channel->dir ? "tx" : "rx")); - return len; -} -static DEVICE_ATTR(dir, S_IRUSR|S_IRGRP, show_direction, NULL); - -static unsigned long npages(unsigned long bytes) -{ - if (bytes % PAGE_SIZE == 0) - return bytes / PAGE_SIZE; - else - return (bytes / PAGE_SIZE) + 1; -} - -static ssize_t show_mmap_size(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct channel_info *channel = dev_get_drvdata(dev); - int len; - unsigned long mmap_size; - unsigned long group_pages; - unsigned long total_group_pages; - - group_pages = npages(channel->group_size); - total_group_pages = group_pages * channel->group_count; - - mmap_size = total_group_pages * PAGE_SIZE; - len = sprintf(buf, "%lu\n", mmap_size); - return len; -} -static DEVICE_ATTR(mmap_size, S_IRUSR|S_IRGRP, show_mmap_size, NULL); - -static struct device_attribute *poch_class_attrs[] = { - &dev_attr_block_size, - &dev_attr_group_size, - &dev_attr_group_count, - &dev_attr_dir, - &dev_attr_mmap_size, -}; - -static void poch_channel_free_groups(struct channel_info *channel) -{ - unsigned long i; - - for (i = 0; i < channel->group_count; i++) { - struct poch_group_info *group; - unsigned int order; - - group = &channel->groups[i]; - order = get_order(channel->group_size); - if (group->pg) - __free_pages(group->pg, order); - } -} - -static int poch_channel_alloc_groups(struct channel_info *channel) -{ - unsigned long i; - unsigned long group_pages; - - group_pages = npages(channel->group_size); - - for (i = 0; i < channel->group_count; i++) { - struct poch_group_info *group; - unsigned int order; - gfp_t gfp_mask; - - group = &channel->groups[i]; - order = get_order(channel->group_size); - - /* - * __GFP_COMP is required here since we are going to - * perform non-linear mapping to userspace. For more - * information read the vm_insert_page() function - * comments. - */ - - gfp_mask = GFP_KERNEL | GFP_DMA32 | __GFP_ZERO; - group->pg = alloc_pages(gfp_mask, order); - if (!group->pg) { - poch_channel_free_groups(channel); - return -ENOMEM; - } - - /* FIXME: This is the physical address not the bus - * address! This won't work in architectures that - * have an IOMMU. Can we use pci_map_single() for - * this? - */ - group->dma_addr = page_to_pfn(group->pg) * PAGE_SIZE; - group->user_offset = (i * group_pages) * PAGE_SIZE; - - printk(KERN_INFO PFX "%ld: user_offset: 0x%lx\n", i, - group->user_offset); - } - - return 0; -} - -static int channel_latch_attr(struct channel_info *channel) -{ - channel->group_count = atomic_read(&channel->sys_group_count); - channel->group_size = atomic_read(&channel->sys_group_size); - channel->block_size = atomic_read(&channel->sys_block_size); - - if (channel->group_count == 0) { - printk(KERN_ERR PFX "invalid group count %lu", - channel->group_count); - return -EINVAL; - } - - if (channel->group_size == 0 || - channel->group_size < channel->block_size) { - printk(KERN_ERR PFX "invalid group size %lu", - channel->group_size); - return -EINVAL; - } - - if (channel->block_size == 0 || (channel->block_size % 8) != 0) { - printk(KERN_ERR PFX "invalid block size %lu", - channel->block_size); - return -EINVAL; - } - - if (channel->group_size % channel->block_size != 0) { - printk(KERN_ERR PFX - "group size should be multiple of block size"); - return -EINVAL; - } - - return 0; -} - -/* - * Configure DMA group registers - */ -static void channel_dma_init(struct channel_info *channel) -{ - void __iomem *fpga = channel->fpga_iomem; - u32 group_regs_base; - u32 group_reg; - unsigned int page; - unsigned int group_in_page; - unsigned long i; - u32 block_size_reg; - u32 block_count_reg; - u32 group_count_reg; - u32 groups_per_int_reg; - u32 curr_pci_reg; - - if (channel->chno == CHNO_RX_CHANNEL) { - group_regs_base = FPGA_RX_GROUP0_START_REG; - block_size_reg = FPGA_RX_BLOCK_SIZE_REG; - block_count_reg = FPGA_RX_BLOCK_COUNT_REG; - group_count_reg = FPGA_RX_GROUP_COUNT_REG; - groups_per_int_reg = FPGA_RX_GROUPS_PER_INT_REG; - curr_pci_reg = FPGA_RX_CURR_PCI_REG; - } else { - group_regs_base = FPGA_TX_GROUP0_START_REG; - block_size_reg = FPGA_TX_BLOCK_SIZE_REG; - block_count_reg = FPGA_TX_BLOCK_COUNT_REG; - group_count_reg = FPGA_TX_GROUP_COUNT_REG; - groups_per_int_reg = FPGA_TX_GROUPS_PER_INT_REG; - curr_pci_reg = FPGA_TX_CURR_PCI_REG; - } - - printk(KERN_WARNING "block_size, group_size, group_count\n"); - /* - * Block size is represented in no. of 64 bit transfers. - */ - iowrite32(channel->block_size / 8, fpga + block_size_reg); - iowrite32(channel->group_size / channel->block_size, - fpga + block_count_reg); - iowrite32(channel->group_count, fpga + group_count_reg); - /* FIXME: Hardcoded groups per int. Get it from sysfs? */ - iowrite32(16, fpga + groups_per_int_reg); - - /* Unlock PCI address? Not defined in the data sheet, but used - * in the reference code by Redrapids. - */ - iowrite32(0x1, fpga + curr_pci_reg); - - /* The DMA address page register is shared between the RX and - * TX channels, so acquire lock. - */ - for (i = 0; i < channel->group_count; i++) { - page = i / 32; - group_in_page = i % 32; - - group_reg = group_regs_base + (group_in_page * 4); - - spin_lock(channel->iomem_lock); - iowrite32(page, fpga + FPGA_DMA_ADR_PAGE_REG); - iowrite32(channel->groups[i].dma_addr, fpga + group_reg); - spin_unlock(channel->iomem_lock); - } - - for (i = 0; i < channel->group_count; i++) { - page = i / 32; - group_in_page = i % 32; - - group_reg = group_regs_base + (group_in_page * 4); - - spin_lock(channel->iomem_lock); - iowrite32(page, fpga + FPGA_DMA_ADR_PAGE_REG); - printk(KERN_INFO PFX "%ld: read dma_addr: 0x%x\n", i, - ioread32(fpga + group_reg)); - spin_unlock(channel->iomem_lock); - } - -} - -static void __poch_channel_clear_counters(struct channel_info *channel) -{ - channel->counters.pll_unlock = 0; - channel->counters.fifo_empty = 0; - channel->counters.fifo_overflow = 0; -} - -static int poch_channel_init(struct channel_info *channel, - struct poch_dev *poch_dev) -{ - struct pci_dev *pdev = poch_dev->pci_dev; - struct device *dev = &pdev->dev; - unsigned long alloc_size; - int ret; - - printk(KERN_WARNING "channel_latch_attr\n"); - - ret = channel_latch_attr(channel); - if (ret != 0) - goto out; - - channel->consumed = 0; - channel->transfer = 0; - - /* Allocate memory to hold group information. */ - alloc_size = channel->group_count * sizeof(struct poch_group_info); - channel->groups = kzalloc(alloc_size, GFP_KERNEL); - if (!channel->groups) { - dev_err(dev, "error allocating memory for group info\n"); - ret = -ENOMEM; - goto out; - } - - printk(KERN_WARNING "poch_channel_alloc_groups\n"); - - ret = poch_channel_alloc_groups(channel); - if (ret) { - dev_err(dev, "error allocating groups of order %d\n", - get_order(channel->group_size)); - goto out_free_group_info; - } - - channel->fpga_iomem = poch_dev->fpga_iomem; - channel->bridge_iomem = poch_dev->bridge_iomem; - channel->iomem_lock = &poch_dev->iomem_lock; - spin_lock_init(&channel->counters_lock); - - __poch_channel_clear_counters(channel); - - return 0; - - out_free_group_info: - kfree(channel->groups); - out: - return ret; -} - -static int poch_wait_fpga_prog(void __iomem *bridge) -{ - unsigned long total_wait; - const unsigned long wait_period = 100; - /* FIXME: Get the actual timeout */ - const unsigned long prog_timeo = 10000; /* 10 Seconds */ - u32 card_power; - - printk(KERN_WARNING "poch_wait_fpg_prog\n"); - - printk(KERN_INFO PFX "programming fpga ...\n"); - total_wait = 0; - while (1) { - msleep(wait_period); - total_wait += wait_period; - - card_power = ioread32(bridge + BRIDGE_CARD_POWER_REG); - if (card_power & BRIDGE_CARD_POWER_PROG_DONE) { - printk(KERN_INFO PFX "programming done\n"); - return 0; - } - if (total_wait > prog_timeo) { - printk(KERN_ERR PFX - "timed out while programming FPGA\n"); - return -EIO; - } - } -} - -static void poch_card_power_off(struct poch_dev *poch_dev) -{ - void __iomem *bridge = poch_dev->bridge_iomem; - u32 card_power; - - iowrite32(0, bridge + BRIDGE_INT_MASK_REG); - iowrite32(0, bridge + BRIDGE_DMA_GO_REG); - - card_power = ioread32(bridge + BRIDGE_CARD_POWER_REG); - iowrite32(card_power & ~BRIDGE_CARD_POWER_EN, - bridge + BRIDGE_CARD_POWER_REG); -} - -enum clk_src { - CLK_SRC_ON_BOARD, - CLK_SRC_EXTERNAL -}; - -static void poch_card_clock_on(void __iomem *fpga) -{ - /* FIXME: Get this data through sysfs? */ - enum clk_src clk_src = CLK_SRC_ON_BOARD; - - if (clk_src == CLK_SRC_ON_BOARD) { - iowrite32(FPGA_ADC_CLOCK_LOCAL_CLK | FPGA_ADC_CLOCK_CTL_OSC_EN, - fpga + FPGA_ADC_CLOCK_CTL_REG); - } else if (clk_src == CLK_SRC_EXTERNAL) { - iowrite32(FPGA_ADC_CLOCK_EXT_SAMP_CLK, - fpga + FPGA_ADC_CLOCK_CTL_REG); - } -} - -static int poch_card_power_on(struct poch_dev *poch_dev) -{ - void __iomem *bridge = poch_dev->bridge_iomem; - void __iomem *fpga = poch_dev->fpga_iomem; - - iowrite32(BRIDGE_CARD_POWER_EN, bridge + BRIDGE_CARD_POWER_REG); - - if (poch_wait_fpga_prog(bridge) != 0) { - poch_card_power_off(poch_dev); - return -EIO; - } - - poch_card_clock_on(fpga); - - /* Sync to new clock, reset state machines, set DMA mode. */ - iowrite32(FPGA_DOM_DCM_RESET | FPGA_DOM_SOFT_RESET - | FPGA_DOM_DUAL_M_SG_DMA, fpga + FPGA_DOM_REG); - - /* FIXME: The time required for sync. needs to be tuned. */ - msleep(1000); - - return 0; -} - -static void poch_channel_analog_on(struct channel_info *channel) -{ - void __iomem *fpga = channel->fpga_iomem; - u32 adc_dac_en; - - spin_lock(channel->iomem_lock); - adc_dac_en = ioread32(fpga + FPGA_ADC_DAC_EN_REG); - switch (channel->chno) { - case CHNO_RX_CHANNEL: - iowrite32(adc_dac_en & ~FPGA_ADC_DAC_EN_ADC_OFF, - fpga + FPGA_ADC_DAC_EN_REG); - break; - case CHNO_TX_CHANNEL: - iowrite32(adc_dac_en & ~FPGA_ADC_DAC_EN_DAC_OFF, - fpga + FPGA_ADC_DAC_EN_REG); - break; - } - spin_unlock(channel->iomem_lock); -} - -static int poch_open(struct inode *inode, struct file *filp) -{ - struct poch_dev *poch_dev; - struct channel_info *channel; - void __iomem *bridge; - void __iomem *fpga; - int chno; - int usage; - int ret; - - poch_dev = container_of(inode->i_cdev, struct poch_dev, cdev); - bridge = poch_dev->bridge_iomem; - fpga = poch_dev->fpga_iomem; - - chno = iminor(inode) % poch_dev->nchannels; - channel = &poch_dev->channels[chno]; - - if (!atomic_dec_and_test(&channel->free)) { - atomic_inc(&channel->free); - ret = -EBUSY; - goto out; - } - - usage = atomic_inc_return(&poch_dev->usage); - - printk(KERN_WARNING "poch_card_power_on\n"); - - if (usage == 1) { - ret = poch_card_power_on(poch_dev); - if (ret) - goto out_dec_usage; - } - - printk(KERN_INFO "CardBus Bridge Revision: %x\n", - ioread32(bridge + BRIDGE_REV_REG)); - printk(KERN_INFO "CardBus Interface Revision: %x\n", - ioread32(fpga + FPGA_IFACE_REV_REG)); - - channel->chno = chno; - filp->private_data = channel; - - printk(KERN_WARNING "poch_channel_init\n"); - - ret = poch_channel_init(channel, poch_dev); - if (ret) - goto out_power_off; - - poch_channel_analog_on(channel); - - printk(KERN_WARNING "channel_dma_init\n"); - - channel_dma_init(channel); - - printk(KERN_WARNING "poch_channel_analog_on\n"); - - if (usage == 1) { - printk(KERN_WARNING "setting up DMA\n"); - - /* Initialize DMA Controller. */ - iowrite32(FPGA_CAP_FIFO_REG, bridge + BRIDGE_STAT_2_REG); - iowrite32(FPGA_DMA_DESC_1_REG, bridge + BRIDGE_STAT_3_REG); - - ioread32(fpga + FPGA_DMA_INT_STAT_REG); - ioread32(fpga + FPGA_INT_STAT_REG); - ioread32(bridge + BRIDGE_INT_STAT_REG); - - /* Initialize Interrupts. FIXME: Enable temperature - * handling We are enabling both Tx and Rx channel - * interrupts here. Do we need to enable interrupts - * only for the current channel? Anyways we won't get - * the interrupt unless the DMA is activated. - */ - iowrite32(BRIDGE_INT_FPGA, bridge + BRIDGE_INT_MASK_REG); - iowrite32(FPGA_INT_DMA_CORE - | FPGA_INT_PLL_UNLOCKED - | FPGA_INT_TX_FF_EMPTY - | FPGA_INT_RX_FF_EMPTY - | FPGA_INT_TX_FF_OVRFLW - | FPGA_INT_RX_FF_OVRFLW, - fpga + FPGA_INT_MASK_REG); - iowrite32(FPGA_DMA_INT_RX | FPGA_DMA_INT_TX, - fpga + FPGA_DMA_INT_MASK_REG); - } - - if (channel->dir == CHANNEL_DIR_TX) { - /* Flush TX FIFO and output data from cardbus. */ - u32 ctl_val = 0; - - ctl_val |= FPGA_TX_CTL_FIFO_FLUSH; - ctl_val |= FPGA_TX_CTL_OUTPUT_CARDBUS; - if (loopback) - ctl_val |= FPGA_TX_CTL_LOOPBACK; - - iowrite32(ctl_val, fpga + FPGA_TX_CTL_REG); - } else { - /* Flush RX FIFO and output data to cardbus. */ - u32 ctl_val = FPGA_RX_CTL_CONT_CAP | FPGA_RX_CTL_FIFO_FLUSH; - if (synth_rx) - ctl_val |= FPGA_RX_CTL_SYNTH_DATA; - - iowrite32(ctl_val, fpga + FPGA_RX_CTL_REG); - } - - atomic_inc(&channel->inited); - - return 0; - - out_power_off: - if (usage == 1) - poch_card_power_off(poch_dev); - out_dec_usage: - atomic_dec(&poch_dev->usage); - atomic_inc(&channel->free); - out: - return ret; -} - -static int poch_release(struct inode *inode, struct file *filp) -{ - struct channel_info *channel = filp->private_data; - struct poch_dev *poch_dev; - int usage; - - poch_dev = container_of(inode->i_cdev, struct poch_dev, cdev); - - usage = atomic_dec_return(&poch_dev->usage); - if (usage == 0) { - printk(KERN_WARNING "poch_card_power_off\n"); - poch_card_power_off(poch_dev); - } - - atomic_dec(&channel->inited); - poch_channel_free_groups(channel); - kfree(channel->groups); - atomic_inc(&channel->free); - - return 0; -} - -/* - * Map the the group buffers, to user space. - */ -static int poch_mmap(struct file *filp, struct vm_area_struct *vma) -{ - struct channel_info *channel = filp->private_data; - - unsigned long start; - unsigned long size; - - unsigned long group_pages; - unsigned long total_group_pages; - - int pg_num; - struct page *pg; - - int i; - int ret; - - printk(KERN_WARNING "poch_mmap\n"); - - if (vma->vm_pgoff) { - printk(KERN_WARNING PFX "page offset: %lu\n", vma->vm_pgoff); - return -EINVAL; - } - - group_pages = npages(channel->group_size); - total_group_pages = group_pages * channel->group_count; - - size = vma->vm_end - vma->vm_start; - if (size != total_group_pages * PAGE_SIZE) { - printk(KERN_WARNING PFX "required %lu bytes\n", size); - return -EINVAL; - } - - start = vma->vm_start; - - for (i = 0; i < channel->group_count; i++) { - pg = channel->groups[i].pg; - for (pg_num = 0; pg_num < group_pages; pg_num++, pg++) { - printk(KERN_DEBUG PFX "%d: group %d: 0x%lx\n", - pg_num, i, start); - ret = vm_insert_page(vma, start, pg); - if (ret) { - printk(KERN_DEBUG PFX - "vm_insert 2 failed at %d\n", pg_num); - return ret; - } - start += PAGE_SIZE; - } - } - - return 0; -} - -/* - * Check whether there is some group that the user space has not - * consumed yet. When the user space consumes a group, it sets it to - * -1. Cosuming could be reading data in case of RX and filling a - * buffer in case of TX. - */ -static int poch_channel_available(struct channel_info *channel) -{ - int available = 0; - - spin_lock_irq(&channel->group_offsets_lock); - - if (channel->consumed != channel->transfer) - available = 1; - - spin_unlock_irq(&channel->group_offsets_lock); - - return available; -} - -static unsigned int poch_poll(struct file *filp, poll_table *pt) -{ - struct channel_info *channel = filp->private_data; - unsigned int ret = 0; - - poll_wait(filp, &channel->wq, pt); - - if (poch_channel_available(channel)) { - if (channel->dir == CHANNEL_DIR_RX) - ret = POLLIN | POLLRDNORM; - else - ret = POLLOUT | POLLWRNORM; - } - - return ret; -} - -static int poch_ioctl(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) -{ - struct channel_info *channel = filp->private_data; - void __iomem *fpga = channel->fpga_iomem; - void __iomem *bridge = channel->bridge_iomem; - void __user *argp = (void __user *)arg; - struct vm_area_struct *vms; - struct poch_counters counters; - int ret; - - switch (cmd) { - case POCH_IOC_TRANSFER_START: - switch (channel->chno) { - case CHNO_TX_CHANNEL: - printk(KERN_INFO PFX "ioctl: Tx start\n"); - iowrite32(0x1, fpga + FPGA_TX_TRIGGER_REG); - iowrite32(0x1, fpga + FPGA_TX_ENABLE_REG); - - /* FIXME: Does it make sense to do a DMA GO - * twice, once in Tx and once in Rx. - */ - iowrite32(0x1, bridge + BRIDGE_DMA_GO_REG); - break; - case CHNO_RX_CHANNEL: - printk(KERN_INFO PFX "ioctl: Rx start\n"); - iowrite32(0x1, fpga + FPGA_RX_ARM_REG); - iowrite32(0x1, bridge + BRIDGE_DMA_GO_REG); - break; - } - break; - case POCH_IOC_TRANSFER_STOP: - switch (channel->chno) { - case CHNO_TX_CHANNEL: - printk(KERN_INFO PFX "ioctl: Tx stop\n"); - iowrite32(0x0, fpga + FPGA_TX_ENABLE_REG); - iowrite32(0x0, fpga + FPGA_TX_TRIGGER_REG); - iowrite32(0x0, bridge + BRIDGE_DMA_GO_REG); - break; - case CHNO_RX_CHANNEL: - printk(KERN_INFO PFX "ioctl: Rx stop\n"); - iowrite32(0x0, fpga + FPGA_RX_ARM_REG); - iowrite32(0x0, bridge + BRIDGE_DMA_GO_REG); - break; - } - break; - case POCH_IOC_CONSUME: - { - int available; - int nfetch; - unsigned int from; - unsigned int count; - unsigned int i, j; - struct poch_consume consume; - struct poch_consume *uconsume; - - uconsume = argp; - ret = copy_from_user(&consume, uconsume, sizeof(consume)); - if (ret) - return ret; - - spin_lock_irq(&channel->group_offsets_lock); - - channel->consumed += consume.nflush; - channel->consumed %= channel->group_count; - - available = channel->transfer - channel->consumed; - if (available < 0) - available += channel->group_count; - - from = channel->consumed; - - spin_unlock_irq(&channel->group_offsets_lock); - - nfetch = consume.nfetch; - count = min(available, nfetch); - - for (i = 0; i < count; i++) { - j = (from + i) % channel->group_count; - ret = put_user(channel->groups[j].user_offset, - &consume.offsets[i]); - if (ret) - return -EFAULT; - } - - ret = put_user(count, &uconsume->nfetch); - if (ret) - return -EFAULT; - - break; - } - case POCH_IOC_GET_COUNTERS: - if (!access_ok(VERIFY_WRITE, argp, sizeof(struct poch_counters))) - return -EFAULT; - - spin_lock_irq(&channel->counters_lock); - counters = channel->counters; - __poch_channel_clear_counters(channel); - spin_unlock_irq(&channel->counters_lock); - - ret = copy_to_user(argp, &counters, - sizeof(struct poch_counters)); - if (ret) - return ret; - - break; - case POCH_IOC_SYNC_GROUP_FOR_USER: - case POCH_IOC_SYNC_GROUP_FOR_DEVICE: - vms = find_vma(current->mm, arg); - if (!vms) - /* Address not mapped. */ - return -EINVAL; - if (vms->vm_file != filp) - /* Address mapped from different device/file. */ - return -EINVAL; - - flush_cache_range(vms, arg, arg + channel->group_size); - break; - } - return 0; -} - -static struct file_operations poch_fops = { - .owner = THIS_MODULE, - .open = poch_open, - .release = poch_release, - .ioctl = poch_ioctl, - .poll = poch_poll, - .mmap = poch_mmap -}; - -static void poch_irq_dma(struct channel_info *channel) -{ - u32 prev_transfer; - u32 curr_transfer; - long groups_done; - unsigned long i, j; - struct poch_group_info *groups; - u32 curr_group_reg; - - if (!atomic_read(&channel->inited)) - return; - - prev_transfer = channel->transfer; - - if (channel->chno == CHNO_RX_CHANNEL) - curr_group_reg = FPGA_RX_CURR_GROUP_REG; - else - curr_group_reg = FPGA_TX_CURR_GROUP_REG; - - curr_transfer = ioread32(channel->fpga_iomem + curr_group_reg); - - groups_done = curr_transfer - prev_transfer; - /* Check wrap over, and handle it. */ - if (groups_done <= 0) - groups_done += channel->group_count; - - groups = channel->groups; - - spin_lock(&channel->group_offsets_lock); - - for (i = 0; i < groups_done; i++) { - j = (prev_transfer + i) % channel->group_count; - - channel->transfer += 1; - channel->transfer %= channel->group_count; - - if (channel->transfer == channel->consumed) { - channel->consumed += 1; - channel->consumed %= channel->group_count; - } - } - - spin_unlock(&channel->group_offsets_lock); - - wake_up_interruptible(&channel->wq); -} - -static irqreturn_t poch_irq_handler(int irq, void *p) -{ - struct poch_dev *poch_dev = p; - void __iomem *bridge = poch_dev->bridge_iomem; - void __iomem *fpga = poch_dev->fpga_iomem; - struct channel_info *channel_rx = &poch_dev->channels[CHNO_RX_CHANNEL]; - struct channel_info *channel_tx = &poch_dev->channels[CHNO_TX_CHANNEL]; - u32 bridge_stat; - u32 fpga_stat; - u32 dma_stat; - - bridge_stat = ioread32(bridge + BRIDGE_INT_STAT_REG); - fpga_stat = ioread32(fpga + FPGA_INT_STAT_REG); - dma_stat = ioread32(fpga + FPGA_DMA_INT_STAT_REG); - - ioread32(fpga + FPGA_DMA_INT_STAT_REG); - ioread32(fpga + FPGA_INT_STAT_REG); - ioread32(bridge + BRIDGE_INT_STAT_REG); - - if (bridge_stat & BRIDGE_INT_FPGA) { - if (fpga_stat & FPGA_INT_DMA_CORE) { - if (dma_stat & FPGA_DMA_INT_RX) - poch_irq_dma(channel_rx); - if (dma_stat & FPGA_DMA_INT_TX) - poch_irq_dma(channel_tx); - } - if (fpga_stat & FPGA_INT_PLL_UNLOCKED) { - channel_tx->counters.pll_unlock++; - channel_rx->counters.pll_unlock++; - if (printk_ratelimit()) - printk(KERN_WARNING PFX "PLL unlocked\n"); - } - if (fpga_stat & FPGA_INT_TX_FF_EMPTY) - channel_tx->counters.fifo_empty++; - if (fpga_stat & FPGA_INT_TX_FF_OVRFLW) - channel_tx->counters.fifo_overflow++; - if (fpga_stat & FPGA_INT_RX_FF_EMPTY) - channel_rx->counters.fifo_empty++; - if (fpga_stat & FPGA_INT_RX_FF_OVRFLW) - channel_rx->counters.fifo_overflow++; - - /* - * FIXME: These errors should be notified through the - * poll interface as POLLERR. - */ - - /* Re-enable interrupts. */ - iowrite32(BRIDGE_INT_FPGA, bridge + BRIDGE_INT_MASK_REG); - - return IRQ_HANDLED; - } - - return IRQ_NONE; -} - -static void poch_class_dev_unregister(struct poch_dev *poch_dev, int id) -{ - int i, j; - int nattrs; - struct channel_info *channel; - dev_t devno; - - if (poch_dev->dev == NULL) - return; - - for (i = 0; i < poch_dev->nchannels; i++) { - channel = &poch_dev->channels[i]; - devno = poch_first_dev + (id * poch_dev->nchannels) + i; - - if (!channel->dev) - continue; - - nattrs = sizeof(poch_class_attrs)/sizeof(poch_class_attrs[0]); - for (j = 0; j < nattrs; j++) - device_remove_file(channel->dev, poch_class_attrs[j]); - - device_unregister(channel->dev); - } - - device_unregister(poch_dev->dev); -} - -static int __devinit poch_class_dev_register(struct poch_dev *poch_dev, - int id) -{ - struct device *dev = &poch_dev->pci_dev->dev; - int i, j; - int nattrs; - int ret; - struct channel_info *channel; - dev_t devno; - - poch_dev->dev = device_create(poch_cls, &poch_dev->pci_dev->dev, - MKDEV(0, 0), NULL, "poch%d", id); - if (IS_ERR(poch_dev->dev)) { - dev_err(dev, "error creating parent class device"); - ret = PTR_ERR(poch_dev->dev); - poch_dev->dev = NULL; - return ret; - } - - for (i = 0; i < poch_dev->nchannels; i++) { - channel = &poch_dev->channels[i]; - - devno = poch_first_dev + (id * poch_dev->nchannels) + i; - channel->dev = device_create(poch_cls, poch_dev->dev, devno, - NULL, "ch%d", i); - if (IS_ERR(channel->dev)) { - dev_err(dev, "error creating channel class device"); - ret = PTR_ERR(channel->dev); - channel->dev = NULL; - poch_class_dev_unregister(poch_dev, id); - return ret; - } - - dev_set_drvdata(channel->dev, channel); - nattrs = sizeof(poch_class_attrs)/sizeof(poch_class_attrs[0]); - for (j = 0; j < nattrs; j++) { - ret = device_create_file(channel->dev, - poch_class_attrs[j]); - if (ret) { - dev_err(dev, "error creating attribute file"); - poch_class_dev_unregister(poch_dev, id); - return ret; - } - } - } - - return 0; -} - -static int __devinit poch_pci_probe(struct pci_dev *pdev, - const struct pci_device_id *pci_id) -{ - struct device *dev = &pdev->dev; - struct poch_dev *poch_dev; - struct uio_info *uio; - int ret; - int id; - int i; - - poch_dev = kzalloc(sizeof(struct poch_dev), GFP_KERNEL); - if (!poch_dev) { - dev_err(dev, "error allocating priv. data memory\n"); - return -ENOMEM; - } - - poch_dev->pci_dev = pdev; - uio = &poch_dev->uio; - - pci_set_drvdata(pdev, poch_dev); - - spin_lock_init(&poch_dev->iomem_lock); - - poch_dev->nchannels = POCH_NCHANNELS; - poch_dev->channels[CHNO_RX_CHANNEL].dir = CHANNEL_DIR_RX; - poch_dev->channels[CHNO_TX_CHANNEL].dir = CHANNEL_DIR_TX; - - for (i = 0; i < poch_dev->nchannels; i++) { - init_waitqueue_head(&poch_dev->channels[i].wq); - atomic_set(&poch_dev->channels[i].free, 1); - atomic_set(&poch_dev->channels[i].inited, 0); - } - - ret = pci_enable_device(pdev); - if (ret) { - dev_err(dev, "error enabling device\n"); - goto out_free; - } - - ret = pci_request_regions(pdev, "poch"); - if (ret) { - dev_err(dev, "error requesting resources\n"); - goto out_disable; - } - - uio->mem[0].addr = pci_resource_start(pdev, 1); - if (!uio->mem[0].addr) { - dev_err(dev, "invalid BAR1\n"); - ret = -ENODEV; - goto out_release; - } - - uio->mem[0].size = pci_resource_len(pdev, 1); - uio->mem[0].memtype = UIO_MEM_PHYS; - - uio->name = "poch"; - uio->version = "0.0.1"; - uio->irq = -1; - ret = uio_register_device(dev, uio); - if (ret) { - dev_err(dev, "error register UIO device: %d\n", ret); - goto out_release; - } - - poch_dev->bridge_iomem = ioremap(pci_resource_start(pdev, 0), - pci_resource_len(pdev, 0)); - if (poch_dev->bridge_iomem == NULL) { - dev_err(dev, "error mapping bridge (bar0) registers\n"); - ret = -ENOMEM; - goto out_uio_unreg; - } - - poch_dev->fpga_iomem = ioremap(pci_resource_start(pdev, 1), - pci_resource_len(pdev, 1)); - if (poch_dev->fpga_iomem == NULL) { - dev_err(dev, "error mapping fpga (bar1) registers\n"); - ret = -ENOMEM; - goto out_bar0_unmap; - } - - ret = request_irq(pdev->irq, poch_irq_handler, IRQF_SHARED, - dev_name(dev), poch_dev); - if (ret) { - dev_err(dev, "error requesting IRQ %u\n", pdev->irq); - ret = -ENOMEM; - goto out_bar1_unmap; - } - - if (!idr_pre_get(&poch_ids, GFP_KERNEL)) { - dev_err(dev, "error allocating memory ids\n"); - ret = -ENOMEM; - goto out_free_irq; - } - - idr_get_new(&poch_ids, poch_dev, &id); - if (id >= MAX_POCH_CARDS) { - dev_err(dev, "minors exhausted\n"); - ret = -EBUSY; - goto out_free_irq; - } - - cdev_init(&poch_dev->cdev, &poch_fops); - poch_dev->cdev.owner = THIS_MODULE; - ret = cdev_add(&poch_dev->cdev, - poch_first_dev + (id * poch_dev->nchannels), - poch_dev->nchannels); - if (ret) { - dev_err(dev, "error register character device\n"); - goto out_idr_remove; - } - - ret = poch_class_dev_register(poch_dev, id); - if (ret) - goto out_cdev_del; - - return 0; - - out_cdev_del: - cdev_del(&poch_dev->cdev); - out_idr_remove: - idr_remove(&poch_ids, id); - out_free_irq: - free_irq(pdev->irq, poch_dev); - out_bar1_unmap: - iounmap(poch_dev->fpga_iomem); - out_bar0_unmap: - iounmap(poch_dev->bridge_iomem); - out_uio_unreg: - uio_unregister_device(uio); - out_release: - pci_release_regions(pdev); - out_disable: - pci_disable_device(pdev); - out_free: - kfree(poch_dev); - return ret; -} - -/* - * FIXME: We are yet to handle the hot unplug case. - */ -static void poch_pci_remove(struct pci_dev *pdev) -{ - struct poch_dev *poch_dev = pci_get_drvdata(pdev); - struct uio_info *uio = &poch_dev->uio; - unsigned int minor = MINOR(poch_dev->cdev.dev); - unsigned int id = minor / poch_dev->nchannels; - - poch_class_dev_unregister(poch_dev, id); - cdev_del(&poch_dev->cdev); - idr_remove(&poch_ids, id); - free_irq(pdev->irq, poch_dev); - iounmap(poch_dev->fpga_iomem); - iounmap(poch_dev->bridge_iomem); - uio_unregister_device(uio); - pci_release_regions(pdev); - pci_disable_device(pdev); - pci_set_drvdata(pdev, NULL); - iounmap(uio->mem[0].internal_addr); - - kfree(poch_dev); -} - -static const struct pci_device_id poch_pci_ids[] /* __devinitconst */ = { - { PCI_DEVICE(PCI_VENDOR_ID_RRAPIDS, - PCI_DEVICE_ID_RRAPIDS_POCKET_CHANGE) }, - { 0, } -}; - -static struct pci_driver poch_pci_driver = { - .name = DRV_NAME, - .id_table = poch_pci_ids, - .probe = poch_pci_probe, - .remove = poch_pci_remove, -}; - -static int __init poch_init_module(void) -{ - int ret = 0; - - ret = alloc_chrdev_region(&poch_first_dev, 0, - MAX_POCH_DEVICES, DRV_NAME); - if (ret) { - printk(KERN_ERR PFX "error allocating device no."); - return ret; - } - - poch_cls = class_create(THIS_MODULE, "pocketchange"); - if (IS_ERR(poch_cls)) { - ret = PTR_ERR(poch_cls); - goto out_unreg_chrdev; - } - - ret = pci_register_driver(&poch_pci_driver); - if (ret) { - printk(KERN_ERR PFX "error register PCI device"); - goto out_class_destroy; - } - - return 0; - - out_class_destroy: - class_destroy(poch_cls); - - out_unreg_chrdev: - unregister_chrdev_region(poch_first_dev, MAX_POCH_DEVICES); - - return ret; -} - -static void __exit poch_exit_module(void) -{ - pci_unregister_driver(&poch_pci_driver); - class_destroy(poch_cls); - unregister_chrdev_region(poch_first_dev, MAX_POCH_DEVICES); -} - -module_init(poch_init_module); -module_exit(poch_exit_module); - -MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/poch/poch.h b/drivers/staging/poch/poch.h deleted file mode 100644 index 8b08385861fd..000000000000 --- a/drivers/staging/poch/poch.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * User-space DMA and UIO based Redrapids Pocket Change CardBus driver - * - * Copyright 2008 Vijay Kumar <vijaykumar@bravegnu.org> - * - * Part of userspace API. Should be moved to a header file in - * include/linux for final version. - * - */ - -#include <linux/types.h> - -struct poch_counters { - __u32 fifo_empty; - __u32 fifo_overflow; - __u32 pll_unlock; -}; - -struct poch_consume { - __u32 __user *offsets; - __u32 nfetch; - __u32 nflush; -}; - -#define POCH_IOC_NUM '9' - -#define POCH_IOC_TRANSFER_START _IO(POCH_IOC_NUM, 0) -#define POCH_IOC_TRANSFER_STOP _IO(POCH_IOC_NUM, 1) -#define POCH_IOC_GET_COUNTERS _IOR(POCH_IOC_NUM, 2, \ - struct poch_counters) -#define POCH_IOC_SYNC_GROUP_FOR_USER _IO(POCH_IOC_NUM, 3) -#define POCH_IOC_SYNC_GROUP_FOR_DEVICE _IO(POCH_IOC_NUM, 4) - -#define POCH_IOC_CONSUME _IOWR(POCH_IOC_NUM, 5, \ - struct poch_consume) diff --git a/drivers/staging/pohmelfs/config.c b/drivers/staging/pohmelfs/config.c index eed0e5545a55..6571a6ae05a5 100644 --- a/drivers/staging/pohmelfs/config.c +++ b/drivers/staging/pohmelfs/config.c @@ -509,13 +509,13 @@ static int pohmelfs_cn_crypto(struct cn_msg *msg) } switch (crypto->type) { - case POHMELFS_CRYPTO_HASH: + case POHMELFS_CRYPTO_HASH: err = pohmelfs_crypto_hash_init(g, crypto); break; - case POHMELFS_CRYPTO_CIPHER: + case POHMELFS_CRYPTO_CIPHER: err = pohmelfs_crypto_cipher_init(g, crypto); break; - default: + default: err = -ENOTSUPP; break; } @@ -536,24 +536,24 @@ static void pohmelfs_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *n return; switch (msg->flags) { - case POHMELFS_FLAGS_ADD: - case POHMELFS_FLAGS_DEL: - case POHMELFS_FLAGS_MODIFY: + case POHMELFS_FLAGS_ADD: + case POHMELFS_FLAGS_DEL: + case POHMELFS_FLAGS_MODIFY: err = pohmelfs_cn_ctl(msg, msg->flags); break; - case POHMELFS_FLAGS_FLUSH: + case POHMELFS_FLAGS_FLUSH: err = pohmelfs_cn_flush(msg); break; - case POHMELFS_FLAGS_SHOW: + case POHMELFS_FLAGS_SHOW: err = pohmelfs_cn_disp(msg); break; - case POHMELFS_FLAGS_DUMP: + case POHMELFS_FLAGS_DUMP: err = pohmelfs_cn_dump(msg); break; - case POHMELFS_FLAGS_CRYPTO: + case POHMELFS_FLAGS_CRYPTO: err = pohmelfs_cn_crypto(msg); break; - default: + default: err = -ENOSYS; break; } diff --git a/drivers/staging/pohmelfs/crypto.c b/drivers/staging/pohmelfs/crypto.c index 884183c0913a..2fdb3e01460d 100644 --- a/drivers/staging/pohmelfs/crypto.c +++ b/drivers/staging/pohmelfs/crypto.c @@ -170,17 +170,17 @@ static int pohmelfs_crypto_process(struct ablkcipher_request *req, err = crypto_ablkcipher_decrypt(req); switch (err) { - case -EINPROGRESS: - case -EBUSY: - err = wait_for_completion_interruptible_timeout(&complete.complete, + case -EINPROGRESS: + case -EBUSY: + err = wait_for_completion_interruptible_timeout(&complete.complete, timeout); - if (!err) - err = -ETIMEDOUT; - else if (err > 0) - err = complete.error; - break; - default: - break; + if (!err) + err = -ETIMEDOUT; + else if (err > 0) + err = complete.error; + break; + default: + break; } return err; @@ -196,7 +196,7 @@ int pohmelfs_crypto_process_input_data(struct pohmelfs_crypto_engine *e, u64 cmd return 0; dprintk("%s: eng: %p, iv: %llx, data: %p, page: %p/%lu, size: %u.\n", - __func__, e, cmd_iv, data, page, (page)?page->index:0, size); + __func__, e, cmd_iv, data, page, (page) ? page->index : 0, size); if (data) { sg_init_one(&sg, data, size); @@ -247,7 +247,7 @@ int pohmelfs_crypto_process_input_data(struct pohmelfs_crypto_engine *e, u64 cmd dprintk("%s: eng: %p, hash: %p, cipher: %p: iv : %llx, hash mismatch (recv/calc): ", __func__, e, e->hash, e->cipher, cmd_iv); - for (i=0; i<crypto_hash_digestsize(e->hash); ++i) { + for (i = 0; i < crypto_hash_digestsize(e->hash); ++i) { #if 0 dprintka("%02x ", recv[i]); if (recv[i] != calc[i]) { @@ -279,7 +279,7 @@ err_out_exit: } static int pohmelfs_trans_iter(struct netfs_trans *t, struct pohmelfs_crypto_engine *e, - int (* iterator) (struct pohmelfs_crypto_engine *e, + int (*iterator) (struct pohmelfs_crypto_engine *e, struct scatterlist *dst, struct scatterlist *src)) { @@ -319,7 +319,7 @@ static int pohmelfs_trans_iter(struct netfs_trans *t, struct pohmelfs_crypto_eng return 0; dpage_idx = 0; - for (i=0; i<t->page_num; ++i) { + for (i = 0; i < t->page_num; ++i) { struct page *page = t->pages[i]; struct page *dpage = e->pages[dpage_idx]; @@ -402,7 +402,7 @@ static int pohmelfs_hash(struct pohmelfs_crypto_thread *tc) { unsigned int i; dprintk("%s: ", __func__); - for (i=0; i<tc->psb->crypto_attached_size; ++i) + for (i = 0; i < tc->psb->crypto_attached_size; ++i) dprintka("%02x ", dst[i]); dprintka("\n"); } @@ -414,7 +414,7 @@ static void pohmelfs_crypto_pages_free(struct pohmelfs_crypto_engine *e) { unsigned int i; - for (i=0; i<e->page_num; ++i) + for (i = 0; i < e->page_num; ++i) __free_page(e->pages[i]); kfree(e->pages); } @@ -427,7 +427,7 @@ static int pohmelfs_crypto_pages_alloc(struct pohmelfs_crypto_engine *e, struct if (!e->pages) return -ENOMEM; - for (i=0; i<psb->trans_max_pages; ++i) { + for (i = 0; i < psb->trans_max_pages; ++i) { e->pages[i] = alloc_page(GFP_KERNEL); if (!e->pages[i]) break; @@ -612,7 +612,7 @@ static int pohmelfs_sys_crypto_init(struct pohmelfs_sb *psb) __func__, st, &st->eng, &st->eng.hash, &st->eng.cipher); } - for (i=0; i<psb->crypto_thread_num; ++i) { + for (i = 0; i < psb->crypto_thread_num; ++i) { err = -ENOMEM; t = kzalloc(sizeof(struct pohmelfs_crypto_thread), GFP_KERNEL); if (!t) @@ -780,7 +780,7 @@ int pohmelfs_crypto_init(struct pohmelfs_sb *psb) } static int pohmelfs_crypto_thread_get(struct pohmelfs_sb *psb, - int (* action)(struct pohmelfs_crypto_thread *t, void *data), void *data) + int (*action)(struct pohmelfs_crypto_thread *t, void *data), void *data) { struct pohmelfs_crypto_thread *t = NULL; int err; diff --git a/drivers/staging/pohmelfs/dir.c b/drivers/staging/pohmelfs/dir.c index 79819f07bfb9..059e9d2ddf6b 100644 --- a/drivers/staging/pohmelfs/dir.c +++ b/drivers/staging/pohmelfs/dir.c @@ -105,7 +105,7 @@ static struct pohmelfs_name *pohmelfs_insert_hash(struct pohmelfs_inode *pi, if (ret) { printk("%s: exist: parent: %llu, ino: %llu, hash: %x, len: %u, data: '%s', " - "new: ino: %llu, hash: %x, len: %u, data: '%s'.\n", + "new: ino: %llu, hash: %x, len: %u, data: '%s'.\n", __func__, pi->ino, ret->ino, ret->hash, ret->len, ret->data, new->ino, new->hash, new->len, new->data); @@ -234,7 +234,7 @@ struct pohmelfs_inode *pohmelfs_new_inode(struct pohmelfs_sb *psb, int err = -EEXIST; dprintk("%s: creating inode: parent: %llu, ino: %llu, str: %p.\n", - __func__, (parent)?parent->ino:0, info->ino, str); + __func__, (parent) ? parent->ino : 0, info->ino, str); err = -ENOMEM; new = iget_locked(psb->sb, info->ino); @@ -265,8 +265,8 @@ struct pohmelfs_inode *pohmelfs_new_inode(struct pohmelfs_sb *psb, s.len = 2; s.hash = jhash(s.name, s.len, 0); - err = pohmelfs_add_dir(psb, npi, (parent)?parent:npi, &s, - (parent)?parent->vfs_inode.i_mode:npi->vfs_inode.i_mode, 0); + err = pohmelfs_add_dir(psb, npi, (parent) ? parent : npi, &s, + (parent) ? parent->vfs_inode.i_mode : npi->vfs_inode.i_mode, 0); if (err) goto err_out_put; } @@ -277,7 +277,7 @@ struct pohmelfs_inode *pohmelfs_new_inode(struct pohmelfs_sb *psb, err = pohmelfs_add_dir(psb, parent, npi, str, info->mode, link); dprintk("%s: %s inserted name: '%s', new_offset: %llu, ino: %llu, parent: %llu.\n", - __func__, (err)?"unsuccessfully":"successfully", + __func__, (err) ? "unsuccessfully" : "successfully", str->name, parent->total_len, info->ino, parent->ino); if (err && err != -EEXIST) @@ -605,7 +605,7 @@ struct pohmelfs_inode *pohmelfs_create_entry_local(struct pohmelfs_sb *psb, if (!start) info.ino = pohmelfs_new_ino(psb); - info.nlink = S_ISDIR(mode)?2:1; + info.nlink = S_ISDIR(mode) ? 2 : 1; info.uid = current_fsuid(); info.gid = current_fsgid(); info.size = 0; @@ -849,7 +849,7 @@ static int pohmelfs_create_link(struct pohmelfs_inode *parent, struct qstr *obj, } dprintk("%s: parent: %llu, obj: '%s', target_inode: %llu, target_str: '%s', full: '%s'.\n", - __func__, parent->ino, obj->name, (target)?target->ino:0, (tstr)?tstr->name:NULL, + __func__, parent->ino, obj->name, (target) ? target->ino : 0, (tstr) ? tstr->name : NULL, (char *)data); cmd->cmd = NETFS_LINK; diff --git a/drivers/staging/pohmelfs/inode.c b/drivers/staging/pohmelfs/inode.c index 63275529ff55..9286e863b0e7 100644 --- a/drivers/staging/pohmelfs/inode.c +++ b/drivers/staging/pohmelfs/inode.c @@ -685,7 +685,7 @@ static int pohmelfs_readpages_trans_complete(struct page **__pages, unsigned int goto err_out_free; } - for (i=0; i<num; ++i) { + for (i = 0; i < num; ++i) { page = pages[i]; if (err) @@ -1431,35 +1431,35 @@ static int pohmelfs_parse_options(char *options, struct pohmelfs_sb *psb, int re continue; switch (token) { - case pohmelfs_opt_idx: - psb->idx = option; - break; - case pohmelfs_opt_trans_scan_timeout: - psb->trans_scan_timeout = msecs_to_jiffies(option); - break; - case pohmelfs_opt_drop_scan_timeout: - psb->drop_scan_timeout = msecs_to_jiffies(option); - break; - case pohmelfs_opt_wait_on_page_timeout: - psb->wait_on_page_timeout = msecs_to_jiffies(option); - break; - case pohmelfs_opt_mcache_timeout: - psb->mcache_timeout = msecs_to_jiffies(option); - break; - case pohmelfs_opt_trans_retries: - psb->trans_retries = option; - break; - case pohmelfs_opt_crypto_thread_num: - psb->crypto_thread_num = option; - break; - case pohmelfs_opt_trans_max_pages: - psb->trans_max_pages = option; - break; - case pohmelfs_opt_crypto_fail_unsupported: - psb->crypto_fail_unsupported = 1; - break; - default: - return -EINVAL; + case pohmelfs_opt_idx: + psb->idx = option; + break; + case pohmelfs_opt_trans_scan_timeout: + psb->trans_scan_timeout = msecs_to_jiffies(option); + break; + case pohmelfs_opt_drop_scan_timeout: + psb->drop_scan_timeout = msecs_to_jiffies(option); + break; + case pohmelfs_opt_wait_on_page_timeout: + psb->wait_on_page_timeout = msecs_to_jiffies(option); + break; + case pohmelfs_opt_mcache_timeout: + psb->mcache_timeout = msecs_to_jiffies(option); + break; + case pohmelfs_opt_trans_retries: + psb->trans_retries = option; + break; + case pohmelfs_opt_crypto_thread_num: + psb->crypto_thread_num = option; + break; + case pohmelfs_opt_trans_max_pages: + psb->trans_max_pages = option; + break; + case pohmelfs_opt_crypto_fail_unsupported: + psb->crypto_fail_unsupported = 1; + break; + default: + return -EINVAL; } } @@ -1777,7 +1777,7 @@ static int pohmelfs_show_stats(struct seq_file *m, struct vfsmount *mnt) seq_printf(m, "%pi6:%u", &sin->sin6_addr, ntohs(sin->sin6_port)); } else { unsigned int i; - for (i=0; i<ctl->addrlen; ++i) + for (i = 0; i < ctl->addrlen; ++i) seq_printf(m, "%02x.", ctl->addr.addr[i]); } @@ -2035,7 +2035,7 @@ err_out_exit: static void __exit exit_pohmel_fs(void) { - unregister_filesystem(&pohmel_fs_type); + unregister_filesystem(&pohmel_fs_type); pohmelfs_destroy_inodecache(); pohmelfs_mcache_exit(); pohmelfs_config_exit(); diff --git a/drivers/staging/pohmelfs/net.c b/drivers/staging/pohmelfs/net.c index 4a86f0b1ea88..9279897ff161 100644 --- a/drivers/staging/pohmelfs/net.c +++ b/drivers/staging/pohmelfs/net.c @@ -713,8 +713,8 @@ static int pohmelfs_crypto_cap_response(struct netfs_state *st) dprintk("%s: cipher '%s': %s, hash: '%s': %s.\n", __func__, - psb->cipher_string, (cap->cipher_strlen)?"SUPPORTED":"NOT SUPPORTED", - psb->hash_string, (cap->hash_strlen)?"SUPPORTED":"NOT SUPPORTED"); + psb->cipher_string, (cap->cipher_strlen) ? "SUPPORTED" : "NOT SUPPORTED", + psb->hash_string, (cap->hash_strlen) ? "SUPPORTED" : "NOT SUPPORTED"); if (!cap->hash_strlen) { if (psb->hash_strlen && psb->crypto_fail_unsupported) @@ -748,11 +748,11 @@ static int pohmelfs_capabilities_response(struct netfs_state *st) return err; switch (cmd->id) { - case POHMELFS_CRYPTO_CAPABILITIES: + case POHMELFS_CRYPTO_CAPABILITIES: return pohmelfs_crypto_cap_response(st); - case POHMELFS_ROOT_CAPABILITIES: + case POHMELFS_ROOT_CAPABILITIES: return pohmelfs_root_cap_response(st); - default: + default: break; } return -EINVAL; @@ -774,7 +774,7 @@ static int pohmelfs_getxattr_response(struct netfs_state *st) m = pohmelfs_mcache_search(psb, cmd->id); dprintk("%s: id: %llu, gen: %llu, err: %d.\n", - __func__, cmd->id, (m)?m->gen:0, error); + __func__, cmd->id, (m) ? m->gen : 0, error); if (!m) { printk("%s: failed to find getxattr cache entry: id: %llu.\n", __func__, cmd->id); @@ -824,7 +824,7 @@ int pohmelfs_data_lock_response(struct netfs_state *st) m = pohmelfs_mcache_search(psb, id); dprintk("%s: id: %llu, gen: %llu, err: %d.\n", - __func__, cmd->id, (m)?m->gen:0, err); + __func__, cmd->id, (m) ? m->gen : 0, err); if (!m) { pohmelfs_data_recv(st, st->data, cmd->size); @@ -915,7 +915,7 @@ static int pohmelfs_recv(void *data) unsigned char *hash = e->data; dprintk("%s: received hash: ", __func__); - for (i=0; i<cmd->csize; ++i) + for (i = 0; i < cmd->csize; ++i) printk("%02x ", hash[i]); printk("\n"); @@ -933,37 +933,37 @@ static int pohmelfs_recv(void *data) } switch (cmd->cmd) { - case NETFS_READ_PAGE: + case NETFS_READ_PAGE: err = pohmelfs_read_page_response(st); break; - case NETFS_READDIR: + case NETFS_READDIR: err = pohmelfs_readdir_response(st); break; - case NETFS_LOOKUP: + case NETFS_LOOKUP: err = pohmelfs_lookup_response(st); break; - case NETFS_CREATE: + case NETFS_CREATE: err = pohmelfs_create_response(st); break; - case NETFS_REMOVE: + case NETFS_REMOVE: err = pohmelfs_remove_response(st); break; - case NETFS_TRANS: + case NETFS_TRANS: err = pohmelfs_transaction_response(st); break; - case NETFS_PAGE_CACHE: + case NETFS_PAGE_CACHE: err = pohmelfs_page_cache_response(st); break; - case NETFS_CAPABILITIES: + case NETFS_CAPABILITIES: err = pohmelfs_capabilities_response(st); break; - case NETFS_LOCK: + case NETFS_LOCK: err = pohmelfs_data_lock_response(st); break; - case NETFS_XATTR_GET: + case NETFS_XATTR_GET: err = pohmelfs_getxattr_response(st); break; - default: + default: printk("%s: wrong cmd: %u, id: %llu, start: %llu, size: %u, ext: %u.\n", __func__, cmd->cmd, cmd->id, cmd->start, cmd->size, cmd->ext); netfs_state_reset(st); diff --git a/drivers/staging/pohmelfs/netfs.h b/drivers/staging/pohmelfs/netfs.h index 01cba006e07a..63391d2c25a4 100644 --- a/drivers/staging/pohmelfs/netfs.h +++ b/drivers/staging/pohmelfs/netfs.h @@ -305,7 +305,7 @@ struct pohmelfs_inode { }; struct netfs_trans; -typedef int (* netfs_trans_complete_t)(struct page **pages, unsigned int page_num, +typedef int (*netfs_trans_complete_t)(struct page **pages, unsigned int page_num, void *private, int err); struct netfs_state; @@ -489,7 +489,7 @@ void pohmelfs_crypto_thread_make_ready(struct pohmelfs_crypto_thread *th); struct netfs_state { struct mutex __state_lock; /* Can not allow to use the same socket simultaneously */ struct mutex __state_send_lock; - struct netfs_cmd cmd; /* Cached command */ + struct netfs_cmd cmd; /* Cached command */ struct netfs_inode_info info; /* Cached inode info */ void *data; /* Cached some data */ @@ -500,9 +500,9 @@ struct netfs_state { struct task_struct *thread; /* Async receiving thread */ /* Waiting/polling machinery */ - wait_queue_t wait; - wait_queue_head_t *whead; - wait_queue_head_t thread_wait; + wait_queue_t wait; + wait_queue_head_t *whead; + wait_queue_head_t thread_wait; struct mutex trans_lock; struct rb_root trans_root; @@ -620,8 +620,8 @@ struct pohmelfs_sb { /* * Timed checks: stale transactions, inodes to be freed and so on. */ - struct delayed_work dwork; - struct delayed_work drop_dwork; + struct delayed_work dwork; + struct delayed_work drop_dwork; struct super_block *sb; @@ -911,7 +911,8 @@ static inline void pohmelfs_mcache_put(struct pohmelfs_sb *psb, pohmelfs_mcache_free(psb, m); } -//#define POHMELFS_TRUNCATE_ON_INODE_FLUSH +/*#define POHMELFS_TRUNCATE_ON_INODE_FLUSH + */ #endif /* __KERNEL__*/ diff --git a/drivers/staging/quatech_usb2/quatech_usb2.c b/drivers/staging/quatech_usb2/quatech_usb2.c index 1561f74a413b..ecd73135b319 100644 --- a/drivers/staging/quatech_usb2/quatech_usb2.c +++ b/drivers/staging/quatech_usb2/quatech_usb2.c @@ -57,7 +57,7 @@ static int debug; #define QT2_HW_FLOW_CONTROL_MASK 0xc5 #define QT2_SW_FLOW_CONTROL_MASK 0xc6 #define QT2_SW_FLOW_CONTROL_DISABLE 0xc7 -#define QT2_BREAK_CONTROL 0xc8 +#define QT2_BREAK_CONTROL 0xc8 #define QT2_STOP_RECEIVE 0xe0 #define QT2_FLUSH_DEVICE 0xc4 #define QT2_GET_SET_QMCR 0xe1 @@ -207,7 +207,7 @@ struct quatech2_dev { bool ReadBulkStopped; char open_ports; struct usb_serial_port *current_port; - int buffer_size; + int buffer_size; }; /* structure which holds line and modem status flags */ @@ -1648,10 +1648,10 @@ __func__); } /*endif*/ if (tty_st && urb->actual_length) { tty_buffer_request_room(tty_st, 1); - tty_insert_flip_string(tty_st, - &((unsigned char *)(urb->transfer_buffer) - )[i], - 1); + tty_insert_flip_string(tty_st, &( + (unsigned char *) + (urb->transfer_buffer) + )[i], 1); } } /*endfor*/ tty_flip_buffer_push(tty_st); diff --git a/drivers/staging/rt2860/chip/mac_pci.h b/drivers/staging/rt2860/chip/mac_pci.h index bc704acaa3d7..9f25ef047f59 100644 --- a/drivers/staging/rt2860/chip/mac_pci.h +++ b/drivers/staging/rt2860/chip/mac_pci.h @@ -147,13 +147,12 @@ typedef union _TX_ATTENUATION_CTRL_STRUC { /* ----------------- Frimware Related MACRO ----------------- */ #define RTMP_WRITE_FIRMWARE(_pAd, _pFwImage, _FwLen) \ - do{ \ + do { \ unsigned long _i, _firm; \ RTMP_IO_WRITE32(_pAd, PBF_SYS_CTRL, 0x10000); \ \ - for(_i=0; _i<_FwLen; _i+=4) \ - { \ - _firm = _pFwImage[_i] + \ + for (_i = 0; _i < _FwLen; _i += 4) { \ + _firm = _pFwImage[_i] + \ (_pFwImage[_i+3] << 24) + \ (_pFwImage[_i+2] << 16) + \ (_pFwImage[_i+1] << 8); \ @@ -165,19 +164,19 @@ typedef union _TX_ATTENUATION_CTRL_STRUC { /* initialize BBP R/W access agent */ \ RTMP_IO_WRITE32(_pAd, H2M_BBP_AGENT, 0); \ RTMP_IO_WRITE32(_pAd, H2M_MAILBOX_CSR, 0); \ - }while(0) + } while (0) /* ----------------- TX Related MACRO ----------------- */ -#define RTMP_START_DEQUEUE(pAd, QueIdx, irqFlags) do{}while(0) -#define RTMP_STOP_DEQUEUE(pAd, QueIdx, irqFlags) do{}while(0) +#define RTMP_START_DEQUEUE(pAd, QueIdx, irqFlags) do {} while (0) +#define RTMP_STOP_DEQUEUE(pAd, QueIdx, irqFlags) do {} while (0) #define RTMP_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, freeNum, pPacket) \ ((freeNum) >= (unsigned long)(pTxBlk->TotalFragNum + RTMP_GET_PACKET_FRAGMENTS(pPacket) + 3)) /* rough estimate we will use 3 more descriptor. */ -#define RTMP_RELEASE_DESC_RESOURCE(pAd, QueIdx) \ - do{}while(0) +#define RTMP_RELEASE_DESC_RESOURCE(pAd, QueIdx) do {} while (0) #define NEED_QUEUE_BACK_FOR_AGG(pAd, QueIdx, freeNum, _TxFrameType) \ - (((freeNum != (TX_RING_SIZE-1)) && (pAd->TxSwQueue[QueIdx].Number == 0)) || (freeNum<3)) + (((freeNum != (TX_RING_SIZE-1)) && \ + (pAd->TxSwQueue[QueIdx].Number == 0)) || (freeNum < 3)) #define HAL_KickOutMgmtTx(_pAd, _QueIdx, _pPacket, _pSrcBufVA, _SrcBufLen) \ RtmpPCIMgmtKickOut(_pAd, _QueIdx, _pPacket, _pSrcBufVA, _SrcBufLen) @@ -185,19 +184,19 @@ typedef union _TX_ATTENUATION_CTRL_STRUC { #define HAL_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) \ /* RtmpPCI_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) */ -#define HAL_WriteTxResource(pAd, pTxBlk,bIsLast, pFreeNumber) \ +#define HAL_WriteTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) \ RtmpPCI_WriteSingleTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) #define HAL_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber) \ RtmpPCI_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber) -#define HAL_WriteMultiTxResource(pAd, pTxBlk,frameNum, pFreeNumber) \ +#define HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, pFreeNumber) \ RtmpPCI_WriteMultiTxResource(pAd, pTxBlk, frameNum, pFreeNumber) #define HAL_FinalWriteTxResource(_pAd, _pTxBlk, _TotalMPDUSize, _FirstTxIdx) \ RtmpPCI_FinalWriteTxResource(_pAd, _pTxBlk, _TotalMPDUSize, _FirstTxIdx) -#define HAL_LastTxIdx(_pAd, _QueIdx,_LastTxIdx) \ +#define HAL_LastTxIdx(_pAd, _QueIdx, _LastTxIdx) \ /*RtmpPCIDataLastTxIdx(_pAd, _QueIdx,_LastTxIdx) */ #define HAL_KickOutTx(_pAd, _pTxBlk, _QueIdx) \ @@ -259,24 +258,24 @@ typedef union _TX_ATTENUATION_CTRL_STRUC { /* Insert the BA bitmap to ASIC for the Wcid entry */ #define RTMP_ADD_BA_SESSION_TO_ASIC(_pAd, _Aid, _TID) \ - do{ \ + do { \ u32 _Value = 0, _Offset; \ _Offset = MAC_WCID_BASE + (_Aid) * HW_WCID_ENTRY_SIZE + 4; \ RTMP_IO_READ32((_pAd), _Offset, &_Value);\ _Value |= (0x10000<<(_TID)); \ RTMP_IO_WRITE32((_pAd), _Offset, _Value);\ - }while(0) + } while (0) /* Remove the BA bitmap from ASIC for the Wcid entry */ /* bitmap field starts at 0x10000 in ASIC WCID table */ #define RTMP_DEL_BA_SESSION_FROM_ASIC(_pAd, _Wcid, _TID) \ - do{ \ + do { \ u32 _Value = 0, _Offset; \ _Offset = MAC_WCID_BASE + (_Wcid) * HW_WCID_ENTRY_SIZE + 4; \ RTMP_IO_READ32((_pAd), _Offset, &_Value); \ _Value &= (~(0x10000 << (_TID))); \ RTMP_IO_WRITE32((_pAd), _Offset, _Value); \ - }while(0) + } while (0) /* ----------------- Interface Related MACRO ----------------- */ @@ -285,16 +284,16 @@ typedef union _TX_ATTENUATION_CTRL_STRUC { /* Since it use ADAPTER structure, it have to be put after structure definition. */ /* */ #define RTMP_ASIC_INTERRUPT_DISABLE(_pAd) \ - do{ \ + do { \ RTMP_IO_WRITE32((_pAd), INT_MASK_CSR, 0x0); /* 0: disable */ \ RTMP_CLEAR_FLAG((_pAd), fRTMP_ADAPTER_INTERRUPT_ACTIVE); \ - }while(0) + } while (0) #define RTMP_ASIC_INTERRUPT_ENABLE(_pAd)\ - do{ \ + do { \ RTMP_IO_WRITE32((_pAd), INT_MASK_CSR, (_pAd)->int_enable_reg /*DELAYINTMASK*/); /* 1:enable */ \ RTMP_SET_FLAG((_pAd), fRTMP_ADAPTER_INTERRUPT_ACTIVE); \ - }while(0) + } while (0) #define RTMP_IRQ_INIT(pAd) \ { pAd->int_enable_reg = ((DELAYINTMASK) | \ diff --git a/drivers/staging/rt2860/chip/mac_usb.h b/drivers/staging/rt2860/chip/mac_usb.h index 0b67c0b1de03..ed0c0b43b05e 100644 --- a/drivers/staging/rt2860/chip/mac_usb.h +++ b/drivers/staging/rt2860/chip/mac_usb.h @@ -25,7 +25,7 @@ ************************************************************************* Module Name: - mac_usb.h + mac_usb.h Abstract: @@ -46,7 +46,7 @@ #define USB_CYC_CFG 0x02a4 #define BEACON_RING_SIZE 2 -#define MGMTPIPEIDX 0 /* EP6 is highest priority */ +#define MGMTPIPEIDX 0 /* EP6 is highest priority */ #define RTMP_PKT_TAIL_PADDING 11 /* 3(max 4 byte padding) + 4 (last packet padding) + 4 (MaxBulkOutsize align padding) */ @@ -220,53 +220,51 @@ struct rt_rx_context { ******************************************************************************/ #define RTMP_START_DEQUEUE(pAd, QueIdx, irqFlags) \ - do{ \ + do { \ RTMP_IRQ_LOCK(&pAd->DeQueueLock[QueIdx], irqFlags); \ - if (pAd->DeQueueRunning[QueIdx]) \ - { \ - RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags);\ + if (pAd->DeQueueRunning[QueIdx]) { \ + RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags); \ DBGPRINT(RT_DEBUG_OFF, ("DeQueueRunning[%d]= TRUE!\n", QueIdx)); \ continue; \ - } \ - else \ - { \ + } else { \ pAd->DeQueueRunning[QueIdx] = TRUE; \ RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags);\ } \ - }while(0) + } while (0) #define RTMP_STOP_DEQUEUE(pAd, QueIdx, irqFlags) \ - do{ \ + do { \ RTMP_IRQ_LOCK(&pAd->DeQueueLock[QueIdx], irqFlags); \ pAd->DeQueueRunning[QueIdx] = FALSE; \ RTMP_IRQ_UNLOCK(&pAd->DeQueueLock[QueIdx], irqFlags); \ - }while(0) + } while (0) #define RTMP_HAS_ENOUGH_FREE_DESC(pAd, pTxBlk, freeNum, pPacket) \ (RTUSBFreeDescriptorRequest(pAd, pTxBlk->QueIdx, (pTxBlk->TotalFrameLen + GET_OS_PKT_LEN(pPacket))) == NDIS_STATUS_SUCCESS) #define RTMP_RELEASE_DESC_RESOURCE(pAd, QueIdx) \ - do{}while(0) + do {} while (0) #define NEED_QUEUE_BACK_FOR_AGG(_pAd, _QueIdx, _freeNum, _TxFrameType) \ - ((_TxFrameType == TX_RALINK_FRAME) && (RTUSBNeedQueueBackForAgg(_pAd, _QueIdx))) + ((_TxFrameType == TX_RALINK_FRAME) && \ + (RTUSBNeedQueueBackForAgg(_pAd, _QueIdx))) #define HAL_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) \ - RtmpUSB_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) + RtmpUSB_WriteSubTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) -#define HAL_WriteTxResource(pAd, pTxBlk,bIsLast, pFreeNumber) \ - RtmpUSB_WriteSingleTxResource(pAd, pTxBlk,bIsLast, pFreeNumber) +#define HAL_WriteTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) \ + RtmpUSB_WriteSingleTxResource(pAd, pTxBlk, bIsLast, pFreeNumber) #define HAL_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber) \ - RtmpUSB_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber) + RtmpUSB_WriteFragTxResource(pAd, pTxBlk, fragNum, pFreeNumber) -#define HAL_WriteMultiTxResource(pAd, pTxBlk,frameNum, pFreeNumber) \ - RtmpUSB_WriteMultiTxResource(pAd, pTxBlk,frameNum, pFreeNumber) +#define HAL_WriteMultiTxResource(pAd, pTxBlk, frameNum, pFreeNumber) \ + RtmpUSB_WriteMultiTxResource(pAd, pTxBlk, frameNum, pFreeNumber) #define HAL_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, TxIdx) \ - RtmpUSB_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, TxIdx) + RtmpUSB_FinalWriteTxResource(pAd, pTxBlk, totalMPDUSize, TxIdx) -#define HAL_LastTxIdx(pAd, QueIdx,TxIdx) \ +#define HAL_LastTxIdx(pAd, QueIdx, TxIdx) \ /*RtmpUSBDataLastTxIdx(pAd, QueIdx,TxIdx) */ #define HAL_KickOutTx(pAd, pTxBlk, QueIdx) \ @@ -286,8 +284,8 @@ struct rt_rx_context { /* * Device Hardware Interface Related MACRO */ -#define RTMP_IRQ_INIT(pAd) do{}while(0) -#define RTMP_IRQ_ENABLE(pAd) do{}while(0) +#define RTMP_IRQ_INIT(pAd) do {} while (0) +#define RTMP_IRQ_ENABLE(pAd) do {} while (0) /* * MLME Related MACRO @@ -305,8 +303,8 @@ struct rt_rx_context { RTUSBMlmeUp(pAd); } #define RTMP_MLME_RESET_STATE_MACHINE(pAd) \ - MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_RESET_CONF, 0, NULL); \ - RTUSBMlmeUp(pAd); + { MlmeEnqueue(pAd, MLME_CNTL_STATE_MACHINE, MT2_RESET_CONF, 0, NULL); \ + RTUSBMlmeUp(pAd); } #define RTMP_HANDLE_COUNTER_MEASURE(_pAd, _pEntry) \ { RTUSBEnqueueInternalCmd(_pAd, CMDTHREAD_802_11_COUNTER_MEASURE, _pEntry, sizeof(struct rt_mac_table_entry)); \ @@ -330,12 +328,11 @@ struct rt_rx_context { {\ if ((_pAd)->StaCfg.WindowsPowerMode == Ndis802_11PowerModeFast_PSP) \ MlmeSetPsmBit(_pAd, _val);\ - else \ - { \ + else { \ u16 _psm_val; \ _psm_val = _val; \ RTUSBEnqueueInternalCmd(_pAd, CMDTHREAD_SET_PSM_BIT, &(_psm_val), sizeof(u16)); \ - }\ + } \ } #define RTMP_MLME_RADIO_ON(pAd) \ diff --git a/drivers/staging/rt2860/chip/rtmp_mac.h b/drivers/staging/rt2860/chip/rtmp_mac.h index f6a72581d3bd..e8f7172ce42a 100644 --- a/drivers/staging/rt2860/chip/rtmp_mac.h +++ b/drivers/staging/rt2860/chip/rtmp_mac.h @@ -154,7 +154,7 @@ typedef union _INT_SOURCE_CSR_STRUC { u32 GPTimer:1; u32 RxCoherent:1; /*bit16 */ u32 TxCoherent:1; - u32 : 14; + u32: 14; } field; u32 word; } INT_SOURCE_CSR_STRUC, *PINT_SOURCE_CSR_STRUC; @@ -175,7 +175,7 @@ typedef union _INT_MASK_CSR_STRUC { u32 HccaDmaDone:1; u32 MgmtDmaDone:1; u32 MCUCommandINT:1; - u32 : 20; + u32: 20; u32 RxCoherent:1; u32 TxCoherent:1; } field; @@ -209,7 +209,7 @@ typedef union _WPDMA_RST_IDX_STRUC { u32 RST_DTX_IDX5:1; u32 rsv:10; u32 RST_DRX_IDX0:1; - u32 : 15; + u32: 15; } field; u32 word; } WPDMA_RST_IDX_STRUC, *PWPDMA_RST_IDX_STRUC; @@ -448,7 +448,7 @@ typedef union _BBP_CSR_CFG_STRUC { u32 Busy:1; /* 1: ASIC is busy execute BBP programming. */ u32 BBP_PAR_DUR:1; /* 0: 4 MAC clock cycles 1: 8 MAC clock cycles */ u32 BBP_RW_MODE:1; /* 0: use serial mode 1:parallel */ - u32 : 12; + u32: 12; } field; u32 word; } BBP_CSR_CFG_STRUC, *PBBP_CSR_CFG_STRUC; @@ -494,7 +494,7 @@ typedef union _LED_CFG_STRUC { u32 GLedMode:2; /* green Led Mode */ u32 YLedMode:2; /* yellow Led Mode */ u32 LedPolar:1; /* Led Polarity. 0: active low1: active high */ - u32 : 1; + u32: 1; } field; u32 word; } LED_CFG_STRUC, *PLED_CFG_STRUC; @@ -533,7 +533,7 @@ typedef union _BCN_TIME_CFG_STRUC { u32 TsfSyncMode:2; /* Enable TSF sync, 00: disable, 01: infra mode, 10: ad-hoc mode */ u32 bTBTTEnable:1; u32 bBeaconGen:1; /* Enable beacon generator */ - u32 : 3; + u32: 3; u32 TxTimestampCompensate:8; } field; u32 word; @@ -560,7 +560,7 @@ typedef union _AUTO_WAKEUP_STRUC { u32 AutoLeadTime:8; u32 NumofSleepingTbtt:7; /* ForceWake has high privilege than PutToSleep when both set */ u32 EnableAutoWakeup:1; /* 0:sleep, 1:awake */ - u32 : 16; + u32: 16; } field; u32 word; } AUTO_WAKEUP_STRUC, *PAUTO_WAKEUP_STRUC; @@ -578,7 +578,7 @@ typedef union _EDCA_AC_CFG_STRUC { u32 Aifsn:4; /* # of slot time */ u32 Cwmin:4; /* */ u32 Cwmax:4; /*unit power of 2 */ - u32 : 12; /* */ + u32: 12; /* */ } field; u32 word; } EDCA_AC_CFG_STRUC, *PEDCA_AC_CFG_STRUC; @@ -751,7 +751,7 @@ typedef union _AUTO_RSP_CFG_STRUC { u32 rsv:1; /* Power bit value in conrtrol frame */ u32 DualCTSEn:1; /* Power bit value in conrtrol frame */ u32 AckCtsPsmBit:1; /* Power bit value in conrtrol frame */ - u32 : 24; + u32: 24; } field; u32 word; } AUTO_RSP_CFG_STRUC, *PAUTO_RSP_CFG_STRUC; @@ -981,21 +981,21 @@ typedef union _MPDU_DEN_CNT_STRUC { typedef union _SHAREDKEY_MODE_STRUC { struct { u32 Bss0Key0CipherAlg:3; - u32 : 1; + u32: 1; u32 Bss0Key1CipherAlg:3; - u32 : 1; + u32: 1; u32 Bss0Key2CipherAlg:3; - u32 : 1; + u32: 1; u32 Bss0Key3CipherAlg:3; - u32 : 1; + u32: 1; u32 Bss1Key0CipherAlg:3; - u32 : 1; + u32: 1; u32 Bss1Key1CipherAlg:3; - u32 : 1; + u32: 1; u32 Bss1Key2CipherAlg:3; - u32 : 1; + u32: 1; u32 Bss1Key3CipherAlg:3; - u32 : 1; + u32: 1; } field; u32 word; } SHAREDKEY_MODE_STRUC, *PSHAREDKEY_MODE_STRUC; @@ -1103,7 +1103,7 @@ typedef union _RX_FILTR_CFG_STRUC { u32 DropBAR:1; /* */ u32 DropRsvCntlType:1; - u32 : 15; + u32: 15; } field; u32 word; } RX_FILTR_CFG_STRUC, *PRX_FILTR_CFG_STRUC; @@ -1128,21 +1128,21 @@ typedef union _PHY_CSR4_STRUC { typedef union _SEC_CSR5_STRUC { struct { u32 Bss2Key0CipherAlg:3; - u32 : 1; + u32: 1; u32 Bss2Key1CipherAlg:3; - u32 : 1; + u32: 1; u32 Bss2Key2CipherAlg:3; - u32 : 1; + u32: 1; u32 Bss2Key3CipherAlg:3; - u32 : 1; + u32: 1; u32 Bss3Key0CipherAlg:3; - u32 : 1; + u32: 1; u32 Bss3Key1CipherAlg:3; - u32 : 1; + u32: 1; u32 Bss3Key2CipherAlg:3; - u32 : 1; + u32: 1; u32 Bss3Key3CipherAlg:3; - u32 : 1; + u32: 1; } field; u32 word; } SEC_CSR5_STRUC, *PSEC_CSR5_STRUC; diff --git a/drivers/staging/rt2860/chip/rtmp_phy.h b/drivers/staging/rt2860/chip/rtmp_phy.h index 8b8b0f47f03b..9f924ea6ca35 100644 --- a/drivers/staging/rt2860/chip/rtmp_phy.h +++ b/drivers/staging/rt2860/chip/rtmp_phy.h @@ -177,8 +177,7 @@ #ifdef RTMP_MAC_PCI #define RTMP_RF_IO_WRITE32(_A, _V) \ { \ - if ((_A)->bPCIclkOff == FALSE) \ - { \ + if ((_A)->bPCIclkOff == FALSE) { \ PHY_CSR4_STRUC _value; \ unsigned long _busyCnt = 0; \ \ @@ -187,9 +186,8 @@ if (_value.field.Busy == IDLE) \ break; \ _busyCnt++; \ - }while (_busyCnt < MAX_BUSY_COUNT); \ - if(_busyCnt < MAX_BUSY_COUNT) \ - { \ + } while (_busyCnt < MAX_BUSY_COUNT); \ + if (_busyCnt < MAX_BUSY_COUNT) { \ RTMP_IO_WRITE32((_A), RF_CSR_CFG0, (_V)); \ } \ } \ @@ -218,52 +216,46 @@ _bViaMCU: if we need access the bbp via the MCU. */ #define RTMP_BBP_IO_READ8(_pAd, _bbpID, _pV, _bViaMCU) \ - do{ \ - BBP_CSR_CFG_STRUC BbpCsr; \ - int _busyCnt, _secCnt, _regID; \ - \ - _regID = ((_bViaMCU) == TRUE ? H2M_BBP_AGENT : BBP_CSR_CFG); \ - for (_busyCnt=0; _busyCnt<MAX_BUSY_COUNT; _busyCnt++) \ - { \ - RTMP_IO_READ32(_pAd, _regID, &BbpCsr.word); \ + do { \ + BBP_CSR_CFG_STRUC BbpCsr; \ + int _busyCnt, _secCnt, _regID; \ + \ + _regID = ((_bViaMCU) == TRUE ? H2M_BBP_AGENT : BBP_CSR_CFG); \ + for (_busyCnt = 0; _busyCnt < MAX_BUSY_COUNT; _busyCnt++) { \ + RTMP_IO_READ32(_pAd, _regID, &BbpCsr.word); \ if (BbpCsr.field.Busy == BUSY) \ - continue; \ + continue; \ BbpCsr.word = 0; \ BbpCsr.field.fRead = 1; \ - BbpCsr.field.BBP_RW_MODE = 1; \ + BbpCsr.field.BBP_RW_MODE = 1; \ BbpCsr.field.Busy = 1; \ - BbpCsr.field.RegNum = _bbpID; \ + BbpCsr.field.RegNum = _bbpID; \ RTMP_IO_WRITE32(_pAd, _regID, BbpCsr.word); \ - if ((_bViaMCU) == TRUE) \ - { \ - AsicSendCommandToMcu(_pAd, 0x80, 0xff, 0x0, 0x0); \ - RTMPusecDelay(1000); \ - } \ - for (_secCnt=0; _secCnt<MAX_BUSY_COUNT; _secCnt++) \ - { \ + if ((_bViaMCU) == TRUE) { \ + AsicSendCommandToMcu(_pAd, 0x80, 0xff, 0x0, 0x0); \ + RTMPusecDelay(1000); \ + } \ + for (_secCnt = 0; _secCnt < MAX_BUSY_COUNT; _secCnt++) { \ RTMP_IO_READ32(_pAd, _regID, &BbpCsr.word); \ - if (BbpCsr.field.Busy == IDLE) \ - break; \ - } \ - if ((BbpCsr.field.Busy == IDLE) && \ - (BbpCsr.field.RegNum == _bbpID)) \ - { \ - *(_pV) = (u8)BbpCsr.field.Value; \ - break; \ - } \ - } \ - if (BbpCsr.field.Busy == BUSY) \ - { \ - DBGPRINT_ERR(("BBP(viaMCU=%d) read R%d fail\n", (_bViaMCU), _bbpID)); \ + if (BbpCsr.field.Busy == IDLE) \ + break; \ + } \ + if ((BbpCsr.field.Busy == IDLE) && \ + (BbpCsr.field.RegNum == _bbpID)) { \ + *(_pV) = (u8)BbpCsr.field.Value; \ + break; \ + } \ + } \ + if (BbpCsr.field.Busy == BUSY) { \ + DBGPRINT_ERR(("BBP(viaMCU=%d) read R%d fail\n", (_bViaMCU), _bbpID)); \ *(_pV) = (_pAd)->BbpWriteLatch[_bbpID]; \ - if ((_bViaMCU) == TRUE) \ - { \ + if ((_bViaMCU) == TRUE) { \ RTMP_IO_READ32(_pAd, _regID, &BbpCsr.word); \ BbpCsr.field.Busy = 0; \ RTMP_IO_WRITE32(_pAd, _regID, BbpCsr.word); \ } \ } \ - }while(0) + } while (0) /* This marco used for the BBP read operation which didn't need via MCU. @@ -283,42 +275,35 @@ int i, k; \ BOOLEAN brc; \ BbpCsr.field.Busy = IDLE; \ - if ((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3) \ + if ((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) \ + && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3) \ && ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE) \ && ((_A)->bPCIclkOff == FALSE) \ - && ((_A)->brt30xxBanMcuCmd == FALSE)) \ - { \ - for (i=0; i<MAX_BUSY_COUNT; i++) \ - { \ - RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \ - if (BbpCsr.field.Busy == BUSY) \ - { \ - continue; \ - } \ - BbpCsr.word = 0; \ - BbpCsr.field.fRead = 1; \ - BbpCsr.field.BBP_RW_MODE = 1; \ - BbpCsr.field.Busy = 1; \ - BbpCsr.field.RegNum = _I; \ - RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \ - brc = AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0); \ - if (brc == TRUE) \ - { \ - for (k=0; k<MAX_BUSY_COUNT; k++) \ - { \ - RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \ - if (BbpCsr.field.Busy == IDLE) \ - break; \ - } \ - if ((BbpCsr.field.Busy == IDLE) && \ - (BbpCsr.field.RegNum == _I)) \ - { \ - *(_pV) = (u8)BbpCsr.field.Value; \ - break; \ - } \ - } \ - else \ - { \ + && ((_A)->brt30xxBanMcuCmd == FALSE)) { \ + for (i = 0; i < MAX_BUSY_COUNT; i++) { \ + RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \ + if (BbpCsr.field.Busy == BUSY) { \ + continue; \ + } \ + BbpCsr.word = 0; \ + BbpCsr.field.fRead = 1; \ + BbpCsr.field.BBP_RW_MODE = 1; \ + BbpCsr.field.Busy = 1; \ + BbpCsr.field.RegNum = _I; \ + RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \ + brc = AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0); \ + if (brc == TRUE) { \ + for (k = 0; k < MAX_BUSY_COUNT; k++) { \ + RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \ + if (BbpCsr.field.Busy == IDLE) \ + break; \ + } \ + if ((BbpCsr.field.Busy == IDLE) && \ + (BbpCsr.field.RegNum == _I)) { \ + *(_pV) = (u8)BbpCsr.field.Value; \ + break; \ + } \ + } else { \ BbpCsr.field.Busy = 0; \ RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \ } \ @@ -326,46 +311,38 @@ } \ else if (!((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3) \ && ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE)) \ - && ((_A)->bPCIclkOff == FALSE)) \ - { \ - for (i=0; i<MAX_BUSY_COUNT; i++) \ - { \ - RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \ - if (BbpCsr.field.Busy == BUSY) \ - { \ - continue; \ - } \ - BbpCsr.word = 0; \ - BbpCsr.field.fRead = 1; \ - BbpCsr.field.BBP_RW_MODE = 1; \ - BbpCsr.field.Busy = 1; \ - BbpCsr.field.RegNum = _I; \ - RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \ - AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0); \ - for (k=0; k<MAX_BUSY_COUNT; k++) \ - { \ - RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \ - if (BbpCsr.field.Busy == IDLE) \ - break; \ - } \ - if ((BbpCsr.field.Busy == IDLE) && \ - (BbpCsr.field.RegNum == _I)) \ - { \ - *(_pV) = (u8)BbpCsr.field.Value; \ - break; \ - } \ - } \ - } \ - else \ - { \ + && ((_A)->bPCIclkOff == FALSE)) { \ + for (i = 0; i < MAX_BUSY_COUNT; i++) { \ + RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \ + if (BbpCsr.field.Busy == BUSY) { \ + continue; \ + } \ + BbpCsr.word = 0; \ + BbpCsr.field.fRead = 1; \ + BbpCsr.field.BBP_RW_MODE = 1; \ + BbpCsr.field.Busy = 1; \ + BbpCsr.field.RegNum = _I; \ + RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \ + AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0); \ + for (k = 0; k < MAX_BUSY_COUNT; k++) { \ + RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \ + if (BbpCsr.field.Busy == IDLE) \ + break; \ + } \ + if ((BbpCsr.field.Busy == IDLE) && \ + (BbpCsr.field.RegNum == _I)) { \ + *(_pV) = (u8)BbpCsr.field.Value; \ + break; \ + } \ + } \ + } else { \ DBGPRINT_ERR((" , brt30xxBanMcuCmd = %d, Read BBP %d \n", (_A)->brt30xxBanMcuCmd, (_I))); \ - *(_pV) = (_A)->BbpWriteLatch[_I]; \ - } \ - if ((BbpCsr.field.Busy == BUSY) || ((_A)->bPCIclkOff == TRUE)) \ - { \ - DBGPRINT_ERR(("BBP read R%d=0x%x fail\n", _I, BbpCsr.word)); \ - *(_pV) = (_A)->BbpWriteLatch[_I]; \ - } \ + *(_pV) = (_A)->BbpWriteLatch[_I]; \ + } \ + if ((BbpCsr.field.Busy == BUSY) || ((_A)->bPCIclkOff == TRUE)) { \ + DBGPRINT_ERR(("BBP read R%d=0x%x fail\n", _I, BbpCsr.word)); \ + *(_pV) = (_A)->BbpWriteLatch[_I]; \ + } \ } /* @@ -376,43 +353,39 @@ _bViaMCU: if we need access the bbp via the MCU. */ #define RTMP_BBP_IO_WRITE8(_pAd, _bbpID, _pV, _bViaMCU) \ - do{ \ + do { \ BBP_CSR_CFG_STRUC BbpCsr; \ - int _busyCnt, _regID; \ - \ + int _busyCnt, _regID; \ + \ _regID = ((_bViaMCU) == TRUE ? H2M_BBP_AGENT : BBP_CSR_CFG); \ - for (_busyCnt=0; _busyCnt<MAX_BUSY_COUNT; _busyCnt++) \ - { \ + for (_busyCnt = 0; _busyCnt < MAX_BUSY_COUNT; _busyCnt++) { \ RTMP_IO_READ32((_pAd), BBP_CSR_CFG, &BbpCsr.word); \ - if (BbpCsr.field.Busy == BUSY) \ - continue; \ - BbpCsr.word = 0; \ - BbpCsr.field.fRead = 0; \ - BbpCsr.field.BBP_RW_MODE = 1; \ - BbpCsr.field.Busy = 1; \ - BbpCsr.field.Value = _pV; \ - BbpCsr.field.RegNum = _bbpID; \ - RTMP_IO_WRITE32((_pAd), BBP_CSR_CFG, BbpCsr.word); \ - if ((_bViaMCU) == TRUE) \ - { \ - AsicSendCommandToMcu(_pAd, 0x80, 0xff, 0x0, 0x0); \ - if ((_pAd)->OpMode == OPMODE_AP) \ - RTMPusecDelay(1000); \ - } \ - (_pAd)->BbpWriteLatch[_bbpID] = _pV; \ - break; \ - } \ - if (_busyCnt == MAX_BUSY_COUNT) \ - { \ - DBGPRINT_ERR(("BBP write R%d fail\n", _bbpID)); \ - if((_bViaMCU) == TRUE) \ - { \ + if (BbpCsr.field.Busy == BUSY) \ + continue; \ + BbpCsr.word = 0; \ + BbpCsr.field.fRead = 0; \ + BbpCsr.field.BBP_RW_MODE = 1; \ + BbpCsr.field.Busy = 1; \ + BbpCsr.field.Value = _pV; \ + BbpCsr.field.RegNum = _bbpID; \ + RTMP_IO_WRITE32((_pAd), BBP_CSR_CFG, BbpCsr.word); \ + if ((_bViaMCU) == TRUE) { \ + AsicSendCommandToMcu(_pAd, 0x80, 0xff, 0x0, 0x0); \ + if ((_pAd)->OpMode == OPMODE_AP) \ + RTMPusecDelay(1000); \ + } \ + (_pAd)->BbpWriteLatch[_bbpID] = _pV; \ + break; \ + } \ + if (_busyCnt == MAX_BUSY_COUNT) { \ + DBGPRINT_ERR(("BBP write R%d fail\n", _bbpID)); \ + if ((_bViaMCU) == TRUE) { \ RTMP_IO_READ32(_pAd, H2M_BBP_AGENT, &BbpCsr.word); \ - BbpCsr.field.Busy = 0; \ + BbpCsr.field.Busy = 0; \ RTMP_IO_WRITE32(_pAd, H2M_BBP_AGENT, BbpCsr.word); \ - } \ - } \ - }while(0) + } \ + } \ + } while (0) /* This marco used for the BBP write operation which didn't need via MCU. @@ -426,25 +399,22 @@ will use this function too and didn't access the bbp register via the MCU. */ /* Write BBP register by register's ID & value */ -#define RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) \ -{ \ - BBP_CSR_CFG_STRUC BbpCsr; \ - int BusyCnt = 0; \ +#define RTMP_BBP_IO_WRITE8_BY_REG_ID(_A, _I, _V) \ +{ \ + BBP_CSR_CFG_STRUC BbpCsr; \ + int BusyCnt = 0; \ BOOLEAN brc; \ - if (_I < MAX_NUM_OF_BBP_LATCH) \ - { \ - if ((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3) \ + if (_I < MAX_NUM_OF_BBP_LATCH) { \ + if ((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) \ + && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3) \ && ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE) \ && ((_A)->bPCIclkOff == FALSE) \ - && ((_A)->brt30xxBanMcuCmd == FALSE)) \ - { \ - if (_A->AccessBBPFailCount > 20) \ - { \ - AsicResetBBPAgent(_A); \ - _A->AccessBBPFailCount = 0; \ - } \ - for (BusyCnt=0; BusyCnt<MAX_BUSY_COUNT; BusyCnt++) \ - { \ + && ((_A)->brt30xxBanMcuCmd == FALSE)) { \ + if (_A->AccessBBPFailCount > 20) { \ + AsicResetBBPAgent(_A); \ + _A->AccessBBPFailCount = 0; \ + } \ + for (BusyCnt = 0; BusyCnt < MAX_BUSY_COUNT; BusyCnt++) { \ RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \ if (BbpCsr.field.Busy == BUSY) \ continue; \ @@ -456,29 +426,24 @@ BbpCsr.field.RegNum = _I; \ RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \ brc = AsicSendCommandToMcu(_A, 0x80, 0xff, 0x0, 0x0); \ - if (brc == TRUE) \ - { \ + if (brc == TRUE) { \ (_A)->BbpWriteLatch[_I] = _V; \ - } \ - else \ - { \ + } else { \ BbpCsr.field.Busy = 0; \ RTMP_IO_WRITE32(_A, H2M_BBP_AGENT, BbpCsr.word); \ } \ break; \ } \ } \ - else if (!((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3) \ + else if (!((IS_RT3090((_A)) || IS_RT3572((_A)) || IS_RT3390((_A))) \ + && ((_A)->StaCfg.PSControl.field.rt30xxPowerMode == 3) \ && ((_A)->StaCfg.PSControl.field.EnableNewPS == TRUE)) \ - && ((_A)->bPCIclkOff == FALSE)) \ - { \ - if (_A->AccessBBPFailCount > 20) \ - { \ - AsicResetBBPAgent(_A); \ - _A->AccessBBPFailCount = 0; \ - } \ - for (BusyCnt=0; BusyCnt<MAX_BUSY_COUNT; BusyCnt++) \ - { \ + && ((_A)->bPCIclkOff == FALSE)) { \ + if (_A->AccessBBPFailCount > 20) { \ + AsicResetBBPAgent(_A); \ + _A->AccessBBPFailCount = 0; \ + } \ + for (BusyCnt = 0; BusyCnt < MAX_BUSY_COUNT; BusyCnt++) { \ RTMP_IO_READ32(_A, H2M_BBP_AGENT, &BbpCsr.word); \ if (BbpCsr.field.Busy == BUSY) \ continue; \ @@ -493,20 +458,15 @@ (_A)->BbpWriteLatch[_I] = _V; \ break; \ } \ - } \ - else \ - { \ + } else { \ DBGPRINT_ERR((" brt30xxBanMcuCmd = %d. Write BBP %d \n", (_A)->brt30xxBanMcuCmd, (_I))); \ } \ - if ((BusyCnt == MAX_BUSY_COUNT) || ((_A)->bPCIclkOff == TRUE)) \ - { \ - if (BusyCnt == MAX_BUSY_COUNT) \ + if ((BusyCnt == MAX_BUSY_COUNT) || ((_A)->bPCIclkOff == TRUE)) { \ + if (BusyCnt == MAX_BUSY_COUNT) \ (_A)->AccessBBPFailCount++; \ - DBGPRINT_ERR(("BBP write R%d=0x%x fail. BusyCnt= %d.bPCIclkOff = %d. \n", _I, BbpCsr.word, BusyCnt, (_A)->bPCIclkOff )); \ + DBGPRINT_ERR(("BBP write R%d=0x%x fail. BusyCnt= %d.bPCIclkOff = %d. \n", _I, BbpCsr.word, BusyCnt, (_A)->bPCIclkOff)); \ } \ - } \ - else \ - { \ + } else { \ DBGPRINT_ERR(("****** BBP_Write_Latch Buffer exceeds max boundry ****** \n")); \ } \ } @@ -522,7 +482,7 @@ #ifdef RT30xx #define RTMP_ASIC_MMPS_DISABLE(_pAd) \ - do{ \ + do { \ u32 _macData; \ u8 _bbpData = 0; \ /* disable MMPS BBP control register */ \ @@ -534,10 +494,10 @@ RTMP_IO_READ32(_pAd, 0x1210, &_macData); \ _macData &= ~(0x09); /*bit 0, 3*/ \ RTMP_IO_WRITE32(_pAd, 0x1210, _macData); \ - }while(0) + } while (0) #define RTMP_ASIC_MMPS_ENABLE(_pAd) \ - do{ \ + do { \ u32 _macData; \ u8 _bbpData = 0; \ /* enable MMPS BBP control register */ \ @@ -549,7 +509,7 @@ RTMP_IO_READ32(_pAd, 0x1210, &_macData); \ _macData |= (0x09); /*bit 0, 3*/ \ RTMP_IO_WRITE32(_pAd, 0x1210, _macData); \ - }while(0) + } while (0) #endif /* RT30xx // */ diff --git a/drivers/staging/rt2860/chips/rt3070.c b/drivers/staging/rt2860/chips/rt3070.c index 627bad943a3c..3a17fd10ec1f 100644 --- a/drivers/staging/rt2860/chips/rt3070.c +++ b/drivers/staging/rt2860/chips/rt3070.c @@ -56,7 +56,7 @@ void NICInitRT3070RFRegisters(struct rt_rtmp_adapter *pAd) u32 RfReg = 0; u32 data; - RT30xxReadRFRegister(pAd, RF_R30, (u8 *)& RfReg); + RT30xxReadRFRegister(pAd, RF_R30, (u8 *)&RfReg); RfReg |= 0x80; RT30xxWriteRFRegister(pAd, RF_R30, (u8)RfReg); RTMPusecDelay(1000); @@ -84,7 +84,7 @@ void NICInitRT3070RFRegisters(struct rt_rtmp_adapter *pAd) } } else if (IS_RT3071(pAd)) { /* Driver should set RF R6 bit6 on before init RF registers */ - RT30xxReadRFRegister(pAd, RF_R06, (u8 *)& RfReg); + RT30xxReadRFRegister(pAd, RF_R06, (u8 *)&RfReg); RfReg |= 0x40; RT30xxWriteRFRegister(pAd, RF_R06, (u8)RfReg); diff --git a/drivers/staging/rt2860/chips/rt3090.c b/drivers/staging/rt2860/chips/rt3090.c index 5927ba4c5a9b..c2933c69bc04 100644 --- a/drivers/staging/rt2860/chips/rt3090.c +++ b/drivers/staging/rt2860/chips/rt3090.c @@ -53,7 +53,7 @@ void NICInitRT3090RFRegisters(struct rt_rtmp_adapter *pAd) /* Driver should toggle RF R30 bit7 before init RF registers */ u32 RfReg = 0, data; - RT30xxReadRFRegister(pAd, RF_R30, (u8 *)& RfReg); + RT30xxReadRFRegister(pAd, RF_R30, (u8 *)&RfReg); RfReg |= 0x80; RT30xxWriteRFRegister(pAd, RF_R30, (u8)RfReg); RTMPusecDelay(1000); @@ -90,7 +90,7 @@ void NICInitRT3090RFRegisters(struct rt_rtmp_adapter *pAd) } /* Driver should set RF R6 bit6 on before calibration */ - RT30xxReadRFRegister(pAd, RF_R06, (u8 *)& RfReg); + RT30xxReadRFRegister(pAd, RF_R06, (u8 *)&RfReg); RfReg |= 0x40; RT30xxWriteRFRegister(pAd, RF_R06, (u8)RfReg); diff --git a/drivers/staging/rt2860/chips/rt30xx.c b/drivers/staging/rt2860/chips/rt30xx.c index 6e684a3ccf0e..4367a196aeff 100644 --- a/drivers/staging/rt2860/chips/rt30xx.c +++ b/drivers/staging/rt2860/chips/rt30xx.c @@ -170,8 +170,7 @@ void RTMPFilterCalibration(struct rt_rtmp_adapter *pAd) pAd->Mlme.CaliBW40RfR24 = 0x2F; /*Bit[5] must be 1 for BW 40 */ do { - if (loop == 1) /*BandWidth = 40 MHz */ - { + if (loop == 1) { /*BandWidth = 40 MHz */ /* Write 0x27 to RF_R24 to program filter */ RF_R24_Value = 0x27; RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value); @@ -190,8 +189,7 @@ void RTMPFilterCalibration(struct rt_rtmp_adapter *pAd) RT30xxReadRFRegister(pAd, RF_R31, &value); value |= 0x20; RT30xxWriteRFRegister(pAd, RF_R31, value); - } else /*BandWidth = 20 MHz */ - { + } else { /*BandWidth = 20 MHz */ /* Write 0x07 to RF_R24 to program filter */ RF_R24_Value = 0x07; RT30xxWriteRFRegister(pAd, RF_R24, RF_R24_Value); @@ -353,8 +351,7 @@ void RT30xxLoadRFNormalModeSetup(struct rt_rtmp_adapter *pAd) RT30xxReadRFRegister(pAd, RF_R27, &RFValue); /* TX to RX IQ glitch(RF_R27) has been fixed in RT3070(F). */ /* Raising RF voltage is no longer needed for RT3070(F) */ - if (IS_RT3090(pAd)) /* RT309x and RT3071/72 */ - { + if (IS_RT3090(pAd)) { /* RT309x and RT3071/72 */ if ((pAd->MACVersion & 0xffff) < 0x0211) RFValue = (RFValue & (~0x77)) | 0x3; else diff --git a/drivers/staging/rt2860/common/cmm_aes.c b/drivers/staging/rt2860/common/cmm_aes.c index 250357c5cd65..1d159ff82fd2 100644 --- a/drivers/staging/rt2860/common/cmm_aes.c +++ b/drivers/staging/rt2860/common/cmm_aes.c @@ -281,7 +281,7 @@ void construct_mic_header2(unsigned char *mic_header2, mic_header2[6] = mpdu[22] & 0x0f; /* SC */ mic_header2[7] = 0x00; /* mpdu[23]; */ - if ((!qc_exists) & a4_exists) { + if ((!qc_exists) && a4_exists) { for (i = 0; i < 6; i++) mic_header2[8 + i] = mpdu[24 + i]; /* A4 */ diff --git a/drivers/staging/rt2860/common/cmm_data.c b/drivers/staging/rt2860/common/cmm_data.c index 68263cee7952..65b00e685eb2 100644 --- a/drivers/staging/rt2860/common/cmm_data.c +++ b/drivers/staging/rt2860/common/cmm_data.c @@ -773,7 +773,8 @@ void RTMPDeQueuePacket(struct rt_rtmp_adapter *pAd, IN BOOLEAN bIntContext, u8 Q /* probe the Queue Head */ pQueue = &pAd->TxSwQueue[QueIdx]; - if ((pEntry = pQueue->Head) == NULL) { + pEntry = pQueue->Head; + if (pEntry == NULL) { DEQUEUE_UNLOCK(&pAd->irq_lock, bIntContext, IrqFlags); break; @@ -824,7 +825,8 @@ void RTMPDeQueuePacket(struct rt_rtmp_adapter *pAd, IN BOOLEAN bIntContext, u8 Q } do { - if ((pEntry = pQueue->Head) == NULL) + pEntry = pQueue->Head; + if (pEntry == NULL) break; /* For TX_AMSDU_FRAME/TX_RALINK_FRAME, Need to check if next pakcet can do aggregation. */ diff --git a/drivers/staging/rt2860/common/cmm_wpa.c b/drivers/staging/rt2860/common/cmm_wpa.c index 94e119faaa71..c16f3763cca6 100644 --- a/drivers/staging/rt2860/common/cmm_wpa.c +++ b/drivers/staging/rt2860/common/cmm_wpa.c @@ -2928,25 +2928,23 @@ void WpaShowAllsuite(u8 *rsnie, u32 rsnie_len) hex_dump("RSNIE", rsnie, rsnie_len); /* group cipher */ - if ((pSuite = - GetSuiteFromRSNIE(rsnie, rsnie_len, GROUP_SUITE, - &count)) != NULL) { + pSuite = GetSuiteFromRSNIE(rsnie, rsnie_len, GROUP_SUITE, &count); + if (pSuite != NULL) { hex_dump("group cipher", pSuite, 4 * count); } /* pairwise cipher */ - if ((pSuite = - GetSuiteFromRSNIE(rsnie, rsnie_len, PAIRWISE_SUITE, - &count)) != NULL) { + pSuite = GetSuiteFromRSNIE(rsnie, rsnie_len, PAIRWISE_SUITE, &count); + if (pSuite != NULL) { hex_dump("pairwise cipher", pSuite, 4 * count); } /* AKM */ - if ((pSuite = - GetSuiteFromRSNIE(rsnie, rsnie_len, AKM_SUITE, &count)) != NULL) { + pSuite = GetSuiteFromRSNIE(rsnie, rsnie_len, AKM_SUITE, &count); + if (pSuite != NULL) { hex_dump("AKM suite", pSuite, 4 * count); } /* PMKID */ - if ((pSuite = - GetSuiteFromRSNIE(rsnie, rsnie_len, PMKID_LIST, &count)) != NULL) { + pSuite = GetSuiteFromRSNIE(rsnie, rsnie_len, PMKID_LIST, &count); + if (pSuite != NULL) { hex_dump("PMKID", pSuite, LEN_PMKID); } diff --git a/drivers/staging/rt2860/common/spectrum.c b/drivers/staging/rt2860/common/spectrum.c index 51e38d809333..2d5f847e6cc6 100644 --- a/drivers/staging/rt2860/common/spectrum.c +++ b/drivers/staging/rt2860/common/spectrum.c @@ -1900,8 +1900,8 @@ static void PeerMeasureReportAction(struct rt_rtmp_adapter *pAd, /* if (pAd->CommonCfg.bIEEE80211H != TRUE) */ /* return; */ - if ((pMeasureReportInfo = - kmalloc(sizeof(struct rt_measure_rpi_report), GFP_ATOMIC)) == NULL) { + pMeasureReportInfo = kmalloc(sizeof(struct rt_measure_rpi_report), GFP_ATOMIC); + if (pMeasureReportInfo == NULL) { DBGPRINT(RT_DEBUG_ERROR, ("%s unable to alloc memory for measure report buffer (size=%zu).\n", __func__, sizeof(struct rt_measure_rpi_report))); @@ -2016,7 +2016,8 @@ static void PeerTpcRepAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_e NdisZeroMemory(&TpcRepInfo, sizeof(struct rt_tpc_report_info)); if (PeerTpcRepSanity (pAd, Elem->Msg, Elem->MsgLen, &DialogToken, &TpcRepInfo)) { - if ((pEntry = TpcReqLookUp(pAd, DialogToken)) != NULL) { + pEntry = TpcReqLookUp(pAd, DialogToken); + if (pEntry != NULL) { TpcReqDelete(pAd, pEntry->DialogToken); DBGPRINT(RT_DEBUG_TRACE, ("%s: DialogToken=%x, TxPwr=%d, LinkMargin=%d\n", diff --git a/drivers/staging/rt2860/pci_main_dev.c b/drivers/staging/rt2860/pci_main_dev.c index e665d862281c..321facd6b0ab 100644 --- a/drivers/staging/rt2860/pci_main_dev.c +++ b/drivers/staging/rt2860/pci_main_dev.c @@ -107,13 +107,13 @@ MODULE_VERSION(STA_DRIVER_VERSION); /* Our PCI driver structure */ /* */ static struct pci_driver rt2860_driver = { -name: "rt2860", -id_table:rt2860_pci_tbl, -probe: rt2860_probe, -remove:__devexit_p(rt2860_remove_one), +name: "rt2860", +id_table : rt2860_pci_tbl, +probe : rt2860_probe, +remove : __devexit_p(rt2860_remove_one), #ifdef CONFIG_PM -suspend:rt2860_suspend, -resume:rt2860_resume, +suspend : rt2860_suspend, +resume : rt2860_resume, #endif }; @@ -211,9 +211,9 @@ static int rt2860_resume(struct pci_dev *pci_dev) DBGPRINT(RT_DEBUG_TRACE, ("===> rt2860_resume()\n")); - if (net_dev == NULL) { + if (net_dev == NULL) DBGPRINT(RT_DEBUG_ERROR, ("net_dev == NULL!\n")); - } else + else GET_PAD_FROM_NET_DEV(pAd, net_dev); if (pAd != NULL) { @@ -281,7 +281,9 @@ static int __devinit rt2860_probe(IN struct pci_dev *pci_dev, /*PCIDevInit============================================== */ /* wake up and enable device */ - if ((rv = pci_enable_device(pci_dev)) != 0) { + rv = pci_enable_device(pci_dev); + + if (rv != 0) { DBGPRINT(RT_DEBUG_ERROR, ("Enable PCI device failed, errno=%d!\n", rv)); return rv; @@ -289,7 +291,9 @@ static int __devinit rt2860_probe(IN struct pci_dev *pci_dev, print_name = (char *)pci_name(pci_dev); - if ((rv = pci_request_regions(pci_dev, print_name)) != 0) { + rv = pci_request_regions(pci_dev, print_name); + + if (rv != 0) { DBGPRINT(RT_DEBUG_ERROR, ("Request PCI resource failed, errno=%d!\n", rv)); goto err_out; @@ -490,9 +494,8 @@ static void RTMPInitPCIeDevice(struct pci_dev *pci_dev, struct rt_rtmp_adapter * /* Support advanced power save after 2892/2790. */ /* MAC version at offset 0x1000 is 0x2872XXXX/0x2870XXXX(PCIe, USB, SDIO). */ - if ((MacCsr0 & 0xffff0000) != 0x28600000) { + if ((MacCsr0 & 0xffff0000) != 0x28600000) OPSTATUS_SET_FLAG(pAd, fOP_STATUS_PCIE_DEVICE); - } } } @@ -900,9 +903,9 @@ void RTMPPCIeLinkCtrlValueRestore(struct rt_rtmp_adapter *pAd, u8 Level) if ((Configuration != 0) && (Configuration != 0xFFFF)) { Configuration &= 0xfefc; /* If call from interface down, restore to orginial setting. */ - if (Level == RESTORE_CLOSE) { + if (Level == RESTORE_CLOSE) Configuration |= pAd->HostLnkCtrlConfiguration; - } else + else Configuration |= 0x0; PCI_REG_WIRTE_WORD(pObj->parent_pci_dev, pAd->HostLnkCtrlOffset, @@ -1100,13 +1103,13 @@ void RTMPrt3xSetPCIePowerLinkCtrl(struct rt_rtmp_adapter *pAd) /* Find PCI-to-PCI Bridge Express Capability Offset */ pos = pci_find_capability(pObj->parent_pci_dev, PCI_CAP_ID_EXP); - if (pos != 0) { + if (pos != 0) pAd->HostLnkCtrlOffset = pos + PCI_EXP_LNKCTL; - } + /* If configurared to turn on L1. */ HostConfiguration = 0; if (pAd->StaCfg.PSControl.field.rt30xxForceASPMTest == 1) { - DBGPRINT(RT_DEBUG_TRACE, ("Enter,PSM : Force ASPM \n")); + DBGPRINT(RT_DEBUG_TRACE, ("Enter,PSM : Force ASPM\n")); /* Skip non-exist deice right away */ if ((pAd->HostLnkCtrlOffset != 0)) { diff --git a/drivers/staging/rt2860/rt_linux.c b/drivers/staging/rt2860/rt_linux.c index fd9a2072139b..27b78102f4bd 100644 --- a/drivers/staging/rt2860/rt_linux.c +++ b/drivers/staging/rt2860/rt_linux.c @@ -82,7 +82,7 @@ char const *pWirelessFloodEventText[IW_FLOOD_EVENT_TYPE_NUM] = { }; /* timeout -- ms */ -void RTMP_SetPeriodicTimer(struct timer_list * pTimer, +void RTMP_SetPeriodicTimer(struct timer_list *pTimer, IN unsigned long timeout) { timeout = ((timeout * OS_HZ) / 1000); @@ -92,7 +92,7 @@ void RTMP_SetPeriodicTimer(struct timer_list * pTimer, /* convert NdisMInitializeTimer --> RTMP_OS_Init_Timer */ void RTMP_OS_Init_Timer(struct rt_rtmp_adapter *pAd, - struct timer_list * pTimer, + struct timer_list *pTimer, IN TIMER_FUNCTION function, void *data) { init_timer(pTimer); @@ -100,7 +100,7 @@ void RTMP_OS_Init_Timer(struct rt_rtmp_adapter *pAd, pTimer->function = function; } -void RTMP_OS_Add_Timer(struct timer_list * pTimer, +void RTMP_OS_Add_Timer(struct timer_list *pTimer, IN unsigned long timeout) { if (timer_pending(pTimer)) @@ -111,14 +111,14 @@ void RTMP_OS_Add_Timer(struct timer_list * pTimer, add_timer(pTimer); } -void RTMP_OS_Mod_Timer(struct timer_list * pTimer, +void RTMP_OS_Mod_Timer(struct timer_list *pTimer, IN unsigned long timeout) { timeout = ((timeout * OS_HZ) / 1000); mod_timer(pTimer, jiffies + timeout); } -void RTMP_OS_Del_Timer(struct timer_list * pTimer, +void RTMP_OS_Del_Timer(struct timer_list *pTimer, OUT BOOLEAN * pCancelled) { if (timer_pending(pTimer)) { @@ -146,7 +146,7 @@ void RTMPusecDelay(unsigned long usec) udelay(usec % 50); } -void RTMP_GetCurrentSystemTime(LARGE_INTEGER * time) +void RTMP_GetCurrentSystemTime(LARGE_INTEGER *time) { time->u.LowPart = jiffies; } @@ -156,9 +156,9 @@ int os_alloc_mem(struct rt_rtmp_adapter *pAd, u8 ** mem, unsigned long size) { *mem = (u8 *)kmalloc(size, GFP_ATOMIC); if (*mem) - return (NDIS_STATUS_SUCCESS); + return NDIS_STATUS_SUCCESS; else - return (NDIS_STATUS_FAILURE); + return NDIS_STATUS_FAILURE; } /* pAd MUST allow to be NULL */ @@ -167,7 +167,7 @@ int os_free_mem(struct rt_rtmp_adapter *pAd, void *mem) ASSERT(mem); kfree(mem); - return (NDIS_STATUS_SUCCESS); + return NDIS_STATUS_SUCCESS; } void *RtmpOSNetPktAlloc(struct rt_rtmp_adapter *pAd, IN int size) @@ -176,7 +176,7 @@ void *RtmpOSNetPktAlloc(struct rt_rtmp_adapter *pAd, IN int size) /* Add 2 more bytes for ip header alignment */ skb = dev_alloc_skb(size + 2); - return ((void *)skb); + return (void *)skb; } void *RTMP_AllocateFragPacketBuffer(struct rt_rtmp_adapter *pAd, @@ -201,7 +201,7 @@ void *RTMP_AllocateFragPacketBuffer(struct rt_rtmp_adapter *pAd, void *RTMP_AllocateTxPacketBuffer(struct rt_rtmp_adapter *pAd, unsigned long Length, IN BOOLEAN Cached, - void ** VirtualAddress) + void **VirtualAddress) { struct sk_buff *pkt; @@ -271,7 +271,7 @@ void RTMPFreeAdapter(struct rt_rtmp_adapter *pAd) BOOLEAN OS_Need_Clone_Packet(void) { - return (FALSE); + return FALSE; } /* @@ -299,7 +299,7 @@ BOOLEAN OS_Need_Clone_Packet(void) int RTMPCloneNdisPacket(struct rt_rtmp_adapter *pAd, IN BOOLEAN pInsAMSDUHdr, void *pInPacket, - void ** ppOutPacket) + void **ppOutPacket) { struct sk_buff *pkt; @@ -328,7 +328,7 @@ int RTMPCloneNdisPacket(struct rt_rtmp_adapter *pAd, /* the allocated NDIS PACKET must be freed via RTMPFreeNdisPacket() */ int RTMPAllocateNdisPacket(struct rt_rtmp_adapter *pAd, - void ** ppPacket, + void **ppPacket, u8 *pHeader, u32 HeaderLen, u8 *pData, u32 DataLen) @@ -391,7 +391,7 @@ int Sniff2BytesFromNdisBuffer(char *pFirstBuffer, void RTMP_QueryPacketInfo(void *pPacket, struct rt_packet_info *pPacketInfo, - u8 ** pSrcBufVA, u32 * pSrcBufLen) + u8 **pSrcBufVA, u32 * pSrcBufLen) { pPacketInfo->BufferCount = 1; pPacketInfo->pFirstBuffer = (char *)GET_OS_PKT_DATAPTR(pPacket); @@ -402,9 +402,9 @@ void RTMP_QueryPacketInfo(void *pPacket, *pSrcBufLen = GET_OS_PKT_LEN(pPacket); } -void RTMP_QueryNextPacketInfo(void ** ppPacket, +void RTMP_QueryNextPacketInfo(void **ppPacket, struct rt_packet_info *pPacketInfo, - u8 ** pSrcBufVA, u32 * pSrcBufLen) + u8 **pSrcBufVA, u32 * pSrcBufLen) { void *pPacket = NULL; @@ -463,8 +463,8 @@ void *duplicate_pkt(struct rt_rtmp_adapter *pAd, struct sk_buff *skb; void *pPacket = NULL; - if ((skb = - __dev_alloc_skb(HdrLen + DataSize + 2, MEM_ALLOC_FLAG)) != NULL) { + skb = __dev_alloc_skb(HdrLen + DataSize + 2, MEM_ALLOC_FLAG); + if (skb != NULL) { skb_reserve(skb, 2); NdisMoveMemory(skb_tail_pointer(skb), pHeader802_3, HdrLen); skb_put(skb, HdrLen); @@ -589,7 +589,7 @@ rt_get_sg_list_from_packet(void *pPacket, struct rt_rtmp_sg_list *sg) sg->NumberOfElements = 1; sg->Elements[0].Address = GET_OS_PKT_DATAPTR(pPacket); sg->Elements[0].Length = GET_OS_PKT_LEN(pPacket); - return (sg); + return sg; } void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen) @@ -673,7 +673,8 @@ void RTMPSendWirelessEvent(struct rt_rtmp_adapter *pAd, return; } /*Allocate memory and copy the msg. */ - if ((pBuf = kmalloc(IW_CUSTOM_MAX_LEN, GFP_ATOMIC)) != NULL) { + pBuf = kmalloc(IW_CUSTOM_MAX_LEN, GFP_ATOMIC); + if (pBuf != NULL) { /*Prepare the payload */ memset(pBuf, 0, IW_CUSTOM_MAX_LEN); @@ -1062,7 +1063,7 @@ void RtmpOSTaskCustomize(struct rt_rtmp_os_task *pTask) #ifndef KTHREAD_SUPPORT - daemonize((char *)& pTask->taskName[0] /*"%s",pAd->net_dev->name */ ); + daemonize((char *)&pTask->taskName[0] /*"%s",pAd->net_dev->name */); allow_signal(SIGTERM); allow_signal(SIGKILL); @@ -1247,7 +1248,7 @@ void RtmpOSNetDevFree(struct net_device *pNetDev) free_netdev(pNetDev); } -int RtmpOSNetDevAlloc(struct net_device ** new_dev_p, u32 privDataSize) +int RtmpOSNetDevAlloc(struct net_device **new_dev_p, u32 privDataSize) { /* assign it as null first. */ *new_dev_p = NULL; @@ -1344,7 +1345,7 @@ struct net_device *RtmpOSNetDevCreate(struct rt_rtmp_adapter *pAd, int status; /* allocate a new network device */ - status = RtmpOSNetDevAlloc(&pNetDev, 0 /*privMemSize */ ); + status = RtmpOSNetDevAlloc(&pNetDev, 0 /*privMemSize */); if (status != NDIS_STATUS_SUCCESS) { /* allocation fail, exit */ DBGPRINT(RT_DEBUG_ERROR, diff --git a/drivers/staging/rt2860/rt_linux.h b/drivers/staging/rt2860/rt_linux.h index a7c540f8e3e3..b370fb21e423 100644 --- a/drivers/staging/rt2860/rt_linux.h +++ b/drivers/staging/rt2860/rt_linux.h @@ -455,10 +455,11 @@ void hex_dump(char *str, unsigned char *pSrcBufVA, unsigned int SrcBufLen); * Device DMA Access related definitions and data structures. **********************************************************************************/ #ifdef RTMP_MAC_PCI -dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, - int sd_idx, int direction); -void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, - int direction); +struct rt_rtmp_adapter; +dma_addr_t linux_pci_map_single(struct rt_rtmp_adapter *pAd, void *ptr, + size_t size, int sd_idx, int direction); +void linux_pci_unmap_single(struct rt_rtmp_adapter *pAd, dma_addr_t dma_addr, + size_t size, int direction); #define PCI_MAP_SINGLE(_handle, _ptr, _size, _sd_idx, _dir) \ linux_pci_map_single(_handle, _ptr, _size, _sd_idx, _dir) @@ -475,11 +476,6 @@ void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, #define DEV_ALLOC_SKB(_length) \ dev_alloc_skb(_length) #endif /* RTMP_MAC_PCI // */ -#ifdef RTMP_MAC_USB -#define PCI_MAP_SINGLE(_handle, _ptr, _size, _dir) (unsigned long)0 - -#define PCI_UNMAP_SINGLE(_handle, _ptr, _size, _dir) -#endif /* RTMP_MAC_USB // */ /* * unsigned long diff --git a/drivers/staging/rt2860/rt_main_dev.c b/drivers/staging/rt2860/rt_main_dev.c index fbddb00cfedd..ad60ceaf4b88 100644 --- a/drivers/staging/rt2860/rt_main_dev.c +++ b/drivers/staging/rt2860/rt_main_dev.c @@ -439,13 +439,13 @@ int rt28xx_open(struct net_device *dev) RTMPInitPCIeLinkCtrlValue(pAd); #endif /* RTMP_MAC_PCI // */ - return (retval); + return retval; err: /*+++Add by shiang, move from rt28xx_init() to here. */ RtmpOSIRQRelease(net_dev); /*---Add by shiang, move from rt28xx_init() to here. */ - return (-1); + return -1; } /* End of rt28xx_open */ static const struct net_device_ops rt2860_netdev_ops = { @@ -534,7 +534,7 @@ int rt28xx_packet_xmit(struct sk_buff *skb) } RTMP_SET_PACKET_5VT(pPacket, 0); - STASendPackets((void *)pAd, (void **)& pPacket, 1); + STASendPackets((void *)pAd, (void **)&pPacket, 1); status = NETDEV_TX_OK; done: @@ -571,7 +571,7 @@ static int rt28xx_send_packets(IN struct sk_buff *skb_p, return NETDEV_TX_OK; } - NdisZeroMemory((u8 *)& skb_p->cb[CB_OFF], 15); + NdisZeroMemory((u8 *)&skb_p->cb[CB_OFF], 15); RTMP_SET_PACKET_NET_DEVICE_MBSSID(skb_p, MAIN_MBSSID); return rt28xx_packet_xmit(skb_p); @@ -628,13 +628,13 @@ void tbtt_tasklet(unsigned long data) ======================================================================== Routine Description: - return ethernet statistics counter + return ethernet statistics counter Arguments: - net_dev Pointer to net_device + net_dev Pointer to net_device Return Value: - net_device_stats* + net_device_stats* Note: @@ -728,9 +728,9 @@ int AdapterBlockAllocateMemory(void *handle, void ** ppAd) if (*ppAd) { NdisZeroMemory(*ppAd, sizeof(struct rt_rtmp_adapter)); - ((struct rt_rtmp_adapter *)* ppAd)->OS_Cookie = handle; - return (NDIS_STATUS_SUCCESS); + ((struct rt_rtmp_adapter *)*ppAd)->OS_Cookie = handle; + return NDIS_STATUS_SUCCESS; } else { - return (NDIS_STATUS_FAILURE); + return NDIS_STATUS_FAILURE; } } diff --git a/drivers/staging/rt2860/rt_pci_rbus.c b/drivers/staging/rt2860/rt_pci_rbus.c index e0a0aeeb17a2..3004be6da003 100644 --- a/drivers/staging/rt2860/rt_pci_rbus.c +++ b/drivers/staging/rt2860/rt_pci_rbus.c @@ -81,7 +81,7 @@ void RTMP_AllocateTxDescMemory(struct rt_rtmp_adapter *pAd, u32 Index, unsigned long Length, IN BOOLEAN Cached, - void ** VirtualAddress, + void **VirtualAddress, dma_addr_t *PhysicalAddress) { struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie; @@ -96,7 +96,7 @@ void RTMP_AllocateTxDescMemory(struct rt_rtmp_adapter *pAd, void RTMP_AllocateMgmtDescMemory(struct rt_rtmp_adapter *pAd, unsigned long Length, IN BOOLEAN Cached, - void ** VirtualAddress, + void **VirtualAddress, dma_addr_t *PhysicalAddress) { struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie; @@ -111,7 +111,7 @@ void RTMP_AllocateMgmtDescMemory(struct rt_rtmp_adapter *pAd, void RTMP_AllocateRxDescMemory(struct rt_rtmp_adapter *pAd, unsigned long Length, IN BOOLEAN Cached, - void ** VirtualAddress, + void **VirtualAddress, dma_addr_t *PhysicalAddress) { struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie; @@ -139,7 +139,7 @@ void RTMP_AllocateFirstTxBuffer(struct rt_rtmp_adapter *pAd, u32 Index, unsigned long Length, IN BOOLEAN Cached, - void ** VirtualAddress, + void **VirtualAddress, dma_addr_t *PhysicalAddress) { struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie; @@ -173,7 +173,7 @@ void RTMP_FreeFirstTxBuffer(struct rt_rtmp_adapter *pAd, void RTMP_AllocateSharedMemory(struct rt_rtmp_adapter *pAd, unsigned long Length, IN BOOLEAN Cached, - void ** VirtualAddress, + void **VirtualAddress, dma_addr_t *PhysicalAddress) { struct os_cookie *pObj = (struct os_cookie *)pAd->OS_Cookie; @@ -197,7 +197,7 @@ void RTMP_AllocateSharedMemory(struct rt_rtmp_adapter *pAd, void *RTMP_AllocateRxPacketBuffer(struct rt_rtmp_adapter *pAd, unsigned long Length, IN BOOLEAN Cached, - void ** VirtualAddress, + void **VirtualAddress, OUT dma_addr_t * PhysicalAddress) { @@ -790,10 +790,9 @@ IRQ_HANDLE_TYPE rt2860_interrupt(int irq, void *dev_instance) * invaild or writeback cache * and convert virtual address to physical address */ -dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, - int sd_idx, int direction) +dma_addr_t linux_pci_map_single(struct rt_rtmp_adapter *pAd, void *ptr, + size_t size, int sd_idx, int direction) { - struct rt_rtmp_adapter *pAd; struct os_cookie *pObj; /* @@ -812,7 +811,6 @@ dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, sd_idx = -1 */ - pAd = (struct rt_rtmp_adapter *)handle; pObj = (struct os_cookie *)pAd->OS_Cookie; if (sd_idx == 1) { @@ -826,13 +824,11 @@ dma_addr_t linux_pci_map_single(void *handle, void *ptr, size_t size, } -void linux_pci_unmap_single(void *handle, dma_addr_t dma_addr, size_t size, - int direction) +void linux_pci_unmap_single(struct rt_rtmp_adapter *pAd, dma_addr_t dma_addr, + size_t size, int direction) { - struct rt_rtmp_adapter *pAd; struct os_cookie *pObj; - pAd = (struct rt_rtmp_adapter *)handle; pObj = (struct os_cookie *)pAd->OS_Cookie; pci_unmap_single(pObj->pci_dev, dma_addr, size, direction); diff --git a/drivers/staging/rt2860/rt_usb.c b/drivers/staging/rt2860/rt_usb.c index 01a7eb4e8ba8..bcfc0f54d2aa 100644 --- a/drivers/staging/rt2860/rt_usb.c +++ b/drivers/staging/rt2860/rt_usb.c @@ -233,8 +233,7 @@ static void rtusb_dataout_complete(unsigned long data) FREE_HTTX_RING(pAd, BulkOutPipeId, pHTTXContext); /*RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); */ - } else /* STATUS_OTHER */ - { + } else { /* STATUS_OTHER */ u8 *pBuf; pAd->BulkOutCompleteOther++; @@ -316,8 +315,7 @@ static void rtusb_null_frame_done_tasklet(unsigned long data) RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag); RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS); - } else /* STATUS_OTHER */ - { + } else { /* STATUS_OTHER */ if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) && @@ -362,8 +360,7 @@ static void rtusb_rts_frame_done_tasklet(unsigned long data) if (Status == USB_ST_NOERROR) { RTMP_IRQ_UNLOCK(&pAd->BulkOutLock[0], irqFlag); RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS); - } else /* STATUS_OTHER */ - { + } else { /* STATUS_OTHER */ if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) && @@ -410,8 +407,7 @@ static void rtusb_pspoll_frame_done_tasklet(unsigned long data) if (Status == USB_ST_NOERROR) { RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS); - } else /* STATUS_OTHER */ - { + } else { /* STATUS_OTHER */ if ((!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_RESET_IN_PROGRESS)) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS)) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST)) && @@ -473,14 +469,12 @@ static void rx_done_tasklet(unsigned long data) if (Status == USB_ST_NOERROR) { pAd->BulkInComplete++; pAd->NextRxBulkInPosition = 0; - if (pRxContext->BulkInOffset) /* As jan's comment, it may bulk-in success but size is zero. */ - { + if (pRxContext->BulkInOffset) { /* As jan's comment, it may bulk-in success but size is zero. */ pRxContext->Readable = TRUE; INC_RING_INDEX(pAd->NextRxBulkInIndex, RX_RING_SIZE); } RTMP_IRQ_UNLOCK(&pAd->BulkInLock, IrqFlags); - } else /* STATUS_OTHER */ - { + } else { /* STATUS_OTHER */ pAd->BulkInCompleteFail++; /* Still read this packet although it may comtain wrong bytes. */ pRxContext->Readable = FALSE; @@ -584,7 +578,7 @@ static void rtusb_mgmt_dma_done_tasklet(unsigned long data) /* The protectioon of rest bulk should be in BulkOut routine */ if (pAd->MgmtRing.TxSwFreeIdx < MGMT_RING_SIZE - /* pMLMEContext->bWaitingBulkOut == TRUE */ ) { + /* pMLMEContext->bWaitingBulkOut == TRUE */) { RTUSB_SET_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME); } RTUSBKickBulkOut(pAd); diff --git a/drivers/staging/rt2860/rtmp.h b/drivers/staging/rt2860/rtmp.h index 4401a55bda67..ab525ee15042 100644 --- a/drivers/staging/rt2860/rtmp.h +++ b/drivers/staging/rt2860/rtmp.h @@ -181,8 +181,7 @@ struct rt_queue_header { (QueueHeader)->Head; \ { \ struct rt_queue_entry *pNext; \ - if ((QueueHeader)->Head != NULL) \ - { \ + if ((QueueHeader)->Head != NULL) { \ pNext = (QueueHeader)->Head->Next; \ (QueueHeader)->Head->Next = NULL; \ (QueueHeader)->Head = pNext; \ @@ -242,9 +241,9 @@ struct rt_queue_header { #define OPSTATUS_CLEAR_FLAG(_pAd, _F) ((_pAd)->CommonCfg.OpStatusFlags &= ~(_F)) #define OPSTATUS_TEST_FLAG(_pAd, _F) (((_pAd)->CommonCfg.OpStatusFlags & (_F)) != 0) -#define CLIENT_STATUS_SET_FLAG(_pEntry,_F) ((_pEntry)->ClientStatusFlags |= (_F)) -#define CLIENT_STATUS_CLEAR_FLAG(_pEntry,_F) ((_pEntry)->ClientStatusFlags &= ~(_F)) -#define CLIENT_STATUS_TEST_FLAG(_pEntry,_F) (((_pEntry)->ClientStatusFlags & (_F)) != 0) +#define CLIENT_STATUS_SET_FLAG(_pEntry, _F) ((_pEntry)->ClientStatusFlags |= (_F)) +#define CLIENT_STATUS_CLEAR_FLAG(_pEntry, _F) ((_pEntry)->ClientStatusFlags &= ~(_F)) +#define CLIENT_STATUS_TEST_FLAG(_pEntry, _F) (((_pEntry)->ClientStatusFlags & (_F)) != 0) #define RX_FILTER_SET_FLAG(_pAd, _F) ((_pAd)->CommonCfg.PacketFilter |= (_F)) #define RX_FILTER_CLEAR_FLAG(_pAd, _F) ((_pAd)->CommonCfg.PacketFilter &= ~(_F)) @@ -279,13 +278,13 @@ struct rt_queue_header { _pAd->StaActive.SupportedHtPhy.RecomWidth = _pAd->MlmeAux.AddHtInfo.AddHtInfo.RecomWidth; \ _pAd->StaActive.SupportedHtPhy.OperaionMode = _pAd->MlmeAux.AddHtInfo.AddHtInfo2.OperaionMode; \ _pAd->StaActive.SupportedHtPhy.NonGfPresent = _pAd->MlmeAux.AddHtInfo.AddHtInfo2.NonGfPresent; \ - NdisMoveMemory((_pAd)->MacTab.Content[BSSID_WCID].HTCapability.MCSSet, (_pAd)->StaActive.SupportedPhyInfo.MCSSet, sizeof(u8)* 16);\ + NdisMoveMemory((_pAd)->MacTab.Content[BSSID_WCID].HTCapability.MCSSet, (_pAd)->StaActive.SupportedPhyInfo.MCSSet, sizeof(u8) * 16);\ } #define COPY_AP_HTSETTINGS_FROM_BEACON(_pAd, _pHtCapability) \ { \ _pAd->MacTab.Content[BSSID_WCID].AMsduSize = (u8)(_pHtCapability->HtCapInfo.AMsduSize); \ - _pAd->MacTab.Content[BSSID_WCID].MmpsMode= (u8)(_pHtCapability->HtCapInfo.MimoPs); \ + _pAd->MacTab.Content[BSSID_WCID].MmpsMode = (u8)(_pHtCapability->HtCapInfo.MimoPs); \ _pAd->MacTab.Content[BSSID_WCID].MaxRAmpduFactor = (u8)(_pHtCapability->HtCapParm.MaxRAmpduFactor); \ } @@ -349,17 +348,14 @@ struct rt_rtmp_sg_list { /* if orginal Ethernet frame contains no LLC/SNAP, then an extra LLC/SNAP encap is required */ #define EXTRA_LLCSNAP_ENCAP_FROM_PKT_START(_pBufVA, _pExtraLlcSnapEncap) \ { \ - if (((*(_pBufVA + 12) << 8) + *(_pBufVA + 13)) > 1500) \ - { \ + if (((*(_pBufVA + 12) << 8) + *(_pBufVA + 13)) > 1500) { \ _pExtraLlcSnapEncap = SNAP_802_1H; \ if (NdisEqualMemory(IPX, _pBufVA + 12, 2) || \ - NdisEqualMemory(APPLE_TALK, _pBufVA + 12, 2)) \ - { \ + NdisEqualMemory(APPLE_TALK, _pBufVA + 12, 2)) { \ _pExtraLlcSnapEncap = SNAP_BRIDGE_TUNNEL; \ } \ } \ - else \ - { \ + else { \ _pExtraLlcSnapEncap = NULL; \ } \ } @@ -367,17 +363,14 @@ struct rt_rtmp_sg_list { /* New Define for new Tx Path. */ #define EXTRA_LLCSNAP_ENCAP_FROM_PKT_OFFSET(_pBufVA, _pExtraLlcSnapEncap) \ { \ - if (((*(_pBufVA) << 8) + *(_pBufVA + 1)) > 1500) \ - { \ + if (((*(_pBufVA) << 8) + *(_pBufVA + 1)) > 1500) { \ _pExtraLlcSnapEncap = SNAP_802_1H; \ if (NdisEqualMemory(IPX, _pBufVA, 2) || \ - NdisEqualMemory(APPLE_TALK, _pBufVA, 2)) \ - { \ + NdisEqualMemory(APPLE_TALK, _pBufVA, 2)) { \ _pExtraLlcSnapEncap = SNAP_BRIDGE_TUNNEL; \ } \ } \ - else \ - { \ + else { \ _pExtraLlcSnapEncap = NULL; \ } \ } @@ -399,33 +392,29 @@ struct rt_rtmp_sg_list { #define CONVERT_TO_802_3(_p8023hdr, _pDA, _pSA, _pData, _DataSize, _pRemovedLLCSNAP) \ { \ char LLC_Len[2]; \ - \ + \ _pRemovedLLCSNAP = NULL; \ if (NdisEqualMemory(SNAP_802_1H, _pData, 6) || \ - NdisEqualMemory(SNAP_BRIDGE_TUNNEL, _pData, 6)) \ - { \ - u8 *pProto = _pData + 6; \ - \ - if ((NdisEqualMemory(IPX, pProto, 2) || NdisEqualMemory(APPLE_TALK, pProto, 2)) && \ - NdisEqualMemory(SNAP_802_1H, _pData, 6)) \ - { \ - LLC_Len[0] = (u8)(_DataSize / 256); \ - LLC_Len[1] = (u8)(_DataSize % 256); \ - MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len); \ - } \ - else \ - { \ - MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, pProto); \ - _pRemovedLLCSNAP = _pData; \ - _DataSize -= LENGTH_802_1_H; \ - _pData += LENGTH_802_1_H; \ - } \ + NdisEqualMemory(SNAP_BRIDGE_TUNNEL, _pData, 6)) { \ + u8 *pProto = _pData + 6; \ + \ + if ((NdisEqualMemory(IPX, pProto, 2) || NdisEqualMemory(APPLE_TALK, pProto, 2)) && \ + NdisEqualMemory(SNAP_802_1H, _pData, 6)) { \ + LLC_Len[0] = (u8)(_DataSize / 256); \ + LLC_Len[1] = (u8)(_DataSize % 256); \ + MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len); \ + } \ + else { \ + MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, pProto); \ + _pRemovedLLCSNAP = _pData; \ + _DataSize -= LENGTH_802_1_H; \ + _pData += LENGTH_802_1_H; \ + } \ } \ - else \ - { \ - LLC_Len[0] = (u8)(_DataSize / 256); \ - LLC_Len[1] = (u8)(_DataSize % 256); \ - MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len); \ + else { \ + LLC_Len[0] = (u8)(_DataSize / 256); \ + LLC_Len[1] = (u8)(_DataSize % 256); \ + MAKE_802_3_HEADER(_p8023hdr, _pDA, _pSA, LLC_Len); \ } \ } @@ -438,19 +427,19 @@ struct rt_rtmp_sg_list { u32 High32TSF, Low32TSF; \ RTMP_IO_READ32(_pAd, TSF_TIMER_DW1, &High32TSF); \ RTMP_IO_READ32(_pAd, TSF_TIMER_DW0, &Low32TSF); \ - MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (u8)_Rssi0, (u8)_Rssi1,(u8)_Rssi2,_FrameSize, _pFrame, (u8)_PlcpSignal); \ + MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (u8)_Rssi0, (u8)_Rssi1, (u8)_Rssi2, _FrameSize, _pFrame, (u8)_PlcpSignal); \ } #endif /* RTMP_MAC_PCI // */ #ifdef RTMP_MAC_USB #define REPORT_MGMT_FRAME_TO_MLME(_pAd, Wcid, _pFrame, _FrameSize, _Rssi0, _Rssi1, _Rssi2, _PlcpSignal) \ { \ - u32 High32TSF=0, Low32TSF=0; \ - MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (u8)_Rssi0, (u8)_Rssi1,(u8)_Rssi2,_FrameSize, _pFrame, (u8)_PlcpSignal); \ + u32 High32TSF = 0, Low32TSF = 0; \ + MlmeEnqueueForRecv(_pAd, Wcid, High32TSF, Low32TSF, (u8)_Rssi0, (u8)_Rssi1, (u8)_Rssi2, _FrameSize, _pFrame, (u8)_PlcpSignal); \ } #endif /* RTMP_MAC_USB // */ -#define MAC_ADDR_EQUAL(pAddr1,pAddr2) RTMPEqualMemory((void *)(pAddr1), (void *)(pAddr2), MAC_ADDR_LEN) -#define SSID_EQUAL(ssid1, len1, ssid2, len2) ((len1==len2) && (RTMPEqualMemory(ssid1, ssid2, len1))) +#define MAC_ADDR_EQUAL(pAddr1, pAddr2) RTMPEqualMemory((void *)(pAddr1), (void *)(pAddr2), MAC_ADDR_LEN) +#define SSID_EQUAL(ssid1, len1, ssid2, len2) ((len1 == len2) && (RTMPEqualMemory(ssid1, ssid2, len1))) /* */ /* Check if it is Japan W53(ch52,56,60,64) channel. */ @@ -1054,7 +1043,7 @@ typedef union _BACAP_STRUC { u32 MMPSmode:2; /* MIMO power save more, 0:static, 1:dynamic, 2:rsv, 3:mimo enable */ u32 bHtAdhoc:1; /* adhoc can use ht rate. */ u32 b2040CoexistScanSup:1; /*As Sta, support do 2040 coexistence scan for AP. As Ap, support monitor trigger event to check if can use BW 40MHz. */ - u32 : 4; + u32: 4; } field; u32 word; } BACAP_STRUC, *PBACAP_STRUC; @@ -1334,7 +1323,7 @@ struct rt_common_config { BOOLEAN PSPXlink; /* 0: Disable. 1: Enable */ -#if defined(RT305x)||defined(RT30xx) +#if defined(RT305x) || defined(RT30xx) /* request by Gary, for High Power issue */ u8 HighPowerPatchDisabled; #endif @@ -2169,8 +2158,8 @@ struct rt_rtmp_adapter { **************************************************************************/ struct rt_rx_blk { RT28XX_RXD_STRUC RxD; - struct rt_rxwi * pRxWI; - struct rt_header_802_11 * pHeader; + struct rt_rxwi *pRxWI; + struct rt_header_802_11 *pHeader; void *pRxPacket; u8 *pData; u16 DataSize; @@ -2268,7 +2257,7 @@ struct rt_tx_blk { * Other static inline function definitions **************************************************************************/ static inline void ConvertMulticastIP2MAC(u8 *pIpAddr, - u8 ** ppMacAddr, + u8 **ppMacAddr, u16 ProtoType) { if (pIpAddr == NULL) @@ -2310,7 +2299,7 @@ char *GetBW(int BW); /* Private routines in rtmp_init.c */ /* */ int RTMPAllocAdapterBlock(void *handle, - struct rt_rtmp_adapter * * ppAdapter); + struct rt_rtmp_adapter **ppAdapter); int RTMPAllocTxRxRingMemory(struct rt_rtmp_adapter *pAd); @@ -2431,11 +2420,11 @@ void ORIBATimerTimeout(struct rt_rtmp_adapter *pAd); void SendRefreshBAR(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry); void ActHeaderInit(struct rt_rtmp_adapter *pAd, - struct rt_header_802_11 * pHdr80211, + struct rt_header_802_11 *pHdr80211, u8 *Addr1, u8 *Addr2, u8 *Addr3); void BarHeaderInit(struct rt_rtmp_adapter *pAd, - struct rt_frame_bar * pCntlBar, u8 *pDA, u8 *pSA); + struct rt_frame_bar *pCntlBar, u8 *pDA, u8 *pSA); void InsertActField(struct rt_rtmp_adapter *pAd, u8 *pFrameBuf, @@ -2443,7 +2432,7 @@ void InsertActField(struct rt_rtmp_adapter *pAd, BOOLEAN CntlEnqueueForRecv(struct rt_rtmp_adapter *pAd, unsigned long Wcid, - unsigned long MsgLen, struct rt_frame_ba_req * pMsg); + unsigned long MsgLen, struct rt_frame_ba_req *pMsg); /* */ /* Private routines in rtmp_data.c */ @@ -2511,7 +2500,7 @@ int MlmeDataHardTransmit(struct rt_rtmp_adapter *pAd, u8 QueIdx, void *pPacket); void RTMPWriteTxDescriptor(struct rt_rtmp_adapter *pAd, - struct rt_txd * pTxD, IN BOOLEAN bWIV, u8 QSEL); + struct rt_txd *pTxD, IN BOOLEAN bWIV, u8 QSEL); #endif /* RTMP_MAC_PCI // */ u16 RTMPCalcDuration(struct rt_rtmp_adapter *pAd, u8 Rate, unsigned long Size); @@ -2527,10 +2516,10 @@ void RTMPWriteTxWI(struct rt_rtmp_adapter *pAd, struct rt_txwi * pTxWI, IN BOOLE IN BOOLEAN CfAck, IN HTTRANSMIT_SETTING * pTransmit); void RTMPWriteTxWI_Data(struct rt_rtmp_adapter *pAd, - struct rt_txwi * pTxWI, struct rt_tx_blk *pTxBlk); + struct rt_txwi *pTxWI, struct rt_tx_blk *pTxBlk); void RTMPWriteTxWI_Cache(struct rt_rtmp_adapter *pAd, - struct rt_txwi * pTxWI, struct rt_tx_blk *pTxBlk); + struct rt_txwi *pTxWI, struct rt_tx_blk *pTxBlk); void RTMPSuspendMsduTransmission(struct rt_rtmp_adapter *pAd); @@ -2573,10 +2562,10 @@ void WpaStaGroupKeySetting(struct rt_rtmp_adapter *pAd); int RTMPCloneNdisPacket(struct rt_rtmp_adapter *pAd, IN BOOLEAN pInsAMSDUHdr, void *pInPacket, - void ** ppOutPacket); + void **ppOutPacket); int RTMPAllocateNdisPacket(struct rt_rtmp_adapter *pAd, - void ** pPacket, + void **pPacket, u8 *pHeader, u32 HeaderLen, u8 *pData, u32 DataLen); @@ -2717,7 +2706,7 @@ BOOLEAN AsicCheckCommanOk(struct rt_rtmp_adapter *pAd, u8 Command); void MacAddrRandomBssid(struct rt_rtmp_adapter *pAd, u8 *pAddr); void MgtMacHeaderInit(struct rt_rtmp_adapter *pAd, - struct rt_header_802_11 * pHdr80211, + struct rt_header_802_11 *pHdr80211, u8 SubType, u8 ToDs, u8 *pDA, u8 *pBssid); @@ -2796,7 +2785,7 @@ void MlmeQueueDestroy(struct rt_mlme_queue *Queue); BOOLEAN MlmeEnqueue(struct rt_rtmp_adapter *pAd, unsigned long Machine, - unsigned long MsgType, unsigned long MsgLen, void * Msg); + unsigned long MsgType, unsigned long MsgLen, void *Msg); BOOLEAN MlmeEnqueueForRecv(struct rt_rtmp_adapter *pAd, unsigned long Wcid, @@ -2807,7 +2796,7 @@ BOOLEAN MlmeEnqueueForRecv(struct rt_rtmp_adapter *pAd, u8 Rssi2, unsigned long MsgLen, void *Msg, u8 Signal); -BOOLEAN MlmeDequeue(struct rt_mlme_queue *Queue, struct rt_mlme_queue_elem ** Elem); +BOOLEAN MlmeDequeue(struct rt_mlme_queue *Queue, struct rt_mlme_queue_elem **Elem); void MlmeRestartStateMachine(struct rt_rtmp_adapter *pAd); @@ -2816,8 +2805,8 @@ BOOLEAN MlmeQueueEmpty(struct rt_mlme_queue *Queue); BOOLEAN MlmeQueueFull(struct rt_mlme_queue *Queue); BOOLEAN MsgTypeSubst(struct rt_rtmp_adapter *pAd, - struct rt_frame_802_11 * pFrame, - int * Machine, int * MsgType); + struct rt_frame_802_11 *pFrame, + int *Machine, int *MsgType); void StateMachineInit(struct rt_state_machine *Sm, IN STATE_MACHINE_FUNC Trans[], @@ -2895,8 +2884,8 @@ void AssocPostProc(struct rt_rtmp_adapter *pAd, u8 ExtRate[], u8 ExtRateLen, struct rt_edca_parm *pEdcaParm, - struct rt_ht_capability_ie * pHtCapability, - u8 HtCapabilityLen, struct rt_add_ht_info_ie * pAddHtInfo); + struct rt_ht_capability_ie *pHtCapability, + u8 HtCapabilityLen, struct rt_add_ht_info_ie *pAddHtInfo); void AuthStateMachineInit(struct rt_rtmp_adapter *pAd, struct rt_state_machine *sm, OUT STATE_MACHINE_FUNC Trans[]); @@ -2928,7 +2917,7 @@ void AuthRspStateMachineInit(struct rt_rtmp_adapter *pAd, void PeerDeauthAction(struct rt_rtmp_adapter *pAd, struct rt_mlme_queue_elem *Elem); void PeerAuthSimpleRspGenAndSend(struct rt_rtmp_adapter *pAd, - struct rt_header_802_11 * pHdr80211, + struct rt_header_802_11 *pHdr80211, u16 Alg, u16 Seq, u16 Reason, u16 Status); @@ -3054,133 +3043,133 @@ void ScanNextChannel(struct rt_rtmp_adapter *pAd); unsigned long MakeIbssBeacon(struct rt_rtmp_adapter *pAd); BOOLEAN MlmeScanReqSanity(struct rt_rtmp_adapter *pAd, - void * Msg, + void *Msg, unsigned long MsgLen, - u8 * BssType, + u8 *BssType, char ssid[], - u8 * SsidLen, u8 * ScanType); + u8 *SsidLen, u8 *ScanType); BOOLEAN PeerBeaconAndProbeRspSanity(struct rt_rtmp_adapter *pAd, - void * Msg, + void *Msg, unsigned long MsgLen, u8 MsgChannel, u8 *pAddr2, u8 *pBssid, char Ssid[], - u8 * pSsidLen, - u8 * pBssType, - u16 * pBeaconPeriod, - u8 * pChannel, - u8 * pNewChannel, + u8 *pSsidLen, + u8 *pBssType, + u16 *pBeaconPeriod, + u8 *pChannel, + u8 *pNewChannel, OUT LARGE_INTEGER * pTimestamp, - struct rt_cf_parm * pCfParm, - u16 * pAtimWin, - u16 * pCapabilityInfo, - u8 * pErp, - u8 * pDtimCount, - u8 * pDtimPeriod, - u8 * pBcastFlag, - u8 * pMessageToMe, + struct rt_cf_parm *pCfParm, + u16 *pAtimWin, + u16 *pCapabilityInfo, + u8 *pErp, + u8 *pDtimCount, + u8 *pDtimPeriod, + u8 *pBcastFlag, + u8 *pMessageToMe, u8 SupRate[], - u8 * pSupRateLen, + u8 *pSupRateLen, u8 ExtRate[], - u8 * pExtRateLen, - u8 * pCkipFlag, - u8 * pAironetCellPowerLimit, + u8 *pExtRateLen, + u8 *pCkipFlag, + u8 *pAironetCellPowerLimit, struct rt_edca_parm *pEdcaParm, struct rt_qbss_load_parm *pQbssLoad, struct rt_qos_capability_parm *pQosCapability, - unsigned long * pRalinkIe, - u8 * pHtCapabilityLen, - u8 * pPreNHtCapabilityLen, - struct rt_ht_capability_ie * pHtCapability, - u8 * AddHtInfoLen, - struct rt_add_ht_info_ie * AddHtInfo, - u8 * NewExtChannel, - u16 * LengthVIE, + unsigned long *pRalinkIe, + u8 *pHtCapabilityLen, + u8 *pPreNHtCapabilityLen, + struct rt_ht_capability_ie *pHtCapability, + u8 *AddHtInfoLen, + struct rt_add_ht_info_ie *AddHtInfo, + u8 *NewExtChannel, + u16 *LengthVIE, struct rt_ndis_802_11_variable_ies *pVIE); BOOLEAN PeerAddBAReqActionSanity(struct rt_rtmp_adapter *pAd, - void * pMsg, + void *pMsg, unsigned long MsgLen, u8 *pAddr2); BOOLEAN PeerAddBARspActionSanity(struct rt_rtmp_adapter *pAd, - void * pMsg, unsigned long MsgLen); + void *pMsg, unsigned long MsgLen); BOOLEAN PeerDelBAActionSanity(struct rt_rtmp_adapter *pAd, - u8 Wcid, void * pMsg, unsigned long MsgLen); + u8 Wcid, void *pMsg, unsigned long MsgLen); BOOLEAN MlmeAssocReqSanity(struct rt_rtmp_adapter *pAd, - void * Msg, + void *Msg, unsigned long MsgLen, u8 *pApAddr, - u16 * CapabilityInfo, - unsigned long * Timeout, u16 * ListenIntv); + u16 *CapabilityInfo, + unsigned long *Timeout, u16 *ListenIntv); BOOLEAN MlmeAuthReqSanity(struct rt_rtmp_adapter *pAd, - void * Msg, + void *Msg, unsigned long MsgLen, u8 *pAddr, - unsigned long * Timeout, u16 * Alg); + unsigned long *Timeout, u16 *Alg); BOOLEAN MlmeStartReqSanity(struct rt_rtmp_adapter *pAd, - void * Msg, + void *Msg, unsigned long MsgLen, - char Ssid[], u8 * Ssidlen); + char Ssid[], u8 *Ssidlen); BOOLEAN PeerAuthSanity(struct rt_rtmp_adapter *pAd, - void * Msg, + void *Msg, unsigned long MsgLen, u8 *pAddr, - u16 * Alg, - u16 * Seq, - u16 * Status, char ChlgText[]); + u16 *Alg, + u16 *Seq, + u16 *Status, char ChlgText[]); -BOOLEAN PeerAssocRspSanity(struct rt_rtmp_adapter *pAd, void * pMsg, unsigned long MsgLen, u8 *pAddr2, u16 * pCapabilityInfo, u16 * pStatus, u16 * pAid, u8 SupRate[], u8 * pSupRateLen, u8 ExtRate[], u8 * pExtRateLen, struct rt_ht_capability_ie * pHtCapability, struct rt_add_ht_info_ie * pAddHtInfo, /* AP might use this additional ht info IE */ - u8 * pHtCapabilityLen, - u8 * pAddHtInfoLen, - u8 * pNewExtChannelOffset, - struct rt_edca_parm *pEdcaParm, u8 * pCkipFlag); +BOOLEAN PeerAssocRspSanity(struct rt_rtmp_adapter *pAd, void *pMsg, unsigned long MsgLen, u8 *pAddr2, u16 *pCapabilityInfo, u16 *pStatus, u16 *pAid, u8 SupRate[], u8 *pSupRateLen, u8 ExtRate[], u8 *pExtRateLen, struct rt_ht_capability_ie *pHtCapability, struct rt_add_ht_info_ie *pAddHtInfo, /* AP might use this additional ht info IE */ + u8 *pHtCapabilityLen, + u8 *pAddHtInfoLen, + u8 *pNewExtChannelOffset, + struct rt_edca_parm *pEdcaParm, u8 *pCkipFlag); BOOLEAN PeerDisassocSanity(struct rt_rtmp_adapter *pAd, - void * Msg, + void *Msg, unsigned long MsgLen, - u8 *pAddr2, u16 * Reason); + u8 *pAddr2, u16 *Reason); BOOLEAN PeerWpaMessageSanity(struct rt_rtmp_adapter *pAd, - struct rt_eapol_packet * pMsg, + struct rt_eapol_packet *pMsg, unsigned long MsgLen, u8 MsgType, struct rt_mac_table_entry *pEntry); BOOLEAN PeerDeauthSanity(struct rt_rtmp_adapter *pAd, - void * Msg, + void *Msg, unsigned long MsgLen, - u8 *pAddr2, u16 * Reason); + u8 *pAddr2, u16 *Reason); BOOLEAN PeerProbeReqSanity(struct rt_rtmp_adapter *pAd, - void * Msg, + void *Msg, unsigned long MsgLen, u8 *pAddr2, - char Ssid[], u8 * pSsidLen); + char Ssid[], u8 *pSsidLen); -BOOLEAN GetTimBit(char * Ptr, +BOOLEAN GetTimBit(char *Ptr, u16 Aid, - u8 * TimLen, - u8 * BcastFlag, - u8 * DtimCount, - u8 * DtimPeriod, u8 * MessageToMe); + u8 *TimLen, + u8 *BcastFlag, + u8 *DtimCount, + u8 *DtimPeriod, u8 *MessageToMe); u8 ChannelSanity(struct rt_rtmp_adapter *pAd, u8 channel); NDIS_802_11_NETWORK_TYPE NetworkTypeInUseSanity(struct rt_bss_entry *pBss); BOOLEAN MlmeDelBAReqSanity(struct rt_rtmp_adapter *pAd, - void * Msg, unsigned long MsgLen); + void *Msg, unsigned long MsgLen); BOOLEAN MlmeAddBAReqSanity(struct rt_rtmp_adapter *pAd, - void * Msg, unsigned long MsgLen, u8 *pAddr2); + void *Msg, unsigned long MsgLen, u8 *pAddr2); -unsigned long MakeOutgoingFrame(u8 * Buffer, unsigned long * Length, ...); +unsigned long MakeOutgoingFrame(u8 *Buffer, unsigned long *Length, ...); void LfsrInit(struct rt_rtmp_adapter *pAd, unsigned long Seed); @@ -3215,7 +3204,7 @@ void MlmeSetTxRate(struct rt_rtmp_adapter *pAd, void MlmeSelectTxRateTable(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry, - u8 ** ppTable, + u8 **ppTable, u8 *pTableSize, u8 *pInitTxRateIdx); void MlmeCalculateChannelQuality(struct rt_rtmp_adapter *pAd, @@ -3235,15 +3224,15 @@ void MlmeUpdateTxRates(struct rt_rtmp_adapter *pAd, void MlmeUpdateHtTxRates(struct rt_rtmp_adapter *pAd, u8 apidx); void RTMPCheckRates(struct rt_rtmp_adapter *pAd, - IN u8 SupRate[], IN u8 * SupRateLen); + IN u8 SupRate[], IN u8 *SupRateLen); BOOLEAN RTMPCheckChannel(struct rt_rtmp_adapter *pAd, u8 CentralChannel, u8 Channel); BOOLEAN RTMPCheckHt(struct rt_rtmp_adapter *pAd, u8 Wcid, - struct rt_ht_capability_ie * pHtCapability, - struct rt_add_ht_info_ie * pAddHtInfo); + struct rt_ht_capability_ie *pHtCapability, + struct rt_add_ht_info_ie *pAddHtInfo); void StaQuickResponeForRateUpExec(void *SystemSpecific1, void *FunctionContext, @@ -3268,7 +3257,7 @@ int set_eFusedump_Proc(struct rt_rtmp_adapter *pAd, char *arg); void eFusePhysicalReadRegisters(struct rt_rtmp_adapter *pAd, u16 Offset, - u16 Length, u16 * pData); + u16 Length, u16 *pData); int RtmpEfuseSupportCheck(struct rt_rtmp_adapter *pAd); @@ -3391,7 +3380,7 @@ int RT_CfgSetWepKey(struct rt_rtmp_adapter *pAd, int RT_CfgSetWPAPSKKey(struct rt_rtmp_adapter *pAd, char *keyString, - u8 * pHashStr, + u8 *pHashStr, int hashStrLen, u8 *pPMKBuf); /* */ @@ -3402,9 +3391,9 @@ void RTMPWPARemoveAllKeys(struct rt_rtmp_adapter *pAd); void RTMPSetPhyMode(struct rt_rtmp_adapter *pAd, unsigned long phymode); void RTMPUpdateHTIE(struct rt_ht_capability *pRtHt, - u8 * pMcsSet, - struct rt_ht_capability_ie * pHtCapability, - struct rt_add_ht_info_ie * pAddHtInfo); + u8 *pMcsSet, + struct rt_ht_capability_ie *pHtCapability, + struct rt_add_ht_info_ie *pAddHtInfo); void RTMPAddWcidAttributeEntry(struct rt_rtmp_adapter *pAd, u8 BssIdx, @@ -3436,22 +3425,22 @@ void RTMPToWirelessSta(struct rt_rtmp_adapter *pAd, u32 DataLen, IN BOOLEAN bClearFrame); void WpaDerivePTK(struct rt_rtmp_adapter *pAd, - u8 * PMK, - u8 * ANonce, - u8 * AA, - u8 * SNonce, - u8 * SA, u8 * output, u32 len); + u8 *PMK, + u8 *ANonce, + u8 *AA, + u8 *SNonce, + u8 *SA, u8 *output, u32 len); -void GenRandom(struct rt_rtmp_adapter *pAd, u8 * macAddr, u8 * random); +void GenRandom(struct rt_rtmp_adapter *pAd, u8 *macAddr, u8 *random); BOOLEAN RTMPCheckWPAframe(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry, u8 *pData, unsigned long DataByteCount, u8 FromWhichBSSID); -void AES_GTK_KEY_UNWRAP(u8 * key, - u8 * plaintext, - u32 c_len, u8 * ciphertext); +void AES_GTK_KEY_UNWRAP(u8 *key, + u8 *plaintext, + u32 c_len, u8 *ciphertext); BOOLEAN RTMPParseEapolKeyData(struct rt_rtmp_adapter *pAd, u8 *pKeyData, @@ -3464,11 +3453,11 @@ void ConstructEapolMsg(struct rt_mac_table_entry *pEntry, u8 GroupKeyWepStatus, u8 MsgType, u8 DefaultKeyIdx, - u8 * KeyNonce, - u8 * TxRSC, - u8 * GTK, - u8 * RSNIE, - u8 RSNIE_Len, struct rt_eapol_packet * pMsg); + u8 *KeyNonce, + u8 *TxRSC, + u8 *GTK, + u8 *RSNIE, + u8 RSNIE_Len, struct rt_eapol_packet *pMsg); int RTMPSoftDecryptBroadCastData(struct rt_rtmp_adapter *pAd, struct rt_rx_blk *pRxBlk, @@ -3515,66 +3504,66 @@ void PeerGroupMsg1Action(struct rt_rtmp_adapter *pAd, void PeerGroupMsg2Action(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry, - void * Msg, u32 MsgLen); + void *Msg, u32 MsgLen); -void WpaDeriveGTK(u8 * PMK, - u8 * GNonce, - u8 * AA, u8 * output, u32 len); +void WpaDeriveGTK(u8 *PMK, + u8 *GNonce, + u8 *AA, u8 *output, u32 len); -void AES_GTK_KEY_WRAP(u8 * key, - u8 * plaintext, - u32 p_len, u8 * ciphertext); +void AES_GTK_KEY_WRAP(u8 *key, + u8 *plaintext, + u32 p_len, u8 *ciphertext); /*typedef void (*TIMER_FUNCTION)(unsigned long); */ /* timeout -- ms */ -void RTMP_SetPeriodicTimer(struct timer_list * pTimer, +void RTMP_SetPeriodicTimer(struct timer_list *pTimer, IN unsigned long timeout); void RTMP_OS_Init_Timer(struct rt_rtmp_adapter *pAd, - struct timer_list * pTimer, + struct timer_list *pTimer, IN TIMER_FUNCTION function, void *data); -void RTMP_OS_Add_Timer(struct timer_list * pTimer, +void RTMP_OS_Add_Timer(struct timer_list *pTimer, IN unsigned long timeout); -void RTMP_OS_Mod_Timer(struct timer_list * pTimer, +void RTMP_OS_Mod_Timer(struct timer_list *pTimer, IN unsigned long timeout); -void RTMP_OS_Del_Timer(struct timer_list * pTimer, - OUT BOOLEAN * pCancelled); +void RTMP_OS_Del_Timer(struct timer_list *pTimer, + OUT BOOLEAN *pCancelled); void RTMP_OS_Release_Packet(struct rt_rtmp_adapter *pAd, struct rt_queue_entry *pEntry); void RTMPusecDelay(unsigned long usec); int os_alloc_mem(struct rt_rtmp_adapter *pAd, - u8 ** mem, unsigned long size); + u8 **mem, unsigned long size); int os_free_mem(struct rt_rtmp_adapter *pAd, void *mem); void RTMP_AllocateSharedMemory(struct rt_rtmp_adapter *pAd, unsigned long Length, IN BOOLEAN Cached, - void ** VirtualAddress, + void **VirtualAddress, dma_addr_t *PhysicalAddress); void RTMPFreeTxRxRingMemory(struct rt_rtmp_adapter *pAd); -int AdapterBlockAllocateMemory(void *handle, void ** ppAd); +int AdapterBlockAllocateMemory(void *handle, void **ppAd); void RTMP_AllocateTxDescMemory(struct rt_rtmp_adapter *pAd, u32 Index, unsigned long Length, IN BOOLEAN Cached, - void ** VirtualAddress, + void **VirtualAddress, dma_addr_t *PhysicalAddress); void RTMP_AllocateFirstTxBuffer(struct rt_rtmp_adapter *pAd, u32 Index, unsigned long Length, IN BOOLEAN Cached, - void ** VirtualAddress, + void **VirtualAddress, dma_addr_t *PhysicalAddress); void RTMP_FreeFirstTxBuffer(struct rt_rtmp_adapter *pAd, @@ -3586,13 +3575,13 @@ void RTMP_FreeFirstTxBuffer(struct rt_rtmp_adapter *pAd, void RTMP_AllocateMgmtDescMemory(struct rt_rtmp_adapter *pAd, unsigned long Length, IN BOOLEAN Cached, - void ** VirtualAddress, + void **VirtualAddress, dma_addr_t *PhysicalAddress); void RTMP_AllocateRxDescMemory(struct rt_rtmp_adapter *pAd, unsigned long Length, IN BOOLEAN Cached, - void ** VirtualAddress, + void **VirtualAddress, dma_addr_t *PhysicalAddress); void RTMP_FreeDescMemory(struct rt_rtmp_adapter *pAd, @@ -3605,30 +3594,29 @@ void *RtmpOSNetPktAlloc(struct rt_rtmp_adapter *pAd, IN int size); void *RTMP_AllocateRxPacketBuffer(struct rt_rtmp_adapter *pAd, unsigned long Length, IN BOOLEAN Cached, - void ** VirtualAddress, - OUT dma_addr_t * - PhysicalAddress); + void **VirtualAddress, + OUT dma_addr_t *PhysicalAddress); void *RTMP_AllocateTxPacketBuffer(struct rt_rtmp_adapter *pAd, unsigned long Length, IN BOOLEAN Cached, - void ** VirtualAddress); + void **VirtualAddress); void *RTMP_AllocateFragPacketBuffer(struct rt_rtmp_adapter *pAd, unsigned long Length); void RTMP_QueryPacketInfo(void *pPacket, struct rt_packet_info *pPacketInfo, - u8 ** pSrcBufVA, u32 * pSrcBufLen); + u8 **pSrcBufVA, u32 *pSrcBufLen); -void RTMP_QueryNextPacketInfo(void ** ppPacket, +void RTMP_QueryNextPacketInfo(void **ppPacket, struct rt_packet_info *pPacketInfo, - u8 ** pSrcBufVA, u32 * pSrcBufLen); + u8 **pSrcBufVA, u32 *pSrcBufLen); BOOLEAN RTMP_FillTxBlkInfo(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk); -struct rt_rtmp_sg_list * -rt_get_sg_list_from_packet(void *pPacket, struct rt_rtmp_sg_list *sg); +struct rt_rtmp_sg_list *rt_get_sg_list_from_packet(void *pPacket, + struct rt_rtmp_sg_list *sg); void announce_802_3_packet(struct rt_rtmp_adapter *pAd, void *pPacket); @@ -3717,23 +3705,19 @@ void wlan_802_11_to_802_3_packet(struct rt_rtmp_adapter *pAd, { \ u8 *_pRemovedLLCSNAP = NULL, *_pDA, *_pSA; \ \ - if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_MESH)) \ - { \ + if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_MESH)) { \ _pDA = _pRxBlk->pHeader->Addr3; \ _pSA = (u8 *)_pRxBlk->pHeader + sizeof(struct rt_header_802_11); \ } \ - else \ - { \ - if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_INFRA)) \ - { \ + else {\ + if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_INFRA)) {\ _pDA = _pRxBlk->pHeader->Addr1; \ if (RX_BLK_TEST_FLAG(_pRxBlk, fRX_DLS)) \ _pSA = _pRxBlk->pHeader->Addr2; \ else \ _pSA = _pRxBlk->pHeader->Addr3; \ } \ - else \ - { \ + else { \ _pDA = _pRxBlk->pHeader->Addr1; \ _pSA = _pRxBlk->pHeader->Addr2; \ } \ @@ -3771,8 +3755,8 @@ void Update_Rssi_Sample(struct rt_rtmp_adapter *pAd, void *GetPacketFromRxRing(struct rt_rtmp_adapter *pAd, OUT PRT28XX_RXD_STRUC pSaveRxD, - OUT BOOLEAN * pbReschedule, - IN u32 * pRxPending); + OUT BOOLEAN *pbReschedule, + IN u32 *pRxPending); void *RTMPDeFragmentDataFrame(struct rt_rtmp_adapter *pAd, struct rt_rx_blk *pRxBlk); @@ -3919,24 +3903,24 @@ BOOLEAN RtmpRaDevCtrlExit(struct rt_rtmp_adapter *pAd); /* */ u16 RtmpPCI_WriteTxResource(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk, - IN BOOLEAN bIsLast, u16 * FreeNumber); + IN BOOLEAN bIsLast, u16 *FreeNumber); u16 RtmpPCI_WriteSingleTxResource(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk, IN BOOLEAN bIsLast, - u16 * FreeNumber); + u16 *FreeNumber); u16 RtmpPCI_WriteMultiTxResource(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk, - u8 frameNum, u16 * FreeNumber); + u8 frameNum, u16 *FreeNumber); u16 RtmpPCI_WriteFragTxResource(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk, - u8 fragNum, u16 * FreeNumber); + u8 fragNum, u16 *FreeNumber); u16 RtmpPCI_WriteSubTxResource(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk, - IN BOOLEAN bIsLast, u16 * FreeNumber); + IN BOOLEAN bIsLast, u16 *FreeNumber); void RtmpPCI_FinalWriteTxResource(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk, @@ -3955,8 +3939,8 @@ int RtmpPCIMgmtKickOut(struct rt_rtmp_adapter *pAd, u8 *pSrcBufVA, u32 SrcBufLen); int RTMPCheckRxError(struct rt_rtmp_adapter *pAd, - struct rt_header_802_11 * pHeader, - struct rt_rxwi * pRxWI, IN PRT28XX_RXD_STRUC pRxD); + struct rt_header_802_11 *pHeader, + struct rt_rxwi *pRxWI, IN PRT28XX_RXD_STRUC pRxD); BOOLEAN RT28xxPciAsicRadioOff(struct rt_rtmp_adapter *pAd, u8 Level, u16 TbttNumToNextWakeUp); @@ -4138,15 +4122,15 @@ void append_pkt(struct rt_rtmp_adapter *pAd, u8 *pHeader802_3, u32 HdrLen, u8 *pData, - unsigned long DataSize, void ** ppPacket); + unsigned long DataSize, void **ppPacket); u32 deaggregate_AMSDU_announce(struct rt_rtmp_adapter *pAd, void *pPacket, u8 *pData, unsigned long DataSize); int RTMPCheckRxError(struct rt_rtmp_adapter *pAd, - struct rt_header_802_11 * pHeader, - struct rt_rxwi * pRxWI, + struct rt_header_802_11 *pHeader, + struct rt_rxwi *pRxWI, IN PRT28XX_RXD_STRUC pRxINFO); void RTUSBMlmeHardTransmit(struct rt_rtmp_adapter *pAd, struct rt_mgmt *pMgmt); @@ -4173,20 +4157,20 @@ void RTMPWriteTxInfo(struct rt_rtmp_adapter *pAd, /* */ u16 RtmpUSB_WriteSubTxResource(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk, - IN BOOLEAN bIsLast, u16 * FreeNumber); + IN BOOLEAN bIsLast, u16 *FreeNumber); u16 RtmpUSB_WriteSingleTxResource(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk, IN BOOLEAN bIsLast, - u16 * FreeNumber); + u16 *FreeNumber); u16 RtmpUSB_WriteFragTxResource(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk, - u8 fragNum, u16 * FreeNumber); + u8 fragNum, u16 *FreeNumber); u16 RtmpUSB_WriteMultiTxResource(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk, - u8 frameNum, u16 * FreeNumber); + u8 frameNum, u16 *FreeNumber); void RtmpUSB_FinalWriteTxResource(struct rt_rtmp_adapter *pAd, struct rt_tx_blk *pTxBlk, @@ -4205,7 +4189,7 @@ int RtmpUSBMgmtKickOut(struct rt_rtmp_adapter *pAd, void RtmpUSBNullFrameKickOut(struct rt_rtmp_adapter *pAd, u8 QueIdx, - u8 * pNullFrame, u32 frameLen); + u8 *pNullFrame, u32 frameLen); void RtmpUsbStaAsicForceWakeupTimeout(void *SystemSpecific1, void *FunctionContext, @@ -4245,9 +4229,9 @@ void AsicStaBbpTuning(struct rt_rtmp_adapter *pAd); BOOLEAN StaAddMacTableEntry(struct rt_rtmp_adapter *pAd, struct rt_mac_table_entry *pEntry, u8 MaxSupportedRateIn500Kbps, - struct rt_ht_capability_ie * pHtCapability, + struct rt_ht_capability_ie *pHtCapability, u8 HtCapabilityLen, - struct rt_add_ht_info_ie * pAddHtInfo, + struct rt_add_ht_info_ie *pAddHtInfo, u8 AddHtInfoLen, u16 CapabilityInfo); BOOLEAN AUTH_ReqSend(struct rt_rtmp_adapter *pAd, @@ -4313,7 +4297,7 @@ void RtmpOSNetDevClose(struct net_device *pNetDev); void RtmpOSNetDevDetach(struct net_device *pNetDev); -int RtmpOSNetDevAlloc(struct net_device ** pNewNetDev, u32 privDataSize); +int RtmpOSNetDevAlloc(struct net_device **pNewNetDev, u32 privDataSize); void RtmpOSNetDevFree(struct net_device *pNetDev); diff --git a/drivers/staging/rt2860/sta/assoc.c b/drivers/staging/rt2860/sta/assoc.c index 7055f229e511..6e85d5e6554b 100644 --- a/drivers/staging/rt2860/sta/assoc.c +++ b/drivers/staging/rt2860/sta/assoc.c @@ -1596,7 +1596,6 @@ BOOLEAN StaAddMacTableEntry(struct rt_rtmp_adapter *pAd, union iwreq_data wrqu; wext_notify_event_assoc(pAd); - memset(wrqu.ap_addr.sa_data, 0, MAC_ADDR_LEN); memcpy(wrqu.ap_addr.sa_data, pAd->MlmeAux.Bssid, MAC_ADDR_LEN); wireless_send_event(pAd->net_dev, SIOCGIWAP, &wrqu, NULL); diff --git a/drivers/staging/rt2860/sta_ioctl.c b/drivers/staging/rt2860/sta_ioctl.c index de4b6277baee..112da7a6c417 100644 --- a/drivers/staging/rt2860/sta_ioctl.c +++ b/drivers/staging/rt2860/sta_ioctl.c @@ -608,7 +608,6 @@ int rt_ioctl_siwap(struct net_device *dev, /* Prevent to connect AP again in STAMlmePeriodicExec */ pAdapter->MlmeAux.AutoReconnectSsidLen = 32; - memset(Bssid, 0, MAC_ADDR_LEN); memcpy(Bssid, ap_addr->sa_data, MAC_ADDR_LEN); MlmeEnqueue(pAdapter, MLME_CNTL_STATE_MACHINE, @@ -1047,8 +1046,7 @@ int rt_ioctl_giwscan(struct net_device *dev, if (tmpRate == 0x6c && pAdapter->ScanTab.BssEntry[i].HtCapabilityLen > 0) { - int rate_count = - sizeof(ralinkrate) / sizeof(__s32); + int rate_count = ARRAY_SIZE(ralinkrate); struct rt_ht_cap_info capInfo = pAdapter->ScanTab.BssEntry[i].HtCapability. HtCapInfo; @@ -1061,10 +1059,11 @@ int rt_ioctl_giwscan(struct net_device *dev, int rate_index = 12 + ((u8)capInfo.ChannelWidth * 24) + ((u8)shortGI * 48) + ((u8)maxMCS); + if (rate_index < 0) rate_index = 0; - if (rate_index > rate_count) - rate_index = rate_count; + if (rate_index >= rate_count) + rate_index = rate_count - 1; iwe.u.bitrate.value = ralinkrate[rate_index] * 500000; } @@ -2338,7 +2337,7 @@ int rt_ioctl_giwrate(struct net_device *dev, */ GET_PAD_FROM_NET_DEV(pAd, dev); - rate_count = sizeof(ralinkrate) / sizeof(__s32); + rate_count = ARRAY_SIZE(ralinkrate); /*check if the interface is down */ if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_INTERRUPT_IN_USE)) { DBGPRINT(RT_DEBUG_TRACE, ("INFO::Network is down!\n")); @@ -2369,8 +2368,8 @@ int rt_ioctl_giwrate(struct net_device *dev, if (rate_index < 0) rate_index = 0; - if (rate_index > rate_count) - rate_index = rate_count; + if (rate_index >= rate_count) + rate_index = rate_count - 1; wrqu->bitrate.value = ralinkrate[rate_index] * 500000; wrqu->bitrate.disabled = 0; diff --git a/drivers/staging/rt2860/usb_main_dev.c b/drivers/staging/rt2860/usb_main_dev.c index 740db0c1ac01..438135de504e 100644 --- a/drivers/staging/rt2860/usb_main_dev.c +++ b/drivers/staging/rt2860/usb_main_dev.c @@ -154,7 +154,7 @@ static void rt2870_disconnect(struct usb_device *dev, struct rt_rtmp_adapter *pA static int __devinit rt2870_probe(IN struct usb_interface *intf, IN struct usb_device *usb_dev, IN const struct usb_device_id *dev_id, - struct rt_rtmp_adapter ** ppAd); + struct rt_rtmp_adapter **ppAd); #ifndef PF_NOFREEZE #define PF_NOFREEZE 0 @@ -802,7 +802,7 @@ static void rt2870_disconnect(struct usb_device *dev, struct rt_rtmp_adapter *pA static int __devinit rt2870_probe(IN struct usb_interface *intf, IN struct usb_device *usb_dev, IN const struct usb_device_id *dev_id, - struct rt_rtmp_adapter ** ppAd) + struct rt_rtmp_adapter **ppAd) { struct net_device *net_dev = NULL; struct rt_rtmp_adapter *pAd = (struct rt_rtmp_adapter *)NULL; diff --git a/drivers/staging/rt2870/Kconfig b/drivers/staging/rt2870/Kconfig index 6ea172b433e9..e988680b5be4 100644 --- a/drivers/staging/rt2870/Kconfig +++ b/drivers/staging/rt2870/Kconfig @@ -1,6 +1,6 @@ config RT2870 tristate "Ralink 2870/3070 wireless support" - depends on USB && X86 && WLAN + depends on USB && (X86 || ARM) && WLAN select WIRELESS_EXT select WEXT_PRIV select CRC_CCITT diff --git a/drivers/staging/rt2870/common/rtusb_bulk.c b/drivers/staging/rt2870/common/rtusb_bulk.c index 379780c72b3c..d2746f8732e6 100644 --- a/drivers/staging/rt2870/common/rtusb_bulk.c +++ b/drivers/staging/rt2870/common/rtusb_bulk.c @@ -172,11 +172,11 @@ void RTUSBInitRxDesc(struct rt_rtmp_adapter *pAd, struct rt_rx_context *pRxConte */ #define BULK_OUT_LOCK(pLock, IrqFlags) \ - if(1 /*!(in_interrupt() & 0xffff0000)*/) \ + if (1 /*!(in_interrupt() & 0xffff0000)*/) \ RTMP_IRQ_LOCK((pLock), IrqFlags); #define BULK_OUT_UNLOCK(pLock, IrqFlags) \ - if(1 /*!(in_interrupt() & 0xffff0000)*/) \ + if (1 /*!(in_interrupt() & 0xffff0000)*/) \ RTMP_IRQ_UNLOCK((pLock), IrqFlags); void RTUSBBulkOutDataPacket(struct rt_rtmp_adapter *pAd, @@ -187,7 +187,7 @@ void RTUSBBulkOutDataPacket(struct rt_rtmp_adapter *pAd, PURB pUrb; int ret = 0; struct rt_txinfo *pTxInfo, *pLastTxInfo = NULL; - struct rt_txwi * pTxWI; + struct rt_txwi *pTxWI; unsigned long TmpBulkEndPos, ThisBulkSize; unsigned long IrqFlags = 0, IrqFlags2 = 0; u8 *pWirelessPkt, *pAppendant; @@ -273,9 +273,9 @@ void RTUSBBulkOutDataPacket(struct rt_rtmp_adapter *pAd, } do { - pTxInfo = (struct rt_txinfo *)& pWirelessPkt[TmpBulkEndPos]; + pTxInfo = (struct rt_txinfo *)&pWirelessPkt[TmpBulkEndPos]; pTxWI = - (struct rt_txwi *) & pWirelessPkt[TmpBulkEndPos + TXINFO_SIZE]; + (struct rt_txwi *)&pWirelessPkt[TmpBulkEndPos + TXINFO_SIZE]; if (pAd->bForcePrintTX == TRUE) DBGPRINT(RT_DEBUG_TRACE, @@ -310,7 +310,7 @@ void RTUSBBulkOutDataPacket(struct rt_rtmp_adapter *pAd, pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos; break; - } else if (((pAd->BulkOutMaxPacketSize < 512) && ((ThisBulkSize & 0xfffff800) != 0)) /*|| ( (ThisBulkSize != 0) && (pTxWI->AMPDU == 0)) */ ) { /* For USB 1.1 or peer which didn't support AMPDU, limit the BulkOut size. */ + } else if (((pAd->BulkOutMaxPacketSize < 512) && ((ThisBulkSize & 0xfffff800) != 0)) /*|| ( (ThisBulkSize != 0) && (pTxWI->AMPDU == 0)) */) { /* For USB 1.1 or peer which didn't support AMPDU, limit the BulkOut size. */ /* For performence in b/g mode, now just check for USB 1.1 and didn't care about the APMDU or not! 2008/06/04. */ pHTTXContext->ENextBulkOutPosition = TmpBulkEndPos; @@ -326,7 +326,7 @@ void RTUSBBulkOutDataPacket(struct rt_rtmp_adapter *pAd, if (pTxInfo->QSEL != FIFO_EDCA) { DBGPRINT(RT_DEBUG_ERROR, ("%s(): ====> pTxInfo->QueueSel(%d)!= FIFO_EDCA!!!!\n", - __FUNCTION__, pTxInfo->QSEL)); + __func__, pTxInfo->QSEL)); DBGPRINT(RT_DEBUG_ERROR, ("\tCWPos=%ld, NBPos=%ld, ENBPos=%ld, bCopy=%d!\n", pHTTXContext->CurWritePosition, @@ -334,7 +334,7 @@ void RTUSBBulkOutDataPacket(struct rt_rtmp_adapter *pAd, pHTTXContext->ENextBulkOutPosition, pHTTXContext->bCopySavePad)); hex_dump("Wrong QSel Pkt:", - (u8 *)& pWirelessPkt[TmpBulkEndPos], + (u8 *)&pWirelessPkt[TmpBulkEndPos], (pHTTXContext->CurWritePosition - pHTTXContext->NextBulkOutPosition)); } @@ -401,9 +401,8 @@ void RTUSBBulkOutDataPacket(struct rt_rtmp_adapter *pAd, } while (TRUE); /* adjust the pTxInfo->USBDMANextVLD value of last pTxInfo. */ - if (pLastTxInfo) { + if (pLastTxInfo) pLastTxInfo->USBDMANextVLD = 0; - } /* We need to copy SavedPad when following condition matched! @@ -475,7 +474,8 @@ void RTUSBBulkOutDataPacket(struct rt_rtmp_adapter *pAd, (usb_complete_t) RTUSBBulkOutDataPacketComplete); pUrb = pHTTXContext->pUrb; - if ((ret = RTUSB_SUBMIT_URB(pUrb)) != 0) { + ret = RTUSB_SUBMIT_URB(pUrb); + if (ret != 0) { DBGPRINT(RT_DEBUG_ERROR, ("RTUSBBulkOutDataPacket: Submit Tx URB failed %d\n", ret)); @@ -573,7 +573,8 @@ void RTUSBBulkOutNullFrame(struct rt_rtmp_adapter *pAd) (usb_complete_t) RTUSBBulkOutNullFrameComplete); pUrb = pNullContext->pUrb; - if ((ret = RTUSB_SUBMIT_URB(pUrb)) != 0) { + ret = RTUSB_SUBMIT_URB(pUrb); + if (ret != 0) { RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], IrqFlags); pAd->BulkOutPending[0] = FALSE; pAd->watchDogTxPendingCnt[0] = 0; @@ -667,7 +668,8 @@ void RTUSBBulkOutMLMEPacket(struct rt_rtmp_adapter *pAd, u8 Index) pUrb->transfer_flags &= (~URB_NO_TRANSFER_DMA_MAP); pUrb = pMLMEContext->pUrb; - if ((ret = RTUSB_SUBMIT_URB(pUrb)) != 0) { + ret = RTUSB_SUBMIT_URB(pUrb); + if (ret != 0) { DBGPRINT(RT_DEBUG_ERROR, ("RTUSBBulkOutMLMEPacket: Submit MLME URB failed %d\n", ret)); @@ -742,7 +744,8 @@ void RTUSBBulkOutPsPoll(struct rt_rtmp_adapter *pAd) (usb_complete_t) RTUSBBulkOutPsPollComplete); pUrb = pPsPollContext->pUrb; - if ((ret = RTUSB_SUBMIT_URB(pUrb)) != 0) { + ret = RTUSB_SUBMIT_URB(pUrb); + if (ret != 0) { RTMP_IRQ_LOCK(&pAd->BulkOutLock[0], IrqFlags); pAd->BulkOutPending[0] = FALSE; pAd->watchDogTxPendingCnt[0] = 0; @@ -799,7 +802,8 @@ void DoBulkIn(struct rt_rtmp_adapter *pAd) RTUSBInitRxDesc(pAd, pRxContext); pUrb = pRxContext->pUrb; - if ((ret = RTUSB_SUBMIT_URB(pUrb)) != 0) { /* fail */ + ret = RTUSB_SUBMIT_URB(pUrb); + if (ret != 0) { /* fail */ RTMP_IRQ_LOCK(&pAd->BulkInLock, IrqFlags); pRxContext->InUse = FALSE; @@ -949,9 +953,8 @@ void RTUSBKickBulkOut(struct rt_rtmp_adapter *pAd) if (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NEED_STOP_TX) ) { /* 2. PS-Poll frame is next */ - if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL)) { + if (RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_PSPOLL)) RTUSBBulkOutPsPoll(pAd); - } /* 5. Mlme frame is next */ else if ((RTUSB_TEST_BULK_FLAG(pAd, fRTUSB_BULK_OUT_MLME)) || (pAd->MgmtRing.TxSwFreeIdx < MGMT_RING_SIZE)) { @@ -1014,9 +1017,8 @@ void RTUSBKickBulkOut(struct rt_rtmp_adapter *pAd) } } /* 8. No data avaliable */ - else { - - } + else + ; } } diff --git a/drivers/staging/rt2870/common/rtusb_data.c b/drivers/staging/rt2870/common/rtusb_data.c index 4583764c78d2..69368862217c 100644 --- a/drivers/staging/rt2870/common/rtusb_data.c +++ b/drivers/staging/rt2870/common/rtusb_data.c @@ -124,7 +124,7 @@ int RTUSBFreeDescriptorRequest(struct rt_rtmp_adapter *pAd, } RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); - return (Status); + return Status; } int RTUSBFreeDescriptorRelease(struct rt_rtmp_adapter *pAd, @@ -138,7 +138,7 @@ int RTUSBFreeDescriptorRelease(struct rt_rtmp_adapter *pAd, pHTTXContext->bCurWriting = FALSE; RTMP_IRQ_UNLOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); - return (NDIS_STATUS_SUCCESS); + return NDIS_STATUS_SUCCESS; } BOOLEAN RTUSBNeedQueueBackForAgg(struct rt_rtmp_adapter *pAd, u8 BulkOutPipeId) @@ -151,7 +151,7 @@ BOOLEAN RTUSBNeedQueueBackForAgg(struct rt_rtmp_adapter *pAd, u8 BulkOutPipeId) RTMP_IRQ_LOCK(&pAd->TxContextQueueLock[BulkOutPipeId], IrqFlags); if ((pHTTXContext->IRPPending == - TRUE) /*&& (pAd->TxSwQueue[BulkOutPipeId].Number == 0) */ ) { + TRUE) /*&& (pAd->TxSwQueue[BulkOutPipeId].Number == 0) */) { if ((pHTTXContext->CurWritePosition < pHTTXContext->ENextBulkOutPosition) && @@ -201,7 +201,7 @@ void RTUSBRejectPendingPackets(struct rt_rtmp_adapter *pAd) for (Index = 0; Index < 4; Index++) { NdisAcquireSpinLock(&pAd->TxSwQueueLock[Index]); while (pAd->TxSwQueue[Index].Head != NULL) { - pQueue = (struct rt_queue_header *)& (pAd->TxSwQueue[Index]); + pQueue = (struct rt_queue_header *)&(pAd->TxSwQueue[Index]); pEntry = RemoveHeadQueue(pQueue); pPacket = QUEUE_ENTRY_TO_PACKET(pEntry); RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_FAILURE); diff --git a/drivers/staging/rt2870/common/rtusb_io.c b/drivers/staging/rt2870/common/rtusb_io.c index cf0d2f5dbc6c..6b9ca24bbee9 100644 --- a/drivers/staging/rt2870/common/rtusb_io.c +++ b/drivers/staging/rt2870/common/rtusb_io.c @@ -24,7 +24,7 @@ * * ************************************************************************* - Module Name: + Module Name: rtusb_io.c Abstract: @@ -400,8 +400,7 @@ int RTUSBWriteBBPRegister(struct rt_rtmp_adapter *pAd, ("RTUSBWriteBBPRegister(BBP_CSR_CFG):retry count=%d!\n", i)); i++; - } - while ((i < RETRY_LIMIT) + } while ((i < RETRY_LIMIT) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))); if ((i == RETRY_LIMIT) @@ -455,8 +454,7 @@ int RTUSBWriteRFRegister(struct rt_rtmp_adapter *pAd, u32 Value) ("RTUSBWriteRFRegister(RF_CSR_CFG0):retry count=%d!\n", i)); i++; - } - while ((i < RETRY_LIMIT) + } while ((i < RETRY_LIMIT) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))); if ((i == RETRY_LIMIT) @@ -652,11 +650,11 @@ int RTUSBEnqueueCmdFromNdis(struct rt_rtmp_adapter *pAd, } else #endif - return (NDIS_STATUS_RESOURCES); + return NDIS_STATUS_RESOURCES; status = os_alloc_mem(pAd, (u8 **) (&cmdqelmt), sizeof(struct rt_cmdqelmt)); if ((status != NDIS_STATUS_SUCCESS) || (cmdqelmt == NULL)) - return (NDIS_STATUS_RESOURCES); + return NDIS_STATUS_RESOURCES; cmdqelmt->buffer = NULL; if (pInformationBuffer != NULL) { @@ -666,7 +664,7 @@ int RTUSBEnqueueCmdFromNdis(struct rt_rtmp_adapter *pAd, if ((status != NDIS_STATUS_SUCCESS) || (cmdqelmt->buffer == NULL)) { kfree(cmdqelmt); - return (NDIS_STATUS_RESOURCES); + return NDIS_STATUS_RESOURCES; } else { NdisMoveMemory(cmdqelmt->buffer, pInformationBuffer, InformationBufferLength); @@ -698,7 +696,7 @@ int RTUSBEnqueueCmdFromNdis(struct rt_rtmp_adapter *pAd, } else RTUSBCMDUp(pAd); - return (NDIS_STATUS_SUCCESS); + return NDIS_STATUS_SUCCESS; } /* @@ -726,7 +724,7 @@ int RTUSBEnqueueInternalCmd(struct rt_rtmp_adapter *pAd, status = os_alloc_mem(pAd, (u8 **) & cmdqelmt, sizeof(struct rt_cmdqelmt)); if ((status != NDIS_STATUS_SUCCESS) || (cmdqelmt == NULL)) - return (NDIS_STATUS_RESOURCES); + return NDIS_STATUS_RESOURCES; NdisZeroMemory(cmdqelmt, sizeof(struct rt_cmdqelmt)); if (InformationBufferLength > 0) { @@ -736,7 +734,7 @@ int RTUSBEnqueueInternalCmd(struct rt_rtmp_adapter *pAd, if ((status != NDIS_STATUS_SUCCESS) || (cmdqelmt->buffer == NULL)) { os_free_mem(pAd, cmdqelmt); - return (NDIS_STATUS_RESOURCES); + return NDIS_STATUS_RESOURCES; } else { NdisMoveMemory(cmdqelmt->buffer, pInformationBuffer, InformationBufferLength); @@ -767,7 +765,7 @@ int RTUSBEnqueueInternalCmd(struct rt_rtmp_adapter *pAd, } else RTUSBCMDUp(pAd); } - return (NDIS_STATUS_SUCCESS); + return NDIS_STATUS_SUCCESS; } /* @@ -1071,7 +1069,7 @@ void CMDHandler(struct rt_rtmp_adapter *pAd) TXRXQ_PCNT, &MACValue); if ((MACValue & 0xf00000 - /*0x800000 */ ) == 0) + /*0x800000 */) == 0) break; Index++; RTMPusecDelay(10000); @@ -1169,11 +1167,10 @@ void CMDHandler(struct rt_rtmp_adapter *pAd) (usb_complete_t) RTUSBBulkOutDataPacketComplete); - if ((ret = - RTUSB_SUBMIT_URB + ret = RTUSB_SUBMIT_URB (pHTTXContext-> - pUrb)) != - 0) { + pUrb); + if (ret != 0) { RTMP_INT_LOCK (&pAd-> BulkOutLock @@ -1406,15 +1403,13 @@ void CMDHandler(struct rt_rtmp_adapter *pAd) /* All transfers must be aborted or cancelled before attempting to reset the pipe. */ { u32 MACValue; - { /*while ((atomic_read(&pAd->PendingRx) > 0) && (!RTMP_TEST_FLAG(pAd, fRTMP_ADAPTER_NIC_NOT_EXIST))) */ if ((pAd->PendingRx > 0) && (!RTMP_TEST_FLAG (pAd, - fRTMP_ADAPTER_NIC_NOT_EXIST))) - { + fRTMP_ADAPTER_NIC_NOT_EXIST))) { DBGPRINT_RAW (RT_DEBUG_ERROR, ("BulkIn IRP Pending!!!\n")); @@ -1424,7 +1419,6 @@ void CMDHandler(struct rt_rtmp_adapter *pAd) pAd->PendingRx = 0; } } - /* Wait 10ms before reading register. */ RTMPusecDelay(10000); ntStatus = @@ -1545,7 +1539,8 @@ void CMDHandler(struct rt_rtmp_adapter *pAd) RTUSBInitRxDesc(pAd, pRxContext); pUrb = pRxContext->pUrb; - if ((ret = RTUSB_SUBMIT_URB(pUrb)) != 0) { /* fail */ + ret = RTUSB_SUBMIT_URB(pUrb); + if (ret != 0) { /* fail */ RTMP_IRQ_LOCK (&pAd-> diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c index 2b7080cc2c05..3a724496e748 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_rx.c @@ -1489,8 +1489,6 @@ inline void ieee80211_process_probe_response( memcpy(target, &network, sizeof(*target)); list_add_tail(&target->list, &ieee->network_list); - if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) - ieee80211_softmac_new_net(ieee,&network); } else { IEEE80211_DEBUG_SCAN("Updating '%s' (%pM) via %s.\n", escape_essid(target->ssid, @@ -1516,8 +1514,6 @@ inline void ieee80211_process_probe_response( renew = 1; //YJ,add,080819,for hidden ap,end update_network(target, &network); - if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)) - ieee80211_softmac_new_net(ieee,&network); } spin_unlock_irqrestore(&ieee->lock, flags); diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c index be2d17f60c35..e099a5fa0494 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c @@ -1555,7 +1555,8 @@ ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; - if ((status = auth_rq_parse(skb, dest))!= -1){ + status = auth_rq_parse(skb, dest); + if (status != -1) { ieee80211_resp_to_auth(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); @@ -2321,9 +2322,11 @@ void ieee80211_disassociate(struct ieee80211_device *ieee) if(IS_DOT11D_ENABLE(ieee)) Dot11d_Reset(ieee); - ieee->state = IEEE80211_NOLINK; + ieee->link_change(ieee->dev); - notify_wx_assoc_event(ieee); + if (ieee->state == IEEE80211_LINKED) + notify_wx_assoc_event(ieee); + ieee->state = IEEE80211_NOLINK; } void ieee80211_associate_retry_wq(struct work_struct *work) diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c index ad42bcdc9374..e46ff2ffa09b 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac_wx.c @@ -277,8 +277,6 @@ void ieee80211_wx_sync_scan_wq(struct work_struct *work) chan = ieee->current_network.channel; - netif_carrier_off(ieee->dev); - if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); @@ -300,8 +298,6 @@ void ieee80211_wx_sync_scan_wq(struct work_struct *work) if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) ieee80211_start_send_beacons(ieee); - netif_carrier_on(ieee->dev); - //YJ,add,080828, In prevent of lossing ping packet during scanning //ieee80211_sta_ps_send_null_frame(ieee, false); //YJ,add,080828,end diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c index 55d12e3271de..84a745bb9ca0 100644 --- a/drivers/staging/rtl8187se/r8180_core.c +++ b/drivers/staging/rtl8187se/r8180_core.c @@ -44,24 +44,24 @@ #include "ieee80211/dot11d.h" static struct pci_device_id rtl8180_pci_id_tbl[] __devinitdata = { - { - .vendor = PCI_VENDOR_ID_REALTEK, - .device = 0x8199, - .subvendor = PCI_ANY_ID, - .subdevice = PCI_ANY_ID, - .driver_data = 0, - }, - { - .vendor = 0, - .device = 0, - .subvendor = 0, - .subdevice = 0, - .driver_data = 0, - } + { + .vendor = PCI_VENDOR_ID_REALTEK, + .device = 0x8199, + .subvendor = PCI_ANY_ID, + .subdevice = PCI_ANY_ID, + .driver_data = 0, + }, + { + .vendor = 0, + .device = 0, + .subvendor = 0, + .subdevice = 0, + .driver_data = 0, + } }; -static char* ifname = "wlan%d"; +static char *ifname = "wlan%d"; static int hwseqnum = 0; static int hwwep = 0; static int channels = 0x3fff; @@ -168,34 +168,34 @@ static struct pci_driver rtl8180_pci_driver = { u8 read_nic_byte(struct net_device *dev, int x) { - return 0xff&readb((u8*)dev->mem_start +x); + return 0xff&readb((u8 *)dev->mem_start + x); } u32 read_nic_dword(struct net_device *dev, int x) { - return readl((u8*)dev->mem_start +x); + return readl((u8 *)dev->mem_start + x); } u16 read_nic_word(struct net_device *dev, int x) { - return readw((u8*)dev->mem_start +x); + return readw((u8 *)dev->mem_start + x); } void write_nic_byte(struct net_device *dev, int x,u8 y) { - writeb(y,(u8*)dev->mem_start +x); + writeb(y, (u8 *)dev->mem_start + x); udelay(20); } void write_nic_dword(struct net_device *dev, int x,u32 y) { - writel(y,(u8*)dev->mem_start +x); + writel(y, (u8 *)dev->mem_start + x); udelay(20); } void write_nic_word(struct net_device *dev, int x,u16 y) { - writew(y,(u8*)dev->mem_start +x); + writew(y, (u8 *)dev->mem_start + x); udelay(20); } @@ -313,7 +313,7 @@ void rtl8180_proc_module_init(void) void rtl8180_proc_module_remove(void) { - remove_proc_entry(RTL8180_MODULE_NAME, init_net.proc_net); + remove_proc_entry(RTL8180_MODULE_NAME, init_net.proc_net); } void rtl8180_proc_remove_one(struct net_device *dev) @@ -383,7 +383,7 @@ void rtl8180_proc_init_one(struct net_device *dev) short buffer_add(struct buffer **buffer, u32 *buf, dma_addr_t dma, struct buffer **bufferhead) { - struct buffer *tmp; + struct buffer *tmp; if(! *buffer){ @@ -403,7 +403,8 @@ short buffer_add(struct buffer **buffer, u32 *buf, dma_addr_t dma, tmp=*buffer; while(tmp->next!=(*buffer)) tmp=tmp->next; - if ((tmp->next= kmalloc(sizeof(struct buffer),GFP_KERNEL)) == NULL){ + tmp->next = kmalloc(sizeof(struct buffer),GFP_KERNEL); + if (tmp->next == NULL) { DMESGE("Failed to kmalloc TX/RX struct"); return -1; } @@ -1155,7 +1156,8 @@ short alloc_rx_desc_ring(struct net_device *dev, u16 bufsize, int count) tmp=desc; for (i = 0; i < count; i++) { - if ((buf= kmalloc(bufsize * sizeof(u8),GFP_ATOMIC)) == NULL){ + buf = kmalloc(bufsize * sizeof(u8),GFP_ATOMIC); + if (buf == NULL) { DMESGE("Failed to kmalloc RX buffer"); return -1; } @@ -1427,7 +1429,7 @@ void rtl8180_rx(struct net_device *dev) u32 RXAGC = 0; long RxAGC_dBm = 0; u8 LNA=0, BB=0; - u8 LNA_gain[4]={02, 17, 29, 39}; + u8 LNA_gain[4] = {02, 17, 29, 39}; u8 Antenna = 0; struct ieee80211_hdr_4addr *hdr; u16 fc,type; @@ -1529,7 +1531,7 @@ void rtl8180_rx(struct net_device *dev) }else { padding = 0; } - padding = 0; + padding = 0; priv->rx_prevlen+=len; if(priv->rx_prevlen > MAX_FRAG_THRESHOLD + 100){ @@ -1622,7 +1624,7 @@ void rtl8180_rx(struct net_device *dev) bICV = ((*(priv->rxringtail)) & (0x00001000)) >> 12; hdr = (struct ieee80211_hdr_4addr *)priv->rxbuffer->buf; fc = le16_to_cpu(hdr->frame_ctl); - type = WLAN_FC_GET_TYPE(fc); + type = WLAN_FC_GET_TYPE(fc); if((IEEE80211_FTYPE_CTL != type) && (eqMacAddr(priv->ieee80211->current_network.bssid, (fc & IEEE80211_FCTL_TODS)? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS )? hdr->addr2 : hdr->addr3)) @@ -1946,11 +1948,11 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, u8 bUseShortPreamble = 0; u8 bCTSEnable = 0; u8 bRTSEnable = 0; - u16 Duration = 0; + u16 Duration = 0; u16 RtsDur = 0; u16 ThisFrameTime = 0; u16 TxDescDuration = 0; - u8 ownbit_flag = false; + u8 ownbit_flag = false; switch(priority) { case MANAGE_PRIORITY: @@ -1998,7 +2000,7 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, default: return -1; break; - } + } memcpy(&dest, frag_hdr->addr1, ETH_ALEN); if (is_multicast_ether_addr(dest) || @@ -2149,8 +2151,8 @@ short rtl8180_tx(struct net_device *dev, u8* txbuf, int len, int priority, if(morefrag) *tail = (*tail) | (1<<17); // more fragment if(!remain) *tail = (*tail) | (1<<28); // last segment of frame - *(tail+5) = *(tail+5)|(2<<27); - *(tail+7) = *(tail+7)|(1<<4); + *(tail+5) = *(tail+5)|(2<<27); + *(tail+7) = *(tail+7)|(1<<4); wmb(); if(ownbit_flag) @@ -2287,13 +2289,13 @@ void rtl8180_hw_wakeup(struct net_device *dev) void rtl8180_hw_sleep_down(struct net_device *dev) { - unsigned long flags; - struct r8180_priv *priv = ieee80211_priv(dev); + unsigned long flags; + struct r8180_priv *priv = ieee80211_priv(dev); - spin_lock_irqsave(&priv->ps_lock,flags); - if(priv->rf_sleep) - priv->rf_sleep(dev); - spin_unlock_irqrestore(&priv->ps_lock,flags); + spin_lock_irqsave(&priv->ps_lock, flags); + if (priv->rf_sleep) + priv->rf_sleep(dev); + spin_unlock_irqrestore(&priv->ps_lock, flags); } void rtl8180_hw_sleep(struct net_device *dev, u32 th, u32 tl) @@ -2784,7 +2786,7 @@ short rtl8180_init(struct net_device *dev) priv->ieee80211->data_hard_stop = rtl8180_data_hard_stop; priv->ieee80211->data_hard_resume = rtl8180_data_hard_resume; - priv->ieee80211->init_wmmparam_flag = 0; + priv->ieee80211->init_wmmparam_flag = 0; priv->ieee80211->start_send_beacons = rtl8180_start_tx_beacon; priv->ieee80211->stop_send_beacons = rtl8180_beacon_tx_disable; @@ -2954,8 +2956,8 @@ short rtl8180_init(struct net_device *dev) return -ENOMEM; if(request_irq(dev->irq, (void *)rtl8180_interrupt, IRQF_SHARED, dev->name, dev)){ - DMESGE("Error allocating IRQ %d",dev->irq); - return -1; + DMESGE("Error allocating IRQ %d", dev->irq); + return -1; }else{ priv->irq=dev->irq; DMESG("IRQ %d",dev->irq); @@ -3100,7 +3102,7 @@ void rtl8185_set_rate(struct net_device *dev) void rtl8180_adapter_start(struct net_device *dev) { - struct r8180_priv *priv = ieee80211_priv(dev); + struct r8180_priv *priv = ieee80211_priv(dev); rtl8180_rtx_disable(dev); rtl8180_reset(dev); @@ -3194,7 +3196,7 @@ void rtl8180_start_tx_beacon(struct net_device *dev) rtl8180_set_mode(dev, EPROM_CMD_NORMAL); - rtl8185b_irq_enable(dev); + rtl8185b_irq_enable(dev); } static struct net_device_stats *rtl8180_stats(struct net_device *dev) @@ -3250,9 +3252,9 @@ void rtl8180_hw_sleep_wq (struct work_struct *work) { struct delayed_work *dwork = to_delayed_work(work); struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_sleep_wq); - struct net_device *dev = ieee->dev; + struct net_device *dev = ieee->dev; - rtl8180_hw_sleep_down(dev); + rtl8180_hw_sleep_down(dev); } static void MgntLinkKeepAlive(struct r8180_priv *priv ) @@ -3371,7 +3373,7 @@ int _rtl8180_up(struct net_device *dev) } timer_rate_adaptive((unsigned long)dev); watch_dog_adaptive((unsigned long)dev); - if(priv->bSwAntennaDiverity) + if (priv->bSwAntennaDiverity) SwAntennaDiversityTimerCallback(dev); ieee80211_softmac_start_protocol(priv->ieee80211); return 0; @@ -3612,10 +3614,10 @@ static int __devinit rtl8180_pci_probe(struct pci_dev *pdev, dev->watchdog_timeo = HZ*3; if (dev_alloc_name(dev, ifname) < 0){ - DMESG("Oops: devname already taken! Trying wlan%%d...\n"); + DMESG("Oops: devname already taken! Trying wlan%%d...\n"); ifname = "wlan%d"; dev_alloc_name(dev, ifname); - } + } if(rtl8180_init(dev)!=0){ DMESG("Initialization failed"); @@ -4089,10 +4091,10 @@ void GPIOChangeRFWorkItemCallBack(struct work_struct *work) u8 btPSR; u8 btConfig0; RT_RF_POWER_STATE eRfPowerStateToSet; - bool bActuallySet=false; + bool bActuallySet = false; char *argv[3]; - static char *RadioPowerPath = "/etc/acpi/events/RadioPower.sh"; + static char *RadioPowerPath = "/etc/acpi/events/RadioPower.sh"; static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL}; static int readf_count = 0; diff --git a/drivers/staging/rtl8187se/r8180_rtl8225z2.c b/drivers/staging/rtl8187se/r8180_rtl8225z2.c index 6edf5a46fa40..2a2afd51cf42 100644 --- a/drivers/staging/rtl8187se/r8180_rtl8225z2.c +++ b/drivers/staging/rtl8187se/r8180_rtl8225z2.c @@ -1,14 +1,13 @@ /* - This is part of the rtl8180-sa2400 driver - released under the GPL (See file COPYING for details). - Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it> - - This files contains programming code for the rtl8225 - radio frontend. - - *Many* thanks to Realtek Corp. for their great support! - -*/ + * This is part of the rtl8180-sa2400 driver + * released under the GPL (See file COPYING for details). + * Copyright (c) 2005 Andrea Merello <andreamrl@tiscali.it> + * + * This files contains programming code for the rtl8225 + * radio frontend. + * + * *Many* thanks to Realtek Corp. for their great support! + */ #include "r8180_hw.h" #include "r8180_rtl8225.h" @@ -225,7 +224,7 @@ static void rtl8225_SetTXPowerLevel(struct net_device *dev, short ch) } static const u8 rtl8225z2_threshold[] = { - 0x8d, 0x8d, 0x8d, 0x8d, 0x9d, 0xad, 0xbd, + 0x8d, 0x8d, 0x8d, 0x8d, 0x9d, 0xad, 0xbd, }; static const u8 rtl8225z2_gain_bg[] = { @@ -307,7 +306,7 @@ static u32 read_rtl8225(struct net_device *dev, u8 adr) u32 data2Write = ((u32)(adr & 0x1f)) << 27; u32 dataRead; u32 mask; - u16 oval,oval2,oval3,tmp; + u16 oval, oval2, oval3, tmp; int i; short bit, rw; u8 wLength = 6; @@ -325,9 +324,11 @@ static u32 read_rtl8225(struct net_device *dev, u8 adr) oval &= ~0xf; - write_nic_word(dev, RFPinsOutput, oval | BB_HOST_BANG_EN ); udelay(4); + write_nic_word(dev, RFPinsOutput, oval | BB_HOST_BANG_EN); + udelay(4); - write_nic_word(dev, RFPinsOutput, oval ); udelay(5); + write_nic_word(dev, RFPinsOutput, oval); + udelay(5); rw = 0; @@ -335,31 +336,45 @@ static u32 read_rtl8225(struct net_device *dev, u8 adr) for (i = 0; i < wLength/2; i++) { bit = ((data2Write&mask) != 0) ? 1 : 0; - write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(1); + write_nic_word(dev, RFPinsOutput, bit | oval | rw); + udelay(1); - write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); - write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); + write_nic_word(dev, RFPinsOutput, + bit | oval | BB_HOST_BANG_CLK | rw); + udelay(2); + write_nic_word(dev, RFPinsOutput, + bit | oval | BB_HOST_BANG_CLK | rw); + udelay(2); - mask = (low2high) ? (mask<<1): (mask>>1); + mask = (low2high) ? (mask<<1) : (mask>>1); if (i == 2) { rw = BB_HOST_BANG_RW; - write_nic_word(dev, RFPinsOutput, bit|oval | BB_HOST_BANG_CLK | rw); udelay(2); - write_nic_word(dev, RFPinsOutput, bit|oval | rw); udelay(2); + write_nic_word(dev, RFPinsOutput, + bit | oval | BB_HOST_BANG_CLK | rw); + udelay(2); + write_nic_word(dev, RFPinsOutput, bit | oval | rw); + udelay(2); break; } - bit = ((data2Write&mask) != 0) ? 1: 0; + bit = ((data2Write&mask) != 0) ? 1 : 0; - write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); - write_nic_word(dev, RFPinsOutput, oval|bit|rw| BB_HOST_BANG_CLK); udelay(2); + write_nic_word(dev, RFPinsOutput, + oval | bit | rw | BB_HOST_BANG_CLK); + udelay(2); + write_nic_word(dev, RFPinsOutput, + oval | bit | rw | BB_HOST_BANG_CLK); + udelay(2); - write_nic_word(dev, RFPinsOutput, oval| bit |rw); udelay(1); + write_nic_word(dev, RFPinsOutput, oval | bit | rw); + udelay(1); mask = (low2high) ? (mask<<1) : (mask>>1); } - write_nic_word(dev, RFPinsOutput, rw|oval); udelay(2); + write_nic_word(dev, RFPinsOutput, rw|oval); + udelay(2); mask = (low2high) ? 0x01 : (((u32)0x01) << (12-1)); /* @@ -371,9 +386,12 @@ static u32 read_rtl8225(struct net_device *dev, u8 adr) for (i = 0; i < rLength; i++) { write_nic_word(dev, RFPinsOutput, rw|oval); udelay(1); - write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); - write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); - write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); udelay(2); + write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); + udelay(2); + write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); + udelay(2); + write_nic_word(dev, RFPinsOutput, rw|oval|BB_HOST_BANG_CLK); + udelay(2); tmp = read_nic_word(dev, RFPinsInput); dataRead |= (tmp & BB_HOST_BANG_CLK ? mask : 0); @@ -383,7 +401,9 @@ static u32 read_rtl8225(struct net_device *dev, u8 adr) mask = (low2high) ? (mask<<1) : (mask>>1); } - write_nic_word(dev, RFPinsOutput, BB_HOST_BANG_EN|BB_HOST_BANG_RW|oval); udelay(2); + write_nic_word(dev, RFPinsOutput, + BB_HOST_BANG_EN | BB_HOST_BANG_RW | oval); + udelay(2); write_nic_word(dev, RFPinsEnable, oval2); write_nic_word(dev, RFPinsSelect, oval3); /* Set To SW Switch */ @@ -426,7 +446,7 @@ void rtl8225z2_rf_close(struct net_device *dev) s8 DbmToTxPwrIdx(struct r8180_priv *priv, WIRELESS_MODE WirelessMode, s32 PowerInDbm) { - bool bUseDefault = true; + bool bUseDefault = true; s8 TxPwrIdx = 0; /* @@ -486,8 +506,10 @@ void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch) if (IS_DOT11D_ENABLE(priv->ieee80211) && IS_DOT11D_STATE_DONE(priv->ieee80211)) { u8 MaxTxPwrInDbm = DOT11D_GetMaxTxPwrInDbm(priv->ieee80211, ch); - u8 CckMaxPwrIdx = DbmToTxPwrIdx(priv, WIRELESS_MODE_B, MaxTxPwrInDbm); - u8 OfdmMaxPwrIdx = DbmToTxPwrIdx(priv, WIRELESS_MODE_G, MaxTxPwrInDbm); + u8 CckMaxPwrIdx = DbmToTxPwrIdx(priv, WIRELESS_MODE_B, + MaxTxPwrInDbm); + u8 OfdmMaxPwrIdx = DbmToTxPwrIdx(priv, WIRELESS_MODE_G, + MaxTxPwrInDbm); if (cck_power_level > CckMaxPwrIdx) cck_power_level = CckMaxPwrIdx; @@ -524,7 +546,7 @@ void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch) if (ofdm_power_level <= 11) { write_phy_ofdm(dev, 0x07, 0x5c); write_phy_ofdm(dev, 0x09, 0x5c); - } + } if (ofdm_power_level <= 17) { write_phy_ofdm(dev, 0x07, 0x54); @@ -613,7 +635,7 @@ void rtl8225z2_rf_init(struct net_device *dev) int i; short channel = 1; u16 brsr; - u32 data,addr; + u32 data, addr; priv->chan = channel; @@ -740,7 +762,7 @@ void rtl8225z2_rf_init(struct net_device *dev) write_phy_ofdm(dev, 0x26, 0x90); mdelay(1); write_phy_ofdm(dev, 0x27, 0x88); mdelay(1); - rtl8225z2_set_gain(dev,4); + rtl8225z2_set_gain(dev, 4); write_phy_cck(dev, 0x0, 0x98); mdelay(1); write_phy_cck(dev, 0x3, 0x20); mdelay(1); @@ -803,12 +825,12 @@ void rtl8225z2_rf_set_mode(struct net_device *dev) write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - rtl8225z2_set_gain(dev,4); + rtl8225z2_set_gain(dev, 4); - write_phy_ofdm(dev,0x15, 0x40); - write_phy_ofdm(dev,0x17, 0x40); + write_phy_ofdm(dev, 0x15, 0x40); + write_phy_ofdm(dev, 0x17, 0x40); - write_nic_dword(dev, 0x94,0x10000000); + write_nic_dword(dev, 0x94, 0x10000000); } else { write_rtl8225(dev, 0x5, 0x1864); write_nic_dword(dev, RF_PARA, 0x10044); @@ -819,18 +841,18 @@ void rtl8225z2_rf_set_mode(struct net_device *dev) write_phy_ofdm(dev, 0xf, 0x20); write_phy_ofdm(dev, 0x11, 0x7); - rtl8225z2_set_gain(dev,4); + rtl8225z2_set_gain(dev, 4); - write_phy_ofdm(dev,0x15, 0x40); - write_phy_ofdm(dev,0x17, 0x40); + write_phy_ofdm(dev, 0x15, 0x40); + write_phy_ofdm(dev, 0x17, 0x40); - write_nic_dword(dev, 0x94,0x04000002); + write_nic_dword(dev, 0x94, 0x04000002); } } -#define MAX_DOZE_WAITING_TIMES_85B 20 -#define MAX_POLLING_24F_TIMES_87SE 10 -#define LPS_MAX_SLEEP_WAITING_TIMES_87SE 5 +#define MAX_DOZE_WAITING_TIMES_85B 20 +#define MAX_POLLING_24F_TIMES_87SE 10 +#define LPS_MAX_SLEEP_WAITING_TIMES_87SE 5 bool SetZebraRFPowerState8185(struct net_device *dev, RT_RF_POWER_STATE eRFPowerState) @@ -882,12 +904,14 @@ bool SetZebraRFPowerState8185(struct net_device *dev, break; case eRfSleep: for (QueueID = 0, i = 0; QueueID < 6;) { - if (get_curr_tx_free_desc(dev, QueueID) == priv->txringcount) { + if (get_curr_tx_free_desc(dev, QueueID) == + priv->txringcount) { QueueID++; continue; } else { priv->TxPollingTimes++; - if (priv->TxPollingTimes >= LPS_MAX_SLEEP_WAITING_TIMES_87SE) { + if (priv->TxPollingTimes >= + LPS_MAX_SLEEP_WAITING_TIMES_87SE) { bActionAllowed = false; break; } else @@ -915,7 +939,8 @@ bool SetZebraRFPowerState8185(struct net_device *dev, while (true) { u8 tmp24F = read_nic_byte(dev, 0x24f); - if ((tmp24F == 0x01) || (tmp24F == 0x09)) { + if ((tmp24F == 0x01) || + (tmp24F == 0x09)) { bTurnOffBB = true; break; } else { @@ -935,7 +960,8 @@ bool SetZebraRFPowerState8185(struct net_device *dev, if (bTurnOffBB) { /* turn off BB */ u1bTmp = read_nic_byte(dev, 0x24E); - write_nic_byte(dev, 0x24E, (u1bTmp | BIT5 | BIT6)); + write_nic_byte(dev, 0x24E, + (u1bTmp | BIT5 | BIT6)); /* turn off AFE PLL */ write_nic_byte(dev, 0x54, 0xFC); @@ -945,7 +971,8 @@ bool SetZebraRFPowerState8185(struct net_device *dev, break; case eRfOff: for (QueueID = 0, i = 0; QueueID < 6;) { - if (get_curr_tx_free_desc(dev, QueueID) == priv->txringcount) { + if (get_curr_tx_free_desc(dev, QueueID) == + priv->txringcount) { QueueID++; continue; } else { diff --git a/drivers/staging/rtl8192e/Makefile b/drivers/staging/rtl8192e/Makefile index e032c3e1e864..41cb4d3d6262 100644 --- a/drivers/staging/rtl8192e/Makefile +++ b/drivers/staging/rtl8192e/Makefile @@ -18,6 +18,7 @@ r8192e_pci-objs := \ r819xE_firmware.o \ r819xE_cmdpkt.o \ r8192E_dm.o \ + r8192_pm.o \ ieee80211/ieee80211_rx.o \ ieee80211/ieee80211_softmac.o \ ieee80211/ieee80211_tx.o \ diff --git a/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c index d1d7b0866755..b4beb2073919 100644 --- a/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192e/ieee80211/ieee80211_softmac.c @@ -1934,7 +1934,8 @@ ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; - if ((status = auth_rq_parse(skb, dest))!= -1){ + status = auth_rq_parse(skb, dest); + if (status != -1) { ieee80211_resp_to_auth(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); diff --git a/drivers/staging/rtl8192e/r8192E_core.c b/drivers/staging/rtl8192e/r8192E_core.c index bb7e1ef28d3b..604c691d64b5 100644 --- a/drivers/staging/rtl8192e/r8192E_core.c +++ b/drivers/staging/rtl8192e/r8192E_core.c @@ -62,7 +62,7 @@ //#include <linux/usb.h> // FIXME: check if 2.6.7 is ok -#ifdef CONFIG_PM_RTL +#ifdef CONFIG_PM #include "r8192_pm.h" #endif @@ -146,7 +146,7 @@ static struct pci_driver rtl8192_pci_driver = { .id_table = rtl8192_pci_id_tbl, /* PCI_ID table */ .probe = rtl8192_pci_probe, /* probe fn */ .remove = __devexit_p(rtl8192_pci_disconnect), /* remove fn */ -#ifdef CONFIG_PM_RTL +#ifdef CONFIG_PM .suspend = rtl8192E_suspend, /* PM suspend fn */ .resume = rtl8192E_resume, /* PM resume fn */ #else @@ -1864,13 +1864,15 @@ static short rtl8192_pci_initdescring(struct net_device *dev) /* general process for other queue */ for (i = 0; i < MAX_TX_QUEUE_COUNT; i++) { - if ((ret = rtl8192_alloc_tx_desc_ring(dev, i, priv->txringcount))) + ret = rtl8192_alloc_tx_desc_ring(dev, i, priv->txringcount); + if (ret) goto err_free_rings; } #if 0 /* specific process for hardware beacon process */ - if ((ret = rtl8192_alloc_tx_desc_ring(dev, MAX_TX_QUEUE_COUNT - 1, 2))) + ret = rtl8192_alloc_tx_desc_ring(dev, MAX_TX_QUEUE_COUNT - 1, 2); + if (ret) goto err_free_rings; #endif diff --git a/drivers/staging/rtl8192e/r8192_pm.c b/drivers/staging/rtl8192e/r8192_pm.c index feef29b0a893..521d49f8f8ea 100644 --- a/drivers/staging/rtl8192e/r8192_pm.c +++ b/drivers/staging/rtl8192e/r8192_pm.c @@ -9,8 +9,6 @@ Released under the terms of GPL (General Public Licence) */ -#ifdef CONFIG_PM_RTL - #include "r8192E.h" #include "r8192E_hw.h" #include "r8192_pm.h" @@ -27,7 +25,9 @@ int rtl8192E_suspend (struct pci_dev *pdev, pm_message_t state) { struct net_device *dev = pci_get_drvdata(pdev); struct r8192_priv *priv = ieee80211_priv(dev); +#ifdef RTL8190P u8 ucRegRead; +#endif u32 ulRegRead; RT_TRACE(COMP_POWER, "============> r8192E suspend call.\n"); @@ -168,5 +168,3 @@ int rtl8192E_enable_wake (struct pci_dev *dev, pm_message_t state, int enable) state.event, enable); return(-EAGAIN); } - -#endif //CONFIG_PM_RTL diff --git a/drivers/staging/rtl8192e/r8192_pm.h b/drivers/staging/rtl8192e/r8192_pm.h index 68d292b1d864..4da9b464b416 100644 --- a/drivers/staging/rtl8192e/r8192_pm.h +++ b/drivers/staging/rtl8192e/r8192_pm.h @@ -10,8 +10,6 @@ */ -#ifdef CONFIG_PM_RTL - #ifndef R8192E_PM_H #define R8192E_PM_H @@ -24,5 +22,3 @@ int rtl8192E_resume (struct pci_dev *dev); int rtl8192E_enable_wake (struct pci_dev *dev, pm_message_t state, int enable); #endif //R8192E_PM_H - -#endif // CONFIG_PM_RTL diff --git a/drivers/staging/rtl8192su/Kconfig b/drivers/staging/rtl8192su/Kconfig index b72a96206f58..b422ea1ecf9c 100644 --- a/drivers/staging/rtl8192su/Kconfig +++ b/drivers/staging/rtl8192su/Kconfig @@ -3,5 +3,6 @@ config RTL8192SU depends on PCI && WLAN && USB select WIRELESS_EXT select WEXT_PRIV + select EEPROM_93CX6 default N ---help--- diff --git a/drivers/staging/rtl8192su/Makefile b/drivers/staging/rtl8192su/Makefile index c8b4332d108c..9374a0179e5b 100644 --- a/drivers/staging/rtl8192su/Makefile +++ b/drivers/staging/rtl8192su/Makefile @@ -9,7 +9,6 @@ EXTRA_CFLAGS += -DTHOMAS_BEACON #EXTRA_CFLAGS += -DMUTIPLE_BULK_OUT r8192s_usb-objs := \ - r8180_93cx6.o \ r8192U_wx.o \ r8192S_phy.o \ r8192S_rtl6052.o \ diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c index 84a4e23b60b3..3cf5fdf8a8cb 100644 --- a/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_softmac.c @@ -1691,7 +1691,8 @@ ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; - if ((status = auth_rq_parse(skb, dest))!= -1){ + status = auth_rq_parse(skb, dest); + if (status != -1) { ieee80211_resp_to_auth(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); diff --git a/drivers/staging/rtl8192su/r8180_93cx6.c b/drivers/staging/rtl8192su/r8180_93cx6.c deleted file mode 100644 index 8878cfeb0fbb..000000000000 --- a/drivers/staging/rtl8192su/r8180_93cx6.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - This files contains card eeprom (93c46 or 93c56) programming routines, - memory is addressed by 16 bits words. - - This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004 <andreamrl@tiscali.it> - Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the - official realtek driver. - - Parts of this driver are based on the rtl8180 driver skeleton - from Patric Schenke & Andres Salomon. - - Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. - - We want to tanks the Authors of those projects and the Ndiswrapper - project Authors. -*/ - -#include "r8180_93cx6.h" - -void eprom_cs(struct net_device *dev, short bit) -{ - if(bit) - write_nic_byte_E(dev, EPROM_CMD, - (1<<EPROM_CS_SHIFT) | \ - read_nic_byte_E(dev, EPROM_CMD)); //enable EPROM - else - write_nic_byte_E(dev, EPROM_CMD, read_nic_byte_E(dev, EPROM_CMD)\ - &~(1<<EPROM_CS_SHIFT)); //disable EPROM - - force_pci_posting(dev); - udelay(EPROM_DELAY); -} - - -void eprom_ck_cycle(struct net_device *dev) -{ - write_nic_byte_E(dev, EPROM_CMD, - (1<<EPROM_CK_SHIFT) | read_nic_byte_E(dev,EPROM_CMD)); - force_pci_posting(dev); - udelay(EPROM_DELAY); - write_nic_byte_E(dev, EPROM_CMD, - read_nic_byte_E(dev, EPROM_CMD) &~ (1<<EPROM_CK_SHIFT)); - force_pci_posting(dev); - udelay(EPROM_DELAY); -} - - -void eprom_w(struct net_device *dev,short bit) -{ - if(bit) - write_nic_byte_E(dev, EPROM_CMD, (1<<EPROM_W_SHIFT) | \ - read_nic_byte_E(dev,EPROM_CMD)); - else - write_nic_byte_E(dev, EPROM_CMD, read_nic_byte_E(dev,EPROM_CMD)\ - &~(1<<EPROM_W_SHIFT)); - - force_pci_posting(dev); - udelay(EPROM_DELAY); -} - - -short eprom_r(struct net_device *dev) -{ - short bit; - - bit=(read_nic_byte_E(dev, EPROM_CMD) & (1<<EPROM_R_SHIFT) ); - udelay(EPROM_DELAY); - - if(bit) return 1; - return 0; -} - - -void eprom_send_bits_string(struct net_device *dev, short b[], int len) -{ - int i; - - for(i=0; i<len; i++){ - eprom_w(dev, b[i]); - eprom_ck_cycle(dev); - } -} - - -u32 eprom_read(struct net_device *dev, u32 addr) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - short read_cmd[]={1,1,0}; - short addr_str[8]; - int i; - int addr_len; - u32 ret; - - ret=0; - //enable EPROM programming - write_nic_byte_E(dev, EPROM_CMD, - (EPROM_CMD_PROGRAM<<EPROM_CMD_OPERATING_MODE_SHIFT)); - force_pci_posting(dev); - udelay(EPROM_DELAY); - - if (priv->epromtype==EPROM_93c56){ - addr_str[7]=addr & 1; - addr_str[6]=addr & (1<<1); - addr_str[5]=addr & (1<<2); - addr_str[4]=addr & (1<<3); - addr_str[3]=addr & (1<<4); - addr_str[2]=addr & (1<<5); - addr_str[1]=addr & (1<<6); - addr_str[0]=addr & (1<<7); - addr_len=8; - }else{ - addr_str[5]=addr & 1; - addr_str[4]=addr & (1<<1); - addr_str[3]=addr & (1<<2); - addr_str[2]=addr & (1<<3); - addr_str[1]=addr & (1<<4); - addr_str[0]=addr & (1<<5); - addr_len=6; - } - eprom_cs(dev, 1); - eprom_ck_cycle(dev); - eprom_send_bits_string(dev, read_cmd, 3); - eprom_send_bits_string(dev, addr_str, addr_len); - - //keep chip pin D to low state while reading. - //I'm unsure if it is necessary, but anyway shouldn't hurt - eprom_w(dev, 0); - - for(i=0;i<16;i++){ - //eeprom needs a clk cycle between writing opcode&adr - //and reading data. (eeprom outs a dummy 0) - eprom_ck_cycle(dev); - ret |= (eprom_r(dev)<<(15-i)); - } - - eprom_cs(dev, 0); - eprom_ck_cycle(dev); - - //disable EPROM programming - write_nic_byte_E(dev, EPROM_CMD, - (EPROM_CMD_NORMAL<<EPROM_CMD_OPERATING_MODE_SHIFT)); - return ret; -} diff --git a/drivers/staging/rtl8192su/r8180_93cx6.h b/drivers/staging/rtl8192su/r8180_93cx6.h deleted file mode 100644 index 0309800255cf..000000000000 --- a/drivers/staging/rtl8192su/r8180_93cx6.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - This is part of rtl8187 OpenSource driver - Copyright (C) Andrea Merello 2004-2005 <andreamrl@tiscali.it> - Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the official realtek driver - Parts of this driver are based on the rtl8180 driver skeleton from Patric Schenke & Andres Salomon - Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to tanks the Authors of such projects and the Ndiswrapper project Authors. -*/ - -/*This files contains card eeprom (93c46 or 93c56) programming routines*/ -/*memory is addressed by WORDS*/ - -#include "r8192U.h" -#include "r8192S_hw.h" - -#define EPROM_DELAY 10 - -#define EPROM_ANAPARAM_ADDRLWORD 0xd -#define EPROM_ANAPARAM_ADDRHWORD 0xe - -#define EPROM_RFCHIPID 0x6 -#define EPROM_TXPW_BASE 0x05 -#define EPROM_RFCHIPID_RTL8225U 5 -#define EPROM_RF_PARAM 0x4 -#define EPROM_CONFIG2 0xc - -#define EPROM_VERSION 0x1E -#define MAC_ADR 0x7 - -#define CIS 0x18 - -#define EPROM_TXPW0 0x16 -#define EPROM_TXPW2 0x1b -#define EPROM_TXPW1 0x3d - - -u32 eprom_read(struct net_device *dev,u32 addr); //reads a 16 bits word diff --git a/drivers/staging/rtl8192su/r8192S_firmware.c b/drivers/staging/rtl8192su/r8192S_firmware.c index 752a3f1fb3f5..b6ae8543c5ca 100644 --- a/drivers/staging/rtl8192su/r8192S_firmware.c +++ b/drivers/staging/rtl8192su/r8192S_firmware.c @@ -338,143 +338,159 @@ void FirmwareHeaderPriveUpdate(struct net_device *dev, PRT_8192S_FIRMWARE_PRIV pFwPriv->rf_config = FirmwareHeaderMapRfType(dev); } +bool FirmwareRequest92S(struct net_device *dev, rt_firmware *pFirmware) +{ + struct r8192_priv *priv = ieee80211_priv(dev); + bool rtStatus = true; + const char *pFwImageFileName[1] = {"RTL8192SU/rtl8192sfw.bin"}; + u8 *pucMappedFile = NULL; + u32 ulInitStep = 0; + u8 FwHdrSize = RT_8192S_FIRMWARE_HDR_SIZE; + PRT_8192S_FIRMWARE_HDR pFwHdr = NULL; + u32 file_length = 0; + int rc; + const struct firmware *fw_entry; + + rc = request_firmware(&fw_entry, + pFwImageFileName[ulInitStep], + &priv->udev->dev); + if (rc < 0) + goto RequestFirmware_Fail; + + if (fw_entry->size > sizeof(pFirmware->szFwTmpBuffer)) { + RT_TRACE(COMP_ERR, "%s(): image file too large" + "for container buffer", __func__); + release_firmware(fw_entry); + goto RequestFirmware_Fail; + } + + memcpy(pFirmware->szFwTmpBuffer, fw_entry->data, fw_entry->size); + pFirmware->szFwTmpBufferLen = fw_entry->size; + release_firmware(fw_entry); + + pucMappedFile = pFirmware->szFwTmpBuffer; + file_length = pFirmware->szFwTmpBufferLen; + + /* Retrieve FW header. */ + pFirmware->pFwHeader = (PRT_8192S_FIRMWARE_HDR) pucMappedFile; + pFwHdr = pFirmware->pFwHeader; + + RT_TRACE(COMP_FIRMWARE, "%s(): signature: %x, version: %x, " + "size: %x, imemsize: %x, sram size: %x", + __func__, pFwHdr->Signature, pFwHdr->Version, + pFwHdr->DMEMSize, pFwHdr->IMG_IMEM_SIZE, + pFwHdr->IMG_SRAM_SIZE); + + pFirmware->FirmwareVersion = byte(pFwHdr->Version , 0); + + if ((pFwHdr->IMG_IMEM_SIZE == 0) || + (pFwHdr->IMG_IMEM_SIZE > sizeof(pFirmware->FwIMEM))) { + RT_TRACE(COMP_ERR, "%s(): memory for data image is less than" + " IMEM requires", __func__); + goto RequestFirmware_Fail; + } else { + pucMappedFile += FwHdrSize; + /* Retrieve IMEM image. */ + memcpy(pFirmware->FwIMEM, pucMappedFile, pFwHdr->IMG_IMEM_SIZE); + pFirmware->FwIMEMLen = pFwHdr->IMG_IMEM_SIZE; + } + + if (pFwHdr->IMG_SRAM_SIZE > sizeof(pFirmware->FwEMEM)) { + RT_TRACE(COMP_ERR, "%s(): memory for data image is less than" + " EMEM requires", __func__); + goto RequestFirmware_Fail; + } else { + pucMappedFile += pFirmware->FwIMEMLen; + /* Retriecve EMEM image */ + memcpy(pFirmware->FwEMEM, pucMappedFile, pFwHdr->IMG_SRAM_SIZE); + pFirmware->FwEMEMLen = pFwHdr->IMG_SRAM_SIZE; + } + return rtStatus; +RequestFirmware_Fail: + RT_TRACE(COMP_ERR, "%s(): failed with TCR-Status: %x\n", + __func__, read_nic_word(dev, TCR)); + rtStatus = false; + return rtStatus; +} bool FirmwareDownload92S(struct net_device *dev) { - struct r8192_priv *priv = ieee80211_priv(dev); - bool rtStatus = true; - const char *pFwImageFileName[1] = {"RTL8192SU/rtl8192sfw.bin"}; - u8 *pucMappedFile = NULL; - u32 ulFileLength, ulInitStep = 0; - u8 FwHdrSize = RT_8192S_FIRMWARE_HDR_SIZE; - rt_firmware *pFirmware = priv->pFirmware; - u8 FwStatus = FW_STATUS_INIT; - PRT_8192S_FIRMWARE_HDR pFwHdr = NULL; - PRT_8192S_FIRMWARE_PRIV pFwPriv = NULL; - int rc; - const struct firmware *fw_entry; - u32 file_length = 0; + struct r8192_priv *priv = ieee80211_priv(dev); + bool rtStatus = true; + u8 *pucMappedFile = NULL; + u32 ulFileLength; + u8 FwHdrSize = RT_8192S_FIRMWARE_HDR_SIZE; + rt_firmware *pFirmware = priv->pFirmware; + u8 FwStatus = FW_STATUS_INIT; + PRT_8192S_FIRMWARE_HDR pFwHdr = NULL; + PRT_8192S_FIRMWARE_PRIV pFwPriv = NULL; pFirmware->FWStatus = FW_STATUS_INIT; - - RT_TRACE(COMP_FIRMWARE, " --->FirmwareDownload92S()\n"); - -/* -* Load the firmware from RTL8192SU/rtl8192sfw.bin -*/ - if(pFirmware->szFwTmpBufferLen == 0) - { - rc = request_firmware(&fw_entry, pFwImageFileName[ulInitStep],&priv->udev->dev); - if(rc < 0 ) { - RT_TRACE(COMP_ERR, "request firmware fail!\n"); - goto DownloadFirmware_Fail; - } - - if(fw_entry->size > sizeof(pFirmware->szFwTmpBuffer)) { - RT_TRACE(COMP_ERR, "img file size exceed the container buffer fail!\n"); - release_firmware(fw_entry); - goto DownloadFirmware_Fail; - } - - memcpy(pFirmware->szFwTmpBuffer,fw_entry->data,fw_entry->size); - pFirmware->szFwTmpBufferLen = fw_entry->size; - release_firmware(fw_entry); - - pucMappedFile = pFirmware->szFwTmpBuffer; - file_length = pFirmware->szFwTmpBufferLen; - - /* Retrieve FW header. */ - pFirmware->pFwHeader = (PRT_8192S_FIRMWARE_HDR) pucMappedFile; - pFwHdr = pFirmware->pFwHeader; - RT_TRACE(COMP_FIRMWARE,"signature:%x, version:%x, size:%x, imemsize:%x, sram size:%x\n", \ - pFwHdr->Signature, pFwHdr->Version, pFwHdr->DMEMSize, \ - pFwHdr->IMG_IMEM_SIZE, pFwHdr->IMG_SRAM_SIZE); - pFirmware->FirmwareVersion = byte(pFwHdr->Version ,0); - if ((pFwHdr->IMG_IMEM_SIZE==0) || (pFwHdr->IMG_IMEM_SIZE > sizeof(pFirmware->FwIMEM))) { - RT_TRACE(COMP_ERR, "%s: memory for data image is less than IMEM required\n",\ - __FUNCTION__); - goto DownloadFirmware_Fail; - } else { - pucMappedFile+=FwHdrSize; - /* Retrieve IMEM image. */ - memcpy(pFirmware->FwIMEM, pucMappedFile, pFwHdr->IMG_IMEM_SIZE); - pFirmware->FwIMEMLen = pFwHdr->IMG_IMEM_SIZE; - } - - if (pFwHdr->IMG_SRAM_SIZE > sizeof(pFirmware->FwEMEM)) { - RT_TRACE(COMP_ERR, "%s: memory for data image is less than EMEM required\n",\ - __FUNCTION__); - goto DownloadFirmware_Fail; - } else { - pucMappedFile += pFirmware->FwIMEMLen; - /* Retriecve EMEM image */ - memcpy(pFirmware->FwEMEM, pucMappedFile, pFwHdr->IMG_SRAM_SIZE);//===>6 - pFirmware->FwEMEMLen = pFwHdr->IMG_SRAM_SIZE; - } + /* + * Load the firmware from RTL8192SU/rtl8192sfw.bin if necessary + */ + if (pFirmware->szFwTmpBufferLen == 0) { + if (FirmwareRequest92S(dev, pFirmware) != true) + goto DownloadFirmware_Fail; } - FwStatus = FirmwareGetNextStatus(pFirmware->FWStatus); - while(FwStatus!= FW_STATUS_READY) - { - // Image buffer redirection. - switch(FwStatus) - { - case FW_STATUS_LOAD_IMEM: - pucMappedFile = pFirmware->FwIMEM; - ulFileLength = pFirmware->FwIMEMLen; - break; + while (FwStatus != FW_STATUS_READY) { + /* Image buffer redirection. */ + switch (FwStatus) { + case FW_STATUS_LOAD_IMEM: + pucMappedFile = pFirmware->FwIMEM; + ulFileLength = pFirmware->FwIMEMLen; + break; - case FW_STATUS_LOAD_EMEM: - pucMappedFile = pFirmware->FwEMEM; - ulFileLength = pFirmware->FwEMEMLen; - break; + case FW_STATUS_LOAD_EMEM: + pucMappedFile = pFirmware->FwEMEM; + ulFileLength = pFirmware->FwEMEMLen; + break; - case FW_STATUS_LOAD_DMEM: - /* <Roger_Notes> Partial update the content of header private. 2008.12.18 */ - pFwHdr = pFirmware->pFwHeader; - pFwPriv = (PRT_8192S_FIRMWARE_PRIV)&pFwHdr->FWPriv; - FirmwareHeaderPriveUpdate(dev, pFwPriv); - pucMappedFile = (u8*)(pFirmware->pFwHeader)+RT_8192S_FIRMWARE_HDR_EXCLUDE_PRI_SIZE; - ulFileLength = FwHdrSize-RT_8192S_FIRMWARE_HDR_EXCLUDE_PRI_SIZE; - break; + case FW_STATUS_LOAD_DMEM: + /* Partial update the content of private header */ + pFwHdr = pFirmware->pFwHeader; + pFwPriv = (PRT_8192S_FIRMWARE_PRIV)&pFwHdr->FWPriv; + FirmwareHeaderPriveUpdate(dev, pFwPriv); + pucMappedFile = (u8 *)(pFirmware->pFwHeader) + + RT_8192S_FIRMWARE_HDR_EXCLUDE_PRI_SIZE; - default: - RT_TRACE(COMP_ERR, "Unexpected Download step!!\n"); - goto DownloadFirmware_Fail; - break; + ulFileLength = FwHdrSize - + RT_8192S_FIRMWARE_HDR_EXCLUDE_PRI_SIZE; + break; + + default: + RT_TRACE(COMP_ERR, "Unexpected Download step!!\n"); + goto DownloadFirmware_Fail; + break; } - //3// - //3// <2> Download image file - //3 // - rtStatus = FirmwareDownloadCode(dev, pucMappedFile, ulFileLength); + /* <2> Download image file */ + + rtStatus = FirmwareDownloadCode(dev, + pucMappedFile, + ulFileLength); if(rtStatus != true) - { - RT_TRACE(COMP_ERR, "FirmwareDownloadCode() fail ! \n" ); goto DownloadFirmware_Fail; - } - //3// - //3// <3> Check whether load FW process is ready - //3 // + /* <3> Check whether load FW process is ready */ + rtStatus = FirmwareCheckReady(dev, FwStatus); if(rtStatus != true) - { - RT_TRACE(COMP_ERR, "FirmwareDownloadCode() fail ! \n"); goto DownloadFirmware_Fail; - } FwStatus = FirmwareGetNextStatus(pFirmware->FWStatus); } - RT_TRACE(COMP_FIRMWARE, "Firmware Download Success!!\n"); + RT_TRACE(COMP_FIRMWARE, "%s(): Firmware Download Success", __func__); return rtStatus; - DownloadFirmware_Fail: - RT_TRACE(COMP_ERR, "Firmware Download Fail!!%x\n",read_nic_word(dev, TCR)); +DownloadFirmware_Fail: + RT_TRACE(COMP_ERR, "%s(): failed with TCR-Status: %x\n", + __func__, read_nic_word(dev, TCR)); rtStatus = false; return rtStatus; } diff --git a/drivers/staging/rtl8192su/r8192S_phy.c b/drivers/staging/rtl8192su/r8192S_phy.c index 63d4e5fd7b18..83c8aaaccd60 100644 --- a/drivers/staging/rtl8192su/r8192S_phy.c +++ b/drivers/staging/rtl8192su/r8192S_phy.c @@ -3607,128 +3607,103 @@ void SetBWModeCallback8192SUsb(struct net_device *dev) RT_TRACE(COMP_SCAN, "<==SetBWMode8190Pci()" ); } -// -// Callback routine of the work item for set bandwidth mode. -// -// use in phy only (in win it's work) +/* + * Callback routine of the work item for set bandwidth mode. + * + * use in phy only (in win it's work) + */ void SetBWModeCallback8192SUsbWorkItem(struct net_device *dev) { - struct r8192_priv *priv = ieee80211_priv(dev); - u8 regBwOpMode; - - // Added it for 20/40 mhz switch time evaluation by guangan 070531 - //u32 NowL, NowH; - //u8Byte BeginTime, EndTime; - u8 regRRSR_RSC; + struct r8192_priv *priv = ieee80211_priv(dev); + u8 regBwOpMode; + u8 regRRSR_RSC; - RT_TRACE(COMP_SCAN, "==>SetBWModeCallback8192SUsbWorkItem() Switch to %s bandwidth\n", \ - priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20?"20MHz":"40MHz"); + RT_TRACE(COMP_SCAN, "%s(): Switch to %s bandwidth", __func__, + priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 ? "20MHz" : "40MHz"); - if(priv->rf_chip == RF_PSEUDO_11N) - { + if (priv->rf_chip == RF_PSEUDO_11N) { priv->SetBWModeInProgress= FALSE; return; } - if(!priv->up) return; - - // Added it for 20/40 mhz switch time evaluation by guangan 070531 - //NowL = read_nic_dword(dev, TSFR); - //NowH = read_nic_dword(dev, TSFR+4); - //BeginTime = ((u8Byte)NowH << 32) + NowL; - - //3<1>Set MAC register + /* Set MAC register */ regBwOpMode = read_nic_byte(dev, BW_OPMODE); regRRSR_RSC = read_nic_byte(dev, RRSR+2); - - switch(priv->CurrentChannelBW) - { - case HT_CHANNEL_WIDTH_20: - regBwOpMode |= BW_OPMODE_20MHZ; - // 2007/02/07 Mark by Emily becasue we have not verify whether this register works - write_nic_byte(dev, BW_OPMODE, regBwOpMode); - break; - - case HT_CHANNEL_WIDTH_20_40: - regBwOpMode &= ~BW_OPMODE_20MHZ; - // 2007/02/07 Mark by Emily becasue we have not verify whether this register works - write_nic_byte(dev, BW_OPMODE, regBwOpMode); - regRRSR_RSC = (regRRSR_RSC&0x90) |(priv->nCur40MhzPrimeSC<<5); - write_nic_byte(dev, RRSR+2, regRRSR_RSC); - - break; - - default: - RT_TRACE(COMP_DBG, "SetBWModeCallback8192SUsbWorkItem(): unknown Bandwidth: %#X\n", - priv->CurrentChannelBW); - break; + switch (priv->CurrentChannelBW) { + case HT_CHANNEL_WIDTH_20: + regBwOpMode |= BW_OPMODE_20MHZ; + /* we have not verified whether this register works */ + write_nic_byte(dev, BW_OPMODE, regBwOpMode); + break; + case HT_CHANNEL_WIDTH_20_40: + regBwOpMode &= ~BW_OPMODE_20MHZ; + /* we have not verified whether this register works */ + write_nic_byte(dev, BW_OPMODE, regBwOpMode); + regRRSR_RSC = (regRRSR_RSC&0x90) | (priv->nCur40MhzPrimeSC<<5); + write_nic_byte(dev, RRSR+2, regRRSR_RSC); + break; + default: + RT_TRACE(COMP_DBG, "%s(): unknown Bandwidth: %#X", __func__, + priv->CurrentChannelBW); + break; } - - //3 <2>Set PHY related register - switch(priv->CurrentChannelBW) - { - case HT_CHANNEL_WIDTH_20: - rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x0); - rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x0); - - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0xff, 0x58); - - break; - case HT_CHANNEL_WIDTH_20_40: - rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x1); - rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x1); - - // Set Control channel to upper or lower. These settings are required only for 40MHz - rtl8192_setBBreg(dev, rCCK0_System, bCCKSideBand, (priv->nCur40MhzPrimeSC>>1)); - rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, priv->nCur40MhzPrimeSC); - - rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0xff, 0x18); - - break; - - - default: - RT_TRACE(COMP_DBG, "SetBWModeCallback8192SUsbWorkItem(): unknown Bandwidth: %#X\n"\ - ,priv->CurrentChannelBW); - break; + /* Set PHY related register */ + switch (priv->CurrentChannelBW) { + case HT_CHANNEL_WIDTH_20: + rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x0); + rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x0); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0xff, 0x58); + break; + case HT_CHANNEL_WIDTH_20_40: + rtl8192_setBBreg(dev, rFPGA0_RFMOD, bRFMOD, 0x1); + rtl8192_setBBreg(dev, rFPGA1_RFMOD, bRFMOD, 0x1); + /* + * Set Control channel to upper or lower. + * These settings are required only for 40MHz + */ + rtl8192_setBBreg(dev, rCCK0_System, bCCKSideBand, + (priv->nCur40MhzPrimeSC>>1)); + rtl8192_setBBreg(dev, rOFDM1_LSTF, 0xC00, + priv->nCur40MhzPrimeSC); + rtl8192_setBBreg(dev, rFPGA0_AnalogParameter2, 0xff, 0x18); + break; + default: + RT_TRACE(COMP_DBG, "%s(): unknown Bandwidth: %#X", __func__, + priv->CurrentChannelBW); + break; } - //Skip over setting of J-mode in BB register here. Default value is "None J mode". Emily 20070315 - - //3<3>Set RF related register - switch( priv->rf_chip ) - { - case RF_8225: - PHY_SetRF8225Bandwidth(dev, priv->CurrentChannelBW); - break; - - case RF_8256: - // Please implement this function in Hal8190PciPhy8256.c - //PHY_SetRF8256Bandwidth(dev, priv->CurrentChannelBW); - break; - - case RF_6052: - PHY_RF6052SetBandwidth(dev, priv->CurrentChannelBW); - break; - - case RF_8258: - // Please implement this function in Hal8190PciPhy8258.c - // PHY_SetRF8258Bandwidth(); - break; - - case RF_PSEUDO_11N: - // Do Nothing - break; + /* + * Skip over setting of J-mode in BB register here. + * Default value is "None J mode". + */ - default: - //RT_ASSERT(FALSE, ("Unknown rf_chip: %d\n", priv->rf_chip)); - break; + /* Set RF related register */ + switch (priv->rf_chip) { + case RF_8225: + PHY_SetRF8225Bandwidth(dev, priv->CurrentChannelBW); + break; + case RF_8256: + /* Please implement this function in Hal8190PciPhy8256.c */ + /* PHY_SetRF8256Bandwidth(dev, priv->CurrentChannelBW); */ + break; + case RF_6052: + PHY_RF6052SetBandwidth(dev, priv->CurrentChannelBW); + break; + case RF_8258: + /* Please implement this function in Hal8190PciPhy8258.c */ + /* PHY_SetRF8258Bandwidth(); */ + break; + case RF_PSEUDO_11N: + /* Do Nothing */ + break; + default: + RT_TRACE(COMP_DBG, "%s(): unknown rf_chip: %d", __func__, + priv->rf_chip); + break; } - priv->SetBWModeInProgress= FALSE; - - RT_TRACE(COMP_SCAN, "<==SetBWModeCallback8192SUsbWorkItem()" ); } //--------------------------Move to oter DIR later-------------------------------*/ diff --git a/drivers/staging/rtl8192su/r8192U.h b/drivers/staging/rtl8192su/r8192U.h index ba87623f32ee..830625253293 100644 --- a/drivers/staging/rtl8192su/r8192U.h +++ b/drivers/staging/rtl8192su/r8192U.h @@ -44,6 +44,12 @@ #include "r8192S_firmware.h" +/* EEPROM defs for use with linux/eeprom_93cx6.h */ +#define RTL819X_EEPROM_CMD_READ (1 << 0) +#define RTL819X_EEPROM_CMD_WRITE (1 << 1) +#define RTL819X_EEPROM_CMD_CK (1 << 2) +#define RTL819X_EEPROM_CMD_CS (1 << 3) + //#define RTL8192U #define RTL819xU_MODULE_NAME "rtl819xU" //added for HW security, john.0629 diff --git a/drivers/staging/rtl8192su/r8192U_core.c b/drivers/staging/rtl8192su/r8192U_core.c index 04d9b85f3d4c..2487da21095c 100644 --- a/drivers/staging/rtl8192su/r8192U_core.c +++ b/drivers/staging/rtl8192su/r8192U_core.c @@ -26,6 +26,7 @@ #include <linux/vmalloc.h> #include <linux/slab.h> +#include <linux/eeprom_93cx6.h> #undef LOOP_TEST #undef DUMP_RX @@ -54,7 +55,6 @@ #include <asm/uaccess.h> #include "r8192U.h" -#include "r8180_93cx6.h" /* Card EEPROM */ #include "r8192U_wx.h" #include "r8192S_rtl8225.h" @@ -217,6 +217,36 @@ static CHANNEL_LIST ChannelPlan[] = { {{1,2,3,4,5,6,7,8,9,10,11,12,13,14},14} //For Global Domain. 1-11:active scan, 12-14 passive scan. //+YJ, 080626 }; +static void rtl819x_eeprom_register_read(struct eeprom_93cx6 *eeprom) +{ + struct net_device *dev = eeprom->data; + u8 reg = read_nic_byte(dev, EPROM_CMD); + + eeprom->reg_data_in = reg & RTL819X_EEPROM_CMD_WRITE; + eeprom->reg_data_out = reg & RTL819X_EEPROM_CMD_READ; + eeprom->reg_data_clock = reg & RTL819X_EEPROM_CMD_CK; + eeprom->reg_chip_select = reg & RTL819X_EEPROM_CMD_CS; +} + +static void rtl819x_eeprom_register_write(struct eeprom_93cx6 *eeprom) +{ + struct net_device *dev = eeprom->data; + u8 reg = 2 << 6; + + if (eeprom->reg_data_in) + reg |= RTL819X_EEPROM_CMD_WRITE; + if (eeprom->reg_data_out) + reg |= RTL819X_EEPROM_CMD_READ; + if (eeprom->reg_data_clock) + reg |= RTL819X_EEPROM_CMD_CK; + if (eeprom->reg_chip_select) + reg |= RTL819X_EEPROM_CMD_CS; + + write_nic_byte(dev, EPROM_CMD, reg); + read_nic_byte(dev, EPROM_CMD); + udelay(10); +} + static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv* priv) { int i, max_chan=-1, min_chan=-1; @@ -1155,15 +1185,6 @@ void tx_timeout(struct net_device *dev) //DMESG("TXTIMEOUT"); } - -/* this is only for debug */ -void dump_eprom(struct net_device *dev) -{ - int i; - for(i=0; i<63; i++) - RT_TRACE(COMP_EPROM, "EEPROM addr %x : %x", i, eprom_read(dev,i)); -} - /* this is only for debug */ void rtl8192_dump_reg(struct net_device *dev) { @@ -2577,30 +2598,20 @@ void rtl8192SU_update_ratr_table(struct net_device* dev) void rtl8192SU_link_change(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); - struct ieee80211_device* ieee = priv->ieee80211; - //unsigned long flags; + struct ieee80211_device *ieee = priv->ieee80211; u32 reg = 0; - printk("=====>%s 1\n", __func__); reg = read_nic_dword(dev, RCR); - - if (ieee->state == IEEE80211_LINKED) - { - + if (ieee->state == IEEE80211_LINKED) { rtl8192SU_net_update(dev); rtl8192SU_update_ratr_table(dev); ieee->SetFwCmdHandler(dev, FW_CMD_HIGH_PWR_ENABLE); priv->ReceiveConfig = reg |= RCR_CBSSID; - }else{ + } else priv->ReceiveConfig = reg &= ~RCR_CBSSID; - - } - write_nic_dword(dev, RCR, reg); rtl8192_update_msr(dev); - - printk("<=====%s 2\n", __func__); } static struct ieee80211_qos_parameters def_qos_parameters = { @@ -3409,34 +3420,28 @@ void update_hal_variables(struct r8192_priv *priv) } } -// -// Description: -// Config HW adapter information into initial value. -// -// Assumption: -// 1. After Auto load fail(i.e, check CR9346 fail) -// -// Created by Roger, 2008.10.21. -// -void -rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(struct net_device* dev) +/* + * Description: + * Config HW adapter information into initial value. + * + * Assumption: + * 1. After Auto load fail(i.e, check CR9346 fail) + * + */ +void rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(struct net_device *dev) { - struct r8192_priv *priv = ieee80211_priv(dev); - //u16 i,usValue; - //u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0x81, 0x92, 0x00}; - u8 rf_path; // For EEPROM/EFUSE After V0.6_1117 - int i; + struct r8192_priv *priv = ieee80211_priv(dev); + u8 rf_path; /* For EEPROM/EFUSE After V0.6_1117 */ + int i; RT_TRACE(COMP_INIT, "====> ConfigAdapterInfo8192SForAutoLoadFail\n"); - write_nic_byte(dev, SYS_ISO_CTRL+1, 0xE8); // Isolation signals from Loader - //PlatformStallExecution(10000); + /* Isolation signals from Loader */ + write_nic_byte(dev, SYS_ISO_CTRL+1, 0xE8); mdelay(10); - write_nic_byte(dev, PMC_FSM, 0x02); // Enable Loader Data Keep + write_nic_byte(dev, PMC_FSM, 0x02); /* Enable Loader Data Keep */ - //RT_ASSERT(priv->AutoloadFailFlag==TRUE, ("ReadAdapterInfo8192SEEPROM(): AutoloadFailFlag !=TRUE\n")); - - // Initialize IC Version && Channel Plan + /* Initialize IC Version && Channel Plan */ priv->eeprom_vid = 0; priv->eeprom_pid = 0; priv->card_8192_version = 0; @@ -3447,12 +3452,14 @@ rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(struct net_device* dev) RT_TRACE(COMP_INIT, "EEPROM VID = 0x%4x\n", priv->eeprom_vid); RT_TRACE(COMP_INIT, "EEPROM PID = 0x%4x\n", priv->eeprom_pid); - RT_TRACE(COMP_INIT, "EEPROM Customer ID: 0x%2x\n", priv->eeprom_CustomerID); - RT_TRACE(COMP_INIT, "EEPROM SubCustomer ID: 0x%2x\n", priv->eeprom_SubCustomerID); - RT_TRACE(COMP_INIT, "EEPROM ChannelPlan = 0x%4x\n", priv->eeprom_ChannelPlan); - RT_TRACE(COMP_INIT, "IgnoreDiffRateTxPowerOffset = %d\n", priv->bIgnoreDiffRateTxPowerOffset); - - + RT_TRACE(COMP_INIT, "EEPROM Customer ID: 0x%2x\n", + priv->eeprom_CustomerID); + RT_TRACE(COMP_INIT, "EEPROM SubCustomer ID: 0x%2x\n", + priv->eeprom_SubCustomerID); + RT_TRACE(COMP_INIT, "EEPROM ChannelPlan = 0x%4x\n", + priv->eeprom_ChannelPlan); + RT_TRACE(COMP_INIT, "IgnoreDiffRateTxPowerOffset = %d\n", + priv->bIgnoreDiffRateTxPowerOffset); priv->EEPROMUsbOption = EEPROM_USB_Default_OPTIONAL_FUNC; RT_TRACE(COMP_INIT, "USB Option = %#x\n", priv->EEPROMUsbOption); @@ -3460,19 +3467,15 @@ rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(struct net_device* dev) for(i=0; i<5; i++) priv->EEPROMUsbPhyParam[i] = EEPROM_USB_Default_PHY_PARAM; - //RT_PRINT_DATA(COMP_INIT|COMP_EFUSE, DBG_LOUD, ("EFUSE USB PHY Param: \n"), priv->EEPROMUsbPhyParam, 5); - { - //<Roger_Notes> In this case, we random assigh MAC address here. 2008.10.15. + /* + * In this case, we randomly assign a MAC address here. + */ static u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0x81, 0x92, 0x00}; - u8 i; - - //sMacAddr[5] = (u8)GetRandomNumber(1, 254); - for(i = 0; i < 6; i++) dev->dev_addr[i] = sMacAddr[i]; } - //NicIFSetMacAddress(Adapter, Adapter->PermanentAddress); + /* NicIFSetMacAddress(Adapter, Adapter->PermanentAddress); */ write_nic_dword(dev, IDR0, ((u32*)dev->dev_addr)[0]); write_nic_word(dev, IDR4, ((u16*)(dev->dev_addr + 4))[0]); @@ -3481,7 +3484,7 @@ rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(struct net_device* dev) dev->dev_addr); priv->EEPROMBoardType = EEPROM_Default_BoardType; - priv->rf_type = RF_1T2R; //RF_2T2R + priv->rf_type = RF_1T2R; /* RF_2T2R */ priv->EEPROMTxPowerDiff = EEPROM_Default_PwDiff; priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; priv->EEPROMCrystalCap = EEPROM_Default_CrystalCap; @@ -3490,13 +3493,11 @@ rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(struct net_device* dev) priv->EEPROMTSSI_B = EEPROM_Default_TSSI; priv->EEPROMTxPwrTkMode = EEPROM_Default_TxPwrTkMode; - - for (rf_path = 0; rf_path < 2; rf_path++) { for (i = 0; i < 3; i++) { - // Read CCK RF A & B Tx power + /* Read CCK RF A & B Tx power */ priv->RfCckChnlAreaTxPwr[rf_path][i] = priv->RfOfdmChnlAreaTxPwr1T[rf_path][i] = priv->RfOfdmChnlAreaTxPwr2T[rf_path][i] = @@ -3506,22 +3507,25 @@ rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(struct net_device* dev) update_hal_variables(priv); - // - // Update remained HAL variables. - // + /* + * Update remaining HAL variables. + */ priv->TSSI_13dBm = priv->EEPROMThermalMeter *100; - priv->LegacyHTTxPowerDiff = priv->EEPROMTxPowerDiff;//new + priv->LegacyHTTxPowerDiff = priv->EEPROMTxPowerDiff; /* new */ priv->TxPowerDiff = priv->EEPROMTxPowerDiff; - //priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf);// Antenna B gain offset to antenna A, bit0~3 - //priv->AntennaTxPwDiff[1] = ((priv->EEPROMTxPowerDiff & 0xf0)>>4);// Antenna C gain offset to antenna A, bit4~7 - priv->CrystalCap = priv->EEPROMCrystalCap; // CrystalCap, bit12~15 - priv->ThermalMeter[0] = priv->EEPROMThermalMeter;// ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2 + /* Antenna B gain offset to antenna A, bit0~3 */ + /* priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf); */ + /* Antenna C gain offset to antenna A, bit4~7 */ + /* priv->AntennaTxPwDiff[1] = ((priv->EEPROMTxPowerDiff & 0xf0)>>4); */ + /* CrystalCap, bit12~15 */ + priv->CrystalCap = priv->EEPROMCrystalCap; + /* ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2 */ + priv->ThermalMeter[0] = priv->EEPROMThermalMeter; priv->LedStrategy = SW_LED_MODE0; init_rate_adaptive(dev); RT_TRACE(COMP_INIT, "<==== ConfigAdapterInfo8192SForAutoLoadFail\n"); - } // @@ -3534,26 +3538,32 @@ rtl8192SU_ConfigAdapterInfo8192SForAutoLoadFail(struct net_device* dev) // // Created by Roger, 2008.10.21. // -void -rtl8192SU_ReadAdapterInfo8192SUsb(struct net_device* dev) +void rtl8192SU_ReadAdapterInfo8192SUsb(struct net_device* dev) { - struct r8192_priv *priv = ieee80211_priv(dev); - u16 i,usValue; - u8 tmpU1b, tempval; - u16 EEPROMId; - u8 hwinfo[HWSET_MAX_SIZE_92S]; - u8 rf_path, index; // For EEPROM/EFUSE After V0.6_1117 - + struct r8192_priv *priv = ieee80211_priv(dev); + u16 i; + u8 tmpU1b, tempval; + u16 EEPROMId; + u8 hwinfo[HWSET_MAX_SIZE_92S]; + u8 rf_path, index; // For EEPROM/EFUSE After V0.6_1117 + struct eeprom_93cx6 eeprom; + u16 eeprom_val; + + eeprom.data = dev; + eeprom.register_read = rtl819x_eeprom_register_read; + eeprom.register_write = rtl819x_eeprom_register_write; + if (priv->epromtype == EPROM_93c46) + eeprom.width = PCI_EEPROM_WIDTH_93C46; + else + eeprom.width = PCI_EEPROM_WIDTH_93C56; RT_TRACE(COMP_INIT, "====> ReadAdapterInfo8192SUsb\n"); - // - // <Roger_Note> The following operation are prevent Efuse leakage by turn on 2.5V. - // 2008.11.25. - // + /* + * The following operation are prevent Efuse leakage by turn on 2.5V.. + */ tmpU1b = read_nic_byte(dev, EFUSE_TEST+3); write_nic_byte(dev, EFUSE_TEST+3, tmpU1b|0x80); - //PlatformStallExecution(1000); mdelay(10); write_nic_byte(dev, EFUSE_TEST+3, (tmpU1b&(~BIT7))); @@ -3561,21 +3571,20 @@ rtl8192SU_ReadAdapterInfo8192SUsb(struct net_device* dev) priv->card_8192_version = (VERSION_8192S)((read_nic_dword(dev, PMC_FSM)>>16)&0xF); RT_TRACE(COMP_INIT, "Chip Version ID: 0x%2x\n", priv->card_8192_version); - switch(priv->card_8192_version) - { - case 0: - RT_TRACE(COMP_INIT, "Chip Version ID: VERSION_8192S_ACUT.\n"); - break; - case 1: - RT_TRACE(COMP_INIT, "Chip Version ID: VERSION_8192S_BCUT.\n"); - break; - case 2: - RT_TRACE(COMP_INIT, "Chip Version ID: VERSION_8192S_CCUT.\n"); - break; - default: - RT_TRACE(COMP_INIT, "Unknown Chip Version!!\n"); - priv->card_8192_version = VERSION_8192S_BCUT; - break; + switch (priv->card_8192_version) { + case 0: + RT_TRACE(COMP_INIT, "Chip Version ID: VERSION_8192S_ACUT.\n"); + break; + case 1: + RT_TRACE(COMP_INIT, "Chip Version ID: VERSION_8192S_BCUT.\n"); + break; + case 2: + RT_TRACE(COMP_INIT, "Chip Version ID: VERSION_8192S_CCUT.\n"); + break; + default: + RT_TRACE(COMP_INIT, "Unknown Chip Version!!\n"); + priv->card_8192_version = VERSION_8192S_BCUT; + break; } //if (IS_BOOT_FROM_EEPROM(Adapter)) @@ -3588,8 +3597,8 @@ rtl8192SU_ReadAdapterInfo8192SUsb(struct net_device* dev) // Read all Content from EEPROM or EFUSE. for(i = 0; i < HWSET_MAX_SIZE_92S; i += 2) { - usValue = eprom_read(dev, (u16) (i>>1)); - *((u16*)(&hwinfo[i])) = usValue; + eeprom_93cx6_read(&eeprom, (u16) (i>>1), &eeprom_val); + *((u16 *)(&hwinfo[i])) = eeprom_val; } } else if (!(priv->EepromOrEfuse)) @@ -4141,11 +4150,6 @@ short rtl8192_init(struct net_device *dev) init_timer(&priv->watch_dog_timer); priv->watch_dog_timer.data = (unsigned long)dev; priv->watch_dog_timer.function = watch_dog_timer_callback; - - //rtl8192_adapter_start(dev); -#ifdef DEBUG_EPROM - dump_eprom(dev); -#endif return 0; } @@ -5513,85 +5517,85 @@ void rtl819x_update_rxcounts( } } -extern void rtl819x_watchdog_wqcallback(struct work_struct *work) +void rtl819x_watchdog_wqcallback(struct work_struct *work) { - struct delayed_work *dwork = container_of(work,struct delayed_work,work); - struct r8192_priv *priv = container_of(dwork,struct r8192_priv,watch_dog_wq); - struct net_device *dev = priv->ieee80211->dev; + struct delayed_work *dwork = container_of(work, + struct delayed_work, + work); + struct r8192_priv *priv = container_of(dwork, + struct r8192_priv, + watch_dog_wq); + struct net_device *dev = priv->ieee80211->dev; struct ieee80211_device* ieee = priv->ieee80211; - RESET_TYPE ResetType = RESET_TYPE_NORESET; - static u8 check_reset_cnt=0; + RESET_TYPE ResetType = RESET_TYPE_NORESET; + static u8 check_reset_cnt; + u32 TotalRxBcnNum = 0; + u32 TotalRxDataNum = 0; bool bBusyTraffic = false; if(!priv->up) return; hal_dm_watchdog(dev); - - {//to get busy traffic condition - if(ieee->state == IEEE80211_LINKED) - { - //windows mod 666 to 100. - //if( ieee->LinkDetectInfo.NumRxOkInPeriod> 666 || - // ieee->LinkDetectInfo.NumTxOkInPeriod> 666 ) { - if( ieee->LinkDetectInfo.NumRxOkInPeriod> 100 || - ieee->LinkDetectInfo.NumTxOkInPeriod> 100 ) { + /* to get busy traffic condition */ + if (ieee->state == IEEE80211_LINKED) { + if (ieee->LinkDetectInfo.NumRxOkInPeriod > 666 || + ieee->LinkDetectInfo.NumTxOkInPeriod > 666) bBusyTraffic = true; - } - ieee->LinkDetectInfo.NumRxOkInPeriod = 0; - ieee->LinkDetectInfo.NumTxOkInPeriod = 0; - ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic; - } - } - //added by amy for AP roaming - { - if(priv->ieee80211->state == IEEE80211_LINKED && priv->ieee80211->iw_mode == IW_MODE_INFRA) - { - u32 TotalRxBcnNum = 0; - u32 TotalRxDataNum = 0; - rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum); - if((TotalRxBcnNum+TotalRxDataNum) == 0) - { - #ifdef TODO - if(rfState == eRfOff) - RT_TRACE(COMP_ERR,"========>%s()\n",__FUNCTION__); - #endif - printk("===>%s(): AP is power off,connect another one\n",__FUNCTION__); - // Dot11d_Reset(dev); - priv->ieee80211->state = IEEE80211_ASSOCIATING; - notify_wx_assoc_event(priv->ieee80211); - RemovePeerTS(priv->ieee80211,priv->ieee80211->current_network.bssid); - ieee->is_roaming = true; - priv->ieee80211->link_change(dev); - queue_work(priv->ieee80211->wq, &priv->ieee80211->associate_procedure_wq); - } + ieee->LinkDetectInfo.NumRxOkInPeriod = 0; + ieee->LinkDetectInfo.NumTxOkInPeriod = 0; + ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic; + } + + if (priv->ieee80211->state == IEEE80211_LINKED && + priv->ieee80211->iw_mode == IW_MODE_INFRA) { + rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum); + if ((TotalRxBcnNum + TotalRxDataNum) == 0) { + RT_TRACE(COMP_ERR, "%s(): AP is powered off," + "connect another one\n", __func__); + /* Dot11d_Reset(dev); */ + priv->ieee80211->state = IEEE80211_ASSOCIATING; + notify_wx_assoc_event(priv->ieee80211); + RemovePeerTS(priv->ieee80211, + priv->ieee80211->current_network.bssid); + ieee->is_roaming = true; + priv->ieee80211->link_change(dev); + queue_work(priv->ieee80211->wq, + &priv->ieee80211->associate_procedure_wq); } - priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod=0; - priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod=0; } -// CAM_read_entry(dev,4); - //check if reset the driver - if(check_reset_cnt++ >= 3 && !ieee->is_roaming) - { - ResetType = rtl819x_ifcheck_resetornot(dev); + priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod = 0; + priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod = 0; + + /* + * CAM_read_entry(dev,4); + * check if reset the driver + */ + if (check_reset_cnt++ >= 3 && !ieee->is_roaming) { + ResetType = rtl819x_ifcheck_resetornot(dev); check_reset_cnt = 3; - //DbgPrint("Start to check silent reset\n"); } - // RT_TRACE(COMP_RESET,"%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n",__FUNCTION__,priv->force_reset,priv->ResetProgress,priv->bForcedSilentReset,priv->bDisableNormalResetCheck,ResetType); -#if 1 - if( (priv->force_reset) || (priv->ResetProgress==RESET_TYPE_NORESET && + if ((priv->force_reset) || (priv->ResetProgress == RESET_TYPE_NORESET && (priv->bForcedSilentReset || - (!priv->bDisableNormalResetCheck && ResetType==RESET_TYPE_SILENT)))) // This is control by OID set in Pomelo - { - RT_TRACE(COMP_RESET,"%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n",__FUNCTION__,priv->force_reset,priv->ResetProgress,priv->bForcedSilentReset,priv->bDisableNormalResetCheck,ResetType); + (!priv->bDisableNormalResetCheck && + /* This is control by OID set in Pomelo */ + ResetType == RESET_TYPE_SILENT)))) { + RT_TRACE(COMP_RESET, "%s(): priv->force_reset is %d," + "priv->ResetProgress is %d, " + "priv->bForcedSilentReset is %d, " + "priv->bDisableNormalResetCheck is %d, " + "ResetType is %d", + __func__, + priv->force_reset, + priv->ResetProgress, + priv->bForcedSilentReset, + priv->bDisableNormalResetCheck, + ResetType); rtl819x_ifsilentreset(dev); } -#endif priv->force_reset = false; priv->bForcedSilentReset = false; priv->bResetInProgress = false; - RT_TRACE(COMP_TRACE, " <==RtUsbCheckForHangWorkItemCallback()\n"); - } void watch_dog_timer_callback(unsigned long data) @@ -7593,96 +7597,113 @@ void rtl8192_try_wake_queue(struct net_device *dev, int pri) void EnableHWSecurityConfig8192(struct net_device *dev) { - u8 SECR_value = 0x0; + u8 SECR_value = 0x0; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); - struct ieee80211_device* ieee = priv->ieee80211; + struct ieee80211_device *ieee = priv->ieee80211; SECR_value = SCR_TxEncEnable | SCR_RxDecEnable; -#if 1 - if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && (priv->ieee80211->auth_mode != 2)) - { - SECR_value |= SCR_RxUseDK; - SECR_value |= SCR_TxUseDK; - } - else if ((ieee->iw_mode == IW_MODE_ADHOC) && (ieee->pairwise_key_type & (KEY_TYPE_CCMP | KEY_TYPE_TKIP))) - { - SECR_value |= SCR_RxUseDK; - SECR_value |= SCR_TxUseDK; + switch (ieee->pairwise_key_type) { + case KEY_TYPE_WEP40: + case KEY_TYPE_WEP104: + if (priv->ieee80211->auth_mode != 2) { + SECR_value |= SCR_RxUseDK; + SECR_value |= SCR_TxUseDK; + } + break; + case KEY_TYPE_TKIP: + case KEY_TYPE_CCMP: + if (ieee->iw_mode == IW_MODE_ADHOC) { + SECR_value |= SCR_RxUseDK; + SECR_value |= SCR_TxUseDK; + } + break; + default: + break; } -#endif - //add HWSec active enable here. -//default using hwsec. when peer AP is in N mode only and pairwise_key_type is none_aes(which HT_IOT_ACT_PURE_N_MODE indicates it), use software security. when peer AP is in b,g,n mode mixed and pairwise_key_type is none_aes, use g mode hw security. WB on 2008.7.4 + /* + * add HWSec active enable here. + * default using hwsec. + * when peer AP is in N mode only and pairwise_key_type is none_aes + * (which HT_IOT_ACT_PURE_N_MODE indicates it), + * use software security. + * when peer AP is in b,g,n mode mixed and pairwise_key_type is none_aes + * use g mode hw security. + */ ieee->hwsec_active = 1; - if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep)//!ieee->hwsec_support) //add hwsec_support flag to totol control hw_sec on/off - { + /* add hwsec_support flag to totol control hw_sec on/off */ + if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep) { ieee->hwsec_active = 0; SECR_value &= ~SCR_RxDecEnable; } - RT_TRACE(COMP_SEC,"%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __FUNCTION__, \ - ieee->hwsec_active, ieee->pairwise_key_type, SECR_value); - { - write_nic_byte(dev, SECR, SECR_value);//SECR_value | SCR_UseDK ); - } + RT_TRACE(COMP_SEC, "%s(): hwsec: %d, pairwise_key: %d, " + "SECR_value: %x", + __func__, ieee->hwsec_active, + ieee->pairwise_key_type, SECR_value); + + write_nic_byte(dev, SECR, SECR_value); /* SECR_value | SCR_UseDK ); */ } -void setKey( struct net_device *dev, +void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u8 *MacAddr, u8 DefaultKey, - u32 *KeyContent ) + u32 *KeyContent) { u32 TargetCommand = 0; u32 TargetContent = 0; u16 usConfig = 0; u8 i; + if (EntryNo >= TOTAL_CAM_ENTRY) - RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n"); + RT_TRACE(COMP_ERR, "%s(): cam entry exceeds TOTAL_CAM_ENTRY", + __func__); - RT_TRACE(COMP_SEC, "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d, KeyType:%d, MacAddr%pM\n", dev,EntryNo, KeyIndex, KeyType, MacAddr); + RT_TRACE(COMP_SEC, "%s(): dev: %p, EntryNo: %d, " + "KeyIndex: %d, KeyType: %d, MacAddr: %pM", + __func__, dev, EntryNo, + KeyIndex, KeyType, MacAddr); if (DefaultKey) - usConfig |= BIT15 | (KeyType<<2); + usConfig |= BIT15 | (KeyType << 2); else - usConfig |= BIT15 | (KeyType<<2) | KeyIndex; -// usConfig |= BIT15 | (KeyType<<2) | (DefaultKey<<5) | KeyIndex; + usConfig |= BIT15 | (KeyType << 2) | KeyIndex; - - for(i=0 ; i<CAM_CONTENT_COUNT; i++){ - TargetCommand = i+CAM_CONTENT_COUNT*EntryNo; + for (i = 0 ; i < CAM_CONTENT_COUNT; i++) { + TargetCommand = i + CAM_CONTENT_COUNT * EntryNo; TargetCommand |= BIT31|BIT16; - - if(i==0){//MAC|Config - TargetContent = (u32)(*(MacAddr+0)) << 16| - (u32)(*(MacAddr+1)) << 24| + switch (i) { + case 0: /* MAC|Config */ + TargetContent = (u32)(*(MacAddr + 0)) << 16| + (u32)(*(MacAddr + 1)) << 24| (u32)usConfig; write_nic_dword(dev, WCAMI, TargetContent); write_nic_dword(dev, RWCAM, TargetCommand); - // printk("setkey cam =%8x\n", read_cam(dev, i+6*EntryNo)); - } - else if(i==1){//MAC - TargetContent = (u32)(*(MacAddr+2)) | - (u32)(*(MacAddr+3)) << 8| - (u32)(*(MacAddr+4)) << 16| - (u32)(*(MacAddr+5)) << 24; + continue; + case 1: /* MAC */ + TargetContent = (u32)(*(MacAddr + 2))| + (u32)(*(MacAddr + 3)) << 8| + (u32)(*(MacAddr + 4)) << 16| + (u32)(*(MacAddr + 5)) << 24; write_nic_dword(dev, WCAMI, TargetContent); write_nic_dword(dev, RWCAM, TargetCommand); - } - else { - //Key Material - if(KeyContent !=NULL){ - write_nic_dword(dev, WCAMI, (u32)(*(KeyContent+i-2)) ); - write_nic_dword(dev, RWCAM, TargetCommand); + continue; + default: /* Key Material */ + if (KeyContent != NULL) { + write_nic_dword(dev, WCAMI, + (u32)(*(KeyContent+i-2))); + write_nic_dword(dev, RWCAM, + TargetCommand); + } + continue; } } - } - } /*************************************************************************** diff --git a/drivers/staging/rtl8192su/r819xU_cmdpkt.c b/drivers/staging/rtl8192su/r819xU_cmdpkt.c index 3ebfe79bb663..43b68a02d0c1 100644 --- a/drivers/staging/rtl8192su/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192su/r819xU_cmdpkt.c @@ -1,384 +1,249 @@ -/****************************************************************************** - - (c) Copyright 2008, RealTEK Technologies Inc. All Rights Reserved. - - Module: r819xusb_cmdpkt.c (RTL8190 TX/RX command packet handler Source C File) - - Note: The module is responsible for handling TX and RX command packet. - 1. TX : Send set and query configuration command packet. - 2. RX : Receive tx feedback, beacon state, query configuration - command packet. - - Function: - - Export: - - Abbrev: - - History: - Data Who Remark - - 05/06/2008 amy Create initial version porting from windows driver. - -******************************************************************************/ +/* + * (c) Copyright 2008, RealTEK Technologies Inc. All Rights Reserved. + * + * Module: r819xusb_cmdpkt.c + * (RTL8190 TX/RX command packet handler Source C File) + * + * Note: The module is responsible for handling TX and RX command packet. + * 1.TX: Send set and query configuration command packet. + * 2.RX: Receive tx feedback, beacon state, query configuration, command packet. + */ #include "r8192U.h" #include "r819xU_cmdpkt.h" -/*---------------------------Define Local Constant---------------------------*/ -/* Debug constant*/ -#define CMPK_DEBOUNCE_CNT 1 -/* 2007/10/24 MH Add for printing a range of data. */ -#define CMPK_PRINT(Address)\ -{\ - unsigned char i;\ - u32 temp[10];\ - \ - memcpy(temp, Address, 40);\ - for (i = 0; i <40; i+=4)\ - printk("\r\n %08x", temp[i]);\ -}\ -/*---------------------------Define functions---------------------------------*/ - -bool -SendTxCommandPacket( - struct net_device *dev, - void* pData, - u32 DataLen - ) + +bool SendTxCommandPacket(struct net_device *dev, void *pData, u32 DataLen) { bool rtStatus = true; struct r8192_priv *priv = ieee80211_priv(dev); struct sk_buff *skb; cb_desc *tcb_desc; unsigned char *ptr_buf; - //bool bLastInitPacket = false; - //PlatformAcquireSpinLock(Adapter, RT_TX_SPINLOCK); + /* PlatformAcquireSpinLock(Adapter, RT_TX_SPINLOCK); */ - //Get TCB and local buffer from common pool. (It is shared by CmdQ, MgntQ, and USB coalesce DataQ) + /* + * Get TCB and local buffer from common pool. + * (It is shared by CmdQ, MgntQ, and USB coalesce DataQ) + */ skb = dev_alloc_skb(USB_HWDESC_HEADER_LEN + DataLen + 4); - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); - tcb_desc = (cb_desc*)(skb->cb + MAX_DEV_ADDR_SIZE); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); + tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->queue_index = TXCMD_QUEUE; tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_NORMAL; tcb_desc->bLastIniPkt = 0; skb_reserve(skb, USB_HWDESC_HEADER_LEN); ptr_buf = skb_put(skb, DataLen); - memset(ptr_buf,0,DataLen); - memcpy(ptr_buf,pData,DataLen); - tcb_desc->txbuf_size= (u16)DataLen; - - if(!priv->ieee80211->check_nic_enough_desc(dev,tcb_desc->queue_index)|| - (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index]))||\ - (priv->ieee80211->queue_stop) ) { - RT_TRACE(COMP_FIRMWARE,"===================NULL packet==================================> tx full!\n"); + memcpy(ptr_buf, pData, DataLen); + tcb_desc->txbuf_size = (u16)DataLen; + + if (!priv->ieee80211->check_nic_enough_desc(dev, tcb_desc->queue_index) || + (!skb_queue_empty(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index])) || + (priv->ieee80211->queue_stop)) { + RT_TRACE(COMP_FIRMWARE, "NULL packet => tx full\n"); skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb); } else { - priv->ieee80211->softmac_hard_start_xmit(skb,dev); + priv->ieee80211->softmac_hard_start_xmit(skb, dev); } //PlatformReleaseSpinLock(Adapter, RT_TX_SPINLOCK); return rtStatus; } -/*----------------------------------------------------------------------------- +/* * Function: cmpk_message_handle_tx() * * Overview: Driver internal module can call the API to send message to - * firmware side. For example, you can send a debug command packet. - * Or you can send a request for FW to modify RLX4181 LBUS HW bank. - * Otherwise, you can change MAC/PHT/RF register by firmware at - * run time. We do not support message more than one segment now. + * firmware side. For example, you can send a debug command packet. + * Or you can send a request for FW to modify RLX4181 LBUS HW bank. + * Otherwise, you can change MAC/PHT/RF register by firmware at + * run time. We do not support message more than one segment now. * * Input: NONE * * Output: NONE * * Return: NONE - * - * Revised History: - * When Who Remark - * 05/06/2008 amy porting from windows code. - * - *---------------------------------------------------------------------------*/ + */ extern bool cmpk_message_handle_tx( struct net_device *dev, - u8* codevirtualaddress, + u8 *codevirtualaddress, u32 packettype, u32 buffer_len) { - - bool rt_status = true; + bool rt_status = true; return rt_status; -} /* CMPK_Message_Handle_Tx */ +} -/*----------------------------------------------------------------------------- - * Function: cmpk_counttxstatistic() - * - * Overview: - * - * Input: PADAPTER pAdapter - . - * CMPK_TXFB_T *psTx_FB - . - * - * Output: NONE - * - * Return: NONE - * - * Revised History: - * When Who Remark - * 05/12/2008 amy Create Version 0 porting from windows code. - * - *---------------------------------------------------------------------------*/ +/* + * Function: cmpk_counttxstatistic() + */ static void -cmpk_count_txstatistic( - struct net_device *dev, - cmpk_txfb_t *pstx_fb) +cmpk_count_txstatistic(struct net_device *dev, cmpk_txfb_t *pstx_fb) { struct r8192_priv *priv = ieee80211_priv(dev); #ifdef ENABLE_PS - RT_RF_POWER_STATE rtState; + RT_RF_POWER_STATE rtState; - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); + pAdapter->HalFunc.GetHwRegHandler(pAdapter, + HW_VAR_RF_STATE, + (pu1Byte)(&rtState)); - // When RF is off, we should not count the packet for hw/sw synchronize - // reason, ie. there may be a duration while sw switch is changed and hw - // switch is being changed. 2006.12.04, by shien chang. + /* + * When RF is off, we should not count the packet for hw/sw synchronize + * reason, ie. there may be a duration while sw switch is changed and hw + * switch is being changed. + */ if (rtState == eRfOff) - { return; - } #endif #ifdef TODO - if(pAdapter->bInHctTest) + if (pAdapter->bInHctTest) return; #endif - /* We can not know the packet length and transmit type: broadcast or uni - or multicast. So the relative statistics must be collected in tx - feedback info. */ - if (pstx_fb->tok) - { + /* + * We can not know the packet length and transmit type: + * broadcast or uni or multicast. + * So the relative statistics must be collected in tx feedback info + */ + if (pstx_fb->tok) { priv->stats.txfeedbackok++; priv->stats.txoktotal++; priv->stats.txokbytestotal += pstx_fb->pkt_length; priv->stats.txokinperiod++; - /* We can not make sure broadcast/multicast or unicast mode. */ - if (pstx_fb->pkt_type == PACKET_MULTICAST) - { + if (pstx_fb->pkt_type == PACKET_MULTICAST) { priv->stats.txmulticast++; priv->stats.txbytesmulticast += pstx_fb->pkt_length; - } - else if (pstx_fb->pkt_type == PACKET_BROADCAST) - { + } else if (pstx_fb->pkt_type == PACKET_BROADCAST) { priv->stats.txbroadcast++; priv->stats.txbytesbroadcast += pstx_fb->pkt_length; - } - else - { + } else { priv->stats.txunicast++; priv->stats.txbytesunicast += pstx_fb->pkt_length; } - } - else - { + } else { priv->stats.txfeedbackfail++; priv->stats.txerrtotal++; priv->stats.txerrbytestotal += pstx_fb->pkt_length; - /* We can not make sure broadcast/multicast or unicast mode. */ if (pstx_fb->pkt_type == PACKET_MULTICAST) - { priv->stats.txerrmulticast++; - } else if (pstx_fb->pkt_type == PACKET_BROADCAST) - { priv->stats.txerrbroadcast++; - } else - { priv->stats.txerrunicast++; - } } - priv->stats.txretrycount += pstx_fb->retry_cnt; priv->stats.txfeedbackretry += pstx_fb->retry_cnt; +} -} /* cmpk_CountTxStatistic */ - - - -/*----------------------------------------------------------------------------- +/* * Function: cmpk_handle_tx_feedback() * * Overview: The function is responsible for extract the message inside TX - * feedbck message from firmware. It will contain dedicated info in - * ws-06-0063-rtl8190-command-packet-specification. Please - * refer to chapter "TX Feedback Element". We have to read 20 bytes - * in the command packet. + * feedbck message from firmware. It will contain dedicated info in + * ws-06-0063-rtl8190-command-packet-specification. Please + * refer to chapter "TX Feedback Element". We have to read 20 bytes + * in the command packet. * * Input: struct net_device * dev - * u8 * pmsg - Msg Ptr of the command packet. + * u8 *pmsg - Msg Ptr of the command packet. * * Output: NONE * * Return: NONE - * - * Revised History: - * When Who Remark - * 05/08/2008 amy Create Version 0 porting from windows code. - * - *---------------------------------------------------------------------------*/ -static void -cmpk_handle_tx_feedback( - struct net_device *dev, - u8 * pmsg) + */ +static void cmpk_handle_tx_feedback(struct net_device *dev, u8 *pmsg) { struct r8192_priv *priv = ieee80211_priv(dev); - cmpk_txfb_t rx_tx_fb; /* */ + cmpk_txfb_t rx_tx_fb; priv->stats.txfeedback++; - /* 0. Display received message. */ - //cmpk_Display_Message(CMPK_RX_TX_FB_SIZE, pMsg); - /* 1. Extract TX feedback info from RFD to temp structure buffer. */ + memcpy((u8 *)&rx_tx_fb, pmsg, sizeof(cmpk_txfb_t)); - /* 2007/07/05 MH Use pointer to transfer structure memory. */ - //memcpy((UINT8 *)&rx_tx_fb, pMsg, sizeof(CMPK_TXFB_T)); - memcpy((u8*)&rx_tx_fb, pmsg, sizeof(cmpk_txfb_t)); /* 2. Use tx feedback info to count TX statistics. */ cmpk_count_txstatistic(dev, &rx_tx_fb); +} - /* 2007/01/17 MH Comment previous method for TX statistic function. */ - /* Collect info TX feedback packet to fill TCB. */ - /* We can not know the packet length and transmit type: broadcast or uni - or multicast. */ - //CountTxStatistics( pAdapter, &tcb ); - -} /* cmpk_Handle_Tx_Feedback */ - -void -cmdpkt_beacontimerinterrupt_819xusb( - struct net_device *dev -) +void cmdpkt_beacontimerinterrupt_819xusb(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); u16 tx_rate; - { - // - // 070117, rcnjko: 87B have to S/W beacon for DTM encryption_cmn. - // - if(priv->ieee80211->current_network.mode == IEEE_A || - priv->ieee80211->current_network.mode == IEEE_N_5G || - (priv->ieee80211->current_network.mode == IEEE_N_24G && (!priv->ieee80211->pHTInfo->bCurSuppCCK))) - { - tx_rate = 60; - DMESG("send beacon frame tx rate is 6Mbpm\n"); - } - else - { - tx_rate =10; - DMESG("send beacon frame tx rate is 1Mbpm\n"); - } - - rtl819xusb_beacon_tx(dev,tx_rate); // HW Beacon + if (priv->ieee80211->current_network.mode == IEEE_A || + priv->ieee80211->current_network.mode == IEEE_N_5G || + (priv->ieee80211->current_network.mode == IEEE_N_24G && + (!priv->ieee80211->pHTInfo->bCurSuppCCK))) { + tx_rate = 60; + DMESG("send beacon frame tx rate is 6Mbpm\n"); + } else { + tx_rate = 10; + DMESG("send beacon frame tx rate is 1Mbpm\n"); } - + rtl819xusb_beacon_tx(dev, tx_rate); /* HW Beacon */ } - - - -/*----------------------------------------------------------------------------- +/* * Function: cmpk_handle_interrupt_status() * * Overview: The function is responsible for extract the message from - * firmware. It will contain dedicated info in - * ws-07-0063-v06-rtl819x-command-packet-specification-070315.doc. - * Please refer to chapter "Interrupt Status Element". + * firmware. It will contain dedicated info in + * ws-07-0063-v06-rtl819x-command-packet-specification-070315.doc. + * Please refer to chapter "Interrupt Status Element". * * Input: struct net_device *dev, - * u8* pmsg - Message Pointer of the command packet. + * u8* pmsg - Message Pointer of the command packet. * * Output: NONE * * Return: NONE - * - * Revised History: - * When Who Remark - * 05/12/2008 amy Add this for rtl8192 porting from windows code. - * - *---------------------------------------------------------------------------*/ -static void -cmpk_handle_interrupt_status( - struct net_device *dev, - u8* pmsg) + */ +static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) { cmpk_intr_sta_t rx_intr_status; /* */ struct r8192_priv *priv = ieee80211_priv(dev); DMESG("---> cmpk_Handle_Interrupt_Status()\n"); - /* 0. Display received message. */ - //cmpk_Display_Message(CMPK_RX_BEACON_STATE_SIZE, pMsg); - /* 1. Extract TX feedback info from RFD to temp structure buffer. */ - /* It seems that FW use big endian(MIPS) and DRV use little endian in - windows OS. So we have to read the content byte by byte or transfer - endian type before copy the message copy. */ - //rx_bcn_state.Element_ID = pMsg[0]; - //rx_bcn_state.Length = pMsg[1]; rx_intr_status.length = pmsg[1]; - if (rx_intr_status.length != (sizeof(cmpk_intr_sta_t) - 2)) - { + if (rx_intr_status.length != (sizeof(cmpk_intr_sta_t) - 2)) { DMESG("cmpk_Handle_Interrupt_Status: wrong length!\n"); return; } - - - // Statistics of beacon for ad-hoc mode. - if( priv->ieee80211->iw_mode == IW_MODE_ADHOC) - { + /* Statistics of beacon for ad-hoc mode. */ + if (priv->ieee80211->iw_mode == IW_MODE_ADHOC) { //2 maybe need endian transform? rx_intr_status.interrupt_status = *((u32 *)(pmsg + 4)); //rx_intr_status.InterruptStatus = N2H4BYTE(*((UINT32 *)(pMsg + 4))); DMESG("interrupt status = 0x%x\n", rx_intr_status.interrupt_status); - if (rx_intr_status.interrupt_status & ISR_TxBcnOk) - { + if (rx_intr_status.interrupt_status & ISR_TxBcnOk) { priv->ieee80211->bibsscoordinator = true; priv->stats.txbeaconokint++; - } - else if (rx_intr_status.interrupt_status & ISR_TxBcnErr) - { + } else if (rx_intr_status.interrupt_status & ISR_TxBcnErr) { priv->ieee80211->bibsscoordinator = false; priv->stats.txbeaconerr++; } if (rx_intr_status.interrupt_status & ISR_BcnTimerIntr) - { cmdpkt_beacontimerinterrupt_819xusb(dev); - } - } - - // Other informations in interrupt status we need? - - + /* Other informations in interrupt status we need? */ DMESG("<---- cmpk_handle_interrupt_status()\n"); +} -} /* cmpk_handle_interrupt_status */ - - -/*----------------------------------------------------------------------------- +/* * Function: cmpk_handle_query_config_rx() * * Overview: The function is responsible for extract the message from * firmware. It will contain dedicated info in - * ws-06-0063-rtl8190-command-packet-specification. Please - * refer to chapter "Beacon State Element". + * ws-06-0063-rtl8190-command-packet-specification + * Please refer to chapter "Beacon State Element". * * Input: u8 * pmsg - Message Pointer of the command packet. * @@ -386,44 +251,28 @@ cmpk_handle_interrupt_status( * * Return: NONE * - * Revised History: - * When Who Remark - * 05/12/2008 amy Create Version 0 porting from windows code. - * - *---------------------------------------------------------------------------*/ -static void -cmpk_handle_query_config_rx( - struct net_device *dev, - u8* pmsg) + */ +static void cmpk_handle_query_config_rx(struct net_device *dev, u8 *pmsg) { - cmpk_query_cfg_t rx_query_cfg; /* */ - - /* 0. Display received message. */ - //cmpk_Display_Message(CMPK_RX_BEACON_STATE_SIZE, pMsg); + cmpk_query_cfg_t rx_query_cfg; + /* + * Extract TX feedback info from RFD to temp structure buffer. + */ + rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000) >> 31; + rx_query_cfg.cfg_type = (pmsg[4] & 0x60) >> 5; + rx_query_cfg.cfg_size = (pmsg[4] & 0x18) >> 3; + rx_query_cfg.cfg_page = (pmsg[6] & 0x0F) >> 0; + rx_query_cfg.cfg_offset = pmsg[7]; + rx_query_cfg.value = (pmsg[8] << 24) | (pmsg[9] << 16) | + (pmsg[10] << 8) | (pmsg[11] << 0); + rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) | + (pmsg[14] << 8) | (pmsg[15] << 0); +} - /* 1. Extract TX feedback info from RFD to temp structure buffer. */ - /* It seems that FW use big endian(MIPS) and DRV use little endian in - windows OS. So we have to read the content byte by byte or transfer - endian type before copy the message copy. */ - //rx_query_cfg.Element_ID = pMsg[0]; - //rx_query_cfg.Length = pMsg[1]; - rx_query_cfg.cfg_action = (pmsg[4] & 0x80000000)>>31; - rx_query_cfg.cfg_type = (pmsg[4] & 0x60) >> 5; - rx_query_cfg.cfg_size = (pmsg[4] & 0x18) >> 3; - rx_query_cfg.cfg_page = (pmsg[6] & 0x0F) >> 0; - rx_query_cfg.cfg_offset = pmsg[7]; - rx_query_cfg.value = (pmsg[8] << 24) | (pmsg[9] << 16) | - (pmsg[10] << 8) | (pmsg[11] << 0); - rx_query_cfg.mask = (pmsg[12] << 24) | (pmsg[13] << 16) | - (pmsg[14] << 8) | (pmsg[15] << 0); - -} /* cmpk_Handle_Query_Config_Rx */ - - -/*----------------------------------------------------------------------------- +/* * Function: cmpk_count_tx_status() * - * Overview: Count aggregated tx status from firmwar of one type rx command + * Overview: Count aggregated tx status from firmware of one type rx command * packet element id = RX_TX_STATUS. * * Input: NONE @@ -431,14 +280,9 @@ cmpk_handle_query_config_rx( * Output: NONE * * Return: NONE - * - * Revised History: - * When Who Remark - * 05/12/2008 amy Create Version 0 porting from windows code. - * - *---------------------------------------------------------------------------*/ -static void cmpk_count_tx_status( struct net_device *dev, - cmpk_tx_status_t *pstx_status) + */ +static void cmpk_count_tx_status(struct net_device *dev, + cmpk_tx_status_t *pstx_status) { struct r8192_priv *priv = ieee80211_priv(dev); @@ -448,13 +292,13 @@ static void cmpk_count_tx_status( struct net_device *dev, pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); - // When RF is off, we should not count the packet for hw/sw synchronize - // reason, ie. there may be a duration while sw switch is changed and hw - // switch is being changed. 2006.12.04, by shien chang. + /* + * When RF is off, we should not count the packet for hw/sw synchronize + * reason, ie. there may be a duration while sw switch is changed and hw + * switch is being changed. + */ if (rtState == eRfOff) - { return; - } #endif priv->stats.txfeedbackok += pstx_status->txok; @@ -463,15 +307,11 @@ static void cmpk_count_tx_status( struct net_device *dev, priv->stats.txfeedbackfail += pstx_status->txfail; priv->stats.txerrtotal += pstx_status->txfail; - priv->stats.txretrycount += pstx_status->txretry; + priv->stats.txretrycount += pstx_status->txretry; priv->stats.txfeedbackretry += pstx_status->txretry; - //pAdapter->TxStats.NumTxOkBytesTotal += psTx_FB->pkt_length; - //pAdapter->TxStats.NumTxErrBytesTotal += psTx_FB->pkt_length; - //pAdapter->MgntInfo.LinkDetectInfo.NumTxOkInPeriod++; - - priv->stats.txmulticast += pstx_status->txmcok; - priv->stats.txbroadcast += pstx_status->txbcok; + priv->stats.txmulticast += pstx_status->txmcok; + priv->stats.txbroadcast += pstx_status->txbcok; priv->stats.txunicast += pstx_status->txucok; priv->stats.txerrmulticast += pstx_status->txmcfail; @@ -480,14 +320,12 @@ static void cmpk_count_tx_status( struct net_device *dev, priv->stats.txbytesmulticast += pstx_status->txmclength; priv->stats.txbytesbroadcast += pstx_status->txbclength; - priv->stats.txbytesunicast += pstx_status->txuclength; - - priv->stats.last_packet_rate = pstx_status->rate; -} /* cmpk_CountTxStatus */ - + priv->stats.txbytesunicast += pstx_status->txuclength; + priv->stats.last_packet_rate = pstx_status->rate; +} -/*----------------------------------------------------------------------------- +/* * Function: cmpk_handle_tx_status() * * Overview: Firmware add a new tx feedback status to reduce rx command @@ -498,27 +336,18 @@ static void cmpk_count_tx_status( struct net_device *dev, * Output: NONE * * Return: NONE - * - * Revised History: - * When Who Remark - * 05/12/2008 amy Create Version 0 porting from windows code. - * - *---------------------------------------------------------------------------*/ + */ static void -cmpk_handle_tx_status( - struct net_device *dev, - u8* pmsg) +cmpk_handle_tx_status(struct net_device *dev, u8 *pmsg) { - cmpk_tx_status_t rx_tx_sts; /* */ + cmpk_tx_status_t rx_tx_sts; - memcpy((void*)&rx_tx_sts, (void*)pmsg, sizeof(cmpk_tx_status_t)); + memcpy((void *)&rx_tx_sts, (void *)pmsg, sizeof(cmpk_tx_status_t)); /* 2. Use tx feedback info to count TX statistics. */ cmpk_count_tx_status(dev, &rx_tx_sts); +} -} /* cmpk_Handle_Tx_Status */ - - -/*----------------------------------------------------------------------------- +/* * Function: cmpk_handle_tx_rate_history() * * Overview: Firmware add a new tx rate history @@ -528,117 +357,90 @@ cmpk_handle_tx_status( * Output: NONE * * Return: NONE - * - * Revised History: - * When Who Remark - * 05/12/2008 amy Create Version 0 porting from windows code. - * - *---------------------------------------------------------------------------*/ -static void -cmpk_handle_tx_rate_history( - struct net_device *dev, - u8* pmsg) + */ +static void cmpk_handle_tx_rate_history(struct net_device *dev, u8 *pmsg) { cmpk_tx_rahis_t *ptxrate; -// RT_RF_POWER_STATE rtState; - u8 i, j; - u16 length = sizeof(cmpk_tx_rahis_t); - u32 *ptemp; + u8 i, j; + u16 length = sizeof(cmpk_tx_rahis_t); + u32 *ptemp; struct r8192_priv *priv = ieee80211_priv(dev); - #ifdef ENABLE_PS - pAdapter->HalFunc.GetHwRegHandler(pAdapter, HW_VAR_RF_STATE, (pu1Byte)(&rtState)); - - // When RF is off, we should not count the packet for hw/sw synchronize - // reason, ie. there may be a duration while sw switch is changed and hw - // switch is being changed. 2006.12.04, by shien chang. + pAdapter->HalFunc.GetHwRegHandler(pAdapter, + HW_VAR_RF_STATE, + (pu1Byte)(&rtState)); + /* + * When RF is off, we should not count the packet for hw/sw synchronize + * reason, ie. there may be a duration while sw switch is changed and hw + * switch is being changed. + */ if (rtState == eRfOff) - { return; - } #endif - ptemp = (u32 *)pmsg; - // - // Do endian transfer to word alignment(16 bits) for windows system. - // You must do different endian transfer for linux and MAC OS - // - for (i = 0; i < (length/4); i++) - { - u16 temp1, temp2; - - temp1 = ptemp[i]&0x0000FFFF; - temp2 = ptemp[i]>>16; - ptemp[i] = (temp1<<16)|temp2; + /* + * Do endian transfer to word alignment(16 bits) for windows system. + * You must do different endian transfer for linux and MAC OS + */ + for (i = 0; i < (length/4); i++) { + u16 temp1, temp2; + temp1 = ptemp[i] & 0x0000FFFF; + temp2 = ptemp[i] >> 16; + ptemp[i] = (temp1 << 16) | temp2; } ptxrate = (cmpk_tx_rahis_t *)pmsg; - if (ptxrate == NULL ) - { + if (ptxrate == NULL) return; - } - for (i = 0; i < 16; i++) - { - // Collect CCK rate packet num + for (i = 0; i < 16; i++) { + /* Collect CCK rate packet num */ if (i < 4) priv->stats.txrate.cck[i] += ptxrate->cck[i]; - - // Collect OFDM rate packet num - if (i< 8) + /* Collect OFDM rate packet num */ + if (i < 8) priv->stats.txrate.ofdm[i] += ptxrate->ofdm[i]; - for (j = 0; j < 4; j++) priv->stats.txrate.ht_mcs[j][i] += ptxrate->ht_mcs[j][i]; } -} /* cmpk_Handle_Tx_Rate_History */ - +} -/*----------------------------------------------------------------------------- +/* * Function: cmpk_message_handle_rx() * * Overview: In the function, we will capture different RX command packet - * info. Every RX command packet element has different message - * length and meaning in content. We only support three type of RX - * command packet now. Please refer to document - * ws-06-0063-rtl8190-command-packet-specification. + * info. Every RX command packet element has different message + * length and meaning in content. We only support three type of RX + * command packet now. Please refer to document + * ws-06-0063-rtl8190-command-packet-specification. * * Input: NONE * * Output: NONE * * Return: NONE - * - * Revised History: - * When Who Remark - * 05/06/2008 amy Create Version 0 porting from windows code. - * - *---------------------------------------------------------------------------*/ + */ extern u32 cmpk_message_handle_rx( struct net_device *dev, struct ieee80211_rx_stats *pstats) { -// u32 debug_level = DBG_LOUD; struct r8192_priv *priv = ieee80211_priv(dev); int total_length; u8 cmd_length, exe_cnt = 0; u8 element_id; u8 *pcmd_buff; - /* 0. Check inpt arguments. If is is a command queue message or pointer is - null. */ - if (/*(prfd->queue_id != CMPK_RX_QUEUE_ID) || */(pstats== NULL)) - { - /* Print error message. */ - /*RT_TRACE(COMP_SEND, DebugLevel, - ("\n\r[CMPK]-->Err queue id or pointer"));*/ + /* + * 0. Check input arguments. + * If is is a command queue message or pointer is null + */ + if ((pstats == NULL)) return 0; /* This is not a command packet. */ - } /* 1. Read received command packet message length from RFD. */ total_length = pstats->Length; @@ -648,70 +450,49 @@ cmpk_message_handle_rx( /* 3. Read command pakcet element id and length. */ element_id = pcmd_buff[0]; - /*RT_TRACE(COMP_SEND, DebugLevel, - ("\n\r[CMPK]-->element ID=%d Len=%d", element_id, total_length));*/ - - /* 4. Check every received command packet conent according to different - element type. Because FW may aggregate RX command packet to minimize - transmit time between DRV and FW.*/ - // Add a counter to prevent to locked in the loop too long - while (total_length > 0 || exe_cnt++ >100) - { - /* 2007/01/17 MH We support aggregation of different cmd in the same packet. */ - element_id = pcmd_buff[0]; - switch(element_id) - { - case RX_TX_FEEDBACK: - cmpk_handle_tx_feedback (dev, pcmd_buff); - cmd_length = CMPK_RX_TX_FB_SIZE; - break; - - case RX_INTERRUPT_STATUS: - cmpk_handle_interrupt_status(dev, pcmd_buff); - cmd_length = sizeof(cmpk_intr_sta_t); - break; - - case BOTH_QUERY_CONFIG: - cmpk_handle_query_config_rx(dev, pcmd_buff); - cmd_length = CMPK_BOTH_QUERY_CONFIG_SIZE; - break; - - case RX_TX_STATUS: - cmpk_handle_tx_status(dev, pcmd_buff); - cmd_length = CMPK_RX_TX_STS_SIZE; - break; - - case RX_TX_PER_PKT_FEEDBACK: - // You must at lease add a switch case element here, - // Otherwise, we will jump to default case. - //DbgPrint("CCX Test\r\n"); - cmd_length = CMPK_RX_TX_FB_SIZE; - break; - - case RX_TX_RATE_HISTORY: - //DbgPrint(" rx tx rate history\r\n"); - cmpk_handle_tx_rate_history(dev, pcmd_buff); - cmd_length = CMPK_TX_RAHIS_SIZE; - break; - - default: - - RT_TRACE(COMP_ERR, "---->cmpk_message_handle_rx():unknown CMD Element\n"); - return 1; /* This is a command packet. */ - } - // 2007/01/22 MH Display received rx command packet info. - //cmpk_Display_Message(cmd_length, pcmd_buff); + /* + * 4. Check every received command packet conent according to different + * element type. Because FW may aggregate RX command packet to minimize + * transmit time between DRV and FW. + */ - // 2007/01/22 MH Add to display tx statistic. - //cmpk_DisplayTxStatistic(pAdapter); - - /* 2007/03/09 MH Collect sidderent cmd element pkt num. */ + /* Add a counter to prevent to locked in the loop too long */ + while (total_length > 0 || exe_cnt++ > 100) { + /* We support aggregation of different cmd in the same packet */ + element_id = pcmd_buff[0]; + switch (element_id) { + case RX_TX_FEEDBACK: + cmpk_handle_tx_feedback(dev, pcmd_buff); + cmd_length = CMPK_RX_TX_FB_SIZE; + break; + case RX_INTERRUPT_STATUS: + cmpk_handle_interrupt_status(dev, pcmd_buff); + cmd_length = sizeof(cmpk_intr_sta_t); + break; + case BOTH_QUERY_CONFIG: + cmpk_handle_query_config_rx(dev, pcmd_buff); + cmd_length = CMPK_BOTH_QUERY_CONFIG_SIZE; + break; + case RX_TX_STATUS: + cmpk_handle_tx_status(dev, pcmd_buff); + cmd_length = CMPK_RX_TX_STS_SIZE; + break; + case RX_TX_PER_PKT_FEEDBACK: + cmd_length = CMPK_RX_TX_FB_SIZE; + break; + case RX_TX_RATE_HISTORY: + cmpk_handle_tx_rate_history(dev, pcmd_buff); + cmd_length = CMPK_TX_RAHIS_SIZE; + break; + default: + RT_TRACE(COMP_ERR, "(%s): unknown CMD Element\n", + __func__); + return 1; /* This is a command packet. */ + } priv->stats.rxcmdpkt[element_id]++; - total_length -= cmd_length; pcmd_buff += cmd_length; - } /* while (total_length > 0) */ - return 1; /* This is a command packet. */ - -} /* CMPK_Message_Handle_Rx */ + } + return 1; /* This is a command packet. */ +} diff --git a/drivers/staging/rtl8192su/r819xU_cmdpkt.h b/drivers/staging/rtl8192su/r819xU_cmdpkt.h index cced8e0d2788..d3c561551880 100644 --- a/drivers/staging/rtl8192su/r819xU_cmdpkt.h +++ b/drivers/staging/rtl8192su/r819xU_cmdpkt.h @@ -1,199 +1,191 @@ #ifndef R819XUSB_CMDPKT_H #define R819XUSB_CMDPKT_H -/* Different command packet have dedicated message length and definition. */ -#define CMPK_RX_TX_FB_SIZE sizeof(cmpk_txfb_t) //20 -#define CMPK_TX_SET_CONFIG_SIZE sizeof(cmpk_set_cfg_t) //16 -#define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(cmpk_set_cfg_t) //16 -#define CMPK_RX_TX_STS_SIZE sizeof(cmpk_tx_status_t)// -#define CMPK_RX_DBG_MSG_SIZE sizeof(cmpk_rx_dbginfo_t)// -#define CMPK_TX_RAHIS_SIZE sizeof(cmpk_tx_rahis_t) - -/* 2008/05/08 amy For USB constant. */ -#define ISR_TxBcnOk BIT27 // Transmit Beacon OK -#define ISR_TxBcnErr BIT26 // Transmit Beacon Error -#define ISR_BcnTimerIntr BIT13 // Beacon Timer Interrupt - -/* Define element ID of command packet. */ - -/*------------------------------Define structure----------------------------*/ -/* Define different command packet structure. */ -/* 1. RX side: TX feedback packet. */ -typedef struct tag_cmd_pkt_tx_feedback -{ - // DWORD 0 - u8 element_id; /* Command packet type. */ - u8 length; /* Command packet length. */ - /* 2007/07/05 MH Change tx feedback info field. */ - /*------TX Feedback Info Field */ - u8 TID:4; /* */ - u8 fail_reason:3; /* */ - u8 tok:1; /* Transmit ok. */ - u8 reserve1:4; /* */ - u8 pkt_type:2; /* */ - u8 bandwidth:1; /* */ - u8 qos_pkt:1; /* */ - - // DWORD 1 - u8 reserve2; /* */ - /*------TX Feedback Info Field */ - u8 retry_cnt; /* */ - u16 pkt_id; /* */ - - // DWORD 3 - u16 seq_num; /* */ - u8 s_rate; /* Start rate. */ - u8 f_rate; /* Final rate. */ - - // DWORD 4 - u8 s_rts_rate; /* */ - u8 f_rts_rate; /* */ - u16 pkt_length; /* */ - - // DWORD 5 - u16 reserve3; /* */ - u16 duration; /* */ -}cmpk_txfb_t; - -/* 2. RX side: Interrupt status packet. It includes Beacon State, - Beacon Timer Interrupt and other useful informations in MAC ISR Reg. */ -typedef struct tag_cmd_pkt_interrupt_status -{ - u8 element_id; /* Command packet type. */ - u8 length; /* Command packet length. */ - u16 reserve; - u32 interrupt_status; /* Interrupt Status. */ -}cmpk_intr_sta_t; - - -/* 3. TX side: Set configuration packet. */ -typedef struct tag_cmd_pkt_set_configuration -{ - u8 element_id; /* Command packet type. */ - u8 length; /* Command packet length. */ - u16 reserve1; /* */ - u8 cfg_reserve1:3; - u8 cfg_size:2; /* Configuration info. */ - u8 cfg_type:2; /* Configuration info. */ - u8 cfg_action:1; /* Configuration info. */ - u8 cfg_reserve2; /* Configuration info. */ - u8 cfg_page:4; /* Configuration info. */ - u8 cfg_reserve3:4; /* Configuration info. */ - u8 cfg_offset; /* Configuration info. */ - u32 value; /* */ - u32 mask; /* */ -}cmpk_set_cfg_t; - -/* 4. Both side : TX/RX query configuraton packet. The query structure is the - same as set configuration. */ -#define cmpk_query_cfg_t cmpk_set_cfg_t -/* 5. Multi packet feedback status. */ -typedef struct tag_tx_stats_feedback // PJ quick rxcmd 09042007 -{ - // For endian transfer --> Driver will not the same as firmware structure. - // DW 0 +/* + * Different command packets have dedicated message length and definition. + */ +#define CMPK_RX_TX_FB_SIZE sizeof(cmpk_txfb_t) /* 20 */ +#define CMPK_TX_SET_CONFIG_SIZE sizeof(cmpk_set_cfg_t) /* 16 */ +#define CMPK_BOTH_QUERY_CONFIG_SIZE sizeof(cmpk_set_cfg_t) /* 16 */ +#define CMPK_RX_TX_STS_SIZE sizeof(cmpk_tx_status_t) +#define CMPK_RX_DBG_MSG_SIZE sizeof(cmpk_rx_dbginfo_t) +#define CMPK_TX_RAHIS_SIZE sizeof(cmpk_tx_rahis_t) + +/* For USB constant. */ +#define ISR_TxBcnOk BIT27 /* Transmit Beacon OK */ +#define ISR_TxBcnErr BIT26 /* Transmit Beacon Error */ +#define ISR_BcnTimerIntr BIT13 /* Beacon Timer Interrupt */ + +/* + * Define different command packet structures + * + * 1. RX side: TX feedback packet. + */ +typedef struct tag_cmd_pkt_tx_feedback { + /* DWORD 0 */ + u8 element_id; /* Command packet type. */ + u8 length; /* Command packet length. */ + /* TX Feedback Info Field */ + u8 TID:4; + u8 fail_reason:3; + u8 tok:1; /* Transmit ok. */ + u8 reserve1:4; + u8 pkt_type:2; + u8 bandwidth:1; + u8 qos_pkt:1; + + /* DWORD 1 */ + u8 reserve2; + /* TX Feedback Info Field */ + u8 retry_cnt; + u16 pkt_id; + + /* DWORD 3 */ + u16 seq_num; + u8 s_rate; /* Start rate. */ + u8 f_rate; /* Final rate. */ + + /* DWORD 4 */ + u8 s_rts_rate; + u8 f_rts_rate; + u16 pkt_length; + + /* DWORD 5 */ + u16 reserve3; + u16 duration; +} cmpk_txfb_t; + +/* + * 2. RX side: Interrupt status packet. + * It includes Beacon State, Beacon Timer Interrupt + * and other useful informations in MAC ISR Reg. + */ +typedef struct tag_cmd_pkt_interrupt_status { + u8 element_id; /* Command packet type. */ + u8 length; /* Command packet length. */ + u16 reserve; + u32 interrupt_status; /* Interrupt Status. */ +} cmpk_intr_sta_t; + + +/* + * 3. TX side: Set configuration packet. + */ +typedef struct tag_cmd_pkt_set_configuration { + u8 element_id; /* Command packet type. */ + u8 length; /* Command packet length. */ u16 reserve1; - u8 length; // Command packet length - u8 element_id; // Command packet type - - // DW 1 - u16 txfail; // Tx Fail count - u16 txok; // Tx ok count - - // DW 2 - u16 txmcok; // tx multicast - u16 txretry; // Tx Retry count - - // DW 3 - u16 txucok; // tx unicast - u16 txbcok; // tx broadcast - - // DW 4 - u16 txbcfail; // - u16 txmcfail; // - - // DW 5 - u16 reserve2; // - u16 txucfail; // - - // DW 6-8 - u32 txmclength; - u32 txbclength; - u32 txuclength; - - // DW 9 - u16 reserve3_23; - u8 reserve3_1; - u8 rate; -}__attribute__((packed)) cmpk_tx_status_t; - -/* 6. Debug feedback message. */ -/* 2007/10/23 MH Define RX debug message */ -typedef struct tag_rx_debug_message_feedback -{ - // For endian transfer --> for driver - // DW 0 - u16 reserve1; - u8 length; // Command packet length - u8 element_id; // Command packet type - - // DW 1-?? - // Variable debug message. - -}cmpk_rx_dbginfo_t; - -/* 2008/03/20 MH Define transmit rate history. For big endian format. */ -typedef struct tag_tx_rate_history -{ - // For endian transfer --> for driver - // DW 0 - u8 element_id; // Command packet type - u8 length; // Command packet length - u16 reserved1; - - // DW 1-2 CCK rate counter - u16 cck[4]; - - // DW 3-6 - u16 ofdm[8]; - - // DW 7-14 - //UINT16 MCS_BW0_SG0[16]; - - // DW 15-22 - //UINT16 MCS_BW1_SG0[16]; - - // DW 23-30 - //UINT16 MCS_BW0_SG1[16]; - - // DW 31-38 - //UINT16 MCS_BW1_SG1[16]; - - // DW 7-14 BW=0 SG=0 - // DW 15-22 BW=1 SG=0 - // DW 23-30 BW=0 SG=1 - // DW 31-38 BW=1 SG=1 - u16 ht_mcs[4][16]; - -}__attribute__((packed)) cmpk_tx_rahis_t; + u8 cfg_reserve1:3; + u8 cfg_size:2; /* Configuration info. */ + u8 cfg_type:2; /* Configuration info. */ + u8 cfg_action:1; /* Configuration info. */ + u8 cfg_reserve2; /* Configuration info. */ + u8 cfg_page:4; /* Configuration info. */ + u8 cfg_reserve3:4; /* Configuration info. */ + u8 cfg_offset; /* Configuration info. */ + u32 value; + u32 mask; +} cmpk_set_cfg_t; + +/* + * 4. Both side : TX/RX query configuraton packet. + * The query structure is the same as set configuration. + */ +#define cmpk_query_cfg_t cmpk_set_cfg_t -typedef enum tag_command_packet_directories -{ +/* + * 5. Multi packet feedback status. + */ +typedef struct tag_tx_stats_feedback { + /* + * For endian transfer + * Driver will not the same as firmware structure. + */ + /* DW 0 */ + u16 reserve1; + u8 length; /* Command packet length */ + u8 element_id; /* Command packet type */ + + /* DW 1 */ + u16 txfail; /* Tx Fail count */ + u16 txok; /* Tx ok count */ + + /* DW 2 */ + u16 txmcok; /* tx multicast */ + u16 txretry; /* Tx Retry count */ + + /* DW 3 */ + u16 txucok; /* tx unicast */ + u16 txbcok; /* tx broadcast */ + + /* DW 4 */ + u16 txbcfail; + u16 txmcfail; + + /* DW 5 */ + u16 reserve2; + u16 txucfail; + + /* DW 6-8 */ + u32 txmclength; + u32 txbclength; + u32 txuclength; + + /* DW 9 */ + u16 reserve3_23; + u8 reserve3_1; + u8 rate; +} __attribute__((packed)) cmpk_tx_status_t; + +/* + * 6. Debug feedback message. + */ +typedef struct tag_rx_debug_message_feedback { + /* For endian transfer --> for driver */ + /* DW 0 */ + u16 reserve1; + u8 length; /* Command packet length */ + u8 element_id; /* Command packet type */ +} cmpk_rx_dbginfo_t; + +/* + * Define transmit rate history. For big endian format. + */ +typedef struct tag_tx_rate_history { + /* For endian transfer --> for driver */ + /* DW 0 */ + u8 element_id; /* Command packet type */ + u8 length; /* Command packet length */ + u16 reserved1; + /* DW 1-2 CCK rate counter */ + u16 cck[4]; + /* DW 3-6 */ + u16 ofdm[8]; + u16 ht_mcs[4][16]; +} __attribute__((packed)) cmpk_tx_rahis_t; + +typedef enum tag_command_packet_directories { RX_TX_FEEDBACK = 0, - RX_INTERRUPT_STATUS = 1, - TX_SET_CONFIG = 2, - BOTH_QUERY_CONFIG = 3, - RX_TX_STATUS = 4, - RX_DBGINFO_FEEDBACK = 5, - RX_TX_PER_PKT_FEEDBACK = 6, - RX_TX_RATE_HISTORY = 7, + RX_INTERRUPT_STATUS = 1, + TX_SET_CONFIG = 2, + BOTH_QUERY_CONFIG = 3, + RX_TX_STATUS = 4, + RX_DBGINFO_FEEDBACK = 5, + RX_TX_PER_PKT_FEEDBACK = 6, + RX_TX_RATE_HISTORY = 7, RX_CMD_ELE_MAX -}cmpk_element_e; +} cmpk_element_e; -extern bool cmpk_message_handle_tx(struct net_device *dev, u8* codevirtualaddress, u32 packettype, u32 buffer_len); +extern bool cmpk_message_handle_tx(struct net_device *dev, + u8 *codevirtualaddress, + u32 packettype, + u32 buffer_len); -extern u32 cmpk_message_handle_rx(struct net_device *dev, struct ieee80211_rx_stats * pstats); -extern bool SendTxCommandPacket( struct net_device *dev, void* pData, u32 DataLen); +extern u32 cmpk_message_handle_rx(struct net_device *dev, + struct ieee80211_rx_stats *pstats); +extern bool SendTxCommandPacket(struct net_device *dev, + void *pData, + u32 DataLen); #endif diff --git a/drivers/staging/rtl8192u/dot11d.h b/drivers/staging/rtl8192u/dot11d.h index 15b7a4ba37b6..0851b9db17a6 100644 --- a/drivers/staging/rtl8192u/dot11d.h +++ b/drivers/staging/rtl8192u/dot11d.h @@ -4,44 +4,44 @@ #ifdef ENABLE_DOT11D #include "ieee80211.h" -//#define ENABLE_DOT11D - -//#define DOT11D_MAX_CHNL_NUM 83 typedef struct _CHNL_TXPOWER_TRIPLE { u8 FirstChnl; u8 NumChnls; u8 MaxTxPowerInDbm; -}CHNL_TXPOWER_TRIPLE, *PCHNL_TXPOWER_TRIPLE; +} CHNL_TXPOWER_TRIPLE, *PCHNL_TXPOWER_TRIPLE; typedef enum _DOT11D_STATE { DOT11D_STATE_NONE = 0, DOT11D_STATE_LEARNED, DOT11D_STATE_DONE, -}DOT11D_STATE; +} DOT11D_STATE; typedef struct _RT_DOT11D_INFO { - //DECLARE_RT_OBJECT(RT_DOT11D_INFO); + /* DECLARE_RT_OBJECT(RT_DOT11D_INFO); */ - bool bEnabled; // dot11MultiDomainCapabilityEnabled + bool bEnabled; /* dot11MultiDomainCapabilityEnabled */ - u16 CountryIeLen; // > 0 if CountryIeBuf[] contains valid country information element. + u16 CountryIeLen; /* > 0 if CountryIeBuf[] contains valid country information element. */ u8 CountryIeBuf[MAX_IE_LEN]; - u8 CountryIeSrcAddr[6]; // Source AP of the country IE. + u8 CountryIeSrcAddr[6]; /* Source AP of the country IE. */ u8 CountryIeWatchdog; - u8 channel_map[MAX_CHANNEL_NUMBER+1]; //!!!Value 0: Invalid, 1: Valid (active scan), 2: Valid (passive scan) - //u8 ChnlListLen; // #Bytes valid in ChnlList[]. - //u8 ChnlList[DOT11D_MAX_CHNL_NUM]; + u8 channel_map[MAX_CHANNEL_NUMBER+1]; /* !Value 0: Invalid, 1: Valid (active scan), 2: Valid (passive scan) */ u8 MaxTxPwrDbmList[MAX_CHANNEL_NUMBER+1]; DOT11D_STATE State; -}RT_DOT11D_INFO, *PRT_DOT11D_INFO; -#define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 ) -#define cpMacAddr(des,src) ((des)[0]=(src)[0],(des)[1]=(src)[1],(des)[2]=(src)[2],(des)[3]=(src)[3],(des)[4]=(src)[4],(des)[5]=(src)[5]) +} RT_DOT11D_INFO, *PRT_DOT11D_INFO; +#define eqMacAddr(a, b) (((a)[0] == (b)[0] && \ + (a)[1] == (b)[1] && (a)[2] == (b)[2] && (a)[3] == (b)[3] && \ + (a)[4] == (b)[4] && (a)[5] == (b)[5]) ? 1 : 0) +#define cpMacAddr(des, src) ((des)[0] = (src)[0], \ + (des)[1] = (src)[1], (des)[2] = (src)[2], \ + (des)[3] = (src)[3], (des)[4] = (src)[4], \ + (des)[5] = (src)[5]) #define GET_DOT11D_INFO(__pIeeeDev) ((PRT_DOT11D_INFO)((__pIeeeDev)->pDot11dInfo)) -#define IS_DOT11D_ENABLE(__pIeeeDev) GET_DOT11D_INFO(__pIeeeDev)->bEnabled +#define IS_DOT11D_ENABLE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->bEnabled) #define IS_COUNTRY_IE_VALID(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0) #define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa) eqMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa) @@ -53,9 +53,9 @@ typedef struct _RT_DOT11D_INFO { (!memcmp(GET_DOT11D_INFO(__pIeeeDev)->CountryIeBuf, (__Ie).Octet, (__Ie).Length))) #define CIE_WATCHDOG_TH 1 -#define GET_CIE_WATCHDOG(__pIeeeDev) GET_DOT11D_INFO(__pIeeeDev)->CountryIeWatchdog +#define GET_CIE_WATCHDOG(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->CountryIeWatchdog) #define RESET_CIE_WATCHDOG(__pIeeeDev) GET_CIE_WATCHDOG(__pIeeeDev) = 0 -#define UPDATE_CIE_WATCHDOG(__pIeeeDev) ++GET_CIE_WATCHDOG(__pIeeeDev) +#define UPDATE_CIE_WATCHDOG(__pIeeeDev) (++GET_CIE_WATCHDOG(__pIeeeDev)) #define IS_DOT11D_STATE_DONE(__pIeeeDev) (GET_DOT11D_INFO(__pIeeeDev)->State == DOT11D_STATE_DONE) @@ -73,9 +73,9 @@ Dot11d_Reset( void Dot11d_UpdateCountryIe( struct ieee80211_device *dev, - u8 * pTaddr, - u16 CoutryIeLen, - u8 * pCoutryIe + u8 *pTaddr, + u16 CoutryIeLen, + u8 *pCoutryIe ); u8 @@ -86,17 +86,17 @@ DOT11D_GetMaxTxPwrInDbm( void DOT11D_ScanComplete( - struct ieee80211_device * dev + struct ieee80211_device *dev ); int IsLegalChannel( - struct ieee80211_device * dev, + struct ieee80211_device *dev, u8 channel ); int ToLegalChannel( - struct ieee80211_device * dev, + struct ieee80211_device *dev, u8 channel ); -#endif //ENABLE_DOT11D -#endif // #ifndef __INC_DOT11D_H +#endif /* ENABLE_DOT11D */ +#endif /* #ifndef __INC_DOT11D_H */ diff --git a/drivers/staging/rtl8192u/ieee80211.h b/drivers/staging/rtl8192u/ieee80211.h index 9d05ed6791ee..ef9e941f4967 100644 --- a/drivers/staging/rtl8192u/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211.h @@ -58,12 +58,12 @@ * */ #define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) + const typeof(((type *)0)->member) (*__mptr = (ptr)); \ + (type *)((char *)__mptr - offsetof(type, member)); }) #endif #define KEY_TYPE_NA 0x0 -#define KEY_TYPE_WEP40 0x1 +#define KEY_TYPE_WEP40 0x1 #define KEY_TYPE_TKIP 0x2 #define KEY_TYPE_CCMP 0x4 #define KEY_TYPE_WEP104 0x5 @@ -71,9 +71,9 @@ /* added for rtl819x tx procedure */ #define MAX_QUEUE_SIZE 0x10 -// -// 8190 queue mapping -// +/* + * 8190 queue mapping + */ #define BK_QUEUE 0 #define BE_QUEUE 1 #define VI_QUEUE 2 @@ -87,13 +87,13 @@ #define LOW_QUEUE BE_QUEUE #define NORMAL_QUEUE MGNT_QUEUE -//added by amy for ps +/* added by amy for ps */ #define SWRF_TIMEOUT 50 -//added by amy for LEAP related -#define IE_CISCO_FLAG_POSITION 0x08 // Flag byte: byte 8, numbered from 0. -#define SUPPORT_CKIP_MIC 0x08 // bit3 -#define SUPPORT_CKIP_PK 0x10 // bit4 +/* added by amy for LEAP related */ +#define IE_CISCO_FLAG_POSITION 0x08 /* Flag byte: byte 8, numbered from 0. */ +#define SUPPORT_CKIP_MIC 0x08 /* bit3 */ +#define SUPPORT_CKIP_PK 0x10 /* bit4 */ /* defined for skb cb field */ /* At most 28 byte */ typedef struct cb_desc { @@ -105,7 +105,7 @@ typedef struct cb_desc { u8 bEncrypt:1; u8 bTxDisableRateFallBack:1; u8 bTxUseDriverAssingedRate:1; - u8 bHwSec:1; //indicate whether use Hw security. WB + u8 bHwSec:1; /* indicate whether use Hw security. WB */ u8 reserved1; @@ -125,17 +125,13 @@ typedef struct cb_desc { u8 bRTSUseShortGI:1; u8 bMulticast:1; u8 bBroadcast:1; - //u8 reserved2:2; u8 drv_agg_enable:1; u8 reserved2:1; /* Tx Desc related element(12-19) */ u8 rata_index; u8 queue_index; - //u8 reserved3; - //u8 reserved4; u16 txbuf_size; - //u8 reserved5; u8 RATRIndex; u8 reserved6; u8 reserved7; @@ -146,13 +142,10 @@ typedef struct cb_desc { u8 rts_rate; u8 ampdu_factor; u8 ampdu_density; - //u8 reserved9; - //u8 reserved10; - //u8 reserved11; u8 DrvAggrNum; u16 pkt_size; u8 reserved12; -}cb_desc, *pcb_desc; +} cb_desc, *pcb_desc; /*--------------------------Define -------------------------------------------*/ #define MGN_1M 0x02 @@ -186,9 +179,9 @@ typedef struct cb_desc { #define MGN_MCS14 0x8e #define MGN_MCS15 0x8f -//---------------------------------------------------------------------------- -// 802.11 Management frame Reason Code field -//---------------------------------------------------------------------------- +/* + * 802.11 Management frame Reason Code field + */ enum _ReasonCode{ unspec_reason = 0x1, auth_not_valid = 0x2, @@ -200,11 +193,11 @@ enum _ReasonCode{ disas_lv_ss = 0x8, asoc_not_auth = 0x9, - //----MIC_CHECK + /* ----MIC_CHECK */ mic_failure = 0xe, - //----END MIC_CHECK + /* ----END MIC_CHECK */ - // Reason code defined in 802.11i D10.0 p.28. + /* Reason code defined in 802.11i D10.0 p.28. */ invalid_IE = 0x0d, four_way_tmout = 0x0f, two_way_tmout = 0x10, @@ -214,27 +207,29 @@ enum _ReasonCode{ invalid_AKMP = 0x14, unsup_RSNIEver = 0x15, invalid_RSNIE = 0x16, - auth_802_1x_fail= 0x17, + auth_802_1x_fail = 0x17, ciper_reject = 0x18, - // Reason code defined in 7.3.1.7, 802.1e D13.0, p.42. Added by Annie, 2005-11-15. - QoS_unspec = 0x20, // 32 - QAP_bandwidth = 0x21, // 33 - poor_condition = 0x22, // 34 - no_facility = 0x23, // 35 - // Where is 36??? - req_declined = 0x25, // 37 - invalid_param = 0x26, // 38 - req_not_honored= 0x27, // 39 - TS_not_created = 0x2F, // 47 - DL_not_allowed = 0x30, // 48 - dest_not_exist = 0x31, // 49 - dest_not_QSTA = 0x32, // 50 + /* Reason code defined in 7.3.1.7, 802.1e D13.0, p.42. */ + QoS_unspec = 0x20, /* 32 */ + QAP_bandwidth = 0x21, /* 33 */ + poor_condition = 0x22, /* 34 */ + no_facility = 0x23, /* 35 */ + /* Where is 36??? */ + req_declined = 0x25, /* 37 */ + invalid_param = 0x26, /* 38 */ + req_not_honored = 0x27, /* 39 */ + TS_not_created = 0x2F, /* 47 */ + DL_not_allowed = 0x30, /* 48 */ + dest_not_exist = 0x31, /* 49 */ + dest_not_QSTA = 0x32, /* 50 */ }; -#define aSifsTime ((priv->ieee80211->current_network.mode == IEEE_A)||(priv->ieee80211->current_network.mode == IEEE_N_24G)||(priv->ieee80211->current_network.mode == IEEE_N_5G))? 16 : 10 +#define aSifsTime ((priv->ieee80211->current_network.mode == IEEE_A) || \ + (priv->ieee80211->current_network.mode == IEEE_N_24G) || \ + (priv->ieee80211->current_network.mode == IEEE_N_5G)) ? 16 : 10 #define MGMT_QUEUE_NUM 5 @@ -249,15 +244,12 @@ enum _ReasonCode{ #define IEEE_PARAM_PRIVACY_INVOKED 4 #define IEEE_PARAM_AUTH_ALGS 5 #define IEEE_PARAM_IEEE_802_1X 6 -//It should consistent with the driver_XXX.c -// David, 2006.9.26 +/* It should consistent with the driver_XXX.c */ #define IEEE_PARAM_WPAX_SELECT 7 -//Added for notify the encryption type selection -// David, 2006.9.26 +/* Added for notify the encryption type selection */ #define IEEE_PROTO_WPA 1 #define IEEE_PROTO_RSN 2 -//Added for notify the encryption type selection -// David, 2006.9.26 +/* Added for notify the encryption type selection */ #define IEEE_WPAX_USEGROUP 0 #define IEEE_WPAX_WEP40 1 #define IEEE_WPAX_TKIP 2 @@ -284,7 +276,7 @@ enum _ReasonCode{ #define MAX_IE_LEN 0xff -// added for kernel conflict +/* added for kernel conflict */ #define ieee80211_crypt_deinit_entries ieee80211_crypt_deinit_entries_rsl #define ieee80211_crypt_deinit_handler ieee80211_crypt_deinit_handler_rsl #define ieee80211_crypt_delayed_deinit ieee80211_crypt_delayed_deinit_rsl @@ -385,7 +377,7 @@ typedef struct ieee_param { u8 key[0]; } crypt; } u; -}ieee_param; +} ieee_param; #if WIRELESS_EXT < 17 @@ -398,7 +390,7 @@ typedef struct ieee_param { #endif -// linux under 2.6.9 release may not support it, so modify it for common use +/* linux under 2.6.9 release may not support it, so modify it for common use */ #define MSECS(t) msecs_to_jiffies(t) #define msleep_interruptible_rsl msleep_interruptible @@ -432,7 +424,7 @@ typedef struct ieee_param { #define IEEE80211_FCTL_FRAMETYPE 0x00fc #define IEEE80211_FCTL_TODS 0x0100 #define IEEE80211_FCTL_FROMDS 0x0200 -#define IEEE80211_FCTL_DSTODS 0x0300 //added by david +#define IEEE80211_FCTL_DSTODS 0x0300 #define IEEE80211_FCTL_MOREFRAGS 0x0400 #define IEEE80211_FCTL_RETRY 0x0800 #define IEEE80211_FCTL_PM 0x1000 @@ -476,7 +468,7 @@ typedef struct ieee_param { #define IEEE80211_STYPE_CFACK 0x0050 #define IEEE80211_STYPE_CFPOLL 0x0060 #define IEEE80211_STYPE_CFACKPOLL 0x0070 -#define IEEE80211_STYPE_QOS_DATA 0x0080 //added for WMM 2006/8/2 +#define IEEE80211_STYPE_QOS_DATA 0x0080 #define IEEE80211_STYPE_QOS_NULL 0x00C0 #define IEEE80211_SCTL_FRAG 0x000F @@ -486,12 +478,12 @@ typedef struct ieee_param { #define IEEE80211_QCTL_TID 0x000F #define FC_QOS_BIT BIT7 -#define IsDataFrame(pdu) ( ((pdu[0] & 0x0C)==0x08) ? true : false ) -#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)) ) -//added by wb. Is this right? -#define IsQoSDataFrame(pframe) ((*(u16*)pframe&(IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA)) == (IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA)) -#define Frame_Order(pframe) (*(u16*)pframe&IEEE80211_FCTL_ORDER) -#define SN_LESS(a, b) (((a-b)&0x800)!=0) +#define IsDataFrame(pdu) (((pdu[0] & 0x0C) == 0x08) ? true : false) +#define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT))) + +#define IsQoSDataFrame(pframe) ((*(u16 *)pframe&(IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA)) == (IEEE80211_STYPE_QOS_DATA|IEEE80211_FTYPE_DATA)) +#define Frame_Order(pframe) (*(u16 *)pframe&IEEE80211_FCTL_ORDER) +#define SN_LESS(a, b) (((a-b)&0x800) != 0) #define SN_EQUAL(a, b) (a == b) #define MAX_DEV_ADDR_SIZE 8 typedef enum _ACT_CATEGORY{ @@ -516,10 +508,10 @@ typedef enum _BA_ACTION{ } BA_ACTION, *PBA_ACTION; typedef enum _InitialGainOpType{ - IG_Backup=0, + IG_Backup = 0, IG_Restore, IG_Max -}InitialGainOpType; +} InitialGainOpType; /* debug macros */ #define CONFIG_IEEE80211_DEBUG @@ -528,25 +520,26 @@ extern u32 ieee80211_debug_level; #define IEEE80211_DEBUG(level, fmt, args...) \ do { if (ieee80211_debug_level & (level)) \ printk(KERN_DEBUG "ieee80211: " fmt, ## args); } while (0) -//wb added to debug out data buf -//if you want print DATA buffer related BA, please set ieee80211_debug_level to DATA|BA +/* wb added to debug out data buf + * if you want print DATA buffer related BA, please set ieee80211_debug_level + * to DATA|BA + */ #define IEEE80211_DEBUG_DATA(level, data, datalen) \ - do{ if ((ieee80211_debug_level & (level)) == (level)) \ - { \ + do { if ((ieee80211_debug_level & (level)) == (level)) { \ int i; \ - u8* pdata = (u8*) data; \ + u8* pdata = (u8 *) data; \ printk(KERN_DEBUG "ieee80211: %s()\n", __FUNCTION__); \ - for(i=0; i<(int)(datalen); i++) \ - { \ + for (i = 0; i < (int)(datalen); i++) { \ printk("%2x ", pdata[i]); \ - if ((i+1)%16 == 0) printk("\n"); \ - } \ + if ((i+1)%16 == 0) \ + printk("\n"); \ + } \ printk("\n"); \ } \ } while (0) #else #define IEEE80211_DEBUG(level, fmt, args...) do {} while (0) -#define IEEE80211_DEBUG_DATA(level, data, datalen) do {} while(0) +#define IEEE80211_DEBUG_DATA(level, data, datalen) do {} while (0) #endif /* CONFIG_IEEE80211_DEBUG */ /* debug macros not dependent on CONFIG_IEEE80211_DEBUG */ @@ -589,16 +582,16 @@ do { if (ieee80211_debug_level & (level)) \ #define IEEE80211_DL_TX (1<<8) #define IEEE80211_DL_RX (1<<9) -#define IEEE80211_DL_HT (1<<10) //HT -#define IEEE80211_DL_BA (1<<11) //ba -#define IEEE80211_DL_TS (1<<12) //TS +#define IEEE80211_DL_HT (1<<10) /* HT */ +#define IEEE80211_DL_BA (1<<11) /* ba */ +#define IEEE80211_DL_TS (1<<12) /* TS */ #define IEEE80211_DL_QOS (1<<13) #define IEEE80211_DL_REORDER (1<<14) #define IEEE80211_DL_IOT (1<<15) #define IEEE80211_DL_IPS (1<<16) -#define IEEE80211_DL_TRACE (1<<29) //trace function, need to user net_ratelimit() together in order not to print too much to the screen -#define IEEE80211_DL_DATA (1<<30) //use this flag to control whether print data buf out. -#define IEEE80211_DL_ERR (1<<31) //always open +#define IEEE80211_DL_TRACE (1<<29) /* trace function, need to user net_ratelimit() together in order not to print too much to the screen */ +#define IEEE80211_DL_DATA (1<<30) /* use this flag to control whether print data buf out. */ +#define IEEE80211_DL_ERR (1<<31) /* always open */ #define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a) #define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a) #define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a) @@ -618,18 +611,17 @@ do { if (ieee80211_debug_level & (level)) \ /* Added by Annie, 2005-11-22. */ #define MAX_STR_LEN 64 /* I want to see ASCII 33 to 126 only. Otherwise, I print '?'. Annie, 2005-11-22.*/ -#define PRINTABLE(_ch) (_ch>'!' && _ch<'~') +#define PRINTABLE(_ch) (_ch > '!' && _ch < '~') #define IEEE80211_PRINT_STR(_Comp, _TitleString, _Ptr, _Len) \ - if((_Comp) & level) \ - { \ + if ((_Comp) & level) { \ int __i; \ u8 buffer[MAX_STR_LEN]; \ - int length = (_Len<MAX_STR_LEN)? _Len : (MAX_STR_LEN-1) ; \ + int length = (_Len < MAX_STR_LEN) ? _Len : (MAX_STR_LEN - 1); \ memset(buffer, 0, MAX_STR_LEN); \ - memcpy(buffer, (u8 *)_Ptr, length ); \ - for( __i=0; __i<MAX_STR_LEN; __i++ ) \ - { \ - if( !PRINTABLE(buffer[__i]) ) buffer[__i] = '?'; \ + memcpy(buffer, (u8 *)_Ptr, length); \ + for (__i = 0; __i < MAX_STR_LEN; __i++) { \ + if (!PRINTABLE(buffer[__i])) \ + buffer[__i] = '?'; \ } \ buffer[length] = '\0'; \ printk("Rtl819x: "); \ @@ -644,9 +636,9 @@ do { if (ieee80211_debug_level & (level)) \ #include <linux/if_arp.h> /* ARPHRD_ETHER */ #ifndef WIRELESS_SPY -#define WIRELESS_SPY // enable iwspy support +#define WIRELESS_SPY /* enable iwspy support */ #endif -#include <net/iw_handler.h> // new driver API +#include <net/iw_handler.h> /* new driver API */ #ifndef ETH_P_PAE #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ @@ -873,29 +865,28 @@ struct ieee80211_rx_stats { u32 beacon_time; u8 nic_type; u16 Length; - // u8 DataRate; // In 0.5 Mbps - u8 SignalQuality; // in 0-100 index. - s32 RecvSignalPower; // Real power in dBm for this packet, no beautification and aggregation. - s8 RxPower; // in dBm Translate from PWdB - u8 SignalStrength; // in 0-100 index. + u8 SignalQuality; /* in 0-100 index. */ + s32 RecvSignalPower; /* Real power in dBm for this packet, no beautification and aggregation. */ + s8 RxPower; /* in dBm Translate from PWdB */ + u8 SignalStrength; /* in 0-100 index. */ u16 bHwError:1; u16 bCRC:1; u16 bICV:1; u16 bShortPreamble:1; - u16 Antenna:1; //for rtl8185 - u16 Decrypted:1; //for rtl8185, rtl8187 - u16 Wakeup:1; //for rtl8185 - u16 Reserved0:1; //for rtl8185 + u16 Antenna:1; /* for rtl8185 */ + u16 Decrypted:1; /* for rtl8185, rtl8187 */ + u16 Wakeup:1; /* for rtl8185 */ + u16 Reserved0:1; /* for rtl8185 */ u8 AGC; u32 TimeStampLow; u32 TimeStampHigh; bool bShift; - bool bIsQosData; // Added by Annie, 2005-12-22. + bool bIsQosData; u8 UserPriority; - //1!!!!!!!!!!!!!!!!!!!!!!!!!!! - //1Attention Please!!!<11n or 8190 specific code should be put below this line> - //1!!!!!!!!!!!!!!!!!!!!!!!!!!! + /* + * 1Attention Please!!!<11n or 8190 specific code should be put below this line> + */ u8 RxDrvInfoSize; u8 RxBufShift; @@ -904,21 +895,20 @@ struct ieee80211_rx_stats { bool bContainHTC; bool RxIs40MHzPacket; u32 RxPWDBAll; - u8 RxMIMOSignalStrength[4]; // in 0~100 index + u8 RxMIMOSignalStrength[4]; /* in 0~100 index */ s8 RxMIMOSignalQuality[2]; bool bPacketMatchBSSID; bool bIsCCK; bool bPacketToSelf; - //added by amy - u8* virtual_address; - u16 packetlength; // Total packet length: Must equal to sum of all FragLength - u16 fraglength; // FragLength should equal to PacketLength in non-fragment case - u16 fragoffset; // Data offset for this fragment + u8 *virtual_address; + u16 packetlength; /* Total packet length: Must equal to sum of all FragLength */ + u16 fraglength; /* FragLength should equal to PacketLength in non-fragment case */ + u16 fragoffset; /* Data offset for this fragment */ u16 ntotalfrag; bool bisrxaggrsubframe; - bool bPacketBeacon; //cosa add for rssi - bool bToSelfBA; //cosa add for rssi - char cck_adc_pwdb[4]; //cosa add for rx path selection + bool bPacketBeacon; /* cosa add for rssi */ + bool bToSelfBA; /* cosa add for rssi */ + char cck_adc_pwdb[4]; /* cosa add for rx path selection */ u16 Seq_Num; }; @@ -1045,9 +1035,9 @@ enum ieee80211_mfie { MFIE_TYPE_ERP = 42, MFIE_TYPE_RSN = 48, MFIE_TYPE_RATES_EX = 50, - MFIE_TYPE_HT_CAP= 45, - MFIE_TYPE_HT_INFO= 61, - MFIE_TYPE_AIRONET=133, + MFIE_TYPE_HT_CAP = 45, + MFIE_TYPE_HT_INFO = 61, + MFIE_TYPE_AIRONET = 133, MFIE_TYPE_GENERIC = 221, MFIE_TYPE_QOS_PARAMETER = 222, }; @@ -1199,7 +1189,7 @@ struct ieee80211_txb { struct ieee80211_drv_agg_txb { u8 nr_drv_agg_frames; struct sk_buff *tx_agg_frames[MAX_TX_AGG_COUNT]; -}__attribute__((packed)); +} __attribute__((packed)); #define MAX_SUBFRAME_COUNT 64 struct ieee80211_rxb { @@ -1207,7 +1197,7 @@ struct ieee80211_rxb { struct sk_buff *subframes[MAX_SUBFRAME_COUNT]; u8 dst[ETH_ALEN]; u8 src[ETH_ALEN]; -}__attribute__((packed)); +} __attribute__((packed)); typedef union _frameqos { u16 shortdata; @@ -1218,8 +1208,8 @@ typedef union _frameqos { u16 ack_policy:2; u16 reserved:1; u16 txop:8; - }field; -}frameqos,*pframeqos; + } field; +} frameqos, *pframeqos; /* SWEEP TABLE ENTRIES NUMBER*/ #define MAX_SWEEP_TAB_ENTRIES 42 @@ -1234,7 +1224,7 @@ typedef union _frameqos { #define MAX_CHANNEL_NUMBER 161 #define IEEE80211_SOFTMAC_SCAN_TIME 100 -//(HZ / 2) +/* (HZ / 2) */ #define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2) #define CRC_LENGTH 4U @@ -1310,7 +1300,6 @@ struct ieee80211_tim_parameters { u8 tim_period; } __attribute__ ((packed)); -//#else struct ieee80211_wmm_ac_param { u8 ac_aci_acm_aifsn; u8 ac_ecwmin_ecwmax; @@ -1340,7 +1329,7 @@ struct ieee80211_wmm_tspec_elem { u32 min_phy_rate; u16 surp_band_allow; u16 medium_time; -}__attribute__((packed)); +} __attribute__((packed)); enum eap_type { EAP_PACKET = 0, EAPOL_START, @@ -1361,17 +1350,15 @@ static inline const char *eap_get_type(int type) { return ((u32)type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type]; } -//added by amy for reorder -static inline u8 Frame_QoSTID(u8* buf) +static inline u8 Frame_QoSTID(u8 *buf) { struct ieee80211_hdr_3addr *hdr; u16 fc; hdr = (struct ieee80211_hdr_3addr *)buf; fc = le16_to_cpu(hdr->frame_ctl); - return (u8)((frameqos*)(buf + (((fc & IEEE80211_FCTL_TODS)&&(fc & IEEE80211_FCTL_FROMDS))? 30 : 24)))->field.tid; + return (u8)((frameqos *)(buf + (((fc & IEEE80211_FCTL_TODS) && (fc & IEEE80211_FCTL_FROMDS)) ? 30 : 24)))->field.tid; } -//added by amy for reorder struct eapol { u8 snap[6]; @@ -1429,7 +1416,7 @@ struct ieee80211_info_element_hdr { */ #define IEEE80211_DEFAULT_TX_ESSID "Penguin" -#define IEEE80211_DEFAULT_BASIC_RATE 2 //1Mbps +#define IEEE80211_DEFAULT_BASIC_RATE 2 /* 1Mbps */ enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame}; #define MAX_SP_Len (WMM_all_frame << 4) @@ -1445,8 +1432,7 @@ enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame}; #define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST #define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST -//added by David for QoS 2006/6/30 -//#define WMM_Hang_8187 + #ifdef WMM_Hang_8187 #undef WMM_Hang_8187 #endif @@ -1461,15 +1447,14 @@ enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame}; #define MAX_RECEIVE_BUFFER_SIZE 9100 -//UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP -//#define UP2AC(up) ((up<3) ? ((up==0)?1:0) : (up>>1)) +/* UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP */ #define UP2AC(up) ( \ ((up) < 1) ? WME_AC_BE : \ ((up) < 3) ? WME_AC_BK : \ ((up) < 4) ? WME_AC_BE : \ ((up) < 6) ? WME_AC_VI : \ WME_AC_VO) -//AC Mapping to UP, using in Tx part for selecting the corresponding TX queue +/* AC Mapping to UP, using in Tx part for selecting the corresponding TX queue */ #define AC2UP(_ac) ( \ ((_ac) == WME_AC_VO) ? 6 : \ ((_ac) == WME_AC_VI) ? 5 : \ @@ -1496,19 +1481,19 @@ typedef struct _bss_ht{ bool support_ht; - // HT related elements + /* HT related elements */ u8 ht_cap_buf[32]; u16 ht_cap_len; u8 ht_info_buf[32]; u16 ht_info_len; HT_SPEC_VER ht_spec_ver; - //HT_CAPABILITY_ELE bdHTCapEle; - //HT_INFORMATION_ELE bdHTInfoEle; + /* HT_CAPABILITY_ELE bdHTCapEle; */ + /* HT_INFORMATION_ELE bdHTInfoEle; */ bool aggregation; bool long_slot_time; -}bss_ht, *pbss_ht; +} bss_ht, *pbss_ht; typedef enum _erp_t{ ERP_NonERPpresent = 0x01, @@ -1525,16 +1510,15 @@ struct ieee80211_network { u8 ssid[IW_ESSID_MAX_SIZE + 1]; u8 ssid_len; struct ieee80211_qos_data qos_data; - //added by amy for LEAP bool bWithAironetIE; bool bCkipSupported; bool bCcxRmEnable; u16 CcxRmState[2]; - // CCXv4 S59, MBSSID. + /* CCXv4 S59, MBSSID. */ bool bMBssidValid; u8 MBssidMask; u8 MBssid[6]; - // CCX 2 S38, WLAN Device Version Number element. Annie, 2006-08-20. + /* CCX 2 S38, WLAN Device Version Number element. */ bool bWithCcxVerNum; u8 BssCcxVerNumber; /* These are network statistics */ @@ -1563,29 +1547,28 @@ struct ieee80211_network { u8 dtim_data; u32 last_dtim_sta_time[2]; - //appeded for QoS + /* appeded for QoS */ u8 wmm_info; struct ieee80211_wmm_ac_param wmm_param[4]; u8 QoS_Enable; #ifdef THOMAS_TURBO - u8 Turbo_Enable;//enable turbo mode, added by thomas + u8 Turbo_Enable;/* enable turbo mode, added by thomas */ #endif #ifdef ENABLE_DOT11D u16 CountryIeLen; u8 CountryIeBuf[MAX_IE_LEN]; #endif - // HT Related, by amy, 2008.04.29 + /* HT Related */ BSS_HT bssht; - // Add to handle broadcom AP management frame CCK rate. + /* Add to handle broadcom AP management frame CCK rate. */ bool broadcom_cap_exist; bool ralink_cap_exist; bool atheros_cap_exist; bool cisco_cap_exist; bool unknown_cap_exist; -// u8 berp_info; bool berp_info_valid; bool buseprotection; - //put at the end of the structure. + /* put at the end of the structure. */ struct list_head list; }; @@ -1650,75 +1633,66 @@ enum ieee80211_state { typedef struct tx_pending_t{ int frag; struct ieee80211_txb *txb; -}tx_pending_t; +} tx_pending_t; -typedef struct _bandwidth_autoswitch -{ +typedef struct _bandwidth_autoswitch { long threshold_20Mhzto40Mhz; long threshold_40Mhzto20Mhz; bool bforced_tx20Mhz; bool bautoswitch_enable; -}bandwidth_autoswitch,*pbandwidth_autoswitch; +} bandwidth_autoswitch, *pbandwidth_autoswitch; -//added by amy for order #define REORDER_WIN_SIZE 128 #define REORDER_ENTRY_NUM 128 -typedef struct _RX_REORDER_ENTRY -{ +typedef struct _RX_REORDER_ENTRY { struct list_head List; u16 SeqNum; - struct ieee80211_rxb* prxb; + struct ieee80211_rxb *prxb; } RX_REORDER_ENTRY, *PRX_REORDER_ENTRY; -//added by amy for order -typedef enum _Fsync_State{ + +typedef enum _Fsync_State { Default_Fsync, HW_Fsync, SW_Fsync -}Fsync_State; +} Fsync_State; -// Power save mode configured. -typedef enum _RT_PS_MODE -{ - eActive, // Active/Continuous access. - eMaxPs, // Max power save mode. - eFastPs // Fast power save mode. -}RT_PS_MODE; +/* Power save mode configured. */ +typedef enum _RT_PS_MODE { + eActive, /* Active/Continuous access. */ + eMaxPs, /* Max power save mode. */ + eFastPs /* Fast power save mode. */ +} RT_PS_MODE; -typedef enum _IPS_CALLBACK_FUNCION -{ +typedef enum _IPS_CALLBACK_FUNCION { IPS_CALLBACK_NONE = 0, IPS_CALLBACK_MGNT_LINK_REQUEST = 1, IPS_CALLBACK_JOIN_REQUEST = 2, -}IPS_CALLBACK_FUNCION; +} IPS_CALLBACK_FUNCION; -typedef enum _RT_JOIN_ACTION{ +typedef enum _RT_JOIN_ACTION { RT_JOIN_INFRA = 1, RT_JOIN_IBSS = 2, RT_START_IBSS = 3, RT_NO_ACTION = 4, -}RT_JOIN_ACTION; +} RT_JOIN_ACTION; -typedef struct _IbssParms{ +typedef struct _IbssParms { u16 atimWin; -}IbssParms, *PIbssParms; -#define MAX_NUM_RATES 264 // Max num of support rates element: 8, Max num of ext. support rate: 255. 061122, by rcnjko. +} IbssParms, *PIbssParms; +#define MAX_NUM_RATES 264 /* Max num of support rates element: 8, Max num of ext. support rate: 255. 061122, by rcnjko. */ -// RF state. -typedef enum _RT_RF_POWER_STATE -{ +/* RF state. */ +typedef enum _RT_RF_POWER_STATE { eRfOn, eRfSleep, eRfOff -}RT_RF_POWER_STATE; +} RT_RF_POWER_STATE; -typedef struct _RT_POWER_SAVE_CONTROL -{ +typedef struct _RT_POWER_SAVE_CONTROL { - // - // Inactive Power Save(IPS) : Disable RF when disconnected - // + /* Inactive Power Save(IPS) : Disable RF when disconnected */ bool bInactivePs; bool bIPSModeBackup; bool bSwRfProcessing; @@ -1726,15 +1700,15 @@ typedef struct _RT_POWER_SAVE_CONTROL struct work_struct InactivePsWorkItem; struct timer_list InactivePsTimer; - // Return point for join action + /* Return point for join action */ IPS_CALLBACK_FUNCION ReturnPoint; - // Recored Parameters for rescheduled JoinRequest + /* Recored Parameters for rescheduled JoinRequest */ bool bTmpBssDesc; RT_JOIN_ACTION tmpJoinAction; struct ieee80211_network tmpBssDesc; - // Recored Parameters for rescheduled MgntLinkRequest + /* Recored Parameters for rescheduled MgntLinkRequest */ bool bTmpScanOnly; bool bTmpActiveScan; bool bTmpFilterHiddenAP; @@ -1753,23 +1727,20 @@ typedef struct _RT_POWER_SAVE_CONTROL IbssParms tmpIbpm; bool bTmpIbpm; - // - // Leisre Poswer Save : Disable RF if connected but traffic is not busy - // + /* Leisre Poswer Save : Disable RF if connected but traffic is not busy */ bool bLeisurePs; -}RT_POWER_SAVE_CONTROL,*PRT_POWER_SAVE_CONTROL; +} RT_POWER_SAVE_CONTROL, *PRT_POWER_SAVE_CONTROL; typedef u32 RT_RF_CHANGE_SOURCE; #define RF_CHANGE_BY_SW BIT31 #define RF_CHANGE_BY_HW BIT30 #define RF_CHANGE_BY_PS BIT29 #define RF_CHANGE_BY_IPS BIT28 -#define RF_CHANGE_BY_INIT 0 // Do not change the RFOff reason. Defined by Bruce, 2008-01-17. +#define RF_CHANGE_BY_INIT 0 /* Do not change the RFOff reason. */ #ifdef ENABLE_DOT11D -typedef enum -{ +typedef enum { COUNTRY_CODE_FCC = 0, COUNTRY_CODE_IC = 1, COUNTRY_CODE_ETSI = 2, @@ -1781,84 +1752,78 @@ typedef enum COUNTRY_CODE_TELEC, COUNTRY_CODE_MIC, COUNTRY_CODE_GLOBAL_DOMAIN -}country_code_type_t; +} country_code_type_t; #endif #define RT_MAX_LD_SLOT_NUM 10 -typedef struct _RT_LINK_DETECT_T{ +typedef struct _RT_LINK_DETECT_T { u32 NumRecvBcnInPeriod; u32 NumRecvDataInPeriod; - u32 RxBcnNum[RT_MAX_LD_SLOT_NUM]; // number of Rx beacon / CheckForHang_period to determine link status - u32 RxDataNum[RT_MAX_LD_SLOT_NUM]; // number of Rx data / CheckForHang_period to determine link status - u16 SlotNum; // number of CheckForHang period to determine link status + u32 RxBcnNum[RT_MAX_LD_SLOT_NUM]; /* number of Rx beacon / CheckForHang_period to determine link status */ + u32 RxDataNum[RT_MAX_LD_SLOT_NUM]; /* number of Rx data / CheckForHang_period to determine link status */ + u16 SlotNum; /* number of CheckForHang period to determine link status */ u16 SlotIndex; u32 NumTxOkInPeriod; u32 NumRxOkInPeriod; bool bBusyTraffic; -}RT_LINK_DETECT_T, *PRT_LINK_DETECT_T; +} RT_LINK_DETECT_T, *PRT_LINK_DETECT_T; struct ieee80211_device { struct net_device *dev; struct ieee80211_security sec; - //hw security related -// u8 hwsec_support; //support? - u8 hwsec_active; //hw security active. + /* hw security related */ + u8 hwsec_active; /* hw security active. */ bool is_silent_reset; bool ieee_up; - //added by amy bool bSupportRemoteWakeUp; - RT_PS_MODE dot11PowerSaveMode; // Power save mode configured. + RT_PS_MODE dot11PowerSaveMode; /* Power save mode configured. */ bool actscanning; bool beinretry; RT_RF_POWER_STATE eRFPowerState; RT_RF_CHANGE_SOURCE RfOffReason; bool is_set_key; - //11n spec related I wonder if These info structure need to be moved out of ieee80211_device + /* 11n spec related I wonder if These info structure need to be moved out of ieee80211_device */ - //11n HT below + /* 11n HT below */ PRT_HIGH_THROUGHPUT pHTInfo; - //struct timer_list SwBwTimer; -// spinlock_t chnlop_spinlock; spinlock_t bw_spinlock; spinlock_t reorder_spinlock; - // for HT operation rate set. we use this one for HT data rate to seperate different descriptors - //the way fill this is the same as in the IE - u8 Regdot11HTOperationalRateSet[16]; //use RATR format - u8 dot11HTOperationalRateSet[16]; //use RATR format + /* for HT operation rate set. we use this one for HT data rate to + * seperate different descriptors + * the way fill this is the same as in the IE + */ + u8 Regdot11HTOperationalRateSet[16]; /* use RATR format */ + u8 dot11HTOperationalRateSet[16]; /* use RATR format */ u8 RegHTSuppRateSet[16]; u8 HTCurrentOperaRate; u8 HTHighestOperaRate; - //wb added for rate operation mode to firmware + /* wb added for rate operation mode to firmware */ u8 bTxDisableRateFallBack; u8 bTxUseDriverAssingedRate; atomic_t atm_chnlop; atomic_t atm_swbw; -// u8 HTHighestOperaRate; -// u8 HTCurrentOperaRate; - // 802.11e and WMM Traffic Stream Info (TX) + /* 802.11e and WMM Traffic Stream Info (TX) */ struct list_head Tx_TS_Admit_List; struct list_head Tx_TS_Pending_List; struct list_head Tx_TS_Unused_List; TX_TS_RECORD TxTsRecord[TOTAL_TS_NUM]; - // 802.11e and WMM Traffic Stream Info (RX) + /* 802.11e and WMM Traffic Stream Info (RX) */ struct list_head Rx_TS_Admit_List; struct list_head Rx_TS_Pending_List; struct list_head Rx_TS_Unused_List; RX_TS_RECORD RxTsRecord[TOTAL_TS_NUM]; -//#ifdef TO_DO_LIST RX_REORDER_ENTRY RxReorderEntry[128]; struct list_head RxReorder_Unused_List; -//#endif - // Qos related. Added by Annie, 2005-11-01. -// PSTA_QOS pStaQos; - u8 ForcedPriority; // Force per-packet priority 1~7. (default: 0, not to force it.) + /* Qos related. */ +/* PSTA_QOS pStaQos; */ + u8 ForcedPriority; /* Force per-packet priority 1~7. (default: 0, not to force it.) */ /* Bookkeeping structures */ @@ -1925,7 +1890,7 @@ struct ieee80211_device { * with RX of broad/multicast frames */ /* Fragmentation structures */ - // each streaming contain a entry + /* each streaming contain a entry */ struct ieee80211_frag_entry frag_cache[17][IEEE80211_FRAG_CACHE_LEN]; unsigned int frag_next_idx[17]; u16 fts; /* Fragmentation Threshold */ @@ -1967,16 +1932,16 @@ struct ieee80211_device { u16 prev_seq_ctl; /* used to drop duplicate frames */ /* map of allowed channels. 0 is dummy */ - // FIXME: remeber to default to a basic channel plan depending of the PHY type + /* FIXME: remeber to default to a basic channel plan depending of the PHY type */ #ifdef ENABLE_DOT11D - void* pDot11dInfo; + void *pDot11dInfo; bool bGlobalDomain; #else int channel_map[MAX_CHANNEL_NUMBER+1]; #endif int rate; /* current rate */ int basic_rate; - //FIXME: pleace callback, see if redundant with softmac_features + /* FIXME: pleace callback, see if redundant with softmac_features */ short active_scan; /* this contains flags for selectively enable softmac support */ @@ -2017,8 +1982,8 @@ struct ieee80211_device { short wap_set; short ssid_set; - u8 wpax_type_set; //{added by David, 2006.9.28} - u32 wpax_type_notify; //{added by David, 2006.9.26} + u8 wpax_type_set; + u32 wpax_type_notify; /* QoS related flag */ char init_wmmparam_flag; @@ -2040,7 +2005,7 @@ struct ieee80211_device { struct sk_buff *mgmt_queue_ring[MGMT_QUEUE_NUM]; int mgmt_queue_head; int mgmt_queue_tail; -//{ added for rtl819x +/* added for rtl819x */ #define IEEE80211_QUEUE_LIMIT 128 u8 AsocRetryCount; unsigned int hw_header; @@ -2049,12 +2014,12 @@ struct ieee80211_device { struct sk_buff_head skb_drv_aggQ[MAX_QUEUE_SIZE]; u32 sta_edca_param[4]; bool aggregation; - // Enable/Disable Rx immediate BA capability. + /* Enable/Disable Rx immediate BA capability. */ bool enable_rx_imm_BA; bool bibsscoordinator; - //+by amy for DM ,080515 - //Dynamic Tx power for near/far range enable/Disable , by amy , 2008-05-15 + /*+by amy for DM ,080515 */ + /* Dynamic Tx power for near/far range enable/Disable */ bool bdynamic_txpower_enable; bool bCTSToSelfEnable; @@ -2065,21 +2030,20 @@ struct ieee80211_device { u8 fsync_rssi_threshold; bool bfsync_enable; - u8 fsync_multiple_timeinterval; // FsyncMultipleTimeInterval * FsyncTimeInterval - u32 fsync_firstdiff_ratethreshold; // low threshold - u32 fsync_seconddiff_ratethreshold; // decrease threshold + u8 fsync_multiple_timeinterval; /* FsyncMultipleTimeInterval * FsyncTimeInterval */ + u32 fsync_firstdiff_ratethreshold; /* low threshold */ + u32 fsync_seconddiff_ratethreshold; /* decrease threshold */ Fsync_State fsync_state; bool bis_any_nonbepkts; - //20Mhz 40Mhz AutoSwitch Threshold + /* 20Mhz 40Mhz AutoSwitch Threshold */ bandwidth_autoswitch bandwidth_auto_switch; - //for txpower tracking + /* for txpower tracking */ bool FwRWRF; - //added by amy for AP roaming + /* added by amy for AP roaming */ RT_LINK_DETECT_T LinkDetectInfo; - //added by amy for ps + /* added by amy for ps */ RT_POWER_SAVE_CONTROL PowerSaveControl; -//} /* used if IEEE_SOFTMAC_TX_QUEUE is set */ struct tx_pending_t tx_pending; @@ -2095,11 +2059,8 @@ struct ieee80211_device { struct delayed_work start_ibss_wq; struct work_struct wx_sync_scan_wq; struct workqueue_struct *wq; - // Qos related. Added by Annie, 2005-11-01. - //STA_QOS StaQos; - - //u32 STA_EDCA_PARAM[4]; - //CHANNEL_ACCESS_SETTING ChannelAccessSetting; + /* Qos related. Added by Annie, 2005-11-01. */ + /* STA_QOS StaQos; */ /* Callback functions */ @@ -2114,10 +2075,10 @@ struct ieee80211_device { struct net_device *dev); int (*reset_port)(struct net_device *dev); - int (*is_queue_full) (struct net_device * dev, int pri); + int (*is_queue_full) (struct net_device *dev, int pri); - int (*handle_management) (struct net_device * dev, - struct ieee80211_network * network, u16 type); + int (*handle_management) (struct net_device *dev, + struct ieee80211_network *network, u16 type); int (*is_qos_active) (struct net_device *dev, struct sk_buff *skb); /* Softmac-generated frames (mamagement) are TXed via this @@ -2137,7 +2098,7 @@ struct ieee80211_device { * This function can't sleep. */ void (*softmac_data_hard_start_xmit)(struct sk_buff *skb, - struct net_device *dev,int rate); + struct net_device *dev, int rate); /* stops the HW queue for DATA frames. Useful to avoid * waste time to TX data frame when we are reassociating @@ -2152,7 +2113,7 @@ struct ieee80211_device { * This function can sleep. the driver should ensure * the radio has been swithced before return. */ - void (*set_chan)(struct net_device *dev,short ch); + void (*set_chan)(struct net_device *dev, short ch); /* These are not used if the ieee stack takes care of * scanning (IEEE_SOFTMAC_SCAN feature set). @@ -2186,7 +2147,7 @@ struct ieee80211_device { * stop_send_bacons is NOT guaranteed to be called only * after start_send_beacons. */ - void (*start_send_beacons) (struct net_device *dev,u16 tx_rate); + void (*start_send_beacons) (struct net_device *dev, u16 tx_rate); void (*stop_send_beacons) (struct net_device *dev); /* power save mode related */ @@ -2194,19 +2155,17 @@ struct ieee80211_device { void (*ps_request_tx_ack) (struct net_device *dev); void (*enter_sleep_state) (struct net_device *dev, u32 th, u32 tl); short (*ps_is_queue_empty) (struct net_device *dev); - int (*handle_beacon) (struct net_device * dev, struct ieee80211_beacon * beacon, struct ieee80211_network * network); - int (*handle_assoc_response) (struct net_device * dev, struct ieee80211_assoc_response_frame * resp, struct ieee80211_network * network); + int (*handle_beacon) (struct net_device *dev, struct ieee80211_beacon *beacon, struct ieee80211_network *network); + int (*handle_assoc_response) (struct net_device *dev, struct ieee80211_assoc_response_frame *resp, struct ieee80211_network *network); /* check whether Tx hw resouce available */ short (*check_nic_enough_desc)(struct net_device *dev, int queue_index); - //added by wb for HT related -// void (*SwChnlByTimerHandler)(struct net_device *dev, int channel); + /* added by wb for HT related */ void (*SetBWModeHandler)(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); -// void (*UpdateHalRATRTableHandler)(struct net_device* dev, u8* pMcsRate); - bool (*GetNmodeSupportBySecCfg)(struct net_device* dev); - void (*SetWirelessMode)(struct net_device* dev, u8 wireless_mode); - bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device* dev); + bool (*GetNmodeSupportBySecCfg)(struct net_device *dev); + void (*SetWirelessMode)(struct net_device *dev, u8 wireless_mode); + bool (*GetHalfNmodeSupportByAPsHandler)(struct net_device *dev); void (*InitialGainHandler)(struct net_device *dev, u8 Operation); /* This must be the last item so that it points to the data @@ -2307,7 +2266,7 @@ extern inline int ieee80211_get_hdrlen(u16 fc) case IEEE80211_FTYPE_DATA: if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS)) hdrlen = IEEE80211_4ADDR_LEN; /* Addr4 */ - if(IEEE80211_QOS_HAS_SEQ(fc)) + if (IEEE80211_QOS_HAS_SEQ(fc)) hdrlen += 2; /* QOS ctrl*/ break; case IEEE80211_FTYPE_CTL: @@ -2408,10 +2367,10 @@ extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, #if WIRELESS_EXT >= 18 extern int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee, struct iw_request_info *info, - union iwreq_data* wrqu, char *extra); + union iwreq_data *wrqu, char *extra); extern int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, struct iw_request_info *info, - union iwreq_data* wrqu, char *extra); + union iwreq_data *wrqu, char *extra); extern int ieee80211_wx_set_auth(struct ieee80211_device *ieee, struct iw_request_info *info, struct iw_param *data, char *extra); @@ -2477,7 +2436,9 @@ extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, union iwreq_data *awrq, char *extra); -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); +extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, struct iw_request_info *info, @@ -2506,7 +2467,6 @@ extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_reques extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b); -//extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); extern void ieee80211_wx_sync_scan_wq(struct work_struct *work); @@ -2533,54 +2493,53 @@ extern int ieee80211_wx_set_rts(struct ieee80211_device *ieee, extern int ieee80211_wx_get_rts(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -//HT -#define MAX_RECEIVE_BUFFER_SIZE 9100 // -extern void HTDebugHTCapability(u8* CapIE, u8* TitleString ); -extern void HTDebugHTInfo(u8* InfoIE, u8* TitleString); - -void HTSetConnectBwMode(struct ieee80211_device* ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); -extern void HTUpdateDefaultSetting(struct ieee80211_device* ieee); -extern void HTConstructCapabilityElement(struct ieee80211_device* ieee, u8* posHTCap, u8* len, u8 isEncrypt); -extern void HTConstructInfoElement(struct ieee80211_device* ieee, u8* posHTInfo, u8* len, u8 isEncrypt); -extern void HTConstructRT2RTAggElement(struct ieee80211_device* ieee, u8* posRT2RTAgg, u8* len); +/* HT */ +#define MAX_RECEIVE_BUFFER_SIZE 9100 +extern void HTDebugHTCapability(u8 *CapIE, u8 *TitleString); +extern void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString); + +void HTSetConnectBwMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); +extern void HTUpdateDefaultSetting(struct ieee80211_device *ieee); +extern void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u8 *len, u8 isEncrypt); +extern void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *len, u8 isEncrypt); +extern void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg, u8 *len); extern void HTOnAssocRsp(struct ieee80211_device *ieee); -extern void HTInitializeHTInfo(struct ieee80211_device* ieee); +extern void HTInitializeHTInfo(struct ieee80211_device *ieee); extern void HTInitializeBssDesc(PBSS_HT pBssHT); -extern void HTResetSelfAndSavePeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork); -extern void HTUpdateSelfAndPeerSetting(struct ieee80211_device* ieee, struct ieee80211_network * pNetwork); -extern u8 HTGetHighestMCSRate(struct ieee80211_device* ieee, u8* pMCSRateSet, u8* pMCSFilter); +extern void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee, struct ieee80211_network *pNetwork); +extern void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee, struct ieee80211_network *pNetwork); +extern u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, u8 *pMCSRateSet, u8 *pMCSFilter); extern u8 MCS_FILTER_ALL[]; extern u16 MCS_DATA_RATE[2][2][77] ; -extern u8 HTCCheck(struct ieee80211_device* ieee, u8* pFrame); -//extern void HTSetConnectBwModeCallback(unsigned long data); +extern u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame); extern void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo); -extern bool IsHTHalfNmodeAPs(struct ieee80211_device* ieee); -extern u16 HTHalfMcsToDataRate(struct ieee80211_device* ieee, u8 nMcsRate); -extern u16 HTMcsToDataRate( struct ieee80211_device* ieee, u8 nMcsRate); -extern u16 TxCountToDataRate( struct ieee80211_device* ieee, u8 nDataRate); -//function in BAPROC.c -extern int ieee80211_rx_ADDBAReq( struct ieee80211_device* ieee, struct sk_buff *skb); -extern int ieee80211_rx_ADDBARsp( struct ieee80211_device* ieee, struct sk_buff *skb); -extern int ieee80211_rx_DELBA(struct ieee80211_device* ieee,struct sk_buff *skb); -extern void TsInitAddBA( struct ieee80211_device* ieee, PTX_TS_RECORD pTS, u8 Policy, u8 bOverwritePending); -extern void TsInitDelBA( struct ieee80211_device* ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect); +extern bool IsHTHalfNmodeAPs(struct ieee80211_device *ieee); +extern u16 HTHalfMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate); +extern u16 HTMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate); +extern u16 TxCountToDataRate(struct ieee80211_device *ieee, u8 nDataRate); +/* function in BAPROC.c */ +extern int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb); +extern int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb); +extern int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb); +extern void TsInitAddBA(struct ieee80211_device *ieee, PTX_TS_RECORD pTS, u8 Policy, u8 bOverwritePending); +extern void TsInitDelBA(struct ieee80211_device *ieee, PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect); extern void BaSetupTimeOut(unsigned long data); extern void TxBaInactTimeout(unsigned long data); extern void RxBaInactTimeout(unsigned long data); -extern void ResetBaEntry( PBA_RECORD pBA); -//function in TS.c +extern void ResetBaEntry(PBA_RECORD pBA); +/* function in TS.c */ extern bool GetTs( - struct ieee80211_device* ieee, - PTS_COMMON_INFO *ppTS, - u8* Addr, + struct ieee80211_device *ieee, + PTS_COMMON_INFO *ppTS, + u8 *Addr, u8 TID, - TR_SELECT TxRxSelect, //Rx:1, Tx:0 + TR_SELECT TxRxSelect, /* Rx:1, Tx:0 */ bool bAddNewTs ); extern void TSInitialize(struct ieee80211_device *ieee); -extern void TsStartAddBaProcess(struct ieee80211_device* ieee, PTX_TS_RECORD pTxTS); -extern void RemovePeerTS(struct ieee80211_device* ieee, u8* Addr); -extern void RemoveAllTS(struct ieee80211_device* ieee); +extern void TsStartAddBaProcess(struct ieee80211_device *ieee, PTX_TS_RECORD pTxTS); +extern void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr); +extern void RemoveAllTS(struct ieee80211_device *ieee); void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee); extern const long ieee80211_wlan_frequencies[]; @@ -2595,7 +2554,8 @@ extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) return ieee->scans; } -static inline const char *escape_essid(const char *essid, u8 essid_len) { +static inline const char *escape_essid(const char *essid, u8 essid_len) +{ static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; const char *s = essid; char *d = escaped; @@ -2630,6 +2590,6 @@ extern int ieee80211_parse_info_param(struct ieee80211_device *ieee, struct ieee80211_network *network, struct ieee80211_rx_stats *stats); -void ieee80211_indicate_packets(struct ieee80211_device *ieee, struct ieee80211_rxb** prxbIndicateArray,u8 index); +void ieee80211_indicate_packets(struct ieee80211_device *ieee, struct ieee80211_rxb **prxbIndicateArray, u8 index); #define RT_ASOC_RETRY_LIMIT 5 #endif /* IEEE80211_H */ diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index d54e3a77423f..148424a9ac1c 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -1713,7 +1713,8 @@ ieee80211_rx_auth_rq(struct ieee80211_device *ieee, struct sk_buff *skb) //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; - if ((status = auth_rq_parse(skb, dest))!= -1){ + status = auth_rq_parse(skb, dest); + if (status != -1) { ieee80211_resp_to_auth(ieee, status, dest); } //DMESG("Dest is "MACSTR, MAC2STR(dest)); diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index 48537d948945..81aa2ed226ac 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c @@ -47,7 +47,6 @@ #include <linux/slab.h> #include <linux/tcp.h> #include <linux/types.h> -#include <linux/version.h> #include <linux/wireless.h> #include <linux/etherdevice.h> #include <asm/uaccess.h> diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c index 750e94e17114..4d5348e6c104 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c @@ -30,7 +30,6 @@ ******************************************************************************/ #include <linux/wireless.h> -#include <linux/version.h> #include <linux/kmod.h> #include <linux/slab.h> #include <linux/module.h> diff --git a/drivers/staging/rtl8192u/ieee80211_crypt.h b/drivers/staging/rtl8192u/ieee80211_crypt.h index b58a3bcc0dc0..0b4ea431982d 100644 --- a/drivers/staging/rtl8192u/ieee80211_crypt.h +++ b/drivers/staging/rtl8192u/ieee80211_crypt.h @@ -77,7 +77,7 @@ struct ieee80211_crypt_data { int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); -struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); +struct ieee80211_crypto_ops *ieee80211_get_crypto_ops(const char *name); void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); void ieee80211_crypt_deinit_handler(unsigned long); void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index fd19a85297a9..0cb28c776c49 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -63,7 +63,6 @@ SendTxCommandPacket( tcb_desc->bLastIniPkt = 0; skb_reserve(skb, USB_HWDESC_HEADER_LEN); ptr_buf = skb_put(skb, DataLen); - memset(ptr_buf,0,DataLen); memcpy(ptr_buf,pData,DataLen); tcb_desc->txbuf_size= (u16)DataLen; diff --git a/drivers/staging/sep/sep_driver.c b/drivers/staging/sep/sep_driver.c index 88880734921a..0332c370fd82 100644 --- a/drivers/staging/sep/sep_driver.c +++ b/drivers/staging/sep/sep_driver.c @@ -39,7 +39,6 @@ #include <linux/mm.h> #include <linux/poll.h> #include <linux/wait.h> -#include <linux/sched.h> #include <linux/pci.h> #include <linux/firmware.h> #include <linux/slab.h> diff --git a/drivers/staging/serqt_usb2/serqt_usb2.c b/drivers/staging/serqt_usb2/serqt_usb2.c index 44f2d4eaf84b..27841ef6a568 100644 --- a/drivers/staging/serqt_usb2/serqt_usb2.c +++ b/drivers/staging/serqt_usb2/serqt_usb2.c @@ -413,7 +413,7 @@ static void qt_read_bulk_callback(struct urb *urb) case 0x01: /* Modem status status change 4th byte must follow */ - dbg("Modem status status. \n"); + dbg("Modem status status.\n"); if (i > (RxCount - 4)) { dbg("Illegal escape sequences in received data\n"); break; @@ -424,7 +424,7 @@ static void qt_read_bulk_callback(struct urb *urb) flag = 1; break; case 0xff: - dbg("No status sequence. \n"); + dbg("No status sequence.\n"); if (tty) { ProcessRxChar(tty, port, data[i]); @@ -738,7 +738,7 @@ static int qt_startup(struct usb_serial *serial) if (!qt_port) { dbg("%s: kmalloc for quatech_port (%d) failed!.", __func__, i); - for(--i; i >= 0; i--) { + for (--i; i >= 0; i--) { port = serial->port[i]; kfree(usb_get_serial_port_data(port)); usb_set_serial_port_data(port, NULL); @@ -963,11 +963,11 @@ static int qt_open(struct tty_struct *tty, } - dbg("port number is %d \n", port->number); - dbg("serial number is %d \n", port->serial->minor); - dbg("Bulkin endpoint is %d \n", port->bulk_in_endpointAddress); - dbg("BulkOut endpoint is %d \n", port->bulk_out_endpointAddress); - dbg("Interrupt endpoint is %d \n", port->interrupt_in_endpointAddress); + dbg("port number is %d\n", port->number); + dbg("serial number is %d\n", port->serial->minor); + dbg("Bulkin endpoint is %d\n", port->bulk_in_endpointAddress); + dbg("BulkOut endpoint is %d\n", port->bulk_out_endpointAddress); + dbg("Interrupt endpoint is %d\n", port->interrupt_in_endpointAddress); dbg("port's number in the device is %d\n", quatech_port->port_num); quatech_port->read_urb = port->read_urb; @@ -1470,7 +1470,7 @@ static int qt_tiocmget(struct tty_struct *tty, struct file *file) int retval = -ENODEV; unsigned long flags; - dbg("In %s \n", __func__); + dbg("In %s\n", __func__); if (!serial) return -ENODEV; @@ -1496,14 +1496,14 @@ static int qt_tiocmset(struct tty_struct *tty, struct file *file, unsigned long flags; int retval = -ENODEV; - dbg("In %s \n", __func__); + dbg("In %s\n", __func__); if (!serial) return -ENODEV; spin_lock_irqsave(&qt_port->lock, flags); - dbg("%s - port %d \n", __func__, port->number); + dbg("%s - port %d\n", __func__, port->number); dbg("%s - qt_port->RxHolding = %d\n", __func__, qt_port->RxHolding); retval = qt_real_tiocmset(tty, port, file, serial, set); @@ -1584,9 +1584,9 @@ static int qt_calc_num_ports(struct usb_serial *serial) { int num_ports; - dbg("numberofendpoints: %d \n", + dbg("numberofendpoints: %d\n", (int)serial->interface->cur_altsetting->desc.bNumEndpoints); - dbg("numberofendpoints: %d \n", + dbg("numberofendpoints: %d\n", (int)serial->interface->altsetting->desc.bNumEndpoints); num_ports = diff --git a/drivers/staging/sm7xx/smtcfb.c b/drivers/staging/sm7xx/smtcfb.c index 8d7261c052eb..e817a20d1bdd 100644 --- a/drivers/staging/sm7xx/smtcfb.c +++ b/drivers/staging/sm7xx/smtcfb.c @@ -3,7 +3,7 @@ * * Copyright (C) 2006 Silicon Motion Technology Corp. * Authors: Ge Wang, gewang@siliconmotion.com - * Boyod boyod.yang@siliconmotion.com.cn + * Boyod boyod.yang@siliconmotion.com.cn * * Copyright (C) 2009 Lemote, Inc. * Author: Wu Zhangjin, wuzhangjin@gmail.com @@ -13,17 +13,17 @@ * more details. * * Version 0.10.26192.21.01 - * - Add PowerPC/Big endian support - * - Add 2D support for Lynx - * - Verified on2.6.19.2 Boyod.yang <boyod.yang@siliconmotion.com.cn> + * - Add PowerPC/Big endian support + * - Add 2D support for Lynx + * - Verified on2.6.19.2 Boyod.yang <boyod.yang@siliconmotion.com.cn> * * Version 0.09.2621.00.01 - * - Only support Linux Kernel's version 2.6.21. + * - Only support Linux Kernel's version 2.6.21. * Boyod.yang <boyod.yang@siliconmotion.com.cn> * * Version 0.09 - * - Only support Linux Kernel's version 2.6.12. - * Boyod.yang <boyod.yang@siliconmotion.com.cn> + * - Only support Linux Kernel's version 2.6.12. + * Boyod.yang <boyod.yang@siliconmotion.com.cn> */ #ifndef __KERNEL__ diff --git a/drivers/staging/sm7xx/smtcfb.h b/drivers/staging/sm7xx/smtcfb.h index 7ee565c2c952..0c113835b85c 100644 --- a/drivers/staging/sm7xx/smtcfb.h +++ b/drivers/staging/sm7xx/smtcfb.h @@ -3,7 +3,7 @@ * * Copyright (C) 2006 Silicon Motion Technology Corp. * Authors: Ge Wang, gewang@siliconmotion.com - * Boyod boyod.yang@siliconmotion.com.cn + * Boyod boyod.yang@siliconmotion.com.cn * * Copyright (C) 2009 Lemote, Inc. * Author: Wu Zhangjin, wuzhangjin@gmail.com diff --git a/drivers/staging/ti-st/Kconfig b/drivers/staging/ti-st/Kconfig new file mode 100644 index 000000000000..120e8db1368b --- /dev/null +++ b/drivers/staging/ti-st/Kconfig @@ -0,0 +1,24 @@ +# +# TI's shared transport line discipline and the protocol +# drivers (BT, FM and GPS) +# +menu "Texas Instruments shared transport line discipline" +config TI_ST + tristate "shared transport core driver" + select FW_LOADER + help + This enables the shared transport core driver for TI + BT / FM and GPS combo chips. This enables protocol drivers + to register themselves with core and send data, the responses + are returned to relevant protocol drivers based on their + packet types. + +config ST_BT + tristate "BlueZ bluetooth driver for ST" + depends on BT + select TI_ST + help + This enables the Bluetooth driver for TI BT/FM/GPS combo devices. + This makes use of shared transport line discipline core driver to + communicate with the BT core of the combo chip. +endmenu diff --git a/drivers/staging/ti-st/Makefile b/drivers/staging/ti-st/Makefile new file mode 100644 index 000000000000..0167d1d2c255 --- /dev/null +++ b/drivers/staging/ti-st/Makefile @@ -0,0 +1,7 @@ +# +# Makefile for TI's shared transport line discipline +# and its protocol drivers (BT, FM, GPS) +# +obj-$(CONFIG_TI_ST) += st_drv.o +st_drv-objs := st_core.o st_kim.o st_ll.o +obj-$(CONFIG_ST_BT) += bt_drv.o diff --git a/drivers/staging/ti-st/TODO b/drivers/staging/ti-st/TODO new file mode 100644 index 000000000000..2c4fe583901d --- /dev/null +++ b/drivers/staging/ti-st/TODO @@ -0,0 +1,19 @@ +TODO: + +1. A per-device/tty port context required to support multiple devices +on same platform. + +2. REMOVE the sysfs entry PID passing mechanism, since there should +be a better way to request user-space to install line discipline. + +3. Re-view/Re-work on the locking. + +4. Re-structure to make the ldisc driver more generic for chipsets which mux +multiple connectivity (BT, FM, GPS) upon 1 TTY port. + +5. Step up and maintain this driver to ensure that it continues +to work. Having the hardware for this is pretty much a +requirement. If this does not happen, the will be removed in +the 2.6.35 kernel release. + +Please send patches to Greg Kroah-Hartman <greg@kroah.com>. diff --git a/drivers/staging/ti-st/bt_drv.c b/drivers/staging/ti-st/bt_drv.c new file mode 100644 index 000000000000..d8420b5c91fa --- /dev/null +++ b/drivers/staging/ti-st/bt_drv.c @@ -0,0 +1,502 @@ +/* + * Texas Instrument's Bluetooth Driver For Shared Transport. + * + * Bluetooth Driver acts as interface between HCI CORE and + * TI Shared Transport Layer. + * + * Copyright (C) 2009 Texas Instruments + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include <net/bluetooth/bluetooth.h> +#include <net/bluetooth/hci_core.h> + +#include "st.h" +#include "bt_drv.h" + +/* Define this macro to get debug msg */ +#undef DEBUG + +#ifdef DEBUG +#define BT_DRV_DBG(fmt, arg...) printk(KERN_INFO "(btdrv):"fmt"\n" , ## arg) +#define BTDRV_API_START() printk(KERN_INFO "(btdrv): %s Start\n", \ + __func__) +#define BTDRV_API_EXIT(errno) printk(KERN_INFO "(btdrv): %s Exit(%d)\n", \ + __func__, errno) +#else +#define BT_DRV_DBG(fmt, arg...) +#define BTDRV_API_START() +#define BTDRV_API_EXIT(errno) +#endif + +#define BT_DRV_ERR(fmt, arg...) printk(KERN_ERR "(btdrv):"fmt"\n" , ## arg) + +static int reset; +static struct hci_st *hst; + +/* Increments HCI counters based on pocket ID (cmd,acl,sco) */ +static inline void hci_st_tx_complete(struct hci_st *hst, int pkt_type) +{ + struct hci_dev *hdev; + + BTDRV_API_START(); + + hdev = hst->hdev; + + /* Update HCI stat counters */ + switch (pkt_type) { + case HCI_COMMAND_PKT: + hdev->stat.cmd_tx++; + break; + + case HCI_ACLDATA_PKT: + hdev->stat.acl_tx++; + break; + + case HCI_SCODATA_PKT: + hdev->stat.cmd_tx++; + break; + } + + BTDRV_API_EXIT(0); +} + +/* ------- Interfaces to Shared Transport ------ */ + +/* Called by ST layer to indicate protocol registration completion + * status.hci_st_open() function will wait for signal from this + * API when st_register() function returns ST_PENDING. + */ +static void hci_st_registration_completion_cb(char data) +{ + BTDRV_API_START(); + + /* hci_st_open() function needs value of 'data' to know + * the registration status(success/fail),So have a back + * up of it. + */ + hst->streg_cbdata = data; + + /* Got a feedback from ST for BT driver registration + * request.Wackup hci_st_open() function to continue + * it's open operation. + */ + complete(&hst->wait_for_btdrv_reg_completion); + + BTDRV_API_EXIT(0); +} + +/* Called by Shared Transport layer when receive data is + * available */ +static long hci_st_receive(struct sk_buff *skb) +{ + int err; + int len; + + BTDRV_API_START(); + + err = 0; + len = 0; + + if (skb == NULL) { + BT_DRV_ERR("Invalid SKB received from ST"); + BTDRV_API_EXIT(-EFAULT); + return -EFAULT; + } + if (!hst) { + kfree_skb(skb); + BT_DRV_ERR("Invalid hci_st memory,freeing SKB"); + BTDRV_API_EXIT(-EFAULT); + return -EFAULT; + } + if (!test_bit(BT_DRV_RUNNING, &hst->flags)) { + kfree_skb(skb); + BT_DRV_ERR("Device is not running,freeing SKB"); + BTDRV_API_EXIT(-EINVAL); + return -EINVAL; + } + + len = skb->len; + skb->dev = (struct net_device *)hst->hdev; + + /* Forward skb to HCI CORE layer */ + err = hci_recv_frame(skb); + if (err) { + kfree_skb(skb); + BT_DRV_ERR("Unable to push skb to HCI CORE(%d),freeing SKB", + err); + BTDRV_API_EXIT(err); + return err; + } + hst->hdev->stat.byte_rx += len; + + BTDRV_API_EXIT(0); + return 0; +} + +/* ------- Interfaces to HCI layer ------ */ + +/* Called from HCI core to initialize the device */ +static int hci_st_open(struct hci_dev *hdev) +{ + static struct st_proto_s hci_st_proto; + unsigned long timeleft; + int err; + + BTDRV_API_START(); + + err = 0; + + BT_DRV_DBG("%s %p", hdev->name, hdev); + + /* Already registered with ST ? */ + if (test_bit(BT_ST_REGISTERED, &hst->flags)) { + BT_DRV_ERR("Registered with ST already,open called again?"); + BTDRV_API_EXIT(0); + return 0; + } + + /* Populate BT driver info required by ST */ + memset(&hci_st_proto, 0, sizeof(hci_st_proto)); + + /* BT driver ID */ + hci_st_proto.type = ST_BT; + + /* Receive function which called from ST */ + hci_st_proto.recv = hci_st_receive; + + /* Packet match function may used in future */ + hci_st_proto.match_packet = NULL; + + /* Callback to be called when registration is pending */ + hci_st_proto.reg_complete_cb = hci_st_registration_completion_cb; + + /* This is write function pointer of ST. BT driver will make use of this + * for sending any packets to chip. ST will assign and give to us, so + * make it as NULL */ + hci_st_proto.write = NULL; + + /* Register with ST layer */ + err = st_register(&hci_st_proto); + if (err == ST_ERR_PENDING) { + /* Prepare wait-for-completion handler data structures. + * Needed to syncronize this and st_registration_completion_cb() + * functions. + */ + init_completion(&hst->wait_for_btdrv_reg_completion); + + /* Reset ST registration callback status flag , this value + * will be updated in hci_st_registration_completion_cb() + * function whenever it called from ST driver. + */ + hst->streg_cbdata = -EINPROGRESS; + + /* ST is busy with other protocol registration(may be busy with + * firmware download).So,Wait till the registration callback + * (passed as a argument to st_register() function) getting + * called from ST. + */ + BT_DRV_DBG(" %s waiting for reg completion signal from ST", + __func__); + + timeleft = + wait_for_completion_timeout + (&hst->wait_for_btdrv_reg_completion, + msecs_to_jiffies(BT_REGISTER_TIMEOUT)); + if (!timeleft) { + BT_DRV_ERR("Timeout(%ld sec),didn't get reg" + "completion signal from ST", + BT_REGISTER_TIMEOUT / 1000); + BTDRV_API_EXIT(-ETIMEDOUT); + return -ETIMEDOUT; + } + + /* Is ST registration callback called with ERROR value? */ + if (hst->streg_cbdata != 0) { + BT_DRV_ERR("ST reg completion CB called with invalid" + "status %d", hst->streg_cbdata); + BTDRV_API_EXIT(-EAGAIN); + return -EAGAIN; + } + err = 0; + } else if (err == ST_ERR_FAILURE) { + BT_DRV_ERR("st_register failed %d", err); + BTDRV_API_EXIT(-EAGAIN); + return -EAGAIN; + } + + /* Do we have proper ST write function? */ + if (hci_st_proto.write != NULL) { + /* We need this pointer for sending any Bluetooth pkts */ + hst->st_write = hci_st_proto.write; + } else { + BT_DRV_ERR("failed to get ST write func pointer"); + + /* Undo registration with ST */ + err = st_unregister(ST_BT); + if (err < 0) + BT_DRV_ERR("st_unregister failed %d", err); + + hst->st_write = NULL; + BTDRV_API_EXIT(-EAGAIN); + return -EAGAIN; + } + + /* Registration with ST layer is completed successfully, + * now chip is ready to accept commands from HCI CORE. + * Mark HCI Device flag as RUNNING + */ + set_bit(HCI_RUNNING, &hdev->flags); + + /* Registration with ST successful */ + set_bit(BT_ST_REGISTERED, &hst->flags); + + BTDRV_API_EXIT(err); + return err; +} + +/* Close device */ +static int hci_st_close(struct hci_dev *hdev) +{ + int err; + + BTDRV_API_START(); + + err = 0; + + /* Unregister from ST layer */ + if (test_and_clear_bit(BT_ST_REGISTERED, &hst->flags)) { + err = st_unregister(ST_BT); + if (err != ST_SUCCESS) { + BT_DRV_ERR("st_unregister failed %d", err); + BTDRV_API_EXIT(-EBUSY); + return -EBUSY; + } + } + + hst->st_write = NULL; + + /* ST layer would have moved chip to inactive state. + * So,clear HCI device RUNNING flag. + */ + if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) { + BTDRV_API_EXIT(0); + return 0; + } + + BTDRV_API_EXIT(err); + return err; +} + +/* Called from HCI CORE , Sends frames to Shared Transport */ +static int hci_st_send_frame(struct sk_buff *skb) +{ + struct hci_dev *hdev; + struct hci_st *hst; + long len; + + BTDRV_API_START(); + + if (skb == NULL) { + BT_DRV_ERR("Invalid skb received from HCI CORE"); + BTDRV_API_EXIT(-ENOMEM); + return -ENOMEM; + } + hdev = (struct hci_dev *)skb->dev; + if (!hdev) { + BT_DRV_ERR("SKB received for invalid HCI Device (hdev=NULL)"); + BTDRV_API_EXIT(-ENODEV); + return -ENODEV; + } + if (!test_bit(HCI_RUNNING, &hdev->flags)) { + BT_DRV_ERR("Device is not running"); + BTDRV_API_EXIT(-EBUSY); + return -EBUSY; + } + + hst = (struct hci_st *)hdev->driver_data; + + /* Prepend skb with frame type */ + memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1); + + BT_DRV_DBG(" %s: type %d len %d", hdev->name, bt_cb(skb)->pkt_type, + skb->len); + + /* Insert skb to shared transport layer's transmit queue. + * Freeing skb memory is taken care in shared transport layer, + * so don't free skb memory here. + */ + if (!hst->st_write) { + kfree_skb(skb); + BT_DRV_ERR(" Can't write to ST, st_write null?"); + BTDRV_API_EXIT(-EAGAIN); + return -EAGAIN; + } + len = hst->st_write(skb); + if (len < 0) { + /* Something went wrong in st write , free skb memory */ + kfree_skb(skb); + BT_DRV_ERR(" ST write failed (%ld)", len); + BTDRV_API_EXIT(-EAGAIN); + return -EAGAIN; + } + + /* ST accepted our skb. So, Go ahead and do rest */ + hdev->stat.byte_tx += len; + hci_st_tx_complete(hst, bt_cb(skb)->pkt_type); + + BTDRV_API_EXIT(0); + return 0; +} + +static void hci_st_destruct(struct hci_dev *hdev) +{ + BTDRV_API_START(); + + if (!hdev) { + BT_DRV_ERR("Destruct called with invalid HCI Device" + "(hdev=NULL)"); + BTDRV_API_EXIT(0); + return; + } + + BT_DRV_DBG("%s", hdev->name); + + /* free hci_st memory */ + if (hdev->driver_data != NULL) + kfree(hdev->driver_data); + + BTDRV_API_EXIT(0); + return; +} + +/* Creates new HCI device */ +static int hci_st_register_dev(struct hci_st *hst) +{ + struct hci_dev *hdev; + + BTDRV_API_START(); + + /* Initialize and register HCI device */ + hdev = hci_alloc_dev(); + if (!hdev) { + BT_DRV_ERR("Can't allocate HCI device"); + BTDRV_API_EXIT(-ENOMEM); + return -ENOMEM; + } + BT_DRV_DBG(" HCI device allocated. hdev= %p", hdev); + + hst->hdev = hdev; + hdev->bus = HCI_UART; + hdev->driver_data = hst; + hdev->open = hci_st_open; + hdev->close = hci_st_close; + hdev->flush = NULL; + hdev->send = hci_st_send_frame; + hdev->destruct = hci_st_destruct; + hdev->owner = THIS_MODULE; + + if (reset) + set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); + + if (hci_register_dev(hdev) < 0) { + BT_DRV_ERR("Can't register HCI device"); + hci_free_dev(hdev); + BTDRV_API_EXIT(-ENODEV); + return -ENODEV; + } + + BT_DRV_DBG(" HCI device registered. hdev= %p", hdev); + BTDRV_API_EXIT(0); + return 0; +} + +/* ------- Module Init interface ------ */ + +static int __init bt_drv_init(void) +{ + int err; + + BTDRV_API_START(); + + err = 0; + + BT_DRV_DBG(" Bluetooth Driver Version %s", VERSION); + + /* Allocate local resource memory */ + hst = kzalloc(sizeof(struct hci_st), GFP_KERNEL); + if (!hst) { + BT_DRV_ERR("Can't allocate control structure"); + BTDRV_API_EXIT(-ENFILE); + return -ENFILE; + } + + /* Expose "hciX" device to user space */ + err = hci_st_register_dev(hst); + if (err) { + /* Release local resource memory */ + kfree(hst); + + BT_DRV_ERR("Unable to expose hci0 device(%d)", err); + BTDRV_API_EXIT(err); + return err; + } + set_bit(BT_DRV_RUNNING, &hst->flags); + + BTDRV_API_EXIT(err); + return err; +} + +/* ------- Module Exit interface ------ */ + +static void __exit bt_drv_exit(void) +{ + BTDRV_API_START(); + + /* Deallocate local resource's memory */ + if (hst) { + struct hci_dev *hdev = hst->hdev; + + if (hdev == NULL) { + BT_DRV_ERR("Invalid hdev memory"); + kfree(hst); + } else { + hci_st_close(hdev); + if (test_and_clear_bit(BT_DRV_RUNNING, &hst->flags)) { + /* Remove HCI device (hciX) created + * in module init. + */ + hci_unregister_dev(hdev); + + /* Free HCI device memory */ + hci_free_dev(hdev); + } + } + } + BTDRV_API_EXIT(0); +} + +module_init(bt_drv_init); +module_exit(bt_drv_exit); + +/* ------ Module Info ------ */ + +module_param(reset, bool, 0644); +MODULE_PARM_DESC(reset, "Send HCI reset command on initialization"); +MODULE_AUTHOR("Raja Mani <raja_mani@ti.com>"); +MODULE_DESCRIPTION("Bluetooth Driver for TI Shared Transport" VERSION); +MODULE_VERSION(VERSION); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/ti-st/bt_drv.h b/drivers/staging/ti-st/bt_drv.h new file mode 100644 index 000000000000..a0beebec8465 --- /dev/null +++ b/drivers/staging/ti-st/bt_drv.h @@ -0,0 +1,61 @@ +/* + * Texas Instrument's Bluetooth Driver For Shared Transport. + * + * Bluetooth Driver acts as interface between HCI CORE and + * TI Shared Transport Layer. + * + * Copyright (C) 2009 Texas Instruments + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _BT_DRV_H +#define _BT_DRV_H + +/* Bluetooth Driver Version */ +#define VERSION "1.0" + +/* Defines number of seconds to wait for reg completion + * callback getting called from ST (in case,registration + * with ST returns PENDING status) + */ +#define BT_REGISTER_TIMEOUT msecs_to_jiffies(6000) /* 6 sec */ + +/* BT driver's local status */ +#define BT_DRV_RUNNING 0 +#define BT_ST_REGISTERED 1 + +/* BT driver operation structure */ +struct hci_st { + + /* hci device pointer which binds to bt driver */ + struct hci_dev *hdev; + + /* used locally,to maintain various BT driver status */ + unsigned long flags; + + /* to hold ST registration callback status */ + char streg_cbdata; + + /* write function pointer of ST driver */ + long (*st_write) (struct sk_buff *); + + /* Wait on comepletion handler needed to synchronize + * hci_st_open() and hci_st_registration_completion_cb() + * functions.*/ + struct completion wait_for_btdrv_reg_completion; +}; + +#endif diff --git a/drivers/staging/ti-st/fm.h b/drivers/staging/ti-st/fm.h new file mode 100644 index 000000000000..be41453649ed --- /dev/null +++ b/drivers/staging/ti-st/fm.h @@ -0,0 +1,13 @@ +struct fm_event_hdr { + unsigned char plen; +} __attribute__ ((packed)); + +#define FM_MAX_FRAME_SIZE 0xFF /* TODO: */ +#define FM_EVENT_HDR_SIZE 1 /* size of fm_event_hdr */ +#define ST_FM_CH8_PKT 0x8 + +/* gps stuff */ +struct gps_event_hdr { +unsigned char opcode; +unsigned short plen; +} __attribute__ ((packed)); diff --git a/drivers/staging/ti-st/st.h b/drivers/staging/ti-st/st.h new file mode 100644 index 000000000000..e8fc97e32c94 --- /dev/null +++ b/drivers/staging/ti-st/st.h @@ -0,0 +1,90 @@ +/* + * Shared Transport Header file + * To be included by the protocol stack drivers for + * Texas Instruments BT,FM and GPS combo chip drivers + * + * Copyright (C) 2009 Texas Instruments + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef ST_H +#define ST_H + +#include <linux/skbuff.h> +/* + * st.h + */ + +/* TODO: + * Move the following to tty.h upon acceptance + */ +#define N_TI_WL 20 /* Ldisc for TI's WL BT, FM, GPS combo chips */ + +/* some gpios have active high, others like fm have + * active low + */ +enum kim_gpio_state { + KIM_GPIO_INACTIVE, + KIM_GPIO_ACTIVE, +}; +/* + * the list of protocols on chip + */ +enum proto_type { + ST_BT, + ST_FM, + ST_GPS, + ST_MAX, +}; + +enum { + ST_ERR_FAILURE = -1, /* check struct */ + ST_SUCCESS, + ST_ERR_PENDING = -5, /* to call reg_complete_cb */ + ST_ERR_ALREADY, /* already registered */ + ST_ERR_INPROGRESS, + ST_ERR_NOPROTO, /* protocol not supported */ +}; + +/* per protocol structure + * for BT/FM and GPS + */ +struct st_proto_s { + enum proto_type type; +/* + * to be called by ST when data arrives + */ + long (*recv) (struct sk_buff *); +/* + * for future use, logic now to be in ST + */ + unsigned char (*match_packet) (const unsigned char *data); +/* + * subsequent registration return PENDING, + * signalled complete by this callback function + */ + void (*reg_complete_cb) (char data); +/* + * write function, sent in as NULL and to be returned to + * protocol drivers + */ + long (*write) (struct sk_buff *skb); +}; + +extern long st_register(struct st_proto_s *new_proto); +extern long st_unregister(enum proto_type type); + +#endif /* ST_H */ diff --git a/drivers/staging/ti-st/st_core.c b/drivers/staging/ti-st/st_core.c new file mode 100644 index 000000000000..4e93694e1c21 --- /dev/null +++ b/drivers/staging/ti-st/st_core.c @@ -0,0 +1,1062 @@ +/* + * Shared Transport Line discipline driver Core + * This hooks up ST KIM driver and ST LL driver + * Copyright (C) 2009 Texas Instruments + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define pr_fmt(fmt) "(stc): " fmt +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/tty.h> + +/* understand BT, FM and GPS for now */ +#include <net/bluetooth/bluetooth.h> +#include <net/bluetooth/hci_core.h> +#include <net/bluetooth/hci.h> +#include "fm.h" +/* + * packet formats for fm and gps + * #include "gps.h" + */ +#include "st_core.h" +#include "st_kim.h" +#include "st_ll.h" +#include "st.h" + +#ifdef DEBUG +/* strings to be used for rfkill entries and by + * ST Core to be used for sysfs debug entry + */ +#define PROTO_ENTRY(type, name) name +const unsigned char *protocol_strngs[] = { + PROTO_ENTRY(ST_BT, "Bluetooth"), + PROTO_ENTRY(ST_FM, "FM"), + PROTO_ENTRY(ST_GPS, "GPS"), +}; +#endif +/* function pointer pointing to either, + * st_kim_recv during registration to receive fw download responses + * st_int_recv after registration to receive proto stack responses + */ +void (*st_recv) (void*, const unsigned char*, long); + +/********************************************************************/ +#if 0 +/* internal misc functions */ +bool is_protocol_list_empty(void) +{ + unsigned char i = 0; + pr_info(" %s ", __func__); + for (i = 0; i < ST_MAX; i++) { + if (st_gdata->list[i] != NULL) + return ST_NOTEMPTY; + /* not empty */ + } + /* list empty */ + return ST_EMPTY; +} +#endif +/* can be called in from + * -- KIM (during fw download) + * -- ST Core (during st_write) + * + * This is the internal write function - a wrapper + * to tty->ops->write + */ +int st_int_write(struct st_data_s *st_gdata, + const unsigned char *data, int count) +{ +#ifdef VERBOSE /* for debug */ + int i; +#endif + struct tty_struct *tty; + if (unlikely(st_gdata == NULL || st_gdata->tty == NULL)) { + pr_err("tty unavailable to perform write"); + return ST_ERR_FAILURE; + } + tty = st_gdata->tty; +#ifdef VERBOSE + printk(KERN_ERR "start data..\n"); + for (i = 0; i < count; i++) /* no newlines for each datum */ + printk(" %x", data[i]); + printk(KERN_ERR "\n ..end data\n"); +#endif + return tty->ops->write(tty, data, count); + +} + +/* + * push the skb received to relevant + * protocol stacks + */ +void st_send_frame(enum proto_type protoid, struct st_data_s *st_gdata) +{ + pr_info(" %s(prot:%d) ", __func__, protoid); + + if (unlikely + (st_gdata == NULL || st_gdata->rx_skb == NULL + || st_gdata->list[protoid] == NULL)) { + pr_err("protocol %d not registered, no data to send?", + protoid); + kfree_skb(st_gdata->rx_skb); + return; + } + /* this cannot fail + * this shouldn't take long + * - should be just skb_queue_tail for the + * protocol stack driver + */ + if (likely(st_gdata->list[protoid]->recv != NULL)) { + if (unlikely(st_gdata->list[protoid]->recv(st_gdata->rx_skb) + != ST_SUCCESS)) { + pr_err(" proto stack %d's ->recv failed", protoid); + kfree_skb(st_gdata->rx_skb); + return; + } + } else { + pr_err(" proto stack %d's ->recv null", protoid); + kfree_skb(st_gdata->rx_skb); + } + pr_info(" done %s", __func__); + return; +} + +/* + * to call registration complete callbacks + * of all protocol stack drivers + */ +void st_reg_complete(struct st_data_s *st_gdata, char err) +{ + unsigned char i = 0; + pr_info(" %s ", __func__); + for (i = 0; i < ST_MAX; i++) { + if (likely(st_gdata != NULL && st_gdata->list[i] != NULL && + st_gdata->list[i]->reg_complete_cb != NULL)) + st_gdata->list[i]->reg_complete_cb(err); + } +} + +static inline int st_check_data_len(struct st_data_s *st_gdata, + int protoid, int len) +{ + register int room = skb_tailroom(st_gdata->rx_skb); + + pr_info("len %d room %d", len, room); + + if (!len) { + /* Received packet has only packet header and + * has zero length payload. So, ask ST CORE to + * forward the packet to protocol driver (BT/FM/GPS) + */ + st_send_frame(protoid, st_gdata); + + } else if (len > room) { + /* Received packet's payload length is larger. + * We can't accommodate it in created skb. + */ + pr_err("Data length is too large len %d room %d", len, + room); + kfree_skb(st_gdata->rx_skb); + } else { + /* Packet header has non-zero payload length and + * we have enough space in created skb. Lets read + * payload data */ + st_gdata->rx_state = ST_BT_W4_DATA; + st_gdata->rx_count = len; + return len; + } + + /* Change ST state to continue to process next + * packet */ + st_gdata->rx_state = ST_W4_PACKET_TYPE; + st_gdata->rx_skb = NULL; + st_gdata->rx_count = 0; + + return 0; +} + +/* internal function for action when wake-up ack + * received + */ +static inline void st_wakeup_ack(struct st_data_s *st_gdata, + unsigned char cmd) +{ + register struct sk_buff *waiting_skb; + unsigned long flags = 0; + + spin_lock_irqsave(&st_gdata->lock, flags); + /* de-Q from waitQ and Q in txQ now that the + * chip is awake + */ + while ((waiting_skb = skb_dequeue(&st_gdata->tx_waitq))) + skb_queue_tail(&st_gdata->txq, waiting_skb); + + /* state forwarded to ST LL */ + st_ll_sleep_state(st_gdata, (unsigned long)cmd); + spin_unlock_irqrestore(&st_gdata->lock, flags); + + /* wake up to send the recently copied skbs from waitQ */ + st_tx_wakeup(st_gdata); +} + +/* Decodes received RAW data and forwards to corresponding + * client drivers (Bluetooth,FM,GPS..etc). + * + */ +void st_int_recv(void *disc_data, + const unsigned char *data, long count) +{ + register char *ptr; + struct hci_event_hdr *eh; + struct hci_acl_hdr *ah; + struct hci_sco_hdr *sh; + struct fm_event_hdr *fm; + struct gps_event_hdr *gps; + register int len = 0, type = 0, dlen = 0; + static enum proto_type protoid = ST_MAX; + struct st_data_s *st_gdata = (struct st_data_s *)disc_data; + + ptr = (char *)data; + /* tty_receive sent null ? */ + if (unlikely(ptr == NULL) || (st_gdata == NULL)) { + pr_err(" received null from TTY "); + return; + } + + pr_info("count %ld rx_state %ld" + "rx_count %ld", count, st_gdata->rx_state, + st_gdata->rx_count); + + /* Decode received bytes here */ + while (count) { + if (st_gdata->rx_count) { + len = min_t(unsigned int, st_gdata->rx_count, count); + memcpy(skb_put(st_gdata->rx_skb, len), ptr, len); + st_gdata->rx_count -= len; + count -= len; + ptr += len; + + if (st_gdata->rx_count) + continue; + + /* Check ST RX state machine , where are we? */ + switch (st_gdata->rx_state) { + + /* Waiting for complete packet ? */ + case ST_BT_W4_DATA: + pr_info("Complete pkt received"); + + /* Ask ST CORE to forward + * the packet to protocol driver */ + st_send_frame(protoid, st_gdata); + + st_gdata->rx_state = ST_W4_PACKET_TYPE; + st_gdata->rx_skb = NULL; + protoid = ST_MAX; /* is this required ? */ + continue; + + /* Waiting for Bluetooth event header ? */ + case ST_BT_W4_EVENT_HDR: + eh = (struct hci_event_hdr *)st_gdata->rx_skb-> + data; + + pr_info("Event header: evt 0x%2.2x" + "plen %d", eh->evt, eh->plen); + + st_check_data_len(st_gdata, protoid, eh->plen); + continue; + + /* Waiting for Bluetooth acl header ? */ + case ST_BT_W4_ACL_HDR: + ah = (struct hci_acl_hdr *)st_gdata->rx_skb-> + data; + dlen = __le16_to_cpu(ah->dlen); + + pr_info("ACL header: dlen %d", dlen); + + st_check_data_len(st_gdata, protoid, dlen); + continue; + + /* Waiting for Bluetooth sco header ? */ + case ST_BT_W4_SCO_HDR: + sh = (struct hci_sco_hdr *)st_gdata->rx_skb-> + data; + + pr_info("SCO header: dlen %d", sh->dlen); + + st_check_data_len(st_gdata, protoid, sh->dlen); + continue; + case ST_FM_W4_EVENT_HDR: + fm = (struct fm_event_hdr *)st_gdata->rx_skb-> + data; + pr_info("FM Header: "); + st_check_data_len(st_gdata, ST_FM, fm->plen); + continue; + /* TODO : Add GPS packet machine logic here */ + case ST_GPS_W4_EVENT_HDR: + /* [0x09 pkt hdr][R/W byte][2 byte len] */ + gps = (struct gps_event_hdr *)st_gdata->rx_skb-> + data; + pr_info("GPS Header: "); + st_check_data_len(st_gdata, ST_GPS, gps->plen); + continue; + } /* end of switch rx_state */ + } + + /* end of if rx_count */ + /* Check first byte of packet and identify module + * owner (BT/FM/GPS) */ + switch (*ptr) { + + /* Bluetooth event packet? */ + case HCI_EVENT_PKT: + pr_info("Event packet"); + st_gdata->rx_state = ST_BT_W4_EVENT_HDR; + st_gdata->rx_count = HCI_EVENT_HDR_SIZE; + type = HCI_EVENT_PKT; + protoid = ST_BT; + break; + + /* Bluetooth acl packet? */ + case HCI_ACLDATA_PKT: + pr_info("ACL packet"); + st_gdata->rx_state = ST_BT_W4_ACL_HDR; + st_gdata->rx_count = HCI_ACL_HDR_SIZE; + type = HCI_ACLDATA_PKT; + protoid = ST_BT; + break; + + /* Bluetooth sco packet? */ + case HCI_SCODATA_PKT: + pr_info("SCO packet"); + st_gdata->rx_state = ST_BT_W4_SCO_HDR; + st_gdata->rx_count = HCI_SCO_HDR_SIZE; + type = HCI_SCODATA_PKT; + protoid = ST_BT; + break; + + /* Channel 8(FM) packet? */ + case ST_FM_CH8_PKT: + pr_info("FM CH8 packet"); + type = ST_FM_CH8_PKT; + st_gdata->rx_state = ST_FM_W4_EVENT_HDR; + st_gdata->rx_count = FM_EVENT_HDR_SIZE; + protoid = ST_FM; + break; + + /* Channel 9(GPS) packet? */ + case 0x9: /*ST_LL_GPS_CH9_PKT */ + pr_info("GPS CH9 packet"); + type = 0x9; /* ST_LL_GPS_CH9_PKT; */ + protoid = ST_GPS; + st_gdata->rx_state = ST_GPS_W4_EVENT_HDR; + st_gdata->rx_count = 3; /* GPS_EVENT_HDR_SIZE -1*/ + break; + case LL_SLEEP_IND: + case LL_SLEEP_ACK: + case LL_WAKE_UP_IND: + pr_info("PM packet"); + /* this takes appropriate action based on + * sleep state received -- + */ + st_ll_sleep_state(st_gdata, *ptr); + ptr++; + count--; + continue; + case LL_WAKE_UP_ACK: + pr_info("PM packet"); + /* wake up ack received */ + st_wakeup_ack(st_gdata, *ptr); + ptr++; + count--; + continue; + /* Unknow packet? */ + default: + pr_err("Unknown packet type %2.2x", (__u8) *ptr); + ptr++; + count--; + continue; + }; + ptr++; + count--; + + switch (protoid) { + case ST_BT: + /* Allocate new packet to hold received data */ + st_gdata->rx_skb = + bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC); + if (!st_gdata->rx_skb) { + pr_err("Can't allocate mem for new packet"); + st_gdata->rx_state = ST_W4_PACKET_TYPE; + st_gdata->rx_count = 0; + return; + } + bt_cb(st_gdata->rx_skb)->pkt_type = type; + break; + case ST_FM: /* for FM */ + st_gdata->rx_skb = + alloc_skb(FM_MAX_FRAME_SIZE, GFP_ATOMIC); + if (!st_gdata->rx_skb) { + pr_err("Can't allocate mem for new packet"); + st_gdata->rx_state = ST_W4_PACKET_TYPE; + st_gdata->rx_count = 0; + return; + } + /* place holder 0x08 */ + skb_reserve(st_gdata->rx_skb, 1); + st_gdata->rx_skb->cb[0] = ST_FM_CH8_PKT; + break; + case ST_GPS: + /* for GPS */ + st_gdata->rx_skb = + alloc_skb(100 /*GPS_MAX_FRAME_SIZE */ , GFP_ATOMIC); + if (!st_gdata->rx_skb) { + pr_err("Can't allocate mem for new packet"); + st_gdata->rx_state = ST_W4_PACKET_TYPE; + st_gdata->rx_count = 0; + return; + } + /* place holder 0x09 */ + skb_reserve(st_gdata->rx_skb, 1); + st_gdata->rx_skb->cb[0] = 0x09; /*ST_GPS_CH9_PKT; */ + break; + case ST_MAX: + break; + } + } + pr_info("done %s", __func__); + return; +} + +/* internal de-Q function + * -- return previous in-completely written skb + * or return the skb in the txQ + */ +struct sk_buff *st_int_dequeue(struct st_data_s *st_gdata) +{ + struct sk_buff *returning_skb; + + pr_info("%s", __func__); + /* if the previous skb wasn't written completely + */ + if (st_gdata->tx_skb != NULL) { + returning_skb = st_gdata->tx_skb; + st_gdata->tx_skb = NULL; + return returning_skb; + } + + /* de-Q from the txQ always if previous write is complete */ + return skb_dequeue(&st_gdata->txq); +} + +/* internal Q-ing function + * will either Q the skb to txq or the tx_waitq + * depending on the ST LL state + * + * lock the whole func - since ll_getstate and Q-ing should happen + * in one-shot + */ +void st_int_enqueue(struct st_data_s *st_gdata, struct sk_buff *skb) +{ + unsigned long flags = 0; + + pr_info("%s", __func__); + /* this function can be invoked in more then one context. + * so have a lock */ + spin_lock_irqsave(&st_gdata->lock, flags); + + switch (st_ll_getstate(st_gdata)) { + case ST_LL_AWAKE: + pr_info("ST LL is AWAKE, sending normally"); + skb_queue_tail(&st_gdata->txq, skb); + break; + case ST_LL_ASLEEP_TO_AWAKE: + skb_queue_tail(&st_gdata->tx_waitq, skb); + break; + case ST_LL_AWAKE_TO_ASLEEP: /* host cannot be in this state */ + pr_err("ST LL is illegal state(%ld)," + "purging received skb.", st_ll_getstate(st_gdata)); + kfree_skb(skb); + break; + + case ST_LL_ASLEEP: + /* call a function of ST LL to put data + * in tx_waitQ and wake_ind in txQ + */ + skb_queue_tail(&st_gdata->tx_waitq, skb); + st_ll_wakeup(st_gdata); + break; + default: + pr_err("ST LL is illegal state(%ld)," + "purging received skb.", st_ll_getstate(st_gdata)); + kfree_skb(skb); + break; + } + spin_unlock_irqrestore(&st_gdata->lock, flags); + pr_info("done %s", __func__); + return; +} + +/* + * internal wakeup function + * called from either + * - TTY layer when write's finished + * - st_write (in context of the protocol stack) + */ +void st_tx_wakeup(struct st_data_s *st_data) +{ + struct sk_buff *skb; + unsigned long flags; /* for irq save flags */ + pr_info("%s", __func__); + /* check for sending & set flag sending here */ + if (test_and_set_bit(ST_TX_SENDING, &st_data->tx_state)) { + pr_info("ST already sending"); + /* keep sending */ + set_bit(ST_TX_WAKEUP, &st_data->tx_state); + return; + /* TX_WAKEUP will be checked in another + * context + */ + } + do { /* come back if st_tx_wakeup is set */ + /* woke-up to write */ + clear_bit(ST_TX_WAKEUP, &st_data->tx_state); + while ((skb = st_int_dequeue(st_data))) { + int len; + spin_lock_irqsave(&st_data->lock, flags); + /* enable wake-up from TTY */ + set_bit(TTY_DO_WRITE_WAKEUP, &st_data->tty->flags); + len = st_int_write(st_data, skb->data, skb->len); + skb_pull(skb, len); + /* if skb->len = len as expected, skb->len=0 */ + if (skb->len) { + /* would be the next skb to be sent */ + st_data->tx_skb = skb; + spin_unlock_irqrestore(&st_data->lock, flags); + break; + } + kfree_skb(skb); + spin_unlock_irqrestore(&st_data->lock, flags); + } + /* if wake-up is set in another context- restart sending */ + } while (test_bit(ST_TX_WAKEUP, &st_data->tx_state)); + + /* clear flag sending */ + clear_bit(ST_TX_SENDING, &st_data->tx_state); +} + +/********************************************************************/ +/* functions called from ST KIM +*/ +void kim_st_list_protocols(struct st_data_s *st_gdata, char *buf) +{ + unsigned long flags = 0; +#ifdef DEBUG + unsigned char i = ST_MAX; +#endif + spin_lock_irqsave(&st_gdata->lock, flags); +#ifdef DEBUG /* more detailed log */ + for (i = 0; i < ST_MAX; i++) { + if (i == 0) { + sprintf(buf, "%s is %s", protocol_strngs[i], + st_gdata->list[i] != + NULL ? "Registered" : "Unregistered"); + } else { + sprintf(buf, "%s\n%s is %s", buf, protocol_strngs[i], + st_gdata->list[i] != + NULL ? "Registered" : "Unregistered"); + } + } + 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'); +#endif + spin_unlock_irqrestore(&st_gdata->lock, flags); +} + +/********************************************************************/ +/* + * functions called from protocol stack drivers + * to be EXPORT-ed + */ +long st_register(struct st_proto_s *new_proto) +{ + struct st_data_s *st_gdata; + long err = ST_SUCCESS; + unsigned long flags = 0; + + st_kim_ref(&st_gdata); + pr_info("%s(%d) ", __func__, new_proto->type); + if (st_gdata == NULL || new_proto == NULL || new_proto->recv == NULL + || new_proto->reg_complete_cb == NULL) { + pr_err("gdata/new_proto/recv or reg_complete_cb not ready"); + return ST_ERR_FAILURE; + } + + if (new_proto->type < ST_BT || new_proto->type >= ST_MAX) { + pr_err("protocol %d not supported", new_proto->type); + return ST_ERR_NOPROTO; + } + + if (st_gdata->list[new_proto->type] != NULL) { + pr_err("protocol %d already registered", new_proto->type); + return ST_ERR_ALREADY; + } + + /* can be from process context only */ + spin_lock_irqsave(&st_gdata->lock, flags); + + if (test_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state)) { + pr_info(" ST_REG_IN_PROGRESS:%d ", new_proto->type); + /* fw download in progress */ + st_kim_chip_toggle(new_proto->type, KIM_GPIO_ACTIVE); + + st_gdata->list[new_proto->type] = new_proto; + new_proto->write = st_write; + + set_bit(ST_REG_PENDING, &st_gdata->st_state); + spin_unlock_irqrestore(&st_gdata->lock, flags); + return ST_ERR_PENDING; + } else if (st_gdata->protos_registered == ST_EMPTY) { + pr_info(" protocol list empty :%d ", new_proto->type); + set_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state); + st_recv = st_kim_recv; + + /* release lock previously held - re-locked below */ + spin_unlock_irqrestore(&st_gdata->lock, flags); + + /* enable the ST LL - to set default chip state */ + st_ll_enable(st_gdata); + /* this may take a while to complete + * since it involves BT fw download + */ + err = st_kim_start(); + if (err != ST_SUCCESS) { + clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state); + if ((st_gdata->protos_registered != ST_EMPTY) && + (test_bit(ST_REG_PENDING, &st_gdata->st_state))) { + pr_err(" KIM failure complete callback "); + st_reg_complete(st_gdata, ST_ERR_FAILURE); + } + + return ST_ERR_FAILURE; + } + + /* the protocol might require other gpios to be toggled + */ + st_kim_chip_toggle(new_proto->type, KIM_GPIO_ACTIVE); + + clear_bit(ST_REG_IN_PROGRESS, &st_gdata->st_state); + st_recv = st_int_recv; + + /* this is where all pending registration + * are signalled to be complete by calling callback functions + */ + 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); + + /* check for already registered once more, + * since the above check is old + */ + if (st_gdata->list[new_proto->type] != NULL) { + pr_err(" proto %d already registered ", + new_proto->type); + return ST_ERR_ALREADY; + } + + spin_lock_irqsave(&st_gdata->lock, flags); + st_gdata->list[new_proto->type] = new_proto; + new_proto->write = st_write; + spin_unlock_irqrestore(&st_gdata->lock, flags); + return err; + } + /* if fw is already downloaded & new stack registers protocol */ + else { + switch (new_proto->type) { + case ST_BT: + /* do nothing */ + break; + case ST_FM: + case ST_GPS: + st_kim_chip_toggle(new_proto->type, KIM_GPIO_ACTIVE); + break; + case ST_MAX: + default: + pr_err("%d protocol not supported", + new_proto->type); + err = ST_ERR_NOPROTO; + /* something wrong */ + break; + } + st_gdata->list[new_proto->type] = new_proto; + new_proto->write = st_write; + + /* lock already held before entering else */ + spin_unlock_irqrestore(&st_gdata->lock, flags); + return err; + } + pr_info("done %s(%d) ", __func__, new_proto->type); +} +EXPORT_SYMBOL_GPL(st_register); + +/* to unregister a protocol - + * to be called from protocol stack driver + */ +long st_unregister(enum proto_type type) +{ + long err = ST_SUCCESS; + unsigned long flags = 0; + struct st_data_s *st_gdata; + + pr_info("%s: %d ", __func__, type); + + st_kim_ref(&st_gdata); + if (type < ST_BT || type >= ST_MAX) { + pr_err(" protocol %d not supported", type); + return ST_ERR_NOPROTO; + } + + spin_lock_irqsave(&st_gdata->lock, flags); + + if (st_gdata->list[type] == NULL) { + pr_err(" protocol %d not registered", type); + spin_unlock_irqrestore(&st_gdata->lock, flags); + return ST_ERR_NOPROTO; + } + + st_gdata->protos_registered--; + st_gdata->list[type] = NULL; + + /* kim ignores BT in the below function + * and handles the rest, BT is toggled + * only in kim_start and kim_stop + */ + st_kim_chip_toggle(type, KIM_GPIO_INACTIVE); + spin_unlock_irqrestore(&st_gdata->lock, flags); + + if ((st_gdata->protos_registered == ST_EMPTY) && + (!test_bit(ST_REG_PENDING, &st_gdata->st_state))) { + pr_info(" all protocols unregistered "); + + /* stop traffic on tty */ + if (st_gdata->tty) { + tty_ldisc_flush(st_gdata->tty); + stop_tty(st_gdata->tty); + } + + /* all protocols now unregistered */ + st_kim_stop(); + /* disable ST LL */ + st_ll_disable(st_gdata); + } + return err; +} + +/* + * called in protocol stack drivers + * via the write function pointer + */ +long st_write(struct sk_buff *skb) +{ + struct st_data_s *st_gdata; +#ifdef DEBUG + enum proto_type protoid = ST_MAX; +#endif + long len; + + st_kim_ref(&st_gdata); + if (unlikely(skb == NULL || st_gdata == NULL + || st_gdata->tty == NULL)) { + pr_err("data/tty unavailable to perform write"); + return ST_ERR_FAILURE; + } +#ifdef DEBUG /* open-up skb to read the 1st byte */ + switch (skb->data[0]) { + case HCI_COMMAND_PKT: + case HCI_ACLDATA_PKT: + case HCI_SCODATA_PKT: + protoid = ST_BT; + break; + case ST_FM_CH8_PKT: + protoid = ST_FM; + break; + case 0x09: + protoid = ST_GPS; + break; + } + if (unlikely(st_gdata->list[protoid] == NULL)) { + pr_err(" protocol %d not registered, and writing? ", + protoid); + return ST_ERR_FAILURE; + } +#endif + pr_info("%d to be written", skb->len); + len = skb->len; + + /* st_ll to decide where to enqueue the skb */ + st_int_enqueue(st_gdata, skb); + /* wake up */ + st_tx_wakeup(st_gdata); + + /* return number of bytes written */ + return len; +} + +/* for protocols making use of shared transport */ +EXPORT_SYMBOL_GPL(st_unregister); + +/********************************************************************/ +/* + * functions called from TTY layer + */ +static int st_tty_open(struct tty_struct *tty) +{ + int err = ST_SUCCESS; + struct st_data_s *st_gdata; + pr_info("%s ", __func__); + + st_kim_ref(&st_gdata); + st_gdata->tty = tty; + tty->disc_data = st_gdata; + + /* don't do an wakeup for now */ + clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); + + /* mem already allocated + */ + tty->receive_room = 65536; + /* Flush any pending characters in the driver and discipline. */ + tty_ldisc_flush(tty); + tty_driver_flush_buffer(tty); + /* + * signal to UIM via KIM that - + * installation of N_TI_WL ldisc is complete + */ + st_kim_complete(); + pr_info("done %s", __func__); + return err; +} + +static void st_tty_close(struct tty_struct *tty) +{ + unsigned char i = ST_MAX; + unsigned long flags = 0; + struct st_data_s *st_gdata = tty->disc_data; + + pr_info("%s ", __func__); + + /* TODO: + * if a protocol has been registered & line discipline + * un-installed for some reason - what should be done ? + */ + spin_lock_irqsave(&st_gdata->lock, flags); + for (i = ST_BT; i < ST_MAX; i++) { + if (st_gdata->list[i] != NULL) + pr_err("%d not un-registered", i); + st_gdata->list[i] = NULL; + } + spin_unlock_irqrestore(&st_gdata->lock, flags); + /* + * signal to UIM via KIM that - + * N_TI_WL ldisc is un-installed + */ + st_kim_complete(); + st_gdata->tty = NULL; + /* Flush any pending characters in the driver and discipline. */ + tty_ldisc_flush(tty); + tty_driver_flush_buffer(tty); + + spin_lock_irqsave(&st_gdata->lock, flags); + /* empty out txq and tx_waitq */ + skb_queue_purge(&st_gdata->txq); + skb_queue_purge(&st_gdata->tx_waitq); + /* reset the TTY Rx states of ST */ + st_gdata->rx_count = 0; + st_gdata->rx_state = ST_W4_PACKET_TYPE; + kfree_skb(st_gdata->rx_skb); + st_gdata->rx_skb = NULL; + spin_unlock_irqrestore(&st_gdata->lock, flags); + + pr_info("%s: done ", __func__); +} + +static void st_tty_receive(struct tty_struct *tty, const unsigned char *data, + char *tty_flags, int count) +{ + +#ifdef VERBOSE + long i; + printk(KERN_ERR "incoming data...\n"); + for (i = 0; i < count; i++) + printk(" %x", data[i]); + printk(KERN_ERR "\n.. data end\n"); +#endif + + /* + * if fw download is in progress then route incoming data + * to KIM for validation + */ + st_recv(tty->disc_data, data, count); + pr_info("done %s", __func__); +} + +/* wake-up function called in from the TTY layer + * inside the internal wakeup function will be called + */ +static void st_tty_wakeup(struct tty_struct *tty) +{ + struct st_data_s *st_gdata = tty->disc_data; + pr_info("%s ", __func__); + /* don't do an wakeup for now */ + clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); + + /* call our internal wakeup */ + st_tx_wakeup((void *)st_gdata); +} + +static void st_tty_flush_buffer(struct tty_struct *tty) +{ + struct st_data_s *st_gdata = tty->disc_data; + pr_info("%s ", __func__); + + kfree_skb(st_gdata->tx_skb); + st_gdata->tx_skb = NULL; + + tty->ops->flush_buffer(tty); + return; +} + +/********************************************************************/ +int st_core_init(struct st_data_s **core_data) +{ + struct st_data_s *st_gdata; + long err; + static struct tty_ldisc_ops *st_ldisc_ops; + + /* populate and register to TTY line discipline */ + st_ldisc_ops = kzalloc(sizeof(*st_ldisc_ops), GFP_KERNEL); + if (!st_ldisc_ops) { + pr_err("no mem to allocate"); + return -ENOMEM; + } + + st_ldisc_ops->magic = TTY_LDISC_MAGIC; + st_ldisc_ops->name = "n_st"; /*"n_hci"; */ + st_ldisc_ops->open = st_tty_open; + st_ldisc_ops->close = st_tty_close; + st_ldisc_ops->receive_buf = st_tty_receive; + st_ldisc_ops->write_wakeup = st_tty_wakeup; + st_ldisc_ops->flush_buffer = st_tty_flush_buffer; + st_ldisc_ops->owner = THIS_MODULE; + + err = tty_register_ldisc(N_TI_WL, st_ldisc_ops); + if (err) { + pr_err("error registering %d line discipline %ld", + N_TI_WL, err); + kfree(st_ldisc_ops); + return err; + } + pr_info("registered n_shared line discipline"); + + st_gdata = kzalloc(sizeof(struct st_data_s), GFP_KERNEL); + if (!st_gdata) { + pr_err("memory allocation failed"); + err = tty_unregister_ldisc(N_TI_WL); + if (err) + pr_err("unable to un-register ldisc %ld", err); + kfree(st_ldisc_ops); + err = -ENOMEM; + return err; + } + + /* Initialize ST TxQ and Tx waitQ queue head. All BT/FM/GPS module skb's + * will be pushed in this queue for actual transmission. + */ + skb_queue_head_init(&st_gdata->txq); + skb_queue_head_init(&st_gdata->tx_waitq); + + /* Locking used in st_int_enqueue() to avoid multiple execution */ + spin_lock_init(&st_gdata->lock); + + /* ldisc_ops ref to be only used in __exit of module */ + st_gdata->ldisc_ops = st_ldisc_ops; + +#if 0 + err = st_kim_init(); + if (err) { + pr_err("error during kim initialization(%ld)", err); + kfree(st_gdata); + err = tty_unregister_ldisc(N_TI_WL); + if (err) + pr_err("unable to un-register ldisc"); + kfree(st_ldisc_ops); + return -1; + } +#endif + + err = st_ll_init(st_gdata); + if (err) { + pr_err("error during st_ll initialization(%ld)", err); + kfree(st_gdata); + err = tty_unregister_ldisc(N_TI_WL); + if (err) + pr_err("unable to un-register ldisc"); + kfree(st_ldisc_ops); + return -1; + } + *core_data = st_gdata; + return 0; +} + +void st_core_exit(struct st_data_s *st_gdata) +{ + long err; + /* internal module cleanup */ + err = st_ll_deinit(st_gdata); + if (err) + pr_err("error during deinit of ST LL %ld", err); +#if 0 + err = st_kim_deinit(); + if (err) + pr_err("error during deinit of ST KIM %ld", err); +#endif + if (st_gdata != NULL) { + /* Free ST Tx Qs and skbs */ + skb_queue_purge(&st_gdata->txq); + skb_queue_purge(&st_gdata->tx_waitq); + kfree_skb(st_gdata->rx_skb); + kfree_skb(st_gdata->tx_skb); + /* TTY ldisc cleanup */ + err = tty_unregister_ldisc(N_TI_WL); + if (err) + pr_err("unable to un-register ldisc %ld", err); + kfree(st_gdata->ldisc_ops); + /* free the global data pointer */ + kfree(st_gdata); + } +} + + diff --git a/drivers/staging/ti-st/st_core.h b/drivers/staging/ti-st/st_core.h new file mode 100644 index 000000000000..f271c88a8087 --- /dev/null +++ b/drivers/staging/ti-st/st_core.h @@ -0,0 +1,98 @@ +/* + * Shared Transport Core header file + * + * Copyright (C) 2009 Texas Instruments + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef ST_CORE_H +#define ST_CORE_H + +#include <linux/skbuff.h> +#include "st.h" + +/* states of protocol list */ +#define ST_NOTEMPTY 1 +#define ST_EMPTY 0 + +/* + * possible st_states + */ +#define ST_INITIALIZING 1 +#define ST_REG_IN_PROGRESS 2 +#define ST_REG_PENDING 3 +#define ST_WAITING_FOR_RESP 4 + +/* + * local data required for ST/KIM/ST-HCI-LL + */ +struct st_data_s { + unsigned long st_state; +/* + * an instance of tty_struct & ldisc ops to move around + */ + struct tty_struct *tty; + struct tty_ldisc_ops *ldisc_ops; +/* + * the tx skb - + * if the skb is already dequeued and the tty failed to write the same + * maintain the skb to write in the next transaction + */ + struct sk_buff *tx_skb; +#define ST_TX_SENDING 1 +#define ST_TX_WAKEUP 2 + unsigned long tx_state; +/* + * list of protocol registered + */ + struct st_proto_s *list[ST_MAX]; +/* + * lock + */ + unsigned long rx_state; + unsigned long rx_count; + struct sk_buff *rx_skb; + struct sk_buff_head txq, tx_waitq; + spinlock_t lock; /* ST LL state lock */ + unsigned char protos_registered; + unsigned long ll_state; /* ST LL power state */ +}; + +/* point this to tty->driver->write or tty->ops->write + * depending upon the kernel version + */ +int st_int_write(struct st_data_s*, const unsigned char*, int); +/* internal write function, passed onto protocol drivers + * via the write function ptr of protocol struct + */ +long st_write(struct sk_buff *); +/* function to be called from ST-LL + */ +void st_ll_send_frame(enum proto_type, struct sk_buff *); +/* internal wake up function */ +void st_tx_wakeup(struct st_data_s *st_data); + +int st_core_init(struct st_data_s **); +void st_core_exit(struct st_data_s *); +void st_kim_ref(struct st_data_s **); + +#define GPS_STUB_TEST +#ifdef GPS_STUB_TEST +int gps_chrdrv_stub_write(const unsigned char*, int); +void gps_chrdrv_stub_init(void); +#endif + +#endif /*ST_CORE_H */ diff --git a/drivers/staging/ti-st/st_kim.c b/drivers/staging/ti-st/st_kim.c new file mode 100644 index 000000000000..98cbabba3844 --- /dev/null +++ b/drivers/staging/ti-st/st_kim.c @@ -0,0 +1,754 @@ +/* + * Shared Transport Line discipline driver Core + * Init Manager module responsible for GPIO control + * and firmware download + * Copyright (C) 2009 Texas Instruments + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define pr_fmt(fmt) "(stk) :" fmt +#include <linux/platform_device.h> +#include <linux/jiffies.h> +#include <linux/firmware.h> +#include <linux/delay.h> +#include <linux/wait.h> +#include <linux/gpio.h> + +#include <linux/sched.h> + +#include "st_kim.h" +/* understand BT events for fw response */ +#include <net/bluetooth/bluetooth.h> +#include <net/bluetooth/hci_core.h> +#include <net/bluetooth/hci.h> + + +static int kim_probe(struct platform_device *pdev); +static int kim_remove(struct platform_device *pdev); + +/* KIM platform device driver structure */ +static struct platform_driver kim_platform_driver = { + .probe = kim_probe, + .remove = kim_remove, + /* TODO: ST driver power management during suspend/resume ? + */ +#if 0 + .suspend = kim_suspend, + .resume = kim_resume, +#endif + .driver = { + .name = "kim", + .owner = THIS_MODULE, + }, +}; + +#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 + *devattr, char *buf, size_t count); +static ssize_t show_list(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); + +static struct kobj_attribute list_protocols = +__ATTR(protocols, 0444, (void *)show_list, NULL); + +static struct attribute *uim_attrs[] = { + &pid_attr.attr, + /* add more debug sysfs entries */ + &list_protocols.attr, + NULL, +}; + +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 + */ +#define PROTO_ENTRY(type, name) name +const unsigned char *protocol_names[] = { + PROTO_ENTRY(ST_BT, "Bluetooth"), + PROTO_ENTRY(ST_FM, "FM"), + PROTO_ENTRY(ST_GPS, "GPS"), +}; + +struct kim_data_s *kim_gdata; + +/**********************************************************************/ +/* internal functions */ + +/* + * function to return whether the firmware response was proper + * in case of error don't complete so that waiting for proper + * response times out + */ +void validate_firmware_response(struct sk_buff *skb) +{ + if (unlikely(skb->data[5] != 0)) { + pr_err("no proper response during fw download"); + pr_err("data6 %x", skb->data[5]); + return; /* keep waiting for the proper response */ + } + /* becos of all the script being downloaded */ + complete_all(&kim_gdata->kim_rcvd); + kfree_skb(skb); +} + +/* check for data len received inside kim_int_recv + * most often hit the last case to update state to waiting for data + */ +static inline int kim_check_data_len(int len) +{ + register int room = skb_tailroom(kim_gdata->rx_skb); + + pr_info("len %d room %d", len, room); + + if (!len) { + validate_firmware_response(kim_gdata->rx_skb); + } else if (len > room) { + /* Received packet's payload length is larger. + * We can't accommodate it in created skb. + */ + pr_err("Data length is too large len %d room %d", len, + room); + kfree_skb(kim_gdata->rx_skb); + } else { + /* Packet header has non-zero payload length and + * we have enough space in created skb. Lets read + * payload data */ + kim_gdata->rx_state = ST_BT_W4_DATA; + kim_gdata->rx_count = len; + return len; + } + + /* Change ST LL state to continue to process next + * packet */ + kim_gdata->rx_state = ST_W4_PACKET_TYPE; + kim_gdata->rx_skb = NULL; + kim_gdata->rx_count = 0; + + return 0; +} + +/* receive function called during firmware download + * - firmware download responses on different UART drivers + * have been observed to come in bursts of different + * tty_receive and hence the logic + */ +void kim_int_recv(const unsigned char *data, long count) +{ + register char *ptr; + struct hci_event_hdr *eh; + register int len = 0, type = 0; + + pr_info("%s", __func__); + /* Decode received bytes here */ + ptr = (char *)data; + if (unlikely(ptr == NULL)) { + pr_err(" received null from TTY "); + return; + } + while (count) { + if (kim_gdata->rx_count) { + len = min_t(unsigned int, kim_gdata->rx_count, count); + memcpy(skb_put(kim_gdata->rx_skb, len), ptr, len); + kim_gdata->rx_count -= len; + count -= len; + ptr += len; + + if (kim_gdata->rx_count) + continue; + + /* Check ST RX state machine , where are we? */ + switch (kim_gdata->rx_state) { + /* Waiting for complete packet ? */ + case ST_BT_W4_DATA: + pr_info("Complete pkt received"); + validate_firmware_response(kim_gdata->rx_skb); + kim_gdata->rx_state = ST_W4_PACKET_TYPE; + kim_gdata->rx_skb = NULL; + continue; + /* Waiting for Bluetooth event header ? */ + case ST_BT_W4_EVENT_HDR: + eh = (struct hci_event_hdr *)kim_gdata-> + rx_skb->data; + pr_info("Event header: evt 0x%2.2x" + "plen %d", eh->evt, eh->plen); + kim_check_data_len(eh->plen); + continue; + } /* end of switch */ + } /* end of if rx_state */ + switch (*ptr) { + /* Bluetooth event packet? */ + case HCI_EVENT_PKT: + pr_info("Event packet"); + kim_gdata->rx_state = ST_BT_W4_EVENT_HDR; + kim_gdata->rx_count = HCI_EVENT_HDR_SIZE; + type = HCI_EVENT_PKT; + break; + default: + pr_info("unknown packet"); + ptr++; + count--; + continue; + } /* end of switch *ptr */ + ptr++; + count--; + kim_gdata->rx_skb = + bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC); + if (!kim_gdata->rx_skb) { + pr_err("can't allocate mem for new packet"); + kim_gdata->rx_state = ST_W4_PACKET_TYPE; + kim_gdata->rx_count = 0; + return; + } /* not necessary in this case */ + bt_cb(kim_gdata->rx_skb)->pkt_type = type; + } /* end of while count */ + pr_info("done %s", __func__); + return; +} + +static long read_local_version(char *bts_scr_name) +{ + unsigned short version = 0, chip = 0, min_ver = 0, maj_ver = 0; + char read_ver_cmd[] = { 0x01, 0x01, 0x10, 0x00 }; + + pr_info("%s", __func__); + + INIT_COMPLETION(kim_gdata->kim_rcvd); + if (4 != st_int_write(kim_gdata->core_data, read_ver_cmd, 4)) { + pr_err("kim: couldn't write 4 bytes"); + return ST_ERR_FAILURE; + } + + if (!wait_for_completion_timeout + (&kim_gdata->kim_rcvd, msecs_to_jiffies(CMD_RESP_TIME))) { + pr_err(" waiting for ver info- timed out "); + return ST_ERR_FAILURE; + } + + version = + MAKEWORD(kim_gdata->resp_buffer[13], kim_gdata->resp_buffer[14]); + chip = (version & 0x7C00) >> 10; + min_ver = (version & 0x007F); + maj_ver = (version & 0x0380) >> 7; + + if (version & 0x8000) + maj_ver |= 0x0008; + + sprintf(bts_scr_name, "TIInit_%d.%d.%d.bts", chip, maj_ver, min_ver); + pr_info("%s", bts_scr_name); + return ST_SUCCESS; +} + +/* internal function which parses through the .bts firmware script file + * intreprets SEND, DELAY actions only as of now + */ +static long download_firmware(void) +{ + long err = ST_SUCCESS; + long len = 0; + register unsigned char *ptr = NULL; + register unsigned char *action_ptr = NULL; + unsigned char bts_scr_name[30] = { 0 }; /* 30 char long bts scr name? */ + + pr_info("%s", __func__); + + err = read_local_version(bts_scr_name); + if (err != ST_SUCCESS) { + pr_err("kim: failed to read local ver"); + return err; + } + err = + request_firmware(&kim_gdata->fw_entry, bts_scr_name, + &kim_gdata->kim_pdev->dev); + if (unlikely((err != 0) || (kim_gdata->fw_entry->data == NULL) || + (kim_gdata->fw_entry->size == 0))) { + pr_err(" request_firmware failed(errno %ld) for %s", err, + bts_scr_name); + return ST_ERR_FAILURE; + } + ptr = (void *)kim_gdata->fw_entry->data; + len = kim_gdata->fw_entry->size; + /* bts_header to remove out magic number and + * version + */ + ptr += sizeof(struct bts_header); + len -= sizeof(struct bts_header); + + while (len > 0 && ptr) { + pr_info(" action size %d, type %d ", + ((struct bts_action *)ptr)->size, + ((struct bts_action *)ptr)->type); + + switch (((struct bts_action *)ptr)->type) { + case ACTION_SEND_COMMAND: /* action send */ + action_ptr = &(((struct bts_action *)ptr)->data[0]); + if (unlikely + (((struct hci_command *)action_ptr)->opcode == + 0xFF36)) { + /* ignore remote change + * baud rate HCI VS command */ + pr_err + (" change remote baud\ + rate command in firmware"); + break; + } + + INIT_COMPLETION(kim_gdata->kim_rcvd); + err = st_int_write(kim_gdata->core_data, + ((struct bts_action_send *)action_ptr)->data, + ((struct bts_action *)ptr)->size); + if (unlikely(err < 0)) { + release_firmware(kim_gdata->fw_entry); + return ST_ERR_FAILURE; + } + if (!wait_for_completion_timeout + (&kim_gdata->kim_rcvd, + msecs_to_jiffies(CMD_RESP_TIME))) { + pr_err + (" response timeout during fw download "); + /* timed out */ + release_firmware(kim_gdata->fw_entry); + return ST_ERR_FAILURE; + } + break; + case ACTION_DELAY: /* sleep */ + pr_info("sleep command in scr"); + action_ptr = &(((struct bts_action *)ptr)->data[0]); + mdelay(((struct bts_action_delay *)action_ptr)->msec); + break; + } + len = + len - (sizeof(struct bts_action) + + ((struct bts_action *)ptr)->size); + ptr = + ptr + sizeof(struct bts_action) + + ((struct bts_action *)ptr)->size; + } + /* fw download complete */ + release_firmware(kim_gdata->fw_entry); + return ST_SUCCESS; +} + +/**********************************************************************/ +/* functions called from ST core */ + +/* function to toggle the GPIO + * needs to know whether the GPIO is active high or active low + */ +void st_kim_chip_toggle(enum proto_type type, enum kim_gpio_state state) +{ + pr_info(" %s ", __func__); + + if (kim_gdata->gpios[type] == -1) { + pr_info(" gpio not requested for protocol %s", + protocol_names[type]); + return; + } + switch (type) { + case ST_BT: + /*Do Nothing */ + break; + + case ST_FM: + if (state == KIM_GPIO_ACTIVE) + gpio_set_value(kim_gdata->gpios[ST_FM], GPIO_LOW); + else + gpio_set_value(kim_gdata->gpios[ST_FM], GPIO_HIGH); + break; + + case ST_GPS: + if (state == KIM_GPIO_ACTIVE) + gpio_set_value(kim_gdata->gpios[ST_GPS], GPIO_HIGH); + else + gpio_set_value(kim_gdata->gpios[ST_GPS], GPIO_LOW); + break; + + case ST_MAX: + default: + break; + } + + return; +} + +/* called from ST Core, when REG_IN_PROGRESS (registration in progress) + * can be because of + * 1. response to read local version + * 2. during send/recv's of firmware download + */ +void st_kim_recv(void *disc_data, const unsigned char *data, long count) +{ + pr_info(" %s ", __func__); + /* copy to local buffer */ + if (unlikely(data[4] == 0x01 && data[5] == 0x10 && data[0] == 0x04)) { + /* must be the read_ver_cmd */ + memcpy(kim_gdata->resp_buffer, data, count); + complete_all(&kim_gdata->kim_rcvd); + return; + } else { + kim_int_recv(data, count); + /* either completes or times out */ + } + return; +} + +/* to signal completion of line discipline installation + * called from ST Core, upon tty_open + */ +void st_kim_complete(void) +{ + complete(&kim_gdata->ldisc_installed); +} + +/* called from ST Core upon 1st registration +*/ +long st_kim_start(void) +{ + long err = ST_SUCCESS; + long retry = POR_RETRY_COUNT; + 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 */ + gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_HIGH); + mdelay(100); + /* re-initialize the completion */ + INIT_COMPLETION(kim_gdata->ldisc_installed); +#ifndef LEGACY_RFKILL_SUPPORT + /* send signal to UIM */ + err = kill_pid(find_get_pid(kim_gdata->uim_pid), SIGUSR2, 0); + if (err != 0) { + pr_info(" sending SIGUSR2 to uim failed %ld", err); + err = ST_ERR_FAILURE; + continue; + } +#else + /* 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)); + if (!err) { /* timeout */ + pr_err("line disc installation timed out "); + err = ST_ERR_FAILURE; + continue; + } else { + /* ldisc installed now */ + pr_info(" line discipline installed "); + err = download_firmware(); + if (err != ST_SUCCESS) { + pr_err("download firmware failed"); + continue; + } else { /* on success don't retry */ + break; + } + } + } while (retry--); + return err; +} + +/* called from ST Core, on the last un-registration +*/ +long st_kim_stop(void) +{ + long err = ST_SUCCESS; + + INIT_COMPLETION(kim_gdata->ldisc_installed); +#ifndef LEGACY_RFKILL_SUPPORT + /* 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 + /* 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, + msecs_to_jiffies(LDISC_TIME)); + if (!err) { /* timeout */ + pr_err(" timed out waiting for ldisc to be un-installed"); + return ST_ERR_FAILURE; + } + + /* By default configure BT nShutdown to LOW state */ + gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_LOW); + mdelay(1); + gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_HIGH); + mdelay(1); + gpio_set_value(kim_gdata->gpios[ST_BT], GPIO_LOW); + return err; +} + +/**********************************************************************/ +/* 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) +{ + pr_info("%s: pid %s ", __func__, buf); + sscanf(buf, "%ld", &kim_gdata->uim_pid); + /* to be made use by kim_start to signal SIGUSR2 + */ + return strlen(buf); +} + +/* called when sysfs entry is read from */ +static ssize_t show_pid(struct device *dev, struct device_attribute + *attr, char *buf) +{ + sprintf(buf, "%ld", kim_gdata->uim_pid); + return strlen(buf); +} + +/* called when sysfs entry is read from */ +static ssize_t show_list(struct device *dev, struct device_attribute + *attr, char *buf) +{ + kim_st_list_protocols(kim_gdata->core_data, buf); + 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 + */ +static int kim_toggle_radio(void *data, bool blocked) +{ + enum proto_type type = *((enum proto_type *)data); + pr_info(" %s: %d ", __func__, type); + + switch (type) { + case ST_BT: + /* do nothing */ + break; + case ST_FM: + case ST_GPS: + if (blocked) + st_kim_chip_toggle(type, KIM_GPIO_INACTIVE); + else + st_kim_chip_toggle(type, KIM_GPIO_ACTIVE); + break; + case ST_MAX: + pr_err(" wrong proto type "); + break; + } + return ST_SUCCESS; +} + +#endif /* LEGACY_RFKILL_SUPPORT */ + +void st_kim_ref(struct st_data_s **core_data) +{ + *core_data = kim_gdata->core_data; +} + +/**********************************************************************/ +/* functions called from platform device driver subsystem + * need to have a relevant platform device entry in the platform's + * board-*.c file + */ + +static int kim_probe(struct platform_device *pdev) +{ + long status; + long proto; + long *gpios = pdev->dev.platform_data; + + status = st_core_init(&kim_gdata->core_data); + if (status != 0) { + pr_err(" ST core init failed"); + return ST_ERR_FAILURE; + } + + for (proto = 0; proto < ST_MAX; proto++) { + kim_gdata->gpios[proto] = gpios[proto]; + pr_info(" %ld gpio to be requested", gpios[proto]); + } + + for (proto = 0; (proto < ST_MAX) && (gpios[proto] != -1); proto++) { + /* Claim the Bluetooth/FM/GPIO + * nShutdown gpio from the system + */ + status = gpio_request(gpios[proto], "kim"); + if (unlikely(status)) { + pr_err(" gpio %ld request failed ", gpios[proto]); + proto -= 1; + while (proto >= 0) { + if (gpios[proto] != -1) + gpio_free(gpios[proto]); + } + return status; + } + + /* Configure nShutdown GPIO as output=0 */ + status = + gpio_direction_output(gpios[proto], 0); + if (unlikely(status)) { + pr_err(" unable to configure gpio %ld", + gpios[proto]); + proto -= 1; + while (proto >= 0) { + if (gpios[proto] != -1) + gpio_free(gpios[proto]); + } + 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; + kim_gdata->rfkill[proto] = rfkill_alloc(protocol_names[proto], + &pdev->dev, RFKILL_TYPE_BLUETOOTH, + &kim_rfkill_ops, &kim_gdata->rf_protos[proto]); + if (kim_gdata->rfkill[proto] == NULL) { + pr_err("cannot create rfkill entry for gpio %ld", + gpios[proto]); + continue; + } + /* block upon creation */ + rfkill_init_sw_state(kim_gdata->rfkill[proto], 1); + status = rfkill_register(kim_gdata->rfkill[proto]); + if (unlikely(status)) { + pr_err("rfkill registration failed for gpio %ld", + gpios[proto]); + rfkill_unregister(kim_gdata->rfkill[proto]); + continue; + } + pr_info("rfkill entry created for %ld", gpios[proto]); + } +#endif + return ST_SUCCESS; +} + +static int kim_remove(struct platform_device *pdev) +{ + /* free the GPIOs requested + */ + long *gpios = pdev->dev.platform_data; + long proto; + + for (proto = 0; (proto < ST_MAX) && (gpios[proto] != -1); proto++) { + /* Claim the Bluetooth/FM/GPIO + * 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; +} + +/**********************************************************************/ +/* entry point for ST KIM module, called in from ST Core */ + +static int __init st_kim_init(void) +{ + long ret = ST_SUCCESS; + kim_gdata = kzalloc(sizeof(struct kim_data_s), GFP_ATOMIC); + if (!kim_gdata) { + pr_err("no mem to allocate"); + return -ENOMEM; + } + + ret = platform_driver_register(&kim_platform_driver); + if (ret != 0) { + pr_err("platform drv registration failed"); + return ST_ERR_FAILURE; + } + return ST_SUCCESS; +} + +static void __exit st_kim_deinit(void) +{ + /* the following returns void */ + platform_driver_unregister(&kim_platform_driver); + kfree(kim_gdata); + kim_gdata = NULL; +} + + +module_init(st_kim_init); +module_exit(st_kim_deinit); +MODULE_AUTHOR("Pavan Savoy <pavan_savoy@ti.com>"); +MODULE_DESCRIPTION("Shared Transport Driver for TI BT/FM/GPS combo chips "); +MODULE_LICENSE("GPL"); diff --git a/drivers/staging/ti-st/st_kim.h b/drivers/staging/ti-st/st_kim.h new file mode 100644 index 000000000000..ff3270ec7847 --- /dev/null +++ b/drivers/staging/ti-st/st_kim.h @@ -0,0 +1,150 @@ +/* + * Shared Transport Line discipline driver Core + * Init Manager Module header file + * Copyright (C) 2009 Texas Instruments + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef ST_KIM_H +#define ST_KIM_H + +#include <linux/types.h> +#include "st.h" +#include "st_core.h" +#include "st_ll.h" +#include <linux/rfkill.h> + +/* time in msec to wait for + * line discipline to be installed + */ +#define LDISC_TIME 500 +#define CMD_RESP_TIME 500 +#define MAKEWORD(a, b) ((unsigned short)(((unsigned char)(a)) \ + | ((unsigned short)((unsigned char)(b))) << 8)) + +#define GPIO_HIGH 1 +#define GPIO_LOW 0 + +/* the Power-On-Reset logic, requires to attempt + * to download firmware onto chip more than once + * since the self-test for chip takes a while + */ +#define POR_RETRY_COUNT 5 +/* + * legacy rfkill support where-in 3 rfkill + * devices are created for the 3 gpios + * that ST has requested + */ +#define LEGACY_RFKILL_SUPPORT +/* + * header file for ST provided by KIM + */ +struct kim_data_s { + long uim_pid; + struct platform_device *kim_pdev; + struct completion kim_rcvd, ldisc_installed; + /* MAX len of the .bts firmware script name */ + 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; +}; + +long st_kim_start(void); +long st_kim_stop(void); +/* + * called from st_tty_receive to authenticate fw_download + */ +void st_kim_recv(void *, const unsigned char *, long count); + +void st_kim_chip_toggle(enum proto_type, enum kim_gpio_state); + +void st_kim_complete(void); + +/* function called from ST KIM to ST Core, to + * list out the protocols registered + */ +void kim_st_list_protocols(struct st_data_s *, char *); + +/* + * BTS headers + */ +#define ACTION_SEND_COMMAND 1 +#define ACTION_WAIT_EVENT 2 +#define ACTION_SERIAL 3 +#define ACTION_DELAY 4 +#define ACTION_RUN_SCRIPT 5 +#define ACTION_REMARKS 6 + +/* + * * BRF Firmware header + * */ +struct bts_header { + uint32_t magic; + uint32_t version; + uint8_t future[24]; + uint8_t actions[0]; +} __attribute__ ((packed)); + +/* + * * BRF Actions structure + * */ +struct bts_action { + uint16_t type; + uint16_t size; + uint8_t data[0]; +} __attribute__ ((packed)); + +struct bts_action_send { + uint8_t data[0]; +} __attribute__ ((packed)); + +struct bts_action_wait { + uint32_t msec; + uint32_t size; + uint8_t data[0]; +} __attribute__ ((packed)); + +struct bts_action_delay { + uint32_t msec; +} __attribute__ ((packed)); + +struct bts_action_serial { + uint32_t baud; + uint32_t flow_control; +} __attribute__ ((packed)); + +/* for identifying the change speed HCI VS + * command + */ +struct hci_command { + uint8_t prefix; + uint16_t opcode; + uint8_t plen; + uint32_t speed; +} __attribute__ ((packed)); + + +#endif /* ST_KIM_H */ diff --git a/drivers/staging/ti-st/st_ll.c b/drivers/staging/ti-st/st_ll.c new file mode 100644 index 000000000000..0685a100db6a --- /dev/null +++ b/drivers/staging/ti-st/st_ll.c @@ -0,0 +1,147 @@ +/* + * Shared Transport driver + * HCI-LL module responsible for TI proprietary HCI_LL protocol + * Copyright (C) 2009 Texas Instruments + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#define pr_fmt(fmt) "(stll) :" fmt +#include "st_ll.h" + +/**********************************************************************/ +/* internal functions */ +static void send_ll_cmd(struct st_data_s *st_data, + unsigned char cmd) +{ + + pr_info("%s: writing %x", __func__, cmd); + st_int_write(st_data, &cmd, 1); + return; +} + +static void ll_device_want_to_sleep(struct st_data_s *st_data) +{ + pr_info("%s", __func__); + /* sanity check */ + if (st_data->ll_state != ST_LL_AWAKE) + pr_err("ERR hcill: ST_LL_GO_TO_SLEEP_IND" + "in state %ld", st_data->ll_state); + + send_ll_cmd(st_data, LL_SLEEP_ACK); + /* update state */ + st_data->ll_state = ST_LL_ASLEEP; +} + +static void ll_device_want_to_wakeup(struct st_data_s *st_data) +{ + /* diff actions in diff states */ + switch (st_data->ll_state) { + case ST_LL_ASLEEP: + send_ll_cmd(st_data, LL_WAKE_UP_ACK); /* send wake_ack */ + break; + case ST_LL_ASLEEP_TO_AWAKE: + /* duplicate wake_ind */ + pr_err("duplicate wake_ind while waiting for Wake ack"); + break; + case ST_LL_AWAKE: + /* duplicate wake_ind */ + pr_err("duplicate wake_ind already AWAKE"); + break; + case ST_LL_AWAKE_TO_ASLEEP: + /* duplicate wake_ind */ + pr_err("duplicate wake_ind"); + break; + } + /* update state */ + st_data->ll_state = ST_LL_AWAKE; +} + +/**********************************************************************/ +/* functions invoked by ST Core */ + +/* called when ST Core wants to + * enable ST LL */ +void st_ll_enable(struct st_data_s *ll) +{ + ll->ll_state = ST_LL_AWAKE; +} + +/* called when ST Core /local module wants to + * disable ST LL */ +void st_ll_disable(struct st_data_s *ll) +{ + ll->ll_state = ST_LL_INVALID; +} + +/* called when ST Core wants to update the state */ +void st_ll_wakeup(struct st_data_s *ll) +{ + if (likely(ll->ll_state != ST_LL_AWAKE)) { + send_ll_cmd(ll, LL_WAKE_UP_IND); /* WAKE_IND */ + ll->ll_state = ST_LL_ASLEEP_TO_AWAKE; + } else { + /* don't send the duplicate wake_indication */ + pr_err(" Chip already AWAKE "); + } +} + +/* called when ST Core wants the state */ +unsigned long st_ll_getstate(struct st_data_s *ll) +{ + pr_info(" returning state %ld", ll->ll_state); + return ll->ll_state; +} + +/* called from ST Core, when a PM related packet arrives */ +unsigned long st_ll_sleep_state(struct st_data_s *st_data, + unsigned char cmd) +{ + switch (cmd) { + case LL_SLEEP_IND: /* sleep ind */ + pr_info("sleep indication recvd"); + ll_device_want_to_sleep(st_data); + break; + case LL_SLEEP_ACK: /* sleep ack */ + pr_err("sleep ack rcvd: host shouldn't"); + break; + case LL_WAKE_UP_IND: /* wake ind */ + pr_info("wake indication recvd"); + ll_device_want_to_wakeup(st_data); + break; + case LL_WAKE_UP_ACK: /* wake ack */ + pr_info("wake ack rcvd"); + st_data->ll_state = ST_LL_AWAKE; + break; + default: + pr_err(" unknown input/state "); + return ST_ERR_FAILURE; + } + return ST_SUCCESS; +} + +/* Called from ST CORE to initialize ST LL */ +long st_ll_init(struct st_data_s *ll) +{ + /* set state to invalid */ + ll->ll_state = ST_LL_INVALID; + return 0; +} + +/* Called from ST CORE to de-initialize ST LL */ +long st_ll_deinit(struct st_data_s *ll) +{ + return 0; +} diff --git a/drivers/staging/ti-st/st_ll.h b/drivers/staging/ti-st/st_ll.h new file mode 100644 index 000000000000..77dfbf07e7b8 --- /dev/null +++ b/drivers/staging/ti-st/st_ll.h @@ -0,0 +1,62 @@ +/* + * Shared Transport Low Level (ST LL) + * + * Copyright (C) 2009 Texas Instruments + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef ST_LL_H +#define ST_LL_H + +#include <linux/skbuff.h> +#include "st.h" +#include "st_core.h" + +/* ST LL receiver states */ +#define ST_W4_PACKET_TYPE 0 +#define ST_BT_W4_EVENT_HDR 1 +#define ST_BT_W4_ACL_HDR 2 +#define ST_BT_W4_SCO_HDR 3 +#define ST_BT_W4_DATA 4 +#define ST_FM_W4_EVENT_HDR 5 +#define ST_GPS_W4_EVENT_HDR 6 + +/* ST LL state machines */ +#define ST_LL_ASLEEP 0 +#define ST_LL_ASLEEP_TO_AWAKE 1 +#define ST_LL_AWAKE 2 +#define ST_LL_AWAKE_TO_ASLEEP 3 +#define ST_LL_INVALID 4 + +#define LL_SLEEP_IND 0x30 +#define LL_SLEEP_ACK 0x31 +#define LL_WAKE_UP_IND 0x32 +#define LL_WAKE_UP_ACK 0x33 + +/* initialize and de-init ST LL */ +long st_ll_init(struct st_data_s *); +long st_ll_deinit(struct st_data_s *); + +/* enable/disable ST LL along with KIM start/stop + * called by ST Core + */ +void st_ll_enable(struct st_data_s *); +void st_ll_disable(struct st_data_s *); + +unsigned long st_ll_getstate(struct st_data_s *); +unsigned long st_ll_sleep_state(struct st_data_s *, unsigned char); +void st_ll_wakeup(struct st_data_s *); +#endif /* ST_LL_H */ diff --git a/drivers/staging/ti-st/sysfs-uim b/drivers/staging/ti-st/sysfs-uim new file mode 100644 index 000000000000..10311afcbd45 --- /dev/null +++ b/drivers/staging/ti-st/sysfs-uim @@ -0,0 +1,16 @@ +What: /sys/class/rfkill/rfkill%d/ +Date: March 22 +Contact: Pavan Savoy <pavan_savoy@ti.com> +Description: + Creates the rfkill entries for Radio apps like + BT app, FM app or GPS app to toggle corresponding + cores of the chip + +What: /dev/rfkill +Date: March 22 +Contact: Pavan Savoy <pavan_savoy@ti.com> +Description: + A daemon which maintains the ldisc installation and + uninstallation would be ppolling on this device and listening + on events which would suggest either to install or un-install + line discipline diff --git a/drivers/staging/udlfb/udlfb.c b/drivers/staging/udlfb/udlfb.c index aa8195199a2c..c40911b158b9 100644 --- a/drivers/staging/udlfb/udlfb.c +++ b/drivers/staging/udlfb/udlfb.c @@ -58,17 +58,17 @@ static struct usb_device_id id_table[] = { MODULE_DEVICE_TABLE(usb, id_table); #ifndef CONFIG_FB_DEFERRED_IO -#warning message "kernel FB_DEFFERRED_IO option to support generic fbdev apps" +#warning Please set CONFIG_FB_DEFFERRED_IO option to support generic fbdev apps #endif #ifndef CONFIG_FB_SYS_IMAGEBLIT #ifndef CONFIG_FB_SYS_IMAGEBLIT_MODULE -#warning message "FB_SYS_* in kernel or module option to support fb console" +#warning Please set CONFIG_FB_SYS_IMAGEBLIT option to support fb console #endif #endif #ifndef CONFIG_FB_MODE_HELPERS -#warning message "kernel FB_MODE_HELPERS required. Expect build break" +#warning CONFIG_FB_MODE_HELPERS required. Expect build break #endif /* dlfb keeps a list of urbs for efficient bulk transfers */ @@ -366,32 +366,32 @@ static int dlfb_trim_hline(const u8 *bback, const u8 **bfront, int *width_bytes) } /* -Render a command stream for an encoded horizontal line segment of pixels. - -A command buffer holds several commands. -It always begins with a fresh command header -(the protocol doesn't require this, but we enforce it to allow -multiple buffers to be potentially encoded and sent in parallel). -A single command encodes one contiguous horizontal line of pixels - -The function relies on the client to do all allocation, so that -rendering can be done directly to output buffers (e.g. USB URBs). -The function fills the supplied command buffer, providing information -on where it left off, so the client may call in again with additional -buffers if the line will take several buffers to complete. - -A single command can transmit a maximum of 256 pixels, -regardless of the compression ratio (protocol design limit). -To the hardware, 0 for a size byte means 256 - -Rather than 256 pixel commands which are either rl or raw encoded, -the rlx command simply assumes alternating raw and rl spans within one cmd. -This has a slightly larger header overhead, but produces more even results. -It also processes all data (read and write) in a single pass. -Performance benchmarks of common cases show it having just slightly better -compression than 256 pixel raw -or- rle commands, with similar CPU consumpion. -But for very rl friendly data, will compress not quite as well. -*/ + * Render a command stream for an encoded horizontal line segment of pixels. + * + * A command buffer holds several commands. + * It always begins with a fresh command header + * (the protocol doesn't require this, but we enforce it to allow + * multiple buffers to be potentially encoded and sent in parallel). + * A single command encodes one contiguous horizontal line of pixels + * + * The function relies on the client to do all allocation, so that + * rendering can be done directly to output buffers (e.g. USB URBs). + * The function fills the supplied command buffer, providing information + * on where it left off, so the client may call in again with additional + * buffers if the line will take several buffers to complete. + * + * A single command can transmit a maximum of 256 pixels, + * regardless of the compression ratio (protocol design limit). + * To the hardware, 0 for a size byte means 256 + * + * Rather than 256 pixel commands which are either rl or raw encoded, + * the rlx command simply assumes alternating raw and rl spans within one cmd. + * This has a slightly larger header overhead, but produces more even results. + * It also processes all data (read and write) in a single pass. + * Performance benchmarks of common cases show it having just slightly better + * compression than 256 pixel raw -or- rle commands, with similar CPU consumpion. + * But for very rl friendly data, will compress not quite as well. + */ static void dlfb_compress_hline( const uint16_t **pixel_start_ptr, const uint16_t *const pixel_end, diff --git a/drivers/staging/usbip/usbip_common.h b/drivers/staging/usbip/usbip_common.h index 6f1dcb197d13..e1bbd1287e28 100644 --- a/drivers/staging/usbip/usbip_common.h +++ b/drivers/staging/usbip/usbip_common.h @@ -182,7 +182,7 @@ struct usbip_header_basic { __u32 devid; #define USBIP_DIR_OUT 0 -#define USBIP_DIR_IN 1 +#define USBIP_DIR_IN 1 __u32 direction; __u32 ep; /* endpoint number */ } __attribute__ ((packed)); diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c index 0b1766122d38..be5d8db98165 100644 --- a/drivers/staging/usbip/vhci_hcd.c +++ b/drivers/staging/usbip/vhci_hcd.c @@ -1072,7 +1072,7 @@ static struct hc_driver vhci_hc_driver = { .flags = HCD_USB2, .start = vhci_start, - .stop = vhci_stop, + .stop = vhci_stop, .urb_enqueue = vhci_urb_enqueue, .urb_dequeue = vhci_urb_dequeue, diff --git a/drivers/staging/usbip/vhci_tx.c b/drivers/staging/usbip/vhci_tx.c index b71b4c2fbd86..e1c1f716a1c2 100644 --- a/drivers/staging/usbip/vhci_tx.c +++ b/drivers/staging/usbip/vhci_tx.c @@ -179,7 +179,7 @@ static int vhci_send_cmd_unlink(struct vhci_device *vdev) memset(&msg, 0, sizeof(msg)); memset(&iov, 0, sizeof(iov)); - usbip_dbg_vhci_tx("setup cmd unlink, %lu \n", unlink->seqnum); + usbip_dbg_vhci_tx("setup cmd unlink, %lu\n", unlink->seqnum); /* 1. setup usbip_header */ diff --git a/drivers/staging/vme/boards/vme_vmivme7805.c b/drivers/staging/vme/boards/vme_vmivme7805.c index 843c9edde555..80eaa0c4fe1c 100644 --- a/drivers/staging/vme/boards/vme_vmivme7805.c +++ b/drivers/staging/vme/boards/vme_vmivme7805.c @@ -10,7 +10,6 @@ * option) any later version. */ -#include <linux/version.h> #include <linux/module.h> #include <linux/types.h> #include <linux/errno.h> diff --git a/drivers/staging/vme/bridges/vme_ca91cx42.c b/drivers/staging/vme/bridges/vme_ca91cx42.c index b159ea58adf7..b9f986b856eb 100644 --- a/drivers/staging/vme/bridges/vme_ca91cx42.c +++ b/drivers/staging/vme/bridges/vme_ca91cx42.c @@ -26,9 +26,9 @@ #include <linux/spinlock.h> #include <linux/sched.h> #include <linux/slab.h> -#include <asm/time.h> -#include <asm/io.h> -#include <asm/uaccess.h> +#include <linux/time.h> +#include <linux/io.h> +#include <linux/uaccess.h> #include "../vme.h" #include "../vme_bridge.h" @@ -94,31 +94,35 @@ static u32 ca91cx42_IACK_irqhandler(struct ca91cx42_driver *bridge) return CA91CX42_LINT_SW_IACK; } -static u32 ca91cx42_VERR_irqhandler(struct ca91cx42_driver *bridge) +static u32 ca91cx42_VERR_irqhandler(struct vme_bridge *ca91cx42_bridge) { int val; + struct ca91cx42_driver *bridge; + + bridge = ca91cx42_bridge->driver_priv; val = ioread32(bridge->base + DGCS); if (!(val & 0x00000800)) { - printk(KERN_ERR "ca91c042: ca91cx42_VERR_irqhandler DMA Read " - "Error DGCS=%08X\n", val); + dev_err(ca91cx42_bridge->parent, "ca91cx42_VERR_irqhandler DMA " + "Read Error DGCS=%08X\n", val); } return CA91CX42_LINT_VERR; } -static u32 ca91cx42_LERR_irqhandler(struct ca91cx42_driver *bridge) +static u32 ca91cx42_LERR_irqhandler(struct vme_bridge *ca91cx42_bridge) { int val; + struct ca91cx42_driver *bridge; - val = ioread32(bridge->base + DGCS); + bridge = ca91cx42_bridge->driver_priv; - if (!(val & 0x00000800)) { - printk(KERN_ERR "ca91c042: ca91cx42_LERR_irqhandler DMA Read " - "Error DGCS=%08X\n", val); + val = ioread32(bridge->base + DGCS); - } + if (!(val & 0x00000800)) + dev_err(ca91cx42_bridge->parent, "ca91cx42_LERR_irqhandler DMA " + "Read Error DGCS=%08X\n", val); return CA91CX42_LINT_LERR; } @@ -176,9 +180,9 @@ static irqreturn_t ca91cx42_irqhandler(int irq, void *ptr) if (stat & CA91CX42_LINT_SW_IACK) serviced |= ca91cx42_IACK_irqhandler(bridge); if (stat & CA91CX42_LINT_VERR) - serviced |= ca91cx42_VERR_irqhandler(bridge); + serviced |= ca91cx42_VERR_irqhandler(ca91cx42_bridge); if (stat & CA91CX42_LINT_LERR) - serviced |= ca91cx42_LERR_irqhandler(bridge); + serviced |= ca91cx42_LERR_irqhandler(ca91cx42_bridge); if (stat & (CA91CX42_LINT_VIRQ1 | CA91CX42_LINT_VIRQ2 | CA91CX42_LINT_VIRQ3 | CA91CX42_LINT_VIRQ4 | CA91CX42_LINT_VIRQ5 | CA91CX42_LINT_VIRQ6 | @@ -326,9 +330,12 @@ int ca91cx42_slave_set(struct vme_slave_resource *image, int enabled, unsigned int i, addr = 0, granularity; unsigned int temp_ctl = 0; unsigned int vme_bound, pci_offset; + struct vme_bridge *ca91cx42_bridge; struct ca91cx42_driver *bridge; - bridge = image->parent->driver_priv; + ca91cx42_bridge = image->parent; + + bridge = ca91cx42_bridge->driver_priv; i = image->number; @@ -353,7 +360,7 @@ int ca91cx42_slave_set(struct vme_slave_resource *image, int enabled, case VME_USER3: case VME_USER4: default: - printk(KERN_ERR "Invalid address space\n"); + dev_err(ca91cx42_bridge->parent, "Invalid address space\n"); return -EINVAL; break; } @@ -371,15 +378,18 @@ int ca91cx42_slave_set(struct vme_slave_resource *image, int enabled, granularity = 0x10000; if (vme_base & (granularity - 1)) { - printk(KERN_ERR "Invalid VME base alignment\n"); + dev_err(ca91cx42_bridge->parent, "Invalid VME base " + "alignment\n"); return -EINVAL; } if (vme_bound & (granularity - 1)) { - printk(KERN_ERR "Invalid VME bound alignment\n"); + dev_err(ca91cx42_bridge->parent, "Invalid VME bound " + "alignment\n"); return -EINVAL; } if (pci_offset & (granularity - 1)) { - printk(KERN_ERR "Invalid PCI Offset alignment\n"); + dev_err(ca91cx42_bridge->parent, "Invalid PCI Offset " + "alignment\n"); return -EINVAL; } @@ -491,7 +501,7 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image, /* Find pci_dev container of dev */ if (ca91cx42_bridge->parent == NULL) { - printk(KERN_ERR "Dev entry NULL\n"); + dev_err(ca91cx42_bridge->parent, "Dev entry NULL\n"); return -EINVAL; } pdev = container_of(ca91cx42_bridge->parent, struct pci_dev, dev); @@ -515,8 +525,8 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image, if (image->bus_resource.name == NULL) { image->bus_resource.name = kmalloc(VMENAMSIZ+3, GFP_KERNEL); if (image->bus_resource.name == NULL) { - printk(KERN_ERR "Unable to allocate memory for resource" - " name\n"); + dev_err(ca91cx42_bridge->parent, "Unable to allocate " + "memory for resource name\n"); retval = -ENOMEM; goto err_name; } @@ -533,8 +543,8 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image, &(image->bus_resource), size, size, PCIBIOS_MIN_MEM, 0, NULL, NULL); if (retval) { - printk(KERN_ERR "Failed to allocate mem resource for " - "window %d size 0x%lx start 0x%lx\n", + dev_err(ca91cx42_bridge->parent, "Failed to allocate mem " + "resource for window %d size 0x%lx start 0x%lx\n", image->number, (unsigned long)size, (unsigned long)image->bus_resource.start); goto err_resource; @@ -543,7 +553,7 @@ static int ca91cx42_alloc_resource(struct vme_master_resource *image, image->kern_base = ioremap_nocache( image->bus_resource.start, size); if (image->kern_base == NULL) { - printk(KERN_ERR "Failed to remap resource\n"); + dev_err(ca91cx42_bridge->parent, "Failed to remap resource\n"); retval = -ENOMEM; goto err_remap; } @@ -582,9 +592,12 @@ int ca91cx42_master_set(struct vme_master_resource *image, int enabled, unsigned int i, granularity = 0; unsigned int temp_ctl = 0; unsigned long long pci_bound, vme_offset, pci_base; + struct vme_bridge *ca91cx42_bridge; struct ca91cx42_driver *bridge; - bridge = image->parent->driver_priv; + ca91cx42_bridge = image->parent; + + bridge = ca91cx42_bridge->driver_priv; i = image->number; @@ -595,12 +608,14 @@ int ca91cx42_master_set(struct vme_master_resource *image, int enabled, /* Verify input data */ if (vme_base & (granularity - 1)) { - printk(KERN_ERR "Invalid VME Window alignment\n"); + dev_err(ca91cx42_bridge->parent, "Invalid VME Window " + "alignment\n"); retval = -EINVAL; goto err_window; } if (size & (granularity - 1)) { - printk(KERN_ERR "Invalid VME Window alignment\n"); + dev_err(ca91cx42_bridge->parent, "Invalid VME Window " + "alignment\n"); retval = -EINVAL; goto err_window; } @@ -614,8 +629,8 @@ int ca91cx42_master_set(struct vme_master_resource *image, int enabled, retval = ca91cx42_alloc_resource(image, size); if (retval) { spin_unlock(&(image->lock)); - printk(KERN_ERR "Unable to allocate memory for resource " - "name\n"); + dev_err(ca91cx42_bridge->parent, "Unable to allocate memory " + "for resource name\n"); retval = -ENOMEM; goto err_res; } @@ -658,7 +673,7 @@ int ca91cx42_master_set(struct vme_master_resource *image, int enabled, break; default: spin_unlock(&(image->lock)); - printk(KERN_ERR "Invalid data width\n"); + dev_err(ca91cx42_bridge->parent, "Invalid data width\n"); retval = -EINVAL; goto err_dwidth; break; @@ -690,7 +705,7 @@ int ca91cx42_master_set(struct vme_master_resource *image, int enabled, case VME_USER4: default: spin_unlock(&(image->lock)); - printk(KERN_ERR "Invalid address space\n"); + dev_err(ca91cx42_bridge->parent, "Invalid address space\n"); retval = -EINVAL; goto err_aspace; break; @@ -921,12 +936,15 @@ int ca91cx42_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src, struct vme_dma_vme *vme_attr; dma_addr_t desc_ptr; int retval = 0; + struct device *dev; + + dev = list->parent->parent->parent; /* XXX descriptor must be aligned on 64-bit boundaries */ entry = (struct ca91cx42_dma_entry *) kmalloc(sizeof(struct ca91cx42_dma_entry), GFP_KERNEL); if (entry == NULL) { - printk(KERN_ERR "Failed to allocate memory for dma resource " + dev_err(dev, "Failed to allocate memory for dma resource " "structure\n"); retval = -ENOMEM; goto err_mem; @@ -934,7 +952,7 @@ int ca91cx42_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src, /* Test descriptor alignment */ if ((unsigned long)&(entry->descriptor) & CA91CX42_DCPP_M) { - printk("Descriptor not aligned to 16 byte boundary as " + dev_err(dev, "Descriptor not aligned to 16 byte boundary as " "required: %p\n", &(entry->descriptor)); retval = -EINVAL; goto err_align; @@ -955,7 +973,7 @@ int ca91cx42_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src, if ((vme_attr->aspace & ~(VME_A16 | VME_A24 | VME_A32 | VME_USER1 | VME_USER2)) != 0) { - printk(KERN_ERR "Unsupported cycle type\n"); + dev_err(dev, "Unsupported cycle type\n"); retval = -EINVAL; goto err_aspace; } @@ -963,7 +981,7 @@ int ca91cx42_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src, if ((vme_attr->cycle & ~(VME_SCT | VME_BLT | VME_SUPER | VME_USER | VME_PROG | VME_DATA)) != 0) { - printk(KERN_ERR "Unsupported cycle type\n"); + dev_err(dev, "Unsupported cycle type\n"); retval = -EINVAL; goto err_cycle; } @@ -972,7 +990,7 @@ int ca91cx42_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src, if (!(((src->type == VME_DMA_PCI) && (dest->type == VME_DMA_VME)) || ((src->type == VME_DMA_VME) && (dest->type == VME_DMA_PCI)))) { - printk(KERN_ERR "Cannot perform transfer with this " + dev_err(dev, "Cannot perform transfer with this " "source-destination combination\n"); retval = -EINVAL; goto err_direct; @@ -997,7 +1015,7 @@ int ca91cx42_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src, entry->descriptor.dctl |= CA91CX42_DCTL_VDW_D64; break; default: - printk(KERN_ERR "Invalid data width\n"); + dev_err(dev, "Invalid data width\n"); return -EINVAL; } @@ -1019,7 +1037,7 @@ int ca91cx42_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src, entry->descriptor.dctl |= CA91CX42_DCTL_VAS_USER2; break; default: - printk(KERN_ERR "Invalid address space\n"); + dev_err(dev, "Invalid address space\n"); return -EINVAL; break; } @@ -1079,12 +1097,13 @@ int ca91cx42_dma_list_exec(struct vme_dma_list *list) int retval = 0; dma_addr_t bus_addr; u32 val; - + struct device *dev; struct ca91cx42_driver *bridge; ctrlr = list->parent; bridge = ctrlr->parent->driver_priv; + dev = ctrlr->parent->parent; mutex_lock(&(ctrlr->mtx)); @@ -1140,7 +1159,7 @@ int ca91cx42_dma_list_exec(struct vme_dma_list *list) if (val & (CA91CX42_DGCS_LERR | CA91CX42_DGCS_VERR | CA91CX42_DGCS_PERR)) { - printk(KERN_ERR "ca91c042: DMA Error. DGCS=%08X\n", val); + dev_err(dev, "ca91c042: DMA Error. DGCS=%08X\n", val); val = ioread32(bridge->base + DCTL); } @@ -1665,9 +1684,8 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id) dev_info(&pdev->dev, "Slot ID is %d\n", ca91cx42_slot_get(ca91cx42_bridge)); - if (ca91cx42_crcsr_init(ca91cx42_bridge, pdev)) { + if (ca91cx42_crcsr_init(ca91cx42_bridge, pdev)) dev_err(&pdev->dev, "CR/CSR configuration failed.\n"); - } /* Need to save ca91cx42_bridge pointer locally in link list for use in * ca91cx42_remove() diff --git a/drivers/staging/vme/bridges/vme_tsi148.c b/drivers/staging/vme/bridges/vme_tsi148.c index 783051f59f19..85eb76970977 100644 --- a/drivers/staging/vme/bridges/vme_tsi148.c +++ b/drivers/staging/vme/bridges/vme_tsi148.c @@ -26,9 +26,9 @@ #include <linux/spinlock.h> #include <linux/sched.h> #include <linux/slab.h> -#include <asm/time.h> -#include <asm/io.h> -#include <asm/uaccess.h> +#include <linux/time.h> +#include <linux/io.h> +#include <linux/uaccess.h> #include "../vme.h" #include "../vme_bridge.h" @@ -40,27 +40,6 @@ static void tsi148_remove(struct pci_dev *); static void __exit tsi148_exit(void); -int tsi148_slave_set(struct vme_slave_resource *, int, unsigned long long, - unsigned long long, dma_addr_t, vme_address_t, vme_cycle_t); -int tsi148_slave_get(struct vme_slave_resource *, int *, unsigned long long *, - unsigned long long *, dma_addr_t *, vme_address_t *, vme_cycle_t *); - -int tsi148_master_get(struct vme_master_resource *, int *, unsigned long long *, - unsigned long long *, vme_address_t *, vme_cycle_t *, vme_width_t *); -int tsi148_master_set(struct vme_master_resource *, int, unsigned long long, - unsigned long long, vme_address_t, vme_cycle_t, vme_width_t); -ssize_t tsi148_master_read(struct vme_master_resource *, void *, size_t, - loff_t); -ssize_t tsi148_master_write(struct vme_master_resource *, void *, size_t, - loff_t); -unsigned int tsi148_master_rmw(struct vme_master_resource *, unsigned int, - unsigned int, unsigned int, loff_t); -int tsi148_dma_list_add (struct vme_dma_list *, struct vme_dma_attr *, - struct vme_dma_attr *, size_t); -int tsi148_dma_list_exec(struct vme_dma_list *); -int tsi148_dma_list_empty(struct vme_dma_list *); -int tsi148_generate_irq(int, int); - /* Module parameter */ static int err_chk; static int geoid; @@ -122,7 +101,7 @@ static u32 tsi148_LM_irqhandler(struct tsi148_driver *bridge, u32 stat) u32 serviced = 0; for (i = 0; i < 4; i++) { - if(stat & TSI148_LCSR_INTS_LMS[i]) { + if (stat & TSI148_LCSR_INTS_LMS[i]) { /* We only enable interrupts if the callback is set */ bridge->lm_callback[i](i); serviced |= TSI148_LCSR_INTC_LMC[i]; @@ -137,16 +116,20 @@ static u32 tsi148_LM_irqhandler(struct tsi148_driver *bridge, u32 stat) * * XXX This functionality is not exposed up though API. */ -static u32 tsi148_MB_irqhandler(struct tsi148_driver *bridge, u32 stat) +static u32 tsi148_MB_irqhandler(struct vme_bridge *tsi148_bridge, u32 stat) { int i; u32 val; u32 serviced = 0; + struct tsi148_driver *bridge; + + bridge = tsi148_bridge->driver_priv; for (i = 0; i < 4; i++) { - if(stat & TSI148_LCSR_INTS_MBS[i]) { + if (stat & TSI148_LCSR_INTS_MBS[i]) { val = ioread32be(bridge->base + TSI148_GCSR_MBOX[i]); - printk("VME Mailbox %d received: 0x%x\n", i, val); + dev_err(tsi148_bridge->parent, "VME Mailbox %d received" + ": 0x%x\n", i, val); serviced |= TSI148_LCSR_INTC_MBC[i]; } } @@ -157,19 +140,22 @@ static u32 tsi148_MB_irqhandler(struct tsi148_driver *bridge, u32 stat) /* * Display error & status message when PERR (PCI) exception interrupt occurs. */ -static u32 tsi148_PERR_irqhandler(struct tsi148_driver *bridge) +static u32 tsi148_PERR_irqhandler(struct vme_bridge *tsi148_bridge) { - printk(KERN_ERR - "PCI Exception at address: 0x%08x:%08x, attributes: %08x\n", + struct tsi148_driver *bridge; + + bridge = tsi148_bridge->driver_priv; + + dev_err(tsi148_bridge->parent, "PCI Exception at address: 0x%08x:%08x, " + "attributes: %08x\n", ioread32be(bridge->base + TSI148_LCSR_EDPAU), ioread32be(bridge->base + TSI148_LCSR_EDPAL), - ioread32be(bridge->base + TSI148_LCSR_EDPAT) - ); - printk(KERN_ERR - "PCI-X attribute reg: %08x, PCI-X split completion reg: %08x\n", + ioread32be(bridge->base + TSI148_LCSR_EDPAT)); + + dev_err(tsi148_bridge->parent, "PCI-X attribute reg: %08x, PCI-X split " + "completion reg: %08x\n", ioread32be(bridge->base + TSI148_LCSR_EDPXA), - ioread32be(bridge->base + TSI148_LCSR_EDPXS) - ); + ioread32be(bridge->base + TSI148_LCSR_EDPXS)); iowrite32be(TSI148_LCSR_EDPAT_EDPCL, bridge->base + TSI148_LCSR_EDPAT); @@ -196,22 +182,21 @@ static u32 tsi148_VERR_irqhandler(struct vme_bridge *tsi148_bridge) reg_join(error_addr_high, error_addr_low, &error_addr); /* Check for exception register overflow (we have lost error data) */ - if(error_attrib & TSI148_LCSR_VEAT_VEOF) { - printk(KERN_ERR "VME Bus Exception Overflow Occurred\n"); + if (error_attrib & TSI148_LCSR_VEAT_VEOF) { + dev_err(tsi148_bridge->parent, "VME Bus Exception Overflow " + "Occurred\n"); } - error = (struct vme_bus_error *)kmalloc(sizeof (struct vme_bus_error), - GFP_ATOMIC); + error = kmalloc(sizeof(struct vme_bus_error), GFP_ATOMIC); if (error) { error->address = error_addr; error->attributes = error_attrib; list_add_tail(&(error->list), &(tsi148_bridge->vme_errors)); } else { - printk(KERN_ERR - "Unable to alloc memory for VMEbus Error reporting\n"); - printk(KERN_ERR - "VME Bus Error at address: 0x%llx, attributes: %08x\n", - error_addr, error_attrib); + dev_err(tsi148_bridge->parent, "Unable to alloc memory for " + "VMEbus Error reporting\n"); + dev_err(tsi148_bridge->parent, "VME Bus Error at address: " + "0x%llx, attributes: %08x\n", error_addr, error_attrib); } /* Clear Status */ @@ -244,10 +229,9 @@ static u32 tsi148_VIRQ_irqhandler(struct vme_bridge *tsi148_bridge, for (i = 7; i > 0; i--) { if (stat & (1 << i)) { /* - * Note: Even though the registers are defined - * as 32-bits in the spec, we only want to issue - * 8-bit IACK cycles on the bus, read from offset - * 3. + * Note: Even though the registers are defined as + * 32-bits in the spec, we only want to issue 8-bit + * IACK cycles on the bus, read from offset 3. */ vec = ioread8(bridge->base + TSI148_LCSR_VIACK[i] + 3); @@ -281,9 +265,8 @@ static irqreturn_t tsi148_irqhandler(int irq, void *ptr) /* Only look at unmasked interrupts */ stat &= enable; - if (unlikely(!stat)) { + if (unlikely(!stat)) return IRQ_NONE; - } /* Call subhandlers as appropriate */ /* DMA irqs */ @@ -298,11 +281,11 @@ static irqreturn_t tsi148_irqhandler(int irq, void *ptr) /* Mail box irqs */ if (stat & (TSI148_LCSR_INTS_MB3S | TSI148_LCSR_INTS_MB2S | TSI148_LCSR_INTS_MB1S | TSI148_LCSR_INTS_MB0S)) - serviced |= tsi148_MB_irqhandler(bridge, stat); + serviced |= tsi148_MB_irqhandler(tsi148_bridge, stat); /* PCI bus error */ if (stat & TSI148_LCSR_INTS_PERRS) - serviced |= tsi148_PERR_irqhandler(bridge); + serviced |= tsi148_PERR_irqhandler(tsi148_bridge); /* VME bus error */ if (stat & TSI148_LCSR_INTS_VERRS) @@ -346,8 +329,8 @@ static int tsi148_irq_init(struct vme_bridge *tsi148_bridge) IRQF_SHARED, driver_name, tsi148_bridge); if (result) { - dev_err(&pdev->dev, "Can't get assigned pci irq vector %02X\n", - pdev->irq); + dev_err(tsi148_bridge->parent, "Can't get assigned pci irq " + "vector %02X\n", pdev->irq); return result; } @@ -515,7 +498,9 @@ static struct vme_bus_error *tsi148_find_error(struct vme_bridge *tsi148_bridge, /* Iterate through errors */ list_for_each(err_pos, &(tsi148_bridge->vme_errors)) { vme_err = list_entry(err_pos, struct vme_bus_error, list); - if((vme_err->address >= address) && (vme_err->address < bound)){ + if ((vme_err->address >= address) && + (vme_err->address < bound)) { + valid = vme_err; break; } @@ -548,7 +533,9 @@ static void tsi148_clear_errors(struct vme_bridge *tsi148_bridge, list_for_each_safe(err_pos, temp, &(tsi148_bridge->vme_errors)) { vme_err = list_entry(err_pos, struct vme_bus_error, list); - if((vme_err->address >= address) && (vme_err->address < bound)){ + if ((vme_err->address >= address) && + (vme_err->address < bound)) { + list_del(err_pos); kfree(vme_err); } @@ -568,9 +555,11 @@ int tsi148_slave_set(struct vme_slave_resource *image, int enabled, unsigned int vme_bound_low, vme_bound_high; unsigned int pci_offset_low, pci_offset_high; unsigned long long vme_bound, pci_offset; + struct vme_bridge *tsi148_bridge; struct tsi148_driver *bridge; - bridge = image->parent->driver_priv; + tsi148_bridge = image->parent; + bridge = tsi148_bridge->driver_priv; i = image->number; @@ -597,7 +586,7 @@ int tsi148_slave_set(struct vme_slave_resource *image, int enabled, case VME_USER3: case VME_USER4: default: - printk("Invalid address space\n"); + dev_err(tsi148_bridge->parent, "Invalid address space\n"); return -EINVAL; break; } @@ -615,15 +604,16 @@ int tsi148_slave_set(struct vme_slave_resource *image, int enabled, reg_split(pci_offset, &pci_offset_high, &pci_offset_low); if (vme_base_low & (granularity - 1)) { - printk("Invalid VME base alignment\n"); + dev_err(tsi148_bridge->parent, "Invalid VME base alignment\n"); return -EINVAL; } if (vme_bound_low & (granularity - 1)) { - printk("Invalid VME bound alignment\n"); + dev_err(tsi148_bridge->parent, "Invalid VME bound alignment\n"); return -EINVAL; } if (pci_offset_low & (granularity - 1)) { - printk("Invalid PCI Offset alignment\n"); + dev_err(tsi148_bridge->parent, "Invalid PCI Offset " + "alignment\n"); return -EINVAL; } @@ -815,12 +805,7 @@ static int tsi148_alloc_resource(struct vme_master_resource *image, tsi148_bridge = image->parent; - /* Find pci_dev container of dev */ - if (tsi148_bridge->parent == NULL) { - printk("Dev entry NULL\n"); - return -EINVAL; - } - pdev = container_of(tsi148_bridge->parent, struct pci_dev, dev); + pdev = container_of(tsi148_bridge->parent, struct pci_dev, dev); existing_size = (unsigned long long)(image->bus_resource.end - image->bus_resource.start); @@ -839,15 +824,14 @@ static int tsi148_alloc_resource(struct vme_master_resource *image, } /* Exit here if size is zero */ - if (size == 0) { + if (size == 0) return 0; - } if (image->bus_resource.name == NULL) { image->bus_resource.name = kmalloc(VMENAMSIZ+3, GFP_KERNEL); if (image->bus_resource.name == NULL) { - printk(KERN_ERR "Unable to allocate memory for resource" - " name\n"); + dev_err(tsi148_bridge->parent, "Unable to allocate " + "memory for resource name\n"); retval = -ENOMEM; goto err_name; } @@ -864,8 +848,8 @@ static int tsi148_alloc_resource(struct vme_master_resource *image, &(image->bus_resource), size, size, PCIBIOS_MIN_MEM, 0, NULL, NULL); if (retval) { - printk(KERN_ERR "Failed to allocate mem resource for " - "window %d size 0x%lx start 0x%lx\n", + dev_err(tsi148_bridge->parent, "Failed to allocate mem " + "resource for window %d size 0x%lx start 0x%lx\n", image->number, (unsigned long)size, (unsigned long)image->bus_resource.start); goto err_resource; @@ -874,7 +858,7 @@ static int tsi148_alloc_resource(struct vme_master_resource *image, image->kern_base = ioremap_nocache( image->bus_resource.start, size); if (image->kern_base == NULL) { - printk(KERN_ERR "Failed to remap resource\n"); + dev_err(tsi148_bridge->parent, "Failed to remap resource\n"); retval = -ENOMEM; goto err_remap; } @@ -907,7 +891,7 @@ static void tsi148_free_resource(struct vme_master_resource *image) /* * Set the attributes of an outbound window. */ -int tsi148_master_set( struct vme_master_resource *image, int enabled, +int tsi148_master_set(struct vme_master_resource *image, int enabled, unsigned long long vme_base, unsigned long long size, vme_address_t aspace, vme_cycle_t cycle, vme_width_t dwidth) { @@ -918,19 +902,24 @@ int tsi148_master_set( struct vme_master_resource *image, int enabled, unsigned int pci_bound_low, pci_bound_high; unsigned int vme_offset_low, vme_offset_high; unsigned long long pci_bound, vme_offset, pci_base; + struct vme_bridge *tsi148_bridge; struct tsi148_driver *bridge; - bridge = image->parent->driver_priv; + tsi148_bridge = image->parent; + + bridge = tsi148_bridge->driver_priv; /* Verify input data */ if (vme_base & 0xFFFF) { - printk(KERN_ERR "Invalid VME Window alignment\n"); + dev_err(tsi148_bridge->parent, "Invalid VME Window " + "alignment\n"); retval = -EINVAL; goto err_window; } if ((size == 0) && (enabled != 0)) { - printk(KERN_ERR "Size must be non-zero for enabled windows\n"); + dev_err(tsi148_bridge->parent, "Size must be non-zero for " + "enabled windows\n"); retval = -EINVAL; goto err_window; } @@ -944,7 +933,7 @@ int tsi148_master_set( struct vme_master_resource *image, int enabled, retval = tsi148_alloc_resource(image, size); if (retval) { spin_unlock(&(image->lock)); - printk(KERN_ERR "Unable to allocate memory for " + dev_err(tsi148_bridge->parent, "Unable to allocate memory for " "resource\n"); goto err_res; } @@ -971,19 +960,20 @@ int tsi148_master_set( struct vme_master_resource *image, int enabled, if (pci_base_low & 0xFFFF) { spin_unlock(&(image->lock)); - printk(KERN_ERR "Invalid PCI base alignment\n"); + dev_err(tsi148_bridge->parent, "Invalid PCI base alignment\n"); retval = -EINVAL; goto err_gran; } if (pci_bound_low & 0xFFFF) { spin_unlock(&(image->lock)); - printk(KERN_ERR "Invalid PCI bound alignment\n"); + dev_err(tsi148_bridge->parent, "Invalid PCI bound alignment\n"); retval = -EINVAL; goto err_gran; } if (vme_offset_low & 0xFFFF) { spin_unlock(&(image->lock)); - printk(KERN_ERR "Invalid VME Offset alignment\n"); + dev_err(tsi148_bridge->parent, "Invalid VME Offset " + "alignment\n"); retval = -EINVAL; goto err_gran; } @@ -1029,8 +1019,8 @@ int tsi148_master_set( struct vme_master_resource *image, int enabled, temp_ctl |= TSI148_LCSR_OTAT_TM_2eSST; } if (cycle & VME_2eSSTB) { - printk(KERN_WARNING "Currently not setting Broadcast Select " - "Registers\n"); + dev_warn(tsi148_bridge->parent, "Currently not setting " + "Broadcast Select Registers\n"); temp_ctl &= ~TSI148_LCSR_OTAT_TM_M; temp_ctl |= TSI148_LCSR_OTAT_TM_2eSSTB; } @@ -1046,7 +1036,7 @@ int tsi148_master_set( struct vme_master_resource *image, int enabled, break; default: spin_unlock(&(image->lock)); - printk(KERN_ERR "Invalid data width\n"); + dev_err(tsi148_bridge->parent, "Invalid data width\n"); retval = -EINVAL; goto err_dwidth; } @@ -1083,7 +1073,7 @@ int tsi148_master_set( struct vme_master_resource *image, int enabled, break; default: spin_unlock(&(image->lock)); - printk(KERN_ERR "Invalid address space\n"); + dev_err(tsi148_bridge->parent, "Invalid address space\n"); retval = -EINVAL; goto err_aspace; break; @@ -1137,7 +1127,7 @@ err_window: * * XXX Not parsing prefetch information. */ -int __tsi148_master_get( struct vme_master_resource *image, int *enabled, +int __tsi148_master_get(struct vme_master_resource *image, int *enabled, unsigned long long *vme_base, unsigned long long *size, vme_address_t *aspace, vme_cycle_t *cycle, vme_width_t *dwidth) { @@ -1214,17 +1204,17 @@ int __tsi148_master_get( struct vme_master_resource *image, int *enabled, *cycle |= VME_2eSST320; /* Setup cycle types */ - if ((ctl & TSI148_LCSR_OTAT_TM_M ) == TSI148_LCSR_OTAT_TM_SCT) + if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_SCT) *cycle |= VME_SCT; - if ((ctl & TSI148_LCSR_OTAT_TM_M ) == TSI148_LCSR_OTAT_TM_BLT) + if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_BLT) *cycle |= VME_BLT; - if ((ctl & TSI148_LCSR_OTAT_TM_M ) == TSI148_LCSR_OTAT_TM_MBLT) + if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_MBLT) *cycle |= VME_MBLT; - if ((ctl & TSI148_LCSR_OTAT_TM_M ) == TSI148_LCSR_OTAT_TM_2eVME) + if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_2eVME) *cycle |= VME_2eVME; - if ((ctl & TSI148_LCSR_OTAT_TM_M ) == TSI148_LCSR_OTAT_TM_2eSST) + if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_2eSST) *cycle |= VME_2eSST; - if ((ctl & TSI148_LCSR_OTAT_TM_M ) == TSI148_LCSR_OTAT_TM_2eSSTB) + if ((ctl & TSI148_LCSR_OTAT_TM_M) == TSI148_LCSR_OTAT_TM_2eSSTB) *cycle |= VME_2eSSTB; if (ctl & TSI148_LCSR_OTAT_SUP) @@ -1247,7 +1237,7 @@ int __tsi148_master_get( struct vme_master_resource *image, int *enabled, } -int tsi148_master_get( struct vme_master_resource *image, int *enabled, +int tsi148_master_get(struct vme_master_resource *image, int *enabled, unsigned long long *vme_base, unsigned long long *size, vme_address_t *aspace, vme_cycle_t *cycle, vme_width_t *dwidth) { @@ -1289,7 +1279,7 @@ ssize_t tsi148_master_read(struct vme_master_resource *image, void *buf, vme_err = tsi148_find_error(tsi148_bridge, aspace, vme_base + offset, count); - if(vme_err != NULL) { + if (vme_err != NULL) { dev_err(image->parent->parent, "First VME read error detected " "an at address 0x%llx\n", vme_err->address); retval = vme_err->address - (vme_base + offset); @@ -1352,9 +1342,9 @@ ssize_t tsi148_master_write(struct vme_master_resource *image, void *buf, vme_err = tsi148_find_error(tsi148_bridge, aspace, vme_base + offset, count); - if(vme_err != NULL) { - printk("First VME write error detected an at address 0x%llx\n", - vme_err->address); + if (vme_err != NULL) { + dev_warn(tsi148_bridge->parent, "First VME write error detected" + " an at address 0x%llx\n", vme_err->address); retval = vme_err->address - (vme_base + offset); /* Clear down save errors in this address range */ tsi148_clear_errors(tsi148_bridge, aspace, vme_base + offset, @@ -1428,8 +1418,8 @@ unsigned int tsi148_master_rmw(struct vme_master_resource *image, return result; } -static int tsi148_dma_set_vme_src_attributes (u32 *attr, vme_address_t aspace, - vme_cycle_t cycle, vme_width_t dwidth) +static int tsi148_dma_set_vme_src_attributes(struct device *dev, u32 *attr, + vme_address_t aspace, vme_cycle_t cycle, vme_width_t dwidth) { /* Setup 2eSST speeds */ switch (cycle & (VME_2eSST160 | VME_2eSST267 | VME_2eSST320)) { @@ -1445,23 +1435,24 @@ static int tsi148_dma_set_vme_src_attributes (u32 *attr, vme_address_t aspace, } /* Setup cycle types */ - if (cycle & VME_SCT) { + if (cycle & VME_SCT) *attr |= TSI148_LCSR_DSAT_TM_SCT; - } - if (cycle & VME_BLT) { + + if (cycle & VME_BLT) *attr |= TSI148_LCSR_DSAT_TM_BLT; - } - if (cycle & VME_MBLT) { + + if (cycle & VME_MBLT) *attr |= TSI148_LCSR_DSAT_TM_MBLT; - } - if (cycle & VME_2eVME) { + + if (cycle & VME_2eVME) *attr |= TSI148_LCSR_DSAT_TM_2eVME; - } - if (cycle & VME_2eSST) { + + if (cycle & VME_2eSST) *attr |= TSI148_LCSR_DSAT_TM_2eSST; - } + if (cycle & VME_2eSSTB) { - printk("Currently not setting Broadcast Select Registers\n"); + dev_err(dev, "Currently not setting Broadcast Select " + "Registers\n"); *attr |= TSI148_LCSR_DSAT_TM_2eSSTB; } @@ -1474,7 +1465,7 @@ static int tsi148_dma_set_vme_src_attributes (u32 *attr, vme_address_t aspace, *attr |= TSI148_LCSR_DSAT_DBW_32; break; default: - printk("Invalid data width\n"); + dev_err(dev, "Invalid data width\n"); return -EINVAL; } @@ -1508,7 +1499,7 @@ static int tsi148_dma_set_vme_src_attributes (u32 *attr, vme_address_t aspace, *attr |= TSI148_LCSR_DSAT_AMODE_USER4; break; default: - printk("Invalid address space\n"); + dev_err(dev, "Invalid address space\n"); return -EINVAL; break; } @@ -1521,8 +1512,8 @@ static int tsi148_dma_set_vme_src_attributes (u32 *attr, vme_address_t aspace, return 0; } -static int tsi148_dma_set_vme_dest_attributes(u32 *attr, vme_address_t aspace, - vme_cycle_t cycle, vme_width_t dwidth) +static int tsi148_dma_set_vme_dest_attributes(struct device *dev, u32 *attr, + vme_address_t aspace, vme_cycle_t cycle, vme_width_t dwidth) { /* Setup 2eSST speeds */ switch (cycle & (VME_2eSST160 | VME_2eSST267 | VME_2eSST320)) { @@ -1538,23 +1529,24 @@ static int tsi148_dma_set_vme_dest_attributes(u32 *attr, vme_address_t aspace, } /* Setup cycle types */ - if (cycle & VME_SCT) { + if (cycle & VME_SCT) *attr |= TSI148_LCSR_DDAT_TM_SCT; - } - if (cycle & VME_BLT) { + + if (cycle & VME_BLT) *attr |= TSI148_LCSR_DDAT_TM_BLT; - } - if (cycle & VME_MBLT) { + + if (cycle & VME_MBLT) *attr |= TSI148_LCSR_DDAT_TM_MBLT; - } - if (cycle & VME_2eVME) { + + if (cycle & VME_2eVME) *attr |= TSI148_LCSR_DDAT_TM_2eVME; - } - if (cycle & VME_2eSST) { + + if (cycle & VME_2eSST) *attr |= TSI148_LCSR_DDAT_TM_2eSST; - } + if (cycle & VME_2eSSTB) { - printk("Currently not setting Broadcast Select Registers\n"); + dev_err(dev, "Currently not setting Broadcast Select " + "Registers\n"); *attr |= TSI148_LCSR_DDAT_TM_2eSSTB; } @@ -1567,7 +1559,7 @@ static int tsi148_dma_set_vme_dest_attributes(u32 *attr, vme_address_t aspace, *attr |= TSI148_LCSR_DDAT_DBW_32; break; default: - printk("Invalid data width\n"); + dev_err(dev, "Invalid data width\n"); return -EINVAL; } @@ -1601,7 +1593,7 @@ static int tsi148_dma_set_vme_dest_attributes(u32 *attr, vme_address_t aspace, *attr |= TSI148_LCSR_DDAT_AMODE_USER4; break; default: - printk("Invalid address space\n"); + dev_err(dev, "Invalid address space\n"); return -EINVAL; break; } @@ -1617,7 +1609,7 @@ static int tsi148_dma_set_vme_dest_attributes(u32 *attr, vme_address_t aspace, /* * Add a link list descriptor to the list */ -int tsi148_dma_list_add (struct vme_dma_list *list, struct vme_dma_attr *src, +int tsi148_dma_list_add(struct vme_dma_list *list, struct vme_dma_attr *src, struct vme_dma_attr *dest, size_t count) { struct tsi148_dma_entry *entry, *prev; @@ -1627,21 +1619,24 @@ int tsi148_dma_list_add (struct vme_dma_list *list, struct vme_dma_attr *src, struct vme_dma_vme *vme_attr; dma_addr_t desc_ptr; int retval = 0; + struct vme_bridge *tsi148_bridge; + + tsi148_bridge = list->parent->parent; /* Descriptor must be aligned on 64-bit boundaries */ - entry = (struct tsi148_dma_entry *)kmalloc( - sizeof(struct tsi148_dma_entry), GFP_KERNEL); + entry = kmalloc(sizeof(struct tsi148_dma_entry), GFP_KERNEL); if (entry == NULL) { - printk("Failed to allocate memory for dma resource " - "structure\n"); + dev_err(tsi148_bridge->parent, "Failed to allocate memory for " + "dma resource structure\n"); retval = -ENOMEM; goto err_mem; } /* Test descriptor alignment */ if ((unsigned long)&(entry->descriptor) & 0x7) { - printk("Descriptor not aligned to 8 byte boundary as " - "required: %p\n", &(entry->descriptor)); + dev_err(tsi148_bridge->parent, "Descriptor not aligned to 8 " + "byte boundary as required: %p\n", + &(entry->descriptor)); retval = -EINVAL; goto err_align; } @@ -1659,13 +1654,13 @@ int tsi148_dma_list_add (struct vme_dma_list *list, struct vme_dma_attr *src, entry->descriptor.dsal = pattern_attr->pattern; entry->descriptor.dsat = TSI148_LCSR_DSAT_TYP_PAT; /* Default behaviour is 32 bit pattern */ - if (pattern_attr->type & VME_DMA_PATTERN_BYTE) { + if (pattern_attr->type & VME_DMA_PATTERN_BYTE) entry->descriptor.dsat |= TSI148_LCSR_DSAT_PSZ; - } + /* It seems that the default behaviour is to increment */ - if ((pattern_attr->type & VME_DMA_PATTERN_INCREMENT) == 0) { + if ((pattern_attr->type & VME_DMA_PATTERN_INCREMENT) == 0) entry->descriptor.dsat |= TSI148_LCSR_DSAT_NIN; - } + break; case VME_DMA_PCI: pci_attr = (struct vme_dma_pci *)src->private; @@ -1686,13 +1681,13 @@ int tsi148_dma_list_add (struct vme_dma_list *list, struct vme_dma_attr *src, entry->descriptor.dsat = TSI148_LCSR_DSAT_TYP_VME; retval = tsi148_dma_set_vme_src_attributes( - &(entry->descriptor.dsat), vme_attr->aspace, - vme_attr->cycle, vme_attr->dwidth); - if(retval < 0 ) + tsi148_bridge->parent, &(entry->descriptor.dsat), + vme_attr->aspace, vme_attr->cycle, vme_attr->dwidth); + if (retval < 0) goto err_source; break; default: - printk("Invalid source type\n"); + dev_err(tsi148_bridge->parent, "Invalid source type\n"); retval = -EINVAL; goto err_source; break; @@ -1724,13 +1719,13 @@ int tsi148_dma_list_add (struct vme_dma_list *list, struct vme_dma_attr *src, entry->descriptor.ddat = TSI148_LCSR_DDAT_TYP_VME; retval = tsi148_dma_set_vme_dest_attributes( - &(entry->descriptor.ddat), vme_attr->aspace, - vme_attr->cycle, vme_attr->dwidth); - if(retval < 0 ) + tsi148_bridge->parent, &(entry->descriptor.ddat), + vme_attr->aspace, vme_attr->cycle, vme_attr->dwidth); + if (retval < 0) goto err_dest; break; default: - printk("Invalid destination type\n"); + dev_err(tsi148_bridge->parent, "Invalid destination type\n"); retval = -EINVAL; goto err_dest; break; @@ -1743,7 +1738,7 @@ int tsi148_dma_list_add (struct vme_dma_list *list, struct vme_dma_attr *src, list_add_tail(&(entry->list), &(list->entries)); /* Fill out previous descriptors "Next Address" */ - if(entry->list.prev != &(list->entries)){ + if (entry->list.prev != &(list->entries)) { prev = list_entry(entry->list.prev, struct tsi148_dma_entry, list); /* We need the bus address for the pointer */ @@ -1795,17 +1790,20 @@ int tsi148_dma_list_exec(struct vme_dma_list *list) dma_addr_t bus_addr; u32 bus_addr_high, bus_addr_low; u32 val, dctlreg = 0; + struct vme_bridge *tsi148_bridge; struct tsi148_driver *bridge; ctrlr = list->parent; - bridge = ctrlr->parent->driver_priv; + tsi148_bridge = ctrlr->parent; + + bridge = tsi148_bridge->driver_priv; mutex_lock(&(ctrlr->mtx)); channel = ctrlr->number; - if (! list_empty(&(ctrlr->running))) { + if (!list_empty(&(ctrlr->running))) { /* * XXX We have an active DMA transfer and currently haven't * sorted out the mechanism for "pending" DMA transfers. @@ -1847,7 +1845,7 @@ int tsi148_dma_list_exec(struct vme_dma_list *list) TSI148_LCSR_OFFSET_DSTA); if (val & TSI148_LCSR_DSTA_VBE) { - printk(KERN_ERR "tsi148: DMA Error. DSTA=%08X\n", val); + dev_err(tsi148_bridge->parent, "DMA Error. DSTA=%08X\n", val); retval = -EIO; } @@ -1867,7 +1865,7 @@ int tsi148_dma_list_exec(struct vme_dma_list *list) int tsi148_dma_list_empty(struct vme_dma_list *list) { struct list_head *pos, *temp; - struct tsi148_dma_entry *entry; + struct tsi148_dma_entry *entry; /* detach and free each entry */ list_for_each_safe(pos, temp, &(list->entries)) { @@ -1876,7 +1874,7 @@ int tsi148_dma_list_empty(struct vme_dma_list *list) kfree(entry); } - return (0); + return 0; } /* @@ -1891,9 +1889,12 @@ int tsi148_lm_set(struct vme_lm_resource *lm, unsigned long long lm_base, { u32 lm_base_high, lm_base_low, lm_ctl = 0; int i; + struct vme_bridge *tsi148_bridge; struct tsi148_driver *bridge; - bridge = lm->parent->driver_priv; + tsi148_bridge = lm->parent; + + bridge = tsi148_bridge->driver_priv; mutex_lock(&(lm->mtx)); @@ -1901,8 +1902,8 @@ int tsi148_lm_set(struct vme_lm_resource *lm, unsigned long long lm_base, for (i = 0; i < lm->monitors; i++) { if (bridge->lm_callback[i] != NULL) { mutex_unlock(&(lm->mtx)); - printk("Location monitor callback attached, can't " - "reset\n"); + dev_err(tsi148_bridge->parent, "Location monitor " + "callback attached, can't reset\n"); return -EBUSY; } } @@ -1922,7 +1923,7 @@ int tsi148_lm_set(struct vme_lm_resource *lm, unsigned long long lm_base, break; default: mutex_unlock(&(lm->mtx)); - printk("Invalid address space\n"); + dev_err(tsi148_bridge->parent, "Invalid address space\n"); return -EINVAL; break; } @@ -1969,18 +1970,18 @@ int tsi148_lm_get(struct vme_lm_resource *lm, unsigned long long *lm_base, if (lm_ctl & TSI148_LCSR_LMAT_EN) enabled = 1; - if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A16) { + if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A16) *aspace |= VME_A16; - } - if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A24) { + + if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A24) *aspace |= VME_A24; - } - if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A32) { + + if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A32) *aspace |= VME_A32; - } - if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A64) { + + if ((lm_ctl & TSI148_LCSR_LMAT_AS_M) == TSI148_LCSR_LMAT_AS_A64) *aspace |= VME_A64; - } + if (lm_ctl & TSI148_LCSR_LMAT_SUPR) *cycle |= VME_SUPER; @@ -2005,9 +2006,12 @@ int tsi148_lm_attach(struct vme_lm_resource *lm, int monitor, void (*callback)(int)) { u32 lm_ctl, tmp; + struct vme_bridge *tsi148_bridge; struct tsi148_driver *bridge; - bridge = lm->parent->driver_priv; + tsi148_bridge = lm->parent; + + bridge = tsi148_bridge->driver_priv; mutex_lock(&(lm->mtx)); @@ -2015,14 +2019,15 @@ int tsi148_lm_attach(struct vme_lm_resource *lm, int monitor, lm_ctl = ioread32be(bridge->base + TSI148_LCSR_LMAT); if ((lm_ctl & (TSI148_LCSR_LMAT_PGM | TSI148_LCSR_LMAT_DATA)) == 0) { mutex_unlock(&(lm->mtx)); - printk("Location monitor not properly configured\n"); + dev_err(tsi148_bridge->parent, "Location monitor not properly " + "configured\n"); return -EINVAL; } /* Check that a callback isn't already attached */ if (bridge->lm_callback[monitor] != NULL) { mutex_unlock(&(lm->mtx)); - printk("Existing callback attached\n"); + dev_err(tsi148_bridge->parent, "Existing callback attached\n"); return -EBUSY; } @@ -2094,7 +2099,7 @@ int tsi148_lm_detach(struct vme_lm_resource *lm, int monitor) */ int tsi148_slot_get(struct vme_bridge *tsi148_bridge) { - u32 slot = 0; + u32 slot = 0; struct tsi148_driver *bridge; bridge = tsi148_bridge->driver_priv; @@ -2139,8 +2144,8 @@ static int tsi148_crcsr_init(struct vme_bridge *tsi148_bridge, bridge->crcsr_kernel = pci_alloc_consistent(pdev, VME_CRCSR_BUF_SIZE, &(bridge->crcsr_bus)); if (bridge->crcsr_kernel == NULL) { - dev_err(&pdev->dev, "Failed to allocate memory for CR/CSR " - "image\n"); + dev_err(tsi148_bridge->parent, "Failed to allocate memory for " + "CR/CSR image\n"); return -ENOMEM; } @@ -2159,29 +2164,30 @@ static int tsi148_crcsr_init(struct vme_bridge *tsi148_bridge, if (cbar != vstat) { cbar = vstat; - dev_info(&pdev->dev, "Setting CR/CSR offset\n"); + dev_info(tsi148_bridge->parent, "Setting CR/CSR offset\n"); iowrite32be(cbar<<3, bridge->base + TSI148_CBAR); } - dev_info(&pdev->dev, "CR/CSR Offset: %d\n", cbar); + dev_info(tsi148_bridge->parent, "CR/CSR Offset: %d\n", cbar); crat = ioread32be(bridge->base + TSI148_LCSR_CRAT); if (crat & TSI148_LCSR_CRAT_EN) { - dev_info(&pdev->dev, "Enabling CR/CSR space\n"); + dev_info(tsi148_bridge->parent, "Enabling CR/CSR space\n"); iowrite32be(crat | TSI148_LCSR_CRAT_EN, bridge->base + TSI148_LCSR_CRAT); } else - dev_info(&pdev->dev, "CR/CSR already enabled\n"); + dev_info(tsi148_bridge->parent, "CR/CSR already enabled\n"); /* If we want flushed, error-checked writes, set up a window * over the CR/CSR registers. We read from here to safely flush * through VME writes. */ - if(err_chk) { + if (err_chk) { retval = tsi148_master_set(bridge->flush_image, 1, (vstat * 0x80000), 0x80000, VME_CRCSR, VME_SCT, VME_D16); if (retval) - dev_err(&pdev->dev, "Configuring flush image failed\n"); + dev_err(tsi148_bridge->parent, "Configuring flush image" + " failed\n"); } return 0; @@ -2224,8 +2230,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) /* If we want to support more than one of each bridge, we need to * dynamically generate this so we get one per device */ - tsi148_bridge = (struct vme_bridge *)kmalloc(sizeof(struct vme_bridge), - GFP_KERNEL); + tsi148_bridge = kmalloc(sizeof(struct vme_bridge), GFP_KERNEL); if (tsi148_bridge == NULL) { dev_err(&pdev->dev, "Failed to allocate memory for device " "structure\n"); @@ -2301,7 +2306,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) * hence have one less master window resource available. */ master_num = TSI148_MAX_MASTER; - if(err_chk){ + if (err_chk) { master_num--; tsi148_device->flush_image = (struct vme_master_resource *) @@ -2331,8 +2336,8 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) /* Add master windows to list */ INIT_LIST_HEAD(&(tsi148_bridge->master_resources)); for (i = 0; i < master_num; i++) { - master_image = (struct vme_master_resource *)kmalloc( - sizeof(struct vme_master_resource), GFP_KERNEL); + master_image = kmalloc(sizeof(struct vme_master_resource), + GFP_KERNEL); if (master_image == NULL) { dev_err(&pdev->dev, "Failed to allocate memory for " "master resource structure\n"); @@ -2360,8 +2365,8 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) /* Add slave windows to list */ INIT_LIST_HEAD(&(tsi148_bridge->slave_resources)); for (i = 0; i < TSI148_MAX_SLAVE; i++) { - slave_image = (struct vme_slave_resource *)kmalloc( - sizeof(struct vme_slave_resource), GFP_KERNEL); + slave_image = kmalloc(sizeof(struct vme_slave_resource), + GFP_KERNEL); if (slave_image == NULL) { dev_err(&pdev->dev, "Failed to allocate memory for " "slave resource structure\n"); @@ -2386,8 +2391,8 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) /* Add dma engines to list */ INIT_LIST_HEAD(&(tsi148_bridge->dma_resources)); for (i = 0; i < TSI148_MAX_DMA; i++) { - dma_ctrlr = (struct vme_dma_resource *)kmalloc( - sizeof(struct vme_dma_resource), GFP_KERNEL); + dma_ctrlr = kmalloc(sizeof(struct vme_dma_resource), + GFP_KERNEL); if (dma_ctrlr == NULL) { dev_err(&pdev->dev, "Failed to allocate memory for " "dma resource structure\n"); @@ -2444,7 +2449,7 @@ static int tsi148_probe(struct pci_dev *pdev, const struct pci_device_id *id) data = ioread32be(tsi148_device->base + TSI148_LCSR_VSTAT); dev_info(&pdev->dev, "Board is%s the VME system controller\n", - (data & TSI148_LCSR_VSTAT_SCONS)? "" : " not"); + (data & TSI148_LCSR_VSTAT_SCONS) ? "" : " not"); if (!geoid) dev_info(&pdev->dev, "VME geographical address is %d\n", data & TSI148_LCSR_VSTAT_GA_M); @@ -2504,7 +2509,8 @@ err_slave: err_master: /* resources are stored in link list */ list_for_each(pos, &(tsi148_bridge->master_resources)) { - master_image = list_entry(pos, struct vme_master_resource, list); + master_image = list_entry(pos, struct vme_master_resource, + list); list_del(pos); kfree(master_image); } @@ -2624,8 +2630,6 @@ static void tsi148_remove(struct pci_dev *pdev) static void __exit tsi148_exit(void) { pci_unregister_driver(&tsi148_driver); - - printk(KERN_DEBUG "Driver removed.\n"); } MODULE_PARM_DESC(err_chk, "Check for VME errors on reads and writes"); diff --git a/drivers/staging/vme/bridges/vme_tsi148.h b/drivers/staging/vme/bridges/vme_tsi148.h index 9e5f7fa1d744..bda64ef85754 100644 --- a/drivers/staging/vme/bridges/vme_tsi148.h +++ b/drivers/staging/vme/bridges/vme_tsi148.h @@ -579,7 +579,7 @@ static const int TSI148_GCSR_MBOX[4] = { TSI148_GCSR_MBOX0, /* * Memory Base Address Lower Reg (CRG + $010) */ -#define TSI148_PCFS_MBARL_BASEL_M (0xFFFFF<<12) /* Base Addr Lower Mask */ +#define TSI148_PCFS_MBARL_BASEL_M (0xFFFFF<<12) /* Base Addr Lower Mask */ #define TSI148_PCFS_MBARL_PRE (1<<3) /* Prefetch */ #define TSI148_PCFS_MBARL_MTYPE_M (3<<1) /* Memory Type Mask */ #define TSI148_PCFS_MBARL_IOMEM (1<<0) /* I/O Space Indicator */ @@ -615,7 +615,8 @@ static const int TSI148_GCSR_MBOX[4] = { TSI148_GCSR_MBOX0, */ #define TSI148_PCFS_PCIXSTAT_RSCEM (1<<29) /* Recieved Split Comp Error */ #define TSI148_PCFS_PCIXSTAT_DMCRS_M (7<<26) /* max Cumulative Read Size */ -#define TSI148_PCFS_PCIXSTAT_DMOST_M (7<<23) /* max outstanding Split Trans */ +#define TSI148_PCFS_PCIXSTAT_DMOST_M (7<<23) /* max outstanding Split Trans + */ #define TSI148_PCFS_PCIXSTAT_DMMRC_M (3<<21) /* max mem read byte count */ #define TSI148_PCFS_PCIXSTAT_DC (1<<20) /* Device Complexity */ #define TSI148_PCFS_PCIXSTAT_USC (1<<19) /* Unexpected Split comp */ @@ -703,7 +704,8 @@ static const int TSI148_GCSR_MBOX[4] = { TSI148_GCSR_MBOX0, #define TSI148_LCSR_VMCTRL_RMWEN (1<<20) /* RMW Enable */ -#define TSI148_LCSR_VMCTRL_ATO_M (7<<16) /* Master Access Time-out Mask */ +#define TSI148_LCSR_VMCTRL_ATO_M (7<<16) /* Master Access Time-out Mask + */ #define TSI148_LCSR_VMCTRL_ATO_32 (0<<16) /* 32 us */ #define TSI148_LCSR_VMCTRL_ATO_128 (1<<16) /* 128 us */ #define TSI148_LCSR_VMCTRL_ATO_512 (2<<16) /* 512 us */ @@ -733,14 +735,16 @@ static const int TSI148_GCSR_MBOX[4] = { TSI148_GCSR_MBOX0, #define TSI148_LCSR_VMCTRL_VTON_256 (6<<8) /* 256us */ #define TSI148_LCSR_VMCTRL_VTON_512 (7<<8) /* 512us */ -#define TSI148_LCSR_VMCTRL_VREL_M (3<<3) /* VMEbus Master Rel Mode Mask */ +#define TSI148_LCSR_VMCTRL_VREL_M (3<<3) /* VMEbus Master Rel Mode Mask + */ #define TSI148_LCSR_VMCTRL_VREL_T_D (0<<3) /* Time on or Done */ #define TSI148_LCSR_VMCTRL_VREL_T_R_D (1<<3) /* Time on and REQ or Done */ #define TSI148_LCSR_VMCTRL_VREL_T_B_D (2<<3) /* Time on and BCLR or Done */ #define TSI148_LCSR_VMCTRL_VREL_T_D_R (3<<3) /* Time on or Done and REQ */ #define TSI148_LCSR_VMCTRL_VFAIR (1<<2) /* VMEbus Master Fair Mode */ -#define TSI148_LCSR_VMCTRL_VREQL_M (3<<0) /* VMEbus Master Req Level Mask */ +#define TSI148_LCSR_VMCTRL_VREQL_M (3<<0) /* VMEbus Master Req Level Mask + */ /* * VMEbus Control Register CRG+$238 @@ -762,7 +766,8 @@ static const int TSI148_GCSR_MBOX[4] = { TSI148_GCSR_MBOX0, #define TSI148_LCSR_VCTRL_DLT_16384 (0xB<<24) /* 16384 VCLKS */ #define TSI148_LCSR_VCTRL_DLT_32768 (0xC<<24) /* 32768 VCLKS */ -#define TSI148_LCSR_VCTRL_NERBB (1<<20) /* No Early Release of Bus Busy */ +#define TSI148_LCSR_VCTRL_NERBB (1<<20) /* No Early Release of Bus Busy + */ #define TSI148_LCSR_VCTRL_SRESET (1<<17) /* System Reset */ #define TSI148_LCSR_VCTRL_LRESET (1<<16) /* Local Reset */ @@ -773,7 +778,8 @@ static const int TSI148_GCSR_MBOX[4] = { TSI148_GCSR_MBOX0, #define TSI148_LCSR_VCTRL_ATOEN (1<<7) /* Arbiter Time-out Enable */ #define TSI148_LCSR_VCTRL_ROBIN (1<<6) /* VMEbus Round Robin */ -#define TSI148_LCSR_VCTRL_GTO_M (7<<0) /* VMEbus Global Time-out Mask */ +#define TSI148_LCSR_VCTRL_GTO_M (7<<0) /* VMEbus Global Time-out Mask + */ #define TSI148_LCSR_VCTRL_GTO_8 (0<<0) /* 8 us */ #define TSI148_LCSR_VCTRL_GTO_16 (1<<0) /* 16 us */ #define TSI148_LCSR_VCTRL_GTO_32 (2<<0) /* 32 us */ @@ -794,7 +800,7 @@ static const int TSI148_GCSR_MBOX[4] = { TSI148_GCSR_MBOX0, #define TSI148_LCSR_VSTAT_ACFAILS (1<<9) /* AC fail status */ #define TSI148_LCSR_VSTAT_SCONS (1<<8) /* System Cont Status */ #define TSI148_LCSR_VSTAT_GAP (1<<5) /* Geographic Addr Parity */ -#define TSI148_LCSR_VSTAT_GA_M (0x1F<<0) /* Geographic Addr Mask */ +#define TSI148_LCSR_VSTAT_GA_M (0x1F<<0) /* Geographic Addr Mask */ /* * PCI Configuration Status Register CRG+$240 @@ -1341,7 +1347,7 @@ static const int TSI148_LCSR_INTC_MBC[4] = { TSI148_LCSR_INTC_MB0C, * DMA Next Link Address Lower */ #define TSI148_LCSR_DNLAL_DNLAL_M (0x3FFFFFF<<6) /* Address Mask */ -#define TSI148_LCSR_DNLAL_LLA (1<<0) /* Last Link Address Indicator */ +#define TSI148_LCSR_DNLAL_LLA (1<<0) /* Last Link Address Indicator */ /* * DMA 2eSST Broadcast Select @@ -1371,7 +1377,7 @@ static const int TSI148_LCSR_INTC_MBC[4] = { TSI148_LCSR_INTC_MB0C, #define TSI148_GCSR_GCTRL_MBI0S (1<<0) /* Mail box 0 Int Status */ #define TSI148_GCSR_GAP (1<<5) /* Geographic Addr Parity */ -#define TSI148_GCSR_GA_M (0x1F<<0) /* Geographic Address Mask */ +#define TSI148_GCSR_GA_M (0x1F<<0) /* Geographic Address Mask */ /* * CR/CSR Register Group diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index 1ab9a985dfb9..bc16fc070fd3 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -31,6 +31,7 @@ #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/syscalls.h> +#include <linux/smp_lock.h> #include <linux/types.h> #include <asm/io.h> @@ -130,8 +131,7 @@ static int vme_user_release(struct inode *, struct file *); static ssize_t vme_user_read(struct file *, char *, size_t, loff_t *); static ssize_t vme_user_write(struct file *, const char *, size_t, loff_t *); static loff_t vme_user_llseek(struct file *, loff_t, int); -static int vme_user_ioctl(struct inode *, struct file *, unsigned int, - unsigned long); +static long vme_user_unlocked_ioctl(struct file *, unsigned int, unsigned long); static int __init vme_user_probe(struct device *, int, int); static int __exit vme_user_remove(struct device *, int, int); @@ -142,7 +142,7 @@ static struct file_operations vme_user_fops = { .read = vme_user_read, .write = vme_user_write, .llseek = vme_user_llseek, - .ioctl = vme_user_ioctl, + .unlocked_ioctl = vme_user_unlocked_ioctl, }; @@ -555,6 +555,18 @@ static int vme_user_ioctl(struct inode *inode, struct file *file, return -EINVAL; } +static long +vme_user_unlocked_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + int ret; + + lock_kernel(); + ret = vme_user_ioctl(file->f_path.dentry->d_inode, file, cmd, arg); + unlock_kernel(); + + return ret; +} + /* * Unallocate a previously allocated buffer diff --git a/drivers/staging/vme/vme.c b/drivers/staging/vme/vme.c index 934283a19ca5..093fbffbf557 100644 --- a/drivers/staging/vme/vme.c +++ b/drivers/staging/vme/vme.c @@ -36,7 +36,7 @@ /* Bitmask and mutex to keep track of bridge numbers */ static unsigned int vme_bus_numbers; -DEFINE_MUTEX(vme_bus_num_mtx); +static DEFINE_MUTEX(vme_bus_num_mtx); static void __exit vme_exit(void); static int __init vme_init(void); @@ -1408,7 +1408,7 @@ EXPORT_SYMBOL(vme_unregister_driver); /* - Bus Registration ------------------------------------------------------ */ -int vme_calc_slot(struct device *dev) +static int vme_calc_slot(struct device *dev) { struct vme_bridge *bridge; int num; diff --git a/drivers/staging/vt6655/80211hdr.h b/drivers/staging/vt6655/80211hdr.h index e5cee6fd0533..b7b170e19aa2 100644 --- a/drivers/staging/vt6655/80211hdr.h +++ b/drivers/staging/vt6655/80211hdr.h @@ -34,7 +34,7 @@ #include "ttype.h" /*--------------------- Export Definitions -------------------------*/ -// bit type +/* bit type */ #define BIT0 0x00000001 #define BIT1 0x00000002 #define BIT2 0x00000004 @@ -80,7 +80,7 @@ #define WLAN_HDR_ADDR4_LEN 30 #define WLAN_IEHDR_LEN 2 #define WLAN_SSID_MAXLEN 32 -//#define WLAN_RATES_MAXLEN 255 +/*#define WLAN_RATES_MAXLEN 255*/ #define WLAN_RATES_MAXLEN 16 #define WLAN_RATES_MAXLEN_11B 4 #define WLAN_RSN_MAXLEN 32 @@ -106,7 +106,7 @@ #define WLAN_WEP40_KEYLEN 5 #define WLAN_WEP104_KEYLEN 13 #define WLAN_WEP232_KEYLEN 29 -//#define WLAN_WEPMAX_KEYLEN 29 +/*#define WLAN_WEPMAX_KEYLEN 29*/ #define WLAN_WEPMAX_KEYLEN 32 #define WLAN_CHALLENGE_IE_MAXLEN 255 #define WLAN_CHALLENGE_IE_LEN 130 @@ -115,7 +115,7 @@ #define WLAN_WEP_ICV_LEN 4 #define WLAN_FRAGS_MAX 16 -// Frame Type +/* Frame Type */ #define WLAN_TYPE_MGR 0x00 #define WLAN_TYPE_CTL 0x01 #define WLAN_TYPE_DATA 0x02 @@ -125,7 +125,7 @@ #define WLAN_FTYPE_DATA 0x02 -// Frame Subtypes +/* Frame Subtypes */ #define WLAN_FSTYPE_ASSOCREQ 0x00 #define WLAN_FSTYPE_ASSOCRESP 0x01 #define WLAN_FSTYPE_REASSOCREQ 0x02 @@ -139,7 +139,7 @@ #define WLAN_FSTYPE_DEAUTHEN 0x0c #define WLAN_FSTYPE_ACTION 0x0d -// Control +/* Control */ #define WLAN_FSTYPE_PSPOLL 0x0a #define WLAN_FSTYPE_RTS 0x0b #define WLAN_FSTYPE_CTS 0x0c @@ -147,7 +147,7 @@ #define WLAN_FSTYPE_CFEND 0x0e #define WLAN_FSTYPE_CFENDCFACK 0x0f -// Data +/* Data */ #define WLAN_FSTYPE_DATAONLY 0x00 #define WLAN_FSTYPE_DATA_CFACK 0x01 #define WLAN_FSTYPE_DATA_CFPOLL 0x02 @@ -160,7 +160,7 @@ #ifdef __BIG_ENDIAN -// GET & SET Frame Control bit +/* GET & SET Frame Control bit */ #define WLAN_GET_FC_PRVER(n) ((((WORD)(n) >> 8) & (BIT0 | BIT1)) #define WLAN_GET_FC_FTYPE(n) ((((WORD)(n) >> 8) & (BIT2 | BIT3)) >> 2) #define WLAN_GET_FC_FSTYPE(n) ((((WORD)(n) >> 8) & (BIT4|BIT5|BIT6|BIT7)) >> 4) @@ -173,12 +173,12 @@ #define WLAN_GET_FC_ISWEP(n) ((((WORD)(n) << 8) & (BIT14)) >> 14) #define WLAN_GET_FC_ORDER(n) ((((WORD)(n) << 8) & (BIT15)) >> 15) -// Sequence Field bit +/* Sequence Field bit */ #define WLAN_GET_SEQ_FRGNUM(n) (((WORD)(n) >> 8) & (BIT0|BIT1|BIT2|BIT3)) #define WLAN_GET_SEQ_SEQNUM(n) ((((WORD)(n) >> 8) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4) -// Capability Field bit +/* Capability Field bit */ #define WLAN_GET_CAP_INFO_ESS(n) (((n) >> 8) & BIT0) #define WLAN_GET_CAP_INFO_IBSS(n) ((((n) >> 8) & BIT1) >> 1) #define WLAN_GET_CAP_INFO_CFPOLLABLE(n) ((((n) >> 8) & BIT2) >> 2) @@ -195,7 +195,7 @@ #else -// GET & SET Frame Control bit +/* GET & SET Frame Control bit */ #define WLAN_GET_FC_PRVER(n) (((WORD)(n)) & (BIT0 | BIT1)) #define WLAN_GET_FC_FTYPE(n) ((((WORD)(n)) & (BIT2 | BIT3)) >> 2) #define WLAN_GET_FC_FSTYPE(n) ((((WORD)(n)) & (BIT4|BIT5|BIT6|BIT7)) >> 4) @@ -209,12 +209,12 @@ #define WLAN_GET_FC_ORDER(n) ((((WORD)(n)) & (BIT15)) >> 15) -// Sequence Field bit +/* Sequence Field bit */ #define WLAN_GET_SEQ_FRGNUM(n) (((WORD)(n)) & (BIT0|BIT1|BIT2|BIT3)) #define WLAN_GET_SEQ_SEQNUM(n) ((((WORD)(n)) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4) -// Capability Field bit +/* Capability Field bit */ #define WLAN_GET_CAP_INFO_ESS(n) ((n) & BIT0) #define WLAN_GET_CAP_INFO_IBSS(n) (((n) & BIT1) >> 1) #define WLAN_GET_CAP_INFO_CFPOLLABLE(n) (((n) & BIT2) >> 2) @@ -229,7 +229,7 @@ #define WLAN_GET_CAP_INFO_GRPACK(n) (((n) & BIT14) >> 14) -#endif //#ifdef __BIG_ENDIAN +#endif /*#ifdef __BIG_ENDIAN */ #define WLAN_SET_CAP_INFO_ESS(n) (n) @@ -261,7 +261,7 @@ #define WLAN_SET_SEQ_FRGNUM(n) ((WORD)(n)) #define WLAN_SET_SEQ_SEQNUM(n) (((WORD)(n)) << 4) -// ERP Field bit +/* ERP Field bit */ #define WLAN_GET_ERP_NONERP_PRESENT(n) ((n) & BIT0) #define WLAN_GET_ERP_USE_PROTECTION(n) (((n) & BIT1) >> 1) @@ -273,19 +273,19 @@ -// Support & Basic Rates field +/* Support & Basic Rates field */ #define WLAN_MGMT_IS_BASICRATE(b) ((b) & BIT7) #define WLAN_MGMT_GET_RATE(b) ((b) & ~BIT7) -// TIM field +/* TIM field */ #define WLAN_MGMT_IS_MULTICAST_TIM(b) ((b) & BIT0) #define WLAN_MGMT_GET_TIM_OFFSET(b) (((b) & ~BIT0) >> 1) -// 3-Addr & 4-Addr +/* 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) -// IEEE ADDR +/* IEEE ADDR */ #define IEEE_ADDR_UNIVERSAL 0x02 #define IEEE_ADDR_GROUP 0x01 @@ -293,7 +293,7 @@ typedef struct { BYTE abyAddr[6]; } IEEE_ADDR, *PIEEE_ADDR; -// 802.11 Header Format +/* 802.11 Header Format */ typedef struct tagWLAN_80211HDR_A2 { @@ -302,7 +302,7 @@ typedef struct tagWLAN_80211HDR_A2 { BYTE abyAddr1[WLAN_ADDR_LEN]; BYTE abyAddr2[WLAN_ADDR_LEN]; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) WLAN_80211HDR_A2, *PWLAN_80211HDR_A2; typedef struct tagWLAN_80211HDR_A3 { @@ -327,7 +327,7 @@ typedef struct tagWLAN_80211HDR_A4 { WORD wSeqCtl; BYTE abyAddr4[WLAN_ADDR_LEN]; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) WLAN_80211HDR_A4, *PWLAN_80211HDR_A4; @@ -348,6 +348,6 @@ typedef union tagUWLAN_80211HDR { -#endif // __80211HDR_H__ +#endif /* __80211HDR_H__ */ diff --git a/drivers/staging/vt6655/desc.h b/drivers/staging/vt6655/desc.h index b573ef77abe1..0e119492d717 100644 --- a/drivers/staging/vt6655/desc.h +++ b/drivers/staging/vt6655/desc.h @@ -232,7 +232,8 @@ typedef struct tagDEVICE_RD_INFO { /* static inline PDEVICE_RD_INFO alloc_rd_info(void) { PDEVICE_RD_INFO ptr; - if ((ptr = kmalloc(sizeof(DEVICE_RD_INFO), GFP_ATOMIC)) == NULL) + ptr = kmalloc(sizeof(DEVICE_RD_INFO), GFP_ATOMIC); + if (ptr == NULL) return NULL; else { memset(ptr,0,sizeof(DEVICE_RD_INFO)); @@ -361,7 +362,8 @@ typedef struct tagDEVICE_TD_INFO{ /* static inline PDEVICE_TD_INFO alloc_td_info(void) { PDEVICE_TD_INFO ptr; - if ((ptr = kmalloc(sizeof(DEVICE_TD_INFO),GFP_ATOMIC))==NULL) + ptr = kmalloc(sizeof(DEVICE_TD_INFO),GFP_ATOMIC); + if (ptr == NULL) return NULL; else { memset(ptr,0,sizeof(DEVICE_TD_INFO)); diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index cde44d21b75c..7a9f40695f2d 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -898,7 +898,8 @@ inline static BOOL device_get_ip(PSDevice pInfo) { static inline PDEVICE_RD_INFO alloc_rd_info(void) { PDEVICE_RD_INFO ptr; - if ((ptr = (PDEVICE_RD_INFO)kmalloc((int)sizeof(DEVICE_RD_INFO), (int)GFP_ATOMIC)) == NULL) + ptr = (PDEVICE_RD_INFO)kmalloc((int)sizeof(DEVICE_RD_INFO), (int)GFP_ATOMIC); + if (ptr == NULL) return NULL; else { memset(ptr,0,sizeof(DEVICE_RD_INFO)); @@ -908,7 +909,8 @@ static inline PDEVICE_RD_INFO alloc_rd_info(void) { static inline PDEVICE_TD_INFO alloc_td_info(void) { PDEVICE_TD_INFO ptr; - if ((ptr = (PDEVICE_TD_INFO)kmalloc((int)sizeof(DEVICE_TD_INFO), (int)GFP_ATOMIC))==NULL) + ptr = (PDEVICE_TD_INFO)kmalloc((int)sizeof(DEVICE_TD_INFO), (int)GFP_ATOMIC); + if (ptr == NULL) return NULL; else { memset(ptr,0,sizeof(DEVICE_TD_INFO)); diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 18f4dfed997f..b1b535051ae5 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -638,7 +638,8 @@ byValue1 = SROMbyReadEmbedded(pDevice->PortOffset, EEP_OFS_ANTENNA); //2008-8-4 <add> by chester //zonetype initial pDevice->byOriginalZonetype = pDevice->abyEEPROM[EEP_OFS_ZONETYPE]; - if((zonetype=Config_FileOperation(pDevice,FALSE,NULL)) >= 0) { //read zonetype file ok! + zonetype = Config_FileOperation(pDevice,FALSE,NULL); + if (zonetype >= 0) { //read zonetype file ok! if ((zonetype == 0)&& (pDevice->abyEEPROM[EEP_OFS_ZONETYPE] !=0x00)){ //for USA pDevice->abyEEPROM[EEP_OFS_ZONETYPE] = 0; @@ -1242,7 +1243,7 @@ device_release_WPADEV(pDevice); } #ifdef HOSTAP if (dev) - hostap_set_hostapd(pDevice, 0, 0); + vt6655_hostap_set_hostapd(pDevice, 0, 0); #endif if (dev) unregister_netdev(dev); @@ -3328,7 +3329,7 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { break; case SIOCSIWTXPOW: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWTXPOW \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWTXPOW \n"); rc = -EOPNOTSUPP; break; @@ -3406,7 +3407,7 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { // Get the spy list case SIOCGIWSPY: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCSIWSPY \n"); + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWSPY \n"); rc = -EOPNOTSUPP; break; @@ -3523,7 +3524,7 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { case IOCTL_CMD_HOSTAPD: - rc = hostap_ioctl(pDevice, &wrq->u.data); + rc = vt6655_hostap_ioctl(pDevice, &wrq->u.data); break; case IOCTL_CMD_WPA: diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c index 58abf44c76a6..9e07a40480fd 100644 --- a/drivers/staging/vt6655/hostap.c +++ b/drivers/staging/vt6655/hostap.c @@ -183,7 +183,7 @@ KeyvInitTable(&pDevice->sKey,pDevice->PortOffset); * */ -int hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked) +int vt6655_hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked) { if (val < 0 || val > 1) return -EINVAL; @@ -746,7 +746,7 @@ static int hostap_get_encryption(PSDevice pDevice, /* * Description: - * hostap_ioctl main function supported for hostap deamon. + * vt6655_hostap_ioctl main function supported for hostap deamon. * * Parameters: * In: @@ -758,7 +758,7 @@ static int hostap_get_encryption(PSDevice pDevice, * */ -int hostap_ioctl(PSDevice pDevice, struct iw_point *p) +int vt6655_hostap_ioctl(PSDevice pDevice, struct iw_point *p) { struct viawget_hostapd_param *param; int ret = 0; @@ -846,7 +846,7 @@ int hostap_ioctl(PSDevice pDevice, struct iw_point *p) return -EOPNOTSUPP; default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "hostap_ioctl: unknown cmd=%d\n", + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "vt6655_hostap_ioctl: unknown cmd=%d\n", (int)param->cmd); return -EOPNOTSUPP; break; diff --git a/drivers/staging/vt6655/hostap.h b/drivers/staging/vt6655/hostap.h index 8fd667b542be..55db55524d96 100644 --- a/drivers/staging/vt6655/hostap.h +++ b/drivers/staging/vt6655/hostap.h @@ -61,8 +61,8 @@ #define ARPHRD_IEEE80211 801 #endif -int hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked); -int hostap_ioctl(PSDevice pDevice, struct iw_point *p); +int vt6655_hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked); +int vt6655_hostap_ioctl(PSDevice pDevice, struct iw_point *p); #endif // __HOSTAP_H__ diff --git a/drivers/staging/vt6655/ioctl.c b/drivers/staging/vt6655/ioctl.c index d9a5fd21ab31..37928e844010 100644 --- a/drivers/staging/vt6655/ioctl.c +++ b/drivers/staging/vt6655/ioctl.c @@ -83,7 +83,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) { pReq->wResult = 0; - switch(pReq->wCmdCode) { + switch (pReq->wCmdCode) { case WLAN_CMD_BSS_SCAN: @@ -429,7 +429,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) { break; }; if (sValue.dwValue == 1) { - if (hostap_set_hostapd(pDevice, 1, 1) == 0){ + if (vt6655_hostap_set_hostapd(pDevice, 1, 1) == 0){ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n"); } else { @@ -438,7 +438,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) { } } else { - hostap_set_hostapd(pDevice, 0, 1); + vt6655_hostap_set_hostapd(pDevice, 0, 1); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n"); } diff --git a/drivers/staging/vt6655/iwctl.c b/drivers/staging/vt6655/iwctl.c index 78b49830a255..7fa5842238b8 100644 --- a/drivers/staging/vt6655/iwctl.c +++ b/drivers/staging/vt6655/iwctl.c @@ -699,7 +699,6 @@ if (pMgmt->eScanState == WMAC_IS_SCANNING) { if (wrq->sa_family != ARPHRD_ETHER) rc = -EINVAL; else { - memset(pMgmt->abyDesireBSSID, 0xFF, 6); memcpy(pMgmt->abyDesireBSSID, wrq->sa_data, 6); //2008-0409-05, <Add> by Einsn Liu if((pDevice->bLinkPass == TRUE) && @@ -889,7 +888,6 @@ if (pMgmt->eScanState == WMAC_IS_SCANNING) { BYTE abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; UINT ii , uSameBssidNum=0; - memset(abyTmpDesireSSID,0,sizeof(abyTmpDesireSSID)); memcpy(abyTmpDesireSSID,pMgmt->abyDesireSSID,sizeof(abyTmpDesireSSID)); pCurr = BSSpSearchBSSList(pDevice, NULL, @@ -1702,7 +1700,8 @@ int iwctl_giwpower(struct net_device *dev, DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO " SIOCGIWPOWER \n"); - if ((wrq->disabled = (mode == WMAC_POWER_CAM))) + wrq->disabled = (mode == WMAC_POWER_CAM); + if (wrq->disabled) return 0; if ((wrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) { diff --git a/drivers/staging/vt6655/srom.c b/drivers/staging/vt6655/srom.c index 5a7c6ca724b3..fb7a6468cab8 100644 --- a/drivers/staging/vt6655/srom.c +++ b/drivers/staging/vt6655/srom.c @@ -85,15 +85,15 @@ BYTE SROMbyReadEmbedded(DWORD_PTR dwIoBase, BYTE byContntOffset) byData = 0xFF; VNSvInPortB(dwIoBase + MAC_REG_I2MCFG, &byOrg); - // turn off hardware retry for getting NACK + /* turn off hardware retry for getting NACK */ VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, (byOrg & (~I2MCFG_NORETRY))); for (wNoACK = 0; wNoACK < W_MAX_I2CRETRY; wNoACK++) { VNSvOutPortB(dwIoBase + MAC_REG_I2MTGID, EEP_I2C_DEV_ID); VNSvOutPortB(dwIoBase + MAC_REG_I2MTGAD, byContntOffset); - // issue read command + /* issue read command */ VNSvOutPortB(dwIoBase + MAC_REG_I2MCSR, I2MCSR_EEMR); - // wait DONE be set + /* wait DONE be set */ for (wDelay = 0; wDelay < W_MAX_TIMEOUT; wDelay++) { VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &byWait); if (byWait & (I2MCSR_DONE | I2MCSR_NACK)) @@ -125,7 +125,7 @@ BYTE SROMbyReadEmbedded(DWORD_PTR dwIoBase, BYTE byContntOffset) * Return Value: TRUE if succeeded; FALSE if failed. * */ -BOOL SROMbWriteEmbedded (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byData) +BOOL SROMbWriteEmbedded(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byData) { WORD wDelay, wNoACK; BYTE byWait; @@ -133,16 +133,16 @@ BOOL SROMbWriteEmbedded (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byData) BYTE byOrg; VNSvInPortB(dwIoBase + MAC_REG_I2MCFG, &byOrg); - // turn off hardware retry for getting NACK + /* turn off hardware retry for getting NACK */ VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, (byOrg & (~I2MCFG_NORETRY))); for (wNoACK = 0; wNoACK < W_MAX_I2CRETRY; wNoACK++) { VNSvOutPortB(dwIoBase + MAC_REG_I2MTGID, EEP_I2C_DEV_ID); VNSvOutPortB(dwIoBase + MAC_REG_I2MTGAD, byContntOffset); VNSvOutPortB(dwIoBase + MAC_REG_I2MDOPT, byData); - // issue write command + /* issue write command */ VNSvOutPortB(dwIoBase + MAC_REG_I2MCSR, I2MCSR_EEMW); - // wait DONE be set + /* wait DONE be set */ for (wDelay = 0; wDelay < W_MAX_TIMEOUT; wDelay++) { VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &byWait); if (byWait & (I2MCSR_DONE | I2MCSR_NACK)) @@ -178,7 +178,7 @@ BOOL SROMbWriteEmbedded (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byData) * Return Value: none * */ -void SROMvRegBitsOn (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byBits) +void SROMvRegBitsOn(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byBits) { BYTE byOrgData; @@ -199,7 +199,7 @@ void SROMvRegBitsOn (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byBits) * none * */ -void SROMvRegBitsOff (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byBits) +void SROMvRegBitsOff(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byBits) { BYTE byOrgData; @@ -222,7 +222,7 @@ void SROMvRegBitsOff (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byBits) * Return Value: TRUE if all test bits on; otherwise FALSE * */ -BOOL SROMbIsRegBitsOn (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byTestBits) +BOOL SROMbIsRegBitsOn(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byTestBits) { BYTE byOrgData; @@ -245,7 +245,7 @@ BOOL SROMbIsRegBitsOn (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byTestBits) * Return Value: TRUE if all test bits off; otherwise FALSE * */ -BOOL SROMbIsRegBitsOff (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byTestBits) +BOOL SROMbIsRegBitsOff(DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byTestBits) { BYTE byOrgData; @@ -266,11 +266,11 @@ BOOL SROMbIsRegBitsOff (DWORD_PTR dwIoBase, BYTE byContntOffset, BYTE byTestBits * Return Value: none * */ -void SROMvReadAllContents (DWORD_PTR dwIoBase, PBYTE pbyEepromRegs) +void SROMvReadAllContents(DWORD_PTR dwIoBase, PBYTE pbyEepromRegs) { int ii; - // ii = Rom Address + /* ii = Rom Address */ for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) { *pbyEepromRegs = SROMbyReadEmbedded(dwIoBase,(BYTE) ii); pbyEepromRegs++; @@ -291,11 +291,11 @@ void SROMvReadAllContents (DWORD_PTR dwIoBase, PBYTE pbyEepromRegs) * Return Value: none * */ -void SROMvWriteAllContents (DWORD_PTR dwIoBase, PBYTE pbyEepromRegs) +void SROMvWriteAllContents(DWORD_PTR dwIoBase, PBYTE pbyEepromRegs) { int ii; - // ii = Rom Address + /* ii = Rom Address */ for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) { SROMbWriteEmbedded(dwIoBase,(BYTE) ii, *pbyEepromRegs); pbyEepromRegs++; @@ -315,11 +315,11 @@ void SROMvWriteAllContents (DWORD_PTR dwIoBase, PBYTE pbyEepromRegs) * Return Value: none * */ -void SROMvReadEtherAddress (DWORD_PTR dwIoBase, PBYTE pbyEtherAddress) +void SROMvReadEtherAddress(DWORD_PTR dwIoBase, PBYTE pbyEtherAddress) { BYTE ii; - // ii = Rom Address + /* ii = Rom Address */ for (ii = 0; ii < U_ETHER_ADDR_LEN; ii++) { *pbyEtherAddress = SROMbyReadEmbedded(dwIoBase, ii); pbyEtherAddress++; @@ -340,11 +340,11 @@ void SROMvReadEtherAddress (DWORD_PTR dwIoBase, PBYTE pbyEtherAddress) * Return Value: none * */ -void SROMvWriteEtherAddress (DWORD_PTR dwIoBase, PBYTE pbyEtherAddress) +void SROMvWriteEtherAddress(DWORD_PTR dwIoBase, PBYTE pbyEtherAddress) { BYTE ii; - // ii = Rom Address + /* ii = Rom Address */ for (ii = 0; ii < U_ETHER_ADDR_LEN; ii++) { SROMbWriteEmbedded(dwIoBase, ii, *pbyEtherAddress); pbyEtherAddress++; @@ -364,15 +364,15 @@ void SROMvWriteEtherAddress (DWORD_PTR dwIoBase, PBYTE pbyEtherAddress) * Return Value: none * */ -void SROMvReadSubSysVenId (DWORD_PTR dwIoBase, PDWORD pdwSubSysVenId) +void SROMvReadSubSysVenId(DWORD_PTR dwIoBase, PDWORD pdwSubSysVenId) { PBYTE pbyData; pbyData = (PBYTE)pdwSubSysVenId; - // sub vendor + /* sub vendor */ *pbyData = SROMbyReadEmbedded(dwIoBase, 6); *(pbyData+1) = SROMbyReadEmbedded(dwIoBase, 7); - // sub system + /* sub system */ *(pbyData+2) = SROMbyReadEmbedded(dwIoBase, 8); *(pbyData+3) = SROMbyReadEmbedded(dwIoBase, 9); } @@ -389,7 +389,7 @@ void SROMvReadSubSysVenId (DWORD_PTR dwIoBase, PDWORD pdwSubSysVenId) * Return Value: TRUE if success; otherwise FALSE * */ -BOOL SROMbAutoLoad (DWORD_PTR dwIoBase) +BOOL SROMbAutoLoad(DWORD_PTR dwIoBase) { BYTE byWait; int ii; @@ -397,12 +397,12 @@ BOOL SROMbAutoLoad (DWORD_PTR dwIoBase) BYTE byOrg; VNSvInPortB(dwIoBase + MAC_REG_I2MCFG, &byOrg); - // turn on hardware retry + /* turn on hardware retry */ VNSvOutPortB(dwIoBase + MAC_REG_I2MCFG, (byOrg | I2MCFG_NORETRY)); MACvRegBitsOn(dwIoBase, MAC_REG_I2MCSR, I2MCSR_AUTOLD); - // ii = Rom Address + /* ii = Rom Address */ for (ii = 0; ii < EEP_MAX_CONTEXT_SIZE; ii++) { MACvTimer0MicroSDelay(dwIoBase, CB_EEPROM_READBYTE_WAIT); VNSvInPortB(dwIoBase + MAC_REG_I2MCSR, &byWait); diff --git a/drivers/staging/vt6656/80211hdr.h b/drivers/staging/vt6656/80211hdr.h index e5cee6fd0533..15c6ef1a635c 100644 --- a/drivers/staging/vt6656/80211hdr.h +++ b/drivers/staging/vt6656/80211hdr.h @@ -16,16 +16,13 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * * File: 80211hdr.h * * Purpose: 802.11 MAC headers related pre-defines and macros. * - * * Author: Lyndon Chen * * Date: Apr 8, 2002 - * */ #ifndef __80211HDR_H__ @@ -34,7 +31,8 @@ #include "ttype.h" /*--------------------- Export Definitions -------------------------*/ -// bit type + +/* bit type */ #define BIT0 0x00000001 #define BIT1 0x00000002 #define BIT2 0x00000004 @@ -68,7 +66,7 @@ #define BIT30 0x40000000 #define BIT31 0x80000000 -// 802.11 frame related, defined as 802.11 spec +/* 802.11 frame related, defined as 802.11 spec */ #define WLAN_ADDR_LEN 6 #define WLAN_CRC_LEN 4 #define WLAN_CRC32_LEN 4 @@ -80,13 +78,14 @@ #define WLAN_HDR_ADDR4_LEN 30 #define WLAN_IEHDR_LEN 2 #define WLAN_SSID_MAXLEN 32 -//#define WLAN_RATES_MAXLEN 255 +/* #define WLAN_RATES_MAXLEN 255 */ #define WLAN_RATES_MAXLEN 16 #define WLAN_RATES_MAXLEN_11B 4 #define WLAN_RSN_MAXLEN 32 #define WLAN_DATA_MAXLEN 2312 -#define WLAN_A3FR_MAXLEN (WLAN_HDR_ADDR3_LEN + WLAN_DATA_MAXLEN + WLAN_CRC_LEN) - +#define WLAN_A3FR_MAXLEN (WLAN_HDR_ADDR3_LEN \ + + WLAN_DATA_MAXLEN \ + + WLAN_CRC_LEN) #define WLAN_BEACON_FR_MAXLEN WLAN_A3FR_MAXLEN #define WLAN_ATIM_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 0) @@ -101,12 +100,11 @@ #define WLAN_AUTHEN_FR_MAXLEN WLAN_A3FR_MAXLEN #define WLAN_DEAUTHEN_FR_MAXLEN (WLAN_HDR_ADDR3_LEN + 2) - #define WLAN_WEP_NKEYS 4 #define WLAN_WEP40_KEYLEN 5 #define WLAN_WEP104_KEYLEN 13 #define WLAN_WEP232_KEYLEN 29 -//#define WLAN_WEPMAX_KEYLEN 29 +/* #define WLAN_WEPMAX_KEYLEN 29 */ #define WLAN_WEPMAX_KEYLEN 32 #define WLAN_CHALLENGE_IE_MAXLEN 255 #define WLAN_CHALLENGE_IE_LEN 130 @@ -115,7 +113,7 @@ #define WLAN_WEP_ICV_LEN 4 #define WLAN_FRAGS_MAX 16 -// Frame Type +/* Frame Type */ #define WLAN_TYPE_MGR 0x00 #define WLAN_TYPE_CTL 0x01 #define WLAN_TYPE_DATA 0x02 @@ -124,8 +122,7 @@ #define WLAN_FTYPE_CTL 0x01 #define WLAN_FTYPE_DATA 0x02 - -// Frame Subtypes +/* Frame Subtypes */ #define WLAN_FSTYPE_ASSOCREQ 0x00 #define WLAN_FSTYPE_ASSOCRESP 0x01 #define WLAN_FSTYPE_REASSOCREQ 0x02 @@ -139,7 +136,7 @@ #define WLAN_FSTYPE_DEAUTHEN 0x0c #define WLAN_FSTYPE_ACTION 0x0d -// Control +/* Control */ #define WLAN_FSTYPE_PSPOLL 0x0a #define WLAN_FSTYPE_RTS 0x0b #define WLAN_FSTYPE_CTS 0x0c @@ -147,7 +144,7 @@ #define WLAN_FSTYPE_CFEND 0x0e #define WLAN_FSTYPE_CFENDCFACK 0x0f -// Data +/* Data */ #define WLAN_FSTYPE_DATAONLY 0x00 #define WLAN_FSTYPE_DATA_CFACK 0x01 #define WLAN_FSTYPE_DATA_CFPOLL 0x02 @@ -157,13 +154,13 @@ #define WLAN_FSTYPE_CFPOLL 0x06 #define WLAN_FSTYPE_CFACK_CFPOLL 0x07 - #ifdef __BIG_ENDIAN -// GET & SET Frame Control bit +/* GET & SET Frame Control bit */ #define WLAN_GET_FC_PRVER(n) ((((WORD)(n) >> 8) & (BIT0 | BIT1)) #define WLAN_GET_FC_FTYPE(n) ((((WORD)(n) >> 8) & (BIT2 | BIT3)) >> 2) -#define WLAN_GET_FC_FSTYPE(n) ((((WORD)(n) >> 8) & (BIT4|BIT5|BIT6|BIT7)) >> 4) +#define WLAN_GET_FC_FSTYPE(n) ((((WORD)(n) >> 8) \ + & (BIT4|BIT5|BIT6|BIT7)) >> 4) #define WLAN_GET_FC_TODS(n) ((((WORD)(n) << 8) & (BIT8)) >> 8) #define WLAN_GET_FC_FROMDS(n) ((((WORD)(n) << 8) & (BIT9)) >> 9) #define WLAN_GET_FC_MOREFRAG(n) ((((WORD)(n) << 8) & (BIT10)) >> 10) @@ -173,12 +170,12 @@ #define WLAN_GET_FC_ISWEP(n) ((((WORD)(n) << 8) & (BIT14)) >> 14) #define WLAN_GET_FC_ORDER(n) ((((WORD)(n) << 8) & (BIT15)) >> 15) -// Sequence Field bit +/* Sequence Field bit */ #define WLAN_GET_SEQ_FRGNUM(n) (((WORD)(n) >> 8) & (BIT0|BIT1|BIT2|BIT3)) -#define WLAN_GET_SEQ_SEQNUM(n) ((((WORD)(n) >> 8) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4) - +#define WLAN_GET_SEQ_SEQNUM(n) ((((WORD)(n) >> 8) \ + & (~(BIT0|BIT1|BIT2|BIT3))) >> 4) -// Capability Field bit +/* Capability Field bit */ #define WLAN_GET_CAP_INFO_ESS(n) (((n) >> 8) & BIT0) #define WLAN_GET_CAP_INFO_IBSS(n) ((((n) >> 8) & BIT1) >> 1) #define WLAN_GET_CAP_INFO_CFPOLLABLE(n) ((((n) >> 8) & BIT2) >> 2) @@ -192,10 +189,9 @@ #define WLAN_GET_CAP_INFO_DSSSOFDM(n) ((((n)) & BIT13) >> 13) #define WLAN_GET_CAP_INFO_GRPACK(n) ((((n)) & BIT14) >> 14) - #else -// GET & SET Frame Control bit +/* GET & SET Frame Control bit */ #define WLAN_GET_FC_PRVER(n) (((WORD)(n)) & (BIT0 | BIT1)) #define WLAN_GET_FC_FTYPE(n) ((((WORD)(n)) & (BIT2 | BIT3)) >> 2) #define WLAN_GET_FC_FSTYPE(n) ((((WORD)(n)) & (BIT4|BIT5|BIT6|BIT7)) >> 4) @@ -208,13 +204,11 @@ #define WLAN_GET_FC_ISWEP(n) ((((WORD)(n)) & (BIT14)) >> 14) #define WLAN_GET_FC_ORDER(n) ((((WORD)(n)) & (BIT15)) >> 15) - -// Sequence Field bit +/* Sequence Field bit */ #define WLAN_GET_SEQ_FRGNUM(n) (((WORD)(n)) & (BIT0|BIT1|BIT2|BIT3)) #define WLAN_GET_SEQ_SEQNUM(n) ((((WORD)(n)) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4) - -// Capability Field bit +/* Capability Field bit */ #define WLAN_GET_CAP_INFO_ESS(n) ((n) & BIT0) #define WLAN_GET_CAP_INFO_IBSS(n) (((n) & BIT1) >> 1) #define WLAN_GET_CAP_INFO_CFPOLLABLE(n) (((n) & BIT2) >> 2) @@ -228,9 +222,7 @@ #define WLAN_GET_CAP_INFO_DSSSOFDM(n) (((n) & BIT13) >> 13) #define WLAN_GET_CAP_INFO_GRPACK(n) (((n) & BIT14) >> 14) - -#endif //#ifdef __BIG_ENDIAN - +#endif /* #ifdef __BIG_ENDIAN */ #define WLAN_SET_CAP_INFO_ESS(n) (n) #define WLAN_SET_CAP_INFO_IBSS(n) ((n) << 1) @@ -245,7 +237,6 @@ #define WLAN_SET_CAP_INFO_DSSSOFDM(n) ((n) << 13) #define WLAN_SET_CAP_INFO_GRPACK(n) ((n) << 14) - #define WLAN_SET_FC_PRVER(n) ((WORD)(n)) #define WLAN_SET_FC_FTYPE(n) (((WORD)(n)) << 2) #define WLAN_SET_FC_FSTYPE(n) (((WORD)(n)) << 4) @@ -261,7 +252,7 @@ #define WLAN_SET_SEQ_FRGNUM(n) ((WORD)(n)) #define WLAN_SET_SEQ_SEQNUM(n) (((WORD)(n)) << 4) -// ERP Field bit +/* ERP Field bit */ #define WLAN_GET_ERP_NONERP_PRESENT(n) ((n) & BIT0) #define WLAN_GET_ERP_USE_PROTECTION(n) (((n) & BIT1) >> 1) @@ -271,21 +262,19 @@ #define WLAN_SET_ERP_USE_PROTECTION(n) ((n) << 1) #define WLAN_SET_ERP_BARKER_MODE(n) ((n) << 2) - - -// Support & Basic Rates field +/* Support & Basic Rates field */ #define WLAN_MGMT_IS_BASICRATE(b) ((b) & BIT7) #define WLAN_MGMT_GET_RATE(b) ((b) & ~BIT7) -// TIM field +/* TIM field */ #define WLAN_MGMT_IS_MULTICAST_TIM(b) ((b) & BIT0) #define WLAN_MGMT_GET_TIM_OFFSET(b) (((b) & ~BIT0) >> 1) -// 3-Addr & 4-Addr +/* 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) -// IEEE ADDR +/* IEEE ADDR */ #define IEEE_ADDR_UNIVERSAL 0x02 #define IEEE_ADDR_GROUP 0x01 @@ -293,7 +282,7 @@ typedef struct { BYTE abyAddr[6]; } IEEE_ADDR, *PIEEE_ADDR; -// 802.11 Header Format +/* 802.11 Header Format */ typedef struct tagWLAN_80211HDR_A2 { @@ -302,7 +291,7 @@ typedef struct tagWLAN_80211HDR_A2 { BYTE abyAddr1[WLAN_ADDR_LEN]; BYTE abyAddr2[WLAN_ADDR_LEN]; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) WLAN_80211HDR_A2, *PWLAN_80211HDR_A2; typedef struct tagWLAN_80211HDR_A3 { @@ -314,7 +303,7 @@ typedef struct tagWLAN_80211HDR_A3 { BYTE abyAddr3[WLAN_ADDR_LEN]; WORD wSeqCtl; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) WLAN_80211HDR_A3, *PWLAN_80211HDR_A3; typedef struct tagWLAN_80211HDR_A4 { @@ -327,10 +316,9 @@ typedef struct tagWLAN_80211HDR_A4 { WORD wSeqCtl; BYTE abyAddr4[WLAN_ADDR_LEN]; -}__attribute__ ((__packed__)) +} __attribute__ ((__packed__)) WLAN_80211HDR_A4, *PWLAN_80211HDR_A4; - typedef union tagUWLAN_80211HDR { WLAN_80211HDR_A2 sA2; @@ -339,15 +327,10 @@ typedef union tagUWLAN_80211HDR { } UWLAN_80211HDR, *PUWLAN_80211HDR; - /*--------------------- Export Classes ----------------------------*/ /*--------------------- Export Variables --------------------------*/ /*--------------------- Export Functions --------------------------*/ - - -#endif // __80211HDR_H__ - - +#endif /* __80211HDR_H__ */ diff --git a/drivers/staging/vt6656/80211mgr.c b/drivers/staging/vt6656/80211mgr.c index 8fa1a8e5a21a..b9dc7b1d9387 100644 --- a/drivers/staging/vt6656/80211mgr.c +++ b/drivers/staging/vt6656/80211mgr.c @@ -91,7 +91,7 @@ static int msglevel =MSG_LEVEL_INFO; VOID vMgrEncodeBeacon( - IN PWLAN_FR_BEACON pFrame + PWLAN_FR_BEACON pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; @@ -123,7 +123,7 @@ vMgrEncodeBeacon( VOID vMgrDecodeBeacon( - IN PWLAN_FR_BEACON pFrame + PWLAN_FR_BEACON pFrame ) { PWLAN_IE pItem; @@ -244,7 +244,7 @@ vMgrDecodeBeacon( VOID vMgrEncodeIBSSATIM( - IN PWLAN_FR_IBSSATIM pFrame + PWLAN_FR_IBSSATIM pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; @@ -267,7 +267,7 @@ vMgrEncodeIBSSATIM( VOID vMgrDecodeIBSSATIM( - IN PWLAN_FR_IBSSATIM pFrame + PWLAN_FR_IBSSATIM pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; @@ -289,7 +289,7 @@ vMgrDecodeIBSSATIM( VOID vMgrEncodeDisassociation( - IN PWLAN_FR_DISASSOC pFrame + PWLAN_FR_DISASSOC pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; @@ -317,7 +317,7 @@ vMgrEncodeDisassociation( VOID vMgrDecodeDisassociation( - IN PWLAN_FR_DISASSOC pFrame + PWLAN_FR_DISASSOC pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; @@ -343,7 +343,7 @@ vMgrDecodeDisassociation( VOID vMgrEncodeAssocRequest( - IN PWLAN_FR_ASSOCREQ pFrame + PWLAN_FR_ASSOCREQ pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; @@ -370,7 +370,7 @@ vMgrEncodeAssocRequest( VOID vMgrDecodeAssocRequest( - IN PWLAN_FR_ASSOCREQ pFrame + PWLAN_FR_ASSOCREQ pFrame ) { PWLAN_IE pItem; @@ -436,7 +436,7 @@ vMgrDecodeAssocRequest( VOID vMgrEncodeAssocResponse( - IN PWLAN_FR_ASSOCRESP pFrame + PWLAN_FR_ASSOCRESP pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; @@ -468,7 +468,7 @@ vMgrEncodeAssocResponse( VOID vMgrDecodeAssocResponse( - IN PWLAN_FR_ASSOCRESP pFrame + PWLAN_FR_ASSOCRESP pFrame ) { PWLAN_IE pItem; @@ -514,7 +514,7 @@ vMgrDecodeAssocResponse( VOID vMgrEncodeReassocRequest( - IN PWLAN_FR_REASSOCREQ pFrame + PWLAN_FR_REASSOCREQ pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; @@ -546,7 +546,7 @@ vMgrEncodeReassocRequest( VOID vMgrDecodeReassocRequest( - IN PWLAN_FR_REASSOCREQ pFrame + PWLAN_FR_REASSOCREQ pFrame ) { PWLAN_IE pItem; @@ -618,7 +618,7 @@ vMgrDecodeReassocRequest( VOID vMgrEncodeProbeRequest( - IN PWLAN_FR_PROBEREQ pFrame + PWLAN_FR_PROBEREQ pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; @@ -639,7 +639,7 @@ vMgrEncodeProbeRequest( VOID vMgrDecodeProbeRequest( - IN PWLAN_FR_PROBEREQ pFrame + PWLAN_FR_PROBEREQ pFrame ) { PWLAN_IE pItem; @@ -692,7 +692,7 @@ vMgrDecodeProbeRequest( VOID vMgrEncodeProbeResponse( - IN PWLAN_FR_PROBERESP pFrame + PWLAN_FR_PROBERESP pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; @@ -726,7 +726,7 @@ vMgrEncodeProbeResponse( VOID vMgrDecodeProbeResponse( - IN PWLAN_FR_PROBERESP pFrame + PWLAN_FR_PROBERESP pFrame ) { PWLAN_IE pItem; @@ -840,7 +840,7 @@ vMgrDecodeProbeResponse( VOID vMgrEncodeAuthen( - IN PWLAN_FR_AUTHEN pFrame + PWLAN_FR_AUTHEN pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; @@ -871,7 +871,7 @@ vMgrEncodeAuthen( VOID vMgrDecodeAuthen( - IN PWLAN_FR_AUTHEN pFrame + PWLAN_FR_AUTHEN pFrame ) { PWLAN_IE pItem; @@ -911,7 +911,7 @@ vMgrDecodeAuthen( VOID vMgrEncodeDeauthen( - IN PWLAN_FR_DEAUTHEN pFrame + PWLAN_FR_DEAUTHEN pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; @@ -938,7 +938,7 @@ vMgrEncodeDeauthen( VOID vMgrDecodeDeauthen( - IN PWLAN_FR_DEAUTHEN pFrame + PWLAN_FR_DEAUTHEN pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; @@ -964,7 +964,7 @@ vMgrDecodeDeauthen( VOID vMgrEncodeReassocResponse( - IN PWLAN_FR_REASSOCRESP pFrame + PWLAN_FR_REASSOCRESP pFrame ) { pFrame->pHdr = (PUWLAN_80211HDR)pFrame->pBuf; @@ -997,7 +997,7 @@ vMgrEncodeReassocResponse( VOID vMgrDecodeReassocResponse( - IN PWLAN_FR_REASSOCRESP pFrame + PWLAN_FR_REASSOCRESP pFrame ) { PWLAN_IE pItem; diff --git a/drivers/staging/vt6656/80211mgr.h b/drivers/staging/vt6656/80211mgr.h index a4ea82492167..f7160cdd164a 100644 --- a/drivers/staging/vt6656/80211mgr.h +++ b/drivers/staging/vt6656/80211mgr.h @@ -750,112 +750,112 @@ typedef struct tagWLAN_FR_DEAUTHEN { /*--------------------- Export Functions --------------------------*/ VOID vMgrEncodeBeacon( - IN PWLAN_FR_BEACON pFrame + PWLAN_FR_BEACON pFrame ); VOID vMgrDecodeBeacon( - IN PWLAN_FR_BEACON pFrame + PWLAN_FR_BEACON pFrame ); VOID vMgrEncodeIBSSATIM( - IN PWLAN_FR_IBSSATIM pFrame + PWLAN_FR_IBSSATIM pFrame ); VOID vMgrDecodeIBSSATIM( - IN PWLAN_FR_IBSSATIM pFrame + PWLAN_FR_IBSSATIM pFrame ); VOID vMgrEncodeDisassociation( - IN PWLAN_FR_DISASSOC pFrame + PWLAN_FR_DISASSOC pFrame ); VOID vMgrDecodeDisassociation( - IN PWLAN_FR_DISASSOC pFrame + PWLAN_FR_DISASSOC pFrame ); VOID vMgrEncodeAssocRequest( - IN PWLAN_FR_ASSOCREQ pFrame + PWLAN_FR_ASSOCREQ pFrame ); VOID vMgrDecodeAssocRequest( - IN PWLAN_FR_ASSOCREQ pFrame + PWLAN_FR_ASSOCREQ pFrame ); VOID vMgrEncodeAssocResponse( - IN PWLAN_FR_ASSOCRESP pFrame + PWLAN_FR_ASSOCRESP pFrame ); VOID vMgrDecodeAssocResponse( - IN PWLAN_FR_ASSOCRESP pFrame + PWLAN_FR_ASSOCRESP pFrame ); VOID vMgrEncodeReassocRequest( - IN PWLAN_FR_REASSOCREQ pFrame + PWLAN_FR_REASSOCREQ pFrame ); VOID vMgrDecodeReassocRequest( - IN PWLAN_FR_REASSOCREQ pFrame + PWLAN_FR_REASSOCREQ pFrame ); VOID vMgrEncodeProbeRequest( - IN PWLAN_FR_PROBEREQ pFrame + PWLAN_FR_PROBEREQ pFrame ); VOID vMgrDecodeProbeRequest( - IN PWLAN_FR_PROBEREQ pFrame + PWLAN_FR_PROBEREQ pFrame ); VOID vMgrEncodeProbeResponse( - IN PWLAN_FR_PROBERESP pFrame + PWLAN_FR_PROBERESP pFrame ); VOID vMgrDecodeProbeResponse( - IN PWLAN_FR_PROBERESP pFrame + PWLAN_FR_PROBERESP pFrame ); VOID vMgrEncodeAuthen( - IN PWLAN_FR_AUTHEN pFrame + PWLAN_FR_AUTHEN pFrame ); VOID vMgrDecodeAuthen( - IN PWLAN_FR_AUTHEN pFrame + PWLAN_FR_AUTHEN pFrame ); VOID vMgrEncodeDeauthen( - IN PWLAN_FR_DEAUTHEN pFrame + PWLAN_FR_DEAUTHEN pFrame ); VOID vMgrDecodeDeauthen( - IN PWLAN_FR_DEAUTHEN pFrame + PWLAN_FR_DEAUTHEN pFrame ); VOID vMgrEncodeReassocResponse( - IN PWLAN_FR_REASSOCRESP pFrame + PWLAN_FR_REASSOCRESP pFrame ); VOID vMgrDecodeReassocResponse( - IN PWLAN_FR_REASSOCRESP pFrame + PWLAN_FR_REASSOCRESP pFrame ); #endif// __80211MGR_H__ diff --git a/drivers/staging/vt6656/aes_ccmp.c b/drivers/staging/vt6656/aes_ccmp.c index 401a7d267c90..a1beaa93b333 100644 --- a/drivers/staging/vt6656/aes_ccmp.c +++ b/drivers/staging/vt6656/aes_ccmp.c @@ -277,7 +277,7 @@ int ii,jj,kk; pbyPayload = pbyIV + 8; //IV-length abyNonce[0] = 0x00; //now is 0, if Qos here will be priority - memcpy(&(abyNonce[1]), pMACHeader->abyAddr2, U_ETHER_ADDR_LEN); + memcpy(&(abyNonce[1]), pMACHeader->abyAddr2, ETH_ALEN); abyNonce[7] = pbyIV[7]; abyNonce[8] = pbyIV[6]; abyNonce[9] = pbyIV[5]; @@ -299,16 +299,17 @@ int ii,jj,kk; byTmp = (BYTE)(pMACHeader->wFrameCtl >> 8); byTmp &= 0x87; MIC_HDR1[3] = byTmp | 0x40; - memcpy(&(MIC_HDR1[4]), pMACHeader->abyAddr1, U_ETHER_ADDR_LEN); - memcpy(&(MIC_HDR1[10]), pMACHeader->abyAddr2, U_ETHER_ADDR_LEN); + memcpy(&(MIC_HDR1[4]), pMACHeader->abyAddr1, ETH_ALEN); + memcpy(&(MIC_HDR1[10]), pMACHeader->abyAddr2, ETH_ALEN); //MIC_HDR2 - memcpy(&(MIC_HDR2[0]), pMACHeader->abyAddr3, U_ETHER_ADDR_LEN); + memcpy(&(MIC_HDR2[0]), pMACHeader->abyAddr3, ETH_ALEN); byTmp = (BYTE)(pMACHeader->wSeqCtl & 0xff); MIC_HDR2[6] = byTmp & 0x0f; MIC_HDR2[7] = 0; + if ( bA4 ) { - memcpy(&(MIC_HDR2[8]), pMACHeader->abyAddr4, U_ETHER_ADDR_LEN); + memcpy(&(MIC_HDR2[8]), pMACHeader->abyAddr4, ETH_ALEN); } else { MIC_HDR2[8] = 0x00; MIC_HDR2[9] = 0x00; diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 7dc01dbfc6ff..9063249efd54 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -691,10 +691,10 @@ s_vClearSQ3Value(PSDevice pDevice); */ UINT BBuGetFrameTime ( - IN BYTE byPreambleType, - IN BYTE byPktType, - IN UINT cbFrameLength, - IN WORD wRate + BYTE byPreambleType, + BYTE byPktType, + UINT cbFrameLength, + WORD wRate ) { UINT uFrameTime; @@ -758,10 +758,10 @@ BBuGetFrameTime ( */ VOID BBvCaculateParameter ( - IN PSDevice pDevice, - IN UINT cbFrameLength, - IN WORD wRate, - IN BYTE byPacketType, + PSDevice pDevice, + UINT cbFrameLength, + WORD wRate, + BYTE byPacketType, OUT PWORD pwPhyLen, OUT PBYTE pbyPhySrv, OUT PBYTE pbyPhySgn @@ -1578,7 +1578,7 @@ BBvAntennaDiversity (PSDevice pDevice, BYTE byRxRate, BYTE bySQ3) VOID TimerSQ3CallBack ( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -1620,7 +1620,7 @@ TimerSQ3CallBack ( VOID TimerSQ3Tmax3CallBack ( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -1652,8 +1652,8 @@ TimerSQ3Tmax3CallBack ( VOID BBvUpdatePreEDThreshold( - IN PSDevice pDevice, - IN BOOL bScanning) + PSDevice pDevice, + BOOL bScanning) { diff --git a/drivers/staging/vt6656/baseband.h b/drivers/staging/vt6656/baseband.h index e991a7e68d4a..10eea90279fa 100644 --- a/drivers/staging/vt6656/baseband.h +++ b/drivers/staging/vt6656/baseband.h @@ -98,18 +98,18 @@ UINT BBuGetFrameTime( - IN BYTE byPreambleType, - IN BYTE byFreqType, - IN UINT cbFrameLength, - IN WORD wRate + BYTE byPreambleType, + BYTE byFreqType, + UINT cbFrameLength, + WORD wRate ); VOID BBvCaculateParameter ( - IN PSDevice pDevice, - IN UINT cbFrameLength, - IN WORD wRate, - IN BYTE byPacketType, + PSDevice pDevice, + UINT cbFrameLength, + WORD wRate, + BYTE byPacketType, OUT PWORD pwPhyLen, OUT PBYTE pbyPhySrv, OUT PBYTE pbyPhySgn @@ -119,12 +119,12 @@ BBvCaculateParameter ( VOID TimerSQ3CallBack ( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ); VOID TimerSQ3Tmax3CallBack ( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ); VOID BBvAntennaDiversity (PSDevice pDevice, BYTE byRxRate, BYTE bySQ3); @@ -139,8 +139,8 @@ BOOL BBbVT3184Init (PSDevice pDevice); VOID BBvSetDeepSleep (PSDevice pDevice); VOID BBvExitDeepSleep (PSDevice pDevice); VOID BBvUpdatePreEDThreshold( - IN PSDevice pDevice, - IN BOOL bScanning + PSDevice pDevice, + BOOL bScanning ); #endif // __BASEBAND_H__ diff --git a/drivers/staging/vt6656/bssdb.c b/drivers/staging/vt6656/bssdb.c index 6b1678bfd61a..fa1ca7902055 100644 --- a/drivers/staging/vt6656/bssdb.c +++ b/drivers/staging/vt6656/bssdb.c @@ -92,16 +92,16 @@ const WORD awHWRetry1[5][5] = { /*--------------------- Static Functions --------------------------*/ VOID s_vCheckSensitivity( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ); VOID s_vCheckPreEDThreshold( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ); #ifdef Calcu_LinkQual VOID s_uCalculateLinkQual( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ); #endif /*--------------------- Export Variables --------------------------*/ @@ -125,10 +125,10 @@ VOID s_uCalculateLinkQual( PKnownBSS BSSpSearchBSSList( - IN HANDLE hDeviceContext, - IN PBYTE pbyDesireBSSID, - IN PBYTE pbyDesireSSID, - IN CARD_PHY_TYPE ePhyType + HANDLE hDeviceContext, + PBYTE pbyDesireBSSID, + PBYTE pbyDesireSSID, + CARD_PHY_TYPE ePhyType ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -298,8 +298,8 @@ pDevice->bSameBSSMaxNum = jj; VOID BSSvClearBSSList( - IN HANDLE hDeviceContext, - IN BOOL bKeepCurrBSSID + HANDLE hDeviceContext, + BOOL bKeepCurrBSSID ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -344,9 +344,9 @@ BSSvClearBSSList( -*/ PKnownBSS BSSpAddrIsInBSSList( - IN HANDLE hDeviceContext, - IN PBYTE abyBSSID, - IN PWLAN_IE_SSID pSSID + HANDLE hDeviceContext, + PBYTE abyBSSID, + PWLAN_IE_SSID pSSID ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -385,23 +385,23 @@ BSSpAddrIsInBSSList( BOOL BSSbInsertToBSSList ( - IN HANDLE hDeviceContext, - IN PBYTE abyBSSIDAddr, - IN QWORD qwTimestamp, - IN WORD wBeaconInterval, - IN WORD wCapInfo, - IN BYTE byCurrChannel, - IN PWLAN_IE_SSID pSSID, - IN PWLAN_IE_SUPP_RATES pSuppRates, - IN PWLAN_IE_SUPP_RATES pExtSuppRates, - IN PERPObject psERP, - IN PWLAN_IE_RSN pRSN, - IN PWLAN_IE_RSN_EXT pRSNWPA, - IN PWLAN_IE_COUNTRY pIE_Country, - IN PWLAN_IE_QUIET pIE_Quiet, - IN UINT uIELength, - IN PBYTE pbyIEs, - IN HANDLE pRxPacketContext + HANDLE hDeviceContext, + PBYTE abyBSSIDAddr, + QWORD qwTimestamp, + WORD wBeaconInterval, + WORD wCapInfo, + BYTE byCurrChannel, + PWLAN_IE_SSID pSSID, + PWLAN_IE_SUPP_RATES pSuppRates, + PWLAN_IE_SUPP_RATES pExtSuppRates, + PERPObject psERP, + PWLAN_IE_RSN pRSN, + PWLAN_IE_RSN_EXT pRSNWPA, + PWLAN_IE_COUNTRY pIE_Country, + PWLAN_IE_QUIET pIE_Quiet, + UINT uIELength, + PBYTE pbyIEs, + HANDLE pRxPacketContext ) { @@ -604,24 +604,24 @@ BSSbInsertToBSSList ( BOOL BSSbUpdateToBSSList ( - IN HANDLE hDeviceContext, - IN QWORD qwTimestamp, - IN WORD wBeaconInterval, - IN WORD wCapInfo, - IN BYTE byCurrChannel, - IN BOOL bChannelHit, - IN PWLAN_IE_SSID pSSID, - IN PWLAN_IE_SUPP_RATES pSuppRates, - IN PWLAN_IE_SUPP_RATES pExtSuppRates, - IN PERPObject psERP, - IN PWLAN_IE_RSN pRSN, - IN PWLAN_IE_RSN_EXT pRSNWPA, - IN PWLAN_IE_COUNTRY pIE_Country, - IN PWLAN_IE_QUIET pIE_Quiet, - IN PKnownBSS pBSSList, - IN UINT uIELength, - IN PBYTE pbyIEs, - IN HANDLE pRxPacketContext + HANDLE hDeviceContext, + QWORD qwTimestamp, + WORD wBeaconInterval, + WORD wCapInfo, + BYTE byCurrChannel, + BOOL bChannelHit, + PWLAN_IE_SSID pSSID, + PWLAN_IE_SUPP_RATES pSuppRates, + PWLAN_IE_SUPP_RATES pExtSuppRates, + PERPObject psERP, + PWLAN_IE_RSN pRSN, + PWLAN_IE_RSN_EXT pRSNWPA, + PWLAN_IE_COUNTRY pIE_Country, + PWLAN_IE_QUIET pIE_Quiet, + PKnownBSS pBSSList, + UINT uIELength, + PBYTE pbyIEs, + HANDLE pRxPacketContext ) { int ii, jj; @@ -770,8 +770,8 @@ BSSbUpdateToBSSList ( BOOL BSSbIsSTAInNodeDB( - IN HANDLE hDeviceContext, - IN PBYTE abyDstAddr, + HANDLE hDeviceContext, + PBYTE abyDstAddr, OUT PUINT puNodeIndex ) { @@ -806,7 +806,7 @@ BSSbIsSTAInNodeDB( -*/ VOID BSSvCreateOneNode( - IN HANDLE hDeviceContext, + HANDLE hDeviceContext, OUT PUINT puNodeIndex ) { @@ -871,8 +871,8 @@ BSSvCreateOneNode( -*/ VOID BSSvRemoveOneNode( - IN HANDLE hDeviceContext, - IN UINT uNodeIndex + HANDLE hDeviceContext, + UINT uNodeIndex ) { @@ -904,10 +904,10 @@ BSSvRemoveOneNode( VOID BSSvUpdateAPNode( - IN HANDLE hDeviceContext, - IN PWORD pwCapInfo, - IN PWLAN_IE_SUPP_RATES pSuppRates, - IN PWLAN_IE_SUPP_RATES pExtSuppRates + HANDLE hDeviceContext, + PWORD pwCapInfo, + PWLAN_IE_SUPP_RATES pSuppRates, + PWLAN_IE_SUPP_RATES pExtSuppRates ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -964,7 +964,7 @@ BSSvUpdateAPNode( VOID BSSvAddMulticastNode( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -1011,7 +1011,7 @@ BSSvAddMulticastNode( VOID BSSvSecondCallBack( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -1397,10 +1397,10 @@ else { VOID BSSvUpdateNodeTxCounter( - IN HANDLE hDeviceContext, - IN PSStatCounter pStatistic, - IN BYTE byTSR, - IN BYTE byPktNO + HANDLE hDeviceContext, + PSStatCounter pStatistic, + BYTE byTSR, + BYTE byPktNO ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -1566,8 +1566,8 @@ BSSvUpdateNodeTxCounter( VOID BSSvClearNodeDBTable( - IN HANDLE hDeviceContext, - IN UINT uStartIndex + HANDLE hDeviceContext, + UINT uStartIndex ) { @@ -1594,7 +1594,7 @@ BSSvClearNodeDBTable( VOID s_vCheckSensitivity( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -1638,7 +1638,7 @@ VOID s_vCheckSensitivity( #ifdef Calcu_LinkQual VOID s_uCalculateLinkQual( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -1687,7 +1687,7 @@ else VOID BSSvClearAnyBSSJoinRecord ( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -1701,7 +1701,7 @@ BSSvClearAnyBSSJoinRecord ( } VOID s_vCheckPreEDThreshold( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ) { PSDevice pDevice = (PSDevice)hDeviceContext; diff --git a/drivers/staging/vt6656/bssdb.h b/drivers/staging/vt6656/bssdb.h index f365b6b8bf6a..eec6cea86071 100644 --- a/drivers/staging/vt6656/bssdb.h +++ b/drivers/staging/vt6656/bssdb.h @@ -233,127 +233,127 @@ typedef struct tagKnownNodeDB { PKnownBSS BSSpSearchBSSList( - IN HANDLE hDeviceContext, - IN PBYTE pbyDesireBSSID, - IN PBYTE pbyDesireSSID, - IN CARD_PHY_TYPE ePhyType + HANDLE hDeviceContext, + PBYTE pbyDesireBSSID, + PBYTE pbyDesireSSID, + CARD_PHY_TYPE ePhyType ); PKnownBSS BSSpAddrIsInBSSList( - IN HANDLE hDeviceContext, - IN PBYTE abyBSSID, - IN PWLAN_IE_SSID pSSID + HANDLE hDeviceContext, + PBYTE abyBSSID, + PWLAN_IE_SSID pSSID ); VOID BSSvClearBSSList( - IN HANDLE hDeviceContext, - IN BOOL bKeepCurrBSSID + HANDLE hDeviceContext, + BOOL bKeepCurrBSSID ); BOOL BSSbInsertToBSSList( - IN HANDLE hDeviceContext, - IN PBYTE abyBSSIDAddr, - IN QWORD qwTimestamp, - IN WORD wBeaconInterval, - IN WORD wCapInfo, - IN BYTE byCurrChannel, - IN PWLAN_IE_SSID pSSID, - IN PWLAN_IE_SUPP_RATES pSuppRates, - IN PWLAN_IE_SUPP_RATES pExtSuppRates, - IN PERPObject psERP, - IN PWLAN_IE_RSN pRSN, - IN PWLAN_IE_RSN_EXT pRSNWPA, - IN PWLAN_IE_COUNTRY pIE_Country, - IN PWLAN_IE_QUIET pIE_Quiet, - IN UINT uIELength, - IN PBYTE pbyIEs, - IN HANDLE pRxPacketContext + HANDLE hDeviceContext, + PBYTE abyBSSIDAddr, + QWORD qwTimestamp, + WORD wBeaconInterval, + WORD wCapInfo, + BYTE byCurrChannel, + PWLAN_IE_SSID pSSID, + PWLAN_IE_SUPP_RATES pSuppRates, + PWLAN_IE_SUPP_RATES pExtSuppRates, + PERPObject psERP, + PWLAN_IE_RSN pRSN, + PWLAN_IE_RSN_EXT pRSNWPA, + PWLAN_IE_COUNTRY pIE_Country, + PWLAN_IE_QUIET pIE_Quiet, + UINT uIELength, + PBYTE pbyIEs, + HANDLE pRxPacketContext ); BOOL BSSbUpdateToBSSList( - IN HANDLE hDeviceContext, - IN QWORD qwTimestamp, - IN WORD wBeaconInterval, - IN WORD wCapInfo, - IN BYTE byCurrChannel, - IN BOOL bChannelHit, - IN PWLAN_IE_SSID pSSID, - IN PWLAN_IE_SUPP_RATES pSuppRates, - IN PWLAN_IE_SUPP_RATES pExtSuppRates, - IN PERPObject psERP, - IN PWLAN_IE_RSN pRSN, - IN PWLAN_IE_RSN_EXT pRSNWPA, - IN PWLAN_IE_COUNTRY pIE_Country, - IN PWLAN_IE_QUIET pIE_Quiet, - IN PKnownBSS pBSSList, - IN UINT uIELength, - IN PBYTE pbyIEs, - IN HANDLE pRxPacketContext + HANDLE hDeviceContext, + QWORD qwTimestamp, + WORD wBeaconInterval, + WORD wCapInfo, + BYTE byCurrChannel, + BOOL bChannelHit, + PWLAN_IE_SSID pSSID, + PWLAN_IE_SUPP_RATES pSuppRates, + PWLAN_IE_SUPP_RATES pExtSuppRates, + PERPObject psERP, + PWLAN_IE_RSN pRSN, + PWLAN_IE_RSN_EXT pRSNWPA, + PWLAN_IE_COUNTRY pIE_Country, + PWLAN_IE_QUIET pIE_Quiet, + PKnownBSS pBSSList, + UINT uIELength, + PBYTE pbyIEs, + HANDLE pRxPacketContext ); BOOL BSSbIsSTAInNodeDB( - IN HANDLE hDeviceContext, - IN PBYTE abyDstAddr, + HANDLE hDeviceContext, + PBYTE abyDstAddr, OUT PUINT puNodeIndex ); VOID BSSvCreateOneNode( - IN HANDLE hDeviceContext, + HANDLE hDeviceContext, OUT PUINT puNodeIndex ); VOID BSSvUpdateAPNode( - IN HANDLE hDeviceContext, - IN PWORD pwCapInfo, - IN PWLAN_IE_SUPP_RATES pItemRates, - IN PWLAN_IE_SUPP_RATES pExtSuppRates + HANDLE hDeviceContext, + PWORD pwCapInfo, + PWLAN_IE_SUPP_RATES pItemRates, + PWLAN_IE_SUPP_RATES pExtSuppRates ); VOID BSSvSecondCallBack( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ); VOID BSSvUpdateNodeTxCounter( - IN HANDLE hDeviceContext, - IN PSStatCounter pStatistic, - IN BYTE byTSR, - IN BYTE byPktNO + HANDLE hDeviceContext, + PSStatCounter pStatistic, + BYTE byTSR, + BYTE byPktNO ); VOID BSSvRemoveOneNode( - IN HANDLE hDeviceContext, - IN UINT uNodeIndex + HANDLE hDeviceContext, + UINT uNodeIndex ); VOID BSSvAddMulticastNode( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ); VOID BSSvClearNodeDBTable( - IN HANDLE hDeviceContext, - IN UINT uStartIndex + HANDLE hDeviceContext, + UINT uStartIndex ); VOID BSSvClearAnyBSSJoinRecord( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ); #endif //__BSSDB_H__ diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index d73efeea2d5c..4ad1e94ffba4 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -224,8 +224,8 @@ WORD swGetOFDMControlRate (PVOID pDeviceHandler, WORD wRateIdx) */ VOID CARDvCaculateOFDMRParameter ( - IN WORD wRate, - IN BYTE byBBType, + WORD wRate, + BYTE byBBType, OUT PBYTE pbyTxRate, OUT PBYTE pbyRsvTime ) @@ -1080,10 +1080,10 @@ void CARDvSetBSSMode (PVOID pDeviceHandler) -*/ BOOL CARDbChannelSwitch ( - IN PVOID pDeviceHandler, - IN BYTE byMode, - IN BYTE byNewChannel, - IN BYTE byCount + PVOID pDeviceHandler, + BYTE byMode, + BYTE byNewChannel, + BYTE byCount ) { PSDevice pDevice = (PSDevice) pDeviceHandler; diff --git a/drivers/staging/vt6656/card.h b/drivers/staging/vt6656/card.h index aa90c2cb4461..16beb71a19bb 100644 --- a/drivers/staging/vt6656/card.h +++ b/drivers/staging/vt6656/card.h @@ -83,10 +83,10 @@ void CARDvSetBSSMode(PVOID pDeviceHandler); BOOL CARDbChannelSwitch ( - IN PVOID pDeviceHandler, - IN BYTE byMode, - IN BYTE byNewChannel, - IN BYTE byCount + PVOID pDeviceHandler, + BYTE byMode, + BYTE byNewChannel, + BYTE byCount ); #endif // __CARD_H__ diff --git a/drivers/staging/vt6656/channel.c b/drivers/staging/vt6656/channel.c index f7136b0073bb..32500af78bc4 100644 --- a/drivers/staging/vt6656/channel.c +++ b/drivers/staging/vt6656/channel.c @@ -425,7 +425,7 @@ exit: ************************************************************************/ BOOL CHvChannelGetList ( - IN UINT uCountryCodeIdx, + UINT uCountryCodeIdx, OUT PBYTE pbyChannelTable ) { diff --git a/drivers/staging/vt6656/channel.h b/drivers/staging/vt6656/channel.h index 2306b2025656..c965d6aff15f 100644 --- a/drivers/staging/vt6656/channel.h +++ b/drivers/staging/vt6656/channel.h @@ -50,7 +50,7 @@ BYTE CHbyGetChannelMapping(BYTE byChannelNumber); BOOL CHvChannelGetList ( - IN UINT uCountryCodeIdx, + UINT uCountryCodeIdx, OUT PBYTE pbyChannelTable ); diff --git a/drivers/staging/vt6656/control.c b/drivers/staging/vt6656/control.c index 7dba7710e593..8aab6718ff47 100644 --- a/drivers/staging/vt6656/control.c +++ b/drivers/staging/vt6656/control.c @@ -30,11 +30,13 @@ * CONTROLnsRequestIn - Read variable length bytes from MEM/BB/MAC/EEPROM * ControlvWriteByte - Write one byte to MEM/BB/MAC/EEPROM * ControlvReadByte - Read one byte from MEM/BB/MAC/EEPROM - * ControlvMaskByte - Read one byte from MEM/BB/MAC/EEPROM and clear/set some bits in the same address + * ControlvMaskByte - Read one byte from MEM/BB/MAC/EEPROM and clear/set + * some bits in the same address * * Revision History: * 04-05-2004 Jerry Chen: Initial release - * 11-24-2004 Warren Hsu: Add ControlvWriteByte,ControlvReadByte,ControlvMaskByte + * 11-24-2004 Warren Hsu: Add ControlvWriteByte, ControlvReadByte, + * ControlvMaskByte * */ @@ -42,8 +44,8 @@ #include "rndis.h" /*--------------------- Static Definitions -------------------------*/ -//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 Classes ----------------------------*/ /*--------------------- Static Variables --------------------------*/ @@ -54,56 +56,43 @@ /*--------------------- Export Functions --------------------------*/ - -void ControlvWriteByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, BYTE byData) +void ControlvWriteByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, + BYTE byData) { -BYTE byData1; - - byData1 = byData; - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE, - byRegOfs, - byRegType, - 1, - &byData1 - ); - + BYTE byData1; + byData1 = byData; + CONTROLnsRequestOut(pDevice, + MESSAGE_TYPE_WRITE, + byRegOfs, + byRegType, + 1, + &byData1); } - -void ControlvReadByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, PBYTE pbyData) +void ControlvReadByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, + PBYTE pbyData) { -NTSTATUS ntStatus; -BYTE byData1; - - - ntStatus = CONTROLnsRequestIn(pDevice, - MESSAGE_TYPE_READ, - byRegOfs, - byRegType, - 1, - &byData1); - - *pbyData = byData1; - + NTSTATUS ntStatus; + BYTE byData1; + ntStatus = CONTROLnsRequestIn(pDevice, + MESSAGE_TYPE_READ, + byRegOfs, + byRegType, + 1, + &byData1); + *pbyData = byData1; } - - -void ControlvMaskByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, BYTE byMask, BYTE byData) +void ControlvMaskByte(PSDevice pDevice, BYTE byRegType, BYTE byRegOfs, + BYTE byMask, BYTE byData) { -BYTE pbyData[2]; - - pbyData[0] = byData; - pbyData[1] = byMask; - - CONTROLnsRequestOut(pDevice, - MESSAGE_TYPE_WRITE_MASK, - byRegOfs, - byRegType, - 2, - pbyData - ); - + BYTE pbyData[2]; + pbyData[0] = byData; + pbyData[1] = byMask; + CONTROLnsRequestOut(pDevice, + MESSAGE_TYPE_WRITE_MASK, + byRegOfs, + byRegType, + 2, + pbyData); } diff --git a/drivers/staging/vt6656/control.h b/drivers/staging/vt6656/control.h index 4d9a777a7064..106c9e9f2b3c 100644 --- a/drivers/staging/vt6656/control.h +++ b/drivers/staging/vt6656/control.h @@ -54,27 +54,27 @@ /*--------------------- Export Functions --------------------------*/ void ControlvWriteByte( - IN PSDevice pDevice, - IN BYTE byRegType, - IN BYTE byRegOfs, - IN BYTE byData + PSDevice pDevice, + BYTE byRegType, + BYTE byRegOfs, + BYTE byData ); void ControlvReadByte( - IN PSDevice pDevice, - IN BYTE byRegType, - IN BYTE byRegOfs, - IN PBYTE pbyData + PSDevice pDevice, + BYTE byRegType, + BYTE byRegOfs, + PBYTE pbyData ); void ControlvMaskByte( - IN PSDevice pDevice, - IN BYTE byRegType, - IN BYTE byRegOfs, - IN BYTE byMask, - IN BYTE byData + PSDevice pDevice, + BYTE byRegType, + BYTE byRegOfs, + BYTE byMask, + BYTE byData ); #endif // __RCV_H__ diff --git a/drivers/staging/vt6656/datarate.c b/drivers/staging/vt6656/datarate.c index 968feb466b0c..e487af57213f 100644 --- a/drivers/staging/vt6656/datarate.c +++ b/drivers/staging/vt6656/datarate.c @@ -66,14 +66,14 @@ const BYTE acbyIERate[MAX_RATE] = /*--------------------- Static Functions --------------------------*/ VOID s_vResetCounter ( - IN PKnownNodeDB psNodeDBTable + PKnownNodeDB psNodeDBTable ); VOID s_vResetCounter ( - IN PKnownNodeDB psNodeDBTable + PKnownNodeDB psNodeDBTable ) { BYTE ii; @@ -107,7 +107,7 @@ s_vResetCounter ( -*/ BYTE DATARATEbyGetRateIdx ( - IN BYTE byRate + BYTE byRate ) { BYTE ii; @@ -161,7 +161,7 @@ DATARATEbyGetRateIdx ( -*/ WORD RATEwGetRateIdx( - IN BYTE byRate + BYTE byRate ) { WORD ii; @@ -197,10 +197,10 @@ RATEwGetRateIdx( -*/ VOID RATEvParseMaxRate ( - IN PVOID pDeviceHandler, - IN PWLAN_IE_SUPP_RATES pItemRates, - IN PWLAN_IE_SUPP_RATES pItemExtRates, - IN BOOL bUpdateBasicRate, + PVOID pDeviceHandler, + PWLAN_IE_SUPP_RATES pItemRates, + PWLAN_IE_SUPP_RATES pItemExtRates, + BOOL bUpdateBasicRate, OUT PWORD pwMaxBasicRate, OUT PWORD pwMaxSuppRate, OUT PWORD pwSuppRate, @@ -310,8 +310,8 @@ UINT uRateLen; VOID RATEvTxRateFallBack ( - IN PVOID pDeviceHandler, - IN PKnownNodeDB psNodeDBTable + PVOID pDeviceHandler, + PKnownNodeDB psNodeDBTable ) { PSDevice pDevice = (PSDevice) pDeviceHandler; @@ -473,9 +473,9 @@ if (wIdxUpRate == RATE_54M ) { //11a/g -*/ BYTE RATEuSetIE ( - IN PWLAN_IE_SUPP_RATES pSrcRates, - IN PWLAN_IE_SUPP_RATES pDstRates, - IN UINT uRateLen + PWLAN_IE_SUPP_RATES pSrcRates, + PWLAN_IE_SUPP_RATES pDstRates, + UINT uRateLen ) { UINT ii, uu, uRateCnt = 0; diff --git a/drivers/staging/vt6656/datarate.h b/drivers/staging/vt6656/datarate.h index 68f206e2707b..5024f716238b 100644 --- a/drivers/staging/vt6656/datarate.h +++ b/drivers/staging/vt6656/datarate.h @@ -71,10 +71,10 @@ VOID RATEvParseMaxRate( - IN PVOID pDeviceHandler, - IN PWLAN_IE_SUPP_RATES pItemRates, - IN PWLAN_IE_SUPP_RATES pItemExtRates, - IN BOOL bUpdateBasicRate, + PVOID pDeviceHandler, + PWLAN_IE_SUPP_RATES pItemRates, + PWLAN_IE_SUPP_RATES pItemExtRates, + BOOL bUpdateBasicRate, OUT PWORD pwMaxBasicRate, OUT PWORD pwMaxSuppRate, OUT PWORD pwSuppRate, @@ -84,26 +84,26 @@ RATEvParseMaxRate( VOID RATEvTxRateFallBack( - IN PVOID pDeviceHandler, - IN PKnownNodeDB psNodeDBTable + PVOID pDeviceHandler, + PKnownNodeDB psNodeDBTable ); BYTE RATEuSetIE( - IN PWLAN_IE_SUPP_RATES pSrcRates, - IN PWLAN_IE_SUPP_RATES pDstRates, - IN UINT uRateLen + PWLAN_IE_SUPP_RATES pSrcRates, + PWLAN_IE_SUPP_RATES pDstRates, + UINT uRateLen ); WORD RATEwGetRateIdx( - IN BYTE byRate + BYTE byRate ); BYTE DATARATEbyGetRateIdx( - IN BYTE byRate + BYTE byRate ); diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index f10530fcc99b..c87ea6b4d864 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -206,8 +206,8 @@ typedef const SRrvTime_atim *PCSRrvTime_atim; typedef struct tagSRTSData { WORD wFrameControl; WORD wDurationID; - BYTE abyRA[U_ETHER_ADDR_LEN]; - BYTE abyTA[U_ETHER_ADDR_LEN]; + BYTE abyRA[ETH_ALEN]; + BYTE abyTA[ETH_ALEN]; }__attribute__ ((__packed__)) SRTSData, *PSRTSData; typedef const SRTSData *PCSRTSData; @@ -282,7 +282,7 @@ typedef const SRTS_a_FB *PCSRTS_a_FB; typedef struct tagSCTSData { WORD wFrameControl; WORD wDurationID; - BYTE abyRA[U_ETHER_ADDR_LEN]; + BYTE abyRA[ETH_ALEN]; WORD wReserved; }__attribute__ ((__packed__)) SCTSData, *PSCTSData; diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 8b541d1d0e23..29bb5977541c 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -107,7 +107,7 @@ #define MAC_MAX_CONTEXT_REG (256+128) #define MAX_MULTICAST_ADDRESS_NUM 32 -#define MULTICAST_ADDRESS_LIST_SIZE (MAX_MULTICAST_ADDRESS_NUM * U_ETHER_ADDR_LEN) +#define MULTICAST_ADDRESS_LIST_SIZE (MAX_MULTICAST_ADDRESS_NUM * ETH_ALEN) //#define OP_MODE_INFRASTRUCTURE 0 @@ -369,7 +369,7 @@ typedef struct tagSQuietControl { // The receive duplicate detection cache entry typedef struct tagSCacheEntry{ WORD wFmSequence; - BYTE abyAddr2[U_ETHER_ADDR_LEN]; + BYTE abyAddr2[ETH_ALEN]; WORD wFrameCtl; } SCacheEntry, *PSCacheEntry; @@ -387,7 +387,7 @@ typedef struct tagSDeFragControlBlock { WORD wSequence; WORD wFragNum; - BYTE abyAddr2[U_ETHER_ADDR_LEN]; + BYTE abyAddr2[ETH_ALEN]; UINT uLifetime; struct sk_buff* skb; PBYTE pbyRxBuffer; @@ -547,10 +547,10 @@ typedef struct __device_info { BYTE byOriginalZonetype; BOOL bLinkPass; // link status: OK or fail - BYTE abyCurrentNetAddr[U_ETHER_ADDR_LEN]; - BYTE abyPermanentNetAddr[U_ETHER_ADDR_LEN]; + BYTE abyCurrentNetAddr[ETH_ALEN]; + BYTE abyPermanentNetAddr[ETH_ALEN]; // SW network address -// BYTE abySoftwareNetAddr[U_ETHER_ADDR_LEN]; + /* u8 abySoftwareNetAddr[ETH_ALEN]; */ BOOL bExistSWNetAddr; // Adapter statistics @@ -671,8 +671,8 @@ typedef struct __device_info { CARD_OP_MODE eOPMode; BOOL bBSSIDFilter; WORD wMaxTransmitMSDULifetime; - BYTE abyBSSID[U_ETHER_ADDR_LEN]; - BYTE abyDesireBSSID[U_ETHER_ADDR_LEN]; + BYTE abyBSSID[ETH_ALEN]; + BYTE abyDesireBSSID[ETH_ALEN]; WORD wCTSDuration; // update while speed change WORD wACKDuration; // update while speed change WORD wRTSTransmitLen; // update while speed change @@ -826,9 +826,9 @@ typedef struct __device_info { SEthernetHeader sTxEthHeader; SEthernetHeader sRxEthHeader; - BYTE abyBroadcastAddr[U_ETHER_ADDR_LEN]; - BYTE abySNAP_RFC1042[U_ETHER_ADDR_LEN]; - BYTE abySNAP_Bridgetunnel[U_ETHER_ADDR_LEN]; + BYTE abyBroadcastAddr[ETH_ALEN]; + BYTE abySNAP_RFC1042[ETH_ALEN]; + BYTE abySNAP_Bridgetunnel[ETH_ALEN]; // Pre-Authentication & PMK cache SPMKID gsPMKID; diff --git a/drivers/staging/vt6656/dpc.c b/drivers/staging/vt6656/dpc.c index 835c6d6967bf..957b7622eb68 100644 --- a/drivers/staging/vt6656/dpc.c +++ b/drivers/staging/vt6656/dpc.c @@ -74,13 +74,12 @@ const BYTE acbyRxRate[MAX_RATE] = /*--------------------- Static Functions --------------------------*/ -static BYTE s_byGetRateIdx(IN BYTE byRate); - +static BYTE s_byGetRateIdx(BYTE byRate); static VOID s_vGetDASA( - IN PBYTE pbyRxBufferAddr, + PBYTE pbyRxBufferAddr, OUT PUINT pcbHeaderSize, OUT PSEthernetHeader psEthHeader ); @@ -88,37 +87,37 @@ s_vGetDASA( static VOID s_vProcessRxMACHeader ( - IN PSDevice pDevice, - IN PBYTE pbyRxBufferAddr, - IN UINT cbPacketSize, - IN BOOL bIsWEP, - IN BOOL bExtIV, + PSDevice pDevice, + PBYTE pbyRxBufferAddr, + UINT cbPacketSize, + BOOL bIsWEP, + BOOL bExtIV, OUT PUINT pcbHeadSize ); static BOOL s_bAPModeRxCtl( - IN PSDevice pDevice, - IN PBYTE pbyFrame, - IN INT iSANodeIndex + PSDevice pDevice, + PBYTE pbyFrame, + INT iSANodeIndex ); static BOOL s_bAPModeRxData ( - IN PSDevice pDevice, - IN struct sk_buff* skb, - IN UINT FrameSize, - IN UINT cbHeaderOffset, - IN INT iSANodeIndex, - IN INT iDANodeIndex + PSDevice pDevice, + struct sk_buff *skb, + UINT FrameSize, + UINT cbHeaderOffset, + INT iSANodeIndex, + INT iDANodeIndex ); static BOOL s_bHandleRxEncryption( - IN PSDevice pDevice, - IN PBYTE pbyFrame, - IN UINT FrameSize, - IN PBYTE pbyRsr, + PSDevice pDevice, + PBYTE pbyFrame, + UINT FrameSize, + PBYTE pbyRsr, OUT PBYTE pbyNewRsr, OUT PSKeyItem *pKeyOut, int * pbExtIV, @@ -128,12 +127,12 @@ static BOOL s_bHandleRxEncryption( static BOOL s_bHostWepRxEncryption( - IN PSDevice pDevice, - IN PBYTE pbyFrame, - IN UINT FrameSize, - IN PBYTE pbyRsr, - IN BOOL bOnFly, - IN PSKeyItem pKey, + PSDevice pDevice, + PBYTE pbyFrame, + UINT FrameSize, + PBYTE pbyRsr, + BOOL bOnFly, + PSKeyItem pKey, OUT PBYTE pbyNewRsr, int * pbExtIV, OUT PWORD pwRxTSC15_0, @@ -163,11 +162,11 @@ static BOOL s_bHostWepRxEncryption( static VOID s_vProcessRxMACHeader ( - IN PSDevice pDevice, - IN PBYTE pbyRxBufferAddr, - IN UINT cbPacketSize, - IN BOOL bIsWEP, - IN BOOL bExtIV, + PSDevice pDevice, + PBYTE pbyRxBufferAddr, + UINT cbPacketSize, + BOOL bIsWEP, + BOOL bExtIV, OUT PUINT pcbHeadSize ) { @@ -234,11 +233,11 @@ s_vProcessRxMACHeader ( } } - cbHeaderSize -= (U_ETHER_ADDR_LEN * 2); + cbHeaderSize -= (ETH_ALEN * 2); pbyRxBuffer = (PBYTE) (pbyRxBufferAddr + cbHeaderSize); - for(ii=0;ii<U_ETHER_ADDR_LEN;ii++) + for (ii = 0; ii < ETH_ALEN; ii++) *pbyRxBuffer++ = pDevice->sRxEthHeader.abyDstAddr[ii]; - for(ii=0;ii<U_ETHER_ADDR_LEN;ii++) + for (ii = 0; ii < ETH_ALEN; ii++) *pbyRxBuffer++ = pDevice->sRxEthHeader.abySrcAddr[ii]; *pcbHeadSize = cbHeaderSize; @@ -247,7 +246,7 @@ s_vProcessRxMACHeader ( -static BYTE s_byGetRateIdx (IN BYTE byRate) +static BYTE s_byGetRateIdx(BYTE byRate) { BYTE byRateIdx; @@ -262,48 +261,53 @@ static BYTE s_byGetRateIdx (IN BYTE byRate) static VOID s_vGetDASA ( - IN PBYTE pbyRxBufferAddr, + PBYTE pbyRxBufferAddr, OUT PUINT pcbHeaderSize, OUT PSEthernetHeader psEthHeader ) { - UINT cbHeaderSize = 0; - PS802_11Header pMACHeader; - int ii; - - pMACHeader = (PS802_11Header) (pbyRxBufferAddr + cbHeaderSize); - - if ((pMACHeader->wFrameCtl & FC_TODS) == 0) { - if (pMACHeader->wFrameCtl & FC_FROMDS) { - for(ii=0;ii<U_ETHER_ADDR_LEN;ii++) { - psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr1[ii]; - psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr3[ii]; - } - } - else { - // IBSS mode - for(ii=0;ii<U_ETHER_ADDR_LEN;ii++) { - psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr1[ii]; - psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr2[ii]; - } - } - } - else { - // Is AP mode.. - if (pMACHeader->wFrameCtl & FC_FROMDS) { - for(ii=0;ii<U_ETHER_ADDR_LEN;ii++) { - psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr3[ii]; - psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr4[ii]; - cbHeaderSize += 6; - } - } - else { - for(ii=0;ii<U_ETHER_ADDR_LEN;ii++) { - psEthHeader->abyDstAddr[ii] = pMACHeader->abyAddr3[ii]; - psEthHeader->abySrcAddr[ii] = pMACHeader->abyAddr2[ii]; - } - } - }; + UINT cbHeaderSize = 0; + PS802_11Header pMACHeader; + int ii; + + pMACHeader = (PS802_11Header) (pbyRxBufferAddr + cbHeaderSize); + + if ((pMACHeader->wFrameCtl & FC_TODS) == 0) { + if (pMACHeader->wFrameCtl & FC_FROMDS) { + for (ii = 0; ii < ETH_ALEN; ii++) { + psEthHeader->abyDstAddr[ii] = + pMACHeader->abyAddr1[ii]; + psEthHeader->abySrcAddr[ii] = + pMACHeader->abyAddr3[ii]; + } + } else { + /* IBSS mode */ + for (ii = 0; ii < ETH_ALEN; ii++) { + psEthHeader->abyDstAddr[ii] = + pMACHeader->abyAddr1[ii]; + psEthHeader->abySrcAddr[ii] = + pMACHeader->abyAddr2[ii]; + } + } + } else { + /* Is AP mode.. */ + if (pMACHeader->wFrameCtl & FC_FROMDS) { + for (ii = 0; ii < ETH_ALEN; ii++) { + psEthHeader->abyDstAddr[ii] = + pMACHeader->abyAddr3[ii]; + psEthHeader->abySrcAddr[ii] = + pMACHeader->abyAddr4[ii]; + cbHeaderSize += 6; + } + } else { + for (ii = 0; ii < ETH_ALEN; ii++) { + psEthHeader->abyDstAddr[ii] = + pMACHeader->abyAddr3[ii]; + psEthHeader->abySrcAddr[ii] = + pMACHeader->abyAddr2[ii]; + } + } + }; *pcbHeaderSize = cbHeaderSize; } @@ -312,9 +316,9 @@ s_vGetDASA ( BOOL RXbBulkInProcessData ( - IN PSDevice pDevice, - IN PRCB pRCB, - IN ULONG BytesToIndicate + PSDevice pDevice, + PRCB pRCB, + ULONG BytesToIndicate ) { @@ -1017,9 +1021,9 @@ RXbBulkInProcessData ( static BOOL s_bAPModeRxCtl ( - IN PSDevice pDevice, - IN PBYTE pbyFrame, - IN INT iSANodeIndex + PSDevice pDevice, + PBYTE pbyFrame, + INT iSANodeIndex ) { PS802_11Header p802_11Header; @@ -1139,10 +1143,10 @@ static BOOL s_bAPModeRxCtl ( } static BOOL s_bHandleRxEncryption ( - IN PSDevice pDevice, - IN PBYTE pbyFrame, - IN UINT FrameSize, - IN PBYTE pbyRsr, + PSDevice pDevice, + PBYTE pbyFrame, + UINT FrameSize, + PBYTE pbyRsr, OUT PBYTE pbyNewRsr, OUT PSKeyItem *pKeyOut, int * pbExtIV, @@ -1285,12 +1289,12 @@ static BOOL s_bHandleRxEncryption ( static BOOL s_bHostWepRxEncryption ( - IN PSDevice pDevice, - IN PBYTE pbyFrame, - IN UINT FrameSize, - IN PBYTE pbyRsr, - IN BOOL bOnFly, - IN PSKeyItem pKey, + PSDevice pDevice, + PBYTE pbyFrame, + UINT FrameSize, + PBYTE pbyRsr, + BOOL bOnFly, + PSKeyItem pKey, OUT PBYTE pbyNewRsr, int * pbExtIV, OUT PWORD pwRxTSC15_0, @@ -1417,12 +1421,12 @@ static BOOL s_bHostWepRxEncryption ( static BOOL s_bAPModeRxData ( - IN PSDevice pDevice, - IN struct sk_buff* skb, - IN UINT FrameSize, - IN UINT cbHeaderOffset, - IN INT iSANodeIndex, - IN INT iDANodeIndex + PSDevice pDevice, + struct sk_buff *skb, + UINT FrameSize, + UINT cbHeaderOffset, + INT iSANodeIndex, + INT iDANodeIndex ) { @@ -1537,8 +1541,8 @@ RXvWorkItem( VOID RXvFreeRCB( - IN PRCB pRCB, - IN BOOL bReAllocSkb + PRCB pRCB, + BOOL bReAllocSkb ) { PSDevice pDevice = (PSDevice)pRCB->pDevice; diff --git a/drivers/staging/vt6656/dpc.h b/drivers/staging/vt6656/dpc.h index df148b453966..8e6dceef2407 100644 --- a/drivers/staging/vt6656/dpc.h +++ b/drivers/staging/vt6656/dpc.h @@ -53,15 +53,15 @@ RXvMngWorkItem( VOID RXvFreeRCB( - IN PRCB pRCB, - IN BOOL bReAllocSkb + PRCB pRCB, + BOOL bReAllocSkb ); BOOL RXbBulkInProcessData( - IN PSDevice pDevice, - IN PRCB pRCB, - IN ULONG BytesToIndicate + PSDevice pDevice, + PRCB pRCB, + ULONG BytesToIndicate ); #endif // __RXTX_H__ diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c index 585b6b12c5ba..e1f96d7086f7 100644 --- a/drivers/staging/vt6656/firmware.c +++ b/drivers/staging/vt6656/firmware.c @@ -770,7 +770,7 @@ const BYTE abyFirmware[] = { BOOL FIRMWAREbDownload( - IN PSDevice pDevice + PSDevice pDevice ) { NDIS_STATUS NdisStatus; @@ -820,7 +820,7 @@ FIRMWAREbDownload( BOOL FIRMWAREbBrach2Sram( - IN PSDevice pDevice + PSDevice pDevice ) { NDIS_STATUS NdisStatus; @@ -845,7 +845,7 @@ FIRMWAREbBrach2Sram( BOOL FIRMWAREbCheckVersion( - IN PSDevice pDevice + PSDevice pDevice ) { NTSTATUS ntStatus; diff --git a/drivers/staging/vt6656/firmware.h b/drivers/staging/vt6656/firmware.h index 97f8559f2a55..10e84cdf21b3 100644 --- a/drivers/staging/vt6656/firmware.h +++ b/drivers/staging/vt6656/firmware.h @@ -43,17 +43,17 @@ BOOL FIRMWAREbDownload( - IN PSDevice pDevice + PSDevice pDevice ); BOOL FIRMWAREbBrach2Sram( - IN PSDevice pDevice + PSDevice pDevice ); BOOL FIRMWAREbCheckVersion( - IN PSDevice pDevice + PSDevice pDevice ); diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c index 1078d616c497..ca007c30e0ab 100644 --- a/drivers/staging/vt6656/hostap.c +++ b/drivers/staging/vt6656/hostap.c @@ -178,7 +178,7 @@ static int hostap_disable_hostapd(PSDevice pDevice, int rtnl_locked) * */ -int hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked) +int vt6656_hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked) { if (val < 0 || val > 1) return -EINVAL; @@ -744,7 +744,7 @@ static int hostap_get_encryption(PSDevice pDevice, /* * Description: - * hostap_ioctl main function supported for hostap deamon. + * vt6656_hostap_ioctl main function supported for hostap deamon. * * Parameters: * In: @@ -756,7 +756,7 @@ static int hostap_get_encryption(PSDevice pDevice, * */ -int hostap_ioctl(PSDevice pDevice, struct iw_point *p) +int vt6656_hostap_ioctl(PSDevice pDevice, struct iw_point *p) { struct viawget_hostapd_param *param; int ret = 0; @@ -844,7 +844,7 @@ int hostap_ioctl(PSDevice pDevice, struct iw_point *p) return -EOPNOTSUPP; default: - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "hostap_ioctl: unknown cmd=%d\n", + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "vt6656_hostap_ioctl: unknown cmd=%d\n", (int)param->cmd); return -EOPNOTSUPP; break; diff --git a/drivers/staging/vt6656/hostap.h b/drivers/staging/vt6656/hostap.h index 8fd667b542be..9e366dca7a63 100644 --- a/drivers/staging/vt6656/hostap.h +++ b/drivers/staging/vt6656/hostap.h @@ -61,8 +61,8 @@ #define ARPHRD_IEEE80211 801 #endif -int hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked); -int hostap_ioctl(PSDevice pDevice, struct iw_point *p); +int vt6656_hostap_set_hostapd(PSDevice pDevice, int val, int rtnl_locked); +int vt6656_hostap_ioctl(PSDevice pDevice, struct iw_point *p); #endif // __HOSTAP_H__ diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c index 35053be6900d..a47eeb069300 100644 --- a/drivers/staging/vt6656/int.c +++ b/drivers/staging/vt6656/int.c @@ -41,8 +41,8 @@ #include "usbpipe.h" /*--------------------- Static Definitions -------------------------*/ -//static int msglevel =MSG_LEVEL_DEBUG; -static int msglevel =MSG_LEVEL_INFO; +/* static int msglevel = MSG_LEVEL_DEBUG; */ +static int msglevel = MSG_LEVEL_INFO; /*--------------------- Static Classes ----------------------------*/ @@ -74,120 +74,152 @@ static int msglevel =MSG_LEVEL_INFO; * * Notes: * - * USB reads are by nature 'Blocking', and when in a read, the device looks like it's - * in a 'stall' condition, so we deliberately time out every second if we've gotten no data + * USB reads are by nature 'Blocking', and when in a read, the device looks + * like it's in a 'stall' condition, so we deliberately time out every second + * if we've gotten no data * -*/ VOID -INTvWorkItem( - PVOID Context - ) +INTvWorkItem(PVOID Context) { - PSDevice pDevice = (PSDevice) Context; - NTSTATUS ntStatus; + PSDevice pDevice = (PSDevice) Context; + NTSTATUS ntStatus; - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n"); - - spin_lock_irq(&pDevice->lock); - if (pDevice->fKillEventPollingThread != TRUE) { - ntStatus = PIPEnsInterruptRead(pDevice); - } - spin_unlock_irq(&pDevice->lock); - - } + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->Interrupt Polling Thread\n"); + spin_lock_irq(&pDevice->lock); + if (pDevice->fKillEventPollingThread != TRUE) + ntStatus = PIPEnsInterruptRead(pDevice); + spin_unlock_irq(&pDevice->lock); +} NTSTATUS -INTnsProcessData( - IN PSDevice pDevice - ) +INTnsProcessData(PSDevice pDevice) { - NTSTATUS status = STATUS_SUCCESS; - PSINTData pINTData; - PSMgmtObject pMgmt = &(pDevice->sMgmtObj); - struct net_device_stats* pStats = &pDevice->stats; - - - DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptProcessData\n"); - - pINTData = (PSINTData) pDevice->intBuf.pDataBuf; - if (pINTData->byTSR0 & TSR_VALID) { - STAvUpdateTDStatCounter (&(pDevice->scStatistic), (BYTE) (pINTData->byPkt0 & 0x0F), (BYTE) (pINTData->byPkt0>>4), pINTData->byTSR0); - BSSvUpdateNodeTxCounter (pDevice, &(pDevice->scStatistic), pINTData->byTSR0, pINTData->byPkt0); - //DBG_PRN_GRP01(("TSR0 %02x\n", pINTData->byTSR0)); - } - if (pINTData->byTSR1 & TSR_VALID) { - STAvUpdateTDStatCounter (&(pDevice->scStatistic), (BYTE) (pINTData->byPkt1 & 0x0F), (BYTE) (pINTData->byPkt1>>4), pINTData->byTSR1); - BSSvUpdateNodeTxCounter (pDevice, &(pDevice->scStatistic), pINTData->byTSR1, pINTData->byPkt1); - //DBG_PRN_GRP01(("TSR1 %02x\n", pINTData->byTSR1)); - } - if (pINTData->byTSR2 & TSR_VALID) { - STAvUpdateTDStatCounter (&(pDevice->scStatistic), (BYTE) (pINTData->byPkt2 & 0x0F), (BYTE) (pINTData->byPkt2>>4), pINTData->byTSR2); - BSSvUpdateNodeTxCounter (pDevice, &(pDevice->scStatistic), pINTData->byTSR2, pINTData->byPkt2); - //DBG_PRN_GRP01(("TSR2 %02x\n", pINTData->byTSR2)); - } - if (pINTData->byTSR3 & TSR_VALID) { - STAvUpdateTDStatCounter (&(pDevice->scStatistic), (BYTE) (pINTData->byPkt3 & 0x0F), (BYTE) (pINTData->byPkt3>>4), pINTData->byTSR3); - BSSvUpdateNodeTxCounter (pDevice, &(pDevice->scStatistic), pINTData->byTSR3, pINTData->byPkt3); - //DBG_PRN_GRP01(("TSR3 %02x\n", pINTData->byTSR3)); - } - if ( pINTData->byISR0 != 0 ) { - if (pINTData->byISR0 & ISR_BNTX) { - - if (pDevice->eOPMode == OP_MODE_AP) { - if(pMgmt->byDTIMCount > 0) { - pMgmt->byDTIMCount --; - pMgmt->sNodeDBTable[0].bRxPSPoll = FALSE; - } else if(pMgmt->byDTIMCount == 0) { - // check if mutltcast tx bufferring - pMgmt->byDTIMCount = pMgmt->byDTIMPeriod - 1; - pMgmt->sNodeDBTable[0].bRxPSPoll = TRUE; - if (pMgmt->sNodeDBTable[0].bPSEnable) { - bScheduleCommand((HANDLE)pDevice, WLAN_CMD_RX_PSPOLL, NULL); - } - } - bScheduleCommand((HANDLE)pDevice, WLAN_CMD_BECON_SEND, NULL); - } // if (pDevice->eOPMode == OP_MODE_AP) - - pDevice->bBeaconSent = TRUE; - } else { - pDevice->bBeaconSent = FALSE; - } - if (pINTData->byISR0 & ISR_TBTT) { - if ( pDevice->bEnablePSMode ) { - bScheduleCommand((HANDLE) pDevice, WLAN_CMD_TBTT_WAKEUP, NULL); - } - if ( pDevice->bChannelSwitch ) { - pDevice->byChannelSwitchCount--; - if ( pDevice->byChannelSwitchCount == 0 ) { - bScheduleCommand((HANDLE) pDevice, WLAN_CMD_11H_CHSW, NULL); - } - } - } - LODWORD(pDevice->qwCurrTSF) = pINTData->dwLoTSF; - HIDWORD(pDevice->qwCurrTSF) = pINTData->dwHiTSF; - //DBG_PRN_GRP01(("ISR0 = %02x ,LoTsf = %08x,HiTsf = %08x\n", pINTData->byISR0, pINTData->dwLoTSF,pINTData->dwHiTSF)); - - STAvUpdate802_11Counter(&pDevice->s802_11Counter, &pDevice->scStatistic, pINTData->byRTSSuccess, - pINTData->byRTSFail, pINTData->byACKFail, pINTData->byFCSErr ); - STAvUpdateIsrStatCounter(&pDevice->scStatistic, pINTData->byISR0, pINTData->byISR1); - - } - - if ( pINTData->byISR1 != 0 ) { - if (pINTData->byISR1 & ISR_GPIO3) { - bScheduleCommand((HANDLE) pDevice, WLAN_CMD_RADIO, NULL); - } - } - pDevice->intBuf.uDataLen = 0; - pDevice->intBuf.bInUse = FALSE; - - pStats->tx_packets = pDevice->scStatistic.ullTsrOK; - pStats->tx_bytes = pDevice->scStatistic.ullTxDirectedBytes + - pDevice->scStatistic.ullTxMulticastBytes + - pDevice->scStatistic.ullTxBroadcastBytes; - pStats->tx_errors = pDevice->scStatistic.dwTsrErr; - pStats->tx_dropped = pDevice->scStatistic.dwTsrErr; - - return status; + NTSTATUS status = STATUS_SUCCESS; + PSINTData pINTData; + PSMgmtObject pMgmt = &(pDevice->sMgmtObj); + struct net_device_stats *pStats = &pDevice->stats; + + DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsInterruptProcessData\n"); + + pINTData = (PSINTData) pDevice->intBuf.pDataBuf; + if (pINTData->byTSR0 & TSR_VALID) { + STAvUpdateTDStatCounter(&(pDevice->scStatistic), + (BYTE) (pINTData->byPkt0 & 0x0F), + (BYTE) (pINTData->byPkt0>>4), + pINTData->byTSR0); + BSSvUpdateNodeTxCounter(pDevice, + &(pDevice->scStatistic), + pINTData->byTSR0, + pINTData->byPkt0); + /*DBG_PRN_GRP01(("TSR0 %02x\n", pINTData->byTSR0));*/ + } + if (pINTData->byTSR1 & TSR_VALID) { + STAvUpdateTDStatCounter(&(pDevice->scStatistic), + (BYTE) (pINTData->byPkt1 & 0x0F), + (BYTE) (pINTData->byPkt1>>4), + pINTData->byTSR1); + BSSvUpdateNodeTxCounter(pDevice, + &(pDevice->scStatistic), + pINTData->byTSR1, + pINTData->byPkt1); + /*DBG_PRN_GRP01(("TSR1 %02x\n", pINTData->byTSR1));*/ + } + if (pINTData->byTSR2 & TSR_VALID) { + STAvUpdateTDStatCounter(&(pDevice->scStatistic), + (BYTE) (pINTData->byPkt2 & 0x0F), + (BYTE) (pINTData->byPkt2>>4), + pINTData->byTSR2); + BSSvUpdateNodeTxCounter(pDevice, + &(pDevice->scStatistic), + pINTData->byTSR2, + pINTData->byPkt2); + /*DBG_PRN_GRP01(("TSR2 %02x\n", pINTData->byTSR2));*/ + } + if (pINTData->byTSR3 & TSR_VALID) { + STAvUpdateTDStatCounter(&(pDevice->scStatistic), + (BYTE) (pINTData->byPkt3 & 0x0F), + (BYTE) (pINTData->byPkt3>>4), + pINTData->byTSR3); + BSSvUpdateNodeTxCounter(pDevice, + &(pDevice->scStatistic), + pINTData->byTSR3, + pINTData->byPkt3); + /*DBG_PRN_GRP01(("TSR3 %02x\n", pINTData->byTSR3));*/ + } + if (pINTData->byISR0 != 0) { + if (pINTData->byISR0 & ISR_BNTX) { + if (pDevice->eOPMode == OP_MODE_AP) { + if (pMgmt->byDTIMCount > 0) { + pMgmt->byDTIMCount--; + pMgmt->sNodeDBTable[0].bRxPSPoll = + FALSE; + } else if (pMgmt->byDTIMCount == 0) { + /* check if mutltcast tx bufferring */ + pMgmt->byDTIMCount = + pMgmt->byDTIMPeriod-1; + pMgmt->sNodeDBTable[0].bRxPSPoll = TRUE; + if (pMgmt->sNodeDBTable[0].bPSEnable) + bScheduleCommand((HANDLE)pDevice, + WLAN_CMD_RX_PSPOLL, + NULL); + } + bScheduleCommand((HANDLE)pDevice, + WLAN_CMD_BECON_SEND, + NULL); + } /* if (pDevice->eOPMode == OP_MODE_AP) */ + pDevice->bBeaconSent = TRUE; + } else { + pDevice->bBeaconSent = FALSE; + } + if (pINTData->byISR0 & ISR_TBTT) { + if (pDevice->bEnablePSMode) + bScheduleCommand((HANDLE) pDevice, + WLAN_CMD_TBTT_WAKEUP, + NULL); + if (pDevice->bChannelSwitch) { + pDevice->byChannelSwitchCount--; + if (pDevice->byChannelSwitchCount == 0) + bScheduleCommand((HANDLE) pDevice, + WLAN_CMD_11H_CHSW, + NULL); + } + } + LODWORD(pDevice->qwCurrTSF) = pINTData->dwLoTSF; + HIDWORD(pDevice->qwCurrTSF) = pINTData->dwHiTSF; + /*DBG_PRN_GRP01(("ISR0 = %02x , + LoTsf = %08x, + HiTsf = %08x\n", + pINTData->byISR0, + pINTData->dwLoTSF, + pINTData->dwHiTSF)); */ + + STAvUpdate802_11Counter(&pDevice->s802_11Counter, + &pDevice->scStatistic, + pINTData->byRTSSuccess, + pINTData->byRTSFail, + pINTData->byACKFail, + pINTData->byFCSErr); + STAvUpdateIsrStatCounter(&pDevice->scStatistic, + pINTData->byISR0, + pINTData->byISR1); + } + + if (pINTData->byISR1 != 0) + if (pINTData->byISR1 & ISR_GPIO3) + bScheduleCommand((HANDLE) pDevice, + WLAN_CMD_RADIO, + NULL); + pDevice->intBuf.uDataLen = 0; + pDevice->intBuf.bInUse = FALSE; + + pStats->tx_packets = pDevice->scStatistic.ullTsrOK; + pStats->tx_bytes = pDevice->scStatistic.ullTxDirectedBytes + + pDevice->scStatistic.ullTxMulticastBytes + + pDevice->scStatistic.ullTxBroadcastBytes; + pStats->tx_errors = pDevice->scStatistic.dwTsrErr; + pStats->tx_dropped = pDevice->scStatistic.dwTsrErr; + + return status; } diff --git a/drivers/staging/vt6656/int.h b/drivers/staging/vt6656/int.h index 15e815a35967..c3476cff5429 100644 --- a/drivers/staging/vt6656/int.h +++ b/drivers/staging/vt6656/int.h @@ -74,7 +74,7 @@ INTvWorkItem( NTSTATUS INTnsProcessData( - IN PSDevice pDevice + PSDevice pDevice ); #endif // __INT_H__ diff --git a/drivers/staging/vt6656/ioctl.c b/drivers/staging/vt6656/ioctl.c index 6f33005a615f..08d5429db26a 100644 --- a/drivers/staging/vt6656/ioctl.c +++ b/drivers/staging/vt6656/ioctl.c @@ -412,7 +412,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) { break; }; if (sValue.dwValue == 1) { - if (hostap_set_hostapd(pDevice, 1, 1) == 0){ + if (vt6656_hostap_set_hostapd(pDevice, 1, 1) == 0){ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Enable HOSTAP\n"); } else { @@ -421,7 +421,7 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) { } } else { - hostap_set_hostapd(pDevice, 0, 1); + vt6656_hostap_set_hostapd(pDevice, 0, 1); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Disable HOSTAP\n"); } @@ -480,7 +480,9 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq) { }; if (sValue.dwValue == 1) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "up wpadev\n"); - memcpy(pDevice->wpadev->dev_addr, pDevice->dev->dev_addr, U_ETHER_ADDR_LEN); + memcpy(pDevice->wpadev->dev_addr, + pDevice->dev->dev_addr, + ETH_ALEN); pDevice->bWPADEVUp = TRUE; } else { diff --git a/drivers/staging/vt6656/ioctl.h b/drivers/staging/vt6656/ioctl.h index 07d228399c3c..d3f49d444164 100644 --- a/drivers/staging/vt6656/ioctl.h +++ b/drivers/staging/vt6656/ioctl.h @@ -44,10 +44,10 @@ int private_ioctl(PSDevice pDevice, struct ifreq *rq); /* VOID vConfigWEPKey ( - IN PSDevice pDevice, - IN DWORD dwKeyIndex, - IN PBYTE pbyKey, - IN ULONG uKeyLength + PSDevice pDevice, + DWORD dwKeyIndex, + PBYTE pbyKey, + ULONG uKeyLength ); */ diff --git a/drivers/staging/vt6656/iwctl.c b/drivers/staging/vt6656/iwctl.c index b7c6a22fe321..d7ed3b456339 100644 --- a/drivers/staging/vt6656/iwctl.c +++ b/drivers/staging/vt6656/iwctl.c @@ -758,7 +758,6 @@ int iwctl_siwap(struct net_device *dev, if (wrq->sa_family != ARPHRD_ETHER) rc = -EINVAL; else { - memset(pMgmt->abyDesireBSSID, 0xFF, 6); memcpy(pMgmt->abyDesireBSSID, wrq->sa_data, 6); //mike :add @@ -936,7 +935,6 @@ int iwctl_siwessid(struct net_device *dev, BYTE abyTmpDesireSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1]; UINT ii , uSameBssidNum=0; - memset(abyTmpDesireSSID,0,sizeof(abyTmpDesireSSID)); memcpy(abyTmpDesireSSID,pMgmt->abyDesireSSID,sizeof(abyTmpDesireSSID)); pCurr = BSSpSearchBSSList(pDevice, NULL, diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c index 13fc69a1a084..6cdc85e8352d 100644 --- a/drivers/staging/vt6656/key.c +++ b/drivers/staging/vt6656/key.c @@ -163,9 +163,9 @@ VOID KeyvInitTable(PVOID pDeviceHandler, PSKeyManagement pTable) * */ BOOL KeybGetKey ( - IN PSKeyManagement pTable, - IN PBYTE pbyBSSID, - IN DWORD dwKeyIndex, + PSKeyManagement pTable, + PBYTE pbyBSSID, + DWORD dwKeyIndex, OUT PSKeyItem *pKey ) { @@ -312,7 +312,7 @@ BOOL KeybSetKey ( } } if (j < (MAX_KEY_TABLE-1)) { - memcpy(pTable->KeyTable[j].abyBSSID,pbyBSSID,U_ETHER_ADDR_LEN); + memcpy(pTable->KeyTable[j].abyBSSID, pbyBSSID, ETH_ALEN); pTable->KeyTable[j].bInUse = TRUE; if ((dwKeyIndex & PAIRWISE_KEY) != 0) { // Pairwise key @@ -562,9 +562,9 @@ VOID KeyvRemoveAllWEPKey ( * */ BOOL KeybGetTransmitKey ( - IN PSKeyManagement pTable, - IN PBYTE pbyBSSID, - IN DWORD dwKeyType, + PSKeyManagement pTable, + PBYTE pbyBSSID, + DWORD dwKeyType, OUT PSKeyItem *pKey ) { @@ -642,7 +642,7 @@ BOOL KeybGetTransmitKey ( * */ BOOL KeybCheckPairewiseKey ( - IN PSKeyManagement pTable, + PSKeyManagement pTable, OUT PSKeyItem *pKey ) { @@ -700,7 +700,7 @@ BOOL KeybSetDefaultKey ( } pTable->KeyTable[MAX_KEY_TABLE-1].bInUse = TRUE; - for(ii=0;ii<U_ETHER_ADDR_LEN;ii++) + for (ii = 0; ii < ETH_ALEN; ii++) pTable->KeyTable[MAX_KEY_TABLE-1].abyBSSID[ii] = 0xFF; // Group key diff --git a/drivers/staging/vt6656/key.h b/drivers/staging/vt6656/key.h index b15a64cb3868..11236e848d9b 100644 --- a/drivers/staging/vt6656/key.h +++ b/drivers/staging/vt6656/key.h @@ -71,7 +71,7 @@ typedef struct tagSKeyItem typedef struct tagSKeyTable { - BYTE abyBSSID[U_ETHER_ADDR_LEN]; //6 + BYTE abyBSSID[ETH_ALEN]; /* 6 */ BYTE byReserved0[2]; //8 SKeyItem PairwiseKey; SKeyItem GroupKey[MAX_GROUP_KEY]; //64*5 = 320, 320+8=328 @@ -100,9 +100,9 @@ typedef struct tagSKeyManagement VOID KeyvInitTable(PVOID pDeviceHandler, PSKeyManagement pTable); BOOL KeybGetKey( - IN PSKeyManagement pTable, - IN PBYTE pbyBSSID, - IN DWORD dwKeyIndex, + PSKeyManagement pTable, + PBYTE pbyBSSID, + DWORD dwKeyIndex, OUT PSKeyItem *pKey ); @@ -142,14 +142,14 @@ VOID KeyvRemoveAllWEPKey( ); BOOL KeybGetTransmitKey( - IN PSKeyManagement pTable, - IN PBYTE pbyBSSID, - IN DWORD dwKeyType, + PSKeyManagement pTable, + PBYTE pbyBSSID, + DWORD dwKeyType, OUT PSKeyItem *pKey ); BOOL KeybCheckPairewiseKey( - IN PSKeyManagement pTable, + PSKeyManagement pTable, OUT PSKeyItem *pKey ); diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 49270db98fbb..a4ad47736978 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -26,7 +26,7 @@ * * Functions: * - * vntwusb_found1 - module initial (insmod) driver entry + * vt6656_probe - module initial (insmod) driver entry * device_remove1 - module remove entry * device_open - allocate dma/descripter resource & initial mac/bbp function * device_xmit - asynchrous data tx function @@ -222,15 +222,11 @@ DEVICE_PARAM(b80211hEnable, "802.11h mode"); // Static vars definitions // - - -static struct usb_device_id vntwusb_table[] = { +static struct usb_device_id vt6656_table[] __devinitdata = { {USB_DEVICE(VNT_USB_VENDOR_ID, VNT_USB_PRODUCT_ID)}, {} }; - - // Frequency list (map channels to frequencies) /* static const long frequency_list[] = { @@ -250,15 +246,17 @@ static const long frequency_list[] = { static const struct iw_handler_def iwctl_handler_def; */ +/*--------------------- Static Functions --------------------------*/ +static int vt6656_probe(struct usb_interface *intf, + const struct usb_device_id *id); +static void vt6656_disconnect(struct usb_interface *intf); -/*--------------------- Static Functions --------------------------*/ -static int vntwusb_found1(struct usb_interface *intf, const struct usb_device_id *id); -static void vntwusb_disconnect(struct usb_interface *intf); #ifdef CONFIG_PM /* Minimal support for suspend and resume */ -static int vntwusb_suspend(struct usb_interface *intf, pm_message_t message); -static int vntwusb_resume(struct usb_interface *intf); -#endif +static int vt6656_suspend(struct usb_interface *intf, pm_message_t message); +static int vt6656_resume(struct usb_interface *intf); +#endif /* CONFIG_PM */ + static struct net_device_stats *device_get_stats(struct net_device *dev); static int device_open(struct net_device *dev); static int device_xmit(struct sk_buff *skb, struct net_device *dev); @@ -297,14 +295,13 @@ static void usb_device_reset(PSDevice pDevice); static void device_set_options(PSDevice pDevice) { - BYTE abyBroadcastAddr[U_ETHER_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - BYTE abySNAP_RFC1042[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00}; - BYTE abySNAP_Bridgetunnel[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8}; - + BYTE abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + BYTE abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00}; + u8 abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8}; - memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, U_ETHER_ADDR_LEN); - memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, U_ETHER_ADDR_LEN); - memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, U_ETHER_ADDR_LEN); + memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, ETH_ALEN); + memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, ETH_ALEN); + memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, ETH_ALEN); pDevice->cbTD = TX_DESC_DEF0; pDevice->cbRD = RX_DESC_DEF0; @@ -361,9 +358,9 @@ static VOID device_init_diversity_timer(PSDevice pDevice) { static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) { - BYTE abyBroadcastAddr[U_ETHER_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - BYTE abySNAP_RFC1042[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00}; - BYTE abySNAP_Bridgetunnel[U_ETHER_ADDR_LEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8}; + u8 abyBroadcastAddr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + u8 abySNAP_RFC1042[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00}; + u8 abySNAP_Bridgetunnel[ETH_ALEN] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8}; BYTE byAntenna; UINT ii; CMD_CARD_INIT sInitCmd; @@ -377,10 +374,12 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "---->INIbInitAdapter. [%d][%d]\n", InitType, pDevice->byPacketType); spin_lock_irq(&pDevice->lock); - if (InitType == DEVICE_INIT_COLD) { - memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, U_ETHER_ADDR_LEN); - memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, U_ETHER_ADDR_LEN); - memcpy(pDevice->abySNAP_Bridgetunnel, abySNAP_Bridgetunnel, U_ETHER_ADDR_LEN); + if (InitType == DEVICE_INIT_COLD) { + memcpy(pDevice->abyBroadcastAddr, abyBroadcastAddr, ETH_ALEN); + memcpy(pDevice->abySNAP_RFC1042, abySNAP_RFC1042, ETH_ALEN); + memcpy(pDevice->abySNAP_Bridgetunnel, + abySNAP_Bridgetunnel, + ETH_ALEN); if ( !FIRMWAREbCheckVersion(pDevice) ) { if (FIRMWAREbDownload(pDevice) == TRUE) { @@ -605,7 +604,9 @@ static BOOL device_init_registers(PSDevice pDevice, DEVICE_INIT_TYPE InitType) // get Permanent network address memcpy(pDevice->abyPermanentNetAddr,&(sInitRsp.byNetAddr[0]),6); - memcpy(pDevice->abyCurrentNetAddr, pDevice->abyPermanentNetAddr, U_ETHER_ADDR_LEN); + memcpy(pDevice->abyCurrentNetAddr, + pDevice->abyPermanentNetAddr, + ETH_ALEN); // if exist SW network address, use SW network address. @@ -712,7 +713,8 @@ static BOOL device_release_WPADEV(PSDevice pDevice) } #ifdef CONFIG_PM /* Minimal support for suspend and resume */ -static int vntwusb_suspend(struct usb_interface *intf, pm_message_t message) + +static int vt6656_suspend(struct usb_interface *intf, pm_message_t message) { PSDevice pDevice = usb_get_intfdata(intf); struct net_device *dev = pDevice->dev; @@ -727,7 +729,7 @@ if(dev != NULL) { return 0; } -static int vntwusb_resume(struct usb_interface *intf) +static int vt6656_resume(struct usb_interface *intf) { PSDevice pDevice = usb_get_intfdata(intf); struct net_device *dev = pDevice->dev; @@ -742,8 +744,8 @@ static int vntwusb_resume(struct usb_interface *intf) } return 0; } -#endif +#endif /* CONFIG_PM */ static const struct net_device_ops device_netdev_ops = { .ndo_open = device_open, @@ -755,10 +757,10 @@ static const struct net_device_ops device_netdev_ops = { }; -static int -vntwusb_found1(struct usb_interface *intf, const struct usb_device_id *id) +static int __devinit +vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id) { - BYTE fake_mac[U_ETHER_ADDR_LEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x01};//fake MAC address + u8 fake_mac[ETH_ALEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x01}; struct usb_device *udev = interface_to_usbdev(intf); int rc = 0; struct net_device *netdev = NULL; @@ -799,7 +801,7 @@ vntwusb_found1(struct usb_interface *intf, const struct usb_device_id *id) //2007-0821-01<Add>by MikeLiu usb_set_intfdata(intf, pDevice); SET_NETDEV_DEV(netdev, &intf->dev); - memcpy(pDevice->dev->dev_addr, fake_mac, U_ETHER_ADDR_LEN); //use fake mac address + memcpy(pDevice->dev->dev_addr, fake_mac, ETH_ALEN); rc = register_netdev(netdev); if (rc != 0) { printk(KERN_ERR DEVICE_NAME " Failed to register netdev\n"); @@ -1102,8 +1104,8 @@ static int device_open(struct net_device *dev) { // Init for Key Management KeyvInitTable(pDevice,&pDevice->sKey); - memcpy(pDevice->sMgmtObj.abyMACAddr, pDevice->abyCurrentNetAddr, U_ETHER_ADDR_LEN); - memcpy(pDevice->dev->dev_addr, pDevice->abyCurrentNetAddr, U_ETHER_ADDR_LEN); + memcpy(pDevice->sMgmtObj.abyMACAddr, pDevice->abyCurrentNetAddr, ETH_ALEN); + memcpy(pDevice->dev->dev_addr, pDevice->abyCurrentNetAddr, ETH_ALEN); pDevice->bStopTx0Pkt = FALSE; pDevice->bStopDataPkt = FALSE; pDevice->bRoaming = FALSE; //DavidWang @@ -1285,8 +1287,7 @@ device_release_WPADEV(pDevice); } -static void vntwusb_disconnect(struct usb_interface *intf) - +static void __devexit vt6656_disconnect(struct usb_interface *intf) { PSDevice pDevice = usb_get_intfdata(intf); @@ -1434,7 +1435,8 @@ static int Config_FileGetParameter(UCHAR *string, UCHAR *dest,UCHAR *source) source+=strlen(buf1); //find target string start point - if((start_p = kstrstr(source,buf1))==NULL) + start_p = kstrstr(source,buf1); + if (start_p == NULL) return FALSE; //check if current config line is marked by "#" ?? @@ -1446,7 +1448,8 @@ for(ii=1;;ii++) { } //find target string end point - if((end_p = kstrstr(start_p,"\n"))==NULL) { //cann't find "\n",but don't care + end_p = kstrstr(start_p,"\n"); + if (end_p == NULL) { //can't find "\n",but don't care end_p=start_p+strlen(start_p); //no include "\n" } @@ -1455,7 +1458,8 @@ for(ii=1;;ii++) { buf2[end_p-start_p]='\0'; //find value - if((start_p = kstrstr(buf2,"="))==NULL) + start_p = kstrstr(buf2,"="); + if (start_p == NULL) return FALSE; memset(buf1,0,100); strcpy(buf1,start_p+1); @@ -1548,7 +1552,8 @@ static int Read_config_file(PSDevice pDevice) { pDevice->config_file.eAuthenMode = -1; pDevice->config_file.eEncryptionStatus = -1; - if((buffer=Config_FileOperation(pDevice)) ==NULL) { + buffer = Config_FileOperation(pDevice); + if (buffer == NULL) { result =-1; return result; } @@ -2064,7 +2069,7 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { rc = 0; } - rc = hostap_ioctl(pDevice, &wrq->u.data); + rc = vt6656_hostap_ioctl(pDevice, &wrq->u.data); break; case IOCTL_CMD_WPA: @@ -2153,35 +2158,29 @@ static int ethtool_ioctl(struct net_device *dev, void *useraddr) /*------------------------------------------------------------------*/ +MODULE_DEVICE_TABLE(usb, vt6656_table); -MODULE_DEVICE_TABLE(usb, vntwusb_table); - - -static struct usb_driver vntwusb_driver = { - .name = DEVICE_NAME, - .probe = vntwusb_found1, - .disconnect = vntwusb_disconnect, - .id_table = vntwusb_table, - -//2008-0920-01<Add>by MikeLiu -//for supporting S3 & S4 function +static struct usb_driver vt6656_driver = { + .name = DEVICE_NAME, + .probe = vt6656_probe, + .disconnect = vt6656_disconnect, + .id_table = vt6656_table, #ifdef CONFIG_PM - .suspend = vntwusb_suspend, - .resume = vntwusb_resume, -#endif + .suspend = vt6656_suspend, + .resume = vt6656_resume, +#endif /* CONFIG_PM */ }; -static int __init vntwusb_init_module(void) +static int __init vt6656_init_module(void) { printk(KERN_NOTICE DEVICE_FULL_DRV_NAM " " DEVICE_VERSION); - return usb_register(&vntwusb_driver); + return usb_register(&vt6656_driver); } -static void __exit vntwusb_cleanup_module(void) +static void __exit vt6656_cleanup_module(void) { - usb_deregister(&vntwusb_driver); + usb_deregister(&vt6656_driver); } -module_init(vntwusb_init_module); -module_exit(vntwusb_cleanup_module); - +module_init(vt6656_init_module); +module_exit(vt6656_cleanup_module); diff --git a/drivers/staging/vt6656/mib.c b/drivers/staging/vt6656/mib.c index 910e610b7cc0..b6f138efb472 100644 --- a/drivers/staging/vt6656/mib.c +++ b/drivers/staging/vt6656/mib.c @@ -156,18 +156,17 @@ void STAvUpdateRDStatCounter (PSStatCounter pStatistic, BYTE byRSR, BYTE byNewRSR, BYTE byRxSts, BYTE byRxRate, PBYTE pbyBuffer, UINT cbFrameLength) { - //need change - PS802_11Header pHeader = (PS802_11Header)pbyBuffer; + /* need change */ + PS802_11Header pHeader = (PS802_11Header)pbyBuffer; - if (byRSR & RSR_ADDROK) - pStatistic->dwRsrADDROk++; - if (byRSR & RSR_CRCOK) { - pStatistic->dwRsrCRCOk++; + if (byRSR & RSR_ADDROK) + pStatistic->dwRsrADDROk++; + if (byRSR & RSR_CRCOK) { + pStatistic->dwRsrCRCOk++; + pStatistic->ullRsrOK++; - pStatistic->ullRsrOK++; - - if (cbFrameLength >= U_ETHER_ADDR_LEN) { - // update counters in case that successful transmit + if (cbFrameLength >= ETH_ALEN) { + /* update counters in case of successful transmission */ if (byRSR & RSR_ADDRBROAD) { pStatistic->ullRxBroadcastFrames++; pStatistic->ullRxBroadcastBytes += (ULONGLONG)cbFrameLength; diff --git a/drivers/staging/vt6656/mib.h b/drivers/staging/vt6656/mib.h index ac996d2cd911..d1d781774ca8 100644 --- a/drivers/staging/vt6656/mib.h +++ b/drivers/staging/vt6656/mib.h @@ -91,7 +91,7 @@ typedef struct tagSMib2Counter { LONG ifType; LONG ifMtu; DWORD ifSpeed; - BYTE ifPhysAddress[U_ETHER_ADDR_LEN]; + BYTE ifPhysAddress[ETH_ALEN]; LONG ifAdminStatus; LONG ifOperStatus; DWORD ifLastChange; @@ -231,7 +231,7 @@ typedef struct tagSTxPktInfo { BYTE byBroadMultiUni; WORD wLength; WORD wFIFOCtl; - BYTE abyDestAddr[U_ETHER_ADDR_LEN]; + BYTE abyDestAddr[ETH_ALEN]; } STxPktInfo, *PSTxPktInfo; diff --git a/drivers/staging/vt6656/michael.c b/drivers/staging/vt6656/michael.c index c930e0cdb853..d4c08209a17f 100644 --- a/drivers/staging/vt6656/michael.c +++ b/drivers/staging/vt6656/michael.c @@ -48,20 +48,23 @@ /*--------------------- Static Functions --------------------------*/ /* -static DWORD s_dwGetUINT32(BYTE * p); // Get DWORD from 4 bytes LSByte first -static VOID s_vPutUINT32(BYTE* p, DWORD val); // Put DWORD into 4 bytes LSByte first -*/ -static VOID s_vClear(void); // Clear the internal message, - // resets the object to the state just after construction. + * static DWORD s_dwGetUINT32(BYTE * p); Get DWORD from + * 4 bytes LSByte first + * static VOID s_vPutUINT32(BYTE* p, DWORD val); Put DWORD into + * 4 bytes LSByte first + */ +static VOID s_vClear(void); /* Clear the internal message, + * resets the object to the + * state just after construction. */ static VOID s_vSetKey(DWORD dwK0, DWORD dwK1); -static VOID s_vAppendByte(BYTE b); // Add a single byte to the internal message +static VOID s_vAppendByte(BYTE b); /* Add a single byte to the internal + * message */ /*--------------------- Export Variables --------------------------*/ -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 DWORD L, R; /* Current state */ +static DWORD K0, K1; /* Key */ +static DWORD M; /* Message accumulator (single word) */ +static UINT nBytesInM; /* # bytes in M */ /*--------------------- Export Functions --------------------------*/ @@ -69,113 +72,105 @@ static UINT nBytesInM; // # bytes in M static DWORD s_dwGetUINT32 (BYTE * p) // Convert from BYTE[] to DWORD in a portable way { - DWORD res = 0; - UINT i; - for(i=0; i<4; i++ ) - { - res |= (*p++) << (8*i); - } - return res; + DWORD res = 0; + UINT i; + for(i=0; i<4; i++ ) + res |= (*p++) << (8*i); + return res; } static VOID s_vPutUINT32 (BYTE* p, DWORD val) // Convert from DWORD to BYTE[] in a portable way { - UINT i; - for(i=0; i<4; i++ ) - { - *p++ = (BYTE) (val & 0xff); - val >>= 8; - } + UINT i; + for(i=0; i<4; i++ ) { + *p++ = (BYTE) (val & 0xff); + val >>= 8; + } } */ -static VOID s_vClear (void) +static VOID s_vClear(void) { - // Reset the state to the empty message. - L = K0; - R = K1; - nBytesInM = 0; - M = 0; + /* Reset the state to the empty message. */ + L = K0; + R = K1; + nBytesInM = 0; + M = 0; } -static VOID s_vSetKey (DWORD dwK0, DWORD dwK1) +static VOID s_vSetKey(DWORD dwK0, DWORD dwK1) { - // Set the key - K0 = dwK0; - K1 = dwK1; - // and reset the message - s_vClear(); + /* Set the key */ + K0 = dwK0; + K1 = dwK1; + /* and reset the message */ + s_vClear(); } -static VOID s_vAppendByte (BYTE b) +static VOID s_vAppendByte(BYTE b) { - // Append the byte to our word-sized buffer - M |= b << (8*nBytesInM); - nBytesInM++; - // Process the word if it is full. - if( nBytesInM >= 4 ) - { - L ^= M; - R ^= ROL32( L, 17 ); - L += R; - R ^= ((L & 0xff00ff00) >> 8) | ((L & 0x00ff00ff) << 8); - L += R; - R ^= ROL32( L, 3 ); - L += R; - R ^= ROR32( L, 2 ); - L += R; - // Clear the buffer - M = 0; - nBytesInM = 0; - } + /* Append the byte to our word-sized buffer */ + M |= b << (8*nBytesInM); + nBytesInM++; + /* Process the word if it is full. */ + if (nBytesInM >= 4) { + L ^= M; + R ^= ROL32(L, 17); + L += R; + R ^= ((L & 0xff00ff00) >> 8) | ((L & 0x00ff00ff) << 8); + L += R; + R ^= ROL32(L, 3); + L += R; + R ^= ROR32(L, 2); + L += R; + /* Clear the buffer */ + M = 0; + nBytesInM = 0; + } } -VOID MIC_vInit (DWORD dwK0, DWORD dwK1) +VOID MIC_vInit(DWORD dwK0, DWORD dwK1) { - // Set the key - s_vSetKey(dwK0, dwK1); + /* Set the key */ + s_vSetKey(dwK0, dwK1); } -VOID MIC_vUnInit (void) +VOID MIC_vUnInit(void) { - // Wipe the key material - K0 = 0; - K1 = 0; + /* Wipe the key material */ + K0 = 0; + K1 = 0; - // And the other fields as well. - //Note that this sets (L,R) to (K0,K1) which is just fine. - s_vClear(); + /* And the other fields as well. */ + /* Note that this sets (L,R) to (K0,K1) which is just fine. */ + s_vClear(); } -VOID MIC_vAppend (PBYTE src, UINT nBytes) +VOID MIC_vAppend(PBYTE src, UINT nBytes) { - // This is simple - while (nBytes > 0) - { - s_vAppendByte(*src++); - nBytes--; - } + /* This is simple */ + while (nBytes > 0) { + s_vAppendByte(*src++); + nBytes--; + } } -VOID MIC_vGetMIC (PDWORD pdwL, PDWORD pdwR) +VOID MIC_vGetMIC(PDWORD pdwL, PDWORD pdwR) { - // Append the minimum padding - s_vAppendByte(0x5a); - s_vAppendByte(0); - s_vAppendByte(0); - s_vAppendByte(0); - s_vAppendByte(0); - // and then zeroes until the length is a multiple of 4 - while( nBytesInM != 0 ) - { - s_vAppendByte(0); - } - // The s_vAppendByte function has already computed the result. - *pdwL = L; - *pdwR = R; - // Reset to the empty message. - s_vClear(); + /* Append the minimum padding */ + s_vAppendByte(0x5a); + s_vAppendByte(0); + s_vAppendByte(0); + s_vAppendByte(0); + s_vAppendByte(0); + /* and then zeroes until the length is a multiple of 4 */ + while (nBytesInM != 0) + s_vAppendByte(0); + /* The s_vAppendByte function has already computed the result. */ + *pdwL = L; + *pdwR = R; + /* Reset to the empty message. */ + s_vClear(); } - diff --git a/drivers/staging/vt6656/power.c b/drivers/staging/vt6656/power.c index b5702b098e18..e50093e355a9 100644 --- a/drivers/staging/vt6656/power.c +++ b/drivers/staging/vt6656/power.c @@ -78,8 +78,8 @@ static int msglevel =MSG_LEVEL_INFO; VOID PSvEnablePowerSaving( - IN HANDLE hDeviceContext, - IN WORD wListenInterval + HANDLE hDeviceContext, + WORD wListenInterval ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -156,7 +156,7 @@ PSvEnablePowerSaving( VOID PSvDisablePowerSaving( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -201,9 +201,9 @@ PSvDisablePowerSaving( BOOL PSbConsiderPowerDown( - IN HANDLE hDeviceContext, - IN BOOL bCheckRxDMA, - IN BOOL bCheckCountToWakeUp + HANDLE hDeviceContext, + BOOL bCheckRxDMA, + BOOL bCheckCountToWakeUp ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -264,7 +264,7 @@ PSbConsiderPowerDown( VOID PSvSendPSPOLL( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -310,7 +310,7 @@ PSvSendPSPOLL( -*/ BOOL PSbSendNullPacket( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -390,7 +390,7 @@ PSbSendNullPacket( BOOL PSbIsNextTBTTWakeUp( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ) { diff --git a/drivers/staging/vt6656/power.h b/drivers/staging/vt6656/power.h index c33c93a86f5e..0a14811ced97 100644 --- a/drivers/staging/vt6656/power.h +++ b/drivers/staging/vt6656/power.h @@ -45,40 +45,40 @@ /*--------------------- Export Functions --------------------------*/ -// IN PSDevice pDevice -// IN PSDevice hDeviceContext +/* PSDevice pDevice */ +/* PSDevice hDeviceContext */ BOOL PSbConsiderPowerDown( - IN HANDLE hDeviceContext, - IN BOOL bCheckRxDMA, - IN BOOL bCheckCountToWakeUp + HANDLE hDeviceContext, + BOOL bCheckRxDMA, + BOOL bCheckCountToWakeUp ); VOID PSvDisablePowerSaving( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ); VOID PSvEnablePowerSaving( - IN HANDLE hDeviceContext, - IN WORD wListenInterval + HANDLE hDeviceContext, + WORD wListenInterval ); VOID PSvSendPSPOLL( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ); BOOL PSbSendNullPacket( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ); BOOL PSbIsNextTBTTWakeUp( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ); #endif //__POWER_H__ diff --git a/drivers/staging/vt6656/rc4.c b/drivers/staging/vt6656/rc4.c index e6c61312fd28..64c419df9321 100644 --- a/drivers/staging/vt6656/rc4.c +++ b/drivers/staging/vt6656/rc4.c @@ -34,54 +34,54 @@ VOID rc4_init(PRC4Ext pRC4, PBYTE pbyKey, UINT cbKey_len) { - UINT ust1, ust2; - UINT keyindex; - UINT stateindex; - PBYTE pbyst; - UINT idx; + UINT ust1, ust2; + UINT keyindex; + UINT stateindex; + PBYTE pbyst; + UINT idx; - pbyst = pRC4->abystate; - pRC4->ux = 0; - pRC4->uy = 0; - for (idx = 0; idx < 256; idx++) - pbyst[idx] = (BYTE)idx; - keyindex = 0; - stateindex = 0; - for (idx = 0; idx < 256; idx++) { - ust1 = pbyst[idx]; - stateindex = (stateindex + pbyKey[keyindex] + ust1) & 0xff; - ust2 = pbyst[stateindex]; - pbyst[stateindex] = (BYTE)ust1; - pbyst[idx] = (BYTE)ust2; - if (++keyindex >= cbKey_len) - keyindex = 0; - } + pbyst = pRC4->abystate; + pRC4->ux = 0; + pRC4->uy = 0; + for (idx = 0; idx < 256; idx++) + pbyst[idx] = (BYTE)idx; + keyindex = 0; + stateindex = 0; + for (idx = 0; idx < 256; idx++) { + ust1 = pbyst[idx]; + stateindex = (stateindex + pbyKey[keyindex] + ust1) & 0xff; + ust2 = pbyst[stateindex]; + pbyst[stateindex] = (BYTE)ust1; + pbyst[idx] = (BYTE)ust2; + if (++keyindex >= cbKey_len) + keyindex = 0; + } } UINT rc4_byte(PRC4Ext pRC4) { - UINT ux; - UINT uy; - UINT ustx, usty; - PBYTE pbyst; + UINT ux; + UINT uy; + UINT ustx, usty; + PBYTE pbyst; - pbyst = pRC4->abystate; - ux = (pRC4->ux + 1) & 0xff; - ustx = pbyst[ux]; - uy = (ustx + pRC4->uy) & 0xff; - usty = pbyst[uy]; - pRC4->ux = ux; - pRC4->uy = uy; - pbyst[uy] = (BYTE)ustx; - pbyst[ux] = (BYTE)usty; + pbyst = pRC4->abystate; + ux = (pRC4->ux + 1) & 0xff; + ustx = pbyst[ux]; + uy = (ustx + pRC4->uy) & 0xff; + usty = pbyst[uy]; + pRC4->ux = ux; + pRC4->uy = uy; + pbyst[uy] = (BYTE)ustx; + pbyst[ux] = (BYTE)usty; - return pbyst[(ustx + usty) & 0xff]; + return pbyst[(ustx + usty) & 0xff]; } VOID rc4_encrypt(PRC4Ext pRC4, PBYTE pbyDest, - PBYTE pbySrc, UINT cbData_len) + PBYTE pbySrc, UINT cbData_len) { - UINT ii; - for (ii = 0; ii < cbData_len; ii++) - pbyDest[ii] = (BYTE)(pbySrc[ii] ^ rc4_byte(pRC4)); + UINT ii; + for (ii = 0; ii < cbData_len; ii++) + pbyDest[ii] = (BYTE)(pbySrc[ii] ^ rc4_byte(pRC4)); } diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index 405c4f71b5fd..d69925ff469b 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -757,9 +757,9 @@ BOOL IFRFbWriteEmbeded (PSDevice pDevice, DWORD dwData) * */ BOOL RFbSetPower ( - IN PSDevice pDevice, - IN UINT uRATE, - IN UINT uCH + PSDevice pDevice, + UINT uRATE, + UINT uCH ) { BOOL bResult = TRUE; @@ -811,9 +811,9 @@ BYTE byPwr = pDevice->byCCKPwr; * */ BOOL RFbRawSetPower ( - IN PSDevice pDevice, - IN BYTE byPwr, - IN UINT uRATE + PSDevice pDevice, + BYTE byPwr, + UINT uRATE ) { BOOL bResult = TRUE; @@ -956,8 +956,8 @@ BOOL bResult = TRUE; -*/ VOID RFvRSSITodBm ( - IN PSDevice pDevice, - IN BYTE byCurrRSSI, + PSDevice pDevice, + BYTE byCurrRSSI, long * pldBm ) { @@ -986,7 +986,7 @@ RFvRSSITodBm ( VOID RFbRFTableDownload ( - IN PSDevice pDevice + PSDevice pDevice ) { WORD wLength1 = 0,wLength2 = 0 ,wLength3 = 0; @@ -1133,9 +1133,9 @@ BYTE abyArray[256]; // RobertYu:20060412, TWIF1.11 adjust LO Current for 11b mode BOOL s_bVT3226D0_11bLoCurrentAdjust( - IN PSDevice pDevice, - IN BYTE byChannel, - IN BOOL b11bMode ) + PSDevice pDevice, + BYTE byChannel, + BOOL b11bMode) { BOOL bResult; diff --git a/drivers/staging/vt6656/rf.h b/drivers/staging/vt6656/rf.h index 55d882f78f20..22159869364e 100644 --- a/drivers/staging/vt6656/rf.h +++ b/drivers/staging/vt6656/rf.h @@ -65,33 +65,33 @@ extern const BYTE RFaby11aChannelIndex[200]; BOOL IFRFbWriteEmbeded(PSDevice pDevice, DWORD dwData); BOOL RFbSetPower ( - IN PSDevice pDevice, - IN UINT uRATE, - IN UINT uCH + PSDevice pDevice, + UINT uRATE, + UINT uCH ); BOOL RFbRawSetPower( - IN PSDevice pDevice, - IN BYTE byPwr, - IN UINT uRATE + PSDevice pDevice, + BYTE byPwr, + UINT uRATE ); VOID RFvRSSITodBm ( - IN PSDevice pDevice, - IN BYTE byCurrRSSI, + PSDevice pDevice, + BYTE byCurrRSSI, long * pldBm ); VOID RFbRFTableDownload ( - IN PSDevice pDevice + PSDevice pDevice ); BOOL s_bVT3226D0_11bLoCurrentAdjust( - IN PSDevice pDevice, - IN BYTE byChannel, - IN BOOL b11bMode + PSDevice pDevice, + BYTE byChannel, + BOOL b11bMode ); #endif // __RF_H__ diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index a2ce6fad8ee5..a8a32bbe005a 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -115,11 +115,11 @@ const WORD wFB_Opt1[2][5] = { static VOID s_vSaveTxPktInfo( - IN PSDevice pDevice, - IN BYTE byPktNum, - IN PBYTE pbyDestAddr, - IN WORD wPktLength, - IN WORD wFIFOCtl + PSDevice pDevice, + BYTE byPktNum, + PBYTE pbyDestAddr, + WORD wPktLength, + WORD wFIFOCtl ); static @@ -132,34 +132,34 @@ s_vGetFreeContext( static VOID s_vGenerateTxParameter( - IN PSDevice pDevice, - IN BYTE byPktType, - IN WORD wCurrentRate, - IN PVOID pTxBufHead, - IN PVOID pvRrvTime, - IN PVOID pvRTS, - IN PVOID pvCTS, - IN UINT cbFrameSize, - IN BOOL bNeedACK, - IN UINT uDMAIdx, - IN PSEthernetHeader psEthHeader + PSDevice pDevice, + BYTE byPktType, + WORD wCurrentRate, + PVOID pTxBufHead, + PVOID pvRrvTime, + PVOID pvRTS, + PVOID pvCTS, + UINT cbFrameSize, + BOOL bNeedACK, + UINT uDMAIdx, + PSEthernetHeader psEthHeader ); static UINT s_uFillDataHead ( - IN PSDevice pDevice, - IN BYTE byPktType, - IN WORD wCurrentRate, - IN PVOID pTxDataHead, - IN UINT cbFrameLength, - IN UINT uDMAIdx, - IN BOOL bNeedAck, - IN UINT uFragIdx, - IN UINT cbLastFragmentSize, - IN UINT uMACfragNum, - IN BYTE byFBOption + PSDevice pDevice, + BYTE byPktType, + WORD wCurrentRate, + PVOID pTxDataHead, + UINT cbFrameLength, + UINT uDMAIdx, + BOOL bNeedAck, + UINT uFragIdx, + UINT cbLastFragmentSize, + UINT uMACfragNum, + BYTE byFBOption ); @@ -168,112 +168,112 @@ s_uFillDataHead ( static VOID s_vGenerateMACHeader ( - IN PSDevice pDevice, - IN PBYTE pbyBufferAddr, - IN WORD wDuration, - IN PSEthernetHeader psEthHeader, - IN BOOL bNeedEncrypt, - IN WORD wFragType, - IN UINT uDMAIdx, - IN UINT uFragIdx + PSDevice pDevice, + PBYTE pbyBufferAddr, + WORD wDuration, + PSEthernetHeader psEthHeader, + BOOL bNeedEncrypt, + WORD wFragType, + UINT uDMAIdx, + UINT uFragIdx ); static VOID s_vFillTxKey( - IN PSDevice pDevice, - IN PBYTE pbyBuf, - IN PBYTE pbyIVHead, - IN PSKeyItem pTransmitKey, - IN PBYTE pbyHdrBuf, - IN WORD wPayloadLen, + PSDevice pDevice, + PBYTE pbyBuf, + PBYTE pbyIVHead, + PSKeyItem pTransmitKey, + PBYTE pbyHdrBuf, + WORD wPayloadLen, OUT PBYTE pMICHDR ); static VOID s_vSWencryption ( - IN PSDevice pDevice, - IN PSKeyItem pTransmitKey, - IN PBYTE pbyPayloadHead, - IN WORD wPayloadSize + PSDevice pDevice, + PSKeyItem pTransmitKey, + PBYTE pbyPayloadHead, + WORD wPayloadSize ); static UINT s_uGetTxRsvTime ( - IN PSDevice pDevice, - IN BYTE byPktType, - IN UINT cbFrameLength, - IN WORD wRate, - IN BOOL bNeedAck + PSDevice pDevice, + BYTE byPktType, + UINT cbFrameLength, + WORD wRate, + BOOL bNeedAck ); static UINT s_uGetRTSCTSRsvTime ( - IN PSDevice pDevice, - IN BYTE byRTSRsvType, - IN BYTE byPktType, - IN UINT cbFrameLength, - IN WORD wCurrentRate + PSDevice pDevice, + BYTE byRTSRsvType, + BYTE byPktType, + UINT cbFrameLength, + WORD wCurrentRate ); static VOID s_vFillCTSHead ( - IN PSDevice pDevice, - IN UINT uDMAIdx, - IN BYTE byPktType, - IN PVOID pvCTS, - IN UINT cbFrameLength, - IN BOOL bNeedAck, - IN BOOL bDisCRC, - IN WORD wCurrentRate, - IN BYTE byFBOption + PSDevice pDevice, + UINT uDMAIdx, + BYTE byPktType, + PVOID pvCTS, + UINT cbFrameLength, + BOOL bNeedAck, + BOOL bDisCRC, + WORD wCurrentRate, + BYTE byFBOption ); static VOID s_vFillRTSHead( - IN PSDevice pDevice, - IN BYTE byPktType, - IN PVOID pvRTS, - IN UINT cbFrameLength, - IN BOOL bNeedAck, - IN BOOL bDisCRC, - IN PSEthernetHeader psEthHeader, - IN WORD wCurrentRate, - IN BYTE byFBOption + PSDevice pDevice, + BYTE byPktType, + PVOID pvRTS, + UINT cbFrameLength, + BOOL bNeedAck, + BOOL bDisCRC, + PSEthernetHeader psEthHeader, + WORD wCurrentRate, + BYTE byFBOption ); static UINT s_uGetDataDuration ( - IN PSDevice pDevice, - IN BYTE byDurType, - IN UINT cbFrameLength, - IN BYTE byPktType, - IN WORD wRate, - IN BOOL bNeedAck, - IN UINT uFragIdx, - IN UINT cbLastFragmentSize, - IN UINT uMACfragNum, - IN BYTE byFBOption + PSDevice pDevice, + BYTE byDurType, + UINT cbFrameLength, + BYTE byPktType, + WORD wRate, + BOOL bNeedAck, + UINT uFragIdx, + UINT cbLastFragmentSize, + UINT uMACfragNum, + BYTE byFBOption ); static UINT s_uGetRTSCTSDuration ( - IN PSDevice pDevice, - IN BYTE byDurType, - IN UINT cbFrameLength, - IN BYTE byPktType, - IN WORD wRate, - IN BOOL bNeedAck, - IN BYTE byFBOption + PSDevice pDevice, + BYTE byDurType, + UINT cbFrameLength, + BYTE byPktType, + WORD wRate, + BOOL bNeedAck, + BYTE byFBOption ); @@ -322,7 +322,9 @@ s_vSaveTxPktInfo(PSDevice pDevice, BYTE byPktNum, PBYTE pbyDestAddr, WORD wPktLe pStatistic->abyTxPktInfo[byPktNum].wLength = wPktLength; pStatistic->abyTxPktInfo[byPktNum].wFIFOCtl = wFIFOCtl; - memcpy(pStatistic->abyTxPktInfo[byPktNum].abyDestAddr, pbyDestAddr, U_ETHER_ADDR_LEN); + memcpy(pStatistic->abyTxPktInfo[byPktNum].abyDestAddr, + pbyDestAddr, + ETH_ALEN); } @@ -331,12 +333,12 @@ s_vSaveTxPktInfo(PSDevice pDevice, BYTE byPktNum, PBYTE pbyDestAddr, WORD wPktLe static VOID s_vFillTxKey ( - IN PSDevice pDevice, - IN PBYTE pbyBuf, - IN PBYTE pbyIVHead, - IN PSKeyItem pTransmitKey, - IN PBYTE pbyHdrBuf, - IN WORD wPayloadLen, + PSDevice pDevice, + PBYTE pbyBuf, + PBYTE pbyIVHead, + PSKeyItem pTransmitKey, + PBYTE pbyHdrBuf, + WORD wPayloadLen, OUT PBYTE pMICHDR ) { @@ -448,10 +450,10 @@ s_vFillTxKey ( static VOID s_vSWencryption ( - IN PSDevice pDevice, - IN PSKeyItem pTransmitKey, - IN PBYTE pbyPayloadHead, - IN WORD wPayloadSize + PSDevice pDevice, + PSKeyItem pTransmitKey, + PBYTE pbyPayloadHead, + WORD wPayloadSize ) { UINT cbICVlen = 4; @@ -497,11 +499,11 @@ s_vSWencryption ( static UINT s_uGetTxRsvTime ( - IN PSDevice pDevice, - IN BYTE byPktType, - IN UINT cbFrameLength, - IN WORD wRate, - IN BOOL bNeedAck + PSDevice pDevice, + BYTE byPktType, + UINT cbFrameLength, + WORD wRate, + BOOL bNeedAck ) { UINT uDataTime, uAckTime; @@ -525,11 +527,11 @@ s_uGetTxRsvTime ( static UINT s_uGetRTSCTSRsvTime ( - IN PSDevice pDevice, - IN BYTE byRTSRsvType, - IN BYTE byPktType, - IN UINT cbFrameLength, - IN WORD wCurrentRate + PSDevice pDevice, + BYTE byRTSRsvType, + BYTE byPktType, + UINT cbFrameLength, + WORD wCurrentRate ) { UINT uRrvTime , uRTSTime, uCTSTime, uAckTime, uDataTime; @@ -567,16 +569,16 @@ s_uGetRTSCTSRsvTime ( static UINT s_uGetDataDuration ( - IN PSDevice pDevice, - IN BYTE byDurType, - IN UINT cbFrameLength, - IN BYTE byPktType, - IN WORD wRate, - IN BOOL bNeedAck, - IN UINT uFragIdx, - IN UINT cbLastFragmentSize, - IN UINT uMACfragNum, - IN BYTE byFBOption + PSDevice pDevice, + BYTE byDurType, + UINT cbFrameLength, + BYTE byPktType, + WORD wRate, + BOOL bNeedAck, + UINT uFragIdx, + UINT cbLastFragmentSize, + UINT uMACfragNum, + BYTE byFBOption ) { BOOL bLastFrag = 0; @@ -737,13 +739,13 @@ s_uGetDataDuration ( static UINT s_uGetRTSCTSDuration ( - IN PSDevice pDevice, - IN BYTE byDurType, - IN UINT cbFrameLength, - IN BYTE byPktType, - IN WORD wRate, - IN BOOL bNeedAck, - IN BYTE byFBOption + PSDevice pDevice, + BYTE byDurType, + UINT cbFrameLength, + BYTE byPktType, + WORD wRate, + BOOL bNeedAck, + BYTE byFBOption ) { UINT uCTSTime = 0, uDurTime = 0; @@ -836,17 +838,17 @@ s_uGetRTSCTSDuration ( static UINT s_uFillDataHead ( - IN PSDevice pDevice, - IN BYTE byPktType, - IN WORD wCurrentRate, - IN PVOID pTxDataHead, - IN UINT cbFrameLength, - IN UINT uDMAIdx, - IN BOOL bNeedAck, - IN UINT uFragIdx, - IN UINT cbLastFragmentSize, - IN UINT uMACfragNum, - IN BYTE byFBOption + PSDevice pDevice, + BYTE byPktType, + WORD wCurrentRate, + PVOID pTxDataHead, + UINT cbFrameLength, + UINT uDMAIdx, + BOOL bNeedAck, + UINT uFragIdx, + UINT cbLastFragmentSize, + UINT uMACfragNum, + BYTE byFBOption ) { @@ -981,15 +983,15 @@ s_uFillDataHead ( static VOID s_vFillRTSHead ( - IN PSDevice pDevice, - IN BYTE byPktType, - IN PVOID pvRTS, - IN UINT cbFrameLength, - IN BOOL bNeedAck, - IN BOOL bDisCRC, - IN PSEthernetHeader psEthHeader, - IN WORD wCurrentRate, - IN BYTE byFBOption + PSDevice pDevice, + BYTE byPktType, + PVOID pvRTS, + UINT cbFrameLength, + BOOL bNeedAck, + BOOL bDisCRC, + PSEthernetHeader psEthHeader, + WORD wCurrentRate, + BYTE byFBOption ) { UINT uRTSFrameLen = 20; @@ -1026,18 +1028,27 @@ s_vFillRTSHead ( pBuf->Data.wDurationID = pBuf->wDuration_aa; //Get RTS Frame body pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4 - if ((pDevice->eOPMode == OP_MODE_ADHOC) || - (pDevice->eOPMode == OP_MODE_AP)) { - memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN); - } + + if ((pDevice->eOPMode == OP_MODE_ADHOC) || + (pDevice->eOPMode == OP_MODE_AP)) { + memcpy(&(pBuf->Data.abyRA[0]), + &(psEthHeader->abyDstAddr[0]), + ETH_ALEN); + } else { - memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN); - } - if (pDevice->eOPMode == OP_MODE_AP) { - memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN); - } + memcpy(&(pBuf->Data.abyRA[0]), + &(pDevice->abyBSSID[0]), + ETH_ALEN); + } + if (pDevice->eOPMode == OP_MODE_AP) { + memcpy(&(pBuf->Data.abyTA[0]), + &(pDevice->abyBSSID[0]), + ETH_ALEN); + } else { - memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN); + memcpy(&(pBuf->Data.abyTA[0]), + &(psEthHeader->abySrcAddr[0]), + ETH_ALEN); } } else { @@ -1063,19 +1074,27 @@ s_vFillRTSHead ( //Get RTS Frame body pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4 - if ((pDevice->eOPMode == OP_MODE_ADHOC) || - (pDevice->eOPMode == OP_MODE_AP)) { - memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN); - } + if ((pDevice->eOPMode == OP_MODE_ADHOC) || + (pDevice->eOPMode == OP_MODE_AP)) { + memcpy(&(pBuf->Data.abyRA[0]), + &(psEthHeader->abyDstAddr[0]), + ETH_ALEN); + } else { - memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN); + memcpy(&(pBuf->Data.abyRA[0]), + &(pDevice->abyBSSID[0]), + ETH_ALEN); } - if (pDevice->eOPMode == OP_MODE_AP) { - memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN); - } + if (pDevice->eOPMode == OP_MODE_AP) { + memcpy(&(pBuf->Data.abyTA[0]), + &(pDevice->abyBSSID[0]), + ETH_ALEN); + } else { - memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN); + memcpy(&(pBuf->Data.abyTA[0]), + &(psEthHeader->abySrcAddr[0]), + ETH_ALEN); } } // if (byFBOption == AUTO_FB_NONE) @@ -1094,20 +1113,26 @@ s_vFillRTSHead ( //Get RTS Frame body pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4 - if ((pDevice->eOPMode == OP_MODE_ADHOC) || - (pDevice->eOPMode == OP_MODE_AP)) { - memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN); - } - else { - memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN); - } - - if (pDevice->eOPMode == OP_MODE_AP) { - memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN); - } - else { - memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN); - } + if ((pDevice->eOPMode == OP_MODE_ADHOC) || + (pDevice->eOPMode == OP_MODE_AP)) { + memcpy(&(pBuf->Data.abyRA[0]), + &(psEthHeader->abyDstAddr[0]), + ETH_ALEN); + } else { + memcpy(&(pBuf->Data.abyRA[0]), + &(pDevice->abyBSSID[0]), + ETH_ALEN); + } + + if (pDevice->eOPMode == OP_MODE_AP) { + memcpy(&(pBuf->Data.abyTA[0]), + &(pDevice->abyBSSID[0]), + ETH_ALEN); + } else { + memcpy(&(pBuf->Data.abyTA[0]), + &(psEthHeader->abySrcAddr[0]), + ETH_ALEN); + } } else { @@ -1125,19 +1150,25 @@ s_vFillRTSHead ( //Get RTS Frame body pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4 - if ((pDevice->eOPMode == OP_MODE_ADHOC) || - (pDevice->eOPMode == OP_MODE_AP)) { - memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN); - } - else { - memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN); - } - if (pDevice->eOPMode == OP_MODE_AP) { - memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN); - } - else { - memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN); - } + if ((pDevice->eOPMode == OP_MODE_ADHOC) || + (pDevice->eOPMode == OP_MODE_AP)) { + memcpy(&(pBuf->Data.abyRA[0]), + &(psEthHeader->abyDstAddr[0]), + ETH_ALEN); + } else { + memcpy(&(pBuf->Data.abyRA[0]), + &(pDevice->abyBSSID[0]), + ETH_ALEN); + } + if (pDevice->eOPMode == OP_MODE_AP) { + memcpy(&(pBuf->Data.abyTA[0]), + &(pDevice->abyBSSID[0]), + ETH_ALEN); + } else { + memcpy(&(pBuf->Data.abyTA[0]), + &(psEthHeader->abySrcAddr[0]), + ETH_ALEN); + } } } else if (byPktType == PK_TYPE_11B) { @@ -1153,20 +1184,26 @@ s_vFillRTSHead ( //Get RTS Frame body pBuf->Data.wFrameControl = TYPE_CTL_RTS;//0x00B4 - - if ((pDevice->eOPMode == OP_MODE_ADHOC) || + if ((pDevice->eOPMode == OP_MODE_ADHOC) || (pDevice->eOPMode == OP_MODE_AP)) { - memcpy(&(pBuf->Data.abyRA[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN); + memcpy(&(pBuf->Data.abyRA[0]), + &(psEthHeader->abyDstAddr[0]), + ETH_ALEN); } else { - memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN); + memcpy(&(pBuf->Data.abyRA[0]), + &(pDevice->abyBSSID[0]), + ETH_ALEN); } if (pDevice->eOPMode == OP_MODE_AP) { - memcpy(&(pBuf->Data.abyTA[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN); - } - else { - memcpy(&(pBuf->Data.abyTA[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN); + memcpy(&(pBuf->Data.abyTA[0]), + &(pDevice->abyBSSID[0]), + ETH_ALEN); + } else { + memcpy(&(pBuf->Data.abyTA[0]), + &(psEthHeader->abySrcAddr[0]), + ETH_ALEN); } } } @@ -1174,15 +1211,15 @@ s_vFillRTSHead ( static VOID s_vFillCTSHead ( - IN PSDevice pDevice, - IN UINT uDMAIdx, - IN BYTE byPktType, - IN PVOID pvCTS, - IN UINT cbFrameLength, - IN BOOL bNeedAck, - IN BOOL bDisCRC, - IN WORD wCurrentRate, - IN BYTE byFBOption + PSDevice pDevice, + UINT uDMAIdx, + BYTE byPktType, + PVOID pvCTS, + UINT cbFrameLength, + BOOL bNeedAck, + BOOL bDisCRC, + WORD wCurrentRate, + BYTE byFBOption ) { UINT uCTSFrameLen = 14; @@ -1222,7 +1259,9 @@ s_vFillCTSHead ( pBuf->Data.wDurationID = pBuf->wDuration_ba; pBuf->Data.wFrameControl = TYPE_CTL_CTS;//0x00C4 pBuf->Data.wReserved = 0x0000; - memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyCurrentNetAddr[0]), U_ETHER_ADDR_LEN); + memcpy(&(pBuf->Data.abyRA[0]), + &(pDevice->abyCurrentNetAddr[0]), + ETH_ALEN); } else { //if (byFBOption != AUTO_FB_NONE && uDMAIdx != TYPE_ATIMDMA && uDMAIdx != TYPE_BEACONDMA) PSCTS pBuf = (PSCTS)pvCTS; //Get SignalField,ServiceField,Length @@ -1239,16 +1278,13 @@ s_vFillCTSHead ( pBuf->Data.wDurationID = pBuf->wDuration_ba; pBuf->Data.wFrameControl = TYPE_CTL_CTS;//0x00C4 pBuf->Data.wReserved = 0x0000; - memcpy(&(pBuf->Data.abyRA[0]), &(pDevice->abyCurrentNetAddr[0]), U_ETHER_ADDR_LEN); + memcpy(&(pBuf->Data.abyRA[0]), + &(pDevice->abyCurrentNetAddr[0]), + ETH_ALEN); } } } - - - - - /*+ * * Description: @@ -1275,17 +1311,17 @@ s_vFillCTSHead ( static VOID s_vGenerateTxParameter ( - IN PSDevice pDevice, - IN BYTE byPktType, - IN WORD wCurrentRate, - IN PVOID pTxBufHead, - IN PVOID pvRrvTime, - IN PVOID pvRTS, - IN PVOID pvCTS, - IN UINT cbFrameSize, - IN BOOL bNeedACK, - IN UINT uDMAIdx, - IN PSEthernetHeader psEthHeader + PSDevice pDevice, + BYTE byPktType, + WORD wCurrentRate, + PVOID pTxBufHead, + PVOID pvRrvTime, + PVOID pvRTS, + PVOID pvCTS, + UINT cbFrameSize, + BOOL bNeedACK, + UINT uDMAIdx, + PSEthernetHeader psEthHeader ) { UINT cbMACHdLen = WLAN_HDR_ADDR3_LEN; //24 @@ -1392,17 +1428,17 @@ s_vGenerateTxParameter ( BOOL s_bPacketToWirelessUsb( - IN PSDevice pDevice, - IN BYTE byPktType, - IN PBYTE usbPacketBuf, - IN BOOL bNeedEncryption, - IN UINT uSkbPacketLen, - IN UINT uDMAIdx, - IN PSEthernetHeader psEthHeader, - IN PBYTE pPacket, - IN PSKeyItem pTransmitKey, - IN UINT uNodeIndex, - IN WORD wCurrentRate, + PSDevice pDevice, + BYTE byPktType, + PBYTE usbPacketBuf, + BOOL bNeedEncryption, + UINT uSkbPacketLen, + UINT uDMAIdx, + PSEthernetHeader psEthHeader, + PBYTE pPacket, + PSKeyItem pTransmitKey, + UINT uNodeIndex, + WORD wCurrentRate, OUT UINT *pcbHeaderLen, OUT UINT *pcbTotalLen ) @@ -1822,14 +1858,14 @@ s_bPacketToWirelessUsb( VOID s_vGenerateMACHeader ( - IN PSDevice pDevice, - IN PBYTE pbyBufferAddr, - IN WORD wDuration, - IN PSEthernetHeader psEthHeader, - IN BOOL bNeedEncrypt, - IN WORD wFragType, - IN UINT uDMAIdx, - IN UINT uFragIdx + PSDevice pDevice, + PBYTE pbyBufferAddr, + WORD wDuration, + PSEthernetHeader psEthHeader, + BOOL bNeedEncrypt, + WORD wFragType, + UINT uDMAIdx, + UINT uFragIdx ) { PS802_11Header pMACHeader = (PS802_11Header)pbyBufferAddr; @@ -1843,21 +1879,35 @@ s_vGenerateMACHeader ( } if (pDevice->eOPMode == OP_MODE_AP) { - memcpy(&(pMACHeader->abyAddr1[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN); - memcpy(&(pMACHeader->abyAddr2[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN); - memcpy(&(pMACHeader->abyAddr3[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN); + memcpy(&(pMACHeader->abyAddr1[0]), + &(psEthHeader->abyDstAddr[0]), + ETH_ALEN); + memcpy(&(pMACHeader->abyAddr2[0]), &(pDevice->abyBSSID[0]), ETH_ALEN); + memcpy(&(pMACHeader->abyAddr3[0]), + &(psEthHeader->abySrcAddr[0]), + ETH_ALEN); pMACHeader->wFrameCtl |= FC_FROMDS; - } - else { - if (pDevice->eOPMode == OP_MODE_ADHOC) { - memcpy(&(pMACHeader->abyAddr1[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN); - memcpy(&(pMACHeader->abyAddr2[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN); - memcpy(&(pMACHeader->abyAddr3[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN); - } - else { - memcpy(&(pMACHeader->abyAddr3[0]), &(psEthHeader->abyDstAddr[0]), U_ETHER_ADDR_LEN); - memcpy(&(pMACHeader->abyAddr2[0]), &(psEthHeader->abySrcAddr[0]), U_ETHER_ADDR_LEN); - memcpy(&(pMACHeader->abyAddr1[0]), &(pDevice->abyBSSID[0]), U_ETHER_ADDR_LEN); + } else { + if (pDevice->eOPMode == OP_MODE_ADHOC) { + memcpy(&(pMACHeader->abyAddr1[0]), + &(psEthHeader->abyDstAddr[0]), + ETH_ALEN); + memcpy(&(pMACHeader->abyAddr2[0]), + &(psEthHeader->abySrcAddr[0]), + ETH_ALEN); + memcpy(&(pMACHeader->abyAddr3[0]), + &(pDevice->abyBSSID[0]), + ETH_ALEN); + } else { + memcpy(&(pMACHeader->abyAddr3[0]), + &(psEthHeader->abyDstAddr[0]), + ETH_ALEN); + memcpy(&(pMACHeader->abyAddr2[0]), + &(psEthHeader->abySrcAddr[0]), + ETH_ALEN); + memcpy(&(pMACHeader->abyAddr1[0]), + &(pDevice->abyBSSID[0]), + ETH_ALEN); pMACHeader->wFrameCtl |= FC_TODS; } } @@ -1908,8 +1958,8 @@ s_vGenerateMACHeader ( -*/ CMD_STATUS csMgmt_xmit( - IN PSDevice pDevice, - IN PSTxMgmtPacket pPacket + PSDevice pDevice, + PSTxMgmtPacket pPacket ) { BYTE byPktType; @@ -2089,8 +2139,12 @@ CMD_STATUS csMgmt_xmit( memset((PVOID)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderSize - wTxBufSize)); - memcpy(&(sEthHeader.abyDstAddr[0]), &(pPacket->p80211Header->sA3.abyAddr1[0]), U_ETHER_ADDR_LEN); - memcpy(&(sEthHeader.abySrcAddr[0]), &(pPacket->p80211Header->sA3.abyAddr2[0]), U_ETHER_ADDR_LEN); + memcpy(&(sEthHeader.abyDstAddr[0]), + &(pPacket->p80211Header->sA3.abyAddr1[0]), + ETH_ALEN); + memcpy(&(sEthHeader.abySrcAddr[0]), + &(pPacket->p80211Header->sA3.abyAddr2[0]), + ETH_ALEN); //========================= // No Fragmentation //========================= @@ -2197,8 +2251,8 @@ CMD_STATUS csMgmt_xmit( CMD_STATUS csBeacon_xmit( - IN PSDevice pDevice, - IN PSTxMgmtPacket pPacket + PSDevice pDevice, + PSTxMgmtPacket pPacket ) { @@ -2521,8 +2575,12 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb) { cbHeaderSize = wTxBufSize + sizeof(SRrvTime_ab) + cbMICHDR + sizeof(STxDataHead_ab); } memset((PVOID)(pbyTxBufferAddr + wTxBufSize), 0, (cbHeaderSize - wTxBufSize)); - memcpy(&(sEthHeader.abyDstAddr[0]), &(p80211Header->sA3.abyAddr1[0]), U_ETHER_ADDR_LEN); - memcpy(&(sEthHeader.abySrcAddr[0]), &(p80211Header->sA3.abyAddr2[0]), U_ETHER_ADDR_LEN); + memcpy(&(sEthHeader.abyDstAddr[0]), + &(p80211Header->sA3.abyAddr1[0]), + ETH_ALEN); + memcpy(&(sEthHeader.abySrcAddr[0]), + &(p80211Header->sA3.abyAddr2[0]), + ETH_ALEN); //========================= // No Fragmentation //========================= @@ -2692,9 +2750,9 @@ vDMA0_tx_80211(PSDevice pDevice, struct sk_buff *skb) { NTSTATUS nsDMA_tx_packet( - IN PSDevice pDevice, - IN UINT uDMAIdx, - IN struct sk_buff *skb + PSDevice pDevice, + UINT uDMAIdx, + struct sk_buff *skb ) { PSMgmtObject pMgmt = &(pDevice->sMgmtObj); @@ -3110,10 +3168,10 @@ nsDMA_tx_packet( BOOL bRelayPacketSend ( - IN PSDevice pDevice, - IN PBYTE pbySkbData, - IN UINT uDataLen, - IN UINT uNodeIndex + PSDevice pDevice, + PBYTE pbySkbData, + UINT uDataLen, + UINT uNodeIndex ) { PSMgmtObject pMgmt = &(pDevice->sMgmtObj); diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index 6bc22d371c1e..1160c0354f3f 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -43,8 +43,8 @@ typedef struct tagSRTSDataF { WORD wFrameControl; WORD wDurationID; - BYTE abyRA[U_ETHER_ADDR_LEN]; - BYTE abyTA[U_ETHER_ADDR_LEN]; + BYTE abyRA[ETH_ALEN]; + BYTE abyTA[ETH_ALEN]; } SRTSDataF, *PSRTSDataF; // @@ -53,7 +53,7 @@ typedef struct tagSRTSDataF { typedef struct tagSCTSDataF { WORD wFrameControl; WORD wDurationID; - BYTE abyRA[U_ETHER_ADDR_LEN]; + BYTE abyRA[ETH_ALEN]; WORD wReserved; } SCTSDataF, *PSCTSDataF; @@ -667,17 +667,17 @@ typedef struct tagSBEACON_BUFFER BOOL bPacketToWirelessUsb( - IN PSDevice pDevice, - IN BYTE byPktType, - IN PBYTE usbPacketBuf, - IN BOOL bNeedEncrypt, - IN UINT cbPayloadSize, - IN UINT uDMAIdx, - IN PSEthernetHeader psEthHeader, - IN PBYTE pPacket, - IN PSKeyItem pTransmitKey, - IN UINT uNodeIndex, - IN WORD wCurrentRate, + PSDevice pDevice, + BYTE byPktType, + PBYTE usbPacketBuf, + BOOL bNeedEncrypt, + UINT cbPayloadSize, + UINT uDMAIdx, + PSEthernetHeader psEthHeader, + PBYTE pPacket, + PSKeyItem pTransmitKey, + UINT uNodeIndex, + WORD wCurrentRate, OUT UINT *pcbHeaderLen, OUT UINT *pcbTotalLen ); diff --git a/drivers/staging/vt6656/tcrc.c b/drivers/staging/vt6656/tcrc.c index 5f0c74763f87..3464801ede57 100644 --- a/drivers/staging/vt6656/tcrc.c +++ b/drivers/staging/vt6656/tcrc.c @@ -41,7 +41,7 @@ /*--------------------- Static Variables --------------------------*/ -// 32-bit CRC table +/* 32-bit CRC table */ static const DWORD s_adwCrc32Table[256] = { 0x00000000L, 0x77073096L, 0xEE0E612CL, 0x990951BAL, 0x076DC419L, 0x706AF48FL, 0xE963A535L, 0x9E6495A3L, @@ -132,17 +132,18 @@ static const DWORD s_adwCrc32Table[256] = { * Return Value: CRC-32 * -*/ -DWORD CRCdwCrc32 (PBYTE pbyData, UINT cbByte, DWORD dwCrcSeed) +DWORD CRCdwCrc32(PBYTE pbyData, UINT cbByte, DWORD dwCrcSeed) { - DWORD dwCrc; + DWORD dwCrc; - dwCrc = dwCrcSeed; - while (cbByte--) { - dwCrc = s_adwCrc32Table[(BYTE)((dwCrc ^ (*pbyData)) & 0xFF)] ^ (dwCrc >> 8); - pbyData++; - } + dwCrc = dwCrcSeed; + while (cbByte--) { + dwCrc = s_adwCrc32Table[(BYTE)((dwCrc ^ (*pbyData)) & 0xFF)] ^ + (dwCrc >> 8); + pbyData++; + } - return dwCrc; + return dwCrc; } @@ -164,7 +165,7 @@ DWORD CRCdwCrc32 (PBYTE pbyData, UINT cbByte, DWORD dwCrcSeed) * Return Value: CRC-32 * -*/ -DWORD CRCdwGetCrc32 (PBYTE pbyData, UINT cbByte) +DWORD CRCdwGetCrc32(PBYTE pbyData, UINT cbByte) { return ~CRCdwCrc32(pbyData, cbByte, 0xFFFFFFFFL); } diff --git a/drivers/staging/vt6656/tether.c b/drivers/staging/vt6656/tether.c index c90b469ad545..a7c716f174da 100644 --- a/drivers/staging/vt6656/tether.c +++ b/drivers/staging/vt6656/tether.c @@ -61,25 +61,25 @@ * Return Value: Hash value * */ -BYTE ETHbyGetHashIndexByCrc32 (PBYTE pbyMultiAddr) +BYTE ETHbyGetHashIndexByCrc32(PBYTE pbyMultiAddr) { - int ii; - BYTE byTmpHash; - BYTE byHash = 0; + int ii; + BYTE byTmpHash; + BYTE byHash = 0; - // get the least 6-bits from CRC generator - byTmpHash = (BYTE)(CRCdwCrc32(pbyMultiAddr, U_ETHER_ADDR_LEN, - 0xFFFFFFFFL) & 0x3F); - // reverse most bit to least bit - for (ii = 0; ii < (sizeof(byTmpHash) * 8); ii++) { - byHash <<= 1; - if (byTmpHash & 0x01) - byHash |= 1; - byTmpHash >>= 1; - } + /* get the least 6-bits from CRC generator */ + byTmpHash = (BYTE)(CRCdwCrc32(pbyMultiAddr, ETH_ALEN, + 0xFFFFFFFFL) & 0x3F); + /* reverse most bit to least bit */ + for (ii = 0; ii < (sizeof(byTmpHash) * 8); ii++) { + byHash <<= 1; + if (byTmpHash & 0x01) + byHash |= 1; + byTmpHash >>= 1; + } - // adjust 6-bits to the right most - return (byHash >> 2); + /* adjust 6-bits to the right most */ + return byHash >> 2; } @@ -96,14 +96,13 @@ BYTE ETHbyGetHashIndexByCrc32 (PBYTE pbyMultiAddr) * Return Value: TRUE if ok; FALSE if error. * */ -BOOL ETHbIsBufferCrc32Ok (PBYTE pbyBuffer, UINT cbFrameLength) +BOOL ETHbIsBufferCrc32Ok(PBYTE pbyBuffer, UINT cbFrameLength) { - DWORD dwCRC; + DWORD dwCRC; - dwCRC = CRCdwGetCrc32(pbyBuffer, cbFrameLength - 4); - if (cpu_to_le32(*((PDWORD)(pbyBuffer + cbFrameLength - 4))) != dwCRC) { - return FALSE; - } - return TRUE; + dwCRC = CRCdwGetCrc32(pbyBuffer, cbFrameLength - 4); + if (cpu_to_le32(*((PDWORD)(pbyBuffer + cbFrameLength - 4))) != dwCRC) + return FALSE; + return TRUE; } diff --git a/drivers/staging/vt6656/tether.h b/drivers/staging/vt6656/tether.h index 5a3c326436c6..af119dd82b24 100644 --- a/drivers/staging/vt6656/tether.h +++ b/drivers/staging/vt6656/tether.h @@ -29,17 +29,17 @@ #ifndef __TETHER_H__ #define __TETHER_H__ +#include <linux/if_ether.h> #include "ttype.h" /*--------------------- Export Definitions -------------------------*/ // // constants // -#define U_ETHER_ADDR_LEN 6 // Ethernet address length #define U_TYPE_LEN 2 // #define U_CRC_LEN 4 // -#define U_HEADER_LEN (U_ETHER_ADDR_LEN * 2 + U_TYPE_LEN) -#define U_ETHER_ADDR_STR_LEN (U_ETHER_ADDR_LEN * 2 + 1) +#define U_HEADER_LEN (ETH_ALEN * 2 + U_TYPE_LEN) +#define U_ETHER_ADDR_STR_LEN (ETH_ALEN * 2 + 1) // Ethernet address string length #define MIN_DATA_LEN 46 // min data length @@ -167,8 +167,8 @@ // Ethernet packet // typedef struct tagSEthernetHeader { - BYTE abyDstAddr[U_ETHER_ADDR_LEN]; - BYTE abySrcAddr[U_ETHER_ADDR_LEN]; + BYTE abyDstAddr[ETH_ALEN]; + BYTE abySrcAddr[ETH_ALEN]; WORD wType; }__attribute__ ((__packed__)) SEthernetHeader, *PSEthernetHeader; @@ -178,8 +178,8 @@ SEthernetHeader, *PSEthernetHeader; // 802_3 packet // typedef struct tagS802_3Header { - BYTE abyDstAddr[U_ETHER_ADDR_LEN]; - BYTE abySrcAddr[U_ETHER_ADDR_LEN]; + BYTE abyDstAddr[ETH_ALEN]; + BYTE abySrcAddr[ETH_ALEN]; WORD wLen; }__attribute__ ((__packed__)) S802_3Header, *PS802_3Header; @@ -190,11 +190,11 @@ S802_3Header, *PS802_3Header; typedef struct tagS802_11Header { WORD wFrameCtl; WORD wDurationID; - BYTE abyAddr1[U_ETHER_ADDR_LEN]; - BYTE abyAddr2[U_ETHER_ADDR_LEN]; - BYTE abyAddr3[U_ETHER_ADDR_LEN]; + BYTE abyAddr1[ETH_ALEN]; + BYTE abyAddr2[ETH_ALEN]; + BYTE abyAddr3[ETH_ALEN]; WORD wSeqCtl; - BYTE abyAddr4[U_ETHER_ADDR_LEN]; + BYTE abyAddr4[ETH_ALEN]; }__attribute__ ((__packed__)) S802_11Header, *PS802_11Header; diff --git a/drivers/staging/vt6656/ttype.h b/drivers/staging/vt6656/ttype.h index 9ee3f436fc3d..2365fa411393 100644 --- a/drivers/staging/vt6656/ttype.h +++ b/drivers/staging/vt6656/ttype.h @@ -37,10 +37,6 @@ #define VOID void #endif -#ifndef IN -#define IN -#endif - #ifndef OUT #define OUT #endif diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 65e91a332a66..901c684b11e9 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -73,34 +73,34 @@ static int msglevel =MSG_LEVEL_INFO; static VOID s_nsInterruptUsbIoCompleteRead( - IN struct urb *urb + struct urb *urb ); static VOID s_nsBulkInUsbIoCompleteRead( - IN struct urb *urb + struct urb *urb ); static VOID s_nsBulkOutIoCompleteWrite( - IN struct urb *urb + struct urb *urb ); static VOID s_nsControlInUsbIoCompleteRead( - IN struct urb *urb + struct urb *urb ); static VOID s_nsControlInUsbIoCompleteWrite( - IN struct urb *urb + struct urb *urb ); /*--------------------- Export Variables --------------------------*/ @@ -111,12 +111,12 @@ s_nsControlInUsbIoCompleteWrite( NTSTATUS PIPEnsControlOutAsyn( - IN PSDevice pDevice, - IN BYTE byRequest, - IN WORD wValue, - IN WORD wIndex, - IN WORD wLength, - IN PBYTE pbyBuffer + PSDevice pDevice, + BYTE byRequest, + WORD wValue, + WORD wIndex, + WORD wLength, + PBYTE pbyBuffer ) { NTSTATUS ntStatus; @@ -162,12 +162,12 @@ PIPEnsControlOutAsyn( NTSTATUS PIPEnsControlOut( - IN PSDevice pDevice, - IN BYTE byRequest, - IN WORD wValue, - IN WORD wIndex, - IN WORD wLength, - IN PBYTE pbyBuffer + PSDevice pDevice, + BYTE byRequest, + WORD wValue, + WORD wIndex, + WORD wLength, + PBYTE pbyBuffer ) { NTSTATUS ntStatus = 0; @@ -193,7 +193,8 @@ PIPEnsControlOut( usb_sndctrlpipe(pDevice->usb , 0), (char *) &pDevice->sUsbCtlRequest, pbyBuffer, wLength, s_nsControlInUsbIoCompleteWrite, pDevice); - if ((ntStatus = usb_submit_urb(pDevice->pControlURB, GFP_ATOMIC)) != 0) { + ntStatus = usb_submit_urb(pDevice->pControlURB, GFP_ATOMIC); + if (ntStatus != 0) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"control send request submission failed: %d\n", ntStatus); return STATUS_FAILURE; } @@ -223,12 +224,12 @@ PIPEnsControlOut( NTSTATUS PIPEnsControlIn( - IN PSDevice pDevice, - IN BYTE byRequest, - IN WORD wValue, - IN WORD wIndex, - IN WORD wLength, - IN OUT PBYTE pbyBuffer + PSDevice pDevice, + BYTE byRequest, + WORD wValue, + WORD wIndex, + WORD wLength, + OUT PBYTE pbyBuffer ) { NTSTATUS ntStatus = 0; @@ -251,7 +252,8 @@ PIPEnsControlIn( usb_rcvctrlpipe(pDevice->usb , 0), (char *) &pDevice->sUsbCtlRequest, pbyBuffer, wLength, s_nsControlInUsbIoCompleteRead, pDevice); - if ((ntStatus = usb_submit_urb(pDevice->pControlURB, GFP_ATOMIC)) != 0) { + ntStatus = usb_submit_urb(pDevice->pControlURB, GFP_ATOMIC); + if (ntStatus != 0) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"control request submission failed: %d\n", ntStatus); }else { MP_SET_FLAG(pDevice, fMP_CONTROL_READS); @@ -279,7 +281,7 @@ PIPEnsControlIn( static VOID s_nsControlInUsbIoCompleteWrite( - IN struct urb *urb + struct urb *urb ) { PSDevice pDevice; @@ -320,7 +322,7 @@ s_nsControlInUsbIoCompleteWrite( static VOID s_nsControlInUsbIoCompleteRead( - IN struct urb *urb + struct urb *urb ) { PSDevice pDevice; @@ -360,7 +362,7 @@ s_nsControlInUsbIoCompleteRead( */ NTSTATUS PIPEnsInterruptRead( - IN PSDevice pDevice + PSDevice pDevice ) { NTSTATUS ntStatus = STATUS_FAILURE; @@ -414,7 +416,8 @@ usb_fill_bulk_urb(pDevice->pInterruptURB, #endif #endif - if ((ntStatus = usb_submit_urb(pDevice->pInterruptURB, GFP_ATOMIC)) != 0) { + ntStatus = usb_submit_urb(pDevice->pInterruptURB, GFP_ATOMIC); + if (ntStatus != 0) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit int URB failed %d\n", ntStatus); } @@ -440,7 +443,7 @@ usb_fill_bulk_urb(pDevice->pInterruptURB, static VOID s_nsInterruptUsbIoCompleteRead( - IN struct urb *urb + struct urb *urb ) { @@ -494,7 +497,8 @@ s_nsInterruptUsbIoCompleteRead( if (pDevice->fKillEventPollingThread != TRUE) { #if 0 //reserve int URB submit - if ((ntStatus = usb_submit_urb(urb, GFP_ATOMIC)) != 0) { + ntStatus = usb_submit_urb(urb, GFP_ATOMIC); + if (ntStatus != 0) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Re-Submit int URB failed %d\n", ntStatus); } #else //replace int URB submit by bulk transfer @@ -507,7 +511,8 @@ s_nsInterruptUsbIoCompleteRead( s_nsInterruptUsbIoCompleteRead, pDevice); - if ((ntStatus = usb_submit_urb(pDevice->pInterruptURB, GFP_ATOMIC)) != 0) { + ntStatus = usb_submit_urb(pDevice->pInterruptURB, GFP_ATOMIC); + if (ntStatus != 0) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit int URB failed %d\n", ntStatus); } @@ -538,8 +543,8 @@ s_nsInterruptUsbIoCompleteRead( */ NTSTATUS PIPEnsBulkInUsbRead( - IN PSDevice pDevice, - IN PRCB pRCB + PSDevice pDevice, + PRCB pRCB ) { NTSTATUS ntStatus= 0; @@ -572,7 +577,8 @@ PIPEnsBulkInUsbRead( s_nsBulkInUsbIoCompleteRead, pRCB); - if((ntStatus = usb_submit_urb(pUrb, GFP_ATOMIC)) != 0){ + ntStatus = usb_submit_urb(pUrb, GFP_ATOMIC); + if (ntStatus != 0) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit Rx URB failed %d\n", ntStatus); return STATUS_FAILURE ; } @@ -602,7 +608,7 @@ PIPEnsBulkInUsbRead( static VOID s_nsBulkInUsbIoCompleteRead( - IN struct urb *urb + struct urb *urb ) { @@ -681,8 +687,8 @@ s_nsBulkInUsbIoCompleteRead( */ NDIS_STATUS PIPEnsSendBulkOut( - IN PSDevice pDevice, - IN PUSB_SEND_CONTEXT pContext + PSDevice pDevice, + PUSB_SEND_CONTEXT pContext ) { NTSTATUS status; @@ -718,7 +724,8 @@ PIPEnsSendBulkOut( s_nsBulkOutIoCompleteWrite, pContext); - if((status = usb_submit_urb(pUrb, GFP_ATOMIC))!=0) + status = usb_submit_urb(pUrb, GFP_ATOMIC); + if (status != 0) { DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit Tx URB failed %d\n", status); return STATUS_FAILURE; @@ -761,7 +768,7 @@ PIPEnsSendBulkOut( static VOID s_nsBulkOutIoCompleteWrite( - IN struct urb *urb + struct urb *urb ) { PSDevice pDevice; diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h index c422d1d08730..0f7cd2d10b93 100644 --- a/drivers/staging/vt6656/usbpipe.h +++ b/drivers/staging/vt6656/usbpipe.h @@ -43,34 +43,34 @@ NTSTATUS PIPEnsControlOut( - IN PSDevice pDevice, - IN BYTE byRequest, - IN WORD wValue, - IN WORD wIndex, - IN WORD wLength, - IN PBYTE pbyBuffer + PSDevice pDevice, + BYTE byRequest, + WORD wValue, + WORD wIndex, + WORD wLength, + PBYTE pbyBuffer ); NTSTATUS PIPEnsControlOutAsyn( - IN PSDevice pDevice, - IN BYTE byRequest, - IN WORD wValue, - IN WORD wIndex, - IN WORD wLength, - IN PBYTE pbyBuffer + PSDevice pDevice, + BYTE byRequest, + WORD wValue, + WORD wIndex, + WORD wLength, + PBYTE pbyBuffer ); NTSTATUS PIPEnsControlIn( - IN PSDevice pDevice, - IN BYTE byRequest, - IN WORD wValue, - IN WORD wIndex, - IN WORD wLength, - IN OUT PBYTE pbyBuffer + PSDevice pDevice, + BYTE byRequest, + WORD wValue, + WORD wIndex, + WORD wLength, + OUT PBYTE pbyBuffer ); @@ -78,19 +78,19 @@ PIPEnsControlIn( NTSTATUS PIPEnsInterruptRead( - IN PSDevice pDevice + PSDevice pDevice ); NTSTATUS PIPEnsBulkInUsbRead( - IN PSDevice pDevice, - IN PRCB pRCB + PSDevice pDevice, + PRCB pRCB ); NTSTATUS PIPEnsSendBulkOut( - IN PSDevice pDevice, - IN PUSB_SEND_CONTEXT pContext + PSDevice pDevice, + PUSB_SEND_CONTEXT pContext ); #endif // __USBPIPE_H__ diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c index 51b2dcfbab91..7e543396536e 100644 --- a/drivers/staging/vt6656/wcmd.c +++ b/drivers/staging/vt6656/wcmd.c @@ -71,19 +71,19 @@ static int msglevel =MSG_LEVEL_INFO; static VOID s_vProbeChannel( - IN PSDevice pDevice + PSDevice pDevice ); static PSTxMgmtPacket s_MgrMakeProbeRequest( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PBYTE pScanBSSID, - IN PWLAN_IE_SSID pSSID, - IN PWLAN_IE_SUPP_RATES pCurrRates, - IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates + PSDevice pDevice, + PSMgmtObject pMgmt, + PBYTE pScanBSSID, + PWLAN_IE_SSID pSSID, + PWLAN_IE_SUPP_RATES pCurrRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates ); @@ -96,7 +96,7 @@ s_bCommandComplete ( static BOOL s_bClearBSSID_SCAN ( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ); /*--------------------- Export Variables --------------------------*/ @@ -212,7 +212,7 @@ vAdHocBeaconRestart(PSDevice pDevice) static VOID s_vProbeChannel( - IN PSDevice pDevice + PSDevice pDevice ) { //1M, 2M, 5M, 11M, 18M, 24M, 36M, 54M @@ -275,12 +275,12 @@ s_vProbeChannel( PSTxMgmtPacket s_MgrMakeProbeRequest( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PBYTE pScanBSSID, - IN PWLAN_IE_SSID pSSID, - IN PWLAN_IE_SUPP_RATES pCurrRates, - IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates + PSDevice pDevice, + PSMgmtObject pMgmt, + PBYTE pScanBSSID, + PWLAN_IE_SSID pSSID, + PWLAN_IE_SUPP_RATES pCurrRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates ) { @@ -327,8 +327,8 @@ s_MgrMakeProbeRequest( VOID vCommandTimerWait( - IN HANDLE hDeviceContext, - IN UINT MSecond + HANDLE hDeviceContext, + UINT MSecond ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -347,7 +347,7 @@ vCommandTimerWait( VOID vRunCommand( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -1193,9 +1193,9 @@ s_bCommandComplete ( } BOOL bScheduleCommand ( - IN HANDLE hDeviceContext, - IN CMD_CODE eCommand, - IN PBYTE pbyItem0 + HANDLE hDeviceContext, + CMD_CODE eCommand, + PBYTE pbyItem0 ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -1266,7 +1266,7 @@ BOOL bScheduleCommand ( */ static BOOL s_bClearBSSID_SCAN ( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -1289,7 +1289,7 @@ BOOL s_bClearBSSID_SCAN ( //mike add:reset command timer VOID vResetCommandTimer( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -1313,7 +1313,7 @@ vResetCommandTimer( #ifdef TxInSleep VOID BSSvSecondTxData( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ) { PSDevice pDevice = (PSDevice)hDeviceContext; diff --git a/drivers/staging/vt6656/wcmd.h b/drivers/staging/vt6656/wcmd.h index 90d672b462b1..28c0aa559c97 100644 --- a/drivers/staging/vt6656/wcmd.h +++ b/drivers/staging/vt6656/wcmd.h @@ -118,19 +118,19 @@ typedef enum tagCMD_STATE { /*--------------------- Export Functions --------------------------*/ VOID vResetCommandTimer( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ); BOOL bScheduleCommand( - IN HANDLE hDeviceContext, - IN CMD_CODE eCommand, - IN PBYTE pbyItem0 + HANDLE hDeviceContext, + CMD_CODE eCommand, + PBYTE pbyItem0 ); VOID vRunCommand( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ); /* VOID @@ -143,7 +143,7 @@ WCMDvCommandThread( #ifdef TxInSleep VOID BSSvSecondTxData( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ); #endif diff --git a/drivers/staging/vt6656/wctl.c b/drivers/staging/vt6656/wctl.c index 40986da1e4a2..956add694227 100644 --- a/drivers/staging/vt6656/wctl.c +++ b/drivers/staging/vt6656/wctl.c @@ -91,7 +91,7 @@ BOOL WCTLbIsDuplicate (PSCache pCache, PS802_11Header pMACHeader) /* Not fount in cache - insert */ pCacheEntry = &pCache->asCacheEntry[pCache->uInPtr]; pCacheEntry->wFmSequence = pMACHeader->wSeqCtl; - memcpy(&(pCacheEntry->abyAddr2[0]), &(pMACHeader->abyAddr2[0]), U_ETHER_ADDR_LEN); + memcpy(&(pCacheEntry->abyAddr2[0]), &(pMACHeader->abyAddr2[0]), ETH_ALEN); pCacheEntry->wFrameCtl = pMACHeader->wFrameCtl; ADD_ONE_WITH_WRAP_AROUND(pCache->uInPtr, DUPLICATE_RX_CACHE_LENGTH); return FALSE; @@ -154,7 +154,9 @@ UINT ii; pDevice->sRxDFCB[ii].bInUse = TRUE; pDevice->sRxDFCB[ii].wSequence = (pMACHeader->wSeqCtl >> 4); pDevice->sRxDFCB[ii].wFragNum = (pMACHeader->wSeqCtl & 0x000F); - memcpy(&(pDevice->sRxDFCB[ii].abyAddr2[0]), &(pMACHeader->abyAddr2[0]), U_ETHER_ADDR_LEN); + memcpy(&(pDevice->sRxDFCB[ii].abyAddr2[0]), + &(pMACHeader->abyAddr2[0]), + ETH_ALEN); return(ii); } } diff --git a/drivers/staging/vt6656/wmgr.c b/drivers/staging/vt6656/wmgr.c index 330aea69d231..b93cb1d2bfb2 100644 --- a/drivers/staging/vt6656/wmgr.c +++ b/drivers/staging/vt6656/wmgr.c @@ -94,110 +94,110 @@ static int msglevel =MSG_LEVEL_INFO; /*--------------------- Static Functions --------------------------*/ //2008-0730-01<Add>by MikeLiu static BOOL ChannelExceedZoneType( - IN PSDevice pDevice, - IN BYTE byCurrChannel + PSDevice pDevice, + BYTE byCurrChannel ); // Association/diassociation functions static PSTxMgmtPacket s_MgrMakeAssocRequest( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PBYTE pDAddr, - IN WORD wCurrCapInfo, - IN WORD wListenInterval, - IN PWLAN_IE_SSID pCurrSSID, - IN PWLAN_IE_SUPP_RATES pCurrRates, - IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates + PSDevice pDevice, + PSMgmtObject pMgmt, + PBYTE pDAddr, + WORD wCurrCapInfo, + WORD wListenInterval, + PWLAN_IE_SSID pCurrSSID, + PWLAN_IE_SUPP_RATES pCurrRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates ); static VOID s_vMgrRxAssocRequest( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket, - IN UINT uNodeIndex + PSDevice pDevice, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket, + UINT uNodeIndex ); static PSTxMgmtPacket s_MgrMakeReAssocRequest( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PBYTE pDAddr, - IN WORD wCurrCapInfo, - IN WORD wListenInterval, - IN PWLAN_IE_SSID pCurrSSID, - IN PWLAN_IE_SUPP_RATES pCurrRates, - IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates + PSDevice pDevice, + PSMgmtObject pMgmt, + PBYTE pDAddr, + WORD wCurrCapInfo, + WORD wListenInterval, + PWLAN_IE_SSID pCurrSSID, + PWLAN_IE_SUPP_RATES pCurrRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates ); static VOID s_vMgrRxAssocResponse( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket, - IN BOOL bReAssocType + PSDevice pDevice, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket, + BOOL bReAssocType ); static VOID s_vMgrRxDisassociation( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket + PSDevice pDevice, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket ); // Authentication/deauthen functions static VOID s_vMgrRxAuthenSequence_1( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PWLAN_FR_AUTHEN pFrame + PSDevice pDevice, + PSMgmtObject pMgmt, + PWLAN_FR_AUTHEN pFrame ); static VOID s_vMgrRxAuthenSequence_2( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PWLAN_FR_AUTHEN pFrame + PSDevice pDevice, + PSMgmtObject pMgmt, + PWLAN_FR_AUTHEN pFrame ); static VOID s_vMgrRxAuthenSequence_3( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PWLAN_FR_AUTHEN pFrame + PSDevice pDevice, + PSMgmtObject pMgmt, + PWLAN_FR_AUTHEN pFrame ); static VOID s_vMgrRxAuthenSequence_4( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PWLAN_FR_AUTHEN pFrame + PSDevice pDevice, + PSMgmtObject pMgmt, + PWLAN_FR_AUTHEN pFrame ); static VOID s_vMgrRxAuthentication( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket + PSDevice pDevice, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket ); static VOID s_vMgrRxDeauthentication( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket + PSDevice pDevice, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket ); // Scan functions @@ -205,49 +205,49 @@ s_vMgrRxDeauthentication( static VOID s_vMgrRxProbeRequest( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket + PSDevice pDevice, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket ); static VOID s_vMgrRxProbeResponse( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket + PSDevice pDevice, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket ); // beacon functions static VOID s_vMgrRxBeacon( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket, - IN BOOL bInScan + PSDevice pDevice, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket, + BOOL bInScan ); static VOID s_vMgrFormatTIM( - IN PSMgmtObject pMgmt, - IN PWLAN_IE_TIM pTIM + PSMgmtObject pMgmt, + PWLAN_IE_TIM pTIM ); static PSTxMgmtPacket s_MgrMakeBeacon( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN WORD wCurrCapInfo, - IN WORD wCurrBeaconPeriod, - IN UINT uCurrChannel, - IN WORD wCurrATIMWinodw, - IN PWLAN_IE_SSID pCurrSSID, - IN PBYTE pCurrBSSID, - IN PWLAN_IE_SUPP_RATES pCurrSuppRates, - IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates + PSDevice pDevice, + PSMgmtObject pMgmt, + WORD wCurrCapInfo, + WORD wCurrBeaconPeriod, + UINT uCurrChannel, + WORD wCurrATIMWinodw, + PWLAN_IE_SSID pCurrSSID, + PBYTE pCurrBSSID, + PWLAN_IE_SUPP_RATES pCurrSuppRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates ); @@ -255,78 +255,78 @@ s_MgrMakeBeacon( static PSTxMgmtPacket s_MgrMakeAssocResponse( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN WORD wCurrCapInfo, - IN WORD wAssocStatus, - IN WORD wAssocAID, - IN PBYTE pDstAddr, - IN PWLAN_IE_SUPP_RATES pCurrSuppRates, - IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates + PSDevice pDevice, + PSMgmtObject pMgmt, + WORD wCurrCapInfo, + WORD wAssocStatus, + WORD wAssocAID, + PBYTE pDstAddr, + PWLAN_IE_SUPP_RATES pCurrSuppRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates ); // ReAssociation response static PSTxMgmtPacket s_MgrMakeReAssocResponse( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN WORD wCurrCapInfo, - IN WORD wAssocStatus, - IN WORD wAssocAID, - IN PBYTE pDstAddr, - IN PWLAN_IE_SUPP_RATES pCurrSuppRates, - IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates + PSDevice pDevice, + PSMgmtObject pMgmt, + WORD wCurrCapInfo, + WORD wAssocStatus, + WORD wAssocAID, + PBYTE pDstAddr, + PWLAN_IE_SUPP_RATES pCurrSuppRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates ); // Probe response static PSTxMgmtPacket s_MgrMakeProbeResponse( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN WORD wCurrCapInfo, - IN WORD wCurrBeaconPeriod, - IN UINT uCurrChannel, - IN WORD wCurrATIMWinodw, - IN PBYTE pDstAddr, - IN PWLAN_IE_SSID pCurrSSID, - IN PBYTE pCurrBSSID, - IN PWLAN_IE_SUPP_RATES pCurrSuppRates, - IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates, - IN BYTE byPHYType + PSDevice pDevice, + PSMgmtObject pMgmt, + WORD wCurrCapInfo, + WORD wCurrBeaconPeriod, + UINT uCurrChannel, + WORD wCurrATIMWinodw, + PBYTE pDstAddr, + PWLAN_IE_SSID pCurrSSID, + PBYTE pCurrBSSID, + PWLAN_IE_SUPP_RATES pCurrSuppRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates, + BYTE byPHYType ); // received status static VOID s_vMgrLogStatus( - IN PSMgmtObject pMgmt, - IN WORD wStatus + PSMgmtObject pMgmt, + WORD wStatus ); static VOID s_vMgrSynchBSS ( - IN PSDevice pDevice, - IN UINT uBSSMode, - IN PKnownBSS pCurr, + PSDevice pDevice, + UINT uBSSMode, + PKnownBSS pCurr, OUT PCMD_STATUS pStatus ); static BOOL s_bCipherMatch ( - IN PKnownBSS pBSSNode, - IN NDIS_802_11_ENCRYPTION_STATUS EncStatus, + PKnownBSS pBSSNode, + NDIS_802_11_ENCRYPTION_STATUS EncStatus, OUT PBYTE pbyCCSPK, OUT PBYTE pbyCCSGK ); static VOID Encyption_Rebuild( - IN PSDevice pDevice, - IN PKnownBSS pCurr + PSDevice pDevice, + PKnownBSS pCurr ); @@ -349,7 +349,7 @@ s_bCipherMatch ( VOID vMgrObjectInit( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -417,8 +417,8 @@ vMgrObjectInit( VOID vMgrAssocBeginSta( - IN HANDLE hDeviceContext, - IN PSMgmtObject pMgmt, + HANDLE hDeviceContext, + PSMgmtObject pMgmt, OUT PCMD_STATUS pStatus ) { @@ -493,8 +493,8 @@ vMgrAssocBeginSta( VOID vMgrReAssocBeginSta( - IN HANDLE hDeviceContext, - IN PSMgmtObject pMgmt, + HANDLE hDeviceContext, + PSMgmtObject pMgmt, OUT PCMD_STATUS pStatus ) { @@ -572,10 +572,10 @@ vMgrReAssocBeginSta( VOID vMgrDisassocBeginSta( - IN HANDLE hDeviceContext, - IN PSMgmtObject pMgmt, - IN PBYTE abyDestAddress, - IN WORD wReason, + HANDLE hDeviceContext, + PSMgmtObject pMgmt, + PBYTE abyDestAddress, + WORD wReason, OUT PCMD_STATUS pStatus ) { @@ -635,10 +635,10 @@ vMgrDisassocBeginSta( static VOID s_vMgrRxAssocRequest( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket, - IN UINT uNodeIndex + PSDevice pDevice, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket, + UINT uNodeIndex ) { WLAN_FR_ASSOCREQ sFrame; @@ -791,10 +791,10 @@ s_vMgrRxAssocRequest( static VOID s_vMgrRxReAssocRequest( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket, - IN UINT uNodeIndex + PSDevice pDevice, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket, + UINT uNodeIndex ) { WLAN_FR_REASSOCREQ sFrame; @@ -938,10 +938,10 @@ s_vMgrRxReAssocRequest( static VOID s_vMgrRxAssocResponse( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket, - IN BOOL bReAssocType + PSDevice pDevice, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket, + BOOL bReAssocType ) { WLAN_FR_ASSOCRESP sFrame; @@ -1104,8 +1104,8 @@ if(pMgmt->eCurrState == WMAC_STATE_ASSOC) VOID vMgrAuthenBeginSta( - IN HANDLE hDeviceContext, - IN PSMgmtObject pMgmt, + HANDLE hDeviceContext, + PSMgmtObject pMgmt, OUT PCMD_STATUS pStatus ) { @@ -1162,10 +1162,10 @@ vMgrAuthenBeginSta( VOID vMgrDeAuthenBeginSta( - IN HANDLE hDeviceContext, - IN PSMgmtObject pMgmt, - IN PBYTE abyDestAddress, - IN WORD wReason, + HANDLE hDeviceContext, + PSMgmtObject pMgmt, + PBYTE abyDestAddress, + WORD wReason, OUT PCMD_STATUS pStatus ) { @@ -1219,9 +1219,9 @@ vMgrDeAuthenBeginSta( static VOID s_vMgrRxAuthentication( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket + PSDevice pDevice, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket ) { WLAN_FR_AUTHEN sFrame; @@ -1277,9 +1277,9 @@ s_vMgrRxAuthentication( static VOID s_vMgrRxAuthenSequence_1( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PWLAN_FR_AUTHEN pFrame + PSDevice pDevice, + PSMgmtObject pMgmt, + PWLAN_FR_AUTHEN pFrame ) { PSTxMgmtPacket pTxPacket = NULL; @@ -1383,9 +1383,9 @@ s_vMgrRxAuthenSequence_1( static VOID s_vMgrRxAuthenSequence_2( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PWLAN_FR_AUTHEN pFrame + PSDevice pDevice, + PSMgmtObject pMgmt, + PWLAN_FR_AUTHEN pFrame ) { WLAN_FR_AUTHEN sFrame; @@ -1485,9 +1485,9 @@ s_vMgrRxAuthenSequence_2( static VOID s_vMgrRxAuthenSequence_3( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PWLAN_FR_AUTHEN pFrame + PSDevice pDevice, + PSMgmtObject pMgmt, + PWLAN_FR_AUTHEN pFrame ) { PSTxMgmtPacket pTxPacket = NULL; @@ -1573,9 +1573,9 @@ reply: static VOID s_vMgrRxAuthenSequence_4( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PWLAN_FR_AUTHEN pFrame + PSDevice pDevice, + PSMgmtObject pMgmt, + PWLAN_FR_AUTHEN pFrame ) { @@ -1612,9 +1612,9 @@ s_vMgrRxAuthenSequence_4( static VOID s_vMgrRxDisassociation( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket + PSDevice pDevice, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket ) { WLAN_FR_DISASSOC sFrame; @@ -1702,9 +1702,9 @@ s_vMgrRxDisassociation( static VOID s_vMgrRxDeauthentication( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket + PSDevice pDevice, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket ) { WLAN_FR_DEAUTHEN sFrame; @@ -1791,8 +1791,8 @@ s_vMgrRxDeauthentication( -*/ static BOOL ChannelExceedZoneType( - IN PSDevice pDevice, - IN BYTE byCurrChannel + PSDevice pDevice, + BYTE byCurrChannel ) { BOOL exceed=FALSE; @@ -1828,10 +1828,10 @@ ChannelExceedZoneType( static VOID s_vMgrRxBeacon( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket, - IN BOOL bInScan + PSDevice pDevice, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket, + BOOL bInScan ) { @@ -2357,7 +2357,7 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) -*/ VOID vMgrCreateOwnIBSS( - IN HANDLE hDeviceContext, + HANDLE hDeviceContext, OUT PCMD_STATUS pStatus ) { @@ -2631,7 +2631,7 @@ vMgrCreateOwnIBSS( VOID vMgrJoinBSSBegin( - IN HANDLE hDeviceContext, + HANDLE hDeviceContext, OUT PCMD_STATUS pStatus ) { @@ -2962,9 +2962,9 @@ vMgrJoinBSSBegin( static VOID s_vMgrSynchBSS ( - IN PSDevice pDevice, - IN UINT uBSSMode, - IN PKnownBSS pCurr, + PSDevice pDevice, + UINT uBSSMode, + PKnownBSS pCurr, OUT PCMD_STATUS pStatus ) { @@ -3123,8 +3123,8 @@ s_vMgrSynchBSS ( //mike add: fix NetworkManager 0.7.0 hidden ssid mode in WPA encryption // ,need reset eAuthenMode and eEncryptionStatus static VOID Encyption_Rebuild( - IN PSDevice pDevice, - IN PKnownBSS pCurr + PSDevice pDevice, + PKnownBSS pCurr ) { PSMgmtObject pMgmt = &(pDevice->sMgmtObj); @@ -3181,8 +3181,8 @@ s_vMgrSynchBSS ( static VOID s_vMgrFormatTIM( - IN PSMgmtObject pMgmt, - IN PWLAN_IE_TIM pTIM + PSMgmtObject pMgmt, + PWLAN_IE_TIM pTIM ) { BYTE byMask[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80}; @@ -3256,16 +3256,16 @@ s_vMgrFormatTIM( static PSTxMgmtPacket s_MgrMakeBeacon( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN WORD wCurrCapInfo, - IN WORD wCurrBeaconPeriod, - IN UINT uCurrChannel, - IN WORD wCurrATIMWinodw, - IN PWLAN_IE_SSID pCurrSSID, - IN PBYTE pCurrBSSID, - IN PWLAN_IE_SUPP_RATES pCurrSuppRates, - IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates + PSDevice pDevice, + PSMgmtObject pMgmt, + WORD wCurrCapInfo, + WORD wCurrBeaconPeriod, + UINT uCurrChannel, + WORD wCurrATIMWinodw, + PWLAN_IE_SSID pCurrSSID, + PBYTE pCurrBSSID, + PWLAN_IE_SUPP_RATES pCurrSuppRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates ) { PSTxMgmtPacket pTxPacket = NULL; @@ -3430,18 +3430,18 @@ s_MgrMakeBeacon( PSTxMgmtPacket s_MgrMakeProbeResponse( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN WORD wCurrCapInfo, - IN WORD wCurrBeaconPeriod, - IN UINT uCurrChannel, - IN WORD wCurrATIMWinodw, - IN PBYTE pDstAddr, - IN PWLAN_IE_SSID pCurrSSID, - IN PBYTE pCurrBSSID, - IN PWLAN_IE_SUPP_RATES pCurrSuppRates, - IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates, - IN BYTE byPHYType + PSDevice pDevice, + PSMgmtObject pMgmt, + WORD wCurrCapInfo, + WORD wCurrBeaconPeriod, + UINT uCurrChannel, + WORD wCurrATIMWinodw, + PBYTE pDstAddr, + PWLAN_IE_SSID pCurrSSID, + PBYTE pCurrBSSID, + PWLAN_IE_SUPP_RATES pCurrSuppRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates, + BYTE byPHYType ) { PSTxMgmtPacket pTxPacket = NULL; @@ -3562,14 +3562,14 @@ s_MgrMakeProbeResponse( PSTxMgmtPacket s_MgrMakeAssocRequest( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PBYTE pDAddr, - IN WORD wCurrCapInfo, - IN WORD wListenInterval, - IN PWLAN_IE_SSID pCurrSSID, - IN PWLAN_IE_SUPP_RATES pCurrRates, - IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates + PSDevice pDevice, + PSMgmtObject pMgmt, + PBYTE pDAddr, + WORD wCurrCapInfo, + WORD wListenInterval, + PWLAN_IE_SSID pCurrSSID, + PWLAN_IE_SUPP_RATES pCurrRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates ) { PSTxMgmtPacket pTxPacket = NULL; @@ -3773,13 +3773,17 @@ s_MgrMakeAssocRequest( pwPMKID = (PWORD)pbyRSN; // Point to PMKID count *pwPMKID = 0; // Initialize PMKID count pbyRSN += 2; // Point to PMKID list - for (ii = 0; ii < pDevice->gsPMKID.BSSIDInfoCount; ii++) { - if ( !memcmp(&pDevice->gsPMKID.BSSIDInfo[ii].BSSID[0], pMgmt->abyCurrBSSID, U_ETHER_ADDR_LEN)) { - (*pwPMKID) ++; - memcpy(pbyRSN, pDevice->gsPMKID.BSSIDInfo[ii].PMKID, 16); - pbyRSN += 16; - } - } + for (ii = 0; ii < pDevice->gsPMKID.BSSIDInfoCount; ii++) { + if (!memcmp(&pDevice->gsPMKID.BSSIDInfo[ii].BSSID[0], + pMgmt->abyCurrBSSID, + ETH_ALEN)) { + (*pwPMKID)++; + memcpy(pbyRSN, + pDevice->gsPMKID.BSSIDInfo[ii].PMKID, + 16); + pbyRSN += 16; + } + } if (*pwPMKID != 0) { sFrame.pRSN->len += (2 + (*pwPMKID)*16); } @@ -3820,14 +3824,14 @@ s_MgrMakeAssocRequest( PSTxMgmtPacket s_MgrMakeReAssocRequest( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PBYTE pDAddr, - IN WORD wCurrCapInfo, - IN WORD wListenInterval, - IN PWLAN_IE_SSID pCurrSSID, - IN PWLAN_IE_SUPP_RATES pCurrRates, - IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates + PSDevice pDevice, + PSMgmtObject pMgmt, + PBYTE pDAddr, + WORD wCurrCapInfo, + WORD wListenInterval, + PWLAN_IE_SSID pCurrSSID, + PWLAN_IE_SUPP_RATES pCurrRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates ) { PSTxMgmtPacket pTxPacket = NULL; @@ -4030,10 +4034,14 @@ s_MgrMakeReAssocRequest( *pwPMKID = 0; // Initialize PMKID count pbyRSN += 2; // Point to PMKID list for (ii = 0; ii < pDevice->gsPMKID.BSSIDInfoCount; ii++) { - if ( !memcmp(&pDevice->gsPMKID.BSSIDInfo[ii].BSSID[0], pMgmt->abyCurrBSSID, U_ETHER_ADDR_LEN)) { - (*pwPMKID) ++; - memcpy(pbyRSN, pDevice->gsPMKID.BSSIDInfo[ii].PMKID, 16); - pbyRSN += 16; + if (!memcmp(&pDevice->gsPMKID.BSSIDInfo[ii].BSSID[0], + pMgmt->abyCurrBSSID, + ETH_ALEN)) { + (*pwPMKID)++; + memcpy(pbyRSN, + pDevice->gsPMKID.BSSIDInfo[ii].PMKID, + 16); + pbyRSN += 16; } } if (*pwPMKID != 0) { @@ -4057,8 +4065,6 @@ s_MgrMakeReAssocRequest( return pTxPacket; } - - /*+ * * Routine Description: @@ -4070,17 +4076,16 @@ s_MgrMakeReAssocRequest( * -*/ - PSTxMgmtPacket s_MgrMakeAssocResponse( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN WORD wCurrCapInfo, - IN WORD wAssocStatus, - IN WORD wAssocAID, - IN PBYTE pDstAddr, - IN PWLAN_IE_SUPP_RATES pCurrSuppRates, - IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates + PSDevice pDevice, + PSMgmtObject pMgmt, + WORD wCurrCapInfo, + WORD wAssocStatus, + WORD wAssocAID, + PBYTE pDstAddr, + PWLAN_IE_SUPP_RATES pCurrSuppRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates ) { PSTxMgmtPacket pTxPacket = NULL; @@ -4147,14 +4152,14 @@ s_MgrMakeAssocResponse( PSTxMgmtPacket s_MgrMakeReAssocResponse( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN WORD wCurrCapInfo, - IN WORD wAssocStatus, - IN WORD wAssocAID, - IN PBYTE pDstAddr, - IN PWLAN_IE_SUPP_RATES pCurrSuppRates, - IN PWLAN_IE_SUPP_RATES pCurrExtSuppRates + PSDevice pDevice, + PSMgmtObject pMgmt, + WORD wCurrCapInfo, + WORD wAssocStatus, + WORD wAssocAID, + PBYTE pDstAddr, + PWLAN_IE_SUPP_RATES pCurrSuppRates, + PWLAN_IE_SUPP_RATES pCurrExtSuppRates ) { PSTxMgmtPacket pTxPacket = NULL; @@ -4221,9 +4226,9 @@ s_MgrMakeReAssocResponse( static VOID s_vMgrRxProbeResponse( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket + PSDevice pDevice, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket ) { PKnownBSS pBSSList = NULL; @@ -4351,9 +4356,9 @@ if(ChannelExceedZoneType(pDevice,byCurrChannel)==TRUE) static VOID s_vMgrRxProbeRequest( - IN PSDevice pDevice, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket + PSDevice pDevice, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket ) { WLAN_FR_PROBEREQ sFrame; @@ -4447,9 +4452,9 @@ s_vMgrRxProbeRequest( VOID vMgrRxManagePacket( - IN HANDLE hDeviceContext, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket + HANDLE hDeviceContext, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -4599,8 +4604,8 @@ vMgrRxManagePacket( -*/ BOOL bMgrPrepareBeaconToSend( - IN HANDLE hDeviceContext, - IN PSMgmtObject pMgmt + HANDLE hDeviceContext, + PSMgmtObject pMgmt ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -4655,8 +4660,8 @@ bMgrPrepareBeaconToSend( static VOID s_vMgrLogStatus( - IN PSMgmtObject pMgmt, - IN WORD wStatus + PSMgmtObject pMgmt, + WORD wStatus ) { switch( wStatus ){ @@ -4724,9 +4729,9 @@ s_vMgrLogStatus( -*/ BOOL bAdd_PMKID_Candidate ( - IN HANDLE hDeviceContext, - IN PBYTE pbyBSSID, - IN PSRSNCapObject psRSNCapObj + HANDLE hDeviceContext, + PBYTE pbyBSSID, + PSRSNCapObject psRSNCapObj ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -4745,13 +4750,16 @@ bAdd_PMKID_Candidate ( // Update Old Candidate for (ii = 0; ii < pDevice->gsPMKIDCandidate.NumCandidates; ii++) { - pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[ii]; - if ( !memcmp(pCandidateList->BSSID, pbyBSSID, U_ETHER_ADDR_LEN)) { - if ((psRSNCapObj->bRSNCapExist == TRUE) && (psRSNCapObj->wRSNCap & BIT0)) { - pCandidateList->Flags |= NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED; - } else { - pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); - } + pCandidateList = &pDevice->gsPMKIDCandidate.CandidateList[ii]; + if (!memcmp(pCandidateList->BSSID, pbyBSSID, ETH_ALEN)) { + if ((psRSNCapObj->bRSNCapExist == TRUE) + && (psRSNCapObj->wRSNCap & BIT0)) { + pCandidateList->Flags |= + NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED; + } else { + pCandidateList->Flags &= + ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); + } return TRUE; } } @@ -4763,7 +4771,7 @@ bAdd_PMKID_Candidate ( } else { pCandidateList->Flags &= ~(NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED); } - memcpy(pCandidateList->BSSID, pbyBSSID, U_ETHER_ADDR_LEN); + memcpy(pCandidateList->BSSID, pbyBSSID, ETH_ALEN); pDevice->gsPMKIDCandidate.NumCandidates++; DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"NumCandidates:%d\n", (int)pDevice->gsPMKIDCandidate.NumCandidates); return TRUE; @@ -4785,7 +4793,7 @@ bAdd_PMKID_Candidate ( -*/ VOID vFlush_PMKID_Candidate ( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ) { PSDevice pDevice = (PSDevice)hDeviceContext; @@ -4798,8 +4806,8 @@ vFlush_PMKID_Candidate ( static BOOL s_bCipherMatch ( - IN PKnownBSS pBSSNode, - IN NDIS_802_11_ENCRYPTION_STATUS EncStatus, + PKnownBSS pBSSNode, + NDIS_802_11_ENCRYPTION_STATUS EncStatus, OUT PBYTE pbyCCSPK, OUT PBYTE pbyCCSGK ) diff --git a/drivers/staging/vt6656/wmgr.h b/drivers/staging/vt6656/wmgr.h index c682a7fcbefa..f6774cedacfa 100644 --- a/drivers/staging/vt6656/wmgr.h +++ b/drivers/staging/vt6656/wmgr.h @@ -410,93 +410,93 @@ typedef struct tagSMgmtObject void vMgrObjectInit( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ); void vMgrAssocBeginSta( - IN HANDLE hDeviceContext, - IN PSMgmtObject pMgmt, + HANDLE hDeviceContext, + PSMgmtObject pMgmt, OUT PCMD_STATUS pStatus ); VOID vMgrReAssocBeginSta( - IN HANDLE hDeviceContext, - IN PSMgmtObject pMgmt, + HANDLE hDeviceContext, + PSMgmtObject pMgmt, OUT PCMD_STATUS pStatus ); VOID vMgrDisassocBeginSta( - IN HANDLE hDeviceContext, - IN PSMgmtObject pMgmt, - IN PBYTE abyDestAddress, - IN WORD wReason, + HANDLE hDeviceContext, + PSMgmtObject pMgmt, + PBYTE abyDestAddress, + WORD wReason, OUT PCMD_STATUS pStatus ); VOID vMgrAuthenBeginSta( - IN HANDLE hDeviceContext, - IN PSMgmtObject pMgmt, + HANDLE hDeviceContext, + PSMgmtObject pMgmt, OUT PCMD_STATUS pStatus ); VOID vMgrCreateOwnIBSS( - IN HANDLE hDeviceContext, + HANDLE hDeviceContext, OUT PCMD_STATUS pStatus ); VOID vMgrJoinBSSBegin( - IN HANDLE hDeviceContext, + HANDLE hDeviceContext, OUT PCMD_STATUS pStatus ); VOID vMgrRxManagePacket( - IN HANDLE hDeviceContext, - IN PSMgmtObject pMgmt, - IN PSRxMgmtPacket pRxPacket + HANDLE hDeviceContext, + PSMgmtObject pMgmt, + PSRxMgmtPacket pRxPacket ); /* VOID vMgrScanBegin( - IN HANDLE hDeviceContext, + HANDLE hDeviceContext, OUT PCMD_STATUS pStatus ); */ VOID vMgrDeAuthenBeginSta( - IN HANDLE hDeviceContext, - IN PSMgmtObject pMgmt, - IN PBYTE abyDestAddress, - IN WORD wReason, + HANDLE hDeviceContext, + PSMgmtObject pMgmt, + PBYTE abyDestAddress, + WORD wReason, OUT PCMD_STATUS pStatus ); BOOL bMgrPrepareBeaconToSend( - IN HANDLE hDeviceContext, - IN PSMgmtObject pMgmt + HANDLE hDeviceContext, + PSMgmtObject pMgmt ); BOOL bAdd_PMKID_Candidate ( - IN HANDLE hDeviceContext, - IN PBYTE pbyBSSID, - IN PSRSNCapObject psRSNCapObj + HANDLE hDeviceContext, + PBYTE pbyBSSID, + PSRSNCapObject psRSNCapObj ); VOID vFlush_PMKID_Candidate ( - IN HANDLE hDeviceContext + HANDLE hDeviceContext ); #endif // __WMGR_H__ diff --git a/drivers/staging/vt6656/wpa.c b/drivers/staging/vt6656/wpa.c index 5da671418b52..9992291ab22c 100644 --- a/drivers/staging/vt6656/wpa.c +++ b/drivers/staging/vt6656/wpa.c @@ -70,7 +70,7 @@ const BYTE abyOUI05[4] = { 0x00, 0x50, 0xf2, 0x05 }; VOID WPA_ClearRSN ( - IN PKnownBSS pBSSList + PKnownBSS pBSSList ) { int ii; @@ -106,8 +106,8 @@ WPA_ClearRSN ( -*/ VOID WPA_ParseRSN ( - IN PKnownBSS pBSSList, - IN PWLAN_IE_RSN_EXT pRSN + PKnownBSS pBSSList, + PWLAN_IE_RSN_EXT pRSN ) { PWLAN_IE_RSN_AUTH pIE_RSN_Auth = NULL; @@ -241,7 +241,7 @@ BOOL WPA_SearchRSN ( BYTE byCmd, BYTE byEncrypt, - IN PKnownBSS pBSSList + PKnownBSS pBSSList ) { int ii; @@ -299,7 +299,7 @@ WPA_SearchRSN ( -*/ BOOL WPAb_Is_RSN ( - IN PWLAN_IE_RSN_EXT pRSN + PWLAN_IE_RSN_EXT pRSN ) { if (pRSN == NULL) diff --git a/drivers/staging/vt6656/wpa.h b/drivers/staging/vt6656/wpa.h index 9d9ce01d0c61..0a955b3200fe 100644 --- a/drivers/staging/vt6656/wpa.h +++ b/drivers/staging/vt6656/wpa.h @@ -60,25 +60,25 @@ VOID WPA_ClearRSN( - IN PKnownBSS pBSSList + PKnownBSS pBSSList ); VOID WPA_ParseRSN( - IN PKnownBSS pBSSList, - IN PWLAN_IE_RSN_EXT pRSN + PKnownBSS pBSSList, + PWLAN_IE_RSN_EXT pRSN ); BOOL WPA_SearchRSN( BYTE byCmd, BYTE byEncrypt, - IN PKnownBSS pBSSList + PKnownBSS pBSSList ); BOOL WPAb_Is_RSN( - IN PWLAN_IE_RSN_EXT pRSN + PWLAN_IE_RSN_EXT pRSN ); #endif // __WPA_H__ diff --git a/drivers/staging/vt6656/wpa2.c b/drivers/staging/vt6656/wpa2.c index fa3aeedfb278..9a972a4f6433 100644 --- a/drivers/staging/vt6656/wpa2.c +++ b/drivers/staging/vt6656/wpa2.c @@ -73,7 +73,7 @@ const BYTE abyOUIPSK[4] = { 0x00, 0x0F, 0xAC, 0x02 }; -*/ VOID WPA2_ClearRSN ( - IN PKnownBSS pBSSNode + PKnownBSS pBSSNode ) { int ii; @@ -108,8 +108,8 @@ WPA2_ClearRSN ( -*/ VOID WPA2vParseRSN ( - IN PKnownBSS pBSSNode, - IN PWLAN_IE_RSN pRSN + PKnownBSS pBSSNode, + PWLAN_IE_RSN pRSN ) { int i, j; @@ -262,7 +262,7 @@ WPA2vParseRSN ( -*/ UINT WPA2uSetIEs( - IN PVOID pMgmtHandle, + PVOID pMgmtHandle, OUT PWLAN_IE_RSN pRSNIEs ) { @@ -337,20 +337,25 @@ WPA2uSetIEs( } pRSNIEs->len +=2; - if ((pMgmt->gsPMKIDCache.BSSIDInfoCount > 0) && - (pMgmt->bRoaming == TRUE) && + if ((pMgmt->gsPMKIDCache.BSSIDInfoCount > 0) && + (pMgmt->bRoaming == TRUE) && (pMgmt->eAuthenMode == WMAC_AUTH_WPA2)) { - // RSN PMKID - pwPMKID = (PWORD)(&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++) { - if ( !memcmp(&pMgmt->gsPMKIDCache.BSSIDInfo[ii].abyBSSID[0], pMgmt->abyCurrBSSID, U_ETHER_ADDR_LEN)) { - (*pwPMKID) ++; - memcpy(pbyBuffer, pMgmt->gsPMKIDCache.BSSIDInfo[ii].abyPMKID, 16); - pbyBuffer += 16; - } - } + /* RSN PMKID, pointer to PMKID count */ + pwPMKID = (PWORD)(&pRSNIEs->abyRSN[18]); + *pwPMKID = 0; /* Initialize PMKID count */ + pbyBuffer = &pRSNIEs->abyRSN[20]; /* Point to PMKID list */ + for (ii = 0; ii < pMgmt->gsPMKIDCache.BSSIDInfoCount; ii++) { + if (!memcmp(&pMgmt-> + gsPMKIDCache.BSSIDInfo[ii].abyBSSID[0], + pMgmt->abyCurrBSSID, + ETH_ALEN)) { + (*pwPMKID)++; + memcpy(pbyBuffer, + pMgmt->gsPMKIDCache.BSSIDInfo[ii].abyPMKID, + 16); + pbyBuffer += 16; + } + } if (*pwPMKID != 0) { pRSNIEs->len += (2 + (*pwPMKID)*16); } else { diff --git a/drivers/staging/vt6656/wpa2.h b/drivers/staging/vt6656/wpa2.h index e553b3869008..51fb3fd8b659 100644 --- a/drivers/staging/vt6656/wpa2.h +++ b/drivers/staging/vt6656/wpa2.h @@ -60,18 +60,18 @@ typedef struct tagSPMKIDCache { VOID WPA2_ClearRSN ( - IN PKnownBSS pBSSNode + PKnownBSS pBSSNode ); VOID WPA2vParseRSN ( - IN PKnownBSS pBSSNode, - IN PWLAN_IE_RSN pRSN + PKnownBSS pBSSNode, + PWLAN_IE_RSN pRSN ); UINT WPA2uSetIEs( - IN PVOID pMgmtHandle, + PVOID pMgmtHandle, OUT PWLAN_IE_RSN pRSNIEs ); diff --git a/drivers/staging/vt6656/wpactl.c b/drivers/staging/vt6656/wpactl.c index 4555bc0448b9..25b784c26e8f 100644 --- a/drivers/staging/vt6656/wpactl.c +++ b/drivers/staging/vt6656/wpactl.c @@ -103,7 +103,7 @@ static int wpa_init_wpadev(PSDevice pDevice) wpadev_priv = netdev_priv(pDevice->wpadev); *wpadev_priv = *pDevice; - memcpy(pDevice->wpadev->dev_addr, dev->dev_addr, U_ETHER_ADDR_LEN); + memcpy(pDevice->wpadev->dev_addr, dev->dev_addr, ETH_ALEN); pDevice->wpadev->base_addr = dev->base_addr; pDevice->wpadev->irq = dev->irq; pDevice->wpadev->mem_start = dev->mem_start; diff --git a/drivers/staging/wavelan/i82586.h b/drivers/staging/wavelan/i82586.h index 5f65b250646f..27f832498139 100644 --- a/drivers/staging/wavelan/i82586.h +++ b/drivers/staging/wavelan/i82586.h @@ -30,14 +30,13 @@ #define ADDR_LEN 6 #define I82586NULL 0xFFFF -#define toff(t,p,f) (unsigned short)((void *)(&((t *)((void *)0 + (p)))->f) - (void *)0) +#define toff(t, p, f) (unsigned short)((void *)(&((t *)((void *)0 + (p)))->f) - (void *)0) /* * System Configuration Pointer (SCP). */ typedef struct scp_t scp_t; -struct scp_t -{ +struct scp_t { unsigned short scp_sysbus; /* 82586 bus width: */ #define SCP_SY_16BBUS (0x0 << 0) /* 16 bits */ #define SCP_SY_8BBUS (0x1 << 0) /* 8 bits. */ @@ -50,8 +49,7 @@ struct scp_t * Intermediate System Configuration Pointer (ISCP). */ typedef struct iscp_t iscp_t; -struct iscp_t -{ +struct iscp_t { unsigned short iscp_busy; /* set by CPU before first CA, */ /* cleared by 82586 after read. */ unsigned short iscp_offset; /* offset of SCB */ @@ -67,8 +65,7 @@ struct iscp_t * then issues a Channel Attention (CA) to alert the 82586. */ typedef struct scb_t scb_t; -struct scb_t -{ +struct scb_t { unsigned short scb_status; /* Status of 82586 */ #define SCB_ST_INT (0xF << 12) /* Some of: */ #define SCB_ST_CX (0x1 << 15) /* Cmd completed */ @@ -118,14 +115,13 @@ struct scb_t unsigned short scb_ovrnerrs; /* Frames lost due to slow bus */ }; -#define scboff(p,f) toff(scb_t, p, f) +#define scboff(p, f) toff(scb_t, p, f) /* * The eight Action Commands. */ typedef enum acmd_e acmd_e; -enum acmd_e -{ +enum acmd_e { acmd_nop = 0, /* Do nothing */ acmd_ia_setup = 1, /* Load an (ethernet) address into the */ /* 82586 */ @@ -143,8 +139,7 @@ enum acmd_e * Generic Action Command header. */ typedef struct ach_t ach_t; -struct ach_t -{ +struct ach_t { unsigned short ac_status; /* Command status: */ #define AC_SFLD_C (0x1 << 15) /* Command completed */ #define AC_SFLD_B (0x1 << 14) /* Busy executing */ @@ -172,14 +167,13 @@ struct ach_t unsigned short ac_link; /* Next Action Command */ }; -#define acoff(p,f) toff(ach_t, p, f) +#define acoff(p, f) toff(ach_t, p, f) /* * The Nop Action Command. */ typedef struct ac_nop_t ac_nop_t; -struct ac_nop_t -{ +struct ac_nop_t { ach_t nop_h; }; @@ -187,8 +181,7 @@ struct ac_nop_t * The IA-Setup Action Command. */ typedef struct ac_ias_t ac_ias_t; -struct ac_ias_t -{ +struct ac_ias_t { ach_t ias_h; unsigned char ias_addr[ADDR_LEN]; /* The (ethernet) address */ }; @@ -197,8 +190,7 @@ struct ac_ias_t * The Configure Action Command. */ typedef struct ac_cfg_t ac_cfg_t; -struct ac_cfg_t -{ +struct ac_cfg_t { ach_t cfg_h; unsigned char cfg_byte_cnt; /* Size foll data: 4-12 */ #define AC_CFG_BYTE_CNT(v) (((v) & 0xF) << 0) @@ -255,8 +247,7 @@ struct ac_cfg_t * The MC-Setup Action Command. */ typedef struct ac_mcs_t ac_mcs_t; -struct ac_mcs_t -{ +struct ac_mcs_t { ach_t mcs_h; unsigned short mcs_cnt; /* No. of bytes of MC addresses */ #if 0 @@ -271,8 +262,7 @@ struct ac_mcs_t * The Transmit Action Command. */ typedef struct ac_tx_t ac_tx_t; -struct ac_tx_t -{ +struct ac_tx_t { ach_t tx_h; unsigned short tx_tbd_offset; /* Address of list of buffers. */ #if 0 @@ -290,8 +280,7 @@ ac_cfg_t action command. * The Time Domain Reflectometer Action Command. */ typedef struct ac_tdr_t ac_tdr_t; -struct ac_tdr_t -{ +struct ac_tdr_t { ach_t tdr_h; unsigned short tdr_result; /* Result. */ #define AC_TDR_LNK_OK (0x1 << 15) /* No link problem */ @@ -307,8 +296,7 @@ struct ac_tdr_t * The Dump Action Command. */ typedef struct ac_dmp_t ac_dmp_t; -struct ac_dmp_t -{ +struct ac_dmp_t { ach_t dmp_h; unsigned short dmp_offset; /* Result. */ }; @@ -322,8 +310,7 @@ struct ac_dmp_t * The Diagnose Action Command. */ typedef struct ac_dgn_t ac_dgn_t; -struct ac_dgn_t -{ +struct ac_dgn_t { ach_t dgn_h; }; @@ -331,8 +318,7 @@ struct ac_dgn_t * Transmit Buffer Descriptor (TBD). */ typedef struct tbd_t tbd_t; -struct tbd_t -{ +struct tbd_t { unsigned short tbd_status; /* Written by the CPU */ #define TBD_STATUS_EOF (0x1 << 15) /* This TBD is the */ /* last for this frame */ @@ -347,8 +333,7 @@ struct tbd_t * Receive Buffer Descriptor (RBD). */ typedef struct rbd_t rbd_t; -struct rbd_t -{ +struct rbd_t { unsigned short rbd_status; /* Written by the 82586 */ #define RBD_STATUS_EOF (0x1 << 15) /* This RBD is the */ /* last for this frame */ @@ -365,14 +350,13 @@ struct rbd_t /* buffer can hold */ }; -#define rbdoff(p,f) toff(rbd_t, p, f) +#define rbdoff(p, f) toff(rbd_t, p, f) /* * Frame Descriptor (FD). */ typedef struct fd_t fd_t; -struct fd_t -{ +struct fd_t { unsigned short fd_status; /* Written by the 82586 */ #define FD_STATUS_C (0x1 << 15) /* Completed storing frame */ #define FD_STATUS_B (0x1 << 14) /* FD was consumed by RU */ @@ -403,7 +387,7 @@ in case, we leave the space. /* Written by 82586 */ }; -#define fdoff(p,f) toff(fd_t, p, f) +#define fdoff(p, f) toff(fd_t, p, f) /* * This software may only be used and distributed diff --git a/drivers/staging/wavelan/wavelan.c b/drivers/staging/wavelan/wavelan.c index f44ef351647b..f6b4e0933703 100644 --- a/drivers/staging/wavelan/wavelan.c +++ b/drivers/staging/wavelan/wavelan.c @@ -36,7 +36,7 @@ static u8 wv_irq_to_psa(int irq) /*------------------------------------------------------------------*/ /* - * Translate PSA irq parameter to irq number + * Translate PSA irq parameter to irq number */ static int __init wv_psa_to_irq(u8 irqval) { @@ -55,7 +55,7 @@ static int __init wv_psa_to_irq(u8 irqval) * * One major difference with the PCMCIA hardware (except the port mapping) * is that we have to keep the state of the Host Control Register - * because of the interrupt enable & bus size flags. + *because of the interrupt enable & bus size flags. */ /*------------------------------------------------------------------*/ @@ -64,7 +64,7 @@ static int __init wv_psa_to_irq(u8 irqval) */ static inline u16 hasr_read(unsigned long ioaddr) { - return (inw(HASR(ioaddr))); + return inw(HASR(ioaddr)); } /* hasr_read */ /*------------------------------------------------------------------*/ @@ -132,11 +132,11 @@ static inline void wv_16_on(unsigned long ioaddr, u16 hacr) * Disable interrupts on the WaveLAN hardware. * (called by wv_82586_stop()) */ -static inline void wv_ints_off(struct net_device * dev) +static inline void wv_ints_off(struct net_device *dev) { net_local *lp = netdev_priv(dev); unsigned long ioaddr = dev->base_addr; - + lp->hacr &= ~HACR_INTRON; hacr_write(ioaddr, lp->hacr); } /* wv_ints_off */ @@ -146,7 +146,7 @@ static inline void wv_ints_off(struct net_device * dev) * Enable interrupts on the WaveLAN hardware. * (called by wv_hw_reset()) */ -static inline void wv_ints_on(struct net_device * dev) +static inline void wv_ints_on(struct net_device *dev) { net_local *lp = netdev_priv(dev); unsigned long ioaddr = dev->base_addr; @@ -167,9 +167,11 @@ static inline void wv_ints_on(struct net_device * dev) /* * Read bytes from the PSA. */ -static void psa_read(unsigned long ioaddr, u16 hacr, int o, /* offset in PSA */ - u8 * b, /* buffer to fill */ - int n) +static void psa_read(unsigned long ioaddr, + u16 hacr, + int o, /* offset in PSA */ + u8 *b, /*buffer to fill */ + int n) { /* size to read */ wv_16_off(ioaddr, hacr); @@ -186,9 +188,11 @@ static void psa_read(unsigned long ioaddr, u16 hacr, int o, /* offset in PSA */ /* * Write the Parameter Storage Area to the WaveLAN card's memory. */ -static void psa_write(unsigned long ioaddr, u16 hacr, int o, /* Offset in PSA */ - u8 * b, /* Buffer in memory */ - int n) +static void psa_write(unsigned long ioaddr, + u16 hacr, + int o, /* Offset in PSA */ + u8 *b, /*buffer in memory */ + int n) { /* Length of buffer */ int count = 0; @@ -203,8 +207,8 @@ static void psa_write(unsigned long ioaddr, u16 hacr, int o, /* Offset in PSA */ /* Wait for the memory to finish its write cycle */ count = 0; - while ((count++ < 100) && - (hasr_read(ioaddr) & HASR_PSA_BUSY)) mdelay(1); + while ((count++ < 100) && (hasr_read(ioaddr) & HASR_PSA_BUSY)) + mdelay(1); } wv_16_on(ioaddr, hacr); @@ -221,8 +225,8 @@ static void psa_write(unsigned long ioaddr, u16 hacr, int o, /* Offset in PSA */ * The Windows drivers don't use the CRC, but the AP and the PtP tool * depend on it. */ -static u16 psa_crc(u8 * psa, /* The PSA */ - int size) +static u16 psa_crc(u8 *psa, /* The PSA */ + int size) { /* Number of short for CRC */ int byte_cnt; /* Loop on the PSA */ u16 crc_bytes = 0; /* Data in the PSA */ @@ -247,7 +251,9 @@ static u16 psa_crc(u8 * psa, /* The PSA */ /* * update the checksum field in the Wavelan's PSA */ -static void update_psa_checksum(struct net_device * dev, unsigned long ioaddr, u16 hacr) +static void update_psa_checksum(struct net_device *dev, + unsigned long ioaddr, + u16 hacr) { #ifdef SET_PSA_CRC psa_t psa; @@ -279,7 +285,8 @@ static void update_psa_checksum(struct net_device * dev, unsigned long ioaddr, u if (crc != 0) printk(KERN_WARNING - "%s: update_psa_checksum(): CRC does not agree with PSA data (even after recalculating)\n", + "%s: update_psa_checksum(): CRC does not \ + agree with PSA data (even after recalculating)\n", dev->name); #endif /* DEBUG_IOCTL_INFO */ #endif /* SET_PSA_CRC */ @@ -305,7 +312,7 @@ static void mmc_out(unsigned long ioaddr, u16 o, u8 d) * Routine to write bytes to the Modem Management Controller. * We start at the end because it is the way it should be! */ -static void mmc_write(unsigned long ioaddr, u8 o, u8 * b, int n) +static void mmc_write(unsigned long ioaddr, u8 o, u8 *b, int n) { o += n; b += n; @@ -340,7 +347,7 @@ static u8 mmc_in(unsigned long ioaddr, u16 o) * (code has just been moved in the above function) * We start at the end because it is the way it should be! */ -static inline void mmc_read(unsigned long ioaddr, u8 o, u8 * b, int n) +static inline void mmc_read(unsigned long ioaddr, u8 o, u8 *b, int n) { o += n; b += n; @@ -369,15 +376,16 @@ static inline int mmc_encr(unsigned long ioaddr) * Wait for the frequency EEPROM to complete a command. * I hope this one will be optimally inlined. */ -static inline void fee_wait(unsigned long ioaddr, /* I/O port of the card */ - int delay, /* Base delay to wait for */ +static inline void fee_wait(unsigned long ioaddr, /* I/O port of the card */ + int delay, /*base delay to wait for */ int number) { /* Number of time to wait */ int count = 0; /* Wait only a limited time */ while ((count++ < number) && (mmc_in(ioaddr, mmroff(0, mmr_fee_status)) & - MMR_FEE_STATUS_BUSY)) udelay(delay); + MMR_FEE_STATUS_BUSY)) + udelay(delay); } /*------------------------------------------------------------------*/ @@ -386,7 +394,7 @@ static inline void fee_wait(unsigned long ioaddr, /* I/O port of the card */ */ static void fee_read(unsigned long ioaddr, /* I/O port of the card */ u16 o, /* destination offset */ - u16 * b, /* data buffer */ + u16 *b, /* data buffer */ int n) { /* number of registers */ b += n; /* Position at the end of the area */ @@ -414,12 +422,12 @@ static void fee_read(unsigned long ioaddr, /* I/O port of the card */ /* * Write bytes from the Frequency EEPROM (frequency select cards). * This is a bit complicated, because the frequency EEPROM has to - * be unprotected and the write enabled. + *be unprotected and the write enabled. * Jean II */ static void fee_write(unsigned long ioaddr, /* I/O port of the card */ u16 o, /* destination offset */ - u16 * b, /* data buffer */ + u16 *b, /* data buffer */ int n) { /* number of registers */ b += n; /* Position at the end of the area. */ @@ -473,7 +481,9 @@ static void fee_write(unsigned long ioaddr, /* I/O port of the card */ mmc_out(ioaddr, mmwoff(0, mmw_fee_ctrl), MMW_FEE_CTRL_WRITE); - /* WaveLAN documentation says to wait at least 10 ms for EEBUSY = 0 */ + /* WaveLAN documentation says to + * wait at least 10 ms for EEBUSY = 0 + */ mdelay(10); fee_wait(ioaddr, 10, 100); } @@ -504,7 +514,7 @@ static void fee_write(unsigned long ioaddr, /* I/O port of the card */ * Why does inlining this function make it fail? */ static /*inline */ void obram_read(unsigned long ioaddr, - u16 o, u8 * b, int n) + u16 o, u8 *b, int n) { outw(o, PIOR1(ioaddr)); insw(PIOP1(ioaddr), (unsigned short *) b, (n + 1) >> 1); @@ -514,7 +524,7 @@ static /*inline */ void obram_read(unsigned long ioaddr, /* * Write bytes to the on-board RAM. */ -static inline void obram_write(unsigned long ioaddr, u16 o, u8 * b, int n) +static inline void obram_write(unsigned long ioaddr, u16 o, u8 *b, int n) { outw(o, PIOR1(ioaddr)); outsw(PIOP1(ioaddr), (unsigned short *) b, (n + 1) >> 1); @@ -524,7 +534,7 @@ static inline void obram_write(unsigned long ioaddr, u16 o, u8 * b, int n) /* * Acknowledge the reading of the status issued by the i82586. */ -static void wv_ack(struct net_device * dev) +static void wv_ack(struct net_device *dev) { net_local *lp = netdev_priv(dev); unsigned long ioaddr = dev->base_addr; @@ -566,7 +576,7 @@ static void wv_ack(struct net_device * dev) * Set channel attention bit and busy wait until command has * completed, then acknowledge completion of the command. */ -static int wv_synchronous_cmd(struct net_device * dev, const char *str) +static int wv_synchronous_cmd(struct net_device *dev, const char *str) { net_local *lp = netdev_priv(dev); unsigned long ioaddr = dev->base_addr; @@ -613,7 +623,7 @@ static int wv_synchronous_cmd(struct net_device * dev, const char *str) * Check if done, and if OK. */ static int -wv_config_complete(struct net_device * dev, unsigned long ioaddr, net_local * lp) +wv_config_complete(struct net_device *dev, unsigned long ioaddr, net_local * lp) { unsigned short mcs_addr; unsigned short status; @@ -641,7 +651,8 @@ wv_config_complete(struct net_device * dev, unsigned long ioaddr, net_local * lp /* Check mc_config command */ if ((status & AC_SFLD_OK) != AC_SFLD_OK) printk(KERN_INFO - "%s: wv_config_complete(): set_multicast_address failed; status = 0x%x\n", + "%s: wv_config_complete(): \ + set_multicast_address failed; status = 0x%x\n", dev->name, status); /* check ia-config command */ @@ -650,7 +661,8 @@ wv_config_complete(struct net_device * dev, unsigned long ioaddr, net_local * lp (unsigned char *) &status, sizeof(status)); if ((status & AC_SFLD_OK) != AC_SFLD_OK) printk(KERN_INFO - "%s: wv_config_complete(): set_MAC_address failed; status = 0x%x\n", + "%s: wv_config_complete(): set_MAC_address \ + failed; status = 0x%x\n", dev->name, status); /* Check config command. */ @@ -659,7 +671,8 @@ wv_config_complete(struct net_device * dev, unsigned long ioaddr, net_local * lp (unsigned char *) &status, sizeof(status)); if ((status & AC_SFLD_OK) != AC_SFLD_OK) printk(KERN_INFO - "%s: wv_config_complete(): configure failed; status = 0x%x\n", + "%s: wv_config_complete(): configure failed; \ + status = 0x%x\n", dev->name, status); #endif /* DEBUG_CONFIG_ERROR */ @@ -680,7 +693,9 @@ wv_config_complete(struct net_device * dev, unsigned long ioaddr, net_local * lp * (called in wavelan_interrupt()). * Note : the spinlock is already grabbed for us. */ -static int wv_complete(struct net_device * dev, unsigned long ioaddr, net_local * lp) +static int wv_complete(struct net_device *dev, + unsigned long ioaddr, + net_local *lp) { int nreaped = 0; @@ -722,9 +737,8 @@ if (lp->tx_n_in_use > 0) /* Next one in the chain */ lp->tx_first_in_use += TXBLOCKZ; if (lp->tx_first_in_use >= - OFFSET_CU + - NTXBLOCKS * TXBLOCKZ) lp->tx_first_in_use -= - NTXBLOCKS * TXBLOCKZ; + OFFSET_CU + NTXBLOCKS * TXBLOCKZ) + lp->tx_first_in_use -= NTXBLOCKS * TXBLOCKZ; } /* Hack for reconfiguration */ @@ -741,7 +755,8 @@ if (lp->tx_n_in_use > 0) #ifdef DEBUG_TX_INFO if (ncollisions > 0) printk(KERN_DEBUG - "%s: wv_complete(): tx completed after %d collisions.\n", + "%s: wv_complete(): tx completed after \ + %d collisions.\n", dev->name, ncollisions); #endif } else { @@ -758,7 +773,8 @@ if (lp->tx_n_in_use > 0) dev->stats.tx_carrier_errors++; #ifdef DEBUG_TX_FAIL printk(KERN_DEBUG - "%s: wv_complete(): tx error: lost CTS.\n", + "%s: wv_complete(): tx error: \ + lost CTS.\n", dev->name); #endif } @@ -766,7 +782,8 @@ if (lp->tx_n_in_use > 0) dev->stats.tx_fifo_errors++; #ifdef DEBUG_TX_FAIL printk(KERN_DEBUG - "%s: wv_complete(): tx error: slow DMA.\n", + "%s: wv_complete(): tx error: \ + slow DMA.\n", dev->name); #endif } @@ -774,7 +791,8 @@ if (lp->tx_n_in_use > 0) dev->stats.tx_heartbeat_errors++; #ifdef DEBUG_TX_FAIL printk(KERN_DEBUG - "%s: wv_complete(): tx error: heart beat.\n", + "%s: wv_complete(): tx error: \ + heart beat.\n", dev->name); #endif } @@ -782,7 +800,8 @@ if (lp->tx_n_in_use > 0) dev->stats.tx_aborted_errors++; #ifdef DEBUG_TX_FAIL printk(KERN_DEBUG - "%s: wv_complete(): tx error: too many collisions.\n", + "%s: wv_complete(): tx error: \ + too many collisions.\n", dev->name); #endif } @@ -804,9 +823,9 @@ if (lp->tx_n_in_use > 0) /* * Inform upper layers. */ - if (lp->tx_n_in_use < NTXBLOCKS - 1) { + if (lp->tx_n_in_use < NTXBLOCKS - 1) netif_wake_queue(dev); - } + #ifdef DEBUG_INTERRUPT_TRACE printk(KERN_DEBUG "%s: <-wv_complete()\n", dev->name); #endif @@ -816,13 +835,13 @@ if (lp->tx_n_in_use > 0) /*------------------------------------------------------------------*/ /* * Reconfigure the i82586, or at least ask for it. - * Because wv_82586_config uses a transmission buffer, we must do it + *because wv_82586_config uses a transmission buffer, we must do it * when we are sure that there is one left, so we do it now * or in wavelan_packet_xmit() (I can't find any better place, * wavelan_interrupt is not an option), so you may experience * delays sometimes. */ -static void wv_82586_reconfig(struct net_device * dev) +static void wv_82586_reconfig(struct net_device *dev) { net_local *lp = netdev_priv(dev); unsigned long flags; @@ -831,13 +850,12 @@ static void wv_82586_reconfig(struct net_device * dev) lp->reconfig_82586 = 1; /* Check if we can do it now ! */ - if((netif_running(dev)) && !(netif_queue_stopped(dev))) { + if ((netif_running(dev)) && !(netif_queue_stopped(dev))) { spin_lock_irqsave(&lp->spinlock, flags); /* May fail */ wv_82586_config(dev); spin_unlock_irqrestore(&lp->spinlock, flags); - } - else { + } else { #ifdef DEBUG_CONFIG_INFO printk(KERN_DEBUG "%s: wv_82586_reconfig(): delayed (state = %lX)\n", @@ -857,7 +875,7 @@ static void wv_82586_reconfig(struct net_device * dev) /* * Print the formatted contents of the Parameter Storage Area. */ -static void wv_psa_show(psa_t * p) +static void wv_psa_show(psa_t *p) { printk(KERN_DEBUG "##### WaveLAN PSA contents: #####\n"); printk(KERN_DEBUG "psa_io_base_addr_1: 0x%02X %02X %02X %02X\n", @@ -919,13 +937,13 @@ static void wv_psa_show(psa_t * p) * Print the formatted status of the Modem Management Controller. * This function needs to be completed. */ -static void wv_mmc_show(struct net_device * dev) +static void wv_mmc_show(struct net_device *dev) { unsigned long ioaddr = dev->base_addr; net_local *lp = netdev_priv(dev); mmr_t m; - /* Basic check */ + /*basic check */ if (hasr_read(ioaddr) & HASR_NO_CLK) { printk(KERN_WARNING "%s: wv_mmc_show: modem not connected\n", @@ -935,7 +953,7 @@ static void wv_mmc_show(struct net_device * dev) /* Read the mmc */ mmc_out(ioaddr, mmwoff(0, mmw_freeze), 1); - mmc_read(ioaddr, 0, (u8 *) & m, sizeof(m)); + mmc_read(ioaddr, 0, (u8 *) &m, sizeof(m)); mmc_out(ioaddr, mmwoff(0, mmw_freeze), 0); /* Don't forget to update statistics */ @@ -1100,7 +1118,7 @@ static void wv_scb_show(unsigned long ioaddr) /* * Print the formatted status of the i82586's receive unit. */ -static void wv_ru_show(struct net_device * dev) +static void wv_ru_show(struct net_device *dev) { printk(KERN_DEBUG "##### WaveLAN i82586 receiver unit status: #####\n"); @@ -1115,7 +1133,7 @@ static void wv_ru_show(struct net_device * dev) /* * Display info about one control block of the i82586 memory. */ -static void wv_cu_show_one(struct net_device * dev, net_local * lp, int i, u16 p) +static void wv_cu_show_one(struct net_device *dev, net_local * lp, int i, u16 p) { unsigned long ioaddr; ac_tx_t actx; @@ -1144,7 +1162,7 @@ static void wv_cu_show_one(struct net_device * dev, net_local * lp, int i, u16 p /* * Print status of the command unit of the i82586. */ -static void wv_cu_show(struct net_device * dev) +static void wv_cu_show(struct net_device *dev) { net_local *lp = netdev_priv(dev); unsigned int i; @@ -1170,7 +1188,7 @@ static void wv_cu_show(struct net_device * dev) /* * Print the formatted status of the WaveLAN PCMCIA device driver. */ -static void wv_dev_show(struct net_device * dev) +static void wv_dev_show(struct net_device *dev) { printk(KERN_DEBUG "dev:"); printk(" state=%lX,", dev->state); @@ -1184,7 +1202,7 @@ static void wv_dev_show(struct net_device * dev) * Print the formatted status of the WaveLAN PCMCIA device driver's * private information. */ -static void wv_local_show(struct net_device * dev) +static void wv_local_show(struct net_device *dev) { net_local *lp; @@ -1245,7 +1263,7 @@ static inline void wv_packet_info(u8 * p, /* Packet to dump */ * This is the information which is displayed by the driver at startup. * There are lots of flags for configuring it to your liking. */ -static void wv_init_info(struct net_device * dev) +static void wv_init_info(struct net_device *dev) { short ioaddr = dev->base_addr; net_local *lp = netdev_priv(dev); @@ -1355,7 +1373,7 @@ static void wv_init_info(struct net_device * dev) * num_addrs > 0 Multicast mode, receive normal and MC packets, * and do best-effort filtering. */ -static void wavelan_set_multicast_list(struct net_device * dev) +static void wavelan_set_multicast_list(struct net_device *dev) { net_local *lp = netdev_priv(dev); @@ -1425,7 +1443,7 @@ static void wavelan_set_multicast_list(struct net_device * dev) * (Note : it was a nice way to test the reconfigure stuff...) */ #ifdef SET_MAC_ADDRESS -static int wavelan_set_mac_address(struct net_device * dev, void *addr) +static int wavelan_set_mac_address(struct net_device *dev, void *addr) { struct sockaddr *mac = addr; @@ -1614,7 +1632,7 @@ static int wv_set_frequency(unsigned long ioaddr, /* I/O port of the card */ return 0; } else - return -EINVAL; /* Bah, never get there... */ + return -EINVAL; /*bah, never get there... */ } /*------------------------------------------------------------------*/ @@ -1663,7 +1681,7 @@ static int wv_frequency_list(unsigned long ioaddr, /* I/O port of the card */ * address with our list, and if they match, get the statistics. * Sorry, but this function really needs the wireless extensions. */ -static inline void wl_spy_gather(struct net_device * dev, +static inline void wl_spy_gather(struct net_device *dev, u8 * mac, /* MAC address */ u8 * stats) /* Statistics to gather */ { @@ -1689,7 +1707,7 @@ static inline void wl_spy_gather(struct net_device * dev, * With this histogram you may detect if one WaveLAN is really weak, * or you may also calculate the mean and standard deviation of the level. */ -static inline void wl_his_gather(struct net_device * dev, u8 * stats) +static inline void wl_his_gather(struct net_device *dev, u8 * stats) { /* Statistics to gather */ net_local *lp = netdev_priv(dev); u8 level = stats[0] & MMR_SIGNAL_LVL; @@ -1981,7 +1999,7 @@ static int wavelan_set_encode(struct net_device *dev, } if(!ret) { - /* Basic checking... */ + /*basic checking... */ if (wrqu->encoding.length == 8) { /* Copy the key in the driver */ memcpy(psa.psa_encryption_key, extra, @@ -2319,7 +2337,7 @@ static const iw_handler wavelan_handler[] = NULL, /* SIOCGIWTXPOW */ NULL, /* SIOCSIWRETRY */ NULL, /* SIOCGIWRETRY */ - /* Bummer ! Why those are only at the end ??? */ + /*bummer ! Why those are only at the end ??? */ wavelan_set_encode, /* SIOCSIWENCODE */ wavelan_get_encode, /* SIOCGIWENCODE */ }; @@ -2358,7 +2376,7 @@ static const struct iw_handler_def wavelan_handler_def = * Get wireless statistics. * Called by /proc/net/wireless */ -static iw_stats *wavelan_get_wireless_stats(struct net_device * dev) +static iw_stats *wavelan_get_wireless_stats(struct net_device *dev) { unsigned long ioaddr = dev->base_addr; net_local *lp = netdev_priv(dev); @@ -2434,7 +2452,7 @@ static iw_stats *wavelan_get_wireless_stats(struct net_device * dev) * (called by wv_packet_rcv()) */ static void -wv_packet_read(struct net_device * dev, u16 buf_off, int sksize) +wv_packet_read(struct net_device *dev, u16 buf_off, int sksize) { net_local *lp = netdev_priv(dev); unsigned long ioaddr = dev->base_addr; @@ -2527,7 +2545,7 @@ wv_packet_read(struct net_device * dev, u16 buf_off, int sksize) * (called in wavelan_interrupt()). * Note : the spinlock is already grabbed for us. */ -static void wv_receive(struct net_device * dev) +static void wv_receive(struct net_device *dev) { unsigned long ioaddr = dev->base_addr; net_local *lp = netdev_priv(dev); @@ -2710,7 +2728,7 @@ static void wv_receive(struct net_device * dev) * * (called in wavelan_packet_xmit()) */ -static int wv_packet_write(struct net_device * dev, void *buf, short length) +static int wv_packet_write(struct net_device *dev, void *buf, short length) { net_local *lp = netdev_priv(dev); unsigned long ioaddr = dev->base_addr; @@ -2842,7 +2860,7 @@ static int wv_packet_write(struct net_device * dev, void *buf, short length) * to send the packet. */ static netdev_tx_t wavelan_packet_xmit(struct sk_buff *skb, - struct net_device * dev) + struct net_device *dev) { net_local *lp = netdev_priv(dev); unsigned long flags; @@ -2854,7 +2872,7 @@ static netdev_tx_t wavelan_packet_xmit(struct sk_buff *skb, #endif /* - * Block a timer-based transmit from overlapping. + *block a timer-based transmit from overlapping. * In other words, prevent reentering this routine. */ netif_stop_queue(dev); @@ -2905,7 +2923,7 @@ static netdev_tx_t wavelan_packet_xmit(struct sk_buff *skb, * Routine to initialize the Modem Management Controller. * (called by wv_hw_reset()) */ -static int wv_mmc_init(struct net_device * dev) +static int wv_mmc_init(struct net_device *dev) { unsigned long ioaddr = dev->base_addr; net_local *lp = netdev_priv(dev); @@ -3077,7 +3095,7 @@ static int wv_mmc_init(struct net_device * dev) * Start the receive unit. * (called by wv_hw_reset()) */ -static int wv_ru_start(struct net_device * dev) +static int wv_ru_start(struct net_device *dev) { net_local *lp = netdev_priv(dev); unsigned long ioaddr = dev->base_addr; @@ -3159,8 +3177,8 @@ static int wv_ru_start(struct net_device * dev) * self-loop of the first transmit block. * * Here we create the list of send buffers used to transmit packets - * between the PC and the command unit. For each buffer, we create a - * buffer descriptor (pointing on the buffer), a transmit command + *between the PC and the command unit. For each buffer, we create a + *buffer descriptor (pointing on the buffer), a transmit command * (pointing to the buffer descriptor) and a NOP command. * The transmit command is linked to the NOP, and the NOP to itself. * When we will have finished executing the transmit command, we will @@ -3169,7 +3187,7 @@ static int wv_ru_start(struct net_device * dev) * * (called by wv_hw_reset()) */ -static int wv_cu_start(struct net_device * dev) +static int wv_cu_start(struct net_device *dev) { net_local *lp = netdev_priv(dev); unsigned long ioaddr = dev->base_addr; @@ -3270,7 +3288,7 @@ static int wv_cu_start(struct net_device * dev) * * (called by wv_hw_reset()) */ -static int wv_82586_start(struct net_device * dev) +static int wv_82586_start(struct net_device *dev) { net_local *lp = netdev_priv(dev); unsigned long ioaddr = dev->base_addr; @@ -3402,7 +3420,7 @@ static int wv_82586_start(struct net_device * dev) * * (called by wv_hw_reset(), wv_82586_reconfig(), wavelan_packet_xmit()) */ -static void wv_82586_config(struct net_device * dev) +static void wv_82586_config(struct net_device *dev) { net_local *lp = netdev_priv(dev); unsigned long ioaddr = dev->base_addr; @@ -3449,7 +3467,7 @@ static void wv_82586_config(struct net_device * dev) tx_addr = txblock; nop_addr = tx_addr + sizeof(tx); tbd_addr = nop_addr + sizeof(nop); - cfg_addr = tbd_addr + sizeof(tbd_t); /* beginning of the buffer */ + cfg_addr = tbd_addr + sizeof(tbd_t); /*beginning of the buffer */ ias_addr = cfg_addr + sizeof(cfg); mcs_addr = ias_addr + sizeof(ias); @@ -3578,7 +3596,7 @@ static void wv_82586_config(struct net_device * dev) * WaveLAN controller (i82586). * (called by wavelan_close()) */ -static void wv_82586_stop(struct net_device * dev) +static void wv_82586_stop(struct net_device *dev) { net_local *lp = netdev_priv(dev); unsigned long ioaddr = dev->base_addr; @@ -3615,7 +3633,7 @@ static void wv_82586_stop(struct net_device * dev) * 5. Start the LAN controller's receive unit * (called by wavelan_interrupt(), wavelan_watchdog() & wavelan_open()) */ -static int wv_hw_reset(struct net_device * dev) +static int wv_hw_reset(struct net_device *dev) { net_local *lp = netdev_priv(dev); unsigned long ioaddr = dev->base_addr; @@ -3939,7 +3957,7 @@ static void wavelan_watchdog(struct net_device * dev) * Configure and start up the WaveLAN PCMCIA adaptor. * Called by NET3 when it "opens" the device. */ -static int wavelan_open(struct net_device * dev) +static int wavelan_open(struct net_device *dev) { net_local *lp = netdev_priv(dev); unsigned long flags; @@ -3994,7 +4012,7 @@ static int wavelan_open(struct net_device * dev) * Shut down the WaveLAN ISA card. * Called by NET3 when it "closes" the device. */ -static int wavelan_close(struct net_device * dev) +static int wavelan_close(struct net_device *dev) { net_local *lp = netdev_priv(dev); unsigned long flags; @@ -4040,7 +4058,7 @@ static const struct net_device_ops wavelan_netdev_ops = { /*------------------------------------------------------------------*/ /* * Probe an I/O address, and if the WaveLAN is there configure the - * device structure + *device structure * (called by wavelan_probe() and via init_module()). */ static int __init wavelan_config(struct net_device *dev, unsigned short ioaddr) @@ -4114,7 +4132,7 @@ static int __init wavelan_config(struct net_device *dev, unsigned short ioaddr) memset(netdev_priv(dev), 0, sizeof(net_local)); lp = netdev_priv(dev); - /* Back link to the device structure. */ + /*back link to the device structure. */ lp->dev = dev; /* Add the device at the beginning of the linked list. */ lp->next = wavelan_list; @@ -4377,7 +4395,7 @@ MODULE_LICENSE("GPL"); * * Please send bug reports, updates, comments to: * - * Bruce Janson Email: bruce@cs.usyd.edu.au - * Basser Department of Computer Science Phone: +61-2-9351-3423 + *bruce Janson Email: bruce@cs.usyd.edu.au + *basser Department of Computer Science Phone: +61-2-9351-3423 * University of Sydney, N.S.W., 2006, AUSTRALIA Fax: +61-2-9351-3838 */ diff --git a/drivers/staging/wavelan/wavelan.h b/drivers/staging/wavelan/wavelan.h index 9ab360558ffd..1ebae10b8696 100644 --- a/drivers/staging/wavelan/wavelan.h +++ b/drivers/staging/wavelan/wavelan.h @@ -26,8 +26,7 @@ * product (OEM, like DEC RoamAbout, Digital Ocean, or Epson), * you might need to modify this part to accommodate your hardware. */ -static const char MAC_ADDRESSES[][3] = -{ +static const char MAC_ADDRESSES[][3] = { { 0x08, 0x00, 0x0E }, /* AT&T WaveLAN (standard) & DEC RoamAbout */ { 0x08, 0x00, 0x6A }, /* AT&T WaveLAN (alternate) */ { 0x00, 0x00, 0xE1 }, /* Hitachi Wavelan */ @@ -67,8 +66,7 @@ static const int fixed_bands[] = { 915e6, 2.425e8, 2.46e8, 2.484e8, 2.4305e8 }; * (base is board port address). */ typedef union hacs_u hacs_u; -union hacs_u -{ +union hacs_u { unsigned short hu_command; /* Command register */ #define HACR_RESET 0x0001 /* Reset board */ #define HACR_CA 0x0002 /* Set Channel Attention for 82586 */ @@ -88,8 +86,7 @@ union hacs_u } __attribute__ ((packed)); typedef struct ha_t ha_t; -struct ha_t -{ +struct ha_t { hacs_u ha_cs; /* Command and status registers */ #define ha_command ha_cs.hu_command #define ha_status ha_cs.hu_status @@ -104,7 +101,7 @@ struct ha_t #define HA_SIZE 16 -#define hoff(p,f) (unsigned short)((void *)(&((ha_t *)((void *)0 + (p)))->f) - (void *)0) +#define hoff(p, f) (unsigned short)((void *)(&((ha_t *)((void *)0 + (p)))->f) - (void *)0) #define HACR(p) hoff(p, ha_command) #define HASR(p) hoff(p, ha_status) #define MMCR(p) hoff(p, ha_mmcr) @@ -127,7 +124,7 @@ struct ha_t #define PARAM_ACCESS_PIO 3 /* Mode 4: LAN parameter access mode */ /* Parameter access. */ #define PIO_MASK 3 /* register mask */ -#define PIOM(cmd,piono) ((u_short)cmd << 10 << (piono * 2)) +#define PIOM(cmd, piono) ((u_short)cmd << 10 << (piono * 2)) #define HACR_DEFAULT (HACR_OUT0 | HACR_OUT1 | HACR_16BITS | PIOM(STATIC_PIO, 0) | PIOM(AUTOINCR_PIO, 1) | PIOM(PARAM_ACCESS_PIO, 2)) #define HACR_INTRON (HACR_82586_INT_ENABLE | HACR_MMC_INT_ENABLE | HACR_INTR_CLR_ENABLE) @@ -156,8 +153,7 @@ struct ha_t * Parameter Storage Area (PSA). */ typedef struct psa_t psa_t; -struct psa_t -{ +struct psa_t { unsigned char psa_io_base_addr_1; /* [0x00] Base address 1 ??? */ unsigned char psa_io_base_addr_2; /* [0x01] Base address 2 */ unsigned char psa_io_base_addr_3; /* [0x02] Base address 3 */ @@ -208,7 +204,7 @@ struct psa_t /* Calculate offset of a field in the above structure. * Warning: only even addresses are used. */ -#define psaoff(p,f) ((unsigned short) ((void *)(&((psa_t *) ((void *) NULL + (p)))->f) - (void *) NULL)) +#define psaoff(p, f) ((unsigned short) ((void *)(&((psa_t *) ((void *) NULL + (p)))->f) - (void *) NULL)) /******************** MODEM MANAGEMENT INTERFACE ********************/ @@ -216,8 +212,7 @@ struct psa_t * Modem Management Controller (MMC) write structure. */ typedef struct mmw_t mmw_t; -struct mmw_t -{ +struct mmw_t { unsigned char mmw_encr_key[8]; /* encryption key */ unsigned char mmw_encr_enable; /* Enable or disable encryption. */ #define MMW_ENCR_ENABLE_MODE 0x02 /* mode of security option */ @@ -296,14 +291,13 @@ struct mmw_t #define MMW_SIZE 37 -#define mmwoff(p,f) (unsigned short)((void *)(&((mmw_t *)((void *)0 + (p)))->f) - (void *)0) +#define mmwoff(p, f) (unsigned short)((void *)(&((mmw_t *)((void *)0 + (p)))->f) - (void *)0) /* * Modem Management Controller (MMC) read structure. */ typedef struct mmr_t mmr_t; -struct mmr_t -{ +struct mmr_t { unsigned char mmr_unused0[8]; /* unused */ unsigned char mmr_des_status; /* encryption status */ unsigned char mmr_des_avail; /* encryption available (0x55 read) */ @@ -351,11 +345,10 @@ struct mmr_t #define MMR_SIZE 36 -#define mmroff(p,f) (unsigned short)((void *)(&((mmr_t *)((void *)0 + (p)))->f) - (void *)0) +#define mmroff(p, f) (unsigned short)((void *)(&((mmr_t *)((void *)0 + (p)))->f) - (void *)0) /* Make the two above structures one */ -typedef union mm_t -{ +typedef union mm_t { struct mmw_t w; /* Write to the mmc */ struct mmr_t r; /* Read from the mmc */ } mm_t; diff --git a/drivers/staging/wavelan/wavelan.p.h b/drivers/staging/wavelan/wavelan.p.h index dbe8de6e5f52..d5f322c68d05 100644 --- a/drivers/staging/wavelan/wavelan.p.h +++ b/drivers/staging/wavelan/wavelan.p.h @@ -125,7 +125,7 @@ * writing a WaveLAN ISA driver for the Mach microkernel. Girish * Welling <welling@paul.rutgers.edu> had also worked on it. * Keith Moore modified this for the PCMCIA hardware. - * + * * Robert Morris <rtm@das.harvard.edu> ported these two drivers to BSDI * and added specific PCMCIA support (there is currently no equivalent * of the PCMCIA package under BSD). @@ -451,17 +451,18 @@ static const char *version = "wavelan.c : v24 (SMP + wireless extensions) 11/12/ /* ------------------------ PRIVATE IOCTL ------------------------ */ #define SIOCSIPQTHR SIOCIWFIRSTPRIV /* Set quality threshold */ -#define SIOCGIPQTHR SIOCIWFIRSTPRIV + 1 /* Get quality threshold */ +#define SIOCGIPQTHR (SIOCIWFIRSTPRIV + 1) /* Get quality threshold */ -#define SIOCSIPHISTO SIOCIWFIRSTPRIV + 2 /* Set histogram ranges */ -#define SIOCGIPHISTO SIOCIWFIRSTPRIV + 3 /* Get histogram values */ +#define SIOCSIPHISTO (SIOCIWFIRSTPRIV + 2) /* Set histogram ranges */ +#define SIOCGIPHISTO (SIOCIWFIRSTPRIV + 3) /* Get histogram values */ /****************************** TYPES ******************************/ /* Shortcuts */ typedef struct iw_statistics iw_stats; typedef struct iw_quality iw_qual; -typedef struct iw_freq iw_freq;typedef struct net_local net_local; +typedef struct iw_freq iw_freq; +typedef struct net_local net_local; typedef struct timer_list timer_list; /* Basic types */ @@ -474,10 +475,9 @@ typedef u_char mac_addr[WAVELAN_ADDR_SIZE]; /* Hardware address */ * keeps the generic data (same format for everybody) and "net_local" keeps * additional specific data. */ -struct net_local -{ - net_local * next; /* linked list of the devices */ - struct net_device * dev; /* reverse link */ +struct net_local { + net_local *next; /* linked list of the devices */ + struct net_device *dev; /* reverse link */ spinlock_t spinlock; /* Serialize access to the hardware (SMP) */ int nresets; /* number of hardware resets */ u_char reconfig_82586; /* We need to reconfigure the controller. */ @@ -534,7 +534,7 @@ static void int, /* offset in PSA */ u_char *, /* buffer to fill */ int), /* size to read */ - psa_write(u_long, /* Write to the PSA. */ + psa_write(u_long, /* Write to the PSA. */ u_short, /* hacr */ int, /* offset in PSA */ u_char *, /* buffer in memory */ @@ -654,8 +654,7 @@ static net_local * wavelan_list = (net_local *) NULL; * This table is used to translate the PSA value to IRQ number * and vice versa. */ -static u_char irqvals[] = -{ +static u_char irqvals[] = { 0, 0, 0, 0x01, 0x02, 0x04, 0, 0x08, 0, 0, 0x10, 0x20, @@ -665,8 +664,7 @@ static u_char irqvals[] = /* * Table of the available I/O addresses (base addresses) for WaveLAN */ -static unsigned short iobase[] = -{ +static unsigned short iobase[] = { #if 0 /* Leave out 0x3C0 for now -- seems to clash with some video * controllers. diff --git a/drivers/staging/wavelan/wavelan_cs.h b/drivers/staging/wavelan/wavelan_cs.h index 2e4bfe4147c6..42e268dbae98 100644 --- a/drivers/staging/wavelan/wavelan_cs.h +++ b/drivers/staging/wavelan/wavelan_cs.h @@ -18,7 +18,7 @@ */ /* - * Definitions for the AT&T GIS (formerly NCR) WaveLAN PCMCIA card: + * Definitions for the AT&T GIS (formerly NCR) WaveLAN PCMCIA card: * An Ethernet-like radio transceiver controlled by an Intel 82593 * coprocessor. * @@ -37,7 +37,7 @@ * in supporting documentation that copying and distribution is * by permission of M.I.T. M.I.T. makes no representations about * the suitability of this software for any purpose. It is pro- - * vided "as is" without express or implied warranty. + * vided "as is" without express or implied warranty. **************************************************************************** * * @@ -62,8 +62,7 @@ * like DEC RoamAbout, or Digital Ocean, Epson, ...), you must modify this * part to accommodate your hardware... */ -static const unsigned char MAC_ADDRESSES[][3] = -{ +static const unsigned char MAC_ADDRESSES[][3] = { { 0x08, 0x00, 0x0E }, /* AT&T Wavelan (standard) & DEC RoamAbout */ { 0x08, 0x00, 0x6A }, /* AT&T Wavelan (alternate) */ { 0x00, 0x00, 0xE1 }, /* Hitachi Wavelan */ @@ -171,8 +170,7 @@ static const int fixed_bands[] = { 915e6, 2.425e8, 2.46e8, 2.484e8, 2.4305e8 }; * Parameter Storage Area (PSA). */ typedef struct psa_t psa_t; -struct psa_t -{ +struct psa_t { /* For the PCMCIA Adapter, locations 0x00-0x0F are unused and fixed at 00 */ unsigned char psa_io_base_addr_1; /* [0x00] Base address 1 ??? */ unsigned char psa_io_base_addr_2; /* [0x01] Base address 2 */ @@ -191,14 +189,14 @@ struct psa_t #define PSA_UNIVERSAL 0 /* Universal (factory) */ #define PSA_LOCAL 1 /* Local */ unsigned char psa_comp_number; /* [0x1D] Compatability Number: */ -#define PSA_COMP_PC_AT_915 0 /* PC-AT 915 MHz */ -#define PSA_COMP_PC_MC_915 1 /* PC-MC 915 MHz */ -#define PSA_COMP_PC_AT_2400 2 /* PC-AT 2.4 GHz */ -#define PSA_COMP_PC_MC_2400 3 /* PC-MC 2.4 GHz */ -#define PSA_COMP_PCMCIA_915 4 /* PCMCIA 915 MHz or 2.0 */ +#define PSA_COMP_PC_AT_915 0 /* PC-AT 915 MHz */ +#define PSA_COMP_PC_MC_915 1 /* PC-MC 915 MHz */ +#define PSA_COMP_PC_AT_2400 2 /* PC-AT 2.4 GHz */ +#define PSA_COMP_PC_MC_2400 3 /* PC-MC 2.4 GHz */ +#define PSA_COMP_PCMCIA_915 4 /* PCMCIA 915 MHz or 2.0 */ unsigned char psa_thr_pre_set; /* [0x1E] Modem Threshold Preset */ unsigned char psa_feature_select; /* [0x1F] Call code required (1=on) */ -#define PSA_FEATURE_CALL_CODE 0x01 /* Call code required (Japan) */ +#define PSA_FEATURE_CALL_CODE 0x01 /* Call code required (Japan) */ unsigned char psa_subband; /* [0x20] Subband */ #define PSA_SUBBAND_915 0 /* 915 MHz or 2.0 */ #define PSA_SUBBAND_2425 1 /* 2425 MHz */ @@ -225,7 +223,7 @@ struct psa_t /* Calculate offset of a field in the above structure * Warning : only even addresses are used */ -#define psaoff(p,f) ((unsigned short) ((void *)(&((psa_t *) ((void *) NULL + (p)))->f) - (void *) NULL)) +#define psaoff(p, f) ((unsigned short) ((void *)(&((psa_t *) ((void *) NULL + (p)))->f) - (void *) NULL)) /******************** MODEM MANAGEMENT INTERFACE ********************/ @@ -233,8 +231,7 @@ struct psa_t * Modem Management Controller (MMC) write structure. */ typedef struct mmw_t mmw_t; -struct mmw_t -{ +struct mmw_t { unsigned char mmw_encr_key[8]; /* encryption key */ unsigned char mmw_encr_enable; /* enable/disable encryption */ #define MMW_ENCR_ENABLE_MODE 0x02 /* Mode of security option */ @@ -315,15 +312,14 @@ struct mmw_t #define MMW_SIZE 37 /* Calculate offset of a field in the above structure */ -#define mmwoff(p,f) (unsigned short)((void *)(&((mmw_t *)((void *)0 + (p)))->f) - (void *)0) +#define mmwoff(p, f) (unsigned short)((void *)(&((mmw_t *)((void *)0 + (p)))->f) - (void *)0) /* * Modem Management Controller (MMC) read structure. */ typedef struct mmr_t mmr_t; -struct mmr_t -{ +struct mmr_t { unsigned char mmr_unused0[8]; /* unused */ unsigned char mmr_des_status; /* encryption status */ unsigned char mmr_des_avail; /* encryption available (0x55 read) */ @@ -373,12 +369,11 @@ struct mmr_t #define MMR_SIZE 36 /* Calculate offset of a field in the above structure */ -#define mmroff(p,f) (unsigned short)((void *)(&((mmr_t *)((void *)0 + (p)))->f) - (void *)0) +#define mmroff(p, f) (unsigned short)((void *)(&((mmr_t *)((void *)0 + (p)))->f) - (void *)0) /* Make the two above structures one */ -typedef union mm_t -{ +typedef union mm_t { struct mmw_t w; /* Write to the mmc */ struct mmr_t r; /* Read from the mmc */ } mm_t; diff --git a/drivers/staging/wavelan/wavelan_cs.p.h b/drivers/staging/wavelan/wavelan_cs.p.h index 8fbfaa8a5a67..7196267976f0 100644 --- a/drivers/staging/wavelan/wavelan_cs.p.h +++ b/drivers/staging/wavelan/wavelan_cs.p.h @@ -123,7 +123,7 @@ * writing a Wavelan ISA driver for the MACH microkernel. Girish * Welling <welling@paul.rutgers.edu> had also worked on it. * Keith Moore modify this for the Pcmcia hardware. - * + * * Robert Morris <rtm@das.harvard.edu> port these two drivers to BSDI * and add specific Pcmcia support (there is currently no equivalent * of the PCMCIA package under BSD...). @@ -283,7 +283,7 @@ * Changes made in sixth release (2.9.1a) : * -------------------------------------- * - Change the detection code for multi manufacturer code support - * - Correct bug (hang kernel) in init when we were "rejecting" a card + * - Correct bug (hang kernel) in init when we were "rejecting" a card * * Changes made in seventh release (2.9.1b) : * ---------------------------------------- @@ -514,12 +514,12 @@ static const char *version = "wavelan_cs.c : v24 (SMP + wireless extensions) 11/ /* ------------------------ PRIVATE IOCTL ------------------------ */ #define SIOCSIPQTHR SIOCIWFIRSTPRIV /* Set quality threshold */ -#define SIOCGIPQTHR SIOCIWFIRSTPRIV + 1 /* Get quality threshold */ -#define SIOCSIPROAM SIOCIWFIRSTPRIV + 2 /* Set roaming state */ -#define SIOCGIPROAM SIOCIWFIRSTPRIV + 3 /* Get roaming state */ +#define SIOCGIPQTHR (SIOCIWFIRSTPRIV + 1) /* Get quality threshold */ +#define SIOCSIPROAM (SIOCIWFIRSTPRIV + 2) /* Set roaming state */ +#define SIOCGIPROAM (SIOCIWFIRSTPRIV + 3) /* Get roaming state */ -#define SIOCSIPHISTO SIOCIWFIRSTPRIV + 4 /* Set histogram ranges */ -#define SIOCGIPHISTO SIOCIWFIRSTPRIV + 5 /* Get histogram values */ +#define SIOCSIPHISTO (SIOCIWFIRSTPRIV + 4) /* Set histogram ranges */ +#define SIOCGIPHISTO (SIOCIWFIRSTPRIV + 5) /* Get histogram values */ /*************************** WaveLAN Roaming **************************/ #ifdef WAVELAN_ROAMING /* Conditional compile, see above in options */ @@ -532,17 +532,16 @@ static const char *version = "wavelan_cs.c : v24 (SMP + wireless extensions) 11/ #define SEARCH_THRESH_LOW 10 /* SNR to enter cell search */ #define SEARCH_THRESH_HIGH 13 /* SNR to leave cell search */ #define WAVELAN_ROAMING_DELTA 1 /* Hysteresis value (+/- SNR) */ -#define CELL_TIMEOUT 2*HZ /* in jiffies */ +#define CELL_TIMEOUT (2*HZ) /* in jiffies */ #define FAST_CELL_SEARCH 1 /* Boolean values... */ #define NWID_PROMISC 1 /* for code clarity. */ -typedef struct wavepoint_beacon -{ +typedef struct wavepoint_beacon { unsigned char dsap, /* Unused */ ssap, /* Unused */ ctrl, /* Unused */ - O,U,I, /* Unused */ + O, U, I, /* Unused */ spec_id1, /* Unused */ spec_id2, /* Unused */ pdu_type, /* Unused */ @@ -551,8 +550,7 @@ typedef struct wavepoint_beacon nwid; /* WavePoint NWID */ } wavepoint_beacon; -typedef struct wavepoint_history -{ +typedef struct wavepoint_history { unsigned short nwid; /* WavePoint's NWID */ int average_slow; /* SNR running average */ int average_fast; /* SNR running average */ @@ -564,8 +562,7 @@ typedef struct wavepoint_history unsigned long last_seen; /* Time of last beacon recvd, jiffies */ } wavepoint_history; -struct wavepoint_table -{ +struct wavepoint_table { wavepoint_history *head; /* Start of ringbuffer */ int num_wavepoints; /* No. of WavePoints visible */ unsigned char locked; /* Table lock */ @@ -592,12 +589,11 @@ typedef u_char mac_addr[WAVELAN_ADDR_SIZE]; /* Hardware address */ * keep the generic data (same format for everybody) and "net_local" keep * the additional specific data. */ -struct net_local -{ +struct net_local { dev_node_t node; /* ???? What is this stuff ???? */ - struct net_device * dev; /* Reverse link... */ + struct net_device *dev; /* Reverse link... */ spinlock_t spinlock; /* Serialize access to the hardware (SMP) */ - struct pcmcia_device * link; /* pcmcia structure */ + struct pcmcia_device *link; /* pcmcia structure */ int nresets; /* Number of hw resets */ u_char configured; /* If it is configured */ u_char reconfig_82593; /* Need to reconfigure the controller */ @@ -623,7 +619,7 @@ struct net_local u_long domain_id; /* Domain ID we lock on for roaming */ int filter_domains; /* Check Domain ID of beacon found */ struct wavepoint_table wavepoint_table; /* Table of visible WavePoints*/ - wavepoint_history * curr_point; /* Current wavepoint */ + wavepoint_history *curr_point; /* Current wavepoint */ int cell_search; /* Searching for new cell? */ struct timer_list cell_timer; /* Garbage collection */ #endif /* WAVELAN_ROAMING */ @@ -673,7 +669,7 @@ static void int); /* number of registers */ /* ---------------------- I82593 SUBROUTINES ----------------------- */ static int - wv_82593_cmd(struct net_device *, /* synchronously send a command to i82593 */ + wv_82593_cmd(struct net_device *, /* synchronously send a command to i82593 */ char *, int, int); @@ -749,14 +745,14 @@ static void */ /* Shared memory speed, in ns */ -static int mem_speed = 0; +static int mem_speed; /* New module interface */ module_param(mem_speed, int, 0); #ifdef WAVELAN_ROAMING /* Conditional compile, see above in options */ /* Enable roaming mode ? No ! Please keep this to 0 */ -static int do_roaming = 0; +static int do_roaming; module_param(do_roaming, bool, 0); #endif /* WAVELAN_ROAMING */ diff --git a/drivers/staging/winbond/README b/drivers/staging/winbond/README index cb944e4bf174..27710241fc14 100644 --- a/drivers/staging/winbond/README +++ b/drivers/staging/winbond/README @@ -2,6 +2,7 @@ TODO: - sparse cleanups - checkpatch cleanups - kerneldoc cleanups + - fix severeCamelCaseInfestation - remove typedefs - remove unused ioctls - use cfg80211 for regulatory stuff diff --git a/drivers/staging/winbond/core.h b/drivers/staging/winbond/core.h index 0a2060bf4f94..b87d6c07600f 100644 --- a/drivers/staging/winbond/core.h +++ b/drivers/staging/winbond/core.h @@ -12,14 +12,16 @@ #define WB_MAX_LINK_NAME_LEN 40 struct wbsoft_priv { - u32 adapterIndex; // 20060703.4 Add for using padapterContext global adapter point + u32 adapterIndex; /* 20060703.4 Add for using padapterContext + global adapter point */ - struct wb_local_para sLocalPara; // Myself connected parameters + struct wb_local_para sLocalPara; /* Myself connected + parameters */ - MLME_FRAME sMlmeFrame; // connect to peerSTA parameters + MLME_FRAME sMlmeFrame; /* connect to peerSTA parameters */ - struct wb35_mto_params sMtoPara; // MTO_struct ... - struct hw_data sHwData; //For HAL + struct wb35_mto_params sMtoPara; /* MTO_struct ... */ + struct hw_data sHwData; /*For HAL */ struct wb35_mds Mds; spinlock_t SpinLock; @@ -30,7 +32,7 @@ struct wbsoft_priv { u32 TxByteCount; struct sk_buff *packet_return; - s32 netif_state_stop; // 1: stop 0: normal + s32 netif_state_stop; /* 1: stop 0: normal */ struct iw_statistics iw_stats; u8 LinkName[WB_MAX_LINK_NAME_LEN]; diff --git a/drivers/staging/winbond/mac_structures.h b/drivers/staging/winbond/mac_structures.h index 0d1619601c0b..7441015cb187 100644 --- a/drivers/staging/winbond/mac_structures.h +++ b/drivers/staging/winbond/mac_structures.h @@ -1,4 +1,4 @@ -//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // MAC_Structures.h // // This file contains the definitions and data structures used by SW-MAC. @@ -16,24 +16,24 @@ // Deleted some unused. // 20021129 PD43 Austin // 20030617 increase the 802.11g definition -//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ #ifndef _MAC_Structures_H_ #define _MAC_Structures_H_ #include <linux/skbuff.h> -//========================================================= +/*========================================================= // Some miscellaneous definitions -//----- +//-----*/ #define MAX_CHANNELS 30 #define MAC_ADDR_LENGTH 6 -#define MAX_WEP_KEY_SIZE 16 // 128 bits -#define MAX_802_11_FRAGMENT_NUMBER 10 // By spec +#define MAX_WEP_KEY_SIZE 16 /* 128 bits */ +#define MAX_802_11_FRAGMENT_NUMBER 10 /* By spec */ -//======================================================== +/* ======================================================== // 802.11 Frame define -//----- +//----- */ #define MASK_PROTOCOL_VERSION_TYPE 0x0F #define MASK_FRAGMENT_NUMBER 0x000F #define SEQUENCE_NUMBER_SHIFT 4 @@ -41,8 +41,8 @@ #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// +#define DOT_11_SEQUENCE_OFFSET 22 /* Sequence control offset */ +#define DOT_11_TYPE_OFFSET 30 /* The start offset of 802.11 Frame// */ #define DOT_11_DATA_OFFSET 24 #define DOT_11_DA_OFFSET 4 #define DOT_3_TYPE_ARP 0x80F3 @@ -54,7 +54,7 @@ #define MAX_ETHERNET_PACKET_SIZE 1514 -//----- management : Type of Bits (2, 3) and Subtype of Bits (4, 5, 6, 7) +/* ----- management : Type of Bits (2, 3) and Subtype of Bits (4, 5, 6, 7) */ #define MAC_SUBTYPE_MNGMNT_ASSOC_REQUEST 0x00 #define MAC_SUBTYPE_MNGMNT_ASSOC_RESPONSE 0x10 #define MAC_SUBTYPE_MNGMNT_REASSOC_REQUEST 0x20 @@ -67,7 +67,7 @@ #define MAC_SUBTYPE_MNGMNT_AUTHENTICATION 0xB0 #define MAC_SUBTYPE_MNGMNT_DEAUTHENTICATION 0xC0 -//----- control : Type of Bits (2, 3) and Subtype of Bits (4, 5, 6, 7) +/* ----- control : Type of Bits (2, 3) and Subtype of Bits (4, 5, 6, 7) */ #define MAC_SUBTYPE_CONTROL_PSPOLL 0xA4 #define MAC_SUBTYPE_CONTROL_RTS 0xB4 #define MAC_SUBTYPE_CONTROL_CTS 0xC4 @@ -75,7 +75,7 @@ #define MAC_SUBTYPE_CONTROL_CFEND 0xE4 #define MAC_SUBTYPE_CONTROL_CFEND_CFACK 0xF4 -//----- data : Type of Bits (2, 3) and Subtype of Bits (4, 5, 6, 7) +/* ----- data : Type of Bits (2, 3) and Subtype of Bits (4, 5, 6, 7) */ #define MAC_SUBTYPE_DATA 0x08 #define MAC_SUBTYPE_DATA_CFACK 0x18 #define MAC_SUBTYPE_DATA_CFPOLL 0x28 @@ -85,12 +85,12 @@ #define MAC_SUBTYPE_DATA_CFPOLL_NULL 0x68 #define MAC_SUBTYPE_DATA_CFACK_CFPOLL_NULL 0x78 -//----- Frame Type of Bits (2, 3) +/* ----- Frame Type of Bits (2, 3) */ #define MAC_TYPE_MANAGEMENT 0x00 #define MAC_TYPE_CONTROL 0x04 #define MAC_TYPE_DATA 0x08 -//----- definitions for Management Frame Element ID (1 BYTE) +/* ----- definitions for Management Frame Element ID (1 BYTE) */ #define ELEMENT_ID_SSID 0 #define ELEMENT_ID_SUPPORTED_RATES 1 #define ELEMENT_ID_FH_PARAMETER_SET 2 @@ -116,13 +116,6 @@ #define WLAN_MAX_PAIRWISE_CIPHER_SUITE_COUNT ((u16) 6) #define WLAN_MAX_AUTH_KEY_MGT_SUITE_LIST_COUNT ((u16) 2) -//======================================================== -typedef enum enum_PowerManagementMode -{ - ACTIVE = 0, - POWER_SAVE -} WB_PM_Mode, *PWB_PM_MODE; - //=================================================================== // Reason Code (Table 18): indicate the reason of DisAssoc, DeAuthen // length of ReasonCode is 2 Octs. @@ -137,7 +130,7 @@ typedef enum enum_PowerManagementMode #define REASON_CLASS3_FRAME_FROM_NONASSO_STA 7 #define DISASS_REASON_LEFT_BSS 8 #define REASON_NOT_AUTH_YET 9 -//802.11i define +/* 802.11i define */ #define REASON_INVALID_IE 13 #define REASON_MIC_ERROR 14 #define REASON_4WAY_HANDSHAKE_TIMEOUT 15 @@ -182,13 +175,12 @@ enum enum_MMPDUResultCode } WB_MMPDURESULTCODE, *PWB_MMPDURESULTCODE; */ -//=========================================================== +/*=========================================================== // enum_TxRate -- // Define the transmission constants based on W89C32 MAC // target specification. -//=========================================================== -typedef enum enum_TxRate -{ +//===========================================================*/ +typedef enum enum_TxRate { TXRATE_1M = 0, TXRATE_2MLONG = 2, TXRATE_2MSHORT = 3, @@ -196,7 +188,7 @@ typedef enum enum_TxRate TXRATE_55MSHORT = 5, TXRATE_11MLONG = 6, TXRATE_11MSHORT = 7, - TXRATE_AUTO = 255 // PD43 20021108 + TXRATE_AUTO = 255 /* PD43 20021108 */ } WB_TXRATE, *PWB_TXRATE; @@ -232,7 +224,7 @@ typedef enum enum_TxRate #define RATE_54M 108 #define RATE_MAX 255 -//CAPABILITY +/* CAPABILITY */ #define CAPABILITY_ESS_BIT 0x0001 #define CAPABILITY_IBSS_BIT 0x0002 #define CAPABILITY_CF_POLL_BIT 0x0004 @@ -245,53 +237,48 @@ typedef enum enum_TxRate #define CAPABILITY_DSSS_OFDM_BIT 0x2000 -struct Capability_Information_Element -{ - union - { - u16 __attribute__ ((packed)) wValue; - #ifdef _BIG_ENDIAN_ //20060926 add by anson's endian - struct _Capability - { - //-- 11G -- - u8 Reserved3 : 2; - u8 DSSS_OFDM : 1; - u8 Reserved2 : 2; - u8 Short_Slot_Time : 1; - u8 Reserved1 : 2; - u8 Channel_Agility : 1; - u8 PBCC : 1; - u8 ShortPreamble : 1; - u8 CF_Privacy : 1; - u8 CF_Poll_Request : 1; - u8 CF_Pollable : 1; - u8 IBSS : 1; - u8 ESS : 1; +struct Capability_Information_Element { + union { + u16 __attribute__ ((packed)) wValue; + #ifdef _BIG_ENDIAN_ /* 20060926 add by anson's endian */ + struct _Capability { + /* -- 11G -- */ + u8 Reserved3:2; + u8 DSSS_OFDM:1; + u8 Reserved2:2; + u8 Short_Slot_Time:1; + u8 Reserved1:2; + u8 Channel_Agility:1; + u8 PBCC:1; + u8 ShortPreamble:1; + u8 CF_Privacy:1; + u8 CF_Poll_Request:1; + u8 CF_Pollable:1; + u8 IBSS:1; + u8 ESS:1; } __attribute__ ((packed)) Capability; #else - struct _Capability - { - u8 ESS : 1; - u8 IBSS : 1; - u8 CF_Pollable : 1; - u8 CF_Poll_Request : 1; - u8 CF_Privacy : 1; - u8 ShortPreamble : 1; - u8 PBCC : 1; - u8 Channel_Agility : 1; - u8 Reserved1 : 2; - //-- 11G -- - u8 Short_Slot_Time : 1; - u8 Reserved2 : 2; - u8 DSSS_OFDM : 1; - u8 Reserved3 : 2; + struct _Capability { + u8 ESS:1; + u8 IBSS:1; + u8 CF_Pollable:1; + u8 CF_Poll_Request:1; + u8 CF_Privacy:1; + u8 ShortPreamble:1; + u8 PBCC:1; + u8 Channel_Agility:1; + u8 Reserved1:2; + /* -- 11G -- */ + u8 Short_Slot_Time:1; + u8 Reserved2:2; + u8 DSSS_OFDM:1; + u8 Reserved3:2; } __attribute__ ((packed)) Capability; #endif - }__attribute__ ((packed)) ; -}__attribute__ ((packed)); + } __attribute__ ((packed)) ; +} __attribute__ ((packed)); -struct FH_Parameter_Set_Element -{ +struct FH_Parameter_Set_Element { u8 Element_ID; u8 Length; u8 Dwell_Time[2]; @@ -300,39 +287,34 @@ struct FH_Parameter_Set_Element u8 Hop_Index; }; -struct DS_Parameter_Set_Element -{ +struct DS_Parameter_Set_Element { u8 Element_ID; u8 Length; u8 Current_Channel; }; -struct Supported_Rates_Element -{ +struct Supported_Rates_Element { u8 Element_ID; u8 Length; u8 SupportedRates[8]; -}__attribute__ ((packed)); +} __attribute__ ((packed)); -struct SSID_Element -{ +struct SSID_Element { u8 Element_ID; u8 Length; u8 SSID[32]; -}__attribute__ ((packed)) ; +} __attribute__ ((packed)) ; -struct CF_Parameter_Set_Element -{ +struct CF_Parameter_Set_Element { u8 Element_ID; u8 Length; u8 CFP_Count; u8 CFP_Period; - u8 CFP_MaxDuration[2]; // in Time Units - u8 CFP_DurRemaining[2]; // in time units + u8 CFP_MaxDuration[2]; /* in Time Units */ + u8 CFP_DurRemaining[2]; /* in time units */ }; -struct TIM_Element -{ +struct TIM_Element { u8 Element_ID; u8 Length; u8 DTIM_Count; @@ -341,24 +323,21 @@ struct TIM_Element u8 Partial_Virtual_Bitmap[251]; }; -struct IBSS_Parameter_Set_Element -{ +struct IBSS_Parameter_Set_Element { u8 Element_ID; u8 Length; u8 ATIM_Window[2]; }; -struct Challenge_Text_Element -{ +struct Challenge_Text_Element { u8 Element_ID; u8 Length; u8 Challenge_Text[253]; }; -struct PHY_Parameter_Set_Element -{ -// int aSlotTime; -// int aSifsTime; +struct PHY_Parameter_Set_Element { +/* int aSlotTime; */ +/* int aSifsTime; */ s32 aCCATime; s32 aRxTxTurnaroundTime; s32 aTxPLCPDelay; @@ -374,18 +353,17 @@ struct PHY_Parameter_Set_Element s32 aPLCPHeaderLength; s32 aMPDUDurationFactor; s32 aMPDUMaxLength; -// int aCWmin; -// int aCWmax; +/* int aCWmin; */ +/* int aCWmax; */ }; -//-- 11G -- -struct ERP_Information_Element -{ +/* -- 11G -- */ +struct ERP_Information_Element { u8 Element_ID; u8 Length; - #ifdef _BIG_ENDIAN_ //20060926 add by anson's endian - u8 Reserved:5; //20060926 add by anson - u8 Barker_Preamble_Mode:1; + #ifdef _BIG_ENDIAN_ /* 20060926 add by anson's endian */ + u8 Reserved:5; /* 20060926 add by anson */ + u8 Barker_Preamble_Mode:1; u8 Use_Protection:1; u8 NonERP_Present:1; #else @@ -396,54 +374,53 @@ struct ERP_Information_Element #endif }; -struct Extended_Supported_Rates_Element -{ +struct Extended_Supported_Rates_Element { u8 Element_ID; u8 Length; u8 ExtendedSupportedRates[255]; -}__attribute__ ((packed)); +} __attribute__ ((packed)); -//WPA(802.11i draft 3.0) +/* WPA(802.11i draft 3.0) */ #define VERSION_WPA 1 #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 +#endif /* end def _WPA2_ */ +#define OUI_WPA 0x00F25000 /* WPA2.0 OUI=00:50:F2, the MSB is reserved for suite type */ #ifdef _WPA2_ -#define OUI_WPA2 0x00AC0F00 // for wpa2 change to 0x00ACOF04 by Ws 26/04/04 -#endif //end def _WPA2_ +#define OUI_WPA2 0x00AC0F00 /* for wpa2 change to 0x00ACOF04 by Ws 26/04/04 */ +#endif /* end def _WPA2_ */ #define OUI_WPA_ADDITIONAL 0x01 -#define WLAN_MIN_RSN_WPA_LENGTH 6 //added by ws 09/10/04 +#define WLAN_MIN_RSN_WPA_LENGTH 6 /* added by ws 09/10/04 */ #ifdef _WPA2_ -#define WLAN_MIN_RSN_WPA2_LENGTH 2 // Fix to 2 09/14/05 -#endif //end def _WPA2_ +#define WLAN_MIN_RSN_WPA2_LENGTH 2 /* Fix to 2 09/14/05 */ +#endif /* end def _WPA2_ */ #define oui_wpa (u32)(OUI_WPA|OUI_WPA_ADDITIONAL) -#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_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 +#define WPA_WPS_OUI cpu_to_le32(0x04F25000) /* 20061108 For WPS. It's little endian. Big endian is 0x0050F204 */ -//-----WPA2----- +/* -----WPA2----- */ #ifdef _WPA2_ #define WPA2_OUI_BIG ((u32)0x01AC0F00) #define WPA2_OUI_LITTLE ((u32)0x01AC0F01) -#endif //end def _WPA2_ +#endif /* end def _WPA2_ */ -//Authentication suite -#define OUI_AUTH_WPA_NONE 0x00 //for WPA_NONE +/* Authentication suite */ +#define OUI_AUTH_WPA_NONE 0x00 /* for WPA_NONE */ #define OUI_AUTH_8021X 0x01 #define OUI_AUTH_PSK 0x02 -//Cipher suite -#define OUI_CIPHER_GROUP_KEY 0x00 //added by ws 05/21/04 +/* Cipher suite */ +#define OUI_CIPHER_GROUP_KEY 0x00 /* added by ws 05/21/04 */ #define OUI_CIPHER_WEP_40 0x01 #define OUI_CIPHER_TKIP 0x02 #define OUI_CIPHER_CCMP 0x04 #define OUI_CIPHER_WEP_104 0x05 -typedef struct _SUITE_SELECTOR_ +struct suite_selector { union { @@ -454,35 +431,35 @@ typedef struct _SUITE_SELECTOR_ u8 Type; }SuitSelector; }; -}SUITE_SELECTOR; +}; //-- WPA -- struct RSN_Information_Element { u8 Element_ID; u8 Length; - SUITE_SELECTOR OuiWPAAdditional;//WPA version 2.0 additional field, and should be 00:50:F2:01 + struct suite_selector OuiWPAAdditional; /* WPA version 2.0 additional field, and should be 00:50:F2:01 */ u16 Version; - SUITE_SELECTOR GroupKeySuite; + struct suite_selector GroupKeySuite; u16 PairwiseKeySuiteCount; - SUITE_SELECTOR PairwiseKeySuite[1]; + struct suite_selector PairwiseKeySuite[1]; }__attribute__ ((packed)); struct RSN_Auth_Sub_Information_Element { u16 AuthKeyMngtSuiteCount; - SUITE_SELECTOR AuthKeyMngtSuite[1]; + struct suite_selector AuthKeyMngtSuite[1]; }__attribute__ ((packed)); -//-- WPA2 -- +/* -- WPA2 -- */ struct RSN_Capability_Element { union { u16 __attribute__ ((packed)) wValue; - #ifdef _BIG_ENDIAN_ //20060927 add by anson's endian + #ifdef _BIG_ENDIAN_ /* 20060927 add by anson's endian */ struct _RSN_Capability { - u16 __attribute__ ((packed)) Reserved2 : 8; // 20051201 + 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; @@ -497,7 +474,7 @@ struct RSN_Capability_Element 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 + u16 __attribute__ ((packed)) Reserved2 : 8; /* 20051201 */ }__attribute__ ((packed)) RSN_Capability; #endif @@ -505,43 +482,43 @@ struct RSN_Capability_Element }__attribute__ ((packed)) ; #ifdef _WPA2_ -typedef struct _PMKID +struct pmkid { u8 pValue[16]; -}PMKID; +}; struct WPA2_RSN_Information_Element { u8 Element_ID; u8 Length; u16 Version; - SUITE_SELECTOR GroupKeySuite; + struct suite_selector GroupKeySuite; u16 PairwiseKeySuiteCount; - SUITE_SELECTOR PairwiseKeySuite[1]; + struct suite_selector PairwiseKeySuite[1]; }__attribute__ ((packed)); struct WPA2_RSN_Auth_Sub_Information_Element { u16 AuthKeyMngtSuiteCount; - SUITE_SELECTOR AuthKeyMngtSuite[1]; + struct suite_selector AuthKeyMngtSuite[1]; }__attribute__ ((packed)); struct PMKID_Information_Element { u16 PMKID_Count; - PMKID pmkid [16] ; + struct pmkid pmkid[16]; }__attribute__ ((packed)); -#endif //enddef _WPA2_ -//============================================================ +#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 + u8 mac_frame_info; /* a combination of the [Protocol Version, Control Type, Control Subtype]*/ + #ifdef _BIG_ENDIAN_ /* 20060927 add by anson's endian */ u8 order:1; u8 WEP:1; u8 more_data:1; @@ -563,24 +540,24 @@ struct MAC_frame_control } __attribute__ ((packed)); struct Management_Frame { - struct MAC_frame_control frame_control; // 2B, ToDS,FromDS,MoreFrag,MoreData,Order=0 + struct MAC_frame_control frame_control; /* 2B, ToDS,FromDS,MoreFrag,MoreData,Order=0 */ u16 duration; - u8 DA[MAC_ADDR_LENGTH]; // Addr1 - u8 SA[MAC_ADDR_LENGTH]; // Addr2 - u8 BSSID[MAC_ADDR_LENGTH]; // Addr3 + u8 DA[MAC_ADDR_LENGTH]; /* Addr1 */ + u8 SA[MAC_ADDR_LENGTH]; /* Addr2 */ + u8 BSSID[MAC_ADDR_LENGTH]; /* Addr3 */ u16 Sequence_Control; - // Management Frame Body <= 325 bytes - // FCS 4 bytes -}__attribute__ ((packed)); + /* Management Frame Body <= 325 bytes */ + /* FCS 4 bytes */ +} __attribute__ ((packed)); -// SW-MAC don't Tx/Rx Control-Frame, HW-MAC do it. +/* 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 + struct MAC_frame_control frame_control; /* ToDS,FromDS,MoreFrag,Retry,MoreData,WEP,Order=0 */ u16 duration; u8 RA[MAC_ADDR_LENGTH]; u8 TA[MAC_ADDR_LENGTH]; u16 FCS; -}__attribute__ ((packed)); +} __attribute__ ((packed)); struct Data_Frame { struct MAC_frame_control frame_control; @@ -589,32 +566,29 @@ struct Data_Frame { u8 Addr2[MAC_ADDR_LENGTH]; u8 Addr3[MAC_ADDR_LENGTH]; u16 Sequence_Control; - u8 Addr4[MAC_ADDR_LENGTH]; // only exist when ToDS=FromDS=1 - // Data Frame Body <= 2312 - // FCS -}__attribute__ ((packed)); + u8 Addr4[MAC_ADDR_LENGTH]; /* only exist when ToDS=FromDS=1 */ + /* Data Frame Body <= 2312 */ + /* FCS */ +} __attribute__ ((packed)); -struct Disassociation_Frame_Body -{ +struct Disassociation_Frame_Body { u16 reasonCode; -}__attribute__ ((packed)); +} __attribute__ ((packed)); -struct Association_Request_Frame_Body -{ +struct Association_Request_Frame_Body { u16 capability_information; u16 listenInterval; - u8 Current_AP_Address[MAC_ADDR_LENGTH];//for reassociation only - // SSID (2+32 bytes) - // Supported_Rates (2+8 bytes) -}__attribute__ ((packed)); + u8 Current_AP_Address[MAC_ADDR_LENGTH];/* for reassociation only */ + /* SSID (2+32 bytes) */ + /* Supported_Rates (2+8 bytes) */ +} __attribute__ ((packed)); -struct Association_Response_Frame_Body -{ +struct Association_Response_Frame_Body { u16 capability_information; u16 statusCode; u16 Association_ID; struct Supported_Rates_Element supportedRates; -}__attribute__ ((packed)); +} __attribute__ ((packed)); /*struct Reassociation_Request_Frame_Body { @@ -624,44 +598,40 @@ struct Association_Response_Frame_Body // SSID (2+32 bytes) // Supported_Rates (2+8 bytes) };*/ -// eliminated by WS 07/22/04 comboined with associateion request frame. +/* eliminated by WS 07/22/04 comboined with associateion request frame. */ -struct Reassociation_Response_Frame_Body -{ +struct Reassociation_Response_Frame_Body { u16 capability_information; u16 statusCode; u16 Association_ID; struct Supported_Rates_Element supportedRates; -}__attribute__ ((packed)); +} __attribute__ ((packed)); -struct Deauthentication_Frame_Body -{ +struct Deauthentication_Frame_Body { u16 reasonCode; -}__attribute__ ((packed)); +} __attribute__ ((packed)); -struct Probe_Response_Frame_Body -{ +struct Probe_Response_Frame_Body { u16 Timestamp; u16 Beacon_Interval; u16 Capability_Information; - // SSID + /* SSID // Supported_Rates // PHY parameter Set (DS Parameters) // CF parameter Set - // IBSS parameter Set -}__attribute__ ((packed)); + // IBSS parameter Set */ +} __attribute__ ((packed)); -struct Authentication_Frame_Body -{ +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 -}__attribute__ ((packed)); + /* NB: don't include ChallengeText in this structure + // struct Challenge_Text_Element sChallengeTextElement; // wkchen added */ +} __attribute__ ((packed)); -#endif // _MAC_Structure_H_ +#endif /* _MAC_Structure_H_ */ diff --git a/drivers/staging/winbond/mds.c b/drivers/staging/winbond/mds.c index 37e0c185d113..65063c33618d 100644 --- a/drivers/staging/winbond/mds.c +++ b/drivers/staging/winbond/mds.c @@ -43,53 +43,53 @@ static void Mds_DurationSet(struct wbsoft_priv *adapter, struct wb35_descriptor pT01 = (PT01_DESCRIPTOR)(buffer+4); pNextT00 = (PT00_DESCRIPTOR)(buffer+OffsetSize); - if( buffer[ DOT_11_DA_OFFSET+8 ] & 0x1 ) // +8 for USB hdr + if( buffer[ DOT_11_DA_OFFSET+8 ] & 0x1 ) /* +8 for USB hdr */ boGroupAddr = true; - //======================================== - // Set RTS/CTS mechanism - //======================================== + /****************************************** + * Set RTS/CTS mechanism + ******************************************/ if (!boGroupAddr) { - //NOTE : If the protection mode is enabled and the MSDU will be fragmented, - // the tx rates of MPDUs will all be DSSS rates. So it will not use - // CTS-to-self in this case. CTS-To-self will only be used when without - // fragmentation. -- 20050112 - BodyLen = (u16)pT00->T00_frame_length; //include 802.11 header - BodyLen += 4; //CRC + /* NOTE : If the protection mode is enabled and the MSDU will be fragmented, + * the tx rates of MPDUs will all be DSSS rates. So it will not use + * CTS-to-self in this case. CTS-To-self will only be used when without + * fragmentation. -- 20050112 */ + BodyLen = (u16)pT00->T00_frame_length; /* include 802.11 header */ + BodyLen += 4; /* CRC */ if( BodyLen >= CURRENT_RTS_THRESHOLD ) - RTS_on = true; // Using RTS + RTS_on = true; /* Using RTS */ else { - if( pT01->T01_modulation_type ) // Is using OFDM + if( pT01->T01_modulation_type ) /* Is using OFDM */ { - if( CURRENT_PROTECT_MECHANISM ) // Is using protect - CTS_on = true; // Using CTS + if( CURRENT_PROTECT_MECHANISM ) /* Is using protect */ + CTS_on = true; /* Using CTS */ } } } if( RTS_on || CTS_on ) { - if( pT01->T01_modulation_type) // Is using OFDM + if( pT01->T01_modulation_type) /* Is using OFDM */ { - //CTS duration - // 2 SIFS + DATA transmit time + 1 ACK - // ACK Rate : 24 Mega bps - // ACK frame length = 14 bytes + /* CTS duration + * 2 SIFS + DATA transmit time + 1 ACK + * ACK Rate : 24 Mega bps + * ACK frame length = 14 bytes */ Duration = 2*DEFAULT_SIFSTIME + 2*PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION + ((BodyLen*8 + 22 + Rate*4 - 1)/(Rate*4))*Tsym + ((112 + 22 + 95)/96)*Tsym; } - else //DSSS + else /* DSSS */ { - //CTS duration - // 2 SIFS + DATA transmit time + 1 ACK - // Rate : ?? Mega bps - // ACK frame length = 14 bytes - if( pT01->T01_plcp_header_length ) //long preamble + /* CTS duration + * 2 SIFS + DATA transmit time + 1 ACK + * Rate : ?? Mega bps + * ACK frame length = 14 bytes */ + if( pT01->T01_plcp_header_length ) /* long preamble */ Duration = LONG_PREAMBLE_PLUS_PLCPHEADER_TIME*2; else Duration = SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME*2; @@ -100,21 +100,21 @@ static void Mds_DurationSet(struct wbsoft_priv *adapter, struct wb35_descriptor if( RTS_on ) { - if( pT01->T01_modulation_type ) // Is using OFDM + if( pT01->T01_modulation_type ) /* Is using OFDM */ { - //CTS + 1 SIFS + CTS duration - //CTS Rate : 24 Mega bps - //CTS frame length = 14 bytes + /* CTS + 1 SIFS + CTS duration + * CTS Rate : 24 Mega bps + * CTS frame length = 14 bytes */ Duration += (DEFAULT_SIFSTIME + PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION + ((112 + 22 + 95)/96)*Tsym); } else { - //CTS + 1 SIFS + CTS duration - //CTS Rate : ?? Mega bps - //CTS frame length = 14 bytes - if( pT01->T01_plcp_header_length ) //long preamble + /* CTS + 1 SIFS + CTS duration + * CTS Rate : ?? Mega bps + * CTS frame length = 14 bytes */ + if( pT01->T01_plcp_header_length ) /* long preamble */ Duration += LONG_PREAMBLE_PLUS_PLCPHEADER_TIME; else Duration += SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME; @@ -123,15 +123,15 @@ static void Mds_DurationSet(struct wbsoft_priv *adapter, struct wb35_descriptor } } - // Set the value into USB descriptor + /* Set the value into USB descriptor */ pT01->T01_add_rts = RTS_on ? 1 : 0; pT01->T01_add_cts = CTS_on ? 1 : 0; pT01->T01_rts_cts_duration = Duration; } - //===================================== - // Fill the more fragment descriptor - //===================================== + /****************************************** + * Fill the more fragment descriptor + ******************************************/ if( boGroupAddr ) Duration = 0; else @@ -139,14 +139,14 @@ static void Mds_DurationSet(struct wbsoft_priv *adapter, struct wb35_descriptor for( i=pDes->FragmentCount-1; i>0; i-- ) { NextBodyLen = (u16)pNextT00->T00_frame_length; - NextBodyLen += 4; //CRC + NextBodyLen += 4; /* CRC */ if( pT01->T01_modulation_type ) { - //OFDM - // data transmit time + 3 SIFS + 2 ACK - // Rate : ??Mega bps - // ACK frame length = 14 bytes, tx rate = 24M + /* OFDM + * data transmit time + 3 SIFS + 2 ACK + * Rate : ??Mega bps + * ACK frame length = 14 bytes, tx rate = 24M */ Duration = PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION * 3; Duration += (((NextBodyLen*8 + 22 + Rate*4 - 1)/(Rate*4)) * Tsym + (((2*14)*8 + 22 + 95)/96)*Tsym + @@ -154,12 +154,12 @@ static void Mds_DurationSet(struct wbsoft_priv *adapter, struct wb35_descriptor } else { - //DSSS - // data transmit time + 2 ACK + 3 SIFS - // Rate : ??Mega bps - // ACK frame length = 14 bytes - //TODO : - if( pT01->T01_plcp_header_length ) //long preamble + /* DSSS + * data transmit time + 2 ACK + 3 SIFS + * Rate : ??Mega bps + * ACK frame length = 14 bytes + * TODO : */ + if( pT01->T01_plcp_header_length ) /* long preamble */ Duration = LONG_PREAMBLE_PLUS_PLCPHEADER_TIME*3; else Duration = SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME*3; @@ -168,39 +168,39 @@ static void Mds_DurationSet(struct wbsoft_priv *adapter, struct wb35_descriptor DEFAULT_SIFSTIME*3 ); } - ((u16 *)buffer)[5] = cpu_to_le16(Duration);// 4 USHOR for skip 8B USB, 2USHORT=FC + Duration + ((u16 *)buffer)[5] = cpu_to_le16(Duration); /* 4 USHOR for skip 8B USB, 2USHORT=FC + Duration */ - //----20061009 add by anson's endian + /* ----20061009 add by anson's endian */ pNextT00->value = cpu_to_le32(pNextT00->value); pT01->value = cpu_to_le32( pT01->value ); - //----end 20061009 add by anson's endian + /* ----end 20061009 add by anson's endian */ buffer += OffsetSize; pT01 = (PT01_DESCRIPTOR)(buffer+4); - if (i != 1) //The last fragment will not have the next fragment + if (i != 1) /* The last fragment will not have the next fragment */ pNextT00 = (PT00_DESCRIPTOR)(buffer+OffsetSize); } - //===================================== - // Fill the last fragment descriptor - //===================================== + /******************************************* + * Fill the last fragment descriptor + *******************************************/ if( pT01->T01_modulation_type ) { - //OFDM - // 1 SIFS + 1 ACK - // Rate : 24 Mega bps - // ACK frame length = 14 bytes + /* OFDM + * 1 SIFS + 1 ACK + * Rate : 24 Mega bps + * ACK frame length = 14 bytes */ Duration = PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION; - //The Tx rate of ACK use 24M + /* The Tx rate of ACK use 24M */ Duration += (((112 + 22 + 95)/96)*Tsym + DEFAULT_SIFSTIME ); } else { - // DSSS - // 1 ACK + 1 SIFS - // Rate : ?? Mega bps - // ACK frame length = 14 bytes(112 bits) - if( pT01->T01_plcp_header_length ) //long preamble + /* DSSS + * 1 ACK + 1 SIFS + * Rate : ?? Mega bps + * ACK frame length = 14 bytes(112 bits) */ + if( pT01->T01_plcp_header_length ) /* long preamble */ Duration = LONG_PREAMBLE_PLUS_PLCPHEADER_TIME; else Duration = SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME; @@ -209,14 +209,14 @@ static void Mds_DurationSet(struct wbsoft_priv *adapter, struct wb35_descriptor } } - ((u16 *)buffer)[5] = cpu_to_le16(Duration);// 4 USHOR for skip 8B USB, 2USHORT=FC + Duration + ((u16 *)buffer)[5] = cpu_to_le16(Duration); /* 4 USHOR for skip 8B USB, 2USHORT=FC + Duration */ pT00->value = cpu_to_le32(pT00->value); pT01->value = cpu_to_le32(pT01->value); - //--end 20061009 add + /* --end 20061009 add */ } -// The function return the 4n size of usb pk +/* The function return the 4n size of usb pk */ static u16 Mds_BodyCopy(struct wbsoft_priv *adapter, struct wb35_descriptor *pDes, u8 *TargetBuffer) { PT00_DESCRIPTOR pT00; @@ -229,8 +229,8 @@ static u16 Mds_BodyCopy(struct wbsoft_priv *adapter, struct wb35_descriptor *pDe u8 buf_index, FragmentCount = 0; - // Copy fragment body - buffer = TargetBuffer; // shift 8B usb + 24B 802.11 + /* Copy fragment body */ + buffer = TargetBuffer; /* shift 8B usb + 24B 802.11 */ SizeLeft = pDes->buffer_total_size; buf_index = pDes->buffer_start_index; @@ -240,35 +240,35 @@ static u16 Mds_BodyCopy(struct wbsoft_priv *adapter, struct wb35_descriptor *pDe CopySize = SizeLeft; if (SizeLeft > pDes->FragmentThreshold) { CopySize = pDes->FragmentThreshold; - pT00->T00_frame_length = 24 + CopySize;//Set USB length + pT00->T00_frame_length = 24 + CopySize; /* Set USB length */ } else - pT00->T00_frame_length = 24 + SizeLeft;//Set USB length + pT00->T00_frame_length = 24 + SizeLeft; /* Set USB length */ SizeLeft -= CopySize; - // 1 Byte operation + /* 1 Byte operation */ pctmp = (u8 *)( buffer + 8 + DOT_11_SEQUENCE_OFFSET ); *pctmp &= 0xf0; - *pctmp |= FragmentCount;//931130.5.m + *pctmp |= FragmentCount; /* 931130.5.m */ if( !FragmentCount ) pT00->T00_first_mpdu = 1; - buffer += 32; // 8B usb + 24B 802.11 header + buffer += 32; /* 8B usb + 24B 802.11 header */ Size += 32; - // Copy into buffer + /* Copy into buffer */ stmp = CopySize + 3; - stmp &= ~0x03;//4n Alignment - Size += stmp;// Current 4n offset of mpdu + stmp &= ~0x03; /* 4n Alignment */ + Size += stmp; /* Current 4n offset of mpdu */ while (CopySize) { - // Copy body + /* Copy body */ src_buffer = pDes->buffer_address[buf_index]; CopyLeft = CopySize; if (CopySize >= pDes->buffer_size[buf_index]) { CopyLeft = pDes->buffer_size[buf_index]; - // Get the next buffer of descriptor + /* Get the next buffer of descriptor */ buf_index++; buf_index %= MAX_DESCRIPTOR_BUFFER_INDEX; } else { @@ -283,14 +283,14 @@ static u16 Mds_BodyCopy(struct wbsoft_priv *adapter, struct wb35_descriptor *pDe CopySize -= CopyLeft; } - // 931130.5.n + /* 931130.5.n */ if (pMds->MicAdd) { if (!SizeLeft) { pMds->MicWriteAddress[ pMds->MicWriteIndex ] = buffer - pMds->MicAdd; pMds->MicWriteSize[ pMds->MicWriteIndex ] = pMds->MicAdd; pMds->MicAdd = 0; } - else if( SizeLeft < 8 ) //931130.5.p + else if( SizeLeft < 8 ) /* 931130.5.p */ { pMds->MicAdd = SizeLeft; pMds->MicWriteAddress[ pMds->MicWriteIndex ] = buffer - ( 8 - SizeLeft ); @@ -299,10 +299,10 @@ static u16 Mds_BodyCopy(struct wbsoft_priv *adapter, struct wb35_descriptor *pDe } } - // Does it need to generate the new header for next mpdu? + /* Does it need to generate the new header for next mpdu? */ if (SizeLeft) { - buffer = TargetBuffer + Size; // Get the next 4n start address - memcpy( buffer, TargetBuffer, 32 );//Copy 8B USB +24B 802.11 + buffer = TargetBuffer + Size; /* Get the next 4n start address */ + memcpy( buffer, TargetBuffer, 32 ); /* Copy 8B USB +24B 802.11 */ pT00 = (PT00_DESCRIPTOR)buffer; pT00->T00_first_mpdu = 0; } @@ -312,16 +312,16 @@ static u16 Mds_BodyCopy(struct wbsoft_priv *adapter, struct wb35_descriptor *pDe pT00->T00_last_mpdu = 1; pT00->T00_IsLastMpdu = 1; - buffer = (u8 *)pT00 + 8; // +8 for USB hdr - buffer[1] &= ~0x04; // Clear more frag bit of 802.11 frame control - pDes->FragmentCount = FragmentCount; // Update the correct fragment number + buffer = (u8 *)pT00 + 8; /* +8 for USB hdr */ + buffer[1] &= ~0x04; /* Clear more frag bit of 802.11 frame control */ + pDes->FragmentCount = FragmentCount; /* Update the correct fragment number */ return Size; } static void Mds_HeaderCopy(struct wbsoft_priv * adapter, struct wb35_descriptor *pDes, u8 *TargetBuffer) { struct wb35_mds *pMds = &adapter->Mds; - u8 *src_buffer = pDes->buffer_address[0];//931130.5.g + u8 *src_buffer = pDes->buffer_address[0]; /* 931130.5.g */ PT00_DESCRIPTOR pT00; PT01_DESCRIPTOR pT01; u16 stmp; @@ -330,44 +330,44 @@ static void Mds_HeaderCopy(struct wbsoft_priv * adapter, struct wb35_descriptor stmp = pDes->buffer_total_size; - // - // Set USB header 8 byte - // + /* + * Set USB header 8 byte + */ pT00 = (PT00_DESCRIPTOR)TargetBuffer; TargetBuffer += 4; pT01 = (PT01_DESCRIPTOR)TargetBuffer; TargetBuffer += 4; - pT00->value = 0;// Clear - pT01->value = 0;// Clear + pT00->value = 0; /* Clear */ + pT01->value = 0; /* Clear */ - pT00->T00_tx_packet_id = pDes->Descriptor_ID;// Set packet ID - pT00->T00_header_length = 24;// Set header length - pT01->T01_retry_abort_ebable = 1;//921013 931130.5.h + pT00->T00_tx_packet_id = pDes->Descriptor_ID; /* Set packet ID */ + pT00->T00_header_length = 24; /* Set header length */ + pT01->T01_retry_abort_ebable = 1; /* 921013 931130.5.h */ - // Key ID setup + /* Key ID setup */ pT01->T01_wep_id = 0; - FragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD; //Do not fragment - // Copy full data, the 1'st buffer contain all the data 931130.5.j - memcpy( TargetBuffer, src_buffer, DOT_11_MAC_HEADER_SIZE );// Copy header + FragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD; /* Do not fragment */ + /* Copy full data, the 1'st buffer contain all the data 931130.5.j */ + memcpy( TargetBuffer, src_buffer, DOT_11_MAC_HEADER_SIZE ); /* Copy header */ pDes->buffer_address[0] = src_buffer + DOT_11_MAC_HEADER_SIZE; pDes->buffer_total_size -= DOT_11_MAC_HEADER_SIZE; pDes->buffer_size[0] = pDes->buffer_total_size; - // Set fragment threshold + /* Set fragment threshold */ FragmentThreshold -= (DOT_11_MAC_HEADER_SIZE + 4); pDes->FragmentThreshold = FragmentThreshold; - // Set more frag bit - TargetBuffer[1] |= 0x04;// Set more frag bit + /* Set more frag bit */ + TargetBuffer[1] |= 0x04; /* Set more frag bit */ - // - // Set tx rate - // - stmp = *(u16 *)(TargetBuffer+30); // 2n alignment address + /* + * Set tx rate + */ + stmp = *(u16 *)(TargetBuffer+30); /* 2n alignment address */ - //Use basic rate + /* Use basic rate */ ctmp1 = ctmpf = CURRENT_TX_RATE_FOR_MNG; pDes->TxRate = ctmp1; @@ -381,10 +381,10 @@ static void Mds_HeaderCopy(struct wbsoft_priv * adapter, struct wb35_descriptor if( i == 1 ) ctmp1 = ctmpf; - pMds->TxRate[pDes->Descriptor_ID][i] = ctmp1; // backup the ta rate and fall back rate + pMds->TxRate[pDes->Descriptor_ID][i] = ctmp1; /* backup the ta rate and fall back rate */ if( ctmp1 == 108) ctmp2 = 7; - else if( ctmp1 == 96 ) ctmp2 = 6; // Rate convert for USB + else if( ctmp1 == 96 ) ctmp2 = 6; /* Rate convert for USB */ else if( ctmp1 == 72 ) ctmp2 = 5; else if( ctmp1 == 48 ) ctmp2 = 4; else if( ctmp1 == 36 ) ctmp2 = 3; @@ -394,7 +394,7 @@ static void Mds_HeaderCopy(struct wbsoft_priv * adapter, struct wb35_descriptor else if( ctmp1 == 22 ) ctmp2 = 3; else if( ctmp1 == 11 ) ctmp2 = 2; else if( ctmp1 == 4 ) ctmp2 = 1; - else ctmp2 = 0; // if( ctmp1 == 2 ) or default + else ctmp2 = 0; /* if( ctmp1 == 2 ) or default */ if( i == 0 ) pT01->T01_transmit_rate = ctmp2; @@ -402,14 +402,14 @@ static void Mds_HeaderCopy(struct wbsoft_priv * adapter, struct wb35_descriptor pT01->T01_fall_back_rate = ctmp2; } - // - // Set preamble type - // - if ((pT01->T01_modulation_type == 0) && (pT01->T01_transmit_rate == 0)) // RATE_1M + /* + * Set preamble type + */ + if ((pT01->T01_modulation_type == 0) && (pT01->T01_transmit_rate == 0)) /* RATE_1M */ pDes->PreambleMode = WLAN_PREAMBLE_TYPE_LONG; else pDes->PreambleMode = CURRENT_PREAMBLE_MODE; - pT01->T01_plcp_header_length = pDes->PreambleMode; // Set preamble + pT01->T01_plcp_header_length = pDes->PreambleMode; /* Set preamble */ } @@ -431,21 +431,21 @@ Mds_Tx(struct wbsoft_priv * adapter) if (!hal_driver_init_OK(pHwData)) return; - //Only one thread can be run here + /* Only one thread can be run here */ if (atomic_inc_return(&pMds->TxThreadCount) != 1) goto cleanup; - // Start to fill the data + /* Start to fill the data */ do { FillIndex = pMds->TxFillIndex; - if (pMds->TxOwner[FillIndex]) { // Is owned by software 0:Yes 1:No + if (pMds->TxOwner[FillIndex]) { /* Is owned by software 0:Yes 1:No */ #ifdef _PE_TX_DUMP_ printk("[Mds_Tx] Tx Owner is H/W.\n"); #endif break; } - XmitBufAddress = pMds->pTxBuffer + (MAX_USB_TX_BUFFER * FillIndex); //Get buffer + XmitBufAddress = pMds->pTxBuffer + (MAX_USB_TX_BUFFER * FillIndex); /* Get buffer */ XmitBufSize = 0; FillCount = 0; do { @@ -453,37 +453,37 @@ Mds_Tx(struct wbsoft_priv * adapter) if (!PacketSize) break; - //For Check the buffer resource + /* For Check the buffer resource */ FragmentThreshold = CURRENT_FRAGMENT_THRESHOLD; - //931130.5.b + /* 931130.5.b */ FragmentCount = PacketSize/FragmentThreshold + 1; - stmp = PacketSize + FragmentCount*32 + 8;//931130.5.c 8:MIC + stmp = PacketSize + FragmentCount*32 + 8; /* 931130.5.c 8:MIC */ if ((XmitBufSize + stmp) >= MAX_USB_TX_BUFFER) { printk("[Mds_Tx] Excess max tx buffer.\n"); - break; // buffer is not enough + break; /* buffer is not enough */ } - // - // Start transmitting - // + /* + * Start transmitting + */ BufferFilled = true; /* Leaves first u8 intact */ memset((u8 *)pTxDes + 1, 0, sizeof(struct wb35_descriptor) - 1); - TxDesIndex = pMds->TxDesIndex;//Get the current ID + TxDesIndex = pMds->TxDesIndex; /* Get the current ID */ pTxDes->Descriptor_ID = TxDesIndex; - pMds->TxDesFrom[ TxDesIndex ] = 2;//Storing the information of source comming from + pMds->TxDesFrom[ TxDesIndex ] = 2; /* Storing the information of source comming from */ pMds->TxDesIndex++; pMds->TxDesIndex %= MAX_USB_TX_DESCRIPTOR; MLME_GetNextPacket( adapter, pTxDes ); - // Copy header. 8byte USB + 24byte 802.11Hdr. Set TxRate, Preamble type + /* Copy header. 8byte USB + 24byte 802.11Hdr. Set TxRate, Preamble type */ Mds_HeaderCopy( adapter, pTxDes, XmitBufAddress ); - // For speed up Key setting + /* For speed up Key setting */ if (pTxDes->EapFix) { #ifdef _PE_TX_DUMP_ printk("35: EPA 4th frame detected. Size = %d\n", PacketSize); @@ -491,41 +491,41 @@ Mds_Tx(struct wbsoft_priv * adapter) pHwData->IsKeyPreSet = 1; } - // Copy (fragment) frame body, and set USB, 802.11 hdr flag + /* Copy (fragment) frame body, and set USB, 802.11 hdr flag */ CurrentSize = Mds_BodyCopy(adapter, pTxDes, XmitBufAddress); - // Set RTS/CTS and Normal duration field into buffer + /* Set RTS/CTS and Normal duration field into buffer */ Mds_DurationSet(adapter, pTxDes, XmitBufAddress); - //Shift to the next address + /* Shift to the next address */ XmitBufSize += CurrentSize; XmitBufAddress += CurrentSize; #ifdef _IBSS_BEACON_SEQ_STICK_ - if ((XmitBufAddress[ DOT_11_DA_OFFSET+8 ] & 0xfc) != MAC_SUBTYPE_MNGMNT_PROBE_REQUEST) // +8 for USB hdr + if ((XmitBufAddress[ DOT_11_DA_OFFSET+8 ] & 0xfc) != MAC_SUBTYPE_MNGMNT_PROBE_REQUEST) /* +8 for USB hdr */ #endif pMds->TxToggle = true; - // Get packet to transmit completed, 1:TESTSTA 2:MLME 3: Ndis data + /* Get packet to transmit completed, 1:TESTSTA 2:MLME 3: Ndis data */ MLME_SendComplete(adapter, 0, true); - // Software TSC count 20060214 + /* Software TSC count 20060214 */ pMds->TxTsc++; if (pMds->TxTsc == 0) pMds->TxTsc_2++; - FillCount++; // 20060928 - } while (HAL_USB_MODE_BURST(pHwData)); // End of multiple MSDU copy loop. false = single true = multiple sending + FillCount++; /* 20060928 */ + } while (HAL_USB_MODE_BURST(pHwData)); /* End of multiple MSDU copy loop. false = single true = multiple sending */ - // Move to the next one, if necessary + /* Move to the next one, if necessary */ if (BufferFilled) { - // size setting + /* size setting */ pMds->TxBufferSize[ FillIndex ] = XmitBufSize; - // 20060928 set Tx count + /* 20060928 set Tx count */ pMds->TxCountInBuffer[FillIndex] = FillCount; - // Set owner flag + /* Set owner flag */ pMds->TxOwner[FillIndex] = 1; pMds->TxFillIndex++; @@ -534,14 +534,14 @@ Mds_Tx(struct wbsoft_priv * adapter) } else break; - if (!PacketSize) // No more pk for transmitting + if (!PacketSize) /* No more pk for transmitting */ break; } while(true); - // - // Start to send by lower module - // + /* + * Start to send by lower module + */ if (!pHwData->IsKeyPreSet) Wb35Tx_start(adapter); @@ -558,20 +558,20 @@ Mds_SendComplete(struct wbsoft_priv * adapter, PT02_DESCRIPTOR pT02) unsigned char SendOK = true; u8 RetryCount, TxRate; - if (pT02->T02_IgnoreResult) // Don't care the result + if (pT02->T02_IgnoreResult) /* Don't care the result */ return; if (pT02->T02_IsLastMpdu) { - //TODO: DTO -- get the retry count and fragment count - // Tx rate + /* TODO: DTO -- get the retry count and fragment count */ + /* Tx rate */ TxRate = pMds->TxRate[ PacketId ][ 0 ]; RetryCount = (u8)pT02->T02_MPDU_Cnt; if (pT02->value & FLAG_ERROR_TX_MASK) { SendOK = false; if (pT02->T02_transmit_abort || pT02->T02_out_of_MaxTxMSDULiftTime) { - //retry error + /* retry error */ pHwData->dto_tx_retry_count += (RetryCount+1); - //[for tx debug] + /* [for tx debug] */ if (RetryCount<7) pHwData->tx_retry_count[RetryCount] += RetryCount; else @@ -583,7 +583,7 @@ Mds_SendComplete(struct wbsoft_priv * adapter, PT02_DESCRIPTOR pT02) } pHwData->dto_tx_frag_count += (RetryCount+1); - //[for tx debug] + /* [for tx debug] */ if (pT02->T02_transmit_abort_due_to_TBTT) pHwData->tx_TBTT_start_count++; if (pT02->T02_transmit_without_encryption_due_to_wep_on_false) @@ -596,7 +596,7 @@ Mds_SendComplete(struct wbsoft_priv * adapter, PT02_DESCRIPTOR pT02) MTO_SetTxCount(adapter, TxRate, RetryCount); } - // Clear send result buffer + /* Clear send result buffer */ pMds->TxResult[ PacketId ] = 0; } else pMds->TxResult[ PacketId ] |= ((u16)(pT02->value & 0x0ffff)); diff --git a/drivers/staging/winbond/mds_f.h b/drivers/staging/winbond/mds_f.h index e09dd4b879d4..20e97bfe01e9 100644 --- a/drivers/staging/winbond/mds_f.h +++ b/drivers/staging/winbond/mds_f.h @@ -4,17 +4,17 @@ #include "wbhal_s.h" #include "core.h" -unsigned char Mds_initial( struct wbsoft_priv *adapter ); -void Mds_Destroy( struct wbsoft_priv *adapter ); -void Mds_Tx( struct wbsoft_priv *adapter ); -void Mds_SendComplete( struct wbsoft_priv *adapter, PT02_DESCRIPTOR pT02 ); -void Mds_MpduProcess( struct wbsoft_priv *adapter, struct wb35_descriptor *pRxDes ); +unsigned char Mds_initial(struct wbsoft_priv *adapter); +void Mds_Destroy(struct wbsoft_priv *adapter); +void Mds_Tx(struct wbsoft_priv *adapter); +void Mds_SendComplete(struct wbsoft_priv *adapter, PT02_DESCRIPTOR pt02); +void Mds_MpduProcess(struct wbsoft_priv *adapter, struct wb35_descriptor *prxdes); extern void DataDmp(u8 *pdata, u32 len, u32 offset); -// For data frame sending 20060802 -u16 MDS_GetPacketSize( struct wbsoft_priv *adapter ); -void MDS_GetNextPacket( struct wbsoft_priv *adapter, struct wb35_descriptor *pDes ); -void MDS_GetNextPacketComplete( struct wbsoft_priv *adapter, struct wb35_descriptor *pDes ); -void MDS_SendResult( struct wbsoft_priv *adapter, u8 PacketId, unsigned char SendOK ); +/* For data frame sending */ +u16 MDS_GetPacketSize(struct wbsoft_priv *adapter); +void MDS_GetNextPacket(struct wbsoft_priv *adapter, struct wb35_descriptor *pdes); +void MDS_GetNextPacketComplete(struct wbsoft_priv *adapter, struct wb35_descriptor *pdes); +void MDS_SendResult(struct wbsoft_priv *adapter, u8 packetid, unsigned char sendok); #endif diff --git a/drivers/staging/winbond/mds_s.h b/drivers/staging/winbond/mds_s.h index 217ff0819a93..89328c5dbdad 100644 --- a/drivers/staging/winbond/mds_s.h +++ b/drivers/staging/winbond/mds_s.h @@ -15,122 +15,121 @@ enum { WLAN_PREAMBLE_TYPE_LONG, }; -//////////////////////////////////////////////////////////////////////////////////////////////////////// -#define MAX_USB_TX_DESCRIPTOR 15 // IS89C35 ability -#define MAX_USB_TX_BUFFER_NUMBER 4 // Virtual pre-buffer number of MAX_USB_TX_BUFFER -#define MAX_USB_TX_BUFFER 4096 // IS89C35 ability 4n alignment is required for hardware +/*****************************************************************************/ +#define MAX_USB_TX_DESCRIPTOR 15 /* IS89C35 ability */ +#define MAX_USB_TX_BUFFER_NUMBER 4 /* Virtual pre-buffer number of MAX_USB_TX_BUFFER */ +#define MAX_USB_TX_BUFFER 4096 /* IS89C35 ability 4n alignment is required for hardware */ -#define AUTH_REQUEST_PAIRWISE_ERROR 0 // _F flag setting -#define AUTH_REQUEST_GROUP_ERROR 1 // _F flag setting +#define AUTH_REQUEST_PAIRWISE_ERROR 0 /* _F flag setting */ +#define AUTH_REQUEST_GROUP_ERROR 1 /* _F flag setting */ -#define CURRENT_FRAGMENT_THRESHOLD (adapter->Mds.TxFragmentThreshold & ~0x1) -#define CURRENT_PREAMBLE_MODE psLOCAL->boShortPreamble?WLAN_PREAMBLE_TYPE_SHORT:WLAN_PREAMBLE_TYPE_LONG -#define CURRENT_TX_RATE_FOR_MNG adapter->sLocalPara.CurrentTxRateForMng -#define CURRENT_PROTECT_MECHANISM psLOCAL->boProtectMechanism -#define CURRENT_RTS_THRESHOLD adapter->Mds.TxRTSThreshold +#define CURRENT_FRAGMENT_THRESHOLD (adapter->Mds.TxFragmentThreshold & ~0x1) +#define CURRENT_PREAMBLE_MODE (psLOCAL->boShortPreamble ? WLAN_PREAMBLE_TYPE_SHORT : WLAN_PREAMBLE_TYPE_LONG) +#define CURRENT_TX_RATE_FOR_MNG (adapter->sLocalPara.CurrentTxRateForMng) +#define CURRENT_PROTECT_MECHANISM (psLOCAL->boProtectMechanism) +#define CURRENT_RTS_THRESHOLD (adapter->Mds.TxRTSThreshold) -#define MIB_GS_XMIT_OK_INC adapter->sLocalPara.GS_XMIT_OK++ -#define MIB_GS_RCV_OK_INC adapter->sLocalPara.GS_RCV_OK++ -#define MIB_GS_XMIT_ERROR_INC adapter->sLocalPara.GS_XMIT_ERROR +#define MIB_GS_XMIT_OK_INC (adapter->sLocalPara.GS_XMIT_OK++) +#define MIB_GS_RCV_OK_INC (adapter->sLocalPara.GS_RCV_OK++) +#define MIB_GS_XMIT_ERROR_INC (adapter->sLocalPara.GS_XMIT_ERROR) -//---------- TX ----------------------------------- +/* ---------- TX ----------------------------------- */ #define ETHERNET_TX_DESCRIPTORS MAX_USB_TX_BUFFER_NUMBER -//---------- RX ------------------------------------ -#define ETHERNET_RX_DESCRIPTORS 8 //It's not necessary to allocate more than 2 in sync indicate - -//================================================================ -// Configration default value -//================================================================ -#define DEFAULT_MULTICASTLISTMAX 32 // standard -#define DEFAULT_TX_BURSTLENGTH 3 // 32 Longwords -#define DEFAULT_RX_BURSTLENGTH 3 // 32 Longwords -#define DEFAULT_TX_THRESHOLD 0 // Full Packet -#define DEFAULT_RX_THRESHOLD 0 // Full Packet -#define DEFAULT_MAXTXRATE 6 // 11 Mbps (Long) -#define DEFAULT_CHANNEL 3 // Chennel 3 -#define DEFAULT_RTSThreshold 2347 // Disable RTS -//#define DEFAULT_PME 1 // Enable -#define DEFAULT_PME 0 // Disable -#define DEFAULT_SIFSTIME 10 -#define DEFAULT_ACKTIME_1ML 304 // 148+44+112 911220 by LCC -#define DEFAULT_ACKTIME_2ML 248 // 148+44+56 911220 by LCC -#define DEFAULT_FRAGMENT_THRESHOLD 2346 // No fragment -#define DEFAULT_PREAMBLE_LENGTH 72 +/* ---------- RX ----------------------------------- */ +#define ETHERNET_RX_DESCRIPTORS 8 /* It's not necessary to allocate more than 2 in sync indicate */ + +/* + * ================================================================ + * Configration default value + * ================================================================ + */ +#define DEFAULT_MULTICASTLISTMAX 32 /* standard */ +#define DEFAULT_TX_BURSTLENGTH 3 /* 32 Longwords */ +#define DEFAULT_RX_BURSTLENGTH 3 /* 32 Longwords */ +#define DEFAULT_TX_THRESHOLD 0 /* Full Packet */ +#define DEFAULT_RX_THRESHOLD 0 /* Full Packet */ +#define DEFAULT_MAXTXRATE 6 /* 11 Mbps (Long) */ +#define DEFAULT_CHANNEL 3 /* Chennel 3 */ +#define DEFAULT_RTSThreshold 2347 /* Disable RTS */ +#define DEFAULT_PME 0 /* Disable */ +#define DEFAULT_SIFSTIME 10 +#define DEFAULT_ACKTIME_1ML 304 /* 148 + 44 + 112 */ +#define DEFAULT_ACKTIME_2ML 248 /* 148 + 44 + 56 */ +#define DEFAULT_FRAGMENT_THRESHOLD 2346 /* No fragment */ +#define DEFAULT_PREAMBLE_LENGTH 72 #define DEFAULT_PLCPHEADERTIME_LENGTH 24 -/*------------------------------------------------------------------------ - 0.96 sec since time unit of the R03 for the current, W89C32 is about 60ns - instead of 960 ns. This shall be fixed in the future W89C32 - -------------------------------------------------------------------------*/ -#define DEFAULT_MAX_RECEIVE_TIME 16440000 +/* + * ------------------------------------------------------------------------ + * 0.96 sec since time unit of the R03 for the current, W89C32 is about 60ns + * instead of 960 ns. This shall be fixed in the future W89C32 + * ------------------------------------------------------------------------- + */ +#define DEFAULT_MAX_RECEIVE_TIME 16440000 -#define RX_BUF_SIZE 2352 // 600 // For 301 must be multiple of 8 -#define MAX_RX_DESCRIPTORS 18 // Rx Layer 2 +#define RX_BUF_SIZE 2352 /* 600 - For 301 must be multiple of 8 */ +#define MAX_RX_DESCRIPTORS 18 /* Rx Layer 2 */ +/* For brand-new rx system */ +#define MDS_ID_IGNORE ETHERNET_RX_DESCRIPTORS -// For brand-new rx system -#define MDS_ID_IGNORE ETHERNET_RX_DESCRIPTORS - -// For Tx Packet status classify -#define PACKET_FREE_TO_USE 0 -#define PACKET_COME_FROM_NDIS 0x08 -#define PACKET_COME_FROM_MLME 0x80 -#define PACKET_SEND_COMPLETE 0xff +/* For Tx Packet status classify */ +#define PACKET_FREE_TO_USE 0 +#define PACKET_COME_FROM_NDIS 0x08 +#define PACKET_COME_FROM_MLME 0x80 +#define PACKET_SEND_COMPLETE 0xff struct wb35_mds { - // For Tx usage - u8 TxOwner[ ((MAX_USB_TX_BUFFER_NUMBER + 3) & ~0x03) ]; + /* For Tx usage */ + u8 TxOwner[((MAX_USB_TX_BUFFER_NUMBER + 3) & ~0x03)]; u8 *pTxBuffer; - u16 TxBufferSize[ ((MAX_USB_TX_BUFFER_NUMBER + 1) & ~0x01) ]; - u8 TxDesFrom[ ((MAX_USB_TX_DESCRIPTOR + 3) & ~0x03) ];//931130.4.u // 1: MLME 2: NDIS control 3: NDIS data - u8 TxCountInBuffer[ ((MAX_USB_TX_DESCRIPTOR + 3) & ~0x03) ]; // 20060928 + u16 TxBufferSize[((MAX_USB_TX_BUFFER_NUMBER + 1) & ~0x01)]; + u8 TxDesFrom[((MAX_USB_TX_DESCRIPTOR + 3) & ~0x03)];/* 1: MLME 2: NDIS control 3: NDIS data */ + u8 TxCountInBuffer[((MAX_USB_TX_DESCRIPTOR + 3) & ~0x03)]; - u8 TxFillIndex;//the next index of TxBuffer can be used - u8 TxDesIndex;//The next index of TxDes can be used - u8 ScanTxPause; //data Tx pause because the scanning is progressing, but probe request Tx won't. - u8 TxPause;//For pause the Mds_Tx modult + u8 TxFillIndex; /* the next index of TxBuffer can be used */ + u8 TxDesIndex; /* The next index of TxDes can be used */ + u8 ScanTxPause; /* data Tx pause because the scanning is progressing, but probe request Tx won't. */ + u8 TxPause; /*For pause the Mds_Tx modult */ - atomic_t TxThreadCount;//For thread counting 931130.4.v -//950301 delete due to HW -// atomic_t TxConcurrentCount;//931130.4.w + atomic_t TxThreadCount; /* For thread counting */ - u16 TxResult[ ((MAX_USB_TX_DESCRIPTOR + 1) & ~0x01) ];//Collect the sending result of Mpdu + u16 TxResult[((MAX_USB_TX_DESCRIPTOR + 1) & ~0x01)];/* Collect the sending result of Mpdu */ - u8 MicRedundant[8]; // For tmp use - u8 *MicWriteAddress[2]; //The start address to fill the Mic, use 2 point due to Mic maybe fragment + u8 MicRedundant[8]; /* For tmp use */ + u8 *MicWriteAddress[2]; /* The start address to fill the Mic, use 2 point due to Mic maybe fragment */ - u16 MicWriteSize[2]; //931130.4.x + u16 MicWriteSize[2]; - u16 MicAdd; // If want to add the Mic, this variable equal to 8 - u16 MicWriteIndex;//The number of MicWriteAddress 931130.4.y + u16 MicAdd; /* If want to add the Mic, this variable equal to 8 */ + u16 MicWriteIndex; /* The number of MicWriteAddress */ - u8 TxRate[ ((MAX_USB_TX_DESCRIPTOR+1)&~0x01) ][2]; // [0] current tx rate, [1] fall back rate - u8 TxInfo[ ((MAX_USB_TX_DESCRIPTOR+1)&~0x01) ]; //Store information for callback function + u8 TxRate[((MAX_USB_TX_DESCRIPTOR + 1) & ~0x01)][2]; /* [0] current tx rate, [1] fall back rate */ + u8 TxInfo[((MAX_USB_TX_DESCRIPTOR + 1) & ~0x01)]; /*Store information for callback function */ - //WKCHEN added for scanning mechanism - u8 TxToggle; //It is TRUE if there are tx activities in some time interval + /* for scanning mechanism */ + u8 TxToggle; /* It is TRUE if there are tx activities in some time interval */ u8 Reserved_[3]; - //---------- for Tx Parameter - u16 TxFragmentThreshold; // For frame body only + /* ---- for Tx Parameter */ + u16 TxFragmentThreshold; /* For frame body only */ u16 TxRTSThreshold; - u32 MaxReceiveTime;//911220.3 Add - - // depend on OS, - u32 MulticastListNo; - u32 PacketFilter; // Setting by NDIS, the current packet filter in use. - u8 MulticastAddressesArray[DEFAULT_MULTICASTLISTMAX][MAC_ADDR_LENGTH]; + u32 MaxReceiveTime; - //COUNTERMEASURE - u8 bMICfailCount; - u8 boCounterMeasureBlock; - u8 reserved_4[2]; + /* depend on OS, */ + u32 MulticastListNo; + u32 PacketFilter; /* Setting by NDIS, the current packet filter in use. */ + u8 MulticastAddressesArray[DEFAULT_MULTICASTLISTMAX][MAC_ADDR_LENGTH]; - u32 TxTsc; // 20060214 - u32 TxTsc_2; // 20060214 + /* COUNTERMEASURE */ + u8 bMICfailCount; + u8 boCounterMeasureBlock; + u8 reserved_4[2]; + u32 TxTsc; + u32 TxTsc_2; }; #endif diff --git a/drivers/staging/winbond/mlme_s.h b/drivers/staging/winbond/mlme_s.h index 1217a1c025e5..a7ef3c78022e 100644 --- a/drivers/staging/winbond/mlme_s.h +++ b/drivers/staging/winbond/mlme_s.h @@ -7,28 +7,29 @@ #include "mac_structures.h" #include "mds_s.h" -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// Mlme.h -// Define the related definitions of MLME module -// history -- 01/14/03' created -// -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -#define AUTH_REJECT_REASON_CHALLENGE_FAIL 1 - -//====== the state of MLME module -#define INACTIVE 0x0 -#define IDLE_SCAN 0x1 - -//====== the state of MLME/ESS module -#define STATE_1 0x2 -#define AUTH_REQ 0x3 -#define AUTH_WEP 0x4 -#define STATE_2 0x5 -#define ASSOC_REQ 0x6 -#define STATE_3 0x7 - -//====== the state of MLME/IBSS module +/* + * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + * Mlme.h + * Define the related definitions of MLME module + * + * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + */ + +#define AUTH_REJECT_REASON_CHALLENGE_FAIL 1 + +/* the state of MLME module */ +#define INACTIVE 0x0 +#define IDLE_SCAN 0x1 + +/* the state of MLME/ESS module */ +#define STATE_1 0x2 +#define AUTH_REQ 0x3 +#define AUTH_WEP 0x4 +#define STATE_2 0x5 +#define ASSOC_REQ 0x6 +#define STATE_3 0x7 + +/* the state of MLME/IBSS module */ #define IBSS_JOIN_SYNC 0x8 #define IBSS_AUTH_REQ 0x9 #define IBSS_AUTH_CHANLGE 0xa @@ -38,159 +39,150 @@ -//========================================= -//depend on D5C(MAC timing control 03 register): MaxTxMSDULifeTime default 0x80000us -#define AUTH_FAIL_TIMEOUT 550 -#define ASSOC_FAIL_TIMEOUT 550 +/* + * ========================================= + * depend on D5C(MAC timing control 03 register): + * MaxTxMSDULifeTime default 0x80000us + */ +#define AUTH_FAIL_TIMEOUT 550 +#define ASSOC_FAIL_TIMEOUT 550 #define REASSOC_FAIL_TIMEOUT 550 - - -// -// MLME task global CONSTANTS, STRUCTURE, variables -// - - -///////////////////////////////////////////////////////////// -// enum_ResultCode -- -// Result code returned from MLME to SME. -// -///////////////////////////////////////////////////////////// -// PD43 20030829 Modifiled -//#define SUCCESS 0 -#define MLME_SUCCESS 0 //follow spec. -#define INVALID_PARAMETERS 1 //Not following spec. -#define NOT_SUPPPORTED 2 -#define TIMEOUT 3 -#define TOO_MANY_SIMULTANEOUS_REQUESTS 4 -#define REFUSED 5 -#define BSS_ALREADY_STARTED_OR_JOINED 6 -#define TRANSMIT_FRAME_FAIL 7 -#define NO_BSS_FOUND 8 -#define RETRY 9 -#define GIVE_UP 10 - - -#define OPEN_AUTH 0 -#define SHARE_AUTH 1 -#define ANY_AUTH 2 -#define WPA_AUTH 3 //for WPA -#define WPAPSK_AUTH 4 -#define WPANONE_AUTH 5 -///////////////////////////////////////////// added by ws 04/19/04 +/* MLME task global CONSTANTS, STRUCTURE, variables */ + +/* ========================================= + * enum_ResultCode -- + * Result code returned from MLME to SME. + * ========================================= + */ +#define MLME_SUCCESS 0 /* follow spec. */ +#define INVALID_PARAMETERS 1 /* Not following spec. */ +#define NOT_SUPPPORTED 2 +#define TIMEOUT 3 +#define TOO_MANY_SIMULTANEOUS_REQUESTS 4 +#define REFUSED 5 +#define BSS_ALREADY_STARTED_OR_JOINED 6 +#define TRANSMIT_FRAME_FAIL 7 +#define NO_BSS_FOUND 8 +#define RETRY 9 +#define GIVE_UP 10 + + +#define OPEN_AUTH 0 +#define SHARE_AUTH 1 +#define ANY_AUTH 2 +#define WPA_AUTH 3 /* for WPA */ +#define WPAPSK_AUTH 4 +#define WPANONE_AUTH 5 #ifdef _WPA2_ -#define WPA2_AUTH 6//for WPA2 -#define WPA2PSK_AUTH 7 -#endif //end def _WPA2_ - -////////////////////////////////////////////////////////////////// -//define the msg type of MLME module -////////////////////////////////////////////////////////////////// -//-------------------------------------------------------- -//from SME - -#define MLMEMSG_AUTH_REQ 0x0b -#define MLMEMSG_DEAUTH_REQ 0x0c -#define MLMEMSG_ASSOC_REQ 0x0d -#define MLMEMSG_REASSOC_REQ 0x0e -#define MLMEMSG_DISASSOC_REQ 0x0f -#define MLMEMSG_START_IBSS_REQ 0x10 -#define MLMEMSG_IBSS_NET_CFM 0x11 - -//from RX : -#define MLMEMSG_RCV_MLMEFRAME 0x20 -#define MLMEMSG_RCV_ASSOCRSP 0x22 -#define MLMEMSG_RCV_REASSOCRSP 0x24 -#define MLMEMSG_RCV_DISASSOC 0x2b -#define MLMEMSG_RCV_AUTH 0x2c -#define MLMEMSG_RCV_DEAUTH 0x2d - - -//from TX callback -#define MLMEMSG_TX_CALLBACK 0x40 -#define MLMEMSG_ASSOCREQ_CALLBACK 0x41 -#define MLMEMSG_REASSOCREQ_CALLBACK 0x43 -#define MLMEMSG_DISASSOC_CALLBACK 0x4a -#define MLMEMSG_AUTH_CALLBACK 0x4c -#define MLMEMSG_DEAUTH_CALLBACK 0x4d - -//#define MLMEMSG_JOIN_FAIL 4 -//#define MLMEMSG_AUTHEN_FAIL 18 -#define MLMEMSG_TIMEOUT 0x50 - -/////////////////////////////////////////////////////////////////////////// -//Global data structures -#define MAX_NUM_TX_MMPDU 2 -#define MAX_MMPDU_SIZE 1512 -#define MAX_NUM_RX_MMPDU 6 - - -/////////////////////////////////////////////////////////////////////////// -//MACRO -#define boMLME_InactiveState(_AA_) (_AA_->wState==INACTIVE) -#define boMLME_IdleScanState(_BB_) (_BB_->wState==IDLE_SCAN) -#define boMLME_FoundSTAinfo(_CC_) (_CC_->wState>=IDLE_SCAN) - -typedef struct _MLME_FRAME -{ - //NDIS_PACKET MLME_Packet; - s8 * pMMPDU; - u16 len; - u8 DataType; - u8 IsInUsed; +#define WPA2_AUTH 6 /* for WPA2 */ +#define WPA2PSK_AUTH 7 +#endif /* end def _WPA2_ */ + +/* + * ========================================= + * define the msg type of MLME module + * ========================================= + */ + +/* from SME */ +#define MLMEMSG_AUTH_REQ 0x0b +#define MLMEMSG_DEAUTH_REQ 0x0c +#define MLMEMSG_ASSOC_REQ 0x0d +#define MLMEMSG_REASSOC_REQ 0x0e +#define MLMEMSG_DISASSOC_REQ 0x0f +#define MLMEMSG_START_IBSS_REQ 0x10 +#define MLMEMSG_IBSS_NET_CFM 0x11 + +/* from RX */ +#define MLMEMSG_RCV_MLMEFRAME 0x20 +#define MLMEMSG_RCV_ASSOCRSP 0x22 +#define MLMEMSG_RCV_REASSOCRSP 0x24 +#define MLMEMSG_RCV_DISASSOC 0x2b +#define MLMEMSG_RCV_AUTH 0x2c +#define MLMEMSG_RCV_DEAUTH 0x2d + + +/* from TX callback */ +#define MLMEMSG_TX_CALLBACK 0x40 +#define MLMEMSG_ASSOCREQ_CALLBACK 0x41 +#define MLMEMSG_REASSOCREQ_CALLBACK 0x43 +#define MLMEMSG_DISASSOC_CALLBACK 0x4a +#define MLMEMSG_AUTH_CALLBACK 0x4c +#define MLMEMSG_DEAUTH_CALLBACK 0x4d + +#define MLMEMSG_TIMEOUT 0x50 + +/* + * ============================================== + * Global data structures + * ============================================== + */ +#define MAX_NUM_TX_MMPDU 2 +#define MAX_MMPDU_SIZE 1512 +#define MAX_NUM_RX_MMPDU 6 + + +/* + * ============================================== + * MACRO + * ============================================== + */ +#define boMLME_InactiveState(_AA_) (_AA_->wState == INACTIVE) +#define boMLME_IdleScanState(_BB_) (_BB_->wState == IDLE_SCAN) +#define boMLME_FoundSTAinfo(_CC_) (_CC_->wState >= IDLE_SCAN) + +typedef struct _MLME_FRAME { + s8 *pMMPDU; + u16 len; + u8 DataType; + u8 IsInUsed; spinlock_t MLMESpinLock; - u8 TxMMPDU[MAX_NUM_TX_MMPDU][MAX_MMPDU_SIZE]; - u8 TxMMPDUInUse[ (MAX_NUM_TX_MMPDU+3) & ~0x03 ]; + u8 TxMMPDU[MAX_NUM_TX_MMPDU][MAX_MMPDU_SIZE]; + u8 TxMMPDUInUse[(MAX_NUM_TX_MMPDU + 3) & ~0x03]; u16 wNumTxMMPDU; u16 wNumTxMMPDUDiscarded; - u8 RxMMPDU[MAX_NUM_RX_MMPDU][MAX_MMPDU_SIZE]; - u8 SaveRxBufSlotInUse[ (MAX_NUM_RX_MMPDU+3) & ~0x03 ]; + u8 RxMMPDU[MAX_NUM_RX_MMPDU][MAX_MMPDU_SIZE]; + u8 SaveRxBufSlotInUse[(MAX_NUM_RX_MMPDU + 3) & ~0x03]; u16 wNumRxMMPDU; u16 wNumRxMMPDUDiscarded; - u16 wNumRxMMPDUInMLME; // Number of the Rx MMPDU - u16 reserved_1; // in MLME. - // excluding the discarded + u16 wNumRxMMPDUInMLME; /* Number of the Rx MMPDU */ + u16 reserved_1; /* in MLME. */ + /* excluding the discarded */ } MLME_FRAME, *psMLME_FRAME; typedef struct _AUTHREQ { - u8 peerMACaddr[MAC_ADDR_LENGTH]; - u16 wAuthAlgorithm; - + u8 peerMACaddr[MAC_ADDR_LENGTH]; + u16 wAuthAlgorithm; } MLME_AUTHREQ_PARA, *psMLME_AUTHREQ_PARA; typedef struct _ASSOCREQ { - u8 PeerSTAAddr[MAC_ADDR_LENGTH]; - u16 CapabilityInfo; - u16 ListenInterval; - -}__attribute__ ((packed)) MLME_ASSOCREQ_PARA, *psMLME_ASSOCREQ_PARA; + u8 PeerSTAAddr[MAC_ADDR_LENGTH]; + u16 CapabilityInfo; + u16 ListenInterval; +} __attribute__ ((packed)) MLME_ASSOCREQ_PARA, *psMLME_ASSOCREQ_PARA; typedef struct _REASSOCREQ { - u8 NewAPAddr[MAC_ADDR_LENGTH]; - u16 CapabilityInfo; - u16 ListenInterval; - -}__attribute__ ((packed)) MLME_REASSOCREQ_PARA, *psMLME_REASSOCREQ_PARA; + u8 NewAPAddr[MAC_ADDR_LENGTH]; + u16 CapabilityInfo; + u16 ListenInterval; +} __attribute__ ((packed)) MLME_REASSOCREQ_PARA, *psMLME_REASSOCREQ_PARA; typedef struct _MLMECALLBACK { - - u8 *psFramePtr; - u8 bResult; - + u8 *psFramePtr; + u8 bResult; } MLME_TXCALLBACK, *psMLME_TXCALLBACK; -typedef struct _RXDATA -{ +typedef struct _RXDATA { s32 FrameLength; - u8 __attribute__ ((packed)) *pbFramePtr; - -}__attribute__ ((packed)) RXDATA, *psRXDATA; + u8 __attribute__ ((packed)) *pbFramePtr; +} __attribute__ ((packed)) RXDATA, *psRXDATA; #endif diff --git a/drivers/staging/winbond/mlmetxrx.c b/drivers/staging/winbond/mlmetxrx.c index f856b94a7810..dcd8a11b5d03 100644 --- a/drivers/staging/winbond/mlmetxrx.c +++ b/drivers/staging/winbond/mlmetxrx.c @@ -1,26 +1,26 @@ -//============================================================================ -// Module Name: -// MLMETxRx.C -// -// Description: -// The interface between MDS (MAC Data Service) and MLME. -// -// Revision History: -// -------------------------------------------------------------------------- -// 200209 UN20 Jennifer Xu -// Initial Release -// 20021108 PD43 Austin Liu -// 20030117 PD43 Austin Liu -// Deleted MLMEReturnPacket and MLMEProcThread() -// -// Copyright (c) 1996-2002 Winbond Electronics Corp. All Rights Reserved. -//============================================================================ +/* ============================================================================ + Module Name: + MLMETxRx.C + + Description: + The interface between MDS (MAC Data Service) and MLME. + + Revision History: + -------------------------------------------------------------------------- + 200209 UN20 Jennifer Xu + Initial Release + 20021108 PD43 Austin Liu + 20030117 PD43 Austin Liu + Deleted MLMEReturnPacket and MLMEProcThread() + + Copyright (c) 1996-2002 Winbond Electronics Corp. All Rights Reserved. +============================================================================ */ #include "sysdef.h" #include "mds_f.h" -//============================================================================= -u8 MLMESendFrame(struct wbsoft_priv * adapter, u8 *pMMPDU, u16 len, u8 DataType) +/* ============================================================================= */ +u8 MLMESendFrame(struct wbsoft_priv *adapter, u8 *pMMPDU, u16 len, u8 DataType) /* DataType : FRAME_TYPE_802_11_MANAGEMENT, FRAME_TYPE_802_11_MANAGEMENT_CHALLENGE, FRAME_TYPE_802_11_DATA */ { @@ -30,17 +30,17 @@ u8 MLMESendFrame(struct wbsoft_priv * adapter, u8 *pMMPDU, u16 len, u8 DataType) } adapter->sMlmeFrame.IsInUsed = PACKET_COME_FROM_MLME; - // Keep information for sending + /* Keep information for sending */ adapter->sMlmeFrame.pMMPDU = pMMPDU; adapter->sMlmeFrame.DataType = DataType; - // len must be the last setting due to QUERY_SIZE_SECOND of Mds + /* len must be the last setting due to QUERY_SIZE_SECOND of Mds */ adapter->sMlmeFrame.len = len; adapter->sMlmeFrame.wNumTxMMPDU++; - // H/W will enter power save by set the register. S/W don't send null frame - //with PWRMgt bit enbled to enter power save now. + /* H/W will enter power save by set the register. S/W don't send null frame + with PWRMgt bit enbled to enter power save now. */ - // Transmit NDIS packet + /* Transmit NDIS packet */ Mds_Tx(adapter); return true; } @@ -60,7 +60,7 @@ static void MLMEfreeMMPDUBuffer(struct wbsoft_priv *adapter, s8 *pData) { int i; - // Reclaim the data buffer + /* Reclaim the data buffer */ for (i = 0; i < MAX_NUM_TX_MMPDU; i++) { if (pData == (s8 *)&(adapter->sMlmeFrame.TxMMPDU[i])) break; @@ -68,24 +68,24 @@ static void MLMEfreeMMPDUBuffer(struct wbsoft_priv *adapter, s8 *pData) if (adapter->sMlmeFrame.TxMMPDUInUse[i]) adapter->sMlmeFrame.TxMMPDUInUse[i] = false; else { - // Something wrong - // PD43 Add debug code here??? + /* Something wrong + PD43 Add debug code here??? */ } } void -MLME_SendComplete(struct wbsoft_priv * adapter, u8 PacketID, unsigned char SendOK) +MLME_SendComplete(struct wbsoft_priv *adapter, u8 PacketID, unsigned char SendOK) { MLME_TXCALLBACK TxCallback; - // Reclaim the data buffer + /* Reclaim the data buffer */ adapter->sMlmeFrame.len = 0; - MLMEfreeMMPDUBuffer( adapter, adapter->sMlmeFrame.pMMPDU ); + MLMEfreeMMPDUBuffer(adapter, adapter->sMlmeFrame.pMMPDU); TxCallback.bResult = MLME_SUCCESS; - // Return resource + /* Return resource */ adapter->sMlmeFrame.IsInUsed = PACKET_FREE_TO_USE; } diff --git a/drivers/staging/winbond/mlmetxrx_f.h b/drivers/staging/winbond/mlmetxrx_f.h index 6c04e3e03e31..d1aa2617d24b 100644 --- a/drivers/staging/winbond/mlmetxrx_f.h +++ b/drivers/staging/winbond/mlmetxrx_f.h @@ -1,10 +1,10 @@ -//================================================================ +/* ================================================================ // MLMETxRx.H -- // // Functions defined in MLMETxRx.c. // // Copyright (c) 2002 Winbond Electrics Corp. All Rights Reserved. -//================================================================ +//================================================================ */ #ifndef _MLMETXRX_H #define _MLMETXRX_H @@ -12,7 +12,7 @@ void MLME_GetNextPacket(struct wbsoft_priv *adapter, struct wb35_descriptor *pDes); u8 MLMESendFrame(struct wbsoft_priv *adapter, - u8 * pMMPDU, u16 len, u8 DataType); + u8 *pMMPDU, u16 len, u8 DataType); void MLME_SendComplete(struct wbsoft_priv *adapter, u8 PacketID, diff --git a/drivers/staging/winbond/mto.c b/drivers/staging/winbond/mto.c index 5e7fa1cd0aea..9cd212783d61 100644 --- a/drivers/staging/winbond/mto.c +++ b/drivers/staging/winbond/mto.c @@ -1,222 +1,181 @@ -//============================================================================ -// MTO.C - -// -// Description: -// MAC Throughput Optimization for W89C33 802.11g WLAN STA. -// -// The following MIB attributes or internal variables will be affected -// while the MTO is being executed: -// dot11FragmentationThreshold, -// dot11RTSThreshold, -// transmission rate and PLCP preamble type, -// CCA mode, -// antenna diversity. -// -// Revision history: -// -------------------------------------------------------------------------- -// 20031227 UN20 Pete Chao -// First draft -// 20031229 Turbo copy from PD43 -// 20040210 Kevin revised -// Copyright (c) 2003 Winbond Electronics Corp. All rights reserved. -//============================================================================ - -// LA20040210_DTO kevin +/* + * ============================================================================ + * MTO.C - + * + * Description: + * MAC Throughput Optimization for W89C33 802.11g WLAN STA. + * + * The following MIB attributes or internal variables will be affected + * while the MTO is being executed: + * dot11FragmentationThreshold, + * dot11RTSThreshold, + * transmission rate and PLCP preamble type, + * CCA mode, + * antenna diversity. + * + * Copyright (c) 2003 Winbond Electronics Corp. All rights reserved. + * ============================================================================ + */ + #include "sysdef.h" #include "sme_api.h" #include "wbhal_f.h" -// Declare SQ3 to rate and fragmentation threshold table -// Declare fragmentation thresholds table -#define MTO_MAX_FRAG_TH_LEVELS 5 -#define MTO_MAX_DATA_RATE_LEVELS 12 +/* Declare SQ3 to rate and fragmentation threshold table */ +/* Declare fragmentation thresholds table */ +#define MTO_MAX_FRAG_TH_LEVELS 5 +#define MTO_MAX_DATA_RATE_LEVELS 12 -u16 MTO_Frag_Th_Tbl[MTO_MAX_FRAG_TH_LEVELS] = -{ - 256, 384, 512, 768, 1536 +u16 MTO_Frag_Th_Tbl[MTO_MAX_FRAG_TH_LEVELS] = { + 256, 384, 512, 768, 1536 }; -// Declare data rate table -//The following table will be changed at anytime if the opration rate supported by AP don't -//match the table +/* + * Declare data rate table: + * The following table will be changed at anytime if the opration rate + * supported by AP don't match the table + */ static u8 MTO_Data_Rate_Tbl[MTO_MAX_DATA_RATE_LEVELS] = { - 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 + 2, 4, 11, 22, 12, 18, 24, 36, 48, 72, 96, 108 }; -static int TotalTxPkt = 0; -static int TotalTxPktRetry = 0; -static int retryrate_rec[MTO_MAX_DATA_RATE_LEVELS];//this record the retry rate at different data rate +static int TotalTxPkt; +static int TotalTxPktRetry; +/* this record the retry rate at different data rate */ +static int retryrate_rec[MTO_MAX_DATA_RATE_LEVELS]; -static int PeriodTotalTxPkt = 0; -static int PeriodTotalTxPktRetry = 0; +static int PeriodTotalTxPkt; +static int PeriodTotalTxPktRetry; -static u8 boSparseTxTraffic = false; +static u8 boSparseTxTraffic; void MTO_Init(struct wbsoft_priv *adapter); void TxRateReductionCtrl(struct wbsoft_priv *adapter); -/** 1.1.31.1000 Turbo modify */ void MTO_SetTxCount(struct wbsoft_priv *adapter, u8 t0, u8 index); void MTO_TxFailed(struct wbsoft_priv *adapter); void hal_get_dto_para(struct wbsoft_priv *adapter, char *buffer); -//=========================================================================== -// MTO_Init -- -// -// Description: -// Initialize MTO parameters. -// -// This function should be invoked during system initialization. -// -// Arguments: -// adapter - The pointer to the Miniport adapter Context -// -// Return Value: -// None -//============================================================================ +/* + * =========================================================================== + * MTO_Init -- + * + * Description: + * Initialize MTO parameters. + * + * This function should be invoked during system initialization. + * + * Arguments: + * adapter - The pointer to the Miniport adapter Context + * =========================================================================== + */ void MTO_Init(struct wbsoft_priv *adapter) { - int i; - - //[WKCHEN]MTO_CCA_MODE_SETUP()= (u8) hal_get_cca_mode(MTO_HAL()); - //[WKCHEN]MTO_CCA_MODE() = MTO_CCA_MODE_SETUP(); - - //MTO_PREAMBLE_TYPE() = MTO_PREAMBLE_LONG; - MTO_PREAMBLE_TYPE() = MTO_PREAMBLE_SHORT; // for test - - MTO_CNT_ANT(0) = 0; - MTO_CNT_ANT(1) = 0; - MTO_SQ_ANT(0) = 0; - MTO_SQ_ANT(1) = 0; - - MTO_AGING_TIMEOUT() = 0; - - // The following parameters should be initialized to the values set by user - // - //MTO_RATE_LEVEL() = 10; - MTO_RATE_LEVEL() = 0; - MTO_FRAG_TH_LEVEL() = 4; - /** 1.1.23.1000 Turbo modify from -1 to +1 - MTO_RTS_THRESHOLD() = MTO_FRAG_TH() - 1; - MTO_RTS_THRESHOLD_SETUP() = MTO_FRAG_TH() - 1; - */ - MTO_RTS_THRESHOLD() = MTO_FRAG_TH() + 1; - MTO_RTS_THRESHOLD_SETUP() = MTO_FRAG_TH() + 1; - // 1.1.23.1000 Turbo add for mto change preamble from 0 to 1 - MTO_RATE_CHANGE_ENABLE() = 1; - MTO_FRAG_CHANGE_ENABLE() = 0; // 1.1.29.1000 Turbo add don't support frag - //The default valud of ANTDIV_DEFAULT_ON will be decided by EEPROM - //#ifdef ANTDIV_DEFAULT_ON - //#else - //#endif - MTO_POWER_CHANGE_ENABLE() = 1; - MTO_PREAMBLE_CHANGE_ENABLE()= 1; - MTO_RTS_CHANGE_ENABLE() = 0; // 1.1.29.1000 Turbo add don't support frag - // 20040512 Turbo add - //old_antenna[0] = 1; - //old_antenna[1] = 0; - //old_antenna[2] = 1; - //old_antenna[3] = 0; - for (i=0;i<MTO_MAX_DATA_RATE_LEVELS;i++) - retryrate_rec[i]=5; + int i; + + MTO_PREAMBLE_TYPE() = MTO_PREAMBLE_SHORT; /* for test */ + + MTO_CNT_ANT(0) = 0; + MTO_CNT_ANT(1) = 0; + MTO_SQ_ANT(0) = 0; + MTO_SQ_ANT(1) = 0; + + MTO_AGING_TIMEOUT() = 0; + + /* The following parameters should be initialized to the values set by user */ + MTO_RATE_LEVEL() = 0; + MTO_FRAG_TH_LEVEL() = 4; + MTO_RTS_THRESHOLD() = MTO_FRAG_TH() + 1; + MTO_RTS_THRESHOLD_SETUP() = MTO_FRAG_TH() + 1; + MTO_RATE_CHANGE_ENABLE() = 1; + MTO_FRAG_CHANGE_ENABLE() = 0; + MTO_POWER_CHANGE_ENABLE() = 1; + MTO_PREAMBLE_CHANGE_ENABLE() = 1; + MTO_RTS_CHANGE_ENABLE() = 0; + + for (i = 0; i < MTO_MAX_DATA_RATE_LEVELS; i++) + retryrate_rec[i] = 5; MTO_TXFLOWCOUNT() = 0; - //--------- DTO threshold parameters ------------- - //MTOPARA_PERIODIC_CHECK_CYCLE() = 50; - MTOPARA_PERIODIC_CHECK_CYCLE() = 10; - MTOPARA_RSSI_TH_FOR_ANTDIV() = 10; - MTOPARA_TXCOUNT_TH_FOR_CALC_RATE() = 50; - MTOPARA_TXRATE_INC_TH() = 10; - MTOPARA_TXRATE_DEC_TH() = 30; - MTOPARA_TXRATE_EQ_TH() = 40; - MTOPARA_TXRATE_BACKOFF() = 12; - MTOPARA_TXRETRYRATE_REDUCE() = 6; - if ( MTO_TXPOWER_FROM_EEPROM == 0xff) - { - switch( MTO_HAL()->phy_type) - { - case RF_AIROHA_2230: - case RF_AIROHA_2230S: // 20060420 Add this - MTOPARA_TXPOWER_INDEX() = 46; // MAX-8 // @@ Only for AL 2230 - break; - case RF_AIROHA_7230: - MTOPARA_TXPOWER_INDEX() = 49; - break; - case RF_WB_242: - MTOPARA_TXPOWER_INDEX() = 10; - break; - case RF_WB_242_1: - MTOPARA_TXPOWER_INDEX() = 24; // ->10 20060316.1 modify - break; + /* --------- DTO threshold parameters ------------- */ + MTOPARA_PERIODIC_CHECK_CYCLE() = 10; + MTOPARA_RSSI_TH_FOR_ANTDIV() = 10; + MTOPARA_TXCOUNT_TH_FOR_CALC_RATE() = 50; + MTOPARA_TXRATE_INC_TH() = 10; + MTOPARA_TXRATE_DEC_TH() = 30; + MTOPARA_TXRATE_EQ_TH() = 40; + MTOPARA_TXRATE_BACKOFF() = 12; + MTOPARA_TXRETRYRATE_REDUCE() = 6; + if (MTO_TXPOWER_FROM_EEPROM == 0xff) { + switch (MTO_HAL()->phy_type) { + case RF_AIROHA_2230: + case RF_AIROHA_2230S: + MTOPARA_TXPOWER_INDEX() = 46; /* MAX-8 @@ Only for AL 2230 */ + break; + case RF_AIROHA_7230: + MTOPARA_TXPOWER_INDEX() = 49; + break; + case RF_WB_242: + MTOPARA_TXPOWER_INDEX() = 10; + break; + case RF_WB_242_1: + MTOPARA_TXPOWER_INDEX() = 24; + break; } - } - else //follow the setting from EEPROM + } else { /* follow the setting from EEPROM */ MTOPARA_TXPOWER_INDEX() = MTO_TXPOWER_FROM_EEPROM; - RFSynthesizer_SetPowerIndex(MTO_HAL(), (u8)MTOPARA_TXPOWER_INDEX()); - //------------------------------------------------ + } + RFSynthesizer_SetPowerIndex(MTO_HAL(), (u8) MTOPARA_TXPOWER_INDEX()); + /* ------------------------------------------------ */ - // For RSSI turning 20060808.4 Cancel load from EEPROM + /* For RSSI turning -- Cancel load from EEPROM */ MTO_DATA().RSSI_high = -41; MTO_DATA().RSSI_low = -60; } -//=========================================================================== -// Description: -// If we enable DTO, we will ignore the tx count with different tx rate from -// DTO rate. This is because when we adjust DTO tx rate, there could be some -// packets in the tx queue with previous tx rate +/* =========================================================================== + * Description: + * If we enable DTO, we will ignore the tx count with different tx rate + * from DTO rate. This is because when we adjust DTO tx rate, there could + * be some packets in the tx queue with previous tx rate + */ + void MTO_SetTxCount(struct wbsoft_priv *adapter, u8 tx_rate, u8 index) { MTO_TXFLOWCOUNT()++; - if ((MTO_ENABLE==1) && (MTO_RATE_CHANGE_ENABLE()==1)) - { - if(tx_rate == MTO_DATA_RATE()) - { - if (index == 0) - { + if ((MTO_ENABLE == 1) && (MTO_RATE_CHANGE_ENABLE() == 1)) { + if (tx_rate == MTO_DATA_RATE()) { + if (index == 0) { if (boSparseTxTraffic) MTO_HAL()->dto_tx_frag_count += MTOPARA_PERIODIC_CHECK_CYCLE(); else MTO_HAL()->dto_tx_frag_count += 1; - } - else - { - if (index<8) - { + } else { + if (index < 8) { MTO_HAL()->dto_tx_retry_count += index; - MTO_HAL()->dto_tx_frag_count += (index+1); - } - else - { + MTO_HAL()->dto_tx_frag_count += (index + 1); + } else { MTO_HAL()->dto_tx_retry_count += 7; MTO_HAL()->dto_tx_frag_count += 7; } } - } - else if(MTO_DATA_RATE()>48 && tx_rate ==48) - {//ALFRED - if (index<3) //for reduciing data rate scheme , - //do not calcu different data rate - //3 is the reducing data rate at retry - { + } else if (MTO_DATA_RATE() > 48 && tx_rate == 48) { + /* for reducing data rate scheme, do not calculate different data rate. 3 is the reducing data rate at retry. */ + if (index < 3) { MTO_HAL()->dto_tx_retry_count += index; - MTO_HAL()->dto_tx_frag_count += (index+1); - } - else - { + MTO_HAL()->dto_tx_frag_count += (index + 1); + } else { MTO_HAL()->dto_tx_retry_count += 3; MTO_HAL()->dto_tx_frag_count += 3; } } - } - else - { + } else { MTO_HAL()->dto_tx_retry_count += index; - MTO_HAL()->dto_tx_frag_count += (index+1); + MTO_HAL()->dto_tx_frag_count += (index + 1); } - TotalTxPkt ++; - TotalTxPktRetry += (index+1); + TotalTxPkt++; + TotalTxPktRetry += (index + 1); - PeriodTotalTxPkt ++; - PeriodTotalTxPktRetry += (index+1); + PeriodTotalTxPkt++; + PeriodTotalTxPktRetry += (index + 1); } diff --git a/drivers/staging/winbond/mto.h b/drivers/staging/winbond/mto.h index fb4781d5781b..a0f659cf99ff 100644 --- a/drivers/staging/winbond/mto.h +++ b/drivers/staging/winbond/mto.h @@ -1,13 +1,10 @@ -//================================================================== -// MTO.H -// -// Revision history -//================================= -// 20030110 UN20 Pete Chao -// Initial Release -// -// Copyright (c) 2003 Winbond Electronics Corp. All rights reserved. -//================================================================== +/* + * ================================================================== + * MTO.H + * + * Copyright (c) 2003 Winbond Electronics Corp. All rights reserved. + * ================================================================== + */ #ifndef __MTO_H__ #define __MTO_H__ @@ -15,115 +12,104 @@ struct wbsoft_priv; -// LA20040210_DTO kevin -//#define MTO_PREAMBLE_LONG 0 -//#define MTO_PREAMBLE_SHORT 1 #define MTO_PREAMBLE_LONG WLAN_PREAMBLE_TYPE_LONG #define MTO_PREAMBLE_SHORT WLAN_PREAMBLE_TYPE_SHORT -//============================================================================ -// struct _MTOParameters -- -// -// Defines the parameters used in the MAC Throughput Optimization algorithm -//============================================================================ +/* Defines the parameters used in the MAC Throughput Optimization algorithm */ struct wb35_mto_params { - //--------- wkchen added ------------- - u32 TxFlowCount; //to judge what kind the tx flow(sparse or busy) is - //------------------------------------------------ + u32 TxFlowCount; /* to judge what kind the tx flow(sparse or busy) is */ - //--------- DTO threshold parameters ------------- - u16 DTO_PeriodicCheckCycle; - u16 DTO_RssiThForAntDiv; + /* --------- DTO threshold parameters ------------- */ + u16 DTO_PeriodicCheckCycle; + u16 DTO_RssiThForAntDiv; - u16 DTO_TxCountThForCalcNewRate; - u16 DTO_TxRateIncTh; + u16 DTO_TxCountThForCalcNewRate; + u16 DTO_TxRateIncTh; - u16 DTO_TxRateDecTh; - u16 DTO_TxRateEqTh; + u16 DTO_TxRateDecTh; + u16 DTO_TxRateEqTh; - u16 DTO_TxRateBackOff; - u16 DTO_TxRetryRateReduce; + u16 DTO_TxRateBackOff; + u16 DTO_TxRetryRateReduce; - u16 DTO_TxPowerIndex; //0 ~ 31 - u16 reserved_1; - //------------------------------------------------ + u16 DTO_TxPowerIndex; /* 0 ~ 31 */ + u16 reserved_1; + /* ------------------------------------------------ */ - u8 PowerChangeEnable; - u8 AntDiversityEnable; - u8 CCA_Mode; - u8 CCA_Mode_Setup; - u8 Preamble_Type; - u8 PreambleChangeEnable; + u8 PowerChangeEnable; + u8 AntDiversityEnable; + u8 CCA_Mode; + u8 CCA_Mode_Setup; + u8 Preamble_Type; + u8 PreambleChangeEnable; - u8 DataRateLevel; - u8 DataRateChangeEnable; - u8 FragThresholdLevel; - u8 FragThresholdChangeEnable; + u8 DataRateLevel; + u8 DataRateChangeEnable; + u8 FragThresholdLevel; + u8 FragThresholdChangeEnable; - u16 RTSThreshold; - u16 RTSThreshold_Setup; + u16 RTSThreshold; + u16 RTSThreshold_Setup; - u32 AvgIdleSlot; - u32 Pr_Interf; - u32 AvgGapBtwnInterf; + u32 AvgIdleSlot; + u32 Pr_Interf; + u32 AvgGapBtwnInterf; - u8 RTSChangeEnable; - u8 Ant_sel; - u8 aging_timeout; - u8 reserved_2; + u8 RTSChangeEnable; + u8 Ant_sel; + u8 aging_timeout; + u8 reserved_2; - u32 Cnt_Ant[2]; - u32 SQ_Ant[2]; + u32 Cnt_Ant[2]; + u32 SQ_Ant[2]; -// 20040510 remove from globe vairable - u8 FallbackRateLevel; - u8 OfdmRateLevel; + u8 FallbackRateLevel; + u8 OfdmRateLevel; - u8 RatePolicy; - u8 reserved_3[3]; - - // For RSSI turning - s32 RSSI_high; - s32 RSSI_low; + u8 RatePolicy; + u8 reserved_3[3]; + /* For RSSI turning */ + s32 RSSI_high; + s32 RSSI_low; }; -#define MTO_DATA() (adapter->sMtoPara) -#define MTO_HAL() (&adapter->sHwData) -#define MTO_SET_PREAMBLE_TYPE(x) // 20040511 Turbo mark LM_PREAMBLE_TYPE(&pcore_data->lm_data) = (x) -#define MTO_ENABLE (adapter->sLocalPara.TxRateMode == RATE_AUTO) -#define MTO_TXPOWER_FROM_EEPROM (adapter->sHwData.PowerIndexFromEEPROM) -#define LOCAL_ANTENNA_NO() (adapter->sLocalPara.bAntennaNo) -#define LOCAL_IS_CONNECTED() (adapter->sLocalPara.wConnectedSTAindex != 0) -#define MTO_INITTXRATE_MODE (adapter->sHwData.SoftwareSet&0x2) //bit 1 +#define MTO_DATA() (adapter->sMtoPara) +#define MTO_HAL() (&adapter->sHwData) +#define MTO_SET_PREAMBLE_TYPE(x) /* Turbo mark LM_PREAMBLE_TYPE(&pcore_data->lm_data) = (x) */ +#define MTO_ENABLE (adapter->sLocalPara.TxRateMode == RATE_AUTO) +#define MTO_TXPOWER_FROM_EEPROM (adapter->sHwData.PowerIndexFromEEPROM) +#define LOCAL_ANTENNA_NO() (adapter->sLocalPara.bAntennaNo) +#define LOCAL_IS_CONNECTED() (adapter->sLocalPara.wConnectedSTAindex != 0) +#define MTO_INITTXRATE_MODE (adapter->sHwData.SoftwareSet&0x2) /* bit 1 */ -#define MTO_POWER_CHANGE_ENABLE() MTO_DATA().PowerChangeEnable -#define MTO_CCA_MODE() MTO_DATA().CCA_Mode -#define MTO_CCA_MODE_SETUP() MTO_DATA().CCA_Mode_Setup -#define MTO_PREAMBLE_TYPE() MTO_DATA().Preamble_Type -#define MTO_PREAMBLE_CHANGE_ENABLE() MTO_DATA().PreambleChangeEnable +#define MTO_POWER_CHANGE_ENABLE() MTO_DATA().PowerChangeEnable +#define MTO_CCA_MODE() MTO_DATA().CCA_Mode +#define MTO_CCA_MODE_SETUP() MTO_DATA().CCA_Mode_Setup +#define MTO_PREAMBLE_TYPE() MTO_DATA().Preamble_Type +#define MTO_PREAMBLE_CHANGE_ENABLE() MTO_DATA().PreambleChangeEnable -#define MTO_RATE_LEVEL() MTO_DATA().DataRateLevel +#define MTO_RATE_LEVEL() MTO_DATA().DataRateLevel #define MTO_OFDM_RATE_LEVEL() MTO_DATA().OfdmRateLevel -#define MTO_RATE_CHANGE_ENABLE() MTO_DATA().DataRateChangeEnable -#define MTO_FRAG_TH_LEVEL() MTO_DATA().FragThresholdLevel -#define MTO_FRAG_CHANGE_ENABLE() MTO_DATA().FragThresholdChangeEnable -#define MTO_RTS_THRESHOLD() MTO_DATA().RTSThreshold -#define MTO_RTS_CHANGE_ENABLE() MTO_DATA().RTSChangeEnable -#define MTO_RTS_THRESHOLD_SETUP() MTO_DATA().RTSThreshold_Setup +#define MTO_RATE_CHANGE_ENABLE() MTO_DATA().DataRateChangeEnable +#define MTO_FRAG_TH_LEVEL() MTO_DATA().FragThresholdLevel +#define MTO_FRAG_CHANGE_ENABLE() MTO_DATA().FragThresholdChangeEnable +#define MTO_RTS_THRESHOLD() MTO_DATA().RTSThreshold +#define MTO_RTS_CHANGE_ENABLE() MTO_DATA().RTSChangeEnable +#define MTO_RTS_THRESHOLD_SETUP() MTO_DATA().RTSThreshold_Setup -#define MTO_AVG_IDLE_SLOT() MTO_DATA().AvgIdleSlot -#define MTO_PR_INTERF() MTO_DATA().Pr_Interf -#define MTO_AVG_GAP_BTWN_INTERF() MTO_DATA().AvgGapBtwnInterf +#define MTO_AVG_IDLE_SLOT() MTO_DATA().AvgIdleSlot +#define MTO_PR_INTERF() MTO_DATA().Pr_Interf +#define MTO_AVG_GAP_BTWN_INTERF() MTO_DATA().AvgGapBtwnInterf -#define MTO_CNT_ANT(x) MTO_DATA().Cnt_Ant[(x)] -#define MTO_SQ_ANT(x) MTO_DATA().SQ_Ant[(x)] -#define MTO_AGING_TIMEOUT() MTO_DATA().aging_timeout +#define MTO_CNT_ANT(x) MTO_DATA().Cnt_Ant[(x)] +#define MTO_SQ_ANT(x) MTO_DATA().SQ_Ant[(x)] +#define MTO_AGING_TIMEOUT() MTO_DATA().aging_timeout +#define MTO_TXFLOWCOUNT() MTO_DATA().TxFlowCount -#define MTO_TXFLOWCOUNT() MTO_DATA().TxFlowCount -//--------- DTO threshold parameters ------------- +/* --------- DTO threshold parameters ------------- */ #define MTOPARA_PERIODIC_CHECK_CYCLE() MTO_DATA().DTO_PeriodicCheckCycle #define MTOPARA_RSSI_TH_FOR_ANTDIV() MTO_DATA().DTO_RssiThForAntDiv #define MTOPARA_TXCOUNT_TH_FOR_CALC_RATE() MTO_DATA().DTO_TxCountThForCalcNewRate @@ -133,13 +119,13 @@ struct wb35_mto_params { #define MTOPARA_TXRATE_BACKOFF() MTO_DATA().DTO_TxRateBackOff #define MTOPARA_TXRETRYRATE_REDUCE() MTO_DATA().DTO_TxRetryRateReduce #define MTOPARA_TXPOWER_INDEX() MTO_DATA().DTO_TxPowerIndex -//------------------------------------------------ +/* ------------------------------------------------ */ -extern u16 MTO_Frag_Th_Tbl[]; +extern u16 MTO_Frag_Th_Tbl[]; -#define MTO_DATA_RATE() MTO_Data_Rate_Tbl[MTO_RATE_LEVEL()] -#define MTO_FRAG_TH() MTO_Frag_Th_Tbl[MTO_FRAG_TH_LEVEL()] +#define MTO_DATA_RATE() MTO_Data_Rate_Tbl[MTO_RATE_LEVEL()] +#define MTO_FRAG_TH() MTO_Frag_Th_Tbl[MTO_FRAG_TH_LEVEL()] extern void MTO_Init(struct wbsoft_priv *); extern void MTO_PeriodicTimerExpired(struct wbsoft_priv *); @@ -148,6 +134,5 @@ extern u8 MTO_GetTxRate(struct wbsoft_priv *adapter, u32 fpdu_len); extern u8 MTO_GetTxFallbackRate(struct wbsoft_priv *adapter); extern void MTO_SetTxCount(struct wbsoft_priv *adapter, u8 t0, u8 index); -#endif //__MTO_H__ - +#endif /* __MTO_H__ */ diff --git a/drivers/staging/winbond/phy_calibration.c b/drivers/staging/winbond/phy_calibration.c index 8c56962ab80c..78935865df19 100644 --- a/drivers/staging/winbond/phy_calibration.c +++ b/drivers/staging/winbond/phy_calibration.c @@ -25,10 +25,7 @@ #define FIXED(X) ((s32)((X) * 32768.0)) #define DEG2RAD(X) 0.017453 * (X) -/****************** LOCAL TYPE DEFINITION SECTION ***************************/ -typedef s32 fixed; /* 16.16 fixed-point */ - -static const fixed Angles[]= +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)), @@ -300,7 +297,7 @@ u32 _sqrt(u32 sqsum) /****************************************************************************/ void _sin_cos(s32 angle, s32 *sin, s32 *cos) { - fixed X, Y, TargetAngle, CurrAngle; + s32 X, Y, TargetAngle, CurrAngle; unsigned Step; X=FIXED(AG_CONST); // AG_CONST * cos(0) @@ -310,7 +307,7 @@ void _sin_cos(s32 angle, s32 *sin, s32 *cos) for (Step=0; Step < 12; Step++) { - fixed NewX; + s32 NewX; if(TargetAngle > CurrAngle) { diff --git a/drivers/staging/winbond/phy_calibration.h b/drivers/staging/winbond/phy_calibration.h index 51c8fde81e2b..303203148839 100644 --- a/drivers/staging/winbond/phy_calibration.h +++ b/drivers/staging/winbond/phy_calibration.h @@ -3,105 +3,82 @@ #include "wbhal_f.h" -// 20031229 Turbo add -#define REG_AGC_CTRL1 0x1000 -#define REG_AGC_CTRL2 0x1004 -#define REG_AGC_CTRL3 0x1008 -#define REG_AGC_CTRL4 0x100C -#define REG_AGC_CTRL5 0x1010 -#define REG_AGC_CTRL6 0x1014 -#define REG_AGC_CTRL7 0x1018 -#define REG_AGC_CTRL8 0x101C -#define REG_AGC_CTRL9 0x1020 -#define REG_AGC_CTRL10 0x1024 -#define REG_CCA_CTRL 0x1028 -#define REG_A_ACQ_CTRL 0x102C -#define REG_B_ACQ_CTRL 0x1030 -#define REG_A_TXRX_CTRL 0x1034 -#define REG_B_TXRX_CTRL 0x1038 -#define REG_A_TX_COEF3 0x103C -#define REG_A_TX_COEF2 0x1040 -#define REG_A_TX_COEF1 0x1044 -#define REG_B_TX_COEF2 0x1048 -#define REG_B_TX_COEF1 0x104C -#define REG_MODE_CTRL 0x1050 -#define REG_CALIB_DATA 0x1054 -#define REG_IQ_ALPHA 0x1058 -#define REG_DC_CANCEL 0x105C -#define REG_WTO_READ 0x1060 -#define REG_OFFSET_READ 0x1064 -#define REG_CALIB_READ1 0x1068 -#define REG_CALIB_READ2 0x106C -#define REG_A_FREQ_EST 0x1070 - - - - -// 20031101 Turbo add -#define MASK_AMER_OFF_REG BIT(31) - -#define MASK_BMER_OFF_REG BIT(31) - -#define MASK_LNA_FIX_GAIN (BIT(3)|BIT(4)) -#define MASK_AGC_FIX BIT(1) - -#define MASK_AGC_FIX_GAIN 0xFF00 - -#define MASK_ADC_DC_CAL_STR BIT(10) -#define MASK_CALIB_START BIT(4) -#define MASK_IQCAL_TONE_SEL (BIT(3)|BIT(2)) -#define MASK_IQCAL_MODE (BIT(1)|BIT(0)) - -#define MASK_TX_CAL_0 0xF0000000 -#define TX_CAL_0_SHIFT 28 -#define MASK_TX_CAL_1 0x0F000000 -#define TX_CAL_1_SHIFT 24 -#define MASK_TX_CAL_2 0x00F00000 -#define TX_CAL_2_SHIFT 20 -#define MASK_TX_CAL_3 0x000F0000 -#define TX_CAL_3_SHIFT 16 -#define MASK_RX_CAL_0 0x0000F000 -#define RX_CAL_0_SHIFT 12 -#define MASK_RX_CAL_1 0x00000F00 -#define RX_CAL_1_SHIFT 8 -#define MASK_RX_CAL_2 0x000000F0 -#define RX_CAL_2_SHIFT 4 -#define MASK_RX_CAL_3 0x0000000F -#define RX_CAL_3_SHIFT 0 - -#define MASK_CANCEL_DC_I 0x3E0 -#define CANCEL_DC_I_SHIFT 5 -#define MASK_CANCEL_DC_Q 0x01F -#define CANCEL_DC_Q_SHIFT 0 - -// LA20040210 kevin -//#define MASK_ADC_DC_CAL_I(x) (((x)&0x1FE00)>>9) -//#define MASK_ADC_DC_CAL_Q(x) ((x)&0x1FF) -#define MASK_ADC_DC_CAL_I(x) (((x)&0x0003FE00)>>9) -#define MASK_ADC_DC_CAL_Q(x) ((x)&0x000001FF) - -// LA20040210 kevin (Turbo has wrong definition) -//#define MASK_IQCAL_TONE_I 0x7FFC000 -//#define SHIFT_IQCAL_TONE_I(x) ((x)>>13) -//#define MASK_IQCAL_TONE_Q 0x1FFF -//#define SHIFT_IQCAL_TONE_Q(x) ((x)>>0) -#define MASK_IQCAL_TONE_I 0x00001FFF -#define SHIFT_IQCAL_TONE_I(x) ((x)>>0) -#define MASK_IQCAL_TONE_Q 0x03FFE000 -#define SHIFT_IQCAL_TONE_Q(x) ((x)>>13) - -// LA20040210 kevin (Turbo has wrong definition) -//#define MASK_IQCAL_IMAGE_I 0x7FFC000 -//#define SHIFT_IQCAL_IMAGE_I(x) ((x)>>13) -//#define MASK_IQCAL_IMAGE_Q 0x1FFF -//#define SHIFT_IQCAL_IMAGE_Q(x) ((x)>>0) - -//#define MASK_IQCAL_IMAGE_I 0x00001FFF -//#define SHIFT_IQCAL_IMAGE_I(x) ((x)>>0) -//#define MASK_IQCAL_IMAGE_Q 0x03FFE000 -//#define SHIFT_IQCAL_IMAGE_Q(x) ((x)>>13) - -void phy_set_rf_data( struct hw_data * pHwData, u32 index, u32 value ); -#define phy_init_rf( _A ) //RFSynthesizer_initial( _A ) +#define REG_AGC_CTRL1 0x1000 +#define REG_AGC_CTRL2 0x1004 +#define REG_AGC_CTRL3 0x1008 +#define REG_AGC_CTRL4 0x100C +#define REG_AGC_CTRL5 0x1010 +#define REG_AGC_CTRL6 0x1014 +#define REG_AGC_CTRL7 0x1018 +#define REG_AGC_CTRL8 0x101C +#define REG_AGC_CTRL9 0x1020 +#define REG_AGC_CTRL10 0x1024 +#define REG_CCA_CTRL 0x1028 +#define REG_A_ACQ_CTRL 0x102C +#define REG_B_ACQ_CTRL 0x1030 +#define REG_A_TXRX_CTRL 0x1034 +#define REG_B_TXRX_CTRL 0x1038 +#define REG_A_TX_COEF3 0x103C +#define REG_A_TX_COEF2 0x1040 +#define REG_A_TX_COEF1 0x1044 +#define REG_B_TX_COEF2 0x1048 +#define REG_B_TX_COEF1 0x104C +#define REG_MODE_CTRL 0x1050 +#define REG_CALIB_DATA 0x1054 +#define REG_IQ_ALPHA 0x1058 +#define REG_DC_CANCEL 0x105C +#define REG_WTO_READ 0x1060 +#define REG_OFFSET_READ 0x1064 +#define REG_CALIB_READ1 0x1068 +#define REG_CALIB_READ2 0x106C +#define REG_A_FREQ_EST 0x1070 + + +#define MASK_AMER_OFF_REG BIT(31) + +#define MASK_BMER_OFF_REG BIT(31) + +#define MASK_LNA_FIX_GAIN (BIT(3) | BIT(4)) +#define MASK_AGC_FIX BIT(1) + +#define MASK_AGC_FIX_GAIN 0xFF00 + +#define MASK_ADC_DC_CAL_STR BIT(10) +#define MASK_CALIB_START BIT(4) +#define MASK_IQCAL_TONE_SEL (BIT(3) | BIT(2)) +#define MASK_IQCAL_MODE (BIT(1) | BIT(0)) + +#define MASK_TX_CAL_0 0xF0000000 +#define TX_CAL_0_SHIFT 28 +#define MASK_TX_CAL_1 0x0F000000 +#define TX_CAL_1_SHIFT 24 +#define MASK_TX_CAL_2 0x00F00000 +#define TX_CAL_2_SHIFT 20 +#define MASK_TX_CAL_3 0x000F0000 +#define TX_CAL_3_SHIFT 16 +#define MASK_RX_CAL_0 0x0000F000 +#define RX_CAL_0_SHIFT 12 +#define MASK_RX_CAL_1 0x00000F00 +#define RX_CAL_1_SHIFT 8 +#define MASK_RX_CAL_2 0x000000F0 +#define RX_CAL_2_SHIFT 4 +#define MASK_RX_CAL_3 0x0000000F +#define RX_CAL_3_SHIFT 0 + +#define MASK_CANCEL_DC_I 0x3E0 +#define CANCEL_DC_I_SHIFT 5 +#define MASK_CANCEL_DC_Q 0x01F +#define CANCEL_DC_Q_SHIFT 0 + +#define MASK_ADC_DC_CAL_I(x) (((x) & 0x0003FE00) >> 9) +#define MASK_ADC_DC_CAL_Q(x) ((x) & 0x000001FF) + +#define MASK_IQCAL_TONE_I 0x00001FFF +#define SHIFT_IQCAL_TONE_I(x) ((x) >> 0) +#define MASK_IQCAL_TONE_Q 0x03FFE000 +#define SHIFT_IQCAL_TONE_Q(x) ((x) >> 13) + +void phy_set_rf_data(struct hw_data *pHwData, u32 index, u32 value); +#define phy_init_rf(_A) /* RFSynthesizer_initial(_A) */ #endif diff --git a/drivers/staging/winbond/reg.c b/drivers/staging/winbond/reg.c index 5f5048af26a5..d9a8128b21f0 100644 --- a/drivers/staging/winbond/reg.c +++ b/drivers/staging/winbond/reg.c @@ -1,514 +1,452 @@ #include "sysdef.h" #include "wbhal_f.h" -/////////////////////////////////////////////////////////////////////////////////////////////////// -// Original Phy.h -//***************************************************************************** - -/***************************************************************************** -; For MAXIM2825/6/7 Ver. 331 or more -; Edited by Tiger, Sep-17-2003 -; revised by Ben, Sep-18-2003 - -0x00 0x000a2 -0x01 0x21cc0 -;0x02 0x13802 -0x02 0x1383a - -;channe1 01 ; 0x03 0x30142 ; 0x04 0x0b333; -;channe1 02 ;0x03 0x32141 ;0x04 0x08444; -;channe1 03 ;0x03 0x32143 ;0x04 0x0aeee; -;channe1 04 ;0x03 0x32142 ;0x04 0x0b333; -;channe1 05 ;0x03 0x31141 ;0x04 0x08444; -;channe1 06 ; -0x03 0x31143; -0x04 0x0aeee; -;channe1 07 ;0x03 0x31142 ;0x04 0x0b333; -;channe1 08 ;0x03 0x33141 ;0x04 0x08444; -;channe1 09 ;0x03 0x33143 ;0x04 0x0aeee; -;channe1 10 ;0x03 0x33142 ;0x04 0x0b333; -;channe1 11 ;0x03 0x30941 ;0x04 0x08444; -;channe1 12 ;0x03 0x30943 ;0x04 0x0aeee; -;channe1 13 ;0x03 0x30942 ;0x04 0x0b333; - -0x05 0x28986 -0x06 0x18008 -0x07 0x38400 -0x08 0x05100; 100 Hz DC -;0x08 0x05900; 30 KHz DC -0x09 0x24f08 -0x0a 0x17e00, 0x17ea0 -0x0b 0x37d80 -0x0c 0x0c900 // 0x0ca00 (lager power 9db than 0x0c000), 0x0c000 -*****************************************************************************/ -// MAX2825 (pure b/g) -u32 max2825_rf_data[] = -{ - (0x00<<18)|0x000a2, - (0x01<<18)|0x21cc0, - (0x02<<18)|0x13806, - (0x03<<18)|0x30142, - (0x04<<18)|0x0b333, - (0x05<<18)|0x289A6, - (0x06<<18)|0x18008, - (0x07<<18)|0x38000, - (0x08<<18)|0x05100, - (0x09<<18)|0x24f08, - (0x0A<<18)|0x14000, - (0x0B<<18)|0x37d80, - (0x0C<<18)|0x0c100 // 11a: 0x0c300, 11g: 0x0c100 -}; +/* + * ==================================================== + * Original Phy.h + * ==================================================== + */ -u32 max2825_channel_data_24[][3] = -{ - {(0x03<<18)|0x30142, (0x04<<18)|0x0b333, (0x05<<18)|0x289A6}, // channe1 01 - {(0x03<<18)|0x32141, (0x04<<18)|0x08444, (0x05<<18)|0x289A6}, // channe1 02 - {(0x03<<18)|0x32143, (0x04<<18)|0x0aeee, (0x05<<18)|0x289A6}, // channe1 03 - {(0x03<<18)|0x32142, (0x04<<18)|0x0b333, (0x05<<18)|0x289A6}, // channe1 04 - {(0x03<<18)|0x31141, (0x04<<18)|0x08444, (0x05<<18)|0x289A6}, // channe1 05 - {(0x03<<18)|0x31143, (0x04<<18)|0x0aeee, (0x05<<18)|0x289A6}, // channe1 06 - {(0x03<<18)|0x31142, (0x04<<18)|0x0b333, (0x05<<18)|0x289A6}, // channe1 07 - {(0x03<<18)|0x33141, (0x04<<18)|0x08444, (0x05<<18)|0x289A6}, // channe1 08 - {(0x03<<18)|0x33143, (0x04<<18)|0x0aeee, (0x05<<18)|0x289A6}, // channe1 09 - {(0x03<<18)|0x33142, (0x04<<18)|0x0b333, (0x05<<18)|0x289A6}, // channe1 10 - {(0x03<<18)|0x30941, (0x04<<18)|0x08444, (0x05<<18)|0x289A6}, // channe1 11 - {(0x03<<18)|0x30943, (0x04<<18)|0x0aeee, (0x05<<18)|0x289A6}, // channe1 12 - {(0x03<<18)|0x30942, (0x04<<18)|0x0b333, (0x05<<18)|0x289A6}, // channe1 13 - {(0x03<<18)|0x32941, (0x04<<18)|0x09999, (0x05<<18)|0x289A6} // 14 (2484MHz) hhmodify +/* + * ==================================================== + * For MAXIM2825/6/7 Ver. 331 or more + * + * 0x00 0x000a2 + * 0x01 0x21cc0 + * 0x02 0x13802 + * 0x02 0x1383a + * + * channe1 01 ; 0x03 0x30142 ; 0x04 0x0b333; + * channe1 02 ; 0x03 0x32141 ; 0x04 0x08444; + * channe1 03 ; 0x03 0x32143 ; 0x04 0x0aeee; + * channe1 04 ; 0x03 0x32142 ; 0x04 0x0b333; + * channe1 05 ; 0x03 0x31141 ; 0x04 0x08444; + * channe1 06 ; 0x03 0x31143 ; 0x04 0x0aeee; + * channe1 07 ; 0x03 0x31142 ; 0x04 0x0b333; + * channe1 08 ; 0x03 0x33141 ; 0x04 0x08444; + * channe1 09 ; 0x03 0x33143 ; 0x04 0x0aeee; + * channe1 10 ; 0x03 0x33142 ; 0x04 0x0b333; + * channe1 11 ; 0x03 0x30941 ; 0x04 0x08444; + * channe1 12 ; 0x03 0x30943 ; 0x04 0x0aeee; + * channe1 13 ; 0x03 0x30942 ; 0x04 0x0b333; + * + * 0x05 0x28986 + * 0x06 0x18008 + * 0x07 0x38400 + * 0x08 0x05100; 100 Hz DC + * 0x08 0x05900; 30 KHz DC + * 0x09 0x24f08 + * 0x0a 0x17e00, 0x17ea0 + * 0x0b 0x37d80 + * 0x0c 0x0c900 -- 0x0ca00 (lager power 9db than 0x0c000), 0x0c000 + */ + +/* MAX2825 (pure b/g) */ +u32 max2825_rf_data[] = { + (0x00<<18) | 0x000a2, + (0x01<<18) | 0x21cc0, + (0x02<<18) | 0x13806, + (0x03<<18) | 0x30142, + (0x04<<18) | 0x0b333, + (0x05<<18) | 0x289A6, + (0x06<<18) | 0x18008, + (0x07<<18) | 0x38000, + (0x08<<18) | 0x05100, + (0x09<<18) | 0x24f08, + (0x0A<<18) | 0x14000, + (0x0B<<18) | 0x37d80, + (0x0C<<18) | 0x0c100 /* 11a: 0x0c300, 11g: 0x0c100 */ }; -u32 max2825_power_data_24[] = {(0x0C<<18)|0x0c000, (0x0C<<18)|0x0c100}; - -/****************************************************************************/ -// MAX2827 (a/b/g) -u32 max2827_rf_data[] = -{ - (0x00<<18)|0x000a2, - (0x01<<18)|0x21cc0, - (0x02<<18)|0x13806, - (0x03<<18)|0x30142, - (0x04<<18)|0x0b333, - (0x05<<18)|0x289A6, - (0x06<<18)|0x18008, - (0x07<<18)|0x38000, - (0x08<<18)|0x05100, - (0x09<<18)|0x24f08, - (0x0A<<18)|0x14000, - (0x0B<<18)|0x37d80, - (0x0C<<18)|0x0c100 // 11a: 0x0c300, 11g: 0x0c100 +u32 max2825_channel_data_24[][3] = { + {(0x03 << 18) | 0x30142, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x289A6}, /* channel 01 */ + {(0x03 << 18) | 0x32141, (0x04 << 18) | 0x08444, (0x05 << 18) | 0x289A6}, /* channel 02 */ + {(0x03 << 18) | 0x32143, (0x04 << 18) | 0x0aeee, (0x05 << 18) | 0x289A6}, /* channel 03 */ + {(0x03 << 18) | 0x32142, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x289A6}, /* channel 04 */ + {(0x03 << 18) | 0x31141, (0x04 << 18) | 0x08444, (0x05 << 18) | 0x289A6}, /* channel 05 */ + {(0x03 << 18) | 0x31143, (0x04 << 18) | 0x0aeee, (0x05 << 18) | 0x289A6}, /* channel 06 */ + {(0x03 << 18) | 0x31142, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x289A6}, /* channel 07 */ + {(0x03 << 18) | 0x33141, (0x04 << 18) | 0x08444, (0x05 << 18) | 0x289A6}, /* channel 08 */ + {(0x03 << 18) | 0x33143, (0x04 << 18) | 0x0aeee, (0x05 << 18) | 0x289A6}, /* channel 09 */ + {(0x03 << 18) | 0x33142, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x289A6}, /* channel 10 */ + {(0x03 << 18) | 0x30941, (0x04 << 18) | 0x08444, (0x05 << 18) | 0x289A6}, /* channel 11 */ + {(0x03 << 18) | 0x30943, (0x04 << 18) | 0x0aeee, (0x05 << 18) | 0x289A6}, /* channel 12 */ + {(0x03 << 18) | 0x30942, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x289A6}, /* channel 13 */ + {(0x03 << 18) | 0x32941, (0x04 << 18) | 0x09999, (0x05 << 18) | 0x289A6} /* channel 14 (2484MHz) */ }; -u32 max2827_channel_data_24[][3] = -{ - {(0x03<<18)|0x30142, (0x04<<18)|0x0b333, (0x05<<18)|0x289A6}, // channe1 01 - {(0x03<<18)|0x32141, (0x04<<18)|0x08444, (0x05<<18)|0x289A6}, // channe1 02 - {(0x03<<18)|0x32143, (0x04<<18)|0x0aeee, (0x05<<18)|0x289A6}, // channe1 03 - {(0x03<<18)|0x32142, (0x04<<18)|0x0b333, (0x05<<18)|0x289A6}, // channe1 04 - {(0x03<<18)|0x31141, (0x04<<18)|0x08444, (0x05<<18)|0x289A6}, // channe1 05 - {(0x03<<18)|0x31143, (0x04<<18)|0x0aeee, (0x05<<18)|0x289A6}, // channe1 06 - {(0x03<<18)|0x31142, (0x04<<18)|0x0b333, (0x05<<18)|0x289A6}, // channe1 07 - {(0x03<<18)|0x33141, (0x04<<18)|0x08444, (0x05<<18)|0x289A6}, // channe1 08 - {(0x03<<18)|0x33143, (0x04<<18)|0x0aeee, (0x05<<18)|0x289A6}, // channe1 09 - {(0x03<<18)|0x33142, (0x04<<18)|0x0b333, (0x05<<18)|0x289A6}, // channe1 10 - {(0x03<<18)|0x30941, (0x04<<18)|0x08444, (0x05<<18)|0x289A6}, // channe1 11 - {(0x03<<18)|0x30943, (0x04<<18)|0x0aeee, (0x05<<18)|0x289A6}, // channe1 12 - {(0x03<<18)|0x30942, (0x04<<18)|0x0b333, (0x05<<18)|0x289A6}, // channe1 13 - {(0x03<<18)|0x32941, (0x04<<18)|0x09999, (0x05<<18)|0x289A6} // 14 (2484MHz) hhmodify +u32 max2825_power_data_24[] = {(0x0C << 18) | 0x0c000, (0x0C << 18) | 0x0c100}; + +/* ========================================== */ +/* MAX2827 (a/b/g) */ +u32 max2827_rf_data[] = { + (0x00 << 18) | 0x000a2, + (0x01 << 18) | 0x21cc0, + (0x02 << 18) | 0x13806, + (0x03 << 18) | 0x30142, + (0x04 << 18) | 0x0b333, + (0x05 << 18) | 0x289A6, + (0x06 << 18) | 0x18008, + (0x07 << 18) | 0x38000, + (0x08 << 18) | 0x05100, + (0x09 << 18) | 0x24f08, + (0x0A << 18) | 0x14000, + (0x0B << 18) | 0x37d80, + (0x0C << 18) | 0x0c100 /* 11a: 0x0c300, 11g: 0x0c100 */ }; -u32 max2827_channel_data_50[][3] = -{ - {(0x03<<18)|0x33cc3, (0x04<<18)|0x08ccc, (0x05<<18)|0x2A9A6}, // channel 36 - {(0x03<<18)|0x302c0, (0x04<<18)|0x08000, (0x05<<18)|0x2A9A6}, // channel 40 - {(0x03<<18)|0x302c2, (0x04<<18)|0x0b333, (0x05<<18)|0x2A9A6}, // channel 44 - {(0x03<<18)|0x322c1, (0x04<<18)|0x09999, (0x05<<18)|0x2A9A6}, // channel 48 - {(0x03<<18)|0x312c1, (0x04<<18)|0x0a666, (0x05<<18)|0x2A9A6}, // channel 52 - {(0x03<<18)|0x332c3, (0x04<<18)|0x08ccc, (0x05<<18)|0x2A9A6}, // channel 56 - {(0x03<<18)|0x30ac0, (0x04<<18)|0x08000, (0x05<<18)|0x2A9A6}, // channel 60 - {(0x03<<18)|0x30ac2, (0x04<<18)|0x0b333, (0x05<<18)|0x2A9A6} // channel 64 +u32 max2827_channel_data_24[][3] = { + {(0x03 << 18) | 0x30142, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x289A6}, /* channe1 01 */ + {(0x03 << 18) | 0x32141, (0x04 << 18) | 0x08444, (0x05 << 18) | 0x289A6}, /* channe1 02 */ + {(0x03 << 18) | 0x32143, (0x04 << 18) | 0x0aeee, (0x05 << 18) | 0x289A6}, /* channe1 03 */ + {(0x03 << 18) | 0x32142, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x289A6}, /* channe1 04 */ + {(0x03 << 18) | 0x31141, (0x04 << 18) | 0x08444, (0x05 << 18) | 0x289A6}, /* channe1 05 */ + {(0x03 << 18) | 0x31143, (0x04 << 18) | 0x0aeee, (0x05 << 18) | 0x289A6}, /* channe1 06 */ + {(0x03 << 18) | 0x31142, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x289A6}, /* channe1 07 */ + {(0x03 << 18) | 0x33141, (0x04 << 18) | 0x08444, (0x05 << 18) | 0x289A6}, /* channe1 08 */ + {(0x03 << 18) | 0x33143, (0x04 << 18) | 0x0aeee, (0x05 << 18) | 0x289A6}, /* channe1 09 */ + {(0x03 << 18) | 0x33142, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x289A6}, /* channe1 10 */ + {(0x03 << 18) | 0x30941, (0x04 << 18) | 0x08444, (0x05 << 18) | 0x289A6}, /* channe1 11 */ + {(0x03 << 18) | 0x30943, (0x04 << 18) | 0x0aeee, (0x05 << 18) | 0x289A6}, /* channe1 12 */ + {(0x03 << 18) | 0x30942, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x289A6}, /* channe1 13 */ + {(0x03 << 18) | 0x32941, (0x04 << 18) | 0x09999, (0x05 << 18) | 0x289A6} /* channel 14 (2484MHz) */ }; -u32 max2827_power_data_24[] = {(0x0C<<18)|0x0C000, (0x0C<<18)|0x0D600, (0x0C<<18)|0x0C100}; -u32 max2827_power_data_50[] = {(0x0C<<18)|0x0C400, (0x0C<<18)|0x0D500, (0x0C<<18)|0x0C300}; - -/****************************************************************************/ -// MAX2828 (a/b/g) -u32 max2828_rf_data[] = -{ - (0x00<<18)|0x000a2, - (0x01<<18)|0x21cc0, - (0x02<<18)|0x13806, - (0x03<<18)|0x30142, - (0x04<<18)|0x0b333, - (0x05<<18)|0x289A6, - (0x06<<18)|0x18008, - (0x07<<18)|0x38000, - (0x08<<18)|0x05100, - (0x09<<18)|0x24f08, - (0x0A<<18)|0x14000, - (0x0B<<18)|0x37d80, - (0x0C<<18)|0x0c100 // 11a: 0x0c300, 11g: 0x0c100 +u32 max2827_channel_data_50[][3] = { + {(0x03 << 18) | 0x33cc3, (0x04 << 18) | 0x08ccc, (0x05 << 18) | 0x2A9A6}, /* channel 36 */ + {(0x03 << 18) | 0x302c0, (0x04 << 18) | 0x08000, (0x05 << 18) | 0x2A9A6}, /* channel 40 */ + {(0x03 << 18) | 0x302c2, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x2A9A6}, /* channel 44 */ + {(0x03 << 18) | 0x322c1, (0x04 << 18) | 0x09999, (0x05 << 18) | 0x2A9A6}, /* channel 48 */ + {(0x03 << 18) | 0x312c1, (0x04 << 18) | 0x0a666, (0x05 << 18) | 0x2A9A6}, /* channel 52 */ + {(0x03 << 18) | 0x332c3, (0x04 << 18) | 0x08ccc, (0x05 << 18) | 0x2A9A6}, /* channel 56 */ + {(0x03 << 18) | 0x30ac0, (0x04 << 18) | 0x08000, (0x05 << 18) | 0x2A9A6}, /* channel 60 */ + {(0x03 << 18) | 0x30ac2, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x2A9A6} /* channel 64 */ }; -u32 max2828_channel_data_24[][3] = -{ - {(0x03<<18)|0x30142, (0x04<<18)|0x0b333, (0x05<<18)|0x289A6}, // channe1 01 - {(0x03<<18)|0x32141, (0x04<<18)|0x08444, (0x05<<18)|0x289A6}, // channe1 02 - {(0x03<<18)|0x32143, (0x04<<18)|0x0aeee, (0x05<<18)|0x289A6}, // channe1 03 - {(0x03<<18)|0x32142, (0x04<<18)|0x0b333, (0x05<<18)|0x289A6}, // channe1 04 - {(0x03<<18)|0x31141, (0x04<<18)|0x08444, (0x05<<18)|0x289A6}, // channe1 05 - {(0x03<<18)|0x31143, (0x04<<18)|0x0aeee, (0x05<<18)|0x289A6}, // channe1 06 - {(0x03<<18)|0x31142, (0x04<<18)|0x0b333, (0x05<<18)|0x289A6}, // channe1 07 - {(0x03<<18)|0x33141, (0x04<<18)|0x08444, (0x05<<18)|0x289A6}, // channe1 08 - {(0x03<<18)|0x33143, (0x04<<18)|0x0aeee, (0x05<<18)|0x289A6}, // channe1 09 - {(0x03<<18)|0x33142, (0x04<<18)|0x0b333, (0x05<<18)|0x289A6}, // channe1 10 - {(0x03<<18)|0x30941, (0x04<<18)|0x08444, (0x05<<18)|0x289A6}, // channe1 11 - {(0x03<<18)|0x30943, (0x04<<18)|0x0aeee, (0x05<<18)|0x289A6}, // channe1 12 - {(0x03<<18)|0x30942, (0x04<<18)|0x0b333, (0x05<<18)|0x289A6}, // channe1 13 - {(0x03<<18)|0x32941, (0x04<<18)|0x09999, (0x05<<18)|0x289A6} // 14 (2484MHz) hhmodify +u32 max2827_power_data_24[] = {(0x0C << 18) | 0x0C000, (0x0C << 18) | 0x0D600, (0x0C << 18) | 0x0C100}; +u32 max2827_power_data_50[] = {(0x0C << 18) | 0x0C400, (0x0C << 18) | 0x0D500, (0x0C << 18) | 0x0C300}; + +/* ======================================================= */ +/* MAX2828 (a/b/g) */ +u32 max2828_rf_data[] = { + (0x00 << 18) | 0x000a2, + (0x01 << 18) | 0x21cc0, + (0x02 << 18) | 0x13806, + (0x03 << 18) | 0x30142, + (0x04 << 18) | 0x0b333, + (0x05 << 18) | 0x289A6, + (0x06 << 18) | 0x18008, + (0x07 << 18) | 0x38000, + (0x08 << 18) | 0x05100, + (0x09 << 18) | 0x24f08, + (0x0A << 18) | 0x14000, + (0x0B << 18) | 0x37d80, + (0x0C << 18) | 0x0c100 /* 11a: 0x0c300, 11g: 0x0c100 */ }; -u32 max2828_channel_data_50[][3] = -{ - {(0x03<<18)|0x33cc3, (0x04<<18)|0x08ccc, (0x05<<18)|0x289A6}, // channel 36 - {(0x03<<18)|0x302c0, (0x04<<18)|0x08000, (0x05<<18)|0x289A6}, // channel 40 - {(0x03<<18)|0x302c2, (0x04<<18)|0x0b333, (0x05<<18)|0x289A6}, // channel 44 - {(0x03<<18)|0x322c1, (0x04<<18)|0x09999, (0x05<<18)|0x289A6}, // channel 48 - {(0x03<<18)|0x312c1, (0x04<<18)|0x0a666, (0x05<<18)|0x289A6}, // channel 52 - {(0x03<<18)|0x332c3, (0x04<<18)|0x08ccc, (0x05<<18)|0x289A6}, // channel 56 - {(0x03<<18)|0x30ac0, (0x04<<18)|0x08000, (0x05<<18)|0x289A6}, // channel 60 - {(0x03<<18)|0x30ac2, (0x04<<18)|0x0b333, (0x05<<18)|0x289A6} // channel 64 +u32 max2828_channel_data_24[][3] = { + {(0x03 << 18) | 0x30142, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x289A6}, /* channe1 01 */ + {(0x03 << 18) | 0x32141, (0x04 << 18) | 0x08444, (0x05 << 18) | 0x289A6}, /* channe1 02 */ + {(0x03 << 18) | 0x32143, (0x04 << 18) | 0x0aeee, (0x05 << 18) | 0x289A6}, /* channe1 03 */ + {(0x03 << 18) | 0x32142, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x289A6}, /* channe1 04 */ + {(0x03 << 18) | 0x31141, (0x04 << 18) | 0x08444, (0x05 << 18) | 0x289A6}, /* channe1 05 */ + {(0x03 << 18) | 0x31143, (0x04 << 18) | 0x0aeee, (0x05 << 18) | 0x289A6}, /* channe1 06 */ + {(0x03 << 18) | 0x31142, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x289A6}, /* channe1 07 */ + {(0x03 << 18) | 0x33141, (0x04 << 18) | 0x08444, (0x05 << 18) | 0x289A6}, /* channe1 08 */ + {(0x03 << 18) | 0x33143, (0x04 << 18) | 0x0aeee, (0x05 << 18) | 0x289A6}, /* channe1 09 */ + {(0x03 << 18) | 0x33142, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x289A6}, /* channe1 10 */ + {(0x03 << 18) | 0x30941, (0x04 << 18) | 0x08444, (0x05 << 18) | 0x289A6}, /* channe1 11 */ + {(0x03 << 18) | 0x30943, (0x04 << 18) | 0x0aeee, (0x05 << 18) | 0x289A6}, /* channe1 12 */ + {(0x03 << 18) | 0x30942, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x289A6}, /* channe1 13 */ + {(0x03 << 18) | 0x32941, (0x04 << 18) | 0x09999, (0x05 << 18) | 0x289A6} /* channel 14 (2484MHz) */ }; -u32 max2828_power_data_24[] = {(0x0C<<18)|0x0c000, (0x0C<<18)|0x0c100}; -u32 max2828_power_data_50[] = {(0x0C<<18)|0x0c000, (0x0C<<18)|0x0c100}; - -/****************************************************************************/ -// LA20040728 kevin -// MAX2829 (a/b/g) -u32 max2829_rf_data[] = -{ - (0x00<<18)|0x000a2, - (0x01<<18)|0x23520, - (0x02<<18)|0x13802, - (0x03<<18)|0x30142, - (0x04<<18)|0x0b333, - (0x05<<18)|0x28906, - (0x06<<18)|0x18008, - (0x07<<18)|0x3B500, - (0x08<<18)|0x05100, - (0x09<<18)|0x24f08, - (0x0A<<18)|0x14000, - (0x0B<<18)|0x37d80, - (0x0C<<18)|0x0F300 //TXVGA=51, (MAX-6 dB) +u32 max2828_channel_data_50[][3] = { + {(0x03 << 18) | 0x33cc3, (0x04 << 18) | 0x08ccc, (0x05 << 18) | 0x289A6}, /* channel 36 */ + {(0x03 << 18) | 0x302c0, (0x04 << 18) | 0x08000, (0x05 << 18) | 0x289A6}, /* channel 40 */ + {(0x03 << 18) | 0x302c2, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x289A6}, /* channel 44 */ + {(0x03 << 18) | 0x322c1, (0x04 << 18) | 0x09999, (0x05 << 18) | 0x289A6}, /* channel 48 */ + {(0x03 << 18) | 0x312c1, (0x04 << 18) | 0x0a666, (0x05 << 18) | 0x289A6}, /* channel 52 */ + {(0x03 << 18) | 0x332c3, (0x04 << 18) | 0x08ccc, (0x05 << 18) | 0x289A6}, /* channel 56 */ + {(0x03 << 18) | 0x30ac0, (0x04 << 18) | 0x08000, (0x05 << 18) | 0x289A6}, /* channel 60 */ + {(0x03 << 18) | 0x30ac2, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x289A6} /* channel 64 */ }; -u32 max2829_channel_data_24[][3] = -{ - {(3<<18)|0x30142, (4<<18)|0x0b333, (5<<18)|0x289C6}, // 01 (2412MHz) - {(3<<18)|0x32141, (4<<18)|0x08444, (5<<18)|0x289C6}, // 02 (2417MHz) - {(3<<18)|0x32143, (4<<18)|0x0aeee, (5<<18)|0x289C6}, // 03 (2422MHz) - {(3<<18)|0x32142, (4<<18)|0x0b333, (5<<18)|0x289C6}, // 04 (2427MHz) - {(3<<18)|0x31141, (4<<18)|0x08444, (5<<18)|0x289C6}, // 05 (2432MHz) - {(3<<18)|0x31143, (4<<18)|0x0aeee, (5<<18)|0x289C6}, // 06 (2437MHz) - {(3<<18)|0x31142, (4<<18)|0x0b333, (5<<18)|0x289C6}, // 07 (2442MHz) - {(3<<18)|0x33141, (4<<18)|0x08444, (5<<18)|0x289C6}, // 08 (2447MHz) - {(3<<18)|0x33143, (4<<18)|0x0aeee, (5<<18)|0x289C6}, // 09 (2452MHz) - {(3<<18)|0x33142, (4<<18)|0x0b333, (5<<18)|0x289C6}, // 10 (2457MHz) - {(3<<18)|0x30941, (4<<18)|0x08444, (5<<18)|0x289C6}, // 11 (2462MHz) - {(3<<18)|0x30943, (4<<18)|0x0aeee, (5<<18)|0x289C6}, // 12 (2467MHz) - {(3<<18)|0x30942, (4<<18)|0x0b333, (5<<18)|0x289C6}, // 13 (2472MHz) - {(3<<18)|0x32941, (4<<18)|0x09999, (5<<18)|0x289C6}, // 14 (2484MHz) hh-modify +u32 max2828_power_data_24[] = {(0x0C << 18) | 0x0c000, (0x0C << 18) | 0x0c100}; +u32 max2828_power_data_50[] = {(0x0C << 18) | 0x0c000, (0x0C << 18) | 0x0c100}; + +/* ========================================================== */ +/* MAX2829 (a/b/g) */ +u32 max2829_rf_data[] = { + (0x00 << 18) | 0x000a2, + (0x01 << 18) | 0x23520, + (0x02 << 18) | 0x13802, + (0x03 << 18) | 0x30142, + (0x04 << 18) | 0x0b333, + (0x05 << 18) | 0x28906, + (0x06 << 18) | 0x18008, + (0x07 << 18) | 0x3B500, + (0x08 << 18) | 0x05100, + (0x09 << 18) | 0x24f08, + (0x0A << 18) | 0x14000, + (0x0B << 18) | 0x37d80, + (0x0C << 18) | 0x0F300 /* TXVGA=51, (MAX-6 dB) */ }; -u32 max2829_channel_data_50[][4] = -{ - {36, (3<<18)|0x33cc3, (4<<18)|0x08ccc, (5<<18)|0x2A946}, // 36 (5.180GHz) - {40, (3<<18)|0x302c0, (4<<18)|0x08000, (5<<18)|0x2A946}, // 40 (5.200GHz) - {44, (3<<18)|0x302c2, (4<<18)|0x0b333, (5<<18)|0x2A946}, // 44 (5.220GHz) - {48, (3<<18)|0x322c1, (4<<18)|0x09999, (5<<18)|0x2A946}, // 48 (5.240GHz) - {52, (3<<18)|0x312c1, (4<<18)|0x0a666, (5<<18)|0x2A946}, // 52 (5.260GHz) - {56, (3<<18)|0x332c3, (4<<18)|0x08ccc, (5<<18)|0x2A946}, // 56 (5.280GHz) - {60, (3<<18)|0x30ac0, (4<<18)|0x08000, (5<<18)|0x2A946}, // 60 (5.300GHz) - {64, (3<<18)|0x30ac2, (4<<18)|0x0b333, (5<<18)|0x2A946}, // 64 (5.320GHz) - - {100, (3<<18)|0x30ec0, (4<<18)|0x08000, (5<<18)|0x2A9C6}, // 100 (5.500GHz) - {104, (3<<18)|0x30ec2, (4<<18)|0x0b333, (5<<18)|0x2A9C6}, // 104 (5.520GHz) - {108, (3<<18)|0x32ec1, (4<<18)|0x09999, (5<<18)|0x2A9C6}, // 108 (5.540GHz) - {112, (3<<18)|0x31ec1, (4<<18)|0x0a666, (5<<18)|0x2A9C6}, // 112 (5.560GHz) - {116, (3<<18)|0x33ec3, (4<<18)|0x08ccc, (5<<18)|0x2A9C6}, // 116 (5.580GHz) - {120, (3<<18)|0x301c0, (4<<18)|0x08000, (5<<18)|0x2A9C6}, // 120 (5.600GHz) - {124, (3<<18)|0x301c2, (4<<18)|0x0b333, (5<<18)|0x2A9C6}, // 124 (5.620GHz) - {128, (3<<18)|0x321c1, (4<<18)|0x09999, (5<<18)|0x2A9C6}, // 128 (5.640GHz) - {132, (3<<18)|0x311c1, (4<<18)|0x0a666, (5<<18)|0x2A9C6}, // 132 (5.660GHz) - {136, (3<<18)|0x331c3, (4<<18)|0x08ccc, (5<<18)|0x2A9C6}, // 136 (5.680GHz) - {140, (3<<18)|0x309c0, (4<<18)|0x08000, (5<<18)|0x2A9C6}, // 140 (5.700GHz) - - {149, (3<<18)|0x329c2, (4<<18)|0x0b333, (5<<18)|0x2A9C6}, // 149 (5.745GHz) - {153, (3<<18)|0x319c1, (4<<18)|0x09999, (5<<18)|0x2A9C6}, // 153 (5.765GHz) - {157, (3<<18)|0x339c1, (4<<18)|0x0a666, (5<<18)|0x2A9C6}, // 157 (5.785GHz) - {161, (3<<18)|0x305c3, (4<<18)|0x08ccc, (5<<18)|0x2A9C6}, // 161 (5.805GHz) - - // Japan - { 184, (3<<18)|0x308c2, (4<<18)|0x0b333, (5<<18)|0x2A946}, // 184 (4.920GHz) - { 188, (3<<18)|0x328c1, (4<<18)|0x09999, (5<<18)|0x2A946}, // 188 (4.940GHz) - { 192, (3<<18)|0x318c1, (4<<18)|0x0a666, (5<<18)|0x2A946}, // 192 (4.960GHz) - { 196, (3<<18)|0x338c3, (4<<18)|0x08ccc, (5<<18)|0x2A946}, // 196 (4.980GHz) - { 8, (3<<18)|0x324c1, (4<<18)|0x09999, (5<<18)|0x2A946}, // 8 (5.040GHz) - { 12, (3<<18)|0x314c1, (4<<18)|0x0a666, (5<<18)|0x2A946}, // 12 (5.060GHz) - { 16, (3<<18)|0x334c3, (4<<18)|0x08ccc, (5<<18)|0x2A946}, // 16 (5.080GHz) - { 34, (3<<18)|0x31cc2, (4<<18)|0x0b333, (5<<18)|0x2A946}, // 34 (5.170GHz) - { 38, (3<<18)|0x33cc1, (4<<18)|0x09999, (5<<18)|0x2A946}, // 38 (5.190GHz) - { 42, (3<<18)|0x302c1, (4<<18)|0x0a666, (5<<18)|0x2A946}, // 42 (5.210GHz) - { 46, (3<<18)|0x322c3, (4<<18)|0x08ccc, (5<<18)|0x2A946}, // 46 (5.230GHz) +u32 max2829_channel_data_24[][3] = { + {(3 << 18) | 0x30142, (4 << 18) | 0x0b333, (5 << 18) | 0x289C6}, /* 01 (2412MHz) */ + {(3 << 18) | 0x32141, (4 << 18) | 0x08444, (5 << 18) | 0x289C6}, /* 02 (2417MHz) */ + {(3 << 18) | 0x32143, (4 << 18) | 0x0aeee, (5 << 18) | 0x289C6}, /* 03 (2422MHz) */ + {(3 << 18) | 0x32142, (4 << 18) | 0x0b333, (5 << 18) | 0x289C6}, /* 04 (2427MHz) */ + {(3 << 18) | 0x31141, (4 << 18) | 0x08444, (5 << 18) | 0x289C6}, /* 05 (2432MHz) */ + {(3 << 18) | 0x31143, (4 << 18) | 0x0aeee, (5 << 18) | 0x289C6}, /* 06 (2437MHz) */ + {(3 << 18) | 0x31142, (4 << 18) | 0x0b333, (5 << 18) | 0x289C6}, /* 07 (2442MHz) */ + {(3 << 18) | 0x33141, (4 << 18) | 0x08444, (5 << 18) | 0x289C6}, /* 08 (2447MHz) */ + {(3 << 18) | 0x33143, (4 << 18) | 0x0aeee, (5 << 18) | 0x289C6}, /* 09 (2452MHz) */ + {(3 << 18) | 0x33142, (4 << 18) | 0x0b333, (5 << 18) | 0x289C6}, /* 10 (2457MHz) */ + {(3 << 18) | 0x30941, (4 << 18) | 0x08444, (5 << 18) | 0x289C6}, /* 11 (2462MHz) */ + {(3 << 18) | 0x30943, (4 << 18) | 0x0aeee, (5 << 18) | 0x289C6}, /* 12 (2467MHz) */ + {(3 << 18) | 0x30942, (4 << 18) | 0x0b333, (5 << 18) | 0x289C6}, /* 13 (2472MHz) */ + {(3 << 18) | 0x32941, (4 << 18) | 0x09999, (5 << 18) | 0x289C6}, /* 14 (2484MHz) */ }; -/***************************************************************************** -; For MAXIM2825/6/7 Ver. 317 or less -; Edited by Tiger, Sep-17-2003 for 2.4Ghz channels -; Updated by Tiger, Sep-22-2003 for 5.0Ghz channels -; Corrected by Tiger, Sep-23-2003, for 0x03 and 0x04 of 5.0Ghz channels - -0x00 0x00080 -0x01 0x214c0 -0x02 0x13802 - -;2.4GHz Channels -;channe1 01 (2.412GHz); 0x03 0x30143 ;0x04 0x0accc -;channe1 02 (2.417GHz); 0x03 0x32140 ;0x04 0x09111 -;channe1 03 (2.422GHz); 0x03 0x32142 ;0x04 0x0bbbb -;channe1 04 (2.427GHz); 0x03 0x32143 ;0x04 0x0accc -;channe1 05 (2.432GHz); 0x03 0x31140 ;0x04 0x09111 -;channe1 06 (2.437GHz); 0x03 0x31142 ;0x04 0x0bbbb -;channe1 07 (2.442GHz); 0x03 0x31143 ;0x04 0x0accc -;channe1 08 (2.447GHz); 0x03 0x33140 ;0x04 0x09111 -;channe1 09 (2.452GHz); 0x03 0x33142 ;0x04 0x0bbbb -;channe1 10 (2.457GHz); 0x03 0x33143 ;0x04 0x0accc -;channe1 11 (2.462GHz); 0x03 0x30940 ;0x04 0x09111 -;channe1 12 (2.467GHz); 0x03 0x30942 ;0x04 0x0bbbb -;channe1 13 (2.472GHz); 0x03 0x30943 ;0x04 0x0accc - -;5.0Ghz Channels -;channel 36 (5.180GHz); 0x03 0x33cc0 ;0x04 0x0b333 -;channel 40 (5.200GHz); 0x03 0x302c0 ;0x04 0x08000 -;channel 44 (5.220GHz); 0x03 0x302c2 ;0x04 0x0b333 -;channel 48 (5.240GHz); 0x03 0x322c1 ;0x04 0x09999 -;channel 52 (5.260GHz); 0x03 0x312c1 ;0x04 0x0a666 -;channel 56 (5.280GHz); 0x03 0x332c3 ;0x04 0x08ccc -;channel 60 (5.300GHz); 0x03 0x30ac0 ;0x04 0x08000 -;channel 64 (5.320GHz); 0x03 0x30ac2 ;0x04 0x08333 - -;2.4GHz band ;0x05 0x28986; -;5.0GHz band -0x05 0x2a986 - -0x06 0x18008 -0x07 0x38400 -0x08 0x05108 -0x09 0x27ff8 -0x0a 0x14000 -0x0b 0x37f99 -0x0c 0x0c000 -*****************************************************************************/ -u32 maxim_317_rf_data[] = -{ - (0x00<<18)|0x000a2, - (0x01<<18)|0x214c0, - (0x02<<18)|0x13802, - (0x03<<18)|0x30143, - (0x04<<18)|0x0accc, - (0x05<<18)|0x28986, - (0x06<<18)|0x18008, - (0x07<<18)|0x38400, - (0x08<<18)|0x05108, - (0x09<<18)|0x27ff8, - (0x0A<<18)|0x14000, - (0x0B<<18)|0x37f99, - (0x0C<<18)|0x0c000 +u32 max2829_channel_data_50[][4] = { + {36, (3 << 18) | 0x33cc3, (4 << 18) | 0x08ccc, (5 << 18) | 0x2A946}, /* 36 (5.180GHz) */ + {40, (3 << 18) | 0x302c0, (4 << 18) | 0x08000, (5 << 18) | 0x2A946}, /* 40 (5.200GHz) */ + {44, (3 << 18) | 0x302c2, (4 << 18) | 0x0b333, (5 << 18) | 0x2A946}, /* 44 (5.220GHz) */ + {48, (3 << 18) | 0x322c1, (4 << 18) | 0x09999, (5 << 18) | 0x2A946}, /* 48 (5.240GHz) */ + {52, (3 << 18) | 0x312c1, (4 << 18) | 0x0a666, (5 << 18) | 0x2A946}, /* 52 (5.260GHz) */ + {56, (3 << 18) | 0x332c3, (4 << 18) | 0x08ccc, (5 << 18) | 0x2A946}, /* 56 (5.280GHz) */ + {60, (3 << 18) | 0x30ac0, (4 << 18) | 0x08000, (5 << 18) | 0x2A946}, /* 60 (5.300GHz) */ + {64, (3 << 18) | 0x30ac2, (4 << 18) | 0x0b333, (5 << 18) | 0x2A946}, /* 64 (5.320GHz) */ + + {100, (3 << 18) | 0x30ec0, (4 << 18) | 0x08000, (5 << 18) | 0x2A9C6}, /* 100 (5.500GHz) */ + {104, (3 << 18) | 0x30ec2, (4 << 18) | 0x0b333, (5 << 18) | 0x2A9C6}, /* 104 (5.520GHz) */ + {108, (3 << 18) | 0x32ec1, (4 << 18) | 0x09999, (5 << 18) | 0x2A9C6}, /* 108 (5.540GHz) */ + {112, (3 << 18) | 0x31ec1, (4 << 18) | 0x0a666, (5 << 18) | 0x2A9C6}, /* 112 (5.560GHz) */ + {116, (3 << 18) | 0x33ec3, (4 << 18) | 0x08ccc, (5 << 18) | 0x2A9C6}, /* 116 (5.580GHz) */ + {120, (3 << 18) | 0x301c0, (4 << 18) | 0x08000, (5 << 18) | 0x2A9C6}, /* 120 (5.600GHz) */ + {124, (3 << 18) | 0x301c2, (4 << 18) | 0x0b333, (5 << 18) | 0x2A9C6}, /* 124 (5.620GHz) */ + {128, (3 << 18) | 0x321c1, (4 << 18) | 0x09999, (5 << 18) | 0x2A9C6}, /* 128 (5.640GHz) */ + {132, (3 << 18) | 0x311c1, (4 << 18) | 0x0a666, (5 << 18) | 0x2A9C6}, /* 132 (5.660GHz) */ + {136, (3 << 18) | 0x331c3, (4 << 18) | 0x08ccc, (5 << 18) | 0x2A9C6}, /* 136 (5.680GHz) */ + {140, (3 << 18) | 0x309c0, (4 << 18) | 0x08000, (5 << 18) | 0x2A9C6}, /* 140 (5.700GHz) */ + + {149, (3 << 18) | 0x329c2, (4 << 18) | 0x0b333, (5 << 18) | 0x2A9C6}, /* 149 (5.745GHz) */ + {153, (3 << 18) | 0x319c1, (4 << 18) | 0x09999, (5 << 18) | 0x2A9C6}, /* 153 (5.765GHz) */ + {157, (3 << 18) | 0x339c1, (4 << 18) | 0x0a666, (5 << 18) | 0x2A9C6}, /* 157 (5.785GHz) */ + {161, (3 << 18) | 0x305c3, (4 << 18) | 0x08ccc, (5 << 18) | 0x2A9C6}, /* 161 (5.805GHz) */ + + /* Japan */ + { 184, (3 << 18) | 0x308c2, (4 << 18) | 0x0b333, (5 << 18) | 0x2A946}, /* 184 (4.920GHz) */ + { 188, (3 << 18) | 0x328c1, (4 << 18) | 0x09999, (5 << 18) | 0x2A946}, /* 188 (4.940GHz) */ + { 192, (3 << 18) | 0x318c1, (4 << 18) | 0x0a666, (5 << 18) | 0x2A946}, /* 192 (4.960GHz) */ + { 196, (3 << 18) | 0x338c3, (4 << 18) | 0x08ccc, (5 << 18) | 0x2A946}, /* 196 (4.980GHz) */ + { 8, (3 << 18) | 0x324c1, (4 << 18) | 0x09999, (5 << 18) | 0x2A946}, /* 8 (5.040GHz) */ + { 12, (3 << 18) | 0x314c1, (4 << 18) | 0x0a666, (5 << 18) | 0x2A946}, /* 12 (5.060GHz) */ + { 16, (3 << 18) | 0x334c3, (4 << 18) | 0x08ccc, (5 << 18) | 0x2A946}, /* 16 (5.080GHz) */ + { 34, (3 << 18) | 0x31cc2, (4 << 18) | 0x0b333, (5 << 18) | 0x2A946}, /* 34 (5.170GHz) */ + { 38, (3 << 18) | 0x33cc1, (4 << 18) | 0x09999, (5 << 18) | 0x2A946}, /* 38 (5.190GHz) */ + { 42, (3 << 18) | 0x302c1, (4 << 18) | 0x0a666, (5 << 18) | 0x2A946}, /* 42 (5.210GHz) */ + { 46, (3 << 18) | 0x322c3, (4 << 18) | 0x08ccc, (5 << 18) | 0x2A946}, /* 46 (5.230GHz) */ }; -u32 maxim_317_channel_data_24[][3] = -{ - {(0x03<<18)|0x30143, (0x04<<18)|0x0accc, (0x05<<18)|0x28986}, // channe1 01 - {(0x03<<18)|0x32140, (0x04<<18)|0x09111, (0x05<<18)|0x28986}, // channe1 02 - {(0x03<<18)|0x32142, (0x04<<18)|0x0bbbb, (0x05<<18)|0x28986}, // channe1 03 - {(0x03<<18)|0x32143, (0x04<<18)|0x0accc, (0x05<<18)|0x28986}, // channe1 04 - {(0x03<<18)|0x31140, (0x04<<18)|0x09111, (0x05<<18)|0x28986}, // channe1 05 - {(0x03<<18)|0x31142, (0x04<<18)|0x0bbbb, (0x05<<18)|0x28986}, // channe1 06 - {(0x03<<18)|0x31143, (0x04<<18)|0x0accc, (0x05<<18)|0x28986}, // channe1 07 - {(0x03<<18)|0x33140, (0x04<<18)|0x09111, (0x05<<18)|0x28986}, // channe1 08 - {(0x03<<18)|0x33142, (0x04<<18)|0x0bbbb, (0x05<<18)|0x28986}, // channe1 09 - {(0x03<<18)|0x33143, (0x04<<18)|0x0accc, (0x05<<18)|0x28986}, // channe1 10 - {(0x03<<18)|0x30940, (0x04<<18)|0x09111, (0x05<<18)|0x28986}, // channe1 11 - {(0x03<<18)|0x30942, (0x04<<18)|0x0bbbb, (0x05<<18)|0x28986}, // channe1 12 - {(0x03<<18)|0x30943, (0x04<<18)|0x0accc, (0x05<<18)|0x28986} // channe1 13 +/* + * ==================================================================== + * For MAXIM2825/6/7 Ver. 317 or less + * + * 0x00 0x00080 + * 0x01 0x214c0 + * 0x02 0x13802 + * + * 2.4GHz Channels + * channe1 01 (2.412GHz); 0x03 0x30143 ;0x04 0x0accc + * channe1 02 (2.417GHz); 0x03 0x32140 ;0x04 0x09111 + * channe1 03 (2.422GHz); 0x03 0x32142 ;0x04 0x0bbbb + * channe1 04 (2.427GHz); 0x03 0x32143 ;0x04 0x0accc + * channe1 05 (2.432GHz); 0x03 0x31140 ;0x04 0x09111 + * channe1 06 (2.437GHz); 0x03 0x31142 ;0x04 0x0bbbb + * channe1 07 (2.442GHz); 0x03 0x31143 ;0x04 0x0accc + * channe1 08 (2.447GHz); 0x03 0x33140 ;0x04 0x09111 + * channe1 09 (2.452GHz); 0x03 0x33142 ;0x04 0x0bbbb + * channe1 10 (2.457GHz); 0x03 0x33143 ;0x04 0x0accc + * channe1 11 (2.462GHz); 0x03 0x30940 ;0x04 0x09111 + * channe1 12 (2.467GHz); 0x03 0x30942 ;0x04 0x0bbbb + * channe1 13 (2.472GHz); 0x03 0x30943 ;0x04 0x0accc + * + * 5.0Ghz Channels + * channel 36 (5.180GHz); 0x03 0x33cc0 ;0x04 0x0b333 + * channel 40 (5.200GHz); 0x03 0x302c0 ;0x04 0x08000 + * channel 44 (5.220GHz); 0x03 0x302c2 ;0x04 0x0b333 + * channel 48 (5.240GHz); 0x03 0x322c1 ;0x04 0x09999 + * channel 52 (5.260GHz); 0x03 0x312c1 ;0x04 0x0a666 + * channel 56 (5.280GHz); 0x03 0x332c3 ;0x04 0x08ccc + * channel 60 (5.300GHz); 0x03 0x30ac0 ;0x04 0x08000 + * channel 64 (5.320GHz); 0x03 0x30ac2 ;0x04 0x08333 + * + * 2.4GHz band ; 0x05 0x28986; + * 5.0GHz band ; 0x05 0x2a986 + * 0x06 0x18008 + * 0x07 0x38400 + * 0x08 0x05108 + * 0x09 0x27ff8 + * 0x0a 0x14000 + * 0x0b 0x37f99 + * 0x0c 0x0c000 + * ==================================================================== + */ +u32 maxim_317_rf_data[] = { + (0x00 << 18) | 0x000a2, + (0x01 << 18) | 0x214c0, + (0x02 << 18) | 0x13802, + (0x03 << 18) | 0x30143, + (0x04 << 18) | 0x0accc, + (0x05 << 18) | 0x28986, + (0x06 << 18) | 0x18008, + (0x07 << 18) | 0x38400, + (0x08 << 18) | 0x05108, + (0x09 << 18) | 0x27ff8, + (0x0A << 18) | 0x14000, + (0x0B << 18) | 0x37f99, + (0x0C << 18) | 0x0c000 }; -u32 maxim_317_channel_data_50[][3] = -{ - {(0x03<<18)|0x33cc0, (0x04<<18)|0x0b333, (0x05<<18)|0x2a986}, // channel 36 - {(0x03<<18)|0x302c0, (0x04<<18)|0x08000, (0x05<<18)|0x2a986}, // channel 40 - {(0x03<<18)|0x302c3, (0x04<<18)|0x0accc, (0x05<<18)|0x2a986}, // channel 44 - {(0x03<<18)|0x322c1, (0x04<<18)|0x09666, (0x05<<18)|0x2a986}, // channel 48 - {(0x03<<18)|0x312c2, (0x04<<18)|0x09999, (0x05<<18)|0x2a986}, // channel 52 - {(0x03<<18)|0x332c0, (0x04<<18)|0x0b333, (0x05<<18)|0x2a99e}, // channel 56 - {(0x03<<18)|0x30ac0, (0x04<<18)|0x08000, (0x05<<18)|0x2a99e}, // channel 60 - {(0x03<<18)|0x30ac3, (0x04<<18)|0x0accc, (0x05<<18)|0x2a99e} // channel 64 +u32 maxim_317_channel_data_24[][3] = { + {(0x03 << 18) | 0x30143, (0x04 << 18) | 0x0accc, (0x05 << 18) | 0x28986}, /* channe1 01 */ + {(0x03 << 18) | 0x32140, (0x04 << 18) | 0x09111, (0x05 << 18) | 0x28986}, /* channe1 02 */ + {(0x03 << 18) | 0x32142, (0x04 << 18) | 0x0bbbb, (0x05 << 18) | 0x28986}, /* channe1 03 */ + {(0x03 << 18) | 0x32143, (0x04 << 18) | 0x0accc, (0x05 << 18) | 0x28986}, /* channe1 04 */ + {(0x03 << 18) | 0x31140, (0x04 << 18) | 0x09111, (0x05 << 18) | 0x28986}, /* channe1 05 */ + {(0x03 << 18) | 0x31142, (0x04 << 18) | 0x0bbbb, (0x05 << 18) | 0x28986}, /* channe1 06 */ + {(0x03 << 18) | 0x31143, (0x04 << 18) | 0x0accc, (0x05 << 18) | 0x28986}, /* channe1 07 */ + {(0x03 << 18) | 0x33140, (0x04 << 18) | 0x09111, (0x05 << 18) | 0x28986}, /* channe1 08 */ + {(0x03 << 18) | 0x33142, (0x04 << 18) | 0x0bbbb, (0x05 << 18) | 0x28986}, /* channe1 09 */ + {(0x03 << 18) | 0x33143, (0x04 << 18) | 0x0accc, (0x05 << 18) | 0x28986}, /* channe1 10 */ + {(0x03 << 18) | 0x30940, (0x04 << 18) | 0x09111, (0x05 << 18) | 0x28986}, /* channe1 11 */ + {(0x03 << 18) | 0x30942, (0x04 << 18) | 0x0bbbb, (0x05 << 18) | 0x28986}, /* channe1 12 */ + {(0x03 << 18) | 0x30943, (0x04 << 18) | 0x0accc, (0x05 << 18) | 0x28986} /* channe1 13 */ }; -u32 maxim_317_power_data_24[] = {(0x0C<<18)|0x0c000, (0x0C<<18)|0x0c100}; -u32 maxim_317_power_data_50[] = {(0x0C<<18)|0x0c000, (0x0C<<18)|0x0c100}; - -/***************************************************************************** -;;AL2230 MP (Mass Production Version) -;;RF Registers Setting for Airoha AL2230 silicon after June 1st, 2004 -;;Updated by Tiger Huang (June 1st, 2004) -;;20-bit length and LSB first - -;;Ch01 (2412MHz) ;0x00 0x09EFC ;0x01 0x8CCCC; -;;Ch02 (2417MHz) ;0x00 0x09EFC ;0x01 0x8CCCD; -;;Ch03 (2422MHz) ;0x00 0x09E7C ;0x01 0x8CCCC; -;;Ch04 (2427MHz) ;0x00 0x09E7C ;0x01 0x8CCCD; -;;Ch05 (2432MHz) ;0x00 0x05EFC ;0x01 0x8CCCC; -;;Ch06 (2437MHz) ;0x00 0x05EFC ;0x01 0x8CCCD; -;;Ch07 (2442MHz) ;0x00 0x05E7C ;0x01 0x8CCCC; -;;Ch08 (2447MHz) ;0x00 0x05E7C ;0x01 0x8CCCD; -;;Ch09 (2452MHz) ;0x00 0x0DEFC ;0x01 0x8CCCC; -;;Ch10 (2457MHz) ;0x00 0x0DEFC ;0x01 0x8CCCD; -;;Ch11 (2462MHz) ;0x00 0x0DE7C ;0x01 0x8CCCC; -;;Ch12 (2467MHz) ;0x00 0x0DE7C ;0x01 0x8CCCD; -;;Ch13 (2472MHz) ;0x00 0x03EFC ;0x01 0x8CCCC; -;;Ch14 (2484Mhz) ;0x00 0x03E7C ;0x01 0x86666; - -0x02 0x401D8; RXDCOC BW 100Hz for RXHP low -;;0x02 0x481DC; RXDCOC BW 30Khz for RXHP low - -0x03 0xCFFF0 -0x04 0x23800 -0x05 0xA3B72 -0x06 0x6DA01 -0x07 0xE1688 -0x08 0x11600 -0x09 0x99E02 -0x0A 0x5DDB0 -0x0B 0xD9900 -0x0C 0x3FFBD -0x0D 0xB0000 -0x0F 0xF00A0 - -;RF Calibration for Airoha AL2230 -;Edit by Ben Chang (01/30/04) -;Updated by Tiger Huang (03/03/04) -0x0f 0xf00a0 ; Initial Setting -0x0f 0xf00b0 ; Activate TX DCC -0x0f 0xf02a0 ; Activate Phase Calibration -0x0f 0xf00e0 ; Activate Filter RC Calibration -0x0f 0xf00a0 ; Restore Initial Setting -*****************************************************************************/ - -u32 al2230_rf_data[] = -{ - (0x00<<20)|0x09EFC, - (0x01<<20)|0x8CCCC, - (0x02<<20)|0x40058,// 20060627 Anson 0x401D8, - (0x03<<20)|0xCFFF0, - (0x04<<20)|0x24100,// 20060627 Anson 0x23800, - (0x05<<20)|0xA3B2F,// 20060627 Anson 0xA3B72 - (0x06<<20)|0x6DA01, - (0x07<<20)|0xE3628,// 20060627 Anson 0xE1688, - (0x08<<20)|0x11600, - (0x09<<20)|0x9DC02,// 20060627 Anosn 0x97602,//0x99E02, //0x9AE02 - (0x0A<<20)|0x5ddb0, // 941206 For QCOM interference 0x588b0,//0x5DDB0, 940601 adj 0x5aa30 for bluetooth - (0x0B<<20)|0xD9900, - (0x0C<<20)|0x3FFBD, - (0x0D<<20)|0xB0000, - (0x0F<<20)|0xF01A0 // 20060627 Anson 0xF00A0 +u32 maxim_317_channel_data_50[][3] = { + {(0x03 << 18) | 0x33cc0, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x2a986}, /* channel 36 */ + {(0x03 << 18) | 0x302c0, (0x04 << 18) | 0x08000, (0x05 << 18) | 0x2a986}, /* channel 40 */ + {(0x03 << 18) | 0x302c3, (0x04 << 18) | 0x0accc, (0x05 << 18) | 0x2a986}, /* channel 44 */ + {(0x03 << 18) | 0x322c1, (0x04 << 18) | 0x09666, (0x05 << 18) | 0x2a986}, /* channel 48 */ + {(0x03 << 18) | 0x312c2, (0x04 << 18) | 0x09999, (0x05 << 18) | 0x2a986}, /* channel 52 */ + {(0x03 << 18) | 0x332c0, (0x04 << 18) | 0x0b333, (0x05 << 18) | 0x2a99e}, /* channel 56 */ + {(0x03 << 18) | 0x30ac0, (0x04 << 18) | 0x08000, (0x05 << 18) | 0x2a99e}, /* channel 60 */ + {(0x03 << 18) | 0x30ac3, (0x04 << 18) | 0x0accc, (0x05 << 18) | 0x2a99e} /* channel 64 */ }; -u32 al2230s_rf_data[] = -{ - (0x00<<20)|0x09EFC, - (0x01<<20)|0x8CCCC, - (0x02<<20)|0x40058,// 20060419 0x401D8, - (0x03<<20)|0xCFFF0, - (0x04<<20)|0x24100,// 20060419 0x23800, - (0x05<<20)|0xA3B2F,// 20060419 0xA3B72, - (0x06<<20)|0x6DA01, - (0x07<<20)|0xE3628,// 20060419 0xE1688, - (0x08<<20)|0x11600, - (0x09<<20)|0x9DC02,// 20060419 0x97602,//0x99E02, //0x9AE02 - (0x0A<<20)|0x5DDB0,// 941206 For QCOM interference 0x588b0,//0x5DDB0, 940601 adj 0x5aa30 for bluetooth - (0x0B<<20)|0xD9900, - (0x0C<<20)|0x3FFBD, - (0x0D<<20)|0xB0000, - (0x0F<<20)|0xF01A0 // 20060419 0xF00A0 +u32 maxim_317_power_data_24[] = {(0x0C << 18) | 0x0c000, (0x0C << 18) | 0x0c100}; +u32 maxim_317_power_data_50[] = {(0x0C << 18) | 0x0c000, (0x0C << 18) | 0x0c100}; + +/* + * =================================================================== + * AL2230 MP (Mass Production Version) + * RF Registers Setting for Airoha AL2230 silicon after June 1st, 2004 + * 20-bit length and LSB first + * + * Ch01 (2412MHz) ;0x00 0x09EFC ;0x01 0x8CCCC; + * Ch02 (2417MHz) ;0x00 0x09EFC ;0x01 0x8CCCD; + * Ch03 (2422MHz) ;0x00 0x09E7C ;0x01 0x8CCCC; + * Ch04 (2427MHz) ;0x00 0x09E7C ;0x01 0x8CCCD; + * Ch05 (2432MHz) ;0x00 0x05EFC ;0x01 0x8CCCC; + * Ch06 (2437MHz) ;0x00 0x05EFC ;0x01 0x8CCCD; + * Ch07 (2442MHz) ;0x00 0x05E7C ;0x01 0x8CCCC; + * Ch08 (2447MHz) ;0x00 0x05E7C ;0x01 0x8CCCD; + * Ch09 (2452MHz) ;0x00 0x0DEFC ;0x01 0x8CCCC; + * Ch10 (2457MHz) ;0x00 0x0DEFC ;0x01 0x8CCCD; + * Ch11 (2462MHz) ;0x00 0x0DE7C ;0x01 0x8CCCC; + * Ch12 (2467MHz) ;0x00 0x0DE7C ;0x01 0x8CCCD; + * Ch13 (2472MHz) ;0x00 0x03EFC ;0x01 0x8CCCC; + * Ch14 (2484Mhz) ;0x00 0x03E7C ;0x01 0x86666; + * + * 0x02 0x401D8; RXDCOC BW 100Hz for RXHP low + * 0x02 0x481DC; RXDCOC BW 30Khz for RXHP low + * + * 0x03 0xCFFF0 + * 0x04 0x23800 + * 0x05 0xA3B72 + * 0x06 0x6DA01 + * 0x07 0xE1688 + * 0x08 0x11600 + * 0x09 0x99E02 + * 0x0A 0x5DDB0 + * 0x0B 0xD9900 + * 0x0C 0x3FFBD + * 0x0D 0xB0000 + * 0x0F 0xF00A0 + * + * RF Calibration for Airoha AL2230 + * + * 0x0f 0xf00a0 ; Initial Setting + * 0x0f 0xf00b0 ; Activate TX DCC + * 0x0f 0xf02a0 ; Activate Phase Calibration + * 0x0f 0xf00e0 ; Activate Filter RC Calibration + * 0x0f 0xf00a0 ; Restore Initial Setting + * ================================================================== + */ +u32 al2230_rf_data[] = { + (0x00 << 20) | 0x09EFC, + (0x01 << 20) | 0x8CCCC, + (0x02 << 20) | 0x40058, + (0x03 << 20) | 0xCFFF0, + (0x04 << 20) | 0x24100, + (0x05 << 20) | 0xA3B2F, + (0x06 << 20) | 0x6DA01, + (0x07 << 20) | 0xE3628, + (0x08 << 20) | 0x11600, + (0x09 << 20) | 0x9DC02, + (0x0A << 20) | 0x5ddb0, + (0x0B << 20) | 0xD9900, + (0x0C << 20) | 0x3FFBD, + (0x0D << 20) | 0xB0000, + (0x0F << 20) | 0xF01A0 }; -u32 al2230_channel_data_24[][2] = -{ - {(0x00<<20)|0x09EFC, (0x01<<20)|0x8CCCC}, // channe1 01 - {(0x00<<20)|0x09EFC, (0x01<<20)|0x8CCCD}, // channe1 02 - {(0x00<<20)|0x09E7C, (0x01<<20)|0x8CCCC}, // channe1 03 - {(0x00<<20)|0x09E7C, (0x01<<20)|0x8CCCD}, // channe1 04 - {(0x00<<20)|0x05EFC, (0x01<<20)|0x8CCCC}, // channe1 05 - {(0x00<<20)|0x05EFC, (0x01<<20)|0x8CCCD}, // channe1 06 - {(0x00<<20)|0x05E7C, (0x01<<20)|0x8CCCC}, // channe1 07 - {(0x00<<20)|0x05E7C, (0x01<<20)|0x8CCCD}, // channe1 08 - {(0x00<<20)|0x0DEFC, (0x01<<20)|0x8CCCC}, // channe1 09 - {(0x00<<20)|0x0DEFC, (0x01<<20)|0x8CCCD}, // channe1 10 - {(0x00<<20)|0x0DE7C, (0x01<<20)|0x8CCCC}, // channe1 11 - {(0x00<<20)|0x0DE7C, (0x01<<20)|0x8CCCD}, // channe1 12 - {(0x00<<20)|0x03EFC, (0x01<<20)|0x8CCCC}, // channe1 13 - {(0x00<<20)|0x03E7C, (0x01<<20)|0x86666} // channe1 14 +u32 al2230s_rf_data[] = { + (0x00 << 20) | 0x09EFC, + (0x01 << 20) | 0x8CCCC, + (0x02 << 20) | 0x40058, + (0x03 << 20) | 0xCFFF0, + (0x04 << 20) | 0x24100, + (0x05 << 20) | 0xA3B2F, + (0x06 << 20) | 0x6DA01, + (0x07 << 20) | 0xE3628, + (0x08 << 20) | 0x11600, + (0x09 << 20) | 0x9DC02, + (0x0A << 20) | 0x5DDB0, + (0x0B << 20) | 0xD9900, + (0x0C << 20) | 0x3FFBD, + (0x0D << 20) | 0xB0000, + (0x0F << 20) | 0xF01A0 }; -// Current setting. u32 airoha_power_data_24[] = {(0x09<<20)|0x90202, (0x09<<20)|0x96602, (0x09<<20)|0x97602}; -#define AIROHA_TXVGA_LOW_INDEX 31 // Index for 0x90202 -#define AIROHA_TXVGA_MIDDLE_INDEX 12 // Index for 0x96602 -#define AIROHA_TXVGA_HIGH_INDEX 8 // Index for 0x97602 1.0.24.0 1.0.28.0 -/* -u32 airoha_power_data_24[] = -{ - 0x9FE02, // Max - 0 dB - 0x9BE02, // Max - 1 dB - 0x9DE02, // Max - 2 dB - 0x99E02, // Max - 3 dB - 0x9EE02, // Max - 4 dB - 0x9AE02, // Max - 5 dB - 0x9CE02, // Max - 6 dB - 0x98E02, // Max - 7 dB - 0x97602, // Max - 8 dB - 0x93602, // Max - 9 dB - 0x95602, // Max - 10 dB - 0x91602, // Max - 11 dB - 0x96602, // Max - 12 dB - 0x92602, // Max - 13 dB - 0x94602, // Max - 14 dB - 0x90602, // Max - 15 dB - 0x97A02, // Max - 16 dB - 0x93A02, // Max - 17 dB - 0x95A02, // Max - 18 dB - 0x91A02, // Max - 19 dB - 0x96A02, // Max - 20 dB - 0x92A02, // Max - 21 dB - 0x94A02, // Max - 22 dB - 0x90A02, // Max - 23 dB - 0x97202, // Max - 24 dB - 0x93202, // Max - 25 dB - 0x95202, // Max - 26 dB - 0x91202, // Max - 27 dB - 0x96202, // Max - 28 dB - 0x92202, // Max - 29 dB - 0x94202, // Max - 30 dB - 0x90202 // Max - 31 dB +u32 al2230_channel_data_24[][2] = { + {(0x00 << 20) | 0x09EFC, (0x01 << 20) | 0x8CCCC}, /* channe1 01 */ + {(0x00 << 20) | 0x09EFC, (0x01 << 20) | 0x8CCCD}, /* channe1 02 */ + {(0x00 << 20) | 0x09E7C, (0x01 << 20) | 0x8CCCC}, /* channe1 03 */ + {(0x00 << 20) | 0x09E7C, (0x01 << 20) | 0x8CCCD}, /* channe1 04 */ + {(0x00 << 20) | 0x05EFC, (0x01 << 20) | 0x8CCCC}, /* channe1 05 */ + {(0x00 << 20) | 0x05EFC, (0x01 << 20) | 0x8CCCD}, /* channe1 06 */ + {(0x00 << 20) | 0x05E7C, (0x01 << 20) | 0x8CCCC}, /* channe1 07 */ + {(0x00 << 20) | 0x05E7C, (0x01 << 20) | 0x8CCCD}, /* channe1 08 */ + {(0x00 << 20) | 0x0DEFC, (0x01 << 20) | 0x8CCCC}, /* channe1 09 */ + {(0x00 << 20) | 0x0DEFC, (0x01 << 20) | 0x8CCCD}, /* channe1 10 */ + {(0x00 << 20) | 0x0DE7C, (0x01 << 20) | 0x8CCCC}, /* channe1 11 */ + {(0x00 << 20) | 0x0DE7C, (0x01 << 20) | 0x8CCCD}, /* channe1 12 */ + {(0x00 << 20) | 0x03EFC, (0x01 << 20) | 0x8CCCC}, /* channe1 13 */ + {(0x00 << 20) | 0x03E7C, (0x01 << 20) | 0x86666} /* channe1 14 */ }; -*/ -// 20040927 1.1.69.1000 ybjiang -// from John -u32 al2230_txvga_data[][2] = -{ - //value , index +/* Current setting. u32 airoha_power_data_24[] = {(0x09 << 20) | 0x90202, (0x09 << 20) | 0x96602, (0x09 << 20) | 0x97602}; */ +#define AIROHA_TXVGA_LOW_INDEX 31 /* Index for 0x90202 */ +#define AIROHA_TXVGA_MIDDLE_INDEX 12 /* Index for 0x96602 */ +#define AIROHA_TXVGA_HIGH_INDEX 8 /* Index for 0x97602 1.0.24.0 1.0.28.0 */ + +u32 al2230_txvga_data[][2] = { + /* value , index */ {0x090202, 0}, {0x094202, 2}, {0x092202, 4}, @@ -551,263 +489,242 @@ u32 al2230_txvga_data[][2] = {0x09FE02, 63} }; -//-------------------------------- -// For Airoha AL7230, 2.4Ghz band -// Edit by Tiger, (March, 9, 2005) -// 24bit, MSB first - -//channel independent registers: -u32 al7230_rf_data_24[] = -{ - (0x00<<24)|0x003790, - (0x01<<24)|0x133331, - (0x02<<24)|0x841FF2, - (0x03<<24)|0x3FDFA3, - (0x04<<24)|0x7FD784, - (0x05<<24)|0x802B55, - (0x06<<24)|0x56AF36, - (0x07<<24)|0xCE0207, - (0x08<<24)|0x6EBC08, - (0x09<<24)|0x221BB9, - (0x0A<<24)|0xE0000A, - (0x0B<<24)|0x08071B, - (0x0C<<24)|0x000A3C, - (0x0D<<24)|0xFFFFFD, - (0x0E<<24)|0x00000E, - (0x0F<<24)|0x1ABA8F +/* + * ========================================== + * For Airoha AL7230, 2.4Ghz band + * 24bit, MSB first + */ + +/* channel independent registers: */ +u32 al7230_rf_data_24[] = { + (0x00 << 24) | 0x003790, + (0x01 << 24) | 0x133331, + (0x02 << 24) | 0x841FF2, + (0x03 << 24) | 0x3FDFA3, + (0x04 << 24) | 0x7FD784, + (0x05 << 24) | 0x802B55, + (0x06 << 24) | 0x56AF36, + (0x07 << 24) | 0xCE0207, + (0x08 << 24) | 0x6EBC08, + (0x09 << 24) | 0x221BB9, + (0x0A << 24) | 0xE0000A, + (0x0B << 24) | 0x08071B, + (0x0C << 24) | 0x000A3C, + (0x0D << 24) | 0xFFFFFD, + (0x0E << 24) | 0x00000E, + (0x0F << 24) | 0x1ABA8F }; -u32 al7230_channel_data_24[][2] = -{ - {(0x00<<24)|0x003790, (0x01<<24)|0x133331}, // channe1 01 - {(0x00<<24)|0x003790, (0x01<<24)|0x1B3331}, // channe1 02 - {(0x00<<24)|0x003790, (0x01<<24)|0x033331}, // channe1 03 - {(0x00<<24)|0x003790, (0x01<<24)|0x0B3331}, // channe1 04 - {(0x00<<24)|0x0037A0, (0x01<<24)|0x133331}, // channe1 05 - {(0x00<<24)|0x0037A0, (0x01<<24)|0x1B3331}, // channe1 06 - {(0x00<<24)|0x0037A0, (0x01<<24)|0x033331}, // channe1 07 - {(0x00<<24)|0x0037A0, (0x01<<24)|0x0B3331}, // channe1 08 - {(0x00<<24)|0x0037B0, (0x01<<24)|0x133331}, // channe1 09 - {(0x00<<24)|0x0037B0, (0x01<<24)|0x1B3331}, // channe1 10 - {(0x00<<24)|0x0037B0, (0x01<<24)|0x033331}, // channe1 11 - {(0x00<<24)|0x0037B0, (0x01<<24)|0x0B3331}, // channe1 12 - {(0x00<<24)|0x0037C0, (0x01<<24)|0x133331}, // channe1 13 - {(0x00<<24)|0x0037C0, (0x01<<24)|0x066661} // channel 14 +u32 al7230_channel_data_24[][2] = { + {(0x00 << 24) | 0x003790, (0x01 << 24) | 0x133331}, /* channe1 01 */ + {(0x00 << 24) | 0x003790, (0x01 << 24) | 0x1B3331}, /* channe1 02 */ + {(0x00 << 24) | 0x003790, (0x01 << 24) | 0x033331}, /* channe1 03 */ + {(0x00 << 24) | 0x003790, (0x01 << 24) | 0x0B3331}, /* channe1 04 */ + {(0x00 << 24) | 0x0037A0, (0x01 << 24) | 0x133331}, /* channe1 05 */ + {(0x00 << 24) | 0x0037A0, (0x01 << 24) | 0x1B3331}, /* channe1 06 */ + {(0x00 << 24) | 0x0037A0, (0x01 << 24) | 0x033331}, /* channe1 07 */ + {(0x00 << 24) | 0x0037A0, (0x01 << 24) | 0x0B3331}, /* channe1 08 */ + {(0x00 << 24) | 0x0037B0, (0x01 << 24) | 0x133331}, /* channe1 09 */ + {(0x00 << 24) | 0x0037B0, (0x01 << 24) | 0x1B3331}, /* channe1 10 */ + {(0x00 << 24) | 0x0037B0, (0x01 << 24) | 0x033331}, /* channe1 11 */ + {(0x00 << 24) | 0x0037B0, (0x01 << 24) | 0x0B3331}, /* channe1 12 */ + {(0x00 << 24) | 0x0037C0, (0x01 << 24) | 0x133331}, /* channe1 13 */ + {(0x00 << 24) | 0x0037C0, (0x01 << 24) | 0x066661} /* channel 14 */ }; -//channel independent registers: -u32 al7230_rf_data_50[] = -{ - (0x00<<24)|0x0FF520, - (0x01<<24)|0x000001, - (0x02<<24)|0x451FE2, - (0x03<<24)|0x5FDFA3, - (0x04<<24)|0x6FD784, - (0x05<<24)|0x853F55, - (0x06<<24)|0x56AF36, - (0x07<<24)|0xCE0207, - (0x08<<24)|0x6EBC08, - (0x09<<24)|0x221BB9, - (0x0A<<24)|0xE0600A, - (0x0B<<24)|0x08044B, - (0x0C<<24)|0x00143C, - (0x0D<<24)|0xFFFFFD, - (0x0E<<24)|0x00000E, - (0x0F<<24)|0x12BACF //5Ghz default state +/* channel independent registers: */ +u32 al7230_rf_data_50[] = { + (0x00 << 24) | 0x0FF520, + (0x01 << 24) | 0x000001, + (0x02 << 24) | 0x451FE2, + (0x03 << 24) | 0x5FDFA3, + (0x04 << 24) | 0x6FD784, + (0x05 << 24) | 0x853F55, + (0x06 << 24) | 0x56AF36, + (0x07 << 24) | 0xCE0207, + (0x08 << 24) | 0x6EBC08, + (0x09 << 24) | 0x221BB9, + (0x0A << 24) | 0xE0600A, + (0x0B << 24) | 0x08044B, + (0x0C << 24) | 0x00143C, + (0x0D << 24) | 0xFFFFFD, + (0x0E << 24) | 0x00000E, + (0x0F << 24) | 0x12BACF /* 5Ghz default state */ }; -u32 al7230_channel_data_5[][4] = -{ - //channel dependent registers: 0x00, 0x01 and 0x04 - //11J =========== - {184, (0x00<<24)|0x0FF520, (0x01<<24)|0x000001, (0x04<<24)|0x67F784}, // channel 184 - {188, (0x00<<24)|0x0FF520, (0x01<<24)|0x0AAAA1, (0x04<<24)|0x77F784}, // channel 188 - {192, (0x00<<24)|0x0FF530, (0x01<<24)|0x155551, (0x04<<24)|0x77F784}, // channel 192 - {196, (0x00<<24)|0x0FF530, (0x01<<24)|0x000001, (0x04<<24)|0x67F784}, // channel 196 - {8, (0x00<<24)|0x0FF540, (0x01<<24)|0x000001, (0x04<<24)|0x67F784}, // channel 008 - {12, (0x00<<24)|0x0FF540, (0x01<<24)|0x0AAAA1, (0x04<<24)|0x77F784}, // channel 012 - {16, (0x00<<24)|0x0FF550, (0x01<<24)|0x155551, (0x04<<24)|0x77F784}, // channel 016 - {34, (0x00<<24)|0x0FF560, (0x01<<24)|0x055551, (0x04<<24)|0x77F784}, // channel 034 - {38, (0x00<<24)|0x0FF570, (0x01<<24)|0x100001, (0x04<<24)|0x77F784}, // channel 038 - {42, (0x00<<24)|0x0FF570, (0x01<<24)|0x1AAAA1, (0x04<<24)|0x77F784}, // channel 042 - {46, (0x00<<24)|0x0FF570, (0x01<<24)|0x055551, (0x04<<24)|0x77F784}, // channel 046 - //11 A/H ========= - {36, (0x00<<24)|0x0FF560, (0x01<<24)|0x0AAAA1, (0x04<<24)|0x77F784}, // channel 036 - {40, (0x00<<24)|0x0FF570, (0x01<<24)|0x155551, (0x04<<24)|0x77F784}, // channel 040 - {44, (0x00<<24)|0x0FF570, (0x01<<24)|0x000001, (0x04<<24)|0x67F784}, // channel 044 - {48, (0x00<<24)|0x0FF570, (0x01<<24)|0x0AAAA1, (0x04<<24)|0x77F784}, // channel 048 - {52, (0x00<<24)|0x0FF580, (0x01<<24)|0x155551, (0x04<<24)|0x77F784}, // channel 052 - {56, (0x00<<24)|0x0FF580, (0x01<<24)|0x000001, (0x04<<24)|0x67F784}, // channel 056 - {60, (0x00<<24)|0x0FF580, (0x01<<24)|0x0AAAA1, (0x04<<24)|0x77F784}, // channel 060 - {64, (0x00<<24)|0x0FF590, (0x01<<24)|0x155551, (0x04<<24)|0x77F784}, // channel 064 - {100, (0x00<<24)|0x0FF5C0, (0x01<<24)|0x155551, (0x04<<24)|0x77F784}, // channel 100 - {104, (0x00<<24)|0x0FF5C0, (0x01<<24)|0x000001, (0x04<<24)|0x67F784}, // channel 104 - {108, (0x00<<24)|0x0FF5C0, (0x01<<24)|0x0AAAA1, (0x04<<24)|0x77F784}, // channel 108 - {112, (0x00<<24)|0x0FF5D0, (0x01<<24)|0x155551, (0x04<<24)|0x77F784}, // channel 112 - {116, (0x00<<24)|0x0FF5D0, (0x01<<24)|0x000001, (0x04<<24)|0x67F784}, // channel 116 - {120, (0x00<<24)|0x0FF5D0, (0x01<<24)|0x0AAAA1, (0x04<<24)|0x77F784}, // channel 120 - {124, (0x00<<24)|0x0FF5E0, (0x01<<24)|0x155551, (0x04<<24)|0x77F784}, // channel 124 - {128, (0x00<<24)|0x0FF5E0, (0x01<<24)|0x000001, (0x04<<24)|0x67F784}, // channel 128 - {132, (0x00<<24)|0x0FF5E0, (0x01<<24)|0x0AAAA1, (0x04<<24)|0x77F784}, // channel 132 - {136, (0x00<<24)|0x0FF5F0, (0x01<<24)|0x155551, (0x04<<24)|0x77F784}, // channel 136 - {140, (0x00<<24)|0x0FF5F0, (0x01<<24)|0x000001, (0x04<<24)|0x67F784}, // channel 140 - {149, (0x00<<24)|0x0FF600, (0x01<<24)|0x180001, (0x04<<24)|0x77F784}, // channel 149 - {153, (0x00<<24)|0x0FF600, (0x01<<24)|0x02AAA1, (0x04<<24)|0x77F784}, // channel 153 - {157, (0x00<<24)|0x0FF600, (0x01<<24)|0x0D5551, (0x04<<24)|0x77F784}, // channel 157 - {161, (0x00<<24)|0x0FF610, (0x01<<24)|0x180001, (0x04<<24)|0x77F784}, // channel 161 - {165, (0x00<<24)|0x0FF610, (0x01<<24)|0x02AAA1, (0x04<<24)|0x77F784} // channel 165 +u32 al7230_channel_data_5[][4] = { + /* channel dependent registers: 0x00, 0x01 and 0x04 */ + /* 11J =========== */ + {184, (0x00 << 24) | 0x0FF520, (0x01 << 24) | 0x000001, (0x04 << 24) | 0x67F784}, /* channel 184 */ + {188, (0x00 << 24) | 0x0FF520, (0x01 << 24) | 0x0AAAA1, (0x04 << 24) | 0x77F784}, /* channel 188 */ + {192, (0x00 << 24) | 0x0FF530, (0x01 << 24) | 0x155551, (0x04 << 24) | 0x77F784}, /* channel 192 */ + {196, (0x00 << 24) | 0x0FF530, (0x01 << 24) | 0x000001, (0x04 << 24) | 0x67F784}, /* channel 196 */ + {8, (0x00 << 24) | 0x0FF540, (0x01 << 24) | 0x000001, (0x04 << 24) | 0x67F784}, /* channel 008 */ + {12, (0x00 << 24) | 0x0FF540, (0x01 << 24) | 0x0AAAA1, (0x04 << 24) | 0x77F784}, /* channel 012 */ + {16, (0x00 << 24) | 0x0FF550, (0x01 << 24) | 0x155551, (0x04 << 24) | 0x77F784}, /* channel 016 */ + {34, (0x00 << 24) | 0x0FF560, (0x01 << 24) | 0x055551, (0x04 << 24) | 0x77F784}, /* channel 034 */ + {38, (0x00 << 24) | 0x0FF570, (0x01 << 24) | 0x100001, (0x04 << 24) | 0x77F784}, /* channel 038 */ + {42, (0x00 << 24) | 0x0FF570, (0x01 << 24) | 0x1AAAA1, (0x04 << 24) | 0x77F784}, /* channel 042 */ + {46, (0x00 << 24) | 0x0FF570, (0x01 << 24) | 0x055551, (0x04 << 24) | 0x77F784}, /* channel 046 */ + /* 11 A/H ========= */ + {36, (0x00 << 24) | 0x0FF560, (0x01 << 24) | 0x0AAAA1, (0x04 << 24) | 0x77F784}, /* channel 036 */ + {40, (0x00 << 24) | 0x0FF570, (0x01 << 24) | 0x155551, (0x04 << 24) | 0x77F784}, /* channel 040 */ + {44, (0x00 << 24) | 0x0FF570, (0x01 << 24) | 0x000001, (0x04 << 24) | 0x67F784}, /* channel 044 */ + {48, (0x00 << 24) | 0x0FF570, (0x01 << 24) | 0x0AAAA1, (0x04 << 24) | 0x77F784}, /* channel 048 */ + {52, (0x00 << 24) | 0x0FF580, (0x01 << 24) | 0x155551, (0x04 << 24) | 0x77F784}, /* channel 052 */ + {56, (0x00 << 24) | 0x0FF580, (0x01 << 24) | 0x000001, (0x04 << 24) | 0x67F784}, /* channel 056 */ + {60, (0x00 << 24) | 0x0FF580, (0x01 << 24) | 0x0AAAA1, (0x04 << 24) | 0x77F784}, /* channel 060 */ + {64, (0x00 << 24) | 0x0FF590, (0x01 << 24) | 0x155551, (0x04 << 24) | 0x77F784}, /* channel 064 */ + {100, (0x00 << 24) | 0x0FF5C0, (0x01 << 24) | 0x155551, (0x04 << 24) | 0x77F784}, /* channel 100 */ + {104, (0x00 << 24) | 0x0FF5C0, (0x01 << 24) | 0x000001, (0x04 << 24) | 0x67F784}, /* channel 104 */ + {108, (0x00 << 24) | 0x0FF5C0, (0x01 << 24) | 0x0AAAA1, (0x04 << 24) | 0x77F784}, /* channel 108 */ + {112, (0x00 << 24) | 0x0FF5D0, (0x01 << 24) | 0x155551, (0x04 << 24) | 0x77F784}, /* channel 112 */ + {116, (0x00 << 24) | 0x0FF5D0, (0x01 << 24) | 0x000001, (0x04 << 24) | 0x67F784}, /* channel 116 */ + {120, (0x00 << 24) | 0x0FF5D0, (0x01 << 24) | 0x0AAAA1, (0x04 << 24) | 0x77F784}, /* channel 120 */ + {124, (0x00 << 24) | 0x0FF5E0, (0x01 << 24) | 0x155551, (0x04 << 24) | 0x77F784}, /* channel 124 */ + {128, (0x00 << 24) | 0x0FF5E0, (0x01 << 24) | 0x000001, (0x04 << 24) | 0x67F784}, /* channel 128 */ + {132, (0x00 << 24) | 0x0FF5E0, (0x01 << 24) | 0x0AAAA1, (0x04 << 24) | 0x77F784}, /* channel 132 */ + {136, (0x00 << 24) | 0x0FF5F0, (0x01 << 24) | 0x155551, (0x04 << 24) | 0x77F784}, /* channel 136 */ + {140, (0x00 << 24) | 0x0FF5F0, (0x01 << 24) | 0x000001, (0x04 << 24) | 0x67F784}, /* channel 140 */ + {149, (0x00 << 24) | 0x0FF600, (0x01 << 24) | 0x180001, (0x04 << 24) | 0x77F784}, /* channel 149 */ + {153, (0x00 << 24) | 0x0FF600, (0x01 << 24) | 0x02AAA1, (0x04 << 24) | 0x77F784}, /* channel 153 */ + {157, (0x00 << 24) | 0x0FF600, (0x01 << 24) | 0x0D5551, (0x04 << 24) | 0x77F784}, /* channel 157 */ + {161, (0x00 << 24) | 0x0FF610, (0x01 << 24) | 0x180001, (0x04 << 24) | 0x77F784}, /* channel 161 */ + {165, (0x00 << 24) | 0x0FF610, (0x01 << 24) | 0x02AAA1, (0x04 << 24) | 0x77F784} /* channel 165 */ }; -//; RF Calibration <=== Register 0x0F -//0x0F 0x1ABA8F; start from 2.4Ghz default state -//0x0F 0x9ABA8F; TXDC compensation -//0x0F 0x3ABA8F; RXFIL adjustment -//0x0F 0x1ABA8F; restore 2.4Ghz default state - -//;TXVGA Mapping Table <=== Register 0x0B -u32 al7230_txvga_data[][2] = -{ - {0x08040B, 0}, //TXVGA=0; - {0x08041B, 1}, //TXVGA=1; - {0x08042B, 2}, //TXVGA=2; - {0x08043B, 3}, //TXVGA=3; - {0x08044B, 4}, //TXVGA=4; - {0x08045B, 5}, //TXVGA=5; - {0x08046B, 6}, //TXVGA=6; - {0x08047B, 7}, //TXVGA=7; - {0x08048B, 8}, //TXVGA=8; - {0x08049B, 9}, //TXVGA=9; - {0x0804AB, 10}, //TXVGA=10; - {0x0804BB, 11}, //TXVGA=11; - {0x0804CB, 12}, //TXVGA=12; - {0x0804DB, 13}, //TXVGA=13; - {0x0804EB, 14}, //TXVGA=14; - {0x0804FB, 15}, //TXVGA=15; - {0x08050B, 16}, //TXVGA=16; - {0x08051B, 17}, //TXVGA=17; - {0x08052B, 18}, //TXVGA=18; - {0x08053B, 19}, //TXVGA=19; - {0x08054B, 20}, //TXVGA=20; - {0x08055B, 21}, //TXVGA=21; - {0x08056B, 22}, //TXVGA=22; - {0x08057B, 23}, //TXVGA=23; - {0x08058B, 24}, //TXVGA=24; - {0x08059B, 25}, //TXVGA=25; - {0x0805AB, 26}, //TXVGA=26; - {0x0805BB, 27}, //TXVGA=27; - {0x0805CB, 28}, //TXVGA=28; - {0x0805DB, 29}, //TXVGA=29; - {0x0805EB, 30}, //TXVGA=30; - {0x0805FB, 31}, //TXVGA=31; - {0x08060B, 32}, //TXVGA=32; - {0x08061B, 33}, //TXVGA=33; - {0x08062B, 34}, //TXVGA=34; - {0x08063B, 35}, //TXVGA=35; - {0x08064B, 36}, //TXVGA=36; - {0x08065B, 37}, //TXVGA=37; - {0x08066B, 38}, //TXVGA=38; - {0x08067B, 39}, //TXVGA=39; - {0x08068B, 40}, //TXVGA=40; - {0x08069B, 41}, //TXVGA=41; - {0x0806AB, 42}, //TXVGA=42; - {0x0806BB, 43}, //TXVGA=43; - {0x0806CB, 44}, //TXVGA=44; - {0x0806DB, 45}, //TXVGA=45; - {0x0806EB, 46}, //TXVGA=46; - {0x0806FB, 47}, //TXVGA=47; - {0x08070B, 48}, //TXVGA=48; - {0x08071B, 49}, //TXVGA=49; - {0x08072B, 50}, //TXVGA=50; - {0x08073B, 51}, //TXVGA=51; - {0x08074B, 52}, //TXVGA=52; - {0x08075B, 53}, //TXVGA=53; - {0x08076B, 54}, //TXVGA=54; - {0x08077B, 55}, //TXVGA=55; - {0x08078B, 56}, //TXVGA=56; - {0x08079B, 57}, //TXVGA=57; - {0x0807AB, 58}, //TXVGA=58; - {0x0807BB, 59}, //TXVGA=59; - {0x0807CB, 60}, //TXVGA=60; - {0x0807DB, 61}, //TXVGA=61; - {0x0807EB, 62}, //TXVGA=62; - {0x0807FB, 63}, //TXVGA=63; +/* + * RF Calibration <=== Register 0x0F + * 0x0F 0x1ABA8F; start from 2.4Ghz default state + * 0x0F 0x9ABA8F; TXDC compensation + * 0x0F 0x3ABA8F; RXFIL adjustment + * 0x0F 0x1ABA8F; restore 2.4Ghz default state + */ + +/* TXVGA Mapping Table <=== Register 0x0B */ +u32 al7230_txvga_data[][2] = { + {0x08040B, 0}, /* TXVGA = 0; */ + {0x08041B, 1}, /* TXVGA = 1; */ + {0x08042B, 2}, /* TXVGA = 2; */ + {0x08043B, 3}, /* TXVGA = 3; */ + {0x08044B, 4}, /* TXVGA = 4; */ + {0x08045B, 5}, /* TXVGA = 5; */ + {0x08046B, 6}, /* TXVGA = 6; */ + {0x08047B, 7}, /* TXVGA = 7; */ + {0x08048B, 8}, /* TXVGA = 8; */ + {0x08049B, 9}, /* TXVGA = 9; */ + {0x0804AB, 10}, /* TXVGA = 10; */ + {0x0804BB, 11}, /* TXVGA = 11; */ + {0x0804CB, 12}, /* TXVGA = 12; */ + {0x0804DB, 13}, /* TXVGA = 13; */ + {0x0804EB, 14}, /* TXVGA = 14; */ + {0x0804FB, 15}, /* TXVGA = 15; */ + {0x08050B, 16}, /* TXVGA = 16; */ + {0x08051B, 17}, /* TXVGA = 17; */ + {0x08052B, 18}, /* TXVGA = 18; */ + {0x08053B, 19}, /* TXVGA = 19; */ + {0x08054B, 20}, /* TXVGA = 20; */ + {0x08055B, 21}, /* TXVGA = 21; */ + {0x08056B, 22}, /* TXVGA = 22; */ + {0x08057B, 23}, /* TXVGA = 23; */ + {0x08058B, 24}, /* TXVGA = 24; */ + {0x08059B, 25}, /* TXVGA = 25; */ + {0x0805AB, 26}, /* TXVGA = 26; */ + {0x0805BB, 27}, /* TXVGA = 27; */ + {0x0805CB, 28}, /* TXVGA = 28; */ + {0x0805DB, 29}, /* TXVGA = 29; */ + {0x0805EB, 30}, /* TXVGA = 30; */ + {0x0805FB, 31}, /* TXVGA = 31; */ + {0x08060B, 32}, /* TXVGA = 32; */ + {0x08061B, 33}, /* TXVGA = 33; */ + {0x08062B, 34}, /* TXVGA = 34; */ + {0x08063B, 35}, /* TXVGA = 35; */ + {0x08064B, 36}, /* TXVGA = 36; */ + {0x08065B, 37}, /* TXVGA = 37; */ + {0x08066B, 38}, /* TXVGA = 38; */ + {0x08067B, 39}, /* TXVGA = 39; */ + {0x08068B, 40}, /* TXVGA = 40; */ + {0x08069B, 41}, /* TXVGA = 41; */ + {0x0806AB, 42}, /* TXVGA = 42; */ + {0x0806BB, 43}, /* TXVGA = 43; */ + {0x0806CB, 44}, /* TXVGA = 44; */ + {0x0806DB, 45}, /* TXVGA = 45; */ + {0x0806EB, 46}, /* TXVGA = 46; */ + {0x0806FB, 47}, /* TXVGA = 47; */ + {0x08070B, 48}, /* TXVGA = 48; */ + {0x08071B, 49}, /* TXVGA = 49; */ + {0x08072B, 50}, /* TXVGA = 50; */ + {0x08073B, 51}, /* TXVGA = 51; */ + {0x08074B, 52}, /* TXVGA = 52; */ + {0x08075B, 53}, /* TXVGA = 53; */ + {0x08076B, 54}, /* TXVGA = 54; */ + {0x08077B, 55}, /* TXVGA = 55; */ + {0x08078B, 56}, /* TXVGA = 56; */ + {0x08079B, 57}, /* TXVGA = 57; */ + {0x0807AB, 58}, /* TXVGA = 58; */ + {0x0807BB, 59}, /* TXVGA = 59; */ + {0x0807CB, 60}, /* TXVGA = 60; */ + {0x0807DB, 61}, /* TXVGA = 61; */ + {0x0807EB, 62}, /* TXVGA = 62; */ + {0x0807FB, 63}, /* TXVGA = 63; */ }; -//-------------------------------- - +/* ============================================= */ -//; W89RF242 RFIC SPI programming initial data -//; Winbond WLAN 11g RFIC BB-SPI register -- version FA5976A rev 1.3b -//; Update Date: Ocotber 3, 2005 by PP10 Hsiang-Te Ho -//; -//; Version 1.3b revision items: (Oct. 1, 2005 by HTHo) for FA5976A -u32 w89rf242_rf_data[] = -{ - (0x00<<24)|0xF86100, // 20060721 0xF86100, //; 3E184; MODA (0x00) -- Normal mode ; calibration off - (0x01<<24)|0xEFFFC2, //; 3BFFF; MODB (0x01) -- turn off RSSI, and other circuits are turned on - (0x02<<24)|0x102504, //; 04094; FSET (0x02) -- default 20MHz crystal ; Icmp=1.5mA - (0x03<<24)|0x026286, //; 0098A; FCHN (0x03) -- default CH7, 2442MHz - (0x04<<24)|0x000208, // 20060612.1.a 0x0002C8, // 20050818 // 20050816 0x000388 - //; 02008; FCAL (0x04) -- XTAL Freq Trim=001000 (socket board#1); FA5976AYG_v1.3C - (0x05<<24)|0x24C60A, // 20060612.1.a 0x24C58A, // 941003 0x24C48A, // 20050818.2 0x24848A, // 20050818 // 20050816 0x24C48A - //; 09316; GANA (0x05) -- TX VGA default (TXVGA=0x18(12)) & TXGPK=110 ; FA5976A_1.3D - (0x06<<24)|0x3432CC, // 941003 0x26C34C, // 20050818 0x06B40C - //; 0D0CB; GANB (0x06) -- RXDC(DC offset) on; LNA=11; RXVGA=001011(11) ; RXFLSW=11(010001); RXGPK=00; RXGCF=00; -50dBm input - (0x07<<24)|0x0C68CE, // 20050818.2 0x0C66CE, // 20050818 // 20050816 0x0C68CE - //; 031A3; FILT (0x07) -- TX/RX filter with auto-tuning; TFLBW=011; RFLBW=100 - (0x08<<24)|0x100010, //; 04000; TCAL (0x08) -- //for LO - (0x09<<24)|0x004012, // 20060612.1.a 0x6E4012, // 0x004012, - //; 1B900; RCALA (0x09) -- FASTS=11; HPDE=01 (100nsec); SEHP=1 (select B0 pin=RXHP); RXHP=1 (Turn on RXHP function)(FA5976A_1.3C) - (0x0A<<24)|0x704014, //; 1C100; RCALB (0x0A) - (0x0B<<24)|0x18BDD6, // 941003 0x1805D6, // 20050818.2 0x1801D6, // 20050818 // 20050816 0x1805D6 - //; 062F7; IQCAL (0x0B) -- Turn on LO phase tuner=0111 & RX-LO phase = 0111; FA5976A_1.3B (2005/09/29) - (0x0C<<24)|0x575558, // 20050818.2 0x555558, // 20050818 // 20050816 0x575558 - //; 15D55 ; IBSA (0x0C) -- IFPre =11 ; TC5376A_v1.3A for corner - (0x0D<<24)|0x55545A, // 20060612.1.a 0x55555A, - //; 15555 ; IBSB (0x0D) - (0x0E<<24)|0x5557DC, // 20060612.1.a 0x55555C, // 941003 0x5557DC, - //; 1555F ; IBSC (0x0E) -- IRLNA & IRLNB (PTAT & Const current)=01/01; FA5976B_1.3F (2005/11/25) - (0x10<<24)|0x000C20, // 941003 0x000020, // 20050818 - //; 00030 ; TMODA (0x10) -- LNA_gain_step=0011 ; LNA=15/16dB - (0x11<<24)|0x0C0022, // 941003 0x030022 // 20050818.2 0x030022 // 20050818 // 20050816 0x0C0022 - //; 03000 ; TMODB (0x11) -- Turn ON RX-Q path Test Switch; To improve IQ path group delay (FA5976A_1.3C) - (0x12<<24)|0x000024 // 20060612.1.a 0x001824 // 941003 add - //; TMODC (0x12) -- Turn OFF Tempearure sensor +/* + * W89RF242 RFIC SPI programming initial data + * Winbond WLAN 11g RFIC BB-SPI register -- version FA5976A rev 1.3b + */ +u32 w89rf242_rf_data[] = { + (0x00 << 24) | 0xF86100, /* 3E184; MODA (0x00) -- Normal mode ; calibration off */ + (0x01 << 24) | 0xEFFFC2, /* 3BFFF; MODB (0x01) -- turn off RSSI, and other circuits are turned on */ + (0x02 << 24) | 0x102504, /* 04094; FSET (0x02) -- default 20MHz crystal ; Icmp=1.5mA */ + (0x03 << 24) | 0x026286, /* 0098A; FCHN (0x03) -- default CH7, 2442MHz */ + (0x04 << 24) | 0x000208, /* 02008; FCAL (0x04) -- XTAL Freq Trim=001000 (socket board#1); FA5976AYG_v1.3C */ + (0x05 << 24) | 0x24C60A, /* 09316; GANA (0x05) -- TX VGA default (TXVGA=0x18(12)) & TXGPK=110 ; FA5976A_1.3D */ + (0x06 << 24) | 0x3432CC, /* 0D0CB; GANB (0x06) -- RXDC(DC offset) on; LNA=11; RXVGA=001011(11) ; RXFLSW=11(010001); RXGPK=00; RXGCF=00; -50dBm input */ + (0x07 << 24) | 0x0C68CE, /* 031A3; FILT (0x07) -- TX/RX filter with auto-tuning; TFLBW=011; RFLBW=100 */ + (0x08 << 24) | 0x100010, /* 04000; TCAL (0x08) -- for LO */ + (0x09 << 24) | 0x004012, /* 1B900; RCALA (0x09) -- FASTS=11; HPDE=01 (100nsec); SEHP=1 (select B0 pin=RXHP); RXHP=1 (Turn on RXHP function)(FA5976A_1.3C) */ + (0x0A << 24) | 0x704014, /* 1C100; RCALB (0x0A) */ + (0x0B << 24) | 0x18BDD6, /* 062F7; IQCAL (0x0B) -- Turn on LO phase tuner=0111 & RX-LO phase = 0111; FA5976A_1.3B */ + (0x0C << 24) | 0x575558, /* 15D55 ; IBSA (0x0C) -- IFPre =11 ; TC5376A_v1.3A for corner */ + (0x0D << 24) | 0x55545A, /* 15555 ; IBSB (0x0D) */ + (0x0E << 24) | 0x5557DC, /* 1555F ; IBSC (0x0E) -- IRLNA & IRLNB (PTAT & Const current)=01/01; FA5976B_1.3F */ + (0x10 << 24) | 0x000C20, /* 00030 ; TMODA (0x10) -- LNA_gain_step=0011 ; LNA=15/16dB */ + (0x11 << 24) | 0x0C0022, /* 03000 ; TMODB (0x11) -- Turn ON RX-Q path Test Switch; To improve IQ path group delay (FA5976A_1.3C) */ + (0x12 << 24) | 0x000024 /* TMODC (0x12) -- Turn OFF Tempearure sensor */ }; -u32 w89rf242_channel_data_24[][2] = -{ - {(0x03<<24)|0x025B06, (0x04<<24)|0x080408}, // channe1 01 - {(0x03<<24)|0x025C46, (0x04<<24)|0x080408}, // channe1 02 - {(0x03<<24)|0x025D86, (0x04<<24)|0x080408}, // channe1 03 - {(0x03<<24)|0x025EC6, (0x04<<24)|0x080408}, // channe1 04 - {(0x03<<24)|0x026006, (0x04<<24)|0x080408}, // channe1 05 - {(0x03<<24)|0x026146, (0x04<<24)|0x080408}, // channe1 06 - {(0x03<<24)|0x026286, (0x04<<24)|0x080408}, // channe1 07 - {(0x03<<24)|0x0263C6, (0x04<<24)|0x080408}, // channe1 08 - {(0x03<<24)|0x026506, (0x04<<24)|0x080408}, // channe1 09 - {(0x03<<24)|0x026646, (0x04<<24)|0x080408}, // channe1 10 - {(0x03<<24)|0x026786, (0x04<<24)|0x080408}, // channe1 11 - {(0x03<<24)|0x0268C6, (0x04<<24)|0x080408}, // channe1 12 - {(0x03<<24)|0x026A06, (0x04<<24)|0x080408}, // channe1 13 - {(0x03<<24)|0x026D06, (0x04<<24)|0x080408} // channe1 14 +u32 w89rf242_channel_data_24[][2] = { + {(0x03 << 24) | 0x025B06, (0x04 << 24) | 0x080408}, /* channe1 01 */ + {(0x03 << 24) | 0x025C46, (0x04 << 24) | 0x080408}, /* channe1 02 */ + {(0x03 << 24) | 0x025D86, (0x04 << 24) | 0x080408}, /* channe1 03 */ + {(0x03 << 24) | 0x025EC6, (0x04 << 24) | 0x080408}, /* channe1 04 */ + {(0x03 << 24) | 0x026006, (0x04 << 24) | 0x080408}, /* channe1 05 */ + {(0x03 << 24) | 0x026146, (0x04 << 24) | 0x080408}, /* channe1 06 */ + {(0x03 << 24) | 0x026286, (0x04 << 24) | 0x080408}, /* channe1 07 */ + {(0x03 << 24) | 0x0263C6, (0x04 << 24) | 0x080408}, /* channe1 08 */ + {(0x03 << 24) | 0x026506, (0x04 << 24) | 0x080408}, /* channe1 09 */ + {(0x03 << 24) | 0x026646, (0x04 << 24) | 0x080408}, /* channe1 10 */ + {(0x03 << 24) | 0x026786, (0x04 << 24) | 0x080408}, /* channe1 11 */ + {(0x03 << 24) | 0x0268C6, (0x04 << 24) | 0x080408}, /* channe1 12 */ + {(0x03 << 24) | 0x026A06, (0x04 << 24) | 0x080408}, /* channe1 13 */ + {(0x03 << 24) | 0x026D06, (0x04 << 24) | 0x080408} /* channe1 14 */ }; -u32 w89rf242_power_data_24[] = {(0x05<<24)|0x24C48A, (0x05<<24)|0x24C48A, (0x05<<24)|0x24C48A}; +u32 w89rf242_power_data_24[] = {(0x05 << 24) | 0x24C48A, (0x05 << 24) | 0x24C48A, (0x05 << 24) | 0x24C48A}; -// 20060315.6 Enlarge for new scale -// 20060316.6 20060619.2.a add mapping array -u32 w89rf242_txvga_old_mapping[][2] = -{ - {0, 0} , // New <-> Old +u32 w89rf242_txvga_old_mapping[][2] = { + {0, 0} , /* New <-> Old */ {1, 1} , {2, 2} , {3, 3} , {4, 4} , {6, 5} , - {8, 6 }, - {10, 7 }, - {12, 8 }, - {14, 9 }, + {8, 6}, + {10, 7}, + {12, 8}, + {14, 9}, {16, 10}, {18, 11}, {20, 12}, @@ -818,1704 +735,1514 @@ u32 w89rf242_txvga_old_mapping[][2] = {30, 17}, {32, 18}, {34, 19}, +}; +u32 w89rf242_txvga_data[][5] = { + /* low gain mode */ + {(0x05 << 24) | 0x24C00A, 0, 0x00292315, 0x0800FEFF, 0x52523131}, /* min gain */ + {(0x05 << 24) | 0x24C80A, 1, 0x00292315, 0x0800FEFF, 0x52523131}, + {(0x05 << 24) | 0x24C04A, 2, 0x00292315, 0x0800FEFF, 0x52523131}, /* (default) +14dBm (ANT) */ + {(0x05 << 24) | 0x24C84A, 3, 0x00292315, 0x0800FEFF, 0x52523131}, -}; + /* TXVGA=0x10 */ + {(0x05 << 24) | 0x24C40A, 4, 0x00292315, 0x0800FEFF, 0x60603838}, + {(0x05 << 24) | 0x24C40A, 5, 0x00262114, 0x0700FEFF, 0x65653B3B}, -// 20060619.3 modify from Bruce's mail -u32 w89rf242_txvga_data[][5] = -{ - //low gain mode - { (0x05<<24)|0x24C00A, 0, 0x00292315, 0x0800FEFF, 0x52523131 },// ; min gain - { (0x05<<24)|0x24C80A, 1, 0x00292315, 0x0800FEFF, 0x52523131 }, - { (0x05<<24)|0x24C04A, 2, 0x00292315, 0x0800FEFF, 0x52523131 },// (default) +14dBm (ANT) - { (0x05<<24)|0x24C84A, 3, 0x00292315, 0x0800FEFF, 0x52523131 }, - - //TXVGA=0x10 - { (0x05<<24)|0x24C40A, 4, 0x00292315, 0x0800FEFF, 0x60603838 }, - { (0x05<<24)|0x24C40A, 5, 0x00262114, 0x0700FEFF, 0x65653B3B }, - - //TXVGA=0x11 - { (0x05<<24)|0x24C44A, 6, 0x00241F13, 0x0700FFFF, 0x58583333 }, - { (0x05<<24)|0x24C44A, 7, 0x00292315, 0x0800FEFF, 0x5E5E3737 }, - - //TXVGA=0x12 - { (0x05<<24)|0x24C48A, 8, 0x00262114, 0x0700FEFF, 0x53533030 }, - { (0x05<<24)|0x24C48A, 9, 0x00241F13, 0x0700FFFF, 0x59593434 }, - - //TXVGA=0x13 - { (0x05<<24)|0x24C4CA, 10, 0x00292315, 0x0800FEFF, 0x52523030 }, - { (0x05<<24)|0x24C4CA, 11, 0x00262114, 0x0700FEFF, 0x56563232 }, - - //TXVGA=0x14 - { (0x05<<24)|0x24C50A, 12, 0x00292315, 0x0800FEFF, 0x54543131 }, - { (0x05<<24)|0x24C50A, 13, 0x00262114, 0x0700FEFF, 0x58583434 }, - - //TXVGA=0x15 - { (0x05<<24)|0x24C54A, 14, 0x00292315, 0x0800FEFF, 0x54543131 }, - { (0x05<<24)|0x24C54A, 15, 0x00262114, 0x0700FEFF, 0x59593434 }, - - //TXVGA=0x16 - { (0x05<<24)|0x24C58A, 16, 0x00292315, 0x0800FEFF, 0x55553131 }, - { (0x05<<24)|0x24C58A, 17, 0x00292315, 0x0800FEFF, 0x5B5B3535 }, - - //TXVGA=0x17 - { (0x05<<24)|0x24C5CA, 18, 0x00262114, 0x0700FEFF, 0x51512F2F }, - { (0x05<<24)|0x24C5CA, 19, 0x00241F13, 0x0700FFFF, 0x55553131 }, - - //TXVGA=0x18 - { (0x05<<24)|0x24C60A, 20, 0x00292315, 0x0800FEFF, 0x4F4F2E2E }, - { (0x05<<24)|0x24C60A, 21, 0x00262114, 0x0700FEFF, 0x53533030 }, - - //TXVGA=0x19 - { (0x05<<24)|0x24C64A, 22, 0x00292315, 0x0800FEFF, 0x4E4E2D2D }, - { (0x05<<24)|0x24C64A, 23, 0x00262114, 0x0700FEFF, 0x53533030 }, - - //TXVGA=0x1A - { (0x05<<24)|0x24C68A, 24, 0x00292315, 0x0800FEFF, 0x50502E2E }, - { (0x05<<24)|0x24C68A, 25, 0x00262114, 0x0700FEFF, 0x55553131 }, - - //TXVGA=0x1B - { (0x05<<24)|0x24C6CA, 26, 0x00262114, 0x0700FEFF, 0x53533030 }, - { (0x05<<24)|0x24C6CA, 27, 0x00292315, 0x0800FEFF, 0x5A5A3434 }, - - //TXVGA=0x1C - { (0x05<<24)|0x24C70A, 28, 0x00292315, 0x0800FEFF, 0x55553131 }, - { (0x05<<24)|0x24C70A, 29, 0x00292315, 0x0800FEFF, 0x5D5D3636 }, - - //TXVGA=0x1D - { (0x05<<24)|0x24C74A, 30, 0x00292315, 0x0800FEFF, 0x5F5F3737 }, - { (0x05<<24)|0x24C74A, 31, 0x00262114, 0x0700FEFF, 0x65653B3B }, - - //TXVGA=0x1E - { (0x05<<24)|0x24C78A, 32, 0x00292315, 0x0800FEFF, 0x66663B3B }, - { (0x05<<24)|0x24C78A, 33, 0x00262114, 0x0700FEFF, 0x70704141 }, - - //TXVGA=0x1F - { (0x05<<24)|0x24C7CA, 34, 0x00292315, 0x0800FEFF, 0x72724242 } + /* TXVGA=0x11 */ + { (0x05 << 24) | 0x24C44A, 6, 0x00241F13, 0x0700FFFF, 0x58583333}, + { (0x05 << 24) | 0x24C44A, 7, 0x00292315, 0x0800FEFF, 0x5E5E3737}, + + /* TXVGA=0x12 */ + {(0x05 << 24) | 0x24C48A, 8, 0x00262114, 0x0700FEFF, 0x53533030}, + {(0x05 << 24) | 0x24C48A, 9, 0x00241F13, 0x0700FFFF, 0x59593434}, + + /* TXVGA=0x13 */ + {(0x05 << 24) | 0x24C4CA, 10, 0x00292315, 0x0800FEFF, 0x52523030}, + {(0x05 << 24) | 0x24C4CA, 11, 0x00262114, 0x0700FEFF, 0x56563232}, + + /* TXVGA=0x14 */ + {(0x05 << 24) | 0x24C50A, 12, 0x00292315, 0x0800FEFF, 0x54543131}, + {(0x05 << 24) | 0x24C50A, 13, 0x00262114, 0x0700FEFF, 0x58583434}, + + /* TXVGA=0x15 */ + {(0x05 << 24) | 0x24C54A, 14, 0x00292315, 0x0800FEFF, 0x54543131}, + {(0x05 << 24) | 0x24C54A, 15, 0x00262114, 0x0700FEFF, 0x59593434}, + + /* TXVGA=0x16 */ + {(0x05 << 24) | 0x24C58A, 16, 0x00292315, 0x0800FEFF, 0x55553131}, + {(0x05 << 24) | 0x24C58A, 17, 0x00292315, 0x0800FEFF, 0x5B5B3535}, + + /* TXVGA=0x17 */ + {(0x05 << 24) | 0x24C5CA, 18, 0x00262114, 0x0700FEFF, 0x51512F2F}, + {(0x05 << 24) | 0x24C5CA, 19, 0x00241F13, 0x0700FFFF, 0x55553131}, + + /* TXVGA=0x18 */ + {(0x05 << 24) | 0x24C60A, 20, 0x00292315, 0x0800FEFF, 0x4F4F2E2E}, + {(0x05 << 24) | 0x24C60A, 21, 0x00262114, 0x0700FEFF, 0x53533030}, + + /* TXVGA=0x19 */ + {(0x05 << 24) | 0x24C64A, 22, 0x00292315, 0x0800FEFF, 0x4E4E2D2D}, + {(0x05 << 24) | 0x24C64A, 23, 0x00262114, 0x0700FEFF, 0x53533030}, + + /* TXVGA=0x1A */ + {(0x05 << 24) | 0x24C68A, 24, 0x00292315, 0x0800FEFF, 0x50502E2E}, + {(0x05 << 24) | 0x24C68A, 25, 0x00262114, 0x0700FEFF, 0x55553131}, + + /* TXVGA=0x1B */ + {(0x05 << 24) | 0x24C6CA, 26, 0x00262114, 0x0700FEFF, 0x53533030}, + {(0x05 << 24) | 0x24C6CA, 27, 0x00292315, 0x0800FEFF, 0x5A5A3434}, + + /* TXVGA=0x1C */ + {(0x05 << 24) | 0x24C70A, 28, 0x00292315, 0x0800FEFF, 0x55553131}, + {(0x05 << 24) | 0x24C70A, 29, 0x00292315, 0x0800FEFF, 0x5D5D3636}, + + /* TXVGA=0x1D */ + {(0x05 << 24) | 0x24C74A, 30, 0x00292315, 0x0800FEFF, 0x5F5F3737}, + {(0x05 << 24) | 0x24C74A, 31, 0x00262114, 0x0700FEFF, 0x65653B3B}, + + /* TXVGA=0x1E */ + {(0x05 << 24) | 0x24C78A, 32, 0x00292315, 0x0800FEFF, 0x66663B3B}, + {(0x05 << 24) | 0x24C78A, 33, 0x00262114, 0x0700FEFF, 0x70704141}, + + /* TXVGA=0x1F */ + {(0x05 << 24) | 0x24C7CA, 34, 0x00292315, 0x0800FEFF, 0x72724242} }; -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////////////////////////// - - - -//============================================================================================================= -// Uxx_ReadEthernetAddress -- -// -// Routine Description: -// Reads in the Ethernet address from the IC. -// -// Arguments: -// pHwData - The pHwData structure -// -// Return Value: -// -// The address is stored in EthernetIDAddr. -//============================================================================================================= -void -Uxx_ReadEthernetAddress( struct hw_data * pHwData ) +/* ================================================================================================== */ + + + +/* + * ============================================================================================================= + * Uxx_ReadEthernetAddress -- + * + * Routine Description: + * Reads in the Ethernet address from the IC. + * + * Arguments: + * pHwData - The pHwData structure + * + * Return Value: + * + * The address is stored in EthernetIDAddr. + * ============================================================================================================= + */ +void Uxx_ReadEthernetAddress(struct hw_data *pHwData) { u32 ltmp; - // Reading Ethernet address from EEPROM and set into hardware due to MAC address maybe change. - // Only unplug and plug again can make hardware read EEPROM again. 20060727 - Wb35Reg_WriteSync( pHwData, 0x03b4, 0x08000000 ); // Start EEPROM access + Read + address(0x0d) - Wb35Reg_ReadSync( pHwData, 0x03b4, <mp ); - *(u16 *)pHwData->PermanentMacAddress = cpu_to_le16((u16)ltmp); //20060926 anson's endian - Wb35Reg_WriteSync( pHwData, 0x03b4, 0x08010000 ); // Start EEPROM access + Read + address(0x0d) - Wb35Reg_ReadSync( pHwData, 0x03b4, <mp ); - *(u16 *)(pHwData->PermanentMacAddress + 2) = cpu_to_le16((u16)ltmp); //20060926 anson's endian - Wb35Reg_WriteSync( pHwData, 0x03b4, 0x08020000 ); // Start EEPROM access + Read + address(0x0d) - Wb35Reg_ReadSync( pHwData, 0x03b4, <mp ); - *(u16 *)(pHwData->PermanentMacAddress + 4) = cpu_to_le16((u16)ltmp); //20060926 anson's endian + /* + * Reading Ethernet address from EEPROM and set into hardware due to MAC address maybe change. + * Only unplug and plug again can make hardware read EEPROM again. + */ + Wb35Reg_WriteSync(pHwData, 0x03b4, 0x08000000); /* Start EEPROM access + Read + address(0x0d) */ + Wb35Reg_ReadSync(pHwData, 0x03b4, <mp); + *(u16 *)pHwData->PermanentMacAddress = cpu_to_le16((u16) ltmp); + Wb35Reg_WriteSync(pHwData, 0x03b4, 0x08010000); /* Start EEPROM access + Read + address(0x0d) */ + Wb35Reg_ReadSync(pHwData, 0x03b4, <mp); + *(u16 *)(pHwData->PermanentMacAddress + 2) = cpu_to_le16((u16) ltmp); + Wb35Reg_WriteSync(pHwData, 0x03b4, 0x08020000); /* Start EEPROM access + Read + address(0x0d) */ + Wb35Reg_ReadSync(pHwData, 0x03b4, <mp); + *(u16 *)(pHwData->PermanentMacAddress + 4) = cpu_to_le16((u16) ltmp); *(u16 *)(pHwData->PermanentMacAddress + 6) = 0; - Wb35Reg_WriteSync( pHwData, 0x03e8, cpu_to_le32(*(u32 *)pHwData->PermanentMacAddress) ); //20060926 anson's endian - Wb35Reg_WriteSync( pHwData, 0x03ec, cpu_to_le32(*(u32 *)(pHwData->PermanentMacAddress+4)) ); //20060926 anson's endian + Wb35Reg_WriteSync(pHwData, 0x03e8, cpu_to_le32(*(u32 *)pHwData->PermanentMacAddress)); + Wb35Reg_WriteSync(pHwData, 0x03ec, cpu_to_le32(*(u32 *)(pHwData->PermanentMacAddress + 4))); } -//=============================================================================================================== -// CardGetMulticastBit -- -// Description: -// For a given multicast address, returns the byte and bit in the card multicast registers that it hashes to. -// Calls CardComputeCrc() to determine the CRC value. -// Arguments: -// Address - the address -// Byte - the byte that it hashes to -// Value - will have a 1 in the relevant bit -// Return Value: -// None. -//============================================================================================================== -void CardGetMulticastBit( u8 Address[ETH_ALEN], u8 *Byte, u8 *Value ) +/* + * =============================================================================================================== + * CardGetMulticastBit -- + * Description: + * For a given multicast address, returns the byte and bit in the card multicast registers that it hashes to. + * Calls CardComputeCrc() to determine the CRC value. + * Arguments: + * Address - the address + * Byte - the byte that it hashes to + * Value - will have a 1 in the relevant bit + * Return Value: + * None. + * ============================================================================================================== + */ +void CardGetMulticastBit(u8 Address[ETH_ALEN], u8 *Byte, u8 *Value) { - u32 Crc; - u32 BitNumber; + u32 Crc; + u32 BitNumber; - // First compute the CRC. - Crc = CardComputeCrc(Address, ETH_ALEN); + /* First compute the CRC. */ + Crc = CardComputeCrc(Address, ETH_ALEN); - // The computed CRC is bit0~31 from left to right - //At first we should do right shift 25bits, and read 7bits by using '&', 2^7=128 + /* The computed CRC is bit0~31 from left to right */ + /* At first we should do right shift 25bits, and read 7bits by using '&', 2^7=128 */ BitNumber = (u32) ((Crc >> 26) & 0x3f); - *Byte = (u8) (BitNumber >> 3);// 900514 original (BitNumber / 8) - *Value = (u8) ((u8)1 << (BitNumber % 8)); + *Byte = (u8) (BitNumber >> 3); /* 900514 original (BitNumber / 8) */ + *Value = (u8) ((u8) 1 << (BitNumber % 8)); } -void Uxx_power_on_procedure( struct hw_data * pHwData ) +void Uxx_power_on_procedure(struct hw_data *pHwData) { u32 ltmp, loop; - if( pHwData->phy_type <= RF_MAXIM_V1 ) - Wb35Reg_WriteSync( pHwData, 0x03d4, 0xffffff38 ); - else - { - Wb35Reg_WriteSync( pHwData, 0x03f4, 0xFF5807FF );// 20060721 For NEW IC 0xFF5807FF - - // 20060511.1 Fix the following 4 steps for Rx of RF 2230 initial fail - Wb35Reg_WriteSync( pHwData, 0x03d4, 0x80 );// regulator on only - msleep(10); // Modify 20051221.1.b - Wb35Reg_WriteSync( pHwData, 0x03d4, 0xb8 );// REG_ON RF_RSTN on, and - msleep(10); // Modify 20051221.1.b - + if (pHwData->phy_type <= RF_MAXIM_V1) + Wb35Reg_WriteSync(pHwData, 0x03d4, 0xffffff38); + else { + Wb35Reg_WriteSync(pHwData, 0x03f4, 0xFF5807FF); + Wb35Reg_WriteSync(pHwData, 0x03d4, 0x80); /* regulator on only */ + msleep(10); + Wb35Reg_WriteSync(pHwData, 0x03d4, 0xb8); /* REG_ON RF_RSTN on, and */ + msleep(10); ltmp = 0x4968; - if( (pHwData->phy_type == RF_WB_242) || - (RF_WB_242_1 == pHwData->phy_type) ) // 20060619.5 Add + if ((pHwData->phy_type == RF_WB_242) || + (RF_WB_242_1 == pHwData->phy_type)) ltmp = 0x4468; - Wb35Reg_WriteSync( pHwData, 0x03d0, ltmp ); - Wb35Reg_WriteSync( pHwData, 0x03d4, 0xa0 );// PLL_PD REF_PD set to 0 + Wb35Reg_WriteSync(pHwData, 0x03d0, ltmp); + Wb35Reg_WriteSync(pHwData, 0x03d4, 0xa0); /* PLL_PD REF_PD set to 0 */ - msleep(20); // Modify 20051221.1.b - Wb35Reg_ReadSync( pHwData, 0x03d0, <mp ); - loop = 500; // Wait for 5 second 20061101 - while( !(ltmp & 0x20) && loop-- ) - { - msleep(10); // Modify 20051221.1.b - if( !Wb35Reg_ReadSync( pHwData, 0x03d0, <mp ) ) + msleep(20); + Wb35Reg_ReadSync(pHwData, 0x03d0, <mp); + loop = 500; /* Wait for 5 second */ + while (!(ltmp & 0x20) && loop--) { + msleep(10); + if (!Wb35Reg_ReadSync(pHwData, 0x03d0, <mp)) break; } - Wb35Reg_WriteSync( pHwData, 0x03d4, 0xe0 );// MLK_EN + Wb35Reg_WriteSync(pHwData, 0x03d4, 0xe0); /* MLK_EN */ } - Wb35Reg_WriteSync( pHwData, 0x03b0, 1 );// Reset hardware first - msleep(10); // Add this 20051221.1.b + Wb35Reg_WriteSync(pHwData, 0x03b0, 1); /* Reset hardware first */ + msleep(10); - // Set burst write delay - Wb35Reg_WriteSync( pHwData, 0x03f8, 0x7ff ); + /* Set burst write delay */ + Wb35Reg_WriteSync(pHwData, 0x03f8, 0x7ff); } -void Set_ChanIndep_RfData_al7230_24( struct hw_data * pHwData, u32 *pltmp ,char number) +void Set_ChanIndep_RfData_al7230_24(struct hw_data *pHwData, u32 *pltmp , char number) { u8 i; - for( i=0; i<number; i++ ) - { + for (i = 0; i < number; i++) { pHwData->phy_para[i] = al7230_rf_data_24[i]; - pltmp[i] = (1 << 31) | (0 << 30) | (24 << 24) | (al7230_rf_data_24[i]&0xffffff); + pltmp[i] = (1 << 31) | (0 << 30) | (24 << 24) | (al7230_rf_data_24[i] & 0xffffff); } } -void Set_ChanIndep_RfData_al7230_50( struct hw_data * pHwData, u32 *pltmp, char number) +void Set_ChanIndep_RfData_al7230_50(struct hw_data *pHwData, u32 *pltmp, char number) { u8 i; - for( i=0; i<number; i++ ) - { + for (i = 0; i < number; i++) { pHwData->phy_para[i] = al7230_rf_data_50[i]; - pltmp[i] = (1 << 31) | (0 << 30) | (24 << 24) | (al7230_rf_data_50[i]&0xffffff); + pltmp[i] = (1 << 31) | (0 << 30) | (24 << 24) | (al7230_rf_data_50[i] & 0xffffff); } } -//============================================================================================================= -// RFSynthesizer_initial -- -//============================================================================================================= -void -RFSynthesizer_initial(struct hw_data * pHwData) +/* + * ============================================================================================================= + * RFSynthesizer_initial -- + * ============================================================================================================= + */ +void RFSynthesizer_initial(struct hw_data *pHwData) { u32 altmp[32]; - u32 * pltmp = altmp; + u32 *pltmp = altmp; u32 ltmp; - u8 number=0x00; // The number of register vale + u8 number = 0x00; /* The number of register vale */ u8 i; - // - // bit[31] SPI Enable. - // 1=perform synthesizer program operation. This bit will - // cleared automatically after the operation is completed. - // bit[30] SPI R/W Control - // 0=write, 1=read - // bit[29:24] SPI Data Format Length - // bit[17:4 ] RF Data bits. - // bit[3 :0 ] RF address. - switch( pHwData->phy_type ) - { + /* + * bit[31] SPI Enable. + * 1=perform synthesizer program operation. This bit will + * cleared automatically after the operation is completed. + * bit[30] SPI R/W Control + * 0=write, 1=read + * bit[29:24] SPI Data Format Length + * bit[17:4 ] RF Data bits. + * bit[3 :0 ] RF address. + */ + switch (pHwData->phy_type) { case RF_MAXIM_2825: - case RF_MAXIM_V1: // 11g Winbond 2nd BB(with Phy board (v1) + Maxim 331) - number = sizeof(max2825_rf_data)/sizeof(max2825_rf_data[0]); - for( i=0; i<number; i++ ) - { - pHwData->phy_para[i] = max2825_rf_data[i];// Backup Rf parameter - pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( max2825_rf_data[i], 18); + case RF_MAXIM_V1: /* 11g Winbond 2nd BB(with Phy board (v1) + Maxim 331) */ + number = sizeof(max2825_rf_data) / sizeof(max2825_rf_data[0]); + for (i = 0; i < number; i++) { + pHwData->phy_para[i] = max2825_rf_data[i]; /* Backup Rf parameter */ + pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(max2825_rf_data[i], 18); } break; - case RF_MAXIM_2827: - number = sizeof(max2827_rf_data)/sizeof(max2827_rf_data[0]); - for( i=0; i<number; i++ ) - { + number = sizeof(max2827_rf_data) / sizeof(max2827_rf_data[0]); + for (i = 0; i < number; i++) { pHwData->phy_para[i] = max2827_rf_data[i]; - pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( max2827_rf_data[i], 18); + pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(max2827_rf_data[i], 18); } break; - case RF_MAXIM_2828: - number = sizeof(max2828_rf_data)/sizeof(max2828_rf_data[0]); - for( i=0; i<number; i++ ) - { + number = sizeof(max2828_rf_data) / sizeof(max2828_rf_data[0]); + for (i = 0; i < number; i++) { pHwData->phy_para[i] = max2828_rf_data[i]; - pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( max2828_rf_data[i], 18); + pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(max2828_rf_data[i], 18); } break; - case RF_MAXIM_2829: - number = sizeof(max2829_rf_data)/sizeof(max2829_rf_data[0]); - for( i=0; i<number; i++ ) - { + number = sizeof(max2829_rf_data) / sizeof(max2829_rf_data[0]); + for (i = 0; i < number; i++) { pHwData->phy_para[i] = max2829_rf_data[i]; - pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( max2829_rf_data[i], 18); + pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(max2829_rf_data[i], 18); } break; - case RF_AIROHA_2230: - number = sizeof(al2230_rf_data)/sizeof(al2230_rf_data[0]); - for( i=0; i<number; i++ ) - { + number = sizeof(al2230_rf_data) / sizeof(al2230_rf_data[0]); + for (i = 0; i < number; i++) { pHwData->phy_para[i] = al2230_rf_data[i]; - pltmp[i] = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse( al2230_rf_data[i], 20); + pltmp[i] = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse(al2230_rf_data[i], 20); } break; - case RF_AIROHA_2230S: - number = sizeof(al2230s_rf_data)/sizeof(al2230s_rf_data[0]); - for( i=0; i<number; i++ ) - { + number = sizeof(al2230s_rf_data) / sizeof(al2230s_rf_data[0]); + for (i = 0; i < number; i++) { pHwData->phy_para[i] = al2230s_rf_data[i]; - pltmp[i] = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse( al2230s_rf_data[i], 20); + pltmp[i] = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse(al2230s_rf_data[i], 20); } break; - case RF_AIROHA_7230: - - //Start to fill RF parameters, PLL_ON should be pulled low. - Wb35Reg_WriteSync( pHwData, 0x03dc, 0x00000000 ); -#ifdef _PE_STATE_DUMP_ + /* Start to fill RF parameters, PLL_ON should be pulled low. */ + Wb35Reg_WriteSync(pHwData, 0x03dc, 0x00000000); + #ifdef _PE_STATE_DUMP_ printk("* PLL_ON low\n"); -#endif - - number = sizeof(al7230_rf_data_24)/sizeof(al7230_rf_data_24[0]); + #endif + number = sizeof(al7230_rf_data_24) / sizeof(al7230_rf_data_24[0]); Set_ChanIndep_RfData_al7230_24(pHwData, pltmp, number); break; - case RF_WB_242: - case RF_WB_242_1: // 20060619.5 Add - number = sizeof(w89rf242_rf_data)/sizeof(w89rf242_rf_data[0]); - for( i=0; i<number; i++ ) - { + case RF_WB_242_1: + number = sizeof(w89rf242_rf_data) / sizeof(w89rf242_rf_data[0]); + for (i = 0; i < number; i++) { ltmp = w89rf242_rf_data[i]; - if( i == 4 ) // Update the VCO trim from EEPROM - { - ltmp &= ~0xff0; // Mask bit4 ~bit11 - ltmp |= pHwData->VCO_trim<<4; + if (i == 4) { /* Update the VCO trim from EEPROM */ + ltmp &= ~0xff0; /* Mask bit4 ~bit11 */ + ltmp |= pHwData->VCO_trim << 4; } pHwData->phy_para[i] = ltmp; - pltmp[i] = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( ltmp, 24); + pltmp[i] = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse(ltmp, 24); } break; } pHwData->phy_number = number; - // The 16 is the maximum capability of hardware. Here use 12 - if( number > 12 ) { - //Wb35Reg_BurstWrite( pHwData, 0x0864, pltmp, 12, NO_INCREMENT ); - for( i=0; i<12; i++ ) // For Al2230 - Wb35Reg_WriteSync( pHwData, 0x0864, pltmp[i] ); + /* The 16 is the maximum capability of hardware. Here use 12 */ + if (number > 12) { + for (i = 0; i < 12; i++) /* For Al2230 */ + Wb35Reg_WriteSync(pHwData, 0x0864, pltmp[i]); pltmp += 12; number -= 12; } - // Write to register. number must less and equal than 16 - for( i=0; i<number; i++ ) - Wb35Reg_WriteSync( pHwData, 0x864, pltmp[i] ); + /* Write to register. number must less and equal than 16 */ + for (i = 0; i < number; i++) + Wb35Reg_WriteSync(pHwData, 0x864, pltmp[i]); - // 20060630.1 Calibration only 1 time - if( pHwData->CalOneTime ) + /* Calibration only 1 time */ + if (pHwData->CalOneTime) return; pHwData->CalOneTime = 1; - switch( pHwData->phy_type ) - { - case RF_AIROHA_2230: - - // 20060511.1 --- Modifying the follow step for Rx issue----------------- - ltmp = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse( (0x07<<20)|0xE168E, 20); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - msleep(10); - ltmp = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse( al2230_rf_data[7], 20); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - msleep(10); - - case RF_AIROHA_2230S: // 20060420 Add this - - // 20060511.1 --- Modifying the follow step for Rx issue----------------- - Wb35Reg_WriteSync( pHwData, 0x03d4, 0x80 );// regulator on only - msleep(10); // Modify 20051221.1.b - - Wb35Reg_WriteSync( pHwData, 0x03d4, 0xa0 );// PLL_PD REF_PD set to 0 - msleep(10); // Modify 20051221.1.b - - Wb35Reg_WriteSync( pHwData, 0x03d4, 0xe0 );// MLK_EN - Wb35Reg_WriteSync( pHwData, 0x03b0, 1 );// Reset hardware first - msleep(10); // Add this 20051221.1.b - //------------------------------------------------------------------------ - - // The follow code doesn't use the burst-write mode - //phy_set_rf_data(phw_data, 0x0F, (0x0F<<20) | 0xF01A0); //Raise Initial Setting - ltmp = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse( (0x0F<<20) | 0xF01A0, 20); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - - ltmp = pHwData->reg.BB5C & 0xfffff000; - Wb35Reg_WriteSync( pHwData, 0x105c, ltmp ); - pHwData->reg.BB50 |= 0x13;//(MASK_IQCAL_MODE|MASK_CALIB_START);//20060315.1 modify - Wb35Reg_WriteSync(pHwData, 0x1050, pHwData->reg.BB50); - msleep(5); - - //phy_set_rf_data(phw_data, 0x0F, (0x0F<<20) | 0xF01B0); //Activate Filter Cal. - ltmp = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse( (0x0F<<20) | 0xF01B0, 20); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - msleep(5); - - //phy_set_rf_data(phw_data, 0x0F, (0x0F<<20) | 0xF01e0); //Activate TX DCC - ltmp = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse( (0x0F<<20) | 0xF01E0, 20); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - msleep(5); - - //phy_set_rf_data(phw_data, 0x0F, (0x0F<<20) | 0xF01A0); //Resotre Initial Setting - ltmp = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse( (0x0F<<20) | 0xF01A0, 20); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - -// //Force TXI(Q)P(N) to normal control - Wb35Reg_WriteSync( pHwData, 0x105c, pHwData->reg.BB5C ); - pHwData->reg.BB50 &= ~0x13;//(MASK_IQCAL_MODE|MASK_CALIB_START); - Wb35Reg_WriteSync( pHwData, 0x1050, pHwData->reg.BB50); - break; - - case RF_AIROHA_7230: - - //RF parameters have filled completely, PLL_ON should be - //pulled high - Wb35Reg_WriteSync( pHwData, 0x03dc, 0x00000080 ); - #ifdef _PE_STATE_DUMP_ - printk("* PLL_ON high\n"); - #endif - - //2.4GHz - //ltmp = (1 << 31) | (0 << 30) | (24 << 24) | 0x1ABA8F; - //Wb35Reg_WriteSync pHwData, 0x0864, ltmp ); - //msleep(1); // Sleep 1 ms - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | 0x9ABA8F; - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - msleep(5); - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | 0x3ABA8F; - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - msleep(5); - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | 0x1ABA8F; - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - msleep(5); - - //5GHz - Wb35Reg_WriteSync( pHwData, 0x03dc, 0x00000000 ); - #ifdef _PE_STATE_DUMP_ - printk("* PLL_ON low\n"); - #endif - - number = sizeof(al7230_rf_data_50)/sizeof(al7230_rf_data_50[0]); - Set_ChanIndep_RfData_al7230_50(pHwData, pltmp, number); - // Write to register. number must less and equal than 16 - for( i=0; i<number; i++ ) - Wb35Reg_WriteSync( pHwData, 0x0864, pltmp[i] ); - msleep(5); - - Wb35Reg_WriteSync( pHwData, 0x03dc, 0x00000080 ); - #ifdef _PE_STATE_DUMP_ - printk("* PLL_ON high\n"); - #endif - - //ltmp = (1 << 31) | (0 << 30) | (24 << 24) | 0x12BACF; - //Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | 0x9ABA8F; - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - msleep(5); - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | 0x3ABA8F; - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - msleep(5); - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | 0x12BACF; - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - msleep(5); - - //Wb35Reg_WriteSync( pHwData, 0x03dc, 0x00000080 ); - //printk("* PLL_ON high\n"); - break; - - case RF_WB_242: - case RF_WB_242_1: // 20060619.5 Add - - // - // ; Version 1.3B revision items: for FA5976A , October 3, 2005 by HTHo - // - ltmp = pHwData->reg.BB5C & 0xfffff000; - Wb35Reg_WriteSync( pHwData, 0x105c, ltmp ); - Wb35Reg_WriteSync( pHwData, 0x1058, 0 ); - pHwData->reg.BB50 |= 0x3;//(MASK_IQCAL_MODE|MASK_CALIB_START);//20060630 - Wb35Reg_WriteSync(pHwData, 0x1050, pHwData->reg.BB50); - - //----- Calibration (1). VCO frequency calibration - //Calibration (1a.0). Synthesizer reset (HTHo corrected 2005/05/10) - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x0F<<24) | 0x00101E, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - msleep(5); // Sleep 5ms - //Calibration (1a). VCO frequency calibration mode ; waiting 2msec VCO calibration time - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x00<<24) | 0xFE69c0, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - msleep(2); // Sleep 2ms - - //----- Calibration (2). TX baseband Gm-C filter auto-tuning - //Calibration (2a). turn off ENCAL signal - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x00<<24) | 0xF8EBC0, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - //Calibration (2b.0). TX filter auto-tuning BW: TFLBW=101 (TC5376A default) - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x07<<24) | 0x0C68CE, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - //Calibration (2b). send TX reset signal (HTHo corrected May 10, 2005) - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x0F<<24) | 0x00201E, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - //Calibration (2c). turn-on TX Gm-C filter auto-tuning - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x00<<24) | 0xFCEBC0, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - udelay(150); // Sleep 150 us - //turn off ENCAL signal - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x00<<24) | 0xF8EBC0, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - - //----- Calibration (3). RX baseband Gm-C filter auto-tuning - //Calibration (3a). turn off ENCAL signal - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x00<<24) | 0xFAEDC0, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - //Calibration (3b.0). RX filter auto-tuning BW: RFLBW=100 (TC5376A+corner default; July 26, 2005) - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x07<<24) | 0x0C68CE, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - //Calibration (3b). send RX reset signal (HTHo corrected May 10, 2005) - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x0F<<24) | 0x00401E, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - //Calibration (3c). turn-on RX Gm-C filter auto-tuning - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x00<<24) | 0xFEEDC0, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - udelay(150); // Sleep 150 us - //Calibration (3e). turn off ENCAL signal - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x00<<24) | 0xFAEDC0, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - - //----- Calibration (4). TX LO leakage calibration - //Calibration (4a). TX LO leakage calibration - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x00<<24) | 0xFD6BC0, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - udelay(150); // Sleep 150 us - - //----- Calibration (5). RX DC offset calibration - //Calibration (5a). turn off ENCAL signal and set to RX SW DC caliration mode - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x00<<24) | 0xFAEDC0, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - //Calibration (5b). turn off AGC servo-loop & RSSI - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x01<<24) | 0xEBFFC2, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - - //; for LNA=11 -------- - //Calibration (5c-h). RX DC offset current bias ON; & LNA=11; RXVGA=111111 - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x06<<24) | 0x343FCC, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - //Calibration (5d). turn on RX DC offset cal function; and waiting 2 msec cal time - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x00<<24) | 0xFF6DC0, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - msleep(2); // Sleep 2ms - //Calibration (5f). turn off ENCAL signal - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x00<<24) | 0xFAEDC0, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - - //; for LNA=10 -------- - //Calibration (5c-m). RX DC offset current bias ON; & LNA=10; RXVGA=111111 - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x06<<24) | 0x342FCC, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - //Calibration (5d). turn on RX DC offset cal function; and waiting 2 msec cal time - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x00<<24) | 0xFF6DC0, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - msleep(2); // Sleep 2ms - //Calibration (5f). turn off ENCAL signal - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x00<<24) | 0xFAEDC0, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - - //; for LNA=01 -------- - //Calibration (5c-m). RX DC offset current bias ON; & LNA=01; RXVGA=111111 - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x06<<24) | 0x341FCC, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - //Calibration (5d). turn on RX DC offset cal function; and waiting 2 msec cal time - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x00<<24) | 0xFF6DC0, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - msleep(2); // Sleep 2ms - //Calibration (5f). turn off ENCAL signal - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x00<<24) | 0xFAEDC0, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - - //; for LNA=00 -------- - //Calibration (5c-l). RX DC offset current bias ON; & LNA=00; RXVGA=111111 - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x06<<24) | 0x340FCC, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - //Calibration (5d). turn on RX DC offset cal function; and waiting 2 msec cal time - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x00<<24) | 0xFF6DC0, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - msleep(2); // Sleep 2ms - //Calibration (5f). turn off ENCAL signal - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x00<<24) | 0xFAEDC0, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - //Calibration (5g). turn on AGC servo-loop - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x01<<24) | 0xEFFFC2, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - - //; ----- Calibration (7). Switch RF chip to normal mode - //0x00 0xF86100 ; 3E184 ; Switch RF chip to normal mode -// msleep(10); // @@ 20060721 - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( (0x00<<24) | 0xF86100, 24); - Wb35Reg_WriteSync( pHwData, 0x0864, ltmp ); - msleep(5); // Sleep 5 ms - -// //write back -// Wb35Reg_WriteSync(pHwData, 0x105c, pHwData->reg.BB5C); -// pHwData->reg.BB50 &= ~0x13;//(MASK_IQCAL_MODE|MASK_CALIB_START); // 20060315.1 fix -// Wb35Reg_WriteSync(pHwData, 0x1050, pHwData->reg.BB50); -// msleep(1); // Sleep 1 ms - break; + switch (pHwData->phy_type) { + case RF_AIROHA_2230: + ltmp = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse((0x07 << 20) | 0xE168E, 20); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + msleep(10); + ltmp = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse(al2230_rf_data[7], 20); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + msleep(10); + case RF_AIROHA_2230S: + Wb35Reg_WriteSync(pHwData, 0x03d4, 0x80); /* regulator on only */ + msleep(10); + Wb35Reg_WriteSync(pHwData, 0x03d4, 0xa0); /* PLL_PD REF_PD set to 0 */ + msleep(10); + Wb35Reg_WriteSync(pHwData, 0x03d4, 0xe0); /* MLK_EN */ + Wb35Reg_WriteSync(pHwData, 0x03b0, 1); /* Reset hardware first */ + msleep(10); + /* ========================================================= */ + + /* The follow code doesn't use the burst-write mode */ + ltmp = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse((0x0F<<20) | 0xF01A0, 20); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + + ltmp = pHwData->reg.BB5C & 0xfffff000; + Wb35Reg_WriteSync(pHwData, 0x105c, ltmp); + pHwData->reg.BB50 |= 0x13; /* (MASK_IQCAL_MODE|MASK_CALIB_START) */ + Wb35Reg_WriteSync(pHwData, 0x1050, pHwData->reg.BB50); + msleep(5); + + ltmp = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse((0x0F << 20) | 0xF01B0, 20); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + msleep(5); + + ltmp = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse((0x0F << 20) | 0xF01E0, 20); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + msleep(5); + + ltmp = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse((0x0F << 20) | 0xF01A0, 20); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp) ; + + Wb35Reg_WriteSync(pHwData, 0x105c, pHwData->reg.BB5C); + pHwData->reg.BB50 &= ~0x13; /* (MASK_IQCAL_MODE|MASK_CALIB_START); */ + Wb35Reg_WriteSync(pHwData, 0x1050, pHwData->reg.BB50); + break; + case RF_AIROHA_7230: + /* RF parameters have filled completely, PLL_ON should be pulled high */ + Wb35Reg_WriteSync(pHwData, 0x03dc, 0x00000080); + #ifdef _PE_STATE_DUMP_ + printk("* PLL_ON high\n"); + #endif + + /* 2.4GHz */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | 0x9ABA8F; + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + msleep(5); + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | 0x3ABA8F; + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + msleep(5); + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | 0x1ABA8F; + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + msleep(5); + + /* 5GHz */ + Wb35Reg_WriteSync(pHwData, 0x03dc, 0x00000000); + #ifdef _PE_STATE_DUMP_ + printk("* PLL_ON low\n"); + #endif + + number = sizeof(al7230_rf_data_50) / sizeof(al7230_rf_data_50[0]); + Set_ChanIndep_RfData_al7230_50(pHwData, pltmp, number); + /* Write to register. number must less and equal than 16 */ + for (i = 0; i < number; i++) + Wb35Reg_WriteSync(pHwData, 0x0864, pltmp[i]); + msleep(5); + + Wb35Reg_WriteSync(pHwData, 0x03dc, 0x00000080); + #ifdef _PE_STATE_DUMP_ + printk("* PLL_ON high\n"); + #endif + + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | 0x9ABA8F; + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + msleep(5); + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | 0x3ABA8F; + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + msleep(5); + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | 0x12BACF; + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + msleep(5); + break; + case RF_WB_242: + case RF_WB_242_1: + /* for FA5976A */ + ltmp = pHwData->reg.BB5C & 0xfffff000; + Wb35Reg_WriteSync(pHwData, 0x105c, ltmp); + Wb35Reg_WriteSync(pHwData, 0x1058, 0); + pHwData->reg.BB50 |= 0x3; /* (MASK_IQCAL_MODE|MASK_CALIB_START); */ + Wb35Reg_WriteSync(pHwData, 0x1050, pHwData->reg.BB50); + + /* ----- Calibration (1). VCO frequency calibration */ + /* Calibration (1a.0). Synthesizer reset */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x0F<<24) | 0x00101E, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + msleep(5); + /* Calibration (1a). VCO frequency calibration mode ; waiting 2msec VCO calibration time */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x00<<24) | 0xFE69c0, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + msleep(2); + + /* ----- Calibration (2). TX baseband Gm-C filter auto-tuning */ + /* Calibration (2a). turn off ENCAL signal */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x00<<24) | 0xF8EBC0, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + /* Calibration (2b.0). TX filter auto-tuning BW: TFLBW=101 (TC5376A default) */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x07<<24) | 0x0C68CE, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + /* Calibration (2b). send TX reset signal */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x0F<<24) | 0x00201E, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + /* Calibration (2c). turn-on TX Gm-C filter auto-tuning */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x00<<24) | 0xFCEBC0, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + udelay(150); /* Sleep 150 us */ + /* turn off ENCAL signal */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x00<<24) | 0xF8EBC0, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + + /* ----- Calibration (3). RX baseband Gm-C filter auto-tuning */ + /* Calibration (3a). turn off ENCAL signal */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x00<<24) | 0xFAEDC0, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + /* Calibration (3b.0). RX filter auto-tuning BW: RFLBW=100 (TC5376A+corner default;) */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x07<<24) | 0x0C68CE, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + /* Calibration (3b). send RX reset signal */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x0F<<24) | 0x00401E, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + /* Calibration (3c). turn-on RX Gm-C filter auto-tuning */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x00<<24) | 0xFEEDC0, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + udelay(150); /* Sleep 150 us */ + /* Calibration (3e). turn off ENCAL signal */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x00<<24) | 0xFAEDC0, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + + /* ----- Calibration (4). TX LO leakage calibration */ + /* Calibration (4a). TX LO leakage calibration */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x00<<24) | 0xFD6BC0, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + udelay(150); /* Sleep 150 us */ + + /* ----- Calibration (5). RX DC offset calibration */ + /* Calibration (5a). turn off ENCAL signal and set to RX SW DC calibration mode */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x00<<24) | 0xFAEDC0, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + /* Calibration (5b). turn off AGC servo-loop & RSSI */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x01<<24) | 0xEBFFC2, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + + /* for LNA=11 -------- */ + /* Calibration (5c-h). RX DC offset current bias ON; & LNA=11; RXVGA=111111 */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x06<<24) | 0x343FCC, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + /* Calibration (5d). turn on RX DC offset cal function; and waiting 2 msec cal time */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x00<<24) | 0xFF6DC0, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + msleep(2); + /* Calibration (5f). turn off ENCAL signal */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x00<<24) | 0xFAEDC0, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + + /* for LNA=10 -------- */ + /* Calibration (5c-m). RX DC offset current bias ON; & LNA=10; RXVGA=111111 */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x06<<24) | 0x342FCC, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + /* Calibration (5d). turn on RX DC offset cal function; and waiting 2 msec cal time */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x00<<24) | 0xFF6DC0, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + msleep(2); + /* Calibration (5f). turn off ENCAL signal */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x00<<24) | 0xFAEDC0, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + + /* for LNA=01 -------- */ + /* Calibration (5c-m). RX DC offset current bias ON; & LNA=01; RXVGA=111111 */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x06<<24) | 0x341FCC, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + /* Calibration (5d). turn on RX DC offset cal function; and waiting 2 msec cal time */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x00<<24) | 0xFF6DC0, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + msleep(2); + /* Calibration (5f). turn off ENCAL signal */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x00<<24) | 0xFAEDC0, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + + /* for LNA=00 -------- */ + /* Calibration (5c-l). RX DC offset current bias ON; & LNA=00; RXVGA=111111 */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x06<<24) | 0x340FCC, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + /* Calibration (5d). turn on RX DC offset cal function; and waiting 2 msec cal time */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x00<<24) | 0xFF6DC0, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + msleep(2); + /* Calibration (5f). turn off ENCAL signal */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x00<<24) | 0xFAEDC0, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + /* Calibration (5g). turn on AGC servo-loop */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x01<<24) | 0xEFFFC2, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + + /* ----- Calibration (7). Switch RF chip to normal mode */ + /* 0x00 0xF86100 ; 3E184 ; Switch RF chip to normal mode */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse((0x00<<24) | 0xF86100, 24); + Wb35Reg_WriteSync(pHwData, 0x0864, ltmp); + msleep(5); + break; } } -void BBProcessor_AL7230_2400( struct hw_data * pHwData) +void BBProcessor_AL7230_2400(struct hw_data *pHwData) { struct wb35_reg *reg = &pHwData->reg; u32 pltmp[12]; - pltmp[0] = 0x16A8337A; // 0x16a5215f; // 0x1000 AGC_Ctrl1 - pltmp[1] = 0x9AFF9AA6; // 0x9aff9ca6; // 0x1004 AGC_Ctrl2 - pltmp[2] = 0x55D00A04; // 0x55d00a04; // 0x1008 AGC_Ctrl3 - pltmp[3] = 0xFFF72031; // 0xFfFf2138; // 0x100c AGC_Ctrl4 + pltmp[0] = 0x16A8337A; /* 0x1000 AGC_Ctrl1 */ + pltmp[1] = 0x9AFF9AA6; /* 0x1004 AGC_Ctrl2 */ + pltmp[2] = 0x55D00A04; /* 0x1008 AGC_Ctrl3 */ + pltmp[3] = 0xFFF72031; /* 0x100c AGC_Ctrl4 */ reg->BB0C = 0xFFF72031; - pltmp[4] = 0x0FacDCC5; // 0x1010 AGC_Ctrl5 // 20050927 0x0FacDCB7 - pltmp[5] = 0x00CAA333; // 0x00eaa333; // 0x1014 AGC_Ctrl6 - pltmp[6] = 0xF2211111; // 0x11111111; // 0x1018 AGC_Ctrl7 - pltmp[7] = 0x0FA3F0ED; // 0x101c AGC_Ctrl8 - pltmp[8] = 0x06443440; // 0x1020 AGC_Ctrl9 - pltmp[9] = 0xA8002A79; // 0xa9002A79; // 0x1024 AGC_Ctrl10 - pltmp[10] = 0x40000528; // 20050927 0x40000228 - pltmp[11] = 0x232D7F30; // 0x23457f30;// 0x102c A_ACQ_Ctrl + pltmp[4] = 0x0FacDCC5; /* 0x1010 AGC_Ctrl5 */ + pltmp[5] = 0x00CAA333; /* 0x1014 AGC_Ctrl6 */ + pltmp[6] = 0xF2211111; /* 0x1018 AGC_Ctrl7 */ + pltmp[7] = 0x0FA3F0ED; /* 0x101c AGC_Ctrl8 */ + pltmp[8] = 0x06443440; /* 0x1020 AGC_Ctrl9 */ + pltmp[9] = 0xA8002A79; /* 0x1024 AGC_Ctrl10 */ + pltmp[10] = 0x40000528; + pltmp[11] = 0x232D7F30; /* 0x102c A_ACQ_Ctrl */ reg->BB2C = 0x232D7F30; - Wb35Reg_BurstWrite( pHwData, 0x1000, pltmp, 12, AUTO_INCREMENT ); + Wb35Reg_BurstWrite(pHwData, 0x1000, pltmp, 12, AUTO_INCREMENT); - pltmp[0] = 0x00002c54; // 0x1030 B_ACQ_Ctrl + pltmp[0] = 0x00002c54; /* 0x1030 B_ACQ_Ctrl */ reg->BB30 = 0x00002c54; - pltmp[1] = 0x00C0D6C5; // 0x1034 A_TXRX_Ctrl - pltmp[2] = 0x5B2C8769; // 0x1038 B_TXRX_Ctrl - pltmp[3] = 0x00000000; // 0x103c 11a TX LS filter + pltmp[1] = 0x00C0D6C5; /* 0x1034 A_TXRX_Ctrl */ + pltmp[2] = 0x5B2C8769; /* 0x1038 B_TXRX_Ctrl */ + pltmp[3] = 0x00000000; /* 0x103c 11a TX LS filter */ reg->BB3C = 0x00000000; - pltmp[4] = 0x00003F29; // 0x1040 11a TX LS filter - pltmp[5] = 0x0EFEFBFE; // 0x1044 11a TX LS filter - pltmp[6] = 0x00332C1B; // 0x00453B24; // 0x1048 11b TX RC filter - pltmp[7] = 0x0A00FEFF; // 0x0E00FEFF; // 0x104c 11b TX RC filter - pltmp[8] = 0x2B106208; // 0x1050 MODE_Ctrl + pltmp[4] = 0x00003F29; /* 0x1040 11a TX LS filter */ + pltmp[5] = 0x0EFEFBFE; /* 0x1044 11a TX LS filter */ + pltmp[6] = 0x00332C1B; /* 0x1048 11b TX RC filter */ + pltmp[7] = 0x0A00FEFF; /* 0x104c 11b TX RC filter */ + pltmp[8] = 0x2B106208; /* 0x1050 MODE_Ctrl */ reg->BB50 = 0x2B106208; - pltmp[9] = 0; // 0x1054 + pltmp[9] = 0; /* 0x1054 */ reg->BB54 = 0x00000000; - pltmp[10] = 0x52524242; // 0x64645252; // 0x1058 IQ_Alpha + pltmp[10] = 0x52524242; /* 0x1058 IQ_Alpha */ reg->BB58 = 0x52524242; - pltmp[11] = 0xAA0AC000; // 0x105c DC_Cancel - Wb35Reg_BurstWrite( pHwData, 0x1030, pltmp, 12, AUTO_INCREMENT ); - + pltmp[11] = 0xAA0AC000; /* 0x105c DC_Cancel */ + Wb35Reg_BurstWrite(pHwData, 0x1030, pltmp, 12, AUTO_INCREMENT); } -void BBProcessor_AL7230_5000( struct hw_data * pHwData) +void BBProcessor_AL7230_5000(struct hw_data *pHwData) { struct wb35_reg *reg = &pHwData->reg; u32 pltmp[12]; - pltmp[0] = 0x16AA6678; // 0x1000 AGC_Ctrl1 - pltmp[1] = 0x9AFFA0B2; // 0x1004 AGC_Ctrl2 - pltmp[2] = 0x55D00A04; // 0x1008 AGC_Ctrl3 - pltmp[3] = 0xEFFF233E; // 0x100c AGC_Ctrl4 + pltmp[0] = 0x16AA6678; /* 0x1000 AGC_Ctrl1 */ + pltmp[1] = 0x9AFFA0B2; /* 0x1004 AGC_Ctrl2 */ + pltmp[2] = 0x55D00A04; /* 0x1008 AGC_Ctrl3 */ + pltmp[3] = 0xEFFF233E; /* 0x100c AGC_Ctrl4 */ reg->BB0C = 0xEFFF233E; - pltmp[4] = 0x0FacDCC5; // 0x1010 AGC_Ctrl5 // 20050927 0x0FacDCB7 - pltmp[5] = 0x00CAA333; // 0x1014 AGC_Ctrl6 - pltmp[6] = 0xF2432111; // 0x1018 AGC_Ctrl7 - pltmp[7] = 0x0FA3F0ED; // 0x101c AGC_Ctrl8 - pltmp[8] = 0x05C43440; // 0x1020 AGC_Ctrl9 - pltmp[9] = 0x00002A79; // 0x1024 AGC_Ctrl10 - pltmp[10] = 0x40000528; // 20050927 0x40000228 - pltmp[11] = 0x232FDF30;// 0x102c A_ACQ_Ctrl + pltmp[4] = 0x0FacDCC5; /* 0x1010 AGC_Ctrl5 */ + pltmp[5] = 0x00CAA333; /* 0x1014 AGC_Ctrl6 */ + pltmp[6] = 0xF2432111; /* 0x1018 AGC_Ctrl7 */ + pltmp[7] = 0x0FA3F0ED; /* 0x101c AGC_Ctrl8 */ + pltmp[8] = 0x05C43440; /* 0x1020 AGC_Ctrl9 */ + pltmp[9] = 0x00002A79; /* 0x1024 AGC_Ctrl10 */ + pltmp[10] = 0x40000528; + pltmp[11] = 0x232FDF30;/* 0x102c A_ACQ_Ctrl */ reg->BB2C = 0x232FDF30; - Wb35Reg_BurstWrite( pHwData, 0x1000, pltmp, 12, AUTO_INCREMENT ); + Wb35Reg_BurstWrite(pHwData, 0x1000, pltmp, 12, AUTO_INCREMENT); - pltmp[0] = 0x80002C7C; // 0x1030 B_ACQ_Ctrl - pltmp[1] = 0x00C0D6C5; // 0x1034 A_TXRX_Ctrl - pltmp[2] = 0x5B2C8769; // 0x1038 B_TXRX_Ctrl - pltmp[3] = 0x00000000; // 0x103c 11a TX LS filter + pltmp[0] = 0x80002C7C; /* 0x1030 B_ACQ_Ctrl */ + pltmp[1] = 0x00C0D6C5; /* 0x1034 A_TXRX_Ctrl */ + pltmp[2] = 0x5B2C8769; /* 0x1038 B_TXRX_Ctrl */ + pltmp[3] = 0x00000000; /* 0x103c 11a TX LS filter */ reg->BB3C = 0x00000000; - pltmp[4] = 0x00003F29; // 0x1040 11a TX LS filter - pltmp[5] = 0x0EFEFBFE; // 0x1044 11a TX LS filter - pltmp[6] = 0x00332C1B; // 0x1048 11b TX RC filter - pltmp[7] = 0x0A00FEFF; // 0x104c 11b TX RC filter - pltmp[8] = 0x2B107208; // 0x1050 MODE_Ctrl + pltmp[4] = 0x00003F29; /* 0x1040 11a TX LS filter */ + pltmp[5] = 0x0EFEFBFE; /* 0x1044 11a TX LS filter */ + pltmp[6] = 0x00332C1B; /* 0x1048 11b TX RC filter */ + pltmp[7] = 0x0A00FEFF; /* 0x104c 11b TX RC filter */ + pltmp[8] = 0x2B107208; /* 0x1050 MODE_Ctrl */ reg->BB50 = 0x2B107208; - pltmp[9] = 0; // 0x1054 + pltmp[9] = 0; /* 0x1054 */ reg->BB54 = 0x00000000; - pltmp[10] = 0x52524242; // 0x1058 IQ_Alpha + pltmp[10] = 0x52524242; /* 0x1058 IQ_Alpha */ reg->BB58 = 0x52524242; - pltmp[11] = 0xAA0AC000; // 0x105c DC_Cancel - Wb35Reg_BurstWrite( pHwData, 0x1030, pltmp, 12, AUTO_INCREMENT ); - + pltmp[11] = 0xAA0AC000; /* 0x105c DC_Cancel */ + Wb35Reg_BurstWrite(pHwData, 0x1030, pltmp, 12, AUTO_INCREMENT); } -//============================================================================================================= -// BBProcessorPowerupInit -- -// -// Description: -// Initialize the Baseband processor. -// -// Arguments: -// pHwData - Handle of the USB Device. -// -// Return values: -// None. -//============================================================================================================= -void -BBProcessor_initial( struct hw_data * pHwData ) +/* + * =========================================================================== + * BBProcessorPowerupInit -- + * + * Description: + * Initialize the Baseband processor. + * + * Arguments: + * pHwData - Handle of the USB Device. + * + * Return values: + * None. + *============================================================================ + */ +void BBProcessor_initial(struct hw_data *pHwData) { struct wb35_reg *reg = &pHwData->reg; u32 i, pltmp[12]; - switch( pHwData->phy_type ) - { - case RF_MAXIM_V1: // Initializng the Winbond 2nd BB(with Phy board (v1) + Maxim 331) - - pltmp[0] = 0x16F47E77; // 0x1000 AGC_Ctrl1 - pltmp[1] = 0x9AFFAEA4; // 0x1004 AGC_Ctrl2 - pltmp[2] = 0x55D00A04; // 0x1008 AGC_Ctrl3 - pltmp[3] = 0xEFFF1A34; // 0x100c AGC_Ctrl4 - reg->BB0C = 0xEFFF1A34; - pltmp[4] = 0x0FABE0B7; // 0x1010 AGC_Ctrl5 - pltmp[5] = 0x00CAA332; // 0x1014 AGC_Ctrl6 - pltmp[6] = 0xF6632111; // 0x1018 AGC_Ctrl7 - pltmp[7] = 0x0FA3F0ED; // 0x101c AGC_Ctrl8 - pltmp[8] = 0x04CC3640; // 0x1020 AGC_Ctrl9 - pltmp[9] = 0x00002A79; // 0x1024 AGC_Ctrl10 - pltmp[10] = (pHwData->phy_type==3) ? 0x40000a28 : 0x40000228; // 0x1028 MAXIM_331(b31=0) + WBRF_V1(b11=1) : MAXIM_331(b31=0) + WBRF_V2(b11=0) - pltmp[11] = 0x232FDF30; // 0x102c A_ACQ_Ctrl - reg->BB2C = 0x232FDF30; //Modify for 33's 1.0.95.xxx version, antenna 1 - Wb35Reg_BurstWrite( pHwData, 0x1000, pltmp, 12, AUTO_INCREMENT ); - - pltmp[0] = 0x00002C54; // 0x1030 B_ACQ_Ctrl - reg->BB30 = 0x00002C54; - pltmp[1] = 0x00C0D6C5; // 0x1034 A_TXRX_Ctrl - pltmp[2] = 0x5B6C8769; // 0x1038 B_TXRX_Ctrl - pltmp[3] = 0x00000000; // 0x103c 11a TX LS filter - reg->BB3C = 0x00000000; - pltmp[4] = 0x00003F29; // 0x1040 11a TX LS filter - pltmp[5] = 0x0EFEFBFE; // 0x1044 11a TX LS filter - pltmp[6] = 0x00453B24; // 0x1048 11b TX RC filter - pltmp[7] = 0x0E00FEFF; // 0x104c 11b TX RC filter - pltmp[8] = 0x27106208; // 0x1050 MODE_Ctrl - reg->BB50 = 0x27106208; - pltmp[9] = 0; // 0x1054 - reg->BB54 = 0x00000000; - pltmp[10] = 0x64646464; // 0x1058 IQ_Alpha - reg->BB58 = 0x64646464; - pltmp[11] = 0xAA0AC000; // 0x105c DC_Cancel - Wb35Reg_BurstWrite( pHwData, 0x1030, pltmp, 12, AUTO_INCREMENT ); - - Wb35Reg_Write( pHwData, 0x1070, 0x00000045 ); - break; - - //------------------------------------------------------------------ - //[20040722 WK] - //Only for baseband version 2 -// case RF_MAXIM_317: - case RF_MAXIM_2825: - case RF_MAXIM_2827: - case RF_MAXIM_2828: - - pltmp[0] = 0x16b47e77; // 0x1000 AGC_Ctrl1 - pltmp[1] = 0x9affaea4; // 0x1004 AGC_Ctrl2 - pltmp[2] = 0x55d00a04; // 0x1008 AGC_Ctrl3 - pltmp[3] = 0xefff1a34; // 0x100c AGC_Ctrl4 - reg->BB0C = 0xefff1a34; - pltmp[4] = 0x0fabe0b7; // 0x1010 AGC_Ctrl5 - pltmp[5] = 0x00caa332; // 0x1014 AGC_Ctrl6 - pltmp[6] = 0xf6632111; // 0x1018 AGC_Ctrl7 - pltmp[7] = 0x0FA3F0ED; // 0x101c AGC_Ctrl8 - pltmp[8] = 0x04CC3640; // 0x1020 AGC_Ctrl9 - pltmp[9] = 0x00002A79; // 0x1024 AGC_Ctrl10 - pltmp[10] = 0x40000528; // 0x40000128; Modify for 33's 1.0.95 - pltmp[11] = 0x232fdf30; // 0x102c A_ACQ_Ctrl - reg->BB2C = 0x232fdf30; //Modify for 33's 1.0.95.xxx version, antenna 1 - Wb35Reg_BurstWrite( pHwData, 0x1000, pltmp, 12, AUTO_INCREMENT ); - - pltmp[0] = 0x00002C54; // 0x1030 B_ACQ_Ctrl - reg->BB30 = 0x00002C54; - pltmp[1] = 0x00C0D6C5; // 0x1034 A_TXRX_Ctrl - pltmp[2] = 0x5B6C8769; // 0x1038 B_TXRX_Ctrl - pltmp[3] = 0x00000000; // 0x103c 11a TX LS filter - reg->BB3C = 0x00000000; - pltmp[4] = 0x00003F29; // 0x1040 11a TX LS filter - pltmp[5] = 0x0EFEFBFE; // 0x1044 11a TX LS filter - pltmp[6] = 0x00453B24; // 0x1048 11b TX RC filter - pltmp[7] = 0x0D00FDFF; // 0x104c 11b TX RC filter - pltmp[8] = 0x27106208; // 0x1050 MODE_Ctrl - reg->BB50 = 0x27106208; - pltmp[9] = 0; // 0x1054 - reg->BB54 = 0x00000000; - pltmp[10] = 0x64646464; // 0x1058 IQ_Alpha - reg->BB58 = 0x64646464; - pltmp[11] = 0xAA28C000; // 0x105c DC_Cancel - Wb35Reg_BurstWrite( pHwData, 0x1030, pltmp, 12, AUTO_INCREMENT ); - - Wb35Reg_Write( pHwData, 0x1070, 0x00000045 ); - break; - - case RF_MAXIM_2829: - - pltmp[0] = 0x16b47e77; // 0x1000 AGC_Ctrl1 - pltmp[1] = 0x9affaea4; // 0x1004 AGC_Ctrl2 - pltmp[2] = 0x55d00a04; // 0x1008 AGC_Ctrl3 - pltmp[3] = 0xf4ff1632; // 0xefff1a34; // 0x100c AGC_Ctrl4 Modify for 33's 1.0.95 - reg->BB0C = 0xf4ff1632; // 0xefff1a34; Modify for 33's 1.0.95 - pltmp[4] = 0x0fabe0b7; // 0x1010 AGC_Ctrl5 - pltmp[5] = 0x00caa332; // 0x1014 AGC_Ctrl6 - pltmp[6] = 0xf8632112; // 0xf6632111; // 0x1018 AGC_Ctrl7 Modify for 33's 1.0.95 - pltmp[7] = 0x0FA3F0ED; // 0x101c AGC_Ctrl8 - pltmp[8] = 0x04CC3640; // 0x1020 AGC_Ctrl9 - pltmp[9] = 0x00002A79; // 0x1024 AGC_Ctrl10 - pltmp[10] = 0x40000528; // 0x40000128; modify for 33's 1.0.95 - pltmp[11] = 0x232fdf30; // 0x102c A_ACQ_Ctrl - reg->BB2C = 0x232fdf30; //Modify for 33's 1.0.95.xxx version, antenna 1 - Wb35Reg_BurstWrite( pHwData, 0x1000, pltmp, 12, AUTO_INCREMENT ); - - pltmp[0] = 0x00002C54; // 0x1030 B_ACQ_Ctrl - reg->BB30 = 0x00002C54; - pltmp[1] = 0x00C0D6C5; // 0x1034 A_TXRX_Ctrl - pltmp[2] = 0x5b2c8769; // 0x5B6C8769; // 0x1038 B_TXRX_Ctrl Modify for 33's 1.0.95 - pltmp[3] = 0x00000000; // 0x103c 11a TX LS filter - reg->BB3C = 0x00000000; - pltmp[4] = 0x00003F29; // 0x1040 11a TX LS filter - pltmp[5] = 0x0EFEFBFE; // 0x1044 11a TX LS filter - pltmp[6] = 0x002c2617; // 0x00453B24; // 0x1048 11b TX RC filter Modify for 33's 1.0.95 - pltmp[7] = 0x0800feff; // 0x0D00FDFF; // 0x104c 11b TX RC filter Modify for 33's 1.0.95 - pltmp[8] = 0x27106208; // 0x1050 MODE_Ctrl - reg->BB50 = 0x27106208; - pltmp[9] = 0; // 0x1054 - reg->BB54 = 0x00000000; - pltmp[10] = 0x64644a4a; // 0x64646464; // 0x1058 IQ_Alpha Modify for 33's 1.0.95 - reg->BB58 = 0x64646464; - pltmp[11] = 0xAA28C000; // 0x105c DC_Cancel - Wb35Reg_BurstWrite( pHwData, 0x1030, pltmp, 12, AUTO_INCREMENT ); - - Wb35Reg_Write( pHwData, 0x1070, 0x00000045 ); - break; - - case RF_AIROHA_2230: - - pltmp[0] = 0X16764A77; // 0x1000 AGC_Ctrl1 //0x16765A77 - pltmp[1] = 0x9affafb2; // 0x1004 AGC_Ctrl2 - pltmp[2] = 0x55d00a04; // 0x1008 AGC_Ctrl3 - pltmp[3] = 0xFFFd203c; // 0xFFFb203a; // 0x100c AGC_Ctrl4 Modify for 33's 1.0.95.xxx version - reg->BB0C = 0xFFFd203c; - pltmp[4] = 0X0FBFDCc5; // 0X0FBFDCA0; // 0x1010 AGC_Ctrl5 //0x0FB2E0B7 Modify for 33's 1.0.95.xxx version - pltmp[5] = 0x00caa332; // 0x00caa333; // 0x1014 AGC_Ctrl6 Modify for 33's 1.0.95.xxx version - pltmp[6] = 0XF6632111; // 0XF1632112; // 0x1018 AGC_Ctrl7 //0xf6632112 Modify for 33's 1.0.95.xxx version - pltmp[7] = 0x0FA3F0ED; // 0x101c AGC_Ctrl8 - pltmp[8] = 0x04C43640; // 0x1020 AGC_Ctrl9 - pltmp[9] = 0x00002A79; // 0x1024 AGC_Ctrl10 - pltmp[10] = 0X40000528; //0x40000228 - pltmp[11] = 0x232dfF30; // 0x232A9F30; // 0x102c A_ACQ_Ctrl //0x232a9730 - reg->BB2C = 0x232dfF30; //Modify for 33's 1.0.95.xxx version, antenna 1 - Wb35Reg_BurstWrite( pHwData, 0x1000, pltmp, 12, AUTO_INCREMENT ); - - pltmp[0] = 0x00002C54; // 0x1030 B_ACQ_Ctrl - reg->BB30 = 0x00002C54; - pltmp[1] = 0x00C0D6C5; // 0x1034 A_TXRX_Ctrl - pltmp[2] = 0x5B2C8769; // 0x1038 B_TXRX_Ctrl //0x5B6C8769 - pltmp[3] = 0x00000000; // 0x103c 11a TX LS filter - reg->BB3C = 0x00000000; - pltmp[4] = 0x00003F29; // 0x1040 11a TX LS filter - pltmp[5] = 0x0EFEFBFE; // 0x1044 11a TX LS filter - pltmp[6] = BB48_DEFAULT_AL2230_11G; // 0x1048 11b TX RC filter 20060613.2 - reg->BB48 = BB48_DEFAULT_AL2230_11G; // 20051221 ch14 20060613.2 - pltmp[7] = BB4C_DEFAULT_AL2230_11G; // 0x104c 11b TX RC filter 20060613.2 - reg->BB4C = BB4C_DEFAULT_AL2230_11G; // 20060613.1 20060613.2 - pltmp[8] = 0x27106200; // 0x1050 MODE_Ctrl - reg->BB50 = 0x27106200; - pltmp[9] = 0; // 0x1054 - reg->BB54 = 0x00000000; - pltmp[10] = 0x52524242; // 0x1058 IQ_Alpha - reg->BB58 = 0x52524242; - pltmp[11] = 0xAA0AC000; // 0x105c DC_Cancel - Wb35Reg_BurstWrite( pHwData, 0x1030, pltmp, 12, AUTO_INCREMENT ); - - Wb35Reg_Write( pHwData, 0x1070, 0x00000045 ); - break; + switch (pHwData->phy_type) { + case RF_MAXIM_V1: /* Initializng the Winbond 2nd BB(with Phy board (v1) + Maxim 331) */ + pltmp[0] = 0x16F47E77; /* 0x1000 AGC_Ctrl1 */ + pltmp[1] = 0x9AFFAEA4; /* 0x1004 AGC_Ctrl2 */ + pltmp[2] = 0x55D00A04; /* 0x1008 AGC_Ctrl3 */ + pltmp[3] = 0xEFFF1A34; /* 0x100c AGC_Ctrl4 */ + reg->BB0C = 0xEFFF1A34; + pltmp[4] = 0x0FABE0B7; /* 0x1010 AGC_Ctrl5 */ + pltmp[5] = 0x00CAA332; /* 0x1014 AGC_Ctrl6 */ + pltmp[6] = 0xF6632111; /* 0x1018 AGC_Ctrl7 */ + pltmp[7] = 0x0FA3F0ED; /* 0x101c AGC_Ctrl8 */ + pltmp[8] = 0x04CC3640; /* 0x1020 AGC_Ctrl9 */ + pltmp[9] = 0x00002A79; /* 0x1024 AGC_Ctrl10 */ + pltmp[10] = (pHwData->phy_type == 3) ? 0x40000a28 : 0x40000228; /* 0x1028 MAXIM_331(b31=0) + WBRF_V1(b11=1) : MAXIM_331(b31=0) + WBRF_V2(b11=0) */ + pltmp[11] = 0x232FDF30; /* 0x102c A_ACQ_Ctrl */ + reg->BB2C = 0x232FDF30; /* Modify for 33's 1.0.95.xxx version, antenna 1 */ + Wb35Reg_BurstWrite(pHwData, 0x1000, pltmp, 12, AUTO_INCREMENT); + + pltmp[0] = 0x00002C54; /* 0x1030 B_ACQ_Ctrl */ + reg->BB30 = 0x00002C54; + pltmp[1] = 0x00C0D6C5; /* 0x1034 A_TXRX_Ctrl */ + pltmp[2] = 0x5B6C8769; /* 0x1038 B_TXRX_Ctrl */ + pltmp[3] = 0x00000000; /* 0x103c 11a TX LS filter */ + reg->BB3C = 0x00000000; + pltmp[4] = 0x00003F29; /* 0x1040 11a TX LS filter */ + pltmp[5] = 0x0EFEFBFE; /* 0x1044 11a TX LS filter */ + pltmp[6] = 0x00453B24; /* 0x1048 11b TX RC filter */ + pltmp[7] = 0x0E00FEFF; /* 0x104c 11b TX RC filter */ + pltmp[8] = 0x27106208; /* 0x1050 MODE_Ctrl */ + reg->BB50 = 0x27106208; + pltmp[9] = 0; /* 0x1054 */ + reg->BB54 = 0x00000000; + pltmp[10] = 0x64646464; /* 0x1058 IQ_Alpha */ + reg->BB58 = 0x64646464; + pltmp[11] = 0xAA0AC000; /* 0x105c DC_Cancel */ + Wb35Reg_BurstWrite(pHwData, 0x1030, pltmp, 12, AUTO_INCREMENT); + + Wb35Reg_Write(pHwData, 0x1070, 0x00000045); + break; - case RF_AIROHA_2230S: // 20060420 Add this - - pltmp[0] = 0X16764A77; // 0x1000 AGC_Ctrl1 //0x16765A77 - pltmp[1] = 0x9affafb2; // 0x1004 AGC_Ctrl2 - pltmp[2] = 0x55d00a04; // 0x1008 AGC_Ctrl3 - pltmp[3] = 0xFFFd203c; // 0xFFFb203a; // 0x100c AGC_Ctrl4 Modify for 33's 1.0.95.xxx version - reg->BB0C = 0xFFFd203c; - pltmp[4] = 0X0FBFDCc5; // 0X0FBFDCA0; // 0x1010 AGC_Ctrl5 //0x0FB2E0B7 Modify for 33's 1.0.95.xxx version - pltmp[5] = 0x00caa332; // 0x00caa333; // 0x1014 AGC_Ctrl6 Modify for 33's 1.0.95.xxx version - pltmp[6] = 0XF6632111; // 0XF1632112; // 0x1018 AGC_Ctrl7 //0xf6632112 Modify for 33's 1.0.95.xxx version - pltmp[7] = 0x0FA3F0ED; // 0x101c AGC_Ctrl8 - pltmp[8] = 0x04C43640; // 0x1020 AGC_Ctrl9 - pltmp[9] = 0x00002A79; // 0x1024 AGC_Ctrl10 - pltmp[10] = 0X40000528; //0x40000228 - pltmp[11] = 0x232dfF30; // 0x232A9F30; // 0x102c A_ACQ_Ctrl //0x232a9730 - reg->BB2C = 0x232dfF30; //Modify for 33's 1.0.95.xxx version, antenna 1 - Wb35Reg_BurstWrite( pHwData, 0x1000, pltmp, 12, AUTO_INCREMENT ); - - pltmp[0] = 0x00002C54; // 0x1030 B_ACQ_Ctrl - reg->BB30 = 0x00002C54; - pltmp[1] = 0x00C0D6C5; // 0x1034 A_TXRX_Ctrl - pltmp[2] = 0x5B2C8769; // 0x1038 B_TXRX_Ctrl //0x5B6C8769 - pltmp[3] = 0x00000000; // 0x103c 11a TX LS filter - reg->BB3C = 0x00000000; - pltmp[4] = 0x00003F29; // 0x1040 11a TX LS filter - pltmp[5] = 0x0EFEFBFE; // 0x1044 11a TX LS filter - pltmp[6] = BB48_DEFAULT_AL2230_11G; // 0x1048 11b TX RC filter 20060613.2 - reg->BB48 = BB48_DEFAULT_AL2230_11G; // 20051221 ch14 20060613.2 - pltmp[7] = BB4C_DEFAULT_AL2230_11G; // 0x104c 11b TX RC filter 20060613.2 - reg->BB4C = BB4C_DEFAULT_AL2230_11G; // 20060613.1 - pltmp[8] = 0x27106200; // 0x1050 MODE_Ctrl - reg->BB50 = 0x27106200; - pltmp[9] = 0; // 0x1054 - reg->BB54 = 0x00000000; - pltmp[10] = 0x52523232; // 20060419 0x52524242; // 0x1058 IQ_Alpha - reg->BB58 = 0x52523232; // 20060419 0x52524242; - pltmp[11] = 0xAA0AC000; // 0x105c DC_Cancel - Wb35Reg_BurstWrite( pHwData, 0x1030, pltmp, 12, AUTO_INCREMENT ); - - Wb35Reg_Write( pHwData, 0x1070, 0x00000045 ); - break; + case RF_MAXIM_2825: + case RF_MAXIM_2827: + case RF_MAXIM_2828: + pltmp[0] = 0x16b47e77; /* 0x1000 AGC_Ctrl1 */ + pltmp[1] = 0x9affaea4; /* 0x1004 AGC_Ctrl2 */ + pltmp[2] = 0x55d00a04; /* 0x1008 AGC_Ctrl3 */ + pltmp[3] = 0xefff1a34; /* 0x100c AGC_Ctrl4 */ + reg->BB0C = 0xefff1a34; + pltmp[4] = 0x0fabe0b7; /* 0x1010 AGC_Ctrl5 */ + pltmp[5] = 0x00caa332; /* 0x1014 AGC_Ctrl6 */ + pltmp[6] = 0xf6632111; /* 0x1018 AGC_Ctrl7 */ + pltmp[7] = 0x0FA3F0ED; /* 0x101c AGC_Ctrl8 */ + pltmp[8] = 0x04CC3640; /* 0x1020 AGC_Ctrl9 */ + pltmp[9] = 0x00002A79; /* 0x1024 AGC_Ctrl10 */ + pltmp[10] = 0x40000528; + pltmp[11] = 0x232fdf30; /* 0x102c A_ACQ_Ctrl */ + reg->BB2C = 0x232fdf30; /* antenna 1 */ + Wb35Reg_BurstWrite(pHwData, 0x1000, pltmp, 12, AUTO_INCREMENT); + + pltmp[0] = 0x00002C54; /* 0x1030 B_ACQ_Ctrl */ + reg->BB30 = 0x00002C54; + pltmp[1] = 0x00C0D6C5; /* 0x1034 A_TXRX_Ctrl */ + pltmp[2] = 0x5B6C8769; /* 0x1038 B_TXRX_Ctrl */ + pltmp[3] = 0x00000000; /* 0x103c 11a TX LS filter */ + reg->BB3C = 0x00000000; + pltmp[4] = 0x00003F29; /* 0x1040 11a TX LS filter */ + pltmp[5] = 0x0EFEFBFE; /* 0x1044 11a TX LS filter */ + pltmp[6] = 0x00453B24; /* 0x1048 11b TX RC filter */ + pltmp[7] = 0x0D00FDFF; /* 0x104c 11b TX RC filter */ + pltmp[8] = 0x27106208; /* 0x1050 MODE_Ctrl */ + reg->BB50 = 0x27106208; + pltmp[9] = 0; /* 0x1054 */ + reg->BB54 = 0x00000000; + pltmp[10] = 0x64646464; /* 0x1058 IQ_Alpha */ + reg->BB58 = 0x64646464; + pltmp[11] = 0xAA28C000; /* 0x105c DC_Cancel */ + Wb35Reg_BurstWrite(pHwData, 0x1030, pltmp, 12, AUTO_INCREMENT); + + Wb35Reg_Write(pHwData, 0x1070, 0x00000045); + break; - case RF_AIROHA_7230: -/* - pltmp[0] = 0x16a84a77; // 0x1000 AGC_Ctrl1 - pltmp[1] = 0x9affafb2; // 0x1004 AGC_Ctrl2 - pltmp[2] = 0x55d00a04; // 0x1008 AGC_Ctrl3 - pltmp[3] = 0xFFFb203a; // 0x100c AGC_Ctrl4 - reg->BB0c = 0xFFFb203a; - pltmp[4] = 0x0FBFDCB7; // 0x1010 AGC_Ctrl5 - pltmp[5] = 0x00caa333; // 0x1014 AGC_Ctrl6 - pltmp[6] = 0xf6632112; // 0x1018 AGC_Ctrl7 - pltmp[7] = 0x0FA3F0ED; // 0x101c AGC_Ctrl8 - pltmp[8] = 0x04C43640; // 0x1020 AGC_Ctrl9 - pltmp[9] = 0x00002A79; // 0x1024 AGC_Ctrl10 - pltmp[10] = 0x40000228; - pltmp[11] = 0x232A9F30;// 0x102c A_ACQ_Ctrl - reg->BB2c = 0x232A9F30; - Wb35Reg_BurstWrite( pHwData, 0x1000, pltmp, 12, AUTO_INCREMENT ); - - pltmp[0] = 0x00002C54; // 0x1030 B_ACQ_Ctrl - reg->BB30 = 0x00002C54; - pltmp[1] = 0x00C0D6C5; // 0x1034 A_TXRX_Ctrl - pltmp[2] = 0x5B2C8769; // 0x1038 B_TXRX_Ctrl - pltmp[3] = 0x00000000; // 0x103c 11a TX LS filter - reg->BB3c = 0x00000000; - pltmp[4] = 0x00003F29; // 0x1040 11a TX LS filter - pltmp[5] = 0x0EFEFBFE; // 0x1044 11a TX LS filter - pltmp[6] = 0x00453B24; // 0x1048 11b TX RC filter - pltmp[7] = 0x0E00FEFF; // 0x104c 11b TX RC filter - pltmp[8] = 0x27106200; // 0x1050 MODE_Ctrl - reg->BB50 = 0x27106200; - pltmp[9] = 0; // 0x1054 - reg->BB54 = 0x00000000; - pltmp[10] = 0x64645252; // 0x1058 IQ_Alpha - reg->BB58 = 0x64645252; - pltmp[11] = 0xAA0AC000; // 0x105c DC_Cancel - Wb35Reg_BurstWrite( pHwData, 0x1030, pltmp, 12, AUTO_INCREMENT ); -*/ - BBProcessor_AL7230_2400( pHwData ); - - Wb35Reg_Write( pHwData, 0x1070, 0x00000045 ); - break; + case RF_MAXIM_2829: + pltmp[0] = 0x16b47e77; /* 0x1000 AGC_Ctrl1 */ + pltmp[1] = 0x9affaea4; /* 0x1004 AGC_Ctrl2 */ + pltmp[2] = 0x55d00a04; /* 0x1008 AGC_Ctrl3 */ + pltmp[3] = 0xf4ff1632; /* 0x100c AGC_Ctrl4 */ + reg->BB0C = 0xf4ff1632; + pltmp[4] = 0x0fabe0b7; /* 0x1010 AGC_Ctrl5 */ + pltmp[5] = 0x00caa332; /* 0x1014 AGC_Ctrl6 */ + pltmp[6] = 0xf8632112; /* 0x1018 AGC_Ctrl7 */ + pltmp[7] = 0x0FA3F0ED; /* 0x101c AGC_Ctrl8 */ + pltmp[8] = 0x04CC3640; /* 0x1020 AGC_Ctrl9 */ + pltmp[9] = 0x00002A79; /* 0x1024 AGC_Ctrl10 */ + pltmp[10] = 0x40000528; + pltmp[11] = 0x232fdf30; /* 0x102c A_ACQ_Ctrl */ + reg->BB2C = 0x232fdf30; /* antenna 1 */ + Wb35Reg_BurstWrite(pHwData, 0x1000, pltmp, 12, AUTO_INCREMENT); + + pltmp[0] = 0x00002C54; /* 0x1030 B_ACQ_Ctrl */ + reg->BB30 = 0x00002C54; + pltmp[1] = 0x00C0D6C5; /* 0x1034 A_TXRX_Ctrl */ + pltmp[2] = 0x5b2c8769; /* 0x1038 B_TXRX_Ctrl */ + pltmp[3] = 0x00000000; /* 0x103c 11a TX LS filter */ + reg->BB3C = 0x00000000; + pltmp[4] = 0x00003F29; /* 0x1040 11a TX LS filter */ + pltmp[5] = 0x0EFEFBFE; /* 0x1044 11a TX LS filter */ + pltmp[6] = 0x002c2617; /* 0x1048 11b TX RC filter */ + pltmp[7] = 0x0800feff; /* 0x104c 11b TX RC filter */ + pltmp[8] = 0x27106208; /* 0x1050 MODE_Ctrl */ + reg->BB50 = 0x27106208; + pltmp[9] = 0; /* 0x1054 */ + reg->BB54 = 0x00000000; + pltmp[10] = 0x64644a4a; /* 0x1058 IQ_Alpha */ + reg->BB58 = 0x64646464; + pltmp[11] = 0xAA28C000; /* 0x105c DC_Cancel */ + Wb35Reg_BurstWrite(pHwData, 0x1030, pltmp, 12, AUTO_INCREMENT); + Wb35Reg_Write(pHwData, 0x1070, 0x00000045); + break; + case RF_AIROHA_2230: + pltmp[0] = 0X16764A77; /* 0x1000 AGC_Ctrl1 */ + pltmp[1] = 0x9affafb2; /* 0x1004 AGC_Ctrl2 */ + pltmp[2] = 0x55d00a04; /* 0x1008 AGC_Ctrl3 */ + pltmp[3] = 0xFFFd203c; /* 0x100c AGC_Ctrl4 */ + reg->BB0C = 0xFFFd203c; + pltmp[4] = 0X0FBFDCc5; /* 0x1010 AGC_Ctrl5 */ + pltmp[5] = 0x00caa332; /* 0x1014 AGC_Ctrl6 */ + pltmp[6] = 0XF6632111; /* 0x1018 AGC_Ctrl7 */ + pltmp[7] = 0x0FA3F0ED; /* 0x101c AGC_Ctrl8 */ + pltmp[8] = 0x04C43640; /* 0x1020 AGC_Ctrl9 */ + pltmp[9] = 0x00002A79; /* 0x1024 AGC_Ctrl10 */ + pltmp[10] = 0X40000528; + pltmp[11] = 0x232dfF30; /* 0x102c A_ACQ_Ctrl */ + reg->BB2C = 0x232dfF30; /* antenna 1 */ + Wb35Reg_BurstWrite(pHwData, 0x1000, pltmp, 12, AUTO_INCREMENT); + + pltmp[0] = 0x00002C54; /* 0x1030 B_ACQ_Ctrl */ + reg->BB30 = 0x00002C54; + pltmp[1] = 0x00C0D6C5; /* 0x1034 A_TXRX_Ctrl */ + pltmp[2] = 0x5B2C8769; /* 0x1038 B_TXRX_Ctrl */ + pltmp[3] = 0x00000000; /* 0x103c 11a TX LS filter */ + reg->BB3C = 0x00000000; + pltmp[4] = 0x00003F29; /* 0x1040 11a TX LS filter */ + pltmp[5] = 0x0EFEFBFE; /* 0x1044 11a TX LS filter */ + pltmp[6] = BB48_DEFAULT_AL2230_11G; /* 0x1048 11b TX RC filter */ + reg->BB48 = BB48_DEFAULT_AL2230_11G; /* 20051221 ch14 */ + pltmp[7] = BB4C_DEFAULT_AL2230_11G; /* 0x104c 11b TX RC filter */ + reg->BB4C = BB4C_DEFAULT_AL2230_11G; + pltmp[8] = 0x27106200; /* 0x1050 MODE_Ctrl */ + reg->BB50 = 0x27106200; + pltmp[9] = 0; /* 0x1054 */ + reg->BB54 = 0x00000000; + pltmp[10] = 0x52524242; /* 0x1058 IQ_Alpha */ + reg->BB58 = 0x52524242; + pltmp[11] = 0xAA0AC000; /* 0x105c DC_Cancel */ + Wb35Reg_BurstWrite(pHwData, 0x1030, pltmp, 12, AUTO_INCREMENT); + + Wb35Reg_Write(pHwData, 0x1070, 0x00000045); + break; + case RF_AIROHA_2230S: + pltmp[0] = 0X16764A77; /* 0x1000 AGC_Ctrl1 */ + pltmp[1] = 0x9affafb2; /* 0x1004 AGC_Ctrl2 */ + pltmp[2] = 0x55d00a04; /* 0x1008 AGC_Ctrl3 */ + pltmp[3] = 0xFFFd203c; /* 0x100c AGC_Ctrl4 */ + reg->BB0C = 0xFFFd203c; + pltmp[4] = 0X0FBFDCc5; /* 0x1010 AGC_Ctrl5 */ + pltmp[5] = 0x00caa332; /* 0x1014 AGC_Ctrl6 */ + pltmp[6] = 0XF6632111; /* 0x1018 AGC_Ctrl7 */ + pltmp[7] = 0x0FA3F0ED; /* 0x101c AGC_Ctrl8 */ + pltmp[8] = 0x04C43640; /* 0x1020 AGC_Ctrl9 */ + pltmp[9] = 0x00002A79; /* 0x1024 AGC_Ctrl10 */ + pltmp[10] = 0X40000528; + pltmp[11] = 0x232dfF30; /* 0x102c A_ACQ_Ctrl */ + reg->BB2C = 0x232dfF30; /* antenna 1 */ + Wb35Reg_BurstWrite(pHwData, 0x1000, pltmp, 12, AUTO_INCREMENT); + + pltmp[0] = 0x00002C54; /* 0x1030 B_ACQ_Ctrl */ + reg->BB30 = 0x00002C54; + pltmp[1] = 0x00C0D6C5; /* 0x1034 A_TXRX_Ctrl */ + pltmp[2] = 0x5B2C8769; /* 0x1038 B_TXRX_Ctrl */ + pltmp[3] = 0x00000000; /* 0x103c 11a TX LS filter */ + reg->BB3C = 0x00000000; + pltmp[4] = 0x00003F29; /* 0x1040 11a TX LS filter */ + pltmp[5] = 0x0EFEFBFE; /* 0x1044 11a TX LS filter */ + pltmp[6] = BB48_DEFAULT_AL2230_11G; /* 0x1048 11b TX RC filter */ + reg->BB48 = BB48_DEFAULT_AL2230_11G; /* ch14 */ + pltmp[7] = BB4C_DEFAULT_AL2230_11G; /* 0x104c 11b TX RC filter */ + reg->BB4C = BB4C_DEFAULT_AL2230_11G; + pltmp[8] = 0x27106200; /* 0x1050 MODE_Ctrl */ + reg->BB50 = 0x27106200; + pltmp[9] = 0; /* 0x1054 */ + reg->BB54 = 0x00000000; + pltmp[10] = 0x52523232; /* 0x1058 IQ_Alpha */ + reg->BB58 = 0x52523232; + pltmp[11] = 0xAA0AC000; /* 0x105c DC_Cancel */ + Wb35Reg_BurstWrite(pHwData, 0x1030, pltmp, 12, AUTO_INCREMENT); + + Wb35Reg_Write(pHwData, 0x1070, 0x00000045); + break; + case RF_AIROHA_7230: + BBProcessor_AL7230_2400(pHwData); - case RF_WB_242: - case RF_WB_242_1: // 20060619.5 Add - - pltmp[0] = 0x16A8525D; // 0x1000 AGC_Ctrl1 - pltmp[1] = 0x9AFF9ABA; // 0x1004 AGC_Ctrl2 - pltmp[2] = 0x55D00A04; // 0x1008 AGC_Ctrl3 - pltmp[3] = 0xEEE91C32; // 0x100c AGC_Ctrl4 - reg->BB0C = 0xEEE91C32; - pltmp[4] = 0x0FACDCC5; // 0x1010 AGC_Ctrl5 - pltmp[5] = 0x000AA344; // 0x1014 AGC_Ctrl6 - pltmp[6] = 0x22222221; // 0x1018 AGC_Ctrl7 - pltmp[7] = 0x0FA3F0ED; // 0x101c AGC_Ctrl8 - pltmp[8] = 0x04CC3440; // 20051018 0x03CB3440; // 0x1020 AGC_Ctrl9 20051014 0x03C33440 - pltmp[9] = 0xA9002A79; // 0x1024 AGC_Ctrl10 - pltmp[10] = 0x40000528; // 0x1028 - pltmp[11] = 0x23457F30; // 0x102c A_ACQ_Ctrl - reg->BB2C = 0x23457F30; - Wb35Reg_BurstWrite( pHwData, 0x1000, pltmp, 12, AUTO_INCREMENT ); - - pltmp[0] = 0x00002C54; // 0x1030 B_ACQ_Ctrl - reg->BB30 = 0x00002C54; - pltmp[1] = 0x00C0D6C5; // 0x1034 A_TXRX_Ctrl - pltmp[2] = 0x5B2C8769; // 0x1038 B_TXRX_Ctrl - pltmp[3] = pHwData->BB3c_cal; // 0x103c 11a TX LS filter - reg->BB3C = pHwData->BB3c_cal; - pltmp[4] = 0x00003F29; // 0x1040 11a TX LS filter - pltmp[5] = 0x0EFEFBFE; // 0x1044 11a TX LS filter - pltmp[6] = BB48_DEFAULT_WB242_11G; // 0x1048 11b TX RC filter 20060613.2 - reg->BB48 = BB48_DEFAULT_WB242_11G; // 20060613.1 20060613.2 - pltmp[7] = BB4C_DEFAULT_WB242_11G; // 0x104c 11b TX RC filter 20060613.2 - reg->BB4C = BB4C_DEFAULT_WB242_11G; // 20060613.1 20060613.2 - pltmp[8] = 0x27106208; // 0x1050 MODE_Ctrl - reg->BB50 = 0x27106208; - pltmp[9] = pHwData->BB54_cal; // 0x1054 - reg->BB54 = pHwData->BB54_cal; - pltmp[10] = 0x52523131; // 0x1058 IQ_Alpha - reg->BB58 = 0x52523131; - pltmp[11] = 0xAA0AC000; // 20060825 0xAA2AC000; // 0x105c DC_Cancel - Wb35Reg_BurstWrite( pHwData, 0x1030, pltmp, 12, AUTO_INCREMENT ); - - Wb35Reg_Write( pHwData, 0x1070, 0x00000045 ); - break; - } + Wb35Reg_Write(pHwData, 0x1070, 0x00000045); + break; + case RF_WB_242: + case RF_WB_242_1: + pltmp[0] = 0x16A8525D; /* 0x1000 AGC_Ctrl1 */ + pltmp[1] = 0x9AFF9ABA; /* 0x1004 AGC_Ctrl2 */ + pltmp[2] = 0x55D00A04; /* 0x1008 AGC_Ctrl3 */ + pltmp[3] = 0xEEE91C32; /* 0x100c AGC_Ctrl4 */ + reg->BB0C = 0xEEE91C32; + pltmp[4] = 0x0FACDCC5; /* 0x1010 AGC_Ctrl5 */ + pltmp[5] = 0x000AA344; /* 0x1014 AGC_Ctrl6 */ + pltmp[6] = 0x22222221; /* 0x1018 AGC_Ctrl7 */ + pltmp[7] = 0x0FA3F0ED; /* 0x101c AGC_Ctrl8 */ + pltmp[8] = 0x04CC3440; /* 0x1020 AGC_Ctrl9 */ + pltmp[9] = 0xA9002A79; /* 0x1024 AGC_Ctrl10 */ + pltmp[10] = 0x40000528; /* 0x1028 */ + pltmp[11] = 0x23457F30; /* 0x102c A_ACQ_Ctrl */ + reg->BB2C = 0x23457F30; + Wb35Reg_BurstWrite(pHwData, 0x1000, pltmp, 12, AUTO_INCREMENT); + + pltmp[0] = 0x00002C54; /* 0x1030 B_ACQ_Ctrl */ + reg->BB30 = 0x00002C54; + pltmp[1] = 0x00C0D6C5; /* 0x1034 A_TXRX_Ctrl */ + pltmp[2] = 0x5B2C8769; /* 0x1038 B_TXRX_Ctrl */ + pltmp[3] = pHwData->BB3c_cal; /* 0x103c 11a TX LS filter */ + reg->BB3C = pHwData->BB3c_cal; + pltmp[4] = 0x00003F29; /* 0x1040 11a TX LS filter */ + pltmp[5] = 0x0EFEFBFE; /* 0x1044 11a TX LS filter */ + pltmp[6] = BB48_DEFAULT_WB242_11G; /* 0x1048 11b TX RC filter */ + reg->BB48 = BB48_DEFAULT_WB242_11G; + pltmp[7] = BB4C_DEFAULT_WB242_11G; /* 0x104c 11b TX RC filter */ + reg->BB4C = BB4C_DEFAULT_WB242_11G; + pltmp[8] = 0x27106208; /* 0x1050 MODE_Ctrl */ + reg->BB50 = 0x27106208; + pltmp[9] = pHwData->BB54_cal; /* 0x1054 */ + reg->BB54 = pHwData->BB54_cal; + pltmp[10] = 0x52523131; /* 0x1058 IQ_Alpha */ + reg->BB58 = 0x52523131; + pltmp[11] = 0xAA0AC000; /* 0x105c DC_Cancel */ + Wb35Reg_BurstWrite(pHwData, 0x1030, pltmp, 12, AUTO_INCREMENT); + + Wb35Reg_Write(pHwData, 0x1070, 0x00000045); + break; + } - // Fill the LNA table - reg->LNAValue[0] = (u8)(reg->BB0C & 0xff); + /* Fill the LNA table */ + reg->LNAValue[0] = (u8) (reg->BB0C & 0xff); reg->LNAValue[1] = 0; - reg->LNAValue[2] = (u8)((reg->BB0C & 0xff00)>>8); + reg->LNAValue[2] = (u8) ((reg->BB0C & 0xff00) >> 8); reg->LNAValue[3] = 0; - // Fill SQ3 table - for( i=0; i<MAX_SQ3_FILTER_SIZE; i++ ) - reg->SQ3_filter[i] = 0x2f; // half of Bit 0 ~ 6 + /* Fill SQ3 table */ + for (i = 0; i < MAX_SQ3_FILTER_SIZE; i++) + reg->SQ3_filter[i] = 0x2f; /* half of Bit 0 ~ 6 */ } -void set_tx_power_per_channel_max2829( struct hw_data * pHwData, struct chan_info Channel) +void set_tx_power_per_channel_max2829(struct hw_data *pHwData, struct chan_info Channel) { - RFSynthesizer_SetPowerIndex( pHwData, 100 ); // 20060620.1 Modify + RFSynthesizer_SetPowerIndex(pHwData, 100); } -void set_tx_power_per_channel_al2230( struct hw_data * pHwData, struct chan_info Channel ) +void set_tx_power_per_channel_al2230(struct hw_data *pHwData, struct chan_info Channel) { u8 index = 100; - if (pHwData->TxVgaFor24[Channel.ChanNo - 1] != 0xff) // 20060620.1 Add + if (pHwData->TxVgaFor24[Channel.ChanNo - 1] != 0xff) index = pHwData->TxVgaFor24[Channel.ChanNo - 1]; - RFSynthesizer_SetPowerIndex( pHwData, index ); + RFSynthesizer_SetPowerIndex(pHwData, index); } -void set_tx_power_per_channel_al7230( struct hw_data * pHwData, struct chan_info Channel) +void set_tx_power_per_channel_al7230(struct hw_data *pHwData, struct chan_info Channel) { u8 i, index = 100; - switch ( Channel.band ) - { - case BAND_TYPE_DSSS: - case BAND_TYPE_OFDM_24: - { - if (pHwData->TxVgaFor24[Channel.ChanNo - 1] != 0xff) - index = pHwData->TxVgaFor24[Channel.ChanNo - 1]; - } - break; - case BAND_TYPE_OFDM_5: - { - for (i =0; i<35; i++) - { - if (Channel.ChanNo == pHwData->TxVgaFor50[i].ChanNo) - { - if (pHwData->TxVgaFor50[i].TxVgaValue != 0xff) - index = pHwData->TxVgaFor50[i].TxVgaValue; - break; - } - } + switch (Channel.band) { + case BAND_TYPE_DSSS: + case BAND_TYPE_OFDM_24: + if (pHwData->TxVgaFor24[Channel.ChanNo - 1] != 0xff) + index = pHwData->TxVgaFor24[Channel.ChanNo - 1]; + break; + case BAND_TYPE_OFDM_5: + for (i = 0; i < 35; i++) { + if (Channel.ChanNo == pHwData->TxVgaFor50[i].ChanNo) { + if (pHwData->TxVgaFor50[i].TxVgaValue != 0xff) + index = pHwData->TxVgaFor50[i].TxVgaValue; + break; } - break; + } + break; } - RFSynthesizer_SetPowerIndex( pHwData, index ); + RFSynthesizer_SetPowerIndex(pHwData, index); } -void set_tx_power_per_channel_wb242( struct hw_data * pHwData, struct chan_info Channel) +void set_tx_power_per_channel_wb242(struct hw_data *pHwData, struct chan_info Channel) { u8 index = 100; - switch ( Channel.band ) - { - case BAND_TYPE_DSSS: - case BAND_TYPE_OFDM_24: - { - if (pHwData->TxVgaFor24[Channel.ChanNo - 1] != 0xff) - index = pHwData->TxVgaFor24[Channel.ChanNo - 1]; - } - break; - case BAND_TYPE_OFDM_5: - break; + switch (Channel.band) { + case BAND_TYPE_DSSS: + case BAND_TYPE_OFDM_24: + if (pHwData->TxVgaFor24[Channel.ChanNo - 1] != 0xff) + index = pHwData->TxVgaFor24[Channel.ChanNo - 1]; + break; + case BAND_TYPE_OFDM_5: + break; } - RFSynthesizer_SetPowerIndex( pHwData, index ); + RFSynthesizer_SetPowerIndex(pHwData, index); } -//============================================================================================================= -// RFSynthesizer_SwitchingChannel -- -// -// Description: -// Swithch the RF channel. -// -// Arguments: -// pHwData - Handle of the USB Device. -// Channel - The channel no. -// -// Return values: -// None. -//============================================================================================================= -void -RFSynthesizer_SwitchingChannel( struct hw_data * pHwData, struct chan_info Channel ) +/* + * ========================================================================== + * RFSynthesizer_SwitchingChannel -- + * + * Description: + * Swithch the RF channel. + * + * Arguments: + * pHwData - Handle of the USB Device. + * Channel - The channel no. + * + * Return values: + * None. + * =========================================================================== + */ +void RFSynthesizer_SwitchingChannel(struct hw_data *pHwData, struct chan_info Channel) { struct wb35_reg *reg = &pHwData->reg; - u32 pltmp[16]; // The 16 is the maximum capability of hardware + u32 pltmp[16]; /* The 16 is the maximum capability of hardware */ u32 count, ltmp; u8 i, j, number; u8 ChnlTmp; - switch( pHwData->phy_type ) - { - case RF_MAXIM_2825: - case RF_MAXIM_V1: // 11g Winbond 2nd BB(with Phy board (v1) + Maxim 331) - - if( Channel.band <= BAND_TYPE_OFDM_24 ) // channel 1 ~ 13 - { - for( i=0; i<3; i++ ) - pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( max2825_channel_data_24[Channel.ChanNo-1][i], 18); - Wb35Reg_BurstWrite( pHwData, 0x0864, pltmp, 3, NO_INCREMENT ); - } - RFSynthesizer_SetPowerIndex( pHwData, 100 ); - break; - - case RF_MAXIM_2827: - - if( Channel.band <= BAND_TYPE_OFDM_24 ) // channel 1 ~ 13 - { - for( i=0; i<3; i++ ) - pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( max2827_channel_data_24[Channel.ChanNo-1][i], 18); - Wb35Reg_BurstWrite( pHwData, 0x0864, pltmp, 3, NO_INCREMENT ); - } - else if( Channel.band == BAND_TYPE_OFDM_5 ) // channel 36 ~ 64 - { - ChnlTmp = (Channel.ChanNo - 36) / 4; - for( i=0; i<3; i++ ) - pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( max2827_channel_data_50[ChnlTmp][i], 18); - Wb35Reg_BurstWrite( pHwData, 0x0864, pltmp, 3, NO_INCREMENT ); - } - RFSynthesizer_SetPowerIndex( pHwData, 100 ); - break; - - case RF_MAXIM_2828: - - if( Channel.band <= BAND_TYPE_OFDM_24 ) // channel 1 ~ 13 - { - for( i=0; i<3; i++ ) - pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( max2828_channel_data_24[Channel.ChanNo-1][i], 18); - Wb35Reg_BurstWrite( pHwData, 0x0864, pltmp, 3, NO_INCREMENT ); - } - else if( Channel.band == BAND_TYPE_OFDM_5 ) // channel 36 ~ 64 - { - ChnlTmp = (Channel.ChanNo - 36) / 4; - for ( i = 0; i < 3; i++) - pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( max2828_channel_data_50[ChnlTmp][i], 18); - Wb35Reg_BurstWrite( pHwData, 0x0864, pltmp, 3, NO_INCREMENT ); - } - RFSynthesizer_SetPowerIndex( pHwData, 100 ); - break; - - case RF_MAXIM_2829: + switch (pHwData->phy_type) { + case RF_MAXIM_2825: + case RF_MAXIM_V1: /* 11g Winbond 2nd BB(with Phy board (v1) + Maxim 331) */ - if( Channel.band <= BAND_TYPE_OFDM_24) - { - for( i=0; i<3; i++ ) - pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( max2829_channel_data_24[Channel.ChanNo-1][i], 18); - Wb35Reg_BurstWrite( pHwData, 0x0864, pltmp, 3, NO_INCREMENT ); - } - else if( Channel.band == BAND_TYPE_OFDM_5 ) - { - count = sizeof(max2829_channel_data_50) / sizeof(max2829_channel_data_50[0]); - - for( i=0; i<count; i++ ) - { - if( max2829_channel_data_50[i][0] == Channel.ChanNo ) - { - for( j=0; j<3; j++ ) - pltmp[j] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( max2829_channel_data_50[i][j+1], 18); - Wb35Reg_BurstWrite( pHwData, 0x0864, pltmp, 3, NO_INCREMENT ); - - if( (max2829_channel_data_50[i][3] & 0x3FFFF) == 0x2A946 ) - { - ltmp = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( (5<<18)|0x2A906, 18); - Wb35Reg_Write( pHwData, 0x0864, ltmp ); - } - else // 0x2A9C6 - { - ltmp = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( (5<<18)|0x2A986, 18); - Wb35Reg_Write( pHwData, 0x0864, ltmp ); - } + if (Channel.band <= BAND_TYPE_OFDM_24) { /* channel 1 ~ 13 */ + for (i = 0; i < 3; i++) + pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(max2825_channel_data_24[Channel.ChanNo-1][i], 18); + Wb35Reg_BurstWrite(pHwData, 0x0864, pltmp, 3, NO_INCREMENT); + } + RFSynthesizer_SetPowerIndex(pHwData, 100); + break; + case RF_MAXIM_2827: + if (Channel.band <= BAND_TYPE_OFDM_24) { /* channel 1 ~ 13 */ + for (i = 0; i < 3; i++) + pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(max2827_channel_data_24[Channel.ChanNo-1][i], 18); + Wb35Reg_BurstWrite(pHwData, 0x0864, pltmp, 3, NO_INCREMENT); + } else if (Channel.band == BAND_TYPE_OFDM_5) { /* channel 36 ~ 64 */ + ChnlTmp = (Channel.ChanNo - 36) / 4; + for (i = 0; i < 3; i++) + pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(max2827_channel_data_50[ChnlTmp][i], 18); + Wb35Reg_BurstWrite(pHwData, 0x0864, pltmp, 3, NO_INCREMENT); + } + RFSynthesizer_SetPowerIndex(pHwData, 100); + break; + case RF_MAXIM_2828: + if (Channel.band <= BAND_TYPE_OFDM_24) { /* channel 1 ~ 13 */ + for (i = 0; i < 3; i++) + pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(max2828_channel_data_24[Channel.ChanNo-1][i], 18); + Wb35Reg_BurstWrite(pHwData, 0x0864, pltmp, 3, NO_INCREMENT); + } else if (Channel.band == BAND_TYPE_OFDM_5) { /* channel 36 ~ 64 */ + ChnlTmp = (Channel.ChanNo - 36) / 4; + for (i = 0; i < 3; i++) + pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(max2828_channel_data_50[ChnlTmp][i], 18); + Wb35Reg_BurstWrite(pHwData, 0x0864, pltmp, 3, NO_INCREMENT); + } + RFSynthesizer_SetPowerIndex(pHwData, 100); + break; + case RF_MAXIM_2829: + if (Channel.band <= BAND_TYPE_OFDM_24) { + for (i = 0; i < 3; i++) + pltmp[i] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(max2829_channel_data_24[Channel.ChanNo-1][i], 18); + Wb35Reg_BurstWrite(pHwData, 0x0864, pltmp, 3, NO_INCREMENT); + } else if (Channel.band == BAND_TYPE_OFDM_5) { + count = sizeof(max2829_channel_data_50) / sizeof(max2829_channel_data_50[0]); + + for (i = 0; i < count; i++) { + if (max2829_channel_data_50[i][0] == Channel.ChanNo) { + for (j = 0; j < 3; j++) + pltmp[j] = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(max2829_channel_data_50[i][j+1], 18); + Wb35Reg_BurstWrite(pHwData, 0x0864, pltmp, 3, NO_INCREMENT); + + if ((max2829_channel_data_50[i][3] & 0x3FFFF) == 0x2A946) { + ltmp = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse((5 << 18) | 0x2A906, 18); + Wb35Reg_Write(pHwData, 0x0864, ltmp); + } else { /* 0x2A9C6 */ + ltmp = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse((5 << 18) | 0x2A986, 18); + Wb35Reg_Write(pHwData, 0x0864, ltmp); } } } - set_tx_power_per_channel_max2829( pHwData, Channel ); - break; - - case RF_AIROHA_2230: - case RF_AIROHA_2230S: // 20060420 Add this - - if( Channel.band <= BAND_TYPE_OFDM_24 ) // channel 1 ~ 14 - { - for( i=0; i<2; i++ ) - pltmp[i] = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse( al2230_channel_data_24[Channel.ChanNo-1][i], 20); - Wb35Reg_BurstWrite( pHwData, 0x0864, pltmp, 2, NO_INCREMENT ); + } + set_tx_power_per_channel_max2829(pHwData, Channel); + break; + case RF_AIROHA_2230: + case RF_AIROHA_2230S: + if (Channel.band <= BAND_TYPE_OFDM_24) { /* channel 1 ~ 14 */ + for (i = 0; i < 2; i++) + pltmp[i] = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse(al2230_channel_data_24[Channel.ChanNo-1][i], 20); + Wb35Reg_BurstWrite(pHwData, 0x0864, pltmp, 2, NO_INCREMENT); + } + set_tx_power_per_channel_al2230(pHwData, Channel); + break; + case RF_AIROHA_7230: + /* Channel independent registers */ + if (Channel.band != pHwData->band) { + if (Channel.band <= BAND_TYPE_OFDM_24) { + /* Update BB register */ + BBProcessor_AL7230_2400(pHwData); + + number = sizeof(al7230_rf_data_24) / sizeof(al7230_rf_data_24[0]); + Set_ChanIndep_RfData_al7230_24(pHwData, pltmp, number); + } else { + /* Update BB register */ + BBProcessor_AL7230_5000(pHwData); + + number = sizeof(al7230_rf_data_50) / sizeof(al7230_rf_data_50[0]); + Set_ChanIndep_RfData_al7230_50(pHwData, pltmp, number); } - set_tx_power_per_channel_al2230( pHwData, Channel ); - break; - case RF_AIROHA_7230: - - //Start to fill RF parameters, PLL_ON should be pulled low. - //Wb35Reg_Write( pHwData, 0x03dc, 0x00000000 ); - //printk("* PLL_ON low\n"); - - //Channel independent registers - if( Channel.band != pHwData->band) - { - if (Channel.band <= BAND_TYPE_OFDM_24) - { - //Update BB register - BBProcessor_AL7230_2400(pHwData); - - number = sizeof(al7230_rf_data_24)/sizeof(al7230_rf_data_24[0]); - Set_ChanIndep_RfData_al7230_24(pHwData, pltmp, number); - } - else - { - //Update BB register - BBProcessor_AL7230_5000(pHwData); - - number = sizeof(al7230_rf_data_50)/sizeof(al7230_rf_data_50[0]); - Set_ChanIndep_RfData_al7230_50(pHwData, pltmp, number); - } - - // Write to register. number must less and equal than 16 - Wb35Reg_BurstWrite( pHwData, 0x0864, pltmp, number, NO_INCREMENT ); - #ifdef _PE_STATE_DUMP_ - printk("Band changed\n"); - #endif - } + /* Write to register. number must less and equal than 16 */ + Wb35Reg_BurstWrite(pHwData, 0x0864, pltmp, number, NO_INCREMENT); + #ifdef _PE_STATE_DUMP_ + printk("Band changed\n"); + #endif + } - if( Channel.band <= BAND_TYPE_OFDM_24 ) // channel 1 ~ 14 - { - for( i=0; i<2; i++ ) - pltmp[i] = (1 << 31) | (0 << 30) | (24 << 24) | (al7230_channel_data_24[Channel.ChanNo-1][i]&0xffffff); - Wb35Reg_BurstWrite( pHwData, 0x0864, pltmp, 2, NO_INCREMENT ); + if (Channel.band <= BAND_TYPE_OFDM_24) { /* channel 1 ~ 14 */ + for (i = 0; i < 2; i++) + pltmp[i] = (1 << 31) | (0 << 30) | (24 << 24) | (al7230_channel_data_24[Channel.ChanNo-1][i]&0xffffff); + Wb35Reg_BurstWrite(pHwData, 0x0864, pltmp, 2, NO_INCREMENT); + } else if (Channel.band == BAND_TYPE_OFDM_5) { + /* Update Reg12 */ + if ((Channel.ChanNo > 64) && (Channel.ChanNo <= 165)) { + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | 0x00143c; + Wb35Reg_Write(pHwData, 0x0864, ltmp); + } else { /* reg12 = 0x00147c at Channel 4920 ~ 5320 */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | 0x00147c; + Wb35Reg_Write(pHwData, 0x0864, ltmp); } - else if( Channel.band == BAND_TYPE_OFDM_5 ) - { - //Update Reg12 - if ((Channel.ChanNo > 64) && (Channel.ChanNo <= 165)) - { - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | 0x00143c; - Wb35Reg_Write( pHwData, 0x0864, ltmp ); - } - else //reg12 = 0x00147c at Channel 4920 ~ 5320 - { - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | 0x00147c; - Wb35Reg_Write( pHwData, 0x0864, ltmp ); - } - count = sizeof(al7230_channel_data_5) / sizeof(al7230_channel_data_5[0]); + count = sizeof(al7230_channel_data_5) / sizeof(al7230_channel_data_5[0]); - for (i=0; i<count; i++) - { - if (al7230_channel_data_5[i][0] == Channel.ChanNo) - { - for( j=0; j<3; j++ ) - pltmp[j] = (1 << 31) | (0 << 30) | (24 << 24) | ( al7230_channel_data_5[i][j+1]&0xffffff); - Wb35Reg_BurstWrite( pHwData, 0x0864, pltmp, 3, NO_INCREMENT ); - } + for (i = 0; i < count; i++) { + if (al7230_channel_data_5[i][0] == Channel.ChanNo) { + for (j = 0; j < 3; j++) + pltmp[j] = (1 << 31) | (0 << 30) | (24 << 24) | (al7230_channel_data_5[i][j+1] & 0xffffff); + Wb35Reg_BurstWrite(pHwData, 0x0864, pltmp, 3, NO_INCREMENT); } } - set_tx_power_per_channel_al7230(pHwData, Channel); - break; - - case RF_WB_242: - case RF_WB_242_1: // 20060619.5 Add + } + set_tx_power_per_channel_al7230(pHwData, Channel); + break; + case RF_WB_242: + case RF_WB_242_1: - if( Channel.band <= BAND_TYPE_OFDM_24 ) // channel 1 ~ 14 - { - ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( w89rf242_channel_data_24[Channel.ChanNo-1][0], 24); - Wb35Reg_Write( pHwData, 0x864, ltmp ); - } - set_tx_power_per_channel_wb242(pHwData, Channel); - break; + if (Channel.band <= BAND_TYPE_OFDM_24) { /* channel 1 ~ 14 */ + ltmp = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse(w89rf242_channel_data_24[Channel.ChanNo-1][0], 24); + Wb35Reg_Write(pHwData, 0x864, ltmp); + } + set_tx_power_per_channel_wb242(pHwData, Channel); + break; } - if( Channel.band <= BAND_TYPE_OFDM_24 ) - { - // BB: select 2.4 GHz, bit[12-11]=00 - reg->BB50 &= ~(BIT(11)|BIT(12)); - Wb35Reg_Write( pHwData, 0x1050, reg->BB50 ); // MODE_Ctrl - // MAC: select 2.4 GHz, bit[5]=0 + if (Channel.band <= BAND_TYPE_OFDM_24) { + /* BB: select 2.4 GHz, bit[12-11]=00 */ + reg->BB50 &= ~(BIT(11) | BIT(12)); + Wb35Reg_Write(pHwData, 0x1050, reg->BB50); /* MODE_Ctrl */ + /* MAC: select 2.4 GHz, bit[5]=0 */ reg->M78_ERPInformation &= ~BIT(5); - Wb35Reg_Write( pHwData, 0x0878, reg->M78_ERPInformation ); - // enable 11b Baseband + Wb35Reg_Write(pHwData, 0x0878, reg->M78_ERPInformation); + /* enable 11b Baseband */ reg->BB30 &= ~BIT(31); - Wb35Reg_Write( pHwData, 0x1030, reg->BB30 ); - } - else if( (Channel.band == BAND_TYPE_OFDM_5) ) - { - // BB: select 5 GHz - reg->BB50 &= ~(BIT(11)|BIT(12)); - if (Channel.ChanNo <=64 ) - reg->BB50 |= BIT(12); // 10-5.25GHz + Wb35Reg_Write(pHwData, 0x1030, reg->BB30); + } else if (Channel.band == BAND_TYPE_OFDM_5) { + /* BB: select 5 GHz */ + reg->BB50 &= ~(BIT(11) | BIT(12)); + if (Channel.ChanNo <= 64) + reg->BB50 |= BIT(12); /* 10-5.25GHz */ else if ((Channel.ChanNo >= 100) && (Channel.ChanNo <= 124)) - reg->BB50 |= BIT(11); // 01-5.48GHz - else if ((Channel.ChanNo >=128) && (Channel.ChanNo <= 161)) - reg->BB50 |= (BIT(12)|BIT(11)); // 11-5.775GHz - else //Chan 184 ~ 196 will use bit[12-11] = 10 in version sh-src-1.2.25 + reg->BB50 |= BIT(11); /* 01-5.48GHz */ + else if ((Channel.ChanNo >= 128) && (Channel.ChanNo <= 161)) + reg->BB50 |= (BIT(12) | BIT(11)); /* 11-5.775GHz */ + else /* Chan 184 ~ 196 will use bit[12-11] = 10 in version sh-src-1.2.25 */ reg->BB50 |= BIT(12); - Wb35Reg_Write( pHwData, 0x1050, reg->BB50 ); // MODE_Ctrl + Wb35Reg_Write(pHwData, 0x1050, reg->BB50); /* MODE_Ctrl */ - //(1) M78 should alway use 2.4G setting when using RF_AIROHA_7230 - //(2) BB30 has been updated previously. - if (pHwData->phy_type != RF_AIROHA_7230) - { - // MAC: select 5 GHz, bit[5]=1 + /* (1) M78 should alway use 2.4G setting when using RF_AIROHA_7230 */ + /* (2) BB30 has been updated previously. */ + if (pHwData->phy_type != RF_AIROHA_7230) { + /* MAC: select 5 GHz, bit[5]=1 */ reg->M78_ERPInformation |= BIT(5); - Wb35Reg_Write( pHwData, 0x0878, reg->M78_ERPInformation ); + Wb35Reg_Write(pHwData, 0x0878, reg->M78_ERPInformation); - // disable 11b Baseband + /* disable 11b Baseband */ reg->BB30 |= BIT(31); - Wb35Reg_Write( pHwData, 0x1030, reg->BB30 ); + Wb35Reg_Write(pHwData, 0x1030, reg->BB30); } } } -//Set the tx power directly from DUT GUI, not from the EEPROM. Return the current setting -u8 RFSynthesizer_SetPowerIndex( struct hw_data * pHwData, u8 PowerIndex ) +/* + * Set the tx power directly from DUT GUI, not from the EEPROM. + * Return the current setting + */ +u8 RFSynthesizer_SetPowerIndex(struct hw_data *pHwData, u8 PowerIndex) { u32 Band = pHwData->band; - u8 index=0; + u8 index = 0; - if( pHwData->power_index == PowerIndex ) // 20060620.1 Add + if (pHwData->power_index == PowerIndex) return PowerIndex; - if (RF_MAXIM_2825 == pHwData->phy_type) - { - // Channel 1 - 13 - index = RFSynthesizer_SetMaxim2825Power( pHwData, PowerIndex ); - } - else if (RF_MAXIM_2827 == pHwData->phy_type) - { - if( Band <= BAND_TYPE_OFDM_24 ) // Channel 1 - 13 - index = RFSynthesizer_SetMaxim2827_24Power( pHwData, PowerIndex ); - else// if( Band == BAND_TYPE_OFDM_5 ) // Channel 36 - 64 - index = RFSynthesizer_SetMaxim2827_50Power( pHwData, PowerIndex ); - } - else if (RF_MAXIM_2828 == pHwData->phy_type) - { - if( Band <= BAND_TYPE_OFDM_24 ) // Channel 1 - 13 - index = RFSynthesizer_SetMaxim2828_24Power( pHwData, PowerIndex ); - else// if( Band == BAND_TYPE_OFDM_5 ) // Channel 36 - 64 - index = RFSynthesizer_SetMaxim2828_50Power( pHwData, PowerIndex ); - } - else if( RF_AIROHA_2230 == pHwData->phy_type ) - { - //Power index: 0 ~ 63 // Channel 1 - 14 - index = RFSynthesizer_SetAiroha2230Power( pHwData, PowerIndex ); - index = (u8)al2230_txvga_data[index][1]; - } - else if( RF_AIROHA_2230S == pHwData->phy_type ) // 20060420 Add this - { - //Power index: 0 ~ 63 // Channel 1 - 14 - index = RFSynthesizer_SetAiroha2230Power( pHwData, PowerIndex ); - index = (u8)al2230_txvga_data[index][1]; - } - else if( RF_AIROHA_7230 == pHwData->phy_type ) - { - //Power index: 0 ~ 63 - index = RFSynthesizer_SetAiroha7230Power( pHwData, PowerIndex ); + if (RF_MAXIM_2825 == pHwData->phy_type) { + /* Channel 1 - 13 */ + index = RFSynthesizer_SetMaxim2825Power(pHwData, PowerIndex); + } else if (RF_MAXIM_2827 == pHwData->phy_type) { + if (Band <= BAND_TYPE_OFDM_24) /* Channel 1 - 13 */ + index = RFSynthesizer_SetMaxim2827_24Power(pHwData, PowerIndex); + else /* Channel 36 - 64 */ + index = RFSynthesizer_SetMaxim2827_50Power(pHwData, PowerIndex); + } else if (RF_MAXIM_2828 == pHwData->phy_type) { + if (Band <= BAND_TYPE_OFDM_24) /* Channel 1 - 13 */ + index = RFSynthesizer_SetMaxim2828_24Power(pHwData, PowerIndex); + else /* Channel 36 - 64 */ + index = RFSynthesizer_SetMaxim2828_50Power(pHwData, PowerIndex); + } else if (RF_AIROHA_2230 == pHwData->phy_type) { + /* Power index: 0 ~ 63 --- Channel 1 - 14 */ + index = RFSynthesizer_SetAiroha2230Power(pHwData, PowerIndex); + index = (u8) al2230_txvga_data[index][1]; + } else if (RF_AIROHA_2230S == pHwData->phy_type) { + /* Power index: 0 ~ 63 --- Channel 1 - 14 */ + index = RFSynthesizer_SetAiroha2230Power(pHwData, PowerIndex); + index = (u8) al2230_txvga_data[index][1]; + } else if (RF_AIROHA_7230 == pHwData->phy_type) { + /* Power index: 0 ~ 63 */ + index = RFSynthesizer_SetAiroha7230Power(pHwData, PowerIndex); index = (u8)al7230_txvga_data[index][1]; - } - else if( (RF_WB_242 == pHwData->phy_type) || - (RF_WB_242_1 == pHwData->phy_type) ) // 20060619.5 Add - { - //Power index: 0 ~ 19 for original. New range is 0 ~ 33 - index = RFSynthesizer_SetWinbond242Power( pHwData, PowerIndex ); + } else if ((RF_WB_242 == pHwData->phy_type) || + (RF_WB_242_1 == pHwData->phy_type)) { + /* Power index: 0 ~ 19 for original. New range is 0 ~ 33 */ + index = RFSynthesizer_SetWinbond242Power(pHwData, PowerIndex); index = (u8)w89rf242_txvga_data[index][1]; } - pHwData->power_index = index; // Backup current + pHwData->power_index = index; /* Backup current */ return index; } -//-- Sub function -u8 RFSynthesizer_SetMaxim2828_24Power( struct hw_data * pHwData, u8 index ) +/* -- Sub function */ +u8 RFSynthesizer_SetMaxim2828_24Power(struct hw_data *pHwData, u8 index) { - u32 PowerData; - if( index > 1 ) index = 1; - PowerData = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( max2828_power_data_24[index], 18); - Wb35Reg_Write( pHwData, 0x0864, PowerData ); + u32 PowerData; + if (index > 1) + index = 1; + PowerData = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(max2828_power_data_24[index], 18); + Wb35Reg_Write(pHwData, 0x0864, PowerData); return index; } -//-- -u8 RFSynthesizer_SetMaxim2828_50Power( struct hw_data * pHwData, u8 index ) + +u8 RFSynthesizer_SetMaxim2828_50Power(struct hw_data *pHwData, u8 index) { - u32 PowerData; - if( index > 1 ) index = 1; - PowerData = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( max2828_power_data_50[index], 18); - Wb35Reg_Write( pHwData, 0x0864, PowerData ); + u32 PowerData; + if (index > 1) + index = 1; + PowerData = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(max2828_power_data_50[index], 18); + Wb35Reg_Write(pHwData, 0x0864, PowerData); return index; } -//-- -u8 RFSynthesizer_SetMaxim2827_24Power( struct hw_data * pHwData, u8 index ) + +u8 RFSynthesizer_SetMaxim2827_24Power(struct hw_data *pHwData, u8 index) { - u32 PowerData; - if( index > 1 ) index = 1; - PowerData = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( max2827_power_data_24[index], 18); - Wb35Reg_Write( pHwData, 0x0864, PowerData ); + u32 PowerData; + if (index > 1) + index = 1; + PowerData = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(max2827_power_data_24[index], 18); + Wb35Reg_Write(pHwData, 0x0864, PowerData); return index; } -//-- -u8 RFSynthesizer_SetMaxim2827_50Power( struct hw_data * pHwData, u8 index ) + +u8 RFSynthesizer_SetMaxim2827_50Power(struct hw_data *pHwData, u8 index) { - u32 PowerData; - if( index > 1 ) index = 1; - PowerData = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( max2827_power_data_50[index], 18); - Wb35Reg_Write( pHwData, 0x0864, PowerData ); + u32 PowerData; + if (index > 1) + index = 1; + PowerData = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(max2827_power_data_50[index], 18); + Wb35Reg_Write(pHwData, 0x0864, PowerData); return index; } -//-- -u8 RFSynthesizer_SetMaxim2825Power( struct hw_data * pHwData, u8 index ) + +u8 RFSynthesizer_SetMaxim2825Power(struct hw_data *pHwData, u8 index) { - u32 PowerData; - if( index > 1 ) index = 1; - PowerData = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse( max2825_power_data_24[index], 18); - Wb35Reg_Write( pHwData, 0x0864, PowerData ); + u32 PowerData; + if (index > 1) + index = 1; + PowerData = (1 << 31) | (0 << 30) | (18 << 24) | BitReverse(max2825_power_data_24[index], 18); + Wb35Reg_Write(pHwData, 0x0864, PowerData); return index; } -//-- -u8 RFSynthesizer_SetAiroha2230Power( struct hw_data * pHwData, u8 index ) + +u8 RFSynthesizer_SetAiroha2230Power(struct hw_data *pHwData, u8 index) { - u32 PowerData; - u8 i,count; + u32 PowerData; + u8 i, count; count = sizeof(al2230_txvga_data) / sizeof(al2230_txvga_data[0]); - for (i=0; i<count; i++) - { + for (i = 0; i < count; i++) { if (al2230_txvga_data[i][1] >= index) break; } if (i == count) i--; - PowerData = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse( al2230_txvga_data[i][0], 20); - Wb35Reg_Write( pHwData, 0x0864, PowerData ); + PowerData = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse(al2230_txvga_data[i][0], 20); + Wb35Reg_Write(pHwData, 0x0864, PowerData); return i; } -//-- -u8 RFSynthesizer_SetAiroha7230Power( struct hw_data * pHwData, u8 index ) + +u8 RFSynthesizer_SetAiroha7230Power(struct hw_data *pHwData, u8 index) { - u32 PowerData; - u8 i,count; + u32 PowerData; + u8 i, count; - //PowerData = (1 << 31) | (0 << 30) | (20 << 24) | BitReverse( airoha_power_data_24[index], 20); count = sizeof(al7230_txvga_data) / sizeof(al7230_txvga_data[0]); - for (i=0; i<count; i++) - { + for (i = 0; i < count; i++) { if (al7230_txvga_data[i][1] >= index) break; } if (i == count) i--; - PowerData = (1 << 31) | (0 << 30) | (24 << 24) | (al7230_txvga_data[i][0]&0xffffff); - Wb35Reg_Write( pHwData, 0x0864, PowerData ); + PowerData = (1 << 31) | (0 << 30) | (24 << 24) | (al7230_txvga_data[i][0] & 0xffffff); + Wb35Reg_Write(pHwData, 0x0864, PowerData); return i; } -u8 RFSynthesizer_SetWinbond242Power( struct hw_data * pHwData, u8 index ) +u8 RFSynthesizer_SetWinbond242Power(struct hw_data *pHwData, u8 index) { - u32 PowerData; - u8 i,count; + u32 PowerData; + u8 i, count; count = sizeof(w89rf242_txvga_data) / sizeof(w89rf242_txvga_data[0]); - for (i=0; i<count; i++) - { + for (i = 0; i < count; i++) { if (w89rf242_txvga_data[i][1] >= index) break; } if (i == count) i--; - // Set TxVga into RF - PowerData = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( w89rf242_txvga_data[i][0], 24); - Wb35Reg_Write( pHwData, 0x0864, PowerData ); - - // Update BB48 BB4C BB58 for high precision txvga - Wb35Reg_Write( pHwData, 0x1048, w89rf242_txvga_data[i][2] ); - Wb35Reg_Write( pHwData, 0x104c, w89rf242_txvga_data[i][3] ); - Wb35Reg_Write( pHwData, 0x1058, w89rf242_txvga_data[i][4] ); - -// Rf vga 0 ~ 3 for temperature compensate. It will affect the scan Bss. -// The i value equals to 8 or 7 usually. So It's not necessary to setup this RF register. -// if( i <= 3 ) -// PowerData = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( 0x000024, 24 ); -// else -// PowerData = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse( 0x001824, 24 ); -// Wb35Reg_Write( pHwData, 0x0864, PowerData ); + /* Set TxVga into RF */ + PowerData = (1 << 31) | (0 << 30) | (24 << 24) | BitReverse(w89rf242_txvga_data[i][0], 24); + Wb35Reg_Write(pHwData, 0x0864, PowerData); + + /* Update BB48 BB4C BB58 for high precision txvga */ + Wb35Reg_Write(pHwData, 0x1048, w89rf242_txvga_data[i][2]); + Wb35Reg_Write(pHwData, 0x104c, w89rf242_txvga_data[i][3]); + Wb35Reg_Write(pHwData, 0x1058, w89rf242_txvga_data[i][4]); + return i; } -//=========================================================================================================== -// Dxx_initial -- -// Mxx_initial -- - // -// Routine Description: -// Initial the hardware setting and module variable - // -//=========================================================================================================== -void Dxx_initial( struct hw_data * pHwData ) +/* + * =========================================================================== + * Dxx_initial -- + * Mxx_initial -- + * + * Routine Description: + * Initial the hardware setting and module variable + * =========================================================================== + */ +void Dxx_initial(struct hw_data *pHwData) { struct wb35_reg *reg = &pHwData->reg; - // Old IC:Single mode only. - // New IC: operation decide by Software set bit[4]. 1:multiple 0: single - reg->D00_DmaControl = 0xc0000004; //Txon, Rxon, multiple Rx for new 4k DMA - //Txon, Rxon, single Rx for old 8k ASIC - if( !HAL_USB_MODE_BURST( pHwData ) ) - reg->D00_DmaControl = 0xc0000000;//Txon, Rxon, single Rx for new 4k DMA + /* + * Old IC: Single mode only. + * New IC: operation decide by Software set bit[4]. 1:multiple 0: single + */ + reg->D00_DmaControl = 0xc0000004; /* Txon, Rxon, multiple Rx for new 4k DMA */ + /* Txon, Rxon, single Rx for old 8k ASIC */ + if (!HAL_USB_MODE_BURST(pHwData)) + reg->D00_DmaControl = 0xc0000000; /* Txon, Rxon, single Rx for new 4k DMA */ - Wb35Reg_WriteSync( pHwData, 0x0400, reg->D00_DmaControl ); + Wb35Reg_WriteSync(pHwData, 0x0400, reg->D00_DmaControl); } -void Mxx_initial( struct hw_data * pHwData ) +void Mxx_initial(struct hw_data *pHwData) { struct wb35_reg *reg = &pHwData->reg; - u32 tmp; - u32 pltmp[11]; + u32 tmp; + u32 pltmp[11]; u16 i; - //====================================================== - // Initial Mxx register - //====================================================== + /* + * ====================================================== + * Initial Mxx register + * ====================================================== + */ - // M00 bit set -#ifdef _IBSS_BEACON_SEQ_STICK_ - reg->M00_MacControl = 0; // Solve beacon sequence number stop by software -#else - reg->M00_MacControl = 0x80000000; // Solve beacon sequence number stop by hardware -#endif + /* M00 bit set */ + #ifdef _IBSS_BEACON_SEQ_STICK_ + reg->M00_MacControl = 0; /* Solve beacon sequence number stop by software */ + #else + reg->M00_MacControl = 0x80000000; /* Solve beacon sequence number stop by hardware */ + #endif - // M24 disable enter power save, BB RxOn and enable NAV attack + /* M24 disable enter power save, BB RxOn and enable NAV attack */ reg->M24_MacControl = 0x08040042; pltmp[0] = reg->M24_MacControl; - pltmp[1] = 0; // Skip M28, because no initialize value is required. + pltmp[1] = 0; /* Skip M28, because no initialize value is required. */ - // M2C CWmin and CWmax setting + /* M2C CWmin and CWmax setting */ pHwData->cwmin = DEFAULT_CWMIN; pHwData->cwmax = DEFAULT_CWMAX; reg->M2C_MacControl = DEFAULT_CWMIN << 10; reg->M2C_MacControl |= DEFAULT_CWMAX; pltmp[2] = reg->M2C_MacControl; - // M30 BSSID + /* M30 BSSID */ pltmp[3] = *(u32 *)pHwData->bssid; - // M34 + /* M34 */ pHwData->AID = DEFAULT_AID; - tmp = *(u16 *)(pHwData->bssid+4); + tmp = *(u16 *) (pHwData->bssid + 4); tmp |= DEFAULT_AID << 16; pltmp[4] = tmp; - // M38 - reg->M38_MacControl = (DEFAULT_RATE_RETRY_LIMIT<<8) | (DEFAULT_LONG_RETRY_LIMIT << 4) | DEFAULT_SHORT_RETRY_LIMIT; + /* M38 */ + reg->M38_MacControl = (DEFAULT_RATE_RETRY_LIMIT << 8) | (DEFAULT_LONG_RETRY_LIMIT << 4) | DEFAULT_SHORT_RETRY_LIMIT; pltmp[5] = reg->M38_MacControl; - // M3C + /* M3C */ tmp = (DEFAULT_PIFST << 26) | (DEFAULT_EIFST << 16) | (DEFAULT_DIFST << 8) | (DEFAULT_SIFST << 4) | DEFAULT_OSIFST ; reg->M3C_MacControl = tmp; pltmp[6] = tmp; - // M40 + /* M40 */ pHwData->slot_time_select = DEFAULT_SLOT_TIME; tmp = (DEFAULT_ATIMWD << 16) | DEFAULT_SLOT_TIME; reg->M40_MacControl = tmp; pltmp[7] = tmp; - // M44 - tmp = DEFAULT_MAX_TX_MSDU_LIFE_TIME << 10; // *1024 + /* M44 */ + tmp = DEFAULT_MAX_TX_MSDU_LIFE_TIME << 10; /* *1024 */ reg->M44_MacControl = tmp; pltmp[8] = tmp; - // M48 + /* M48 */ pHwData->BeaconPeriod = DEFAULT_BEACON_INTERVAL; pHwData->ProbeDelay = DEFAULT_PROBE_DELAY_TIME; tmp = (DEFAULT_BEACON_INTERVAL << 16) | DEFAULT_PROBE_DELAY_TIME; reg->M48_MacControl = tmp; pltmp[9] = tmp; - //M4C + /* M4C */ reg->M4C_MacStatus = (DEFAULT_PROTOCOL_VERSION << 30) | (DEFAULT_MAC_POWER_STATE << 28) | (DEFAULT_DTIM_ALERT_TIME << 24); pltmp[10] = reg->M4C_MacStatus; - // Burst write - //Wb35Reg_BurstWrite( pHwData, 0x0824, pltmp, 11, AUTO_INCREMENT ); - for( i=0; i<11; i++ ) - Wb35Reg_WriteSync( pHwData, 0x0824 + i*4, pltmp[i] ); + for (i = 0; i < 11; i++) + Wb35Reg_WriteSync(pHwData, 0x0824 + i * 4, pltmp[i]); - // M60 - Wb35Reg_WriteSync( pHwData, 0x0860, 0x12481248 ); + /* M60 */ + Wb35Reg_WriteSync(pHwData, 0x0860, 0x12481248); reg->M60_MacControl = 0x12481248; - // M68 - Wb35Reg_WriteSync( pHwData, 0x0868, 0x00050900 ); // 20051018 0x000F0F00 ); // 940930 0x00131300 + /* M68 */ + Wb35Reg_WriteSync(pHwData, 0x0868, 0x00050900); reg->M68_MacControl = 0x00050900; - // M98 - Wb35Reg_WriteSync( pHwData, 0x0898, 0xffff8888 ); + /* M98 */ + Wb35Reg_WriteSync(pHwData, 0x0898, 0xffff8888); reg->M98_MacControl = 0xffff8888; } -void Uxx_power_off_procedure( struct hw_data * pHwData ) +void Uxx_power_off_procedure(struct hw_data *pHwData) { - // SW, PMU reset and turn off clock - Wb35Reg_WriteSync( pHwData, 0x03b0, 3 ); - Wb35Reg_WriteSync( pHwData, 0x03f0, 0xf9 ); + /* SW, PMU reset and turn off clock */ + Wb35Reg_WriteSync(pHwData, 0x03b0, 3); + Wb35Reg_WriteSync(pHwData, 0x03f0, 0xf9); } -//Decide the TxVga of every channel -void GetTxVgaFromEEPROM( struct hw_data * pHwData ) +/*Decide the TxVga of every channel */ +void GetTxVgaFromEEPROM(struct hw_data *pHwData) { - u32 i, j, ltmp; - u16 Value[MAX_TXVGA_EEPROM]; - u8 *pctmp; - u8 ctmp=0; - - // Get the entire TxVga setting in EEPROM - for( i=0; i<MAX_TXVGA_EEPROM; i++ ) - { - Wb35Reg_WriteSync( pHwData, 0x03b4, 0x08100000 + 0x00010000*i ); - Wb35Reg_ReadSync( pHwData, 0x03b4, <mp ); - Value[i] = (u16)( ltmp & 0xffff ); // Get 16 bit available - Value[i] = cpu_to_le16( Value[i] ); // [7:0]2412 [7:0]2417 .... + u32 i, j, ltmp; + u16 Value[MAX_TXVGA_EEPROM]; + u8 *pctmp; + u8 ctmp = 0; + + /* Get the entire TxVga setting in EEPROM */ + for (i = 0; i < MAX_TXVGA_EEPROM; i++) { + Wb35Reg_WriteSync(pHwData, 0x03b4, 0x08100000 + 0x00010000 * i); + Wb35Reg_ReadSync(pHwData, 0x03b4, <mp); + Value[i] = (u16) (ltmp & 0xffff); /* Get 16 bit available */ + Value[i] = cpu_to_le16(Value[i]); /* [7:0]2412 [7:0]2417 .... */ } - // Adjust the filed which fills with reserved value. - pctmp = (u8 *)Value; - for( i=0; i<(MAX_TXVGA_EEPROM*2); i++ ) - { - if( pctmp[i] != 0xff ) + /* Adjust the filed which fills with reserved value. */ + pctmp = (u8 *) Value; + for (i = 0; i < (MAX_TXVGA_EEPROM * 2); i++) { + if (pctmp[i] != 0xff) ctmp = pctmp[i]; else pctmp[i] = ctmp; } - // Adjust WB_242 to WB_242_1 TxVga scale - if( pHwData->phy_type == RF_WB_242 ) - { - for( i=0; i<4; i++ ) // Only 2412 2437 2462 2484 case must be modified - { - for( j=0; j<(sizeof(w89rf242_txvga_old_mapping)/sizeof(w89rf242_txvga_old_mapping[0])); j++ ) - { - if( pctmp[i] < (u8)w89rf242_txvga_old_mapping[j][1] ) - { - pctmp[i] = (u8)w89rf242_txvga_old_mapping[j][0]; + /* Adjust WB_242 to WB_242_1 TxVga scale */ + if (pHwData->phy_type == RF_WB_242) { + for (i = 0; i < 4; i++) { /* Only 2412 2437 2462 2484 case must be modified */ + for (j = 0; j < (sizeof(w89rf242_txvga_old_mapping) / sizeof(w89rf242_txvga_old_mapping[0])); j++) { + if (pctmp[i] < (u8) w89rf242_txvga_old_mapping[j][1]) { + pctmp[i] = (u8) w89rf242_txvga_old_mapping[j][0]; break; } } - if( j == (sizeof(w89rf242_txvga_old_mapping)/sizeof(w89rf242_txvga_old_mapping[0])) ) + if (j == (sizeof(w89rf242_txvga_old_mapping) / sizeof(w89rf242_txvga_old_mapping[0]))) pctmp[i] = (u8)w89rf242_txvga_old_mapping[j-1][0]; } } - // 20060621 Add - memcpy( pHwData->TxVgaSettingInEEPROM, pctmp, MAX_TXVGA_EEPROM*2 ); //MAX_TXVGA_EEPROM is u16 count - EEPROMTxVgaAdjust( pHwData ); + memcpy(pHwData->TxVgaSettingInEEPROM, pctmp, MAX_TXVGA_EEPROM * 2); /* MAX_TXVGA_EEPROM is u16 count */ + EEPROMTxVgaAdjust(pHwData); } -// This function will affect the TxVga parameter in HAL. If hal_set_current_channel -// or RFSynthesizer_SetPowerIndex be called, new TxVga will take effect. -// TxVgaSettingInEEPROM of sHwData is an u8 array point to EEPROM contain for IS89C35 -// This function will use default TxVgaSettingInEEPROM data to calculate new TxVga. -void EEPROMTxVgaAdjust( struct hw_data * pHwData ) // 20060619.5 Add +/* + * This function will affect the TxVga parameter in HAL. If hal_set_current_channel + * or RFSynthesizer_SetPowerIndex be called, new TxVga will take effect. + * TxVgaSettingInEEPROM of sHwData is an u8 array point to EEPROM contain for IS89C35 + * This function will use default TxVgaSettingInEEPROM data to calculate new TxVga. + */ +void EEPROMTxVgaAdjust(struct hw_data *pHwData) { - u8 * pTxVga = pHwData->TxVgaSettingInEEPROM; - s16 i, stmp; + u8 *pTxVga = pHwData->TxVgaSettingInEEPROM; + s16 i, stmp; - //-- 2.4G -- 20060704.2 Request from Tiger - //channel 1 ~ 5 + /* -- 2.4G -- */ + /* channel 1 ~ 5 */ stmp = pTxVga[1] - pTxVga[0]; - for( i=0; i<5; i++ ) - pHwData->TxVgaFor24[i] = pTxVga[0] + stmp*i/4; - //channel 6 ~ 10 + for (i = 0; i < 5; i++) + pHwData->TxVgaFor24[i] = pTxVga[0] + stmp * i / 4; + /* channel 6 ~ 10 */ stmp = pTxVga[2] - pTxVga[1]; - for( i=5; i<10; i++ ) - pHwData->TxVgaFor24[i] = pTxVga[1] + stmp*(i-5)/4; - //channel 11 ~ 13 + for (i = 5; i < 10; i++) + pHwData->TxVgaFor24[i] = pTxVga[1] + stmp * (i - 5) / 4; + /* channel 11 ~ 13 */ stmp = pTxVga[3] - pTxVga[2]; - for( i=10; i<13; i++ ) - pHwData->TxVgaFor24[i] = pTxVga[2] + stmp*(i-10)/2; - //channel 14 + for (i = 10; i < 13; i++) + pHwData->TxVgaFor24[i] = pTxVga[2] + stmp * (i - 10) / 2; + /* channel 14 */ pHwData->TxVgaFor24[13] = pTxVga[3]; - //-- 5G -- - if( pHwData->phy_type == RF_AIROHA_7230 ) - { - //channel 184 + /* -- 5G -- */ + if (pHwData->phy_type == RF_AIROHA_7230) { + /* channel 184 */ pHwData->TxVgaFor50[0].ChanNo = 184; pHwData->TxVgaFor50[0].TxVgaValue = pTxVga[4]; - //channel 196 + /* channel 196 */ pHwData->TxVgaFor50[3].ChanNo = 196; pHwData->TxVgaFor50[3].TxVgaValue = pTxVga[5]; - //interpolate + /* interpolate */ pHwData->TxVgaFor50[1].ChanNo = 188; pHwData->TxVgaFor50[2].ChanNo = 192; stmp = pTxVga[5] - pTxVga[4]; - pHwData->TxVgaFor50[2].TxVgaValue = pTxVga[5] - stmp/3; - pHwData->TxVgaFor50[1].TxVgaValue = pTxVga[5] - stmp*2/3; + pHwData->TxVgaFor50[2].TxVgaValue = pTxVga[5] - stmp / 3; + pHwData->TxVgaFor50[1].TxVgaValue = pTxVga[5] - stmp * 2 / 3; - //channel 16 + /* channel 16 */ pHwData->TxVgaFor50[6].ChanNo = 16; pHwData->TxVgaFor50[6].TxVgaValue = pTxVga[6]; pHwData->TxVgaFor50[4].ChanNo = 8; @@ -2523,7 +2250,7 @@ void EEPROMTxVgaAdjust( struct hw_data * pHwData ) // 20060619.5 Add pHwData->TxVgaFor50[5].ChanNo = 12; pHwData->TxVgaFor50[5].TxVgaValue = pTxVga[6]; - //channel 36 + /* channel 36 */ pHwData->TxVgaFor50[8].ChanNo = 36; pHwData->TxVgaFor50[8].TxVgaValue = pTxVga[7]; pHwData->TxVgaFor50[7].ChanNo = 34; @@ -2531,153 +2258,135 @@ void EEPROMTxVgaAdjust( struct hw_data * pHwData ) // 20060619.5 Add pHwData->TxVgaFor50[9].ChanNo = 38; pHwData->TxVgaFor50[9].TxVgaValue = pTxVga[7]; - //channel 40 + /* channel 40 */ pHwData->TxVgaFor50[10].ChanNo = 40; pHwData->TxVgaFor50[10].TxVgaValue = pTxVga[8]; - //channel 48 + /* channel 48 */ pHwData->TxVgaFor50[14].ChanNo = 48; pHwData->TxVgaFor50[14].TxVgaValue = pTxVga[9]; - //interpolate + /* interpolate */ pHwData->TxVgaFor50[11].ChanNo = 42; pHwData->TxVgaFor50[12].ChanNo = 44; pHwData->TxVgaFor50[13].ChanNo = 46; stmp = pTxVga[9] - pTxVga[8]; - pHwData->TxVgaFor50[13].TxVgaValue = pTxVga[9] - stmp/4; - pHwData->TxVgaFor50[12].TxVgaValue = pTxVga[9] - stmp*2/4; - pHwData->TxVgaFor50[11].TxVgaValue = pTxVga[9] - stmp*3/4; + pHwData->TxVgaFor50[13].TxVgaValue = pTxVga[9] - stmp / 4; + pHwData->TxVgaFor50[12].TxVgaValue = pTxVga[9] - stmp * 2 / 4; + pHwData->TxVgaFor50[11].TxVgaValue = pTxVga[9] - stmp * 3 / 4; - //channel 52 + /* channel 52 */ pHwData->TxVgaFor50[15].ChanNo = 52; pHwData->TxVgaFor50[15].TxVgaValue = pTxVga[10]; - //channel 64 + /* channel 64 */ pHwData->TxVgaFor50[18].ChanNo = 64; pHwData->TxVgaFor50[18].TxVgaValue = pTxVga[11]; - //interpolate + /* interpolate */ pHwData->TxVgaFor50[16].ChanNo = 56; pHwData->TxVgaFor50[17].ChanNo = 60; stmp = pTxVga[11] - pTxVga[10]; - pHwData->TxVgaFor50[17].TxVgaValue = pTxVga[11] - stmp/3; - pHwData->TxVgaFor50[16].TxVgaValue = pTxVga[11] - stmp*2/3; + pHwData->TxVgaFor50[17].TxVgaValue = pTxVga[11] - stmp / 3; + pHwData->TxVgaFor50[16].TxVgaValue = pTxVga[11] - stmp * 2 / 3; - //channel 100 + /* channel 100 */ pHwData->TxVgaFor50[19].ChanNo = 100; pHwData->TxVgaFor50[19].TxVgaValue = pTxVga[12]; - //channel 112 + /* channel 112 */ pHwData->TxVgaFor50[22].ChanNo = 112; pHwData->TxVgaFor50[22].TxVgaValue = pTxVga[13]; - //interpolate + /* interpolate */ pHwData->TxVgaFor50[20].ChanNo = 104; pHwData->TxVgaFor50[21].ChanNo = 108; stmp = pTxVga[13] - pTxVga[12]; - pHwData->TxVgaFor50[21].TxVgaValue = pTxVga[13] - stmp/3; - pHwData->TxVgaFor50[20].TxVgaValue = pTxVga[13] - stmp*2/3; + pHwData->TxVgaFor50[21].TxVgaValue = pTxVga[13] - stmp / 3; + pHwData->TxVgaFor50[20].TxVgaValue = pTxVga[13] - stmp * 2 / 3; - //channel 128 + /* channel 128 */ pHwData->TxVgaFor50[26].ChanNo = 128; pHwData->TxVgaFor50[26].TxVgaValue = pTxVga[14]; - //interpolate + /* interpolate */ pHwData->TxVgaFor50[23].ChanNo = 116; pHwData->TxVgaFor50[24].ChanNo = 120; pHwData->TxVgaFor50[25].ChanNo = 124; stmp = pTxVga[14] - pTxVga[13]; - pHwData->TxVgaFor50[25].TxVgaValue = pTxVga[14] - stmp/4; - pHwData->TxVgaFor50[24].TxVgaValue = pTxVga[14] - stmp*2/4; - pHwData->TxVgaFor50[23].TxVgaValue = pTxVga[14] - stmp*3/4; + pHwData->TxVgaFor50[25].TxVgaValue = pTxVga[14] - stmp / 4; + pHwData->TxVgaFor50[24].TxVgaValue = pTxVga[14] - stmp * 2 / 4; + pHwData->TxVgaFor50[23].TxVgaValue = pTxVga[14] - stmp * 3 / 4; - //channel 140 + /* channel 140 */ pHwData->TxVgaFor50[29].ChanNo = 140; pHwData->TxVgaFor50[29].TxVgaValue = pTxVga[15]; - //interpolate + /* interpolate */ pHwData->TxVgaFor50[27].ChanNo = 132; pHwData->TxVgaFor50[28].ChanNo = 136; stmp = pTxVga[15] - pTxVga[14]; - pHwData->TxVgaFor50[28].TxVgaValue = pTxVga[15] - stmp/3; - pHwData->TxVgaFor50[27].TxVgaValue = pTxVga[15] - stmp*2/3; + pHwData->TxVgaFor50[28].TxVgaValue = pTxVga[15] - stmp / 3; + pHwData->TxVgaFor50[27].TxVgaValue = pTxVga[15] - stmp * 2 / 3; - //channel 149 + /* channel 149 */ pHwData->TxVgaFor50[30].ChanNo = 149; pHwData->TxVgaFor50[30].TxVgaValue = pTxVga[16]; - //channel 165 + /* channel 165 */ pHwData->TxVgaFor50[34].ChanNo = 165; pHwData->TxVgaFor50[34].TxVgaValue = pTxVga[17]; - //interpolate + /* interpolate */ pHwData->TxVgaFor50[31].ChanNo = 153; pHwData->TxVgaFor50[32].ChanNo = 157; pHwData->TxVgaFor50[33].ChanNo = 161; stmp = pTxVga[17] - pTxVga[16]; - pHwData->TxVgaFor50[33].TxVgaValue = pTxVga[17] - stmp/4; - pHwData->TxVgaFor50[32].TxVgaValue = pTxVga[17] - stmp*2/4; - pHwData->TxVgaFor50[31].TxVgaValue = pTxVga[17] - stmp*3/4; + pHwData->TxVgaFor50[33].TxVgaValue = pTxVga[17] - stmp / 4; + pHwData->TxVgaFor50[32].TxVgaValue = pTxVga[17] - stmp * 2 / 4; + pHwData->TxVgaFor50[31].TxVgaValue = pTxVga[17] - stmp * 3 / 4; } #ifdef _PE_STATE_DUMP_ - printk(" TxVgaFor24 : \n"); - DataDmp((u8 *)pHwData->TxVgaFor24, 14 ,0); - printk(" TxVgaFor50 : \n"); - DataDmp((u8 *)pHwData->TxVgaFor50, 70 ,0); + printk(" TxVgaFor24 :\n"); + DataDmp((u8 *)pHwData->TxVgaFor24, 14 , 0); + printk(" TxVgaFor50 :\n"); + DataDmp((u8 *)pHwData->TxVgaFor50, 70 , 0); #endif } -void BBProcessor_RateChanging( struct hw_data * pHwData, u8 rate ) // 20060613.1 +void BBProcessor_RateChanging(struct hw_data *pHwData, u8 rate) { struct wb35_reg *reg = &pHwData->reg; - unsigned char Is11bRate; + unsigned char Is11bRate; Is11bRate = (rate % 6) ? 1 : 0; - switch( pHwData->phy_type ) - { - case RF_AIROHA_2230: - case RF_AIROHA_2230S: // 20060420 Add this - if( Is11bRate ) - { - if( (reg->BB48 != BB48_DEFAULT_AL2230_11B) && - (reg->BB4C != BB4C_DEFAULT_AL2230_11B) ) - { - Wb35Reg_Write( pHwData, 0x1048, BB48_DEFAULT_AL2230_11B ); - Wb35Reg_Write( pHwData, 0x104c, BB4C_DEFAULT_AL2230_11B ); - } + switch (pHwData->phy_type) { + case RF_AIROHA_2230: + case RF_AIROHA_2230S: + if (Is11bRate) { + if ((reg->BB48 != BB48_DEFAULT_AL2230_11B) && + (reg->BB4C != BB4C_DEFAULT_AL2230_11B)) { + Wb35Reg_Write(pHwData, 0x1048, BB48_DEFAULT_AL2230_11B); + Wb35Reg_Write(pHwData, 0x104c, BB4C_DEFAULT_AL2230_11B); } - else - { - if( (reg->BB48 != BB48_DEFAULT_AL2230_11G) && - (reg->BB4C != BB4C_DEFAULT_AL2230_11G) ) - { - Wb35Reg_Write( pHwData, 0x1048, BB48_DEFAULT_AL2230_11G ); - Wb35Reg_Write( pHwData, 0x104c, BB4C_DEFAULT_AL2230_11G ); - } + } else { + if ((reg->BB48 != BB48_DEFAULT_AL2230_11G) && + (reg->BB4C != BB4C_DEFAULT_AL2230_11G)) { + Wb35Reg_Write(pHwData, 0x1048, BB48_DEFAULT_AL2230_11G); + Wb35Reg_Write(pHwData, 0x104c, BB4C_DEFAULT_AL2230_11G); } - break; - - case RF_WB_242: // 20060623 The fix only for old TxVGA setting - if( Is11bRate ) - { - if( (reg->BB48 != BB48_DEFAULT_WB242_11B) && - (reg->BB4C != BB4C_DEFAULT_WB242_11B) ) - { - reg->BB48 = BB48_DEFAULT_WB242_11B; - reg->BB4C = BB4C_DEFAULT_WB242_11B; - Wb35Reg_Write( pHwData, 0x1048, BB48_DEFAULT_WB242_11B ); - Wb35Reg_Write( pHwData, 0x104c, BB4C_DEFAULT_WB242_11B ); - } + } + break; + case RF_WB_242: + if (Is11bRate) { + if ((reg->BB48 != BB48_DEFAULT_WB242_11B) && + (reg->BB4C != BB4C_DEFAULT_WB242_11B)) { + reg->BB48 = BB48_DEFAULT_WB242_11B; + reg->BB4C = BB4C_DEFAULT_WB242_11B; + Wb35Reg_Write(pHwData, 0x1048, BB48_DEFAULT_WB242_11B); + Wb35Reg_Write(pHwData, 0x104c, BB4C_DEFAULT_WB242_11B); } - else - { - if( (reg->BB48 != BB48_DEFAULT_WB242_11G) && - (reg->BB4C != BB4C_DEFAULT_WB242_11G) ) - { - reg->BB48 = BB48_DEFAULT_WB242_11G; - reg->BB4C = BB4C_DEFAULT_WB242_11G; - Wb35Reg_Write( pHwData, 0x1048, BB48_DEFAULT_WB242_11G ); - Wb35Reg_Write( pHwData, 0x104c, BB4C_DEFAULT_WB242_11G ); - } + } else { + if ((reg->BB48 != BB48_DEFAULT_WB242_11G) && + (reg->BB4C != BB4C_DEFAULT_WB242_11G)) { + reg->BB48 = BB48_DEFAULT_WB242_11G; + reg->BB4C = BB4C_DEFAULT_WB242_11G; + Wb35Reg_Write(pHwData, 0x1048, BB48_DEFAULT_WB242_11G); + Wb35Reg_Write(pHwData, 0x104c, BB4C_DEFAULT_WB242_11G); } - break; + } + break; } } - - - - - - diff --git a/drivers/staging/winbond/scan_s.h b/drivers/staging/winbond/scan_s.h index 209717f5d47d..85e7523196d0 100644 --- a/drivers/staging/winbond/scan_s.h +++ b/drivers/staging/winbond/scan_s.h @@ -4,117 +4,107 @@ #include <linux/types.h> #include "localpara.h" -// -// SCAN task global CONSTANTS, STRUCTURES, variables -// - -////////////////////////////////////////////////////////////////////////// -//define the msg type of SCAN module -#define SCANMSG_SCAN_REQ 0x01 -#define SCANMSG_BEACON 0x02 +/* + * SCAN task global CONSTANTS, STRUCTURES, variables + */ + +/* define the msg type of SCAN module */ +#define SCANMSG_SCAN_REQ 0x01 +#define SCANMSG_BEACON 0x02 #define SCANMSG_PROBE_RESPONSE 0x03 -#define SCANMSG_TIMEOUT 0x04 +#define SCANMSG_TIMEOUT 0x04 #define SCANMSG_TXPROBE_FAIL 0x05 #define SCANMSG_ENABLE_BGSCAN 0x06 -#define SCANMSG_STOP_SCAN 0x07 +#define SCANMSG_STOP_SCAN 0x07 -// BSS Type =>conform to -// IBSS : ToDS/FromDS = 00 -// Infrastructure : ToDS/FromDS = 01 +/* + * BSS Type =>conform to + * IBSS : ToDS/FromDS = 00 + * Infrastructure : ToDS/FromDS = 01 + */ #define IBSS_NET 0 #define ESS_NET 1 #define ANYBSS_NET 2 -// Scan Type +/* Scan Type */ #define ACTIVE_SCAN 0 -#define PASSIVE_SCAN 1 +#define PASSIVE_SCAN 1 + +/* Global data structures, Initial Scan & Background Scan */ +typedef struct _SCAN_REQ_PARA { /* mandatory parameters for SCAN request */ -/////////////////////////////////////////////////////////////////////////// -//Global data structures, Initial Scan & Background Scan -typedef struct _SCAN_REQ_PARA //mandatory parameters for SCAN request -{ - u32 ScanType; //passive/active scan + u32 ScanType; /* passive/active scan */ u8 reserved_1[2]; - struct SSID_Element sSSID; // 34B. scan only for this SSID + struct SSID_Element sSSID; /* 34B. scan only for this SSID */ u8 reserved_2[2]; } SCAN_REQ_PARA, *psSCAN_REQ_PARA; -typedef struct _SCAN_PARAMETERS -{ - u16 wState; - u16 iCurrentChannelIndex; +typedef struct _SCAN_PARAMETERS { + u16 wState; + u16 iCurrentChannelIndex; SCAN_REQ_PARA sScanReq; - u8 BSSID[MAC_ADDR_LENGTH + 2]; //scan only for this BSSID + u8 BSSID[MAC_ADDR_LENGTH + 2]; /* scan only for this BSSID */ - u32 BssType; //scan only for this BSS type + u32 BssType; /* scan only for this BSS type */ - //struct SSID_Element sSSID; //scan only for this SSID - u16 ProbeDelay; - u16 MinChannelTime; + u16 ProbeDelay; + u16 MinChannelTime; - u16 MaxChannelTime; - u16 reserved_1; + u16 MaxChannelTime; + u16 reserved_1; - s32 iBgScanPeriod; // XP: 5 sec + s32 iBgScanPeriod; /* XP: 5 sec */ - u8 boBgScan; // Wb: enable BG scan, For XP, this value must be FALSE - u8 boFastScan; // Wb: reserved - u8 boCCAbusy; // Wb: HWMAC CCA busy status - u8 reserved_2; + u8 boBgScan; /* Wb: enable BG scan, For XP, this value must be FALSE */ + u8 boFastScan; /* Wb: reserved */ + u8 boCCAbusy; /* Wb: HWMAC CCA busy status */ + u8 reserved_2; struct timer_list timer; - u32 ScanTimeStamp; //Increase 1 per background scan(1 minute) - u32 BssTimeStamp; //Increase 1 per connect status check - u32 RxNumPerAntenna[2]; // - - u8 AntennaToggle; // - u8 boInTimerHandler; - u8 boTimerActive; // Wb: reserved - u8 boSave; + u32 ScanTimeStamp; /* Increase 1 per background scan(1 minute) */ + u32 BssTimeStamp; /* Increase 1 per connect status check */ + u32 RxNumPerAntenna[2]; - u32 BScanEnable; // Background scan enable. Default is On + u8 AntennaToggle; + u8 boInTimerHandler; + u8 boTimerActive; /* Wb: reserved */ + u8 boSave; + u32 BScanEnable; /* Background scan enable. Default is On */ } SCAN_PARAMETERS, *psSCAN_PARAMETERS; -// Encapsulate 'adapter' data structure -#define psSCAN (&(adapter->sScanPara)) -#define psSCANREQ (&(adapter->sScanPara.sScanReq)) - -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// scan.h -// Define the related definitions of scan module -// history -- 01/14/03' created -// -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -//Define the state of scan module -#define SCAN_INACTIVE 0 -#define WAIT_PROBE_DELAY 1 -#define WAIT_RESPONSE_MIN 2 -#define WAIT_RESPONSE_MAX_ACTIVE 3 -#define WAIT_BEACON_MAX_PASSIVE 4 -#define SCAN_COMPLETE 5 -#define BG_SCAN 6 -#define BG_SCANNING 7 - - -// The value will load from EEPROM -// If 0xff is set in EEPOM, the driver will use SCAN_MAX_CHNL_TIME instead. -// The definition is in WbHal.h -// #define SCAN_MAX_CHNL_TIME (50) - - - -// static functions - -//static void ScanTimerHandler(struct wbsoft_priv * adapter); -//static void vScanTimerStart(struct wbsoft_priv * adapter, int timeout_value); -//static void vScanTimerStop(struct wbsoft_priv * adapter); - +/* Encapsulate 'adapter' data structure */ +#define psSCAN (&(adapter->sScanPara)) +#define psSCANREQ (&(adapter->sScanPara.sScanReq)) + +/* + * =========================================================== + * scan.h + * Define the related definitions of scan module + * + * =========================================================== + */ + +/* Define the state of scan module */ +#define SCAN_INACTIVE 0 +#define WAIT_PROBE_DELAY 1 +#define WAIT_RESPONSE_MIN 2 +#define WAIT_RESPONSE_MAX_ACTIVE 3 +#define WAIT_BEACON_MAX_PASSIVE 4 +#define SCAN_COMPLETE 5 +#define BG_SCAN 6 +#define BG_SCANNING 7 + + +/* + * The value will load from EEPROM + * If 0xff is set in EEPOM, the driver will use SCAN_MAX_CHNL_TIME instead. + * The definition is in WbHal.h + */ #endif diff --git a/drivers/staging/winbond/sme_api.h b/drivers/staging/winbond/sme_api.h index b5898294eb8a..8f4596c9e9b3 100644 --- a/drivers/staging/winbond/sme_api.h +++ b/drivers/staging/winbond/sme_api.h @@ -2,12 +2,6 @@ * sme_api.h * * Copyright(C) 2002 Winbond Electronics Corp. - * - * modification history - * --------------------------------------------------------------------------- - * 1.00.001, 2003-04-21, Kevin created - * 1.00.002, 2003-05-14, PD43 & PE20 modified - * */ #ifndef __SME_API_H__ @@ -18,42 +12,42 @@ #include "localpara.h" /****************** CONSTANT AND MACRO SECTION ******************************/ -#define _INLINE __inline +#define _INLINE __inline -#define MEDIA_STATE_DISCONNECTED 0 -#define MEDIA_STATE_CONNECTED 1 +#define MEDIA_STATE_DISCONNECTED 0 +#define MEDIA_STATE_CONNECTED 1 -//ARRAY CHECK -#define MAX_POWER_TO_DB 32 +/* ARRAY CHECK */ +#define MAX_POWER_TO_DB 32 /****************** TYPE DEFINITION SECTION *********************************/ /****************** EXPORTED FUNCTION DECLARATION SECTION *******************/ -// OID_802_11_BSSID +/* OID_802_11_BSSID */ s8 sme_get_bssid(void *pcore_data, u8 *pbssid); -s8 sme_get_desired_bssid(void *pcore_data, u8 *pbssid);//Not use +s8 sme_get_desired_bssid(void *pcore_data, u8 *pbssid); /* Not use */ s8 sme_set_desired_bssid(void *pcore_data, u8 *pbssid); -// OID_802_11_SSID +/* OID_802_11_SSID */ s8 sme_get_ssid(void *pcore_data, u8 *pssid, u8 *pssid_len); -s8 sme_get_desired_ssid(void *pcore_data, u8 *pssid, u8 *pssid_len);// Not use +s8 sme_get_desired_ssid(void *pcore_data, u8 *pssid, u8 *pssid_len);/* Not use */ s8 sme_set_desired_ssid(void *pcore_data, u8 *pssid, u8 ssid_len); -// OID_802_11_INFRASTRUCTURE_MODE +/* OID_802_11_INFRASTRUCTURE_MODE */ s8 sme_get_bss_type(void *pcore_data, u8 *pbss_type); -s8 sme_get_desired_bss_type(void *pcore_data, u8 *pbss_type);//Not use +s8 sme_get_desired_bss_type(void *pcore_data, u8 *pbss_type); /* Not use */ s8 sme_set_desired_bss_type(void *pcore_data, u8 bss_type); -// OID_802_11_FRAGMENTATION_THRESHOLD +/* OID_802_11_FRAGMENTATION_THRESHOLD */ s8 sme_get_fragment_threshold(void *pcore_data, u32 *pthreshold); s8 sme_set_fragment_threshold(void *pcore_data, u32 threshold); -// OID_802_11_RTS_THRESHOLD +/* OID_802_11_RTS_THRESHOLD */ s8 sme_get_rts_threshold(void *pcore_data, u32 *pthreshold); s8 sme_set_rts_threshold(void *pcore_data, u32 threshold); -// OID_802_11_CONFIGURATION +/* OID_802_11_CONFIGURATION */ s8 sme_get_beacon_period(void *pcore_data, u16 *pbeacon_period); s8 sme_set_beacon_period(void *pcore_data, u16 beacon_period); @@ -64,116 +58,69 @@ s8 sme_get_current_channel(void *pcore_data, u8 *pcurrent_channel); s8 sme_get_current_band(void *pcore_data, u8 *pcurrent_band); s8 sme_set_current_channel(void *pcore_data, u8 current_channel); -// OID_802_11_BSSID_LIST +/* OID_802_11_BSSID_LIST */ s8 sme_get_scan_bss_count(void *pcore_data, u8 *pcount); s8 sme_get_scan_bss(void *pcore_data, u8 index, void **ppbss); s8 sme_get_connected_bss(void *pcore_data, void **ppbss_now); -// OID_802_11_AUTHENTICATION_MODE +/* OID_802_11_AUTHENTICATION_MODE */ s8 sme_get_auth_mode(void *pcore_data, u8 *pauth_mode); s8 sme_set_auth_mode(void *pcore_data, u8 auth_mode); -// OID_802_11_WEP_STATUS / OID_802_11_ENCRYPTION_STATUS +/* OID_802_11_WEP_STATUS / OID_802_11_ENCRYPTION_STATUS */ s8 sme_get_wep_mode(void *pcore_data, u8 *pwep_mode); s8 sme_set_wep_mode(void *pcore_data, u8 wep_mode); -//s8 sme_get_encryption_status(void *pcore_data, u8 *pstatus); -//s8 sme_set_encryption_status(void *pcore_data, u8 status); - -// ??????????????????????????????????????? -// OID_GEN_VENDOR_ID -// OID_802_3_PERMANENT_ADDRESS +/* OID_GEN_VENDOR_ID */ +/* OID_802_3_PERMANENT_ADDRESS */ s8 sme_get_permanent_mac_addr(void *pcore_data, u8 *pmac_addr); -// OID_802_3_CURRENT_ADDRESS +/* OID_802_3_CURRENT_ADDRESS */ s8 sme_get_current_mac_addr(void *pcore_data, u8 *pmac_addr); -// OID_802_11_NETWORK_TYPE_IN_USE +/* OID_802_11_NETWORK_TYPE_IN_USE */ s8 sme_get_network_type_in_use(void *pcore_data, u8 *ptype); s8 sme_set_network_type_in_use(void *pcore_data, u8 type); -// OID_802_11_SUPPORTED_RATES +/* OID_802_11_SUPPORTED_RATES */ s8 sme_get_supported_rate(void *pcore_data, u8 *prates); -// OID_802_11_ADD_WEP -//12/29/03' wkchen +/* OID_802_11_ADD_WEP */ s8 sme_set_add_wep(void *pcore_data, u32 key_index, u32 key_len, u8 *Address, u8 *key); -// OID_802_11_REMOVE_WEP +/* OID_802_11_REMOVE_WEP */ s8 sme_set_remove_wep(void *pcre_data, u32 key_index); -// OID_802_11_DISASSOCIATE +/* OID_802_11_DISASSOCIATE */ s8 sme_set_disassociate(void *pcore_data); -// OID_802_11_POWER_MODE +/* OID_802_11_POWER_MODE */ s8 sme_get_power_mode(void *pcore_data, u8 *pmode); s8 sme_set_power_mode(void *pcore_data, u8 mode); -// OID_802_11_BSSID_LIST_SCAN +/* OID_802_11_BSSID_LIST_SCAN */ s8 sme_set_bssid_list_scan(void *pcore_data, void *pscan_para); -// OID_802_11_RELOAD_DEFAULTS +/* OID_802_11_RELOAD_DEFAULTS */ s8 sme_set_reload_defaults(void *pcore_data, u8 reload_type); -// The following SME API functions are used for WPA -// -// Mandatory OIDs for WPA -// - -// OID_802_11_ADD_KEY -//s8 sme_set_add_key(void *pcore_data, NDIS_802_11_KEY *pkey); - -// OID_802_11_REMOVE_KEY -//s8 sme_set_remove_key(void *pcore_data, NDIS_802_11_REMOVE_KEY *pkey); - -// OID_802_11_ASSOCIATION_INFORMATION -//s8 sme_set_association_information(void *pcore_data, -// NDIS_802_11_ASSOCIATION_INFORMATION *pinfo); - -// OID_802_11_TEST -//s8 sme_set_test(void *pcore_data, NDIS_802_11_TEST *ptest_data); - -//--------------------------------------------------------------------------// -/* -// The left OIDs - -// OID_802_11_NETWORK_TYPES_SUPPORTED -// OID_802_11_TX_POWER_LEVEL -// OID_802_11_RSSI_TRIGGER -// OID_802_11_NUMBER_OF_ANTENNAS -// OID_802_11_RX_ANTENNA_SELECTED -// OID_802_11_TX_ANTENNA_SELECTED -// OID_802_11_STATISTICS -// OID_802_11_DESIRED_RATES -// OID_802_11_PRIVACY_FILTER - -*/ - /*------------------------- none-standard ----------------------------------*/ s8 sme_get_connect_status(void *pcore_data, u8 *pstatus); - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -//s8 sme_get_scan_type(void *pcore_data, u8 *pscan_type); -//s8 sme_set_scan_type(void *pcore_data, u8 scan_type); - -//s8 sme_get_scan_channel_list(void *pcore_data, u8 *pscan_type); -//s8 sme_set_scan_channel_list(void *pcore_data, u8 scan_type); - +/*--------------------------------------------------------------------------*/ void sme_get_encryption_status(void *pcore_data, u8 *EncryptStatus); void sme_set_encryption_status(void *pcore_data, u8 EncryptStatus); -s8 sme_add_key(void *pcore_data, - u32 key_index, - u8 key_len, - u8 key_type, - u8 *key_bssid, - //u8 *key_rsc, - u8 *ptx_tsc, - u8 *prx_tsc, - u8 *key_material); +s8 sme_add_key(void *pcore_data, + u32 key_index, + u8 key_len, + u8 key_type, + u8 *key_bssid, + u8 *ptx_tsc, + u8 *prx_tsc, + u8 *key_material); void sme_remove_default_key(void *pcore_data, int index); void sme_remove_mapping_key(void *pcore_data, u8 *pmac_addr); void sme_clear_all_mapping_key(void *pcore_data); @@ -202,60 +149,44 @@ u8 sme_set_rx_antenna(void *pcore_data, u32 RxAntenna); void sme_get_tx_antenna(void *pcore_data, u32 *TxAntenna); s8 sme_set_tx_antenna(void *pcore_data, u32 TxAntenna); s8 sme_set_IBSS_chan(void *pcore_data, struct chan_info chan); - -//20061108 WPS s8 sme_set_IE_append(void *pcore_data, u8 *buffer, u16 buf_len); - - - -//================== Local functions ====================== -//#ifdef _HSINCHU -//void drv_translate_rssi(); // HW RSSI bit -> NDIS RSSI representation -//void drv_translate_bss_description(); // Local bss desc -> NDIS bss desc -//void drv_translate_channel(u8 NetworkType, u8 ChannelNumber, u32 *freq); // channel number -> channel /freq. -//#endif _HSINCHU -// -static const u32 PowerDbToMw[] = -{ - 56, //mW, MAX - 0, 17.5 dbm - 40, //mW, MAX - 1, 16.0 dbm - 30, //mW, MAX - 2, 14.8 dbm - 20, //mW, MAX - 3, 13.0 dbm - 15, //mW, MAX - 4, 11.8 dbm - 12, //mW, MAX - 5, 10.6 dbm - 9, //mW, MAX - 6, 9.4 dbm - 7, //mW, MAX - 7, 8.3 dbm - 5, //mW, MAX - 8, 6.4 dbm - 4, //mW, MAX - 9, 5.3 dbm - 3, //mW, MAX - 10, 4.0 dbm - 2, //mW, MAX - 11, ? dbm - 2, //mW, MAX - 12, ? dbm - 2, //mW, MAX - 13, ? dbm - 2, //mW, MAX - 14, ? dbm - 2, //mW, MAX - 15, ? dbm - 2, //mW, MAX - 16, ? dbm - 2, //mW, MAX - 17, ? dbm - 2, //mW, MAX - 18, ? dbm - 1, //mW, MAX - 19, ? dbm - 1, //mW, MAX - 20, ? dbm - 1, //mW, MAX - 21, ? dbm - 1, //mW, MAX - 22, ? dbm - 1, //mW, MAX - 23, ? dbm - 1, //mW, MAX - 24, ? dbm - 1, //mW, MAX - 25, ? dbm - 1, //mW, MAX - 26, ? dbm - 1, //mW, MAX - 27, ? dbm - 1, //mW, MAX - 28, ? dbm - 1, //mW, MAX - 29, ? dbm - 1, //mW, MAX - 30, ? dbm - 1 //mW, MAX - 31, ? dbm +/* ================== Local functions ====================== */ +static const u32 PowerDbToMw[] = { + 56, /* mW, MAX - 0, 17.5 dbm */ + 40, /* mW, MAX - 1, 16.0 dbm */ + 30, /* mW, MAX - 2, 14.8 dbm */ + 20, /* mW, MAX - 3, 13.0 dbm */ + 15, /* mW, MAX - 4, 11.8 dbm */ + 12, /* mW, MAX - 5, 10.6 dbm */ + 9, /* mW, MAX - 6, 9.4 dbm */ + 7, /* mW, MAX - 7, 8.3 dbm */ + 5, /* mW, MAX - 8, 6.4 dbm */ + 4, /* mW, MAX - 9, 5.3 dbm */ + 3, /* mW, MAX - 10, 4.0 dbm */ + 2, /* mW, MAX - 11, ? dbm */ + 2, /* mW, MAX - 12, ? dbm */ + 2, /* mW, MAX - 13, ? dbm */ + 2, /* mW, MAX - 14, ? dbm */ + 2, /* mW, MAX - 15, ? dbm */ + 2, /* mW, MAX - 16, ? dbm */ + 2, /* mW, MAX - 17, ? dbm */ + 2, /* mW, MAX - 18, ? dbm */ + 1, /* mW, MAX - 19, ? dbm */ + 1, /* mW, MAX - 20, ? dbm */ + 1, /* mW, MAX - 21, ? dbm */ + 1, /* mW, MAX - 22, ? dbm */ + 1, /* mW, MAX - 23, ? dbm */ + 1, /* mW, MAX - 24, ? dbm */ + 1, /* mW, MAX - 25, ? dbm */ + 1, /* mW, MAX - 26, ? dbm */ + 1, /* mW, MAX - 27, ? dbm */ + 1, /* mW, MAX - 28, ? dbm */ + 1, /* mW, MAX - 29, ? dbm */ + 1, /* mW, MAX - 30, ? dbm */ + 1 /* mW, MAX - 31, ? dbm */ }; - - - - #endif /* __SME_API_H__ */ diff --git a/drivers/staging/winbond/sysdef.h b/drivers/staging/winbond/sysdef.h index 251b9c553b6c..9195adf98e14 100644 --- a/drivers/staging/winbond/sysdef.h +++ b/drivers/staging/winbond/sysdef.h @@ -1,31 +1,19 @@ +/* Winbond WLAN System Configuration defines */ - -// -// Winbond WLAN System Configuration defines -// - -//===================================================================== -// Current directory is Linux -// The definition WB_LINUX is a keyword for this OS -//===================================================================== #ifndef SYS_DEF_H #define SYS_DEF_H #define WB_LINUX #define WB_LINUX_WPA_PSK - -//#define _IBSS_BEACON_SEQ_STICK_ #define _USE_FALLBACK_RATE_ -//#define ANTDIV_DEFAULT_ON - -#define _WPA2_ // 20061122 It's needed for current Linux driver +#define _WPA2_ #ifndef _WPA_PSK_DEBUG #undef _WPA_PSK_DEBUG #endif -// debug print options, mark what debug you don't need +/* debug print options, mark what debug you don't need */ #ifdef FULL_DEBUG #define _PE_STATE_DUMP_ diff --git a/drivers/staging/winbond/wb35reg.c b/drivers/staging/winbond/wb35reg.c index 1b93547ff5bc..770722385eeb 100644 --- a/drivers/staging/winbond/wb35reg.c +++ b/drivers/staging/winbond/wb35reg.c @@ -6,60 +6,61 @@ extern void phy_calibration_winbond(struct hw_data *phw_data, u32 frequency); -// true : read command process successfully -// false : register not support -// RegisterNo : start base -// pRegisterData : data point -// NumberOfData : number of register data -// Flag : AUTO_INCREMENT - RegisterNo will auto increment 4 -// NO_INCREMENT - Function will write data into the same register -unsigned char -Wb35Reg_BurstWrite(struct hw_data * pHwData, u16 RegisterNo, u32 * pRegisterData, u8 NumberOfData, u8 Flag) +/* + * true : read command process successfully + * false : register not support + * RegisterNo : start base + * pRegisterData : data point + * NumberOfData : number of register data + * Flag : AUTO_INCREMENT - RegisterNo will auto increment 4 + * NO_INCREMENT - Function will write data into the same register + */ +unsigned char Wb35Reg_BurstWrite(struct hw_data *pHwData, u16 RegisterNo, u32 *pRegisterData, u8 NumberOfData, u8 Flag) { - struct wb35_reg *reg = &pHwData->reg; - struct urb *urb = NULL; - struct wb35_reg_queue *reg_queue = NULL; - u16 UrbSize; - struct usb_ctrlrequest *dr; - u16 i, DataSize = NumberOfData*4; - - // Module shutdown + struct wb35_reg *reg = &pHwData->reg; + struct urb *urb = NULL; + struct wb35_reg_queue *reg_queue = NULL; + u16 UrbSize; + struct usb_ctrlrequest *dr; + u16 i, DataSize = NumberOfData * 4; + + /* Module shutdown */ if (pHwData->SurpriseRemove) return false; - // Trying to use burst write function if use new hardware + /* Trying to use burst write function if use new hardware */ UrbSize = sizeof(struct wb35_reg_queue) + DataSize + sizeof(struct usb_ctrlrequest); reg_queue = kzalloc(UrbSize, GFP_ATOMIC); urb = usb_alloc_urb(0, GFP_ATOMIC); - if( urb && reg_queue ) { - reg_queue->DIRECT = 2;// burst write register + if (urb && reg_queue) { + reg_queue->DIRECT = 2; /* burst write register */ reg_queue->INDEX = RegisterNo; reg_queue->pBuffer = (u32 *)((u8 *)reg_queue + sizeof(struct wb35_reg_queue)); - memcpy( reg_queue->pBuffer, pRegisterData, DataSize ); - //the function for reversing register data from little endian to big endian - for( i=0; i<NumberOfData ; i++ ) - reg_queue->pBuffer[i] = cpu_to_le32( reg_queue->pBuffer[i] ); + memcpy(reg_queue->pBuffer, pRegisterData, DataSize); + /* the function for reversing register data from little endian to big endian */ + for (i = 0; i < NumberOfData ; i++) + reg_queue->pBuffer[i] = cpu_to_le32(reg_queue->pBuffer[i]); dr = (struct usb_ctrlrequest *)((u8 *)reg_queue + sizeof(struct wb35_reg_queue) + DataSize); dr->bRequestType = USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE; - dr->bRequest = 0x04; // USB or vendor-defined request code, burst mode - dr->wValue = cpu_to_le16( Flag ); // 0: Register number auto-increment, 1: No auto increment - dr->wIndex = cpu_to_le16( RegisterNo ); - dr->wLength = cpu_to_le16( DataSize ); + dr->bRequest = 0x04; /* USB or vendor-defined request code, burst mode */ + dr->wValue = cpu_to_le16(Flag); /* 0: Register number auto-increment, 1: No auto increment */ + dr->wIndex = cpu_to_le16(RegisterNo); + dr->wLength = cpu_to_le16(DataSize); reg_queue->Next = NULL; reg_queue->pUsbReq = dr; reg_queue->urb = urb; - spin_lock_irq( ®->EP0VM_spin_lock ); + spin_lock_irq(®->EP0VM_spin_lock); if (reg->reg_first == NULL) reg->reg_first = reg_queue; else reg->reg_last->Next = reg_queue; reg->reg_last = reg_queue; - spin_unlock_irq( ®->EP0VM_spin_lock ); + spin_unlock_irq(®->EP0VM_spin_lock); - // Start EP0VM + /* Start EP0VM */ Wb35Reg_EP0VM_start(pHwData); return true; @@ -73,8 +74,7 @@ Wb35Reg_BurstWrite(struct hw_data * pHwData, u16 RegisterNo, u32 * pRegisterData return false; } -void -Wb35Reg_Update(struct hw_data * pHwData, u16 RegisterNo, u32 RegisterValue) +void Wb35Reg_Update(struct hw_data *pHwData, u16 RegisterNo, u32 RegisterValue) { struct wb35_reg *reg = &pHwData->reg; switch (RegisterNo) { @@ -116,97 +116,96 @@ Wb35Reg_Update(struct hw_data * pHwData, u16 RegisterNo, u32 RegisterValue) } } -// true : read command process successfully -// false : register not support -unsigned char -Wb35Reg_WriteSync( struct hw_data * pHwData, u16 RegisterNo, u32 RegisterValue ) +/* + * true : read command process successfully + * false : register not support + */ +unsigned char Wb35Reg_WriteSync(struct hw_data *pHwData, u16 RegisterNo, u32 RegisterValue) { struct wb35_reg *reg = &pHwData->reg; int ret = -1; - // Module shutdown + /* Module shutdown */ if (pHwData->SurpriseRemove) return false; RegisterValue = cpu_to_le32(RegisterValue); - // update the register by send usb message------------------------------------ + /* update the register by send usb message */ reg->SyncIoPause = 1; - // 20060717.5 Wait until EP0VM stop + /* Wait until EP0VM stop */ while (reg->EP0vm_state != VM_STOP) msleep(10); - // Sync IoCallDriver + /* Sync IoCallDriver */ reg->EP0vm_state = VM_RUNNING; - ret = usb_control_msg( pHwData->WbUsb.udev, - usb_sndctrlpipe( pHwData->WbUsb.udev, 0 ), + ret = usb_control_msg(pHwData->WbUsb.udev, + usb_sndctrlpipe(pHwData->WbUsb.udev, 0), 0x03, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, - 0x0,RegisterNo, &RegisterValue, 4, HZ*100 ); + 0x0, RegisterNo, &RegisterValue, 4, HZ * 100); reg->EP0vm_state = VM_STOP; reg->SyncIoPause = 0; Wb35Reg_EP0VM_start(pHwData); if (ret < 0) { - #ifdef _PE_REG_DUMP_ +#ifdef _PE_REG_DUMP_ printk("EP0 Write register usb message sending error\n"); - #endif - - pHwData->SurpriseRemove = 1; // 20060704.2 +#endif + pHwData->SurpriseRemove = 1; return false; } - return true; } -// true : read command process successfully -// false : register not support -unsigned char -Wb35Reg_Write( struct hw_data * pHwData, u16 RegisterNo, u32 RegisterValue ) +/* + * true : read command process successfully + * false : register not support + */ +unsigned char Wb35Reg_Write(struct hw_data *pHwData, u16 RegisterNo, u32 RegisterValue) { - struct wb35_reg *reg = &pHwData->reg; - struct usb_ctrlrequest *dr; - struct urb *urb = NULL; - struct wb35_reg_queue *reg_queue = NULL; - u16 UrbSize; - + struct wb35_reg *reg = &pHwData->reg; + struct usb_ctrlrequest *dr; + struct urb *urb = NULL; + struct wb35_reg_queue *reg_queue = NULL; + u16 UrbSize; - // Module shutdown + /* Module shutdown */ if (pHwData->SurpriseRemove) return false; - // update the register by send urb request------------------------------------ + /* update the register by send urb request */ UrbSize = sizeof(struct wb35_reg_queue) + sizeof(struct usb_ctrlrequest); reg_queue = kzalloc(UrbSize, GFP_ATOMIC); urb = usb_alloc_urb(0, GFP_ATOMIC); if (urb && reg_queue) { - reg_queue->DIRECT = 1;// burst write register + reg_queue->DIRECT = 1; /* burst write register */ reg_queue->INDEX = RegisterNo; reg_queue->VALUE = cpu_to_le32(RegisterValue); reg_queue->RESERVED_VALID = false; dr = (struct usb_ctrlrequest *)((u8 *)reg_queue + sizeof(struct wb35_reg_queue)); - dr->bRequestType = USB_TYPE_VENDOR|USB_DIR_OUT |USB_RECIP_DEVICE; - dr->bRequest = 0x03; // USB or vendor-defined request code, burst mode + dr->bRequestType = USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE; + dr->bRequest = 0x03; /* USB or vendor-defined request code, burst mode */ dr->wValue = cpu_to_le16(0x0); dr->wIndex = cpu_to_le16(RegisterNo); dr->wLength = cpu_to_le16(4); - // Enter the sending queue + /* Enter the sending queue */ reg_queue->Next = NULL; reg_queue->pUsbReq = dr; reg_queue->urb = urb; - spin_lock_irq(®->EP0VM_spin_lock ); + spin_lock_irq(®->EP0VM_spin_lock); if (reg->reg_first == NULL) reg->reg_first = reg_queue; else reg->reg_last->Next = reg_queue; reg->reg_last = reg_queue; - spin_unlock_irq( ®->EP0VM_spin_lock ); + spin_unlock_irq(®->EP0VM_spin_lock); - // Start EP0VM + /* Start EP0VM */ Wb35Reg_EP0VM_start(pHwData); return true; @@ -218,56 +217,60 @@ Wb35Reg_Write( struct hw_data * pHwData, u16 RegisterNo, u32 RegisterValue ) } } -//This command will be executed with a user defined value. When it completes, -//this value is useful. For example, hal_set_current_channel will use it. -// true : read command process successfully -// false : register not support -unsigned char -Wb35Reg_WriteWithCallbackValue( struct hw_data * pHwData, u16 RegisterNo, u32 RegisterValue, - s8 *pValue, s8 Len) +/* + * This command will be executed with a user defined value. When it completes, + * this value is useful. For example, hal_set_current_channel will use it. + * true : read command process successfully + * false : register not support + */ +unsigned char Wb35Reg_WriteWithCallbackValue(struct hw_data *pHwData, + u16 RegisterNo, + u32 RegisterValue, + s8 *pValue, + s8 Len) { - struct wb35_reg *reg = &pHwData->reg; - struct usb_ctrlrequest *dr; - struct urb *urb = NULL; - struct wb35_reg_queue *reg_queue = NULL; - u16 UrbSize; + struct wb35_reg *reg = &pHwData->reg; + struct usb_ctrlrequest *dr; + struct urb *urb = NULL; + struct wb35_reg_queue *reg_queue = NULL; + u16 UrbSize; - // Module shutdown + /* Module shutdown */ if (pHwData->SurpriseRemove) return false; - // update the register by send urb request------------------------------------ + /* update the register by send urb request */ UrbSize = sizeof(struct wb35_reg_queue) + sizeof(struct usb_ctrlrequest); reg_queue = kzalloc(UrbSize, GFP_ATOMIC); urb = usb_alloc_urb(0, GFP_ATOMIC); if (urb && reg_queue) { - reg_queue->DIRECT = 1;// burst write register + reg_queue->DIRECT = 1; /* burst write register */ reg_queue->INDEX = RegisterNo; reg_queue->VALUE = cpu_to_le32(RegisterValue); - //NOTE : Users must guarantee the size of value will not exceed the buffer size. + /* NOTE : Users must guarantee the size of value will not exceed the buffer size. */ memcpy(reg_queue->RESERVED, pValue, Len); reg_queue->RESERVED_VALID = true; dr = (struct usb_ctrlrequest *)((u8 *)reg_queue + sizeof(struct wb35_reg_queue)); - dr->bRequestType = USB_TYPE_VENDOR|USB_DIR_OUT |USB_RECIP_DEVICE; - dr->bRequest = 0x03; // USB or vendor-defined request code, burst mode + dr->bRequestType = USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE; + dr->bRequest = 0x03; /* USB or vendor-defined request code, burst mode */ dr->wValue = cpu_to_le16(0x0); dr->wIndex = cpu_to_le16(RegisterNo); dr->wLength = cpu_to_le16(4); - // Enter the sending queue + /* Enter the sending queue */ reg_queue->Next = NULL; reg_queue->pUsbReq = dr; reg_queue->urb = urb; - spin_lock_irq (®->EP0VM_spin_lock ); - if( reg->reg_first == NULL ) + spin_lock_irq(®->EP0VM_spin_lock); + if (reg->reg_first == NULL) reg->reg_first = reg_queue; else reg->reg_last->Next = reg_queue; reg->reg_last = reg_queue; - spin_unlock_irq ( ®->EP0VM_spin_lock ); + spin_unlock_irq(®->EP0VM_spin_lock); - // Start EP0VM + /* Start EP0VM */ Wb35Reg_EP0VM_start(pHwData); return true; } else { @@ -278,115 +281,114 @@ Wb35Reg_WriteWithCallbackValue( struct hw_data * pHwData, u16 RegisterNo, u32 Re } } -// true : read command process successfully -// false : register not support -// pRegisterValue : It must be a resident buffer due to asynchronous read register. -unsigned char -Wb35Reg_ReadSync( struct hw_data * pHwData, u16 RegisterNo, u32 * pRegisterValue ) +/* + * true : read command process successfully + * false : register not support + * pRegisterValue : It must be a resident buffer due to + * asynchronous read register. + */ +unsigned char Wb35Reg_ReadSync(struct hw_data *pHwData, u16 RegisterNo, u32 *pRegisterValue) { struct wb35_reg *reg = &pHwData->reg; - u32 * pltmp = pRegisterValue; - int ret = -1; + u32 *pltmp = pRegisterValue; + int ret = -1; - // Module shutdown + /* Module shutdown */ if (pHwData->SurpriseRemove) return false; - // Read the register by send usb message------------------------------------ - + /* Read the register by send usb message */ reg->SyncIoPause = 1; - // 20060717.5 Wait until EP0VM stop + /* Wait until EP0VM stop */ while (reg->EP0vm_state != VM_STOP) msleep(10); reg->EP0vm_state = VM_RUNNING; - ret = usb_control_msg( pHwData->WbUsb.udev, + ret = usb_control_msg(pHwData->WbUsb.udev, usb_rcvctrlpipe(pHwData->WbUsb.udev, 0), - 0x01, USB_TYPE_VENDOR|USB_RECIP_DEVICE|USB_DIR_IN, - 0x0, RegisterNo, pltmp, 4, HZ*100 ); + 0x01, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, + 0x0, RegisterNo, pltmp, 4, HZ * 100); *pRegisterValue = cpu_to_le32(*pltmp); reg->EP0vm_state = VM_STOP; - Wb35Reg_Update( pHwData, RegisterNo, *pRegisterValue ); + Wb35Reg_Update(pHwData, RegisterNo, *pRegisterValue); reg->SyncIoPause = 0; - Wb35Reg_EP0VM_start( pHwData ); + Wb35Reg_EP0VM_start(pHwData); if (ret < 0) { - #ifdef _PE_REG_DUMP_ +#ifdef _PE_REG_DUMP_ printk("EP0 Read register usb message sending error\n"); - #endif - - pHwData->SurpriseRemove = 1; // 20060704.2 +#endif + pHwData->SurpriseRemove = 1; return false; } - return true; } -// true : read command process successfully -// false : register not support -// pRegisterValue : It must be a resident buffer due to asynchronous read register. -unsigned char -Wb35Reg_Read(struct hw_data * pHwData, u16 RegisterNo, u32 * pRegisterValue ) +/* + * true : read command process successfully + * false : register not support + * pRegisterValue : It must be a resident buffer due to + * asynchronous read register. + */ +unsigned char Wb35Reg_Read(struct hw_data *pHwData, u16 RegisterNo, u32 *pRegisterValue) { - struct wb35_reg *reg = &pHwData->reg; - struct usb_ctrlrequest * dr; - struct urb *urb; - struct wb35_reg_queue *reg_queue; - u16 UrbSize; + struct wb35_reg *reg = &pHwData->reg; + struct usb_ctrlrequest *dr; + struct urb *urb; + struct wb35_reg_queue *reg_queue; + u16 UrbSize; - // Module shutdown + /* Module shutdown */ if (pHwData->SurpriseRemove) return false; - // update the variable by send Urb to read register ------------------------------------ + /* update the variable by send Urb to read register */ UrbSize = sizeof(struct wb35_reg_queue) + sizeof(struct usb_ctrlrequest); reg_queue = kzalloc(UrbSize, GFP_ATOMIC); urb = usb_alloc_urb(0, GFP_ATOMIC); - if( urb && reg_queue ) - { - reg_queue->DIRECT = 0;// read register + if (urb && reg_queue) { + reg_queue->DIRECT = 0; /* read register */ reg_queue->INDEX = RegisterNo; reg_queue->pBuffer = pRegisterValue; dr = (struct usb_ctrlrequest *)((u8 *)reg_queue + sizeof(struct wb35_reg_queue)); - dr->bRequestType = USB_TYPE_VENDOR|USB_RECIP_DEVICE|USB_DIR_IN; - dr->bRequest = 0x01; // USB or vendor-defined request code, burst mode + dr->bRequestType = USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN; + dr->bRequest = 0x01; /* USB or vendor-defined request code, burst mode */ dr->wValue = cpu_to_le16(0x0); - dr->wIndex = cpu_to_le16 (RegisterNo); - dr->wLength = cpu_to_le16 (4); + dr->wIndex = cpu_to_le16(RegisterNo); + dr->wLength = cpu_to_le16(4); - // Enter the sending queue + /* Enter the sending queue */ reg_queue->Next = NULL; reg_queue->pUsbReq = dr; reg_queue->urb = urb; - spin_lock_irq ( ®->EP0VM_spin_lock ); - if( reg->reg_first == NULL ) + spin_lock_irq(®->EP0VM_spin_lock); + if (reg->reg_first == NULL) reg->reg_first = reg_queue; else reg->reg_last->Next = reg_queue; reg->reg_last = reg_queue; - spin_unlock_irq( ®->EP0VM_spin_lock ); + spin_unlock_irq(®->EP0VM_spin_lock); - // Start EP0VM - Wb35Reg_EP0VM_start( pHwData ); + /* Start EP0VM */ + Wb35Reg_EP0VM_start(pHwData); return true; } else { if (urb) - usb_free_urb( urb ); + usb_free_urb(urb); kfree(reg_queue); return false; } } -void -Wb35Reg_EP0VM_start( struct hw_data * pHwData ) +void Wb35Reg_EP0VM_start(struct hw_data *pHwData) { struct wb35_reg *reg = &pHwData->reg; @@ -397,15 +399,14 @@ Wb35Reg_EP0VM_start( struct hw_data * pHwData ) atomic_dec(®->RegFireCount); } -void -Wb35Reg_EP0VM(struct hw_data * pHwData ) +void Wb35Reg_EP0VM(struct hw_data *pHwData) { - struct wb35_reg *reg = &pHwData->reg; - struct urb *urb; - struct usb_ctrlrequest *dr; - u32 * pBuffer; + struct wb35_reg *reg = &pHwData->reg; + struct urb *urb; + struct usb_ctrlrequest *dr; + u32 *pBuffer; int ret = -1; - struct wb35_reg_queue *reg_queue; + struct wb35_reg_queue *reg_queue; if (reg->SyncIoPause) @@ -414,27 +415,27 @@ Wb35Reg_EP0VM(struct hw_data * pHwData ) if (pHwData->SurpriseRemove) goto cleanup; - // Get the register data and send to USB through Irp - spin_lock_irq( ®->EP0VM_spin_lock ); + /* Get the register data and send to USB through Irp */ + spin_lock_irq(®->EP0VM_spin_lock); reg_queue = reg->reg_first; - spin_unlock_irq( ®->EP0VM_spin_lock ); + spin_unlock_irq(®->EP0VM_spin_lock); if (!reg_queue) goto cleanup; - // Get an Urb, send it + /* Get an Urb, send it */ urb = (struct urb *)reg_queue->urb; dr = reg_queue->pUsbReq; urb = reg_queue->urb; pBuffer = reg_queue->pBuffer; - if (reg_queue->DIRECT == 1) // output + if (reg_queue->DIRECT == 1) /* output */ pBuffer = ®_queue->VALUE; - usb_fill_control_urb( urb, pHwData->WbUsb.udev, - REG_DIRECTION(pHwData->WbUsb.udev,reg_queue), - (u8 *)dr,pBuffer,cpu_to_le16(dr->wLength), - Wb35Reg_EP0VM_complete, (void*)pHwData); + usb_fill_control_urb(urb, pHwData->WbUsb.udev, + REG_DIRECTION(pHwData->WbUsb.udev, reg_queue), + (u8 *)dr, pBuffer, cpu_to_le16(dr->wLength), + Wb35Reg_EP0VM_complete, (void *)pHwData); reg->EP0vm_state = VM_RUNNING; @@ -446,7 +447,6 @@ Wb35Reg_EP0VM(struct hw_data * pHwData ) #endif goto cleanup; } - return; cleanup: @@ -455,29 +455,28 @@ Wb35Reg_EP0VM(struct hw_data * pHwData ) } -void -Wb35Reg_EP0VM_complete(struct urb *urb) +void Wb35Reg_EP0VM_complete(struct urb *urb) { - struct hw_data * pHwData = (struct hw_data *)urb->context; - struct wb35_reg *reg = &pHwData->reg; - struct wb35_reg_queue *reg_queue; + struct hw_data *pHwData = (struct hw_data *)urb->context; + struct wb35_reg *reg = &pHwData->reg; + struct wb35_reg_queue *reg_queue; - // Variable setting + /* Variable setting */ reg->EP0vm_state = VM_COMPLETED; reg->EP0VM_status = urb->status; - if (pHwData->SurpriseRemove) { // Let WbWlanHalt to handle surprise remove + if (pHwData->SurpriseRemove) { /* Let WbWlanHalt to handle surprise remove */ reg->EP0vm_state = VM_STOP; atomic_dec(®->RegFireCount); } else { - // Complete to send, remove the URB from the first - spin_lock_irq( ®->EP0VM_spin_lock ); + /* Complete to send, remove the URB from the first */ + spin_lock_irq(®->EP0VM_spin_lock); reg_queue = reg->reg_first; if (reg_queue == reg->reg_last) reg->reg_last = NULL; reg->reg_first = reg->reg_first->Next; - spin_unlock_irq( ®->EP0VM_spin_lock ); + spin_unlock_irq(®->EP0VM_spin_lock); if (reg->EP0VM_status) { #ifdef _PE_REG_DUMP_ @@ -486,37 +485,35 @@ Wb35Reg_EP0VM_complete(struct urb *urb) reg->EP0vm_state = VM_STOP; pHwData->SurpriseRemove = 1; } else { - // Success. Update the result + /* Success. Update the result */ - // Start the next send + /* Start the next send */ Wb35Reg_EP0VM(pHwData); } - kfree(reg_queue); + kfree(reg_queue); } usb_free_urb(urb); } -void -Wb35Reg_destroy(struct hw_data * pHwData) +void Wb35Reg_destroy(struct hw_data *pHwData) { - struct wb35_reg *reg = &pHwData->reg; - struct urb *urb; - struct wb35_reg_queue *reg_queue; - + struct wb35_reg *reg = &pHwData->reg; + struct urb *urb; + struct wb35_reg_queue *reg_queue; Uxx_power_off_procedure(pHwData); - // Wait for Reg operation completed + /* Wait for Reg operation completed */ do { - msleep(10); // Delay for waiting function enter 940623.1.a + msleep(10); /* Delay for waiting function enter */ } while (reg->EP0vm_state != VM_STOP); - msleep(10); // Delay for waiting function enter 940623.1.b + msleep(10); /* Delay for waiting function enter */ - // Release all the data in RegQueue - spin_lock_irq( ®->EP0VM_spin_lock ); + /* Release all the data in RegQueue */ + spin_lock_irq(®->EP0VM_spin_lock); reg_queue = reg->reg_first; while (reg_queue) { if (reg_queue == reg->reg_last) @@ -524,84 +521,88 @@ Wb35Reg_destroy(struct hw_data * pHwData) reg->reg_first = reg->reg_first->Next; urb = reg_queue->urb; - spin_unlock_irq( ®->EP0VM_spin_lock ); + spin_unlock_irq(®->EP0VM_spin_lock); if (urb) { usb_free_urb(urb); kfree(reg_queue); } else { - #ifdef _PE_REG_DUMP_ +#ifdef _PE_REG_DUMP_ printk("EP0 queue release error\n"); - #endif +#endif } - spin_lock_irq( ®->EP0VM_spin_lock ); + spin_lock_irq(®->EP0VM_spin_lock); reg_queue = reg->reg_first; } - spin_unlock_irq( ®->EP0VM_spin_lock ); + spin_unlock_irq(®->EP0VM_spin_lock); } -//==================================================================================== -// The function can be run in passive-level only. -//==================================================================================== -unsigned char Wb35Reg_initial(struct hw_data * pHwData) +/* + * ======================================================================= + * The function can be run in passive-level only. + * ========================================================================= + */ +unsigned char Wb35Reg_initial(struct hw_data *pHwData) { - struct wb35_reg *reg=&pHwData->reg; + struct wb35_reg *reg = &pHwData->reg; u32 ltmp; u32 SoftwareSet, VCO_trim, TxVga, Region_ScanInterval; - // Spin lock is acquired for read and write IRP command - spin_lock_init( ®->EP0VM_spin_lock ); - - // Getting RF module type from EEPROM ------------------------------------ - Wb35Reg_WriteSync( pHwData, 0x03b4, 0x080d0000 ); // Start EEPROM access + Read + address(0x0d) - Wb35Reg_ReadSync( pHwData, 0x03b4, <mp ); - - //Update RF module type and determine the PHY type by inf or EEPROM - reg->EEPROMPhyType = (u8)( ltmp & 0xff ); - // 0 V MAX2825, 1 V MAX2827, 2 V MAX2828, 3 V MAX2829 - // 16V AL2230, 17 - AL7230, 18 - AL2230S - // 32 Reserved - // 33 - W89RF242(TxVGA 0~19), 34 - W89RF242(TxVGA 0~34) + /* Spin lock is acquired for read and write IRP command */ + spin_lock_init(®->EP0VM_spin_lock); + + /* Getting RF module type from EEPROM */ + Wb35Reg_WriteSync(pHwData, 0x03b4, 0x080d0000); /* Start EEPROM access + Read + address(0x0d) */ + Wb35Reg_ReadSync(pHwData, 0x03b4, <mp); + + /* Update RF module type and determine the PHY type by inf or EEPROM */ + reg->EEPROMPhyType = (u8)(ltmp & 0xff); + /* + * 0 V MAX2825, 1 V MAX2827, 2 V MAX2828, 3 V MAX2829 + * 16V AL2230, 17 - AL7230, 18 - AL2230S + * 32 Reserved + * 33 - W89RF242(TxVGA 0~19), 34 - W89RF242(TxVGA 0~34) + */ if (reg->EEPROMPhyType != RF_DECIDE_BY_INF) { - if( (reg->EEPROMPhyType == RF_MAXIM_2825) || + if ((reg->EEPROMPhyType == RF_MAXIM_2825) || (reg->EEPROMPhyType == RF_MAXIM_2827) || (reg->EEPROMPhyType == RF_MAXIM_2828) || (reg->EEPROMPhyType == RF_MAXIM_2829) || (reg->EEPROMPhyType == RF_MAXIM_V1) || (reg->EEPROMPhyType == RF_AIROHA_2230) || - (reg->EEPROMPhyType == RF_AIROHA_2230S) || + (reg->EEPROMPhyType == RF_AIROHA_2230S) || (reg->EEPROMPhyType == RF_AIROHA_7230) || - (reg->EEPROMPhyType == RF_WB_242) || + (reg->EEPROMPhyType == RF_WB_242) || (reg->EEPROMPhyType == RF_WB_242_1)) pHwData->phy_type = reg->EEPROMPhyType; } - // Power On procedure running. The relative parameter will be set according to phy_type - Uxx_power_on_procedure( pHwData ); + /* Power On procedure running. The relative parameter will be set according to phy_type */ + Uxx_power_on_procedure(pHwData); - // Reading MAC address - Uxx_ReadEthernetAddress( pHwData ); + /* Reading MAC address */ + Uxx_ReadEthernetAddress(pHwData); - // Read VCO trim for RF parameter - Wb35Reg_WriteSync( pHwData, 0x03b4, 0x08200000 ); - Wb35Reg_ReadSync( pHwData, 0x03b4, &VCO_trim ); + /* Read VCO trim for RF parameter */ + Wb35Reg_WriteSync(pHwData, 0x03b4, 0x08200000); + Wb35Reg_ReadSync(pHwData, 0x03b4, &VCO_trim); - // Read Antenna On/Off of software flag - Wb35Reg_WriteSync( pHwData, 0x03b4, 0x08210000 ); - Wb35Reg_ReadSync( pHwData, 0x03b4, &SoftwareSet ); + /* Read Antenna On/Off of software flag */ + Wb35Reg_WriteSync(pHwData, 0x03b4, 0x08210000); + Wb35Reg_ReadSync(pHwData, 0x03b4, &SoftwareSet); - // Read TXVGA - Wb35Reg_WriteSync( pHwData, 0x03b4, 0x08100000 ); - Wb35Reg_ReadSync( pHwData, 0x03b4, &TxVga ); + /* Read TXVGA */ + Wb35Reg_WriteSync(pHwData, 0x03b4, 0x08100000); + Wb35Reg_ReadSync(pHwData, 0x03b4, &TxVga); - // Get Scan interval setting from EEPROM offset 0x1c - Wb35Reg_WriteSync( pHwData, 0x03b4, 0x081d0000 ); - Wb35Reg_ReadSync( pHwData, 0x03b4, &Region_ScanInterval ); + /* Get Scan interval setting from EEPROM offset 0x1c */ + Wb35Reg_WriteSync(pHwData, 0x03b4, 0x081d0000); + Wb35Reg_ReadSync(pHwData, 0x03b4, &Region_ScanInterval); - // Update Ethernet address - memcpy( pHwData->CurrentMacAddress, pHwData->PermanentMacAddress, ETH_ALEN ); + /* Update Ethernet address */ + memcpy(pHwData->CurrentMacAddress, pHwData->PermanentMacAddress, ETH_ALEN); - // Update software variable + /* Update software variable */ pHwData->SoftwareSet = (u16)(SoftwareSet & 0xffff); TxVga &= 0x000000ff; pHwData->PowerIndexFromEEPROM = (u8)TxVga; @@ -609,22 +610,22 @@ unsigned char Wb35Reg_initial(struct hw_data * pHwData) if (pHwData->VCO_trim == 0xff) pHwData->VCO_trim = 0x28; - reg->EEPROMRegion = (u8)(Region_ScanInterval>>8); // 20060720 - if( reg->EEPROMRegion<1 || reg->EEPROMRegion>6 ) + reg->EEPROMRegion = (u8)(Region_ScanInterval >> 8); + if (reg->EEPROMRegion < 1 || reg->EEPROMRegion > 6) reg->EEPROMRegion = REGION_AUTO; - //For Get Tx VGA from EEPROM 20060315.5 move here - GetTxVgaFromEEPROM( pHwData ); + /* For Get Tx VGA from EEPROM */ + GetTxVgaFromEEPROM(pHwData); - // Set Scan Interval + /* Set Scan Interval */ pHwData->Scan_Interval = (u8)(Region_ScanInterval & 0xff) * 10; - if ((pHwData->Scan_Interval == 2550) || (pHwData->Scan_Interval < 10)) // Is default setting 0xff * 10 + if ((pHwData->Scan_Interval == 2550) || (pHwData->Scan_Interval < 10)) /* Is default setting 0xff * 10 */ pHwData->Scan_Interval = SCAN_MAX_CHNL_TIME; - // Initial register + /* Initial register */ RFSynthesizer_initial(pHwData); - BBProcessor_initial(pHwData); // Async write, must wait until complete + BBProcessor_initial(pHwData); /* Async write, must wait until complete */ Wb35Reg_phy_calibration(pHwData); @@ -634,113 +635,104 @@ unsigned char Wb35Reg_initial(struct hw_data * pHwData) if (pHwData->SurpriseRemove) return false; else - return true; // Initial fail + return true; /* Initial fail */ } -//=================================================================================== -// CardComputeCrc -- -// -// Description: -// Runs the AUTODIN II CRC algorithm on buffer Buffer of length, Length. -// -// Arguments: -// Buffer - the input buffer -// Length - the length of Buffer -// -// Return Value: -// The 32-bit CRC value. -// -// Note: -// This is adapted from the comments in the assembly language -// version in _GENREQ.ASM of the DWB NE1000/2000 driver. -//================================================================================== -u32 -CardComputeCrc(u8 * Buffer, u32 Length) +/* + * ================================================================ + * CardComputeCrc -- + * + * Description: + * Runs the AUTODIN II CRC algorithm on buffer Buffer of length, Length. + * + * Arguments: + * Buffer - the input buffer + * Length - the length of Buffer + * + * Return Value: + * The 32-bit CRC value. + * =================================================================== + */ +u32 CardComputeCrc(u8 *Buffer, u32 Length) { - u32 Crc, Carry; - u32 i, j; - u8 CurByte; - - Crc = 0xffffffff; - - for (i = 0; i < Length; i++) { - - CurByte = Buffer[i]; - - for (j = 0; j < 8; j++) { - - Carry = ((Crc & 0x80000000) ? 1 : 0) ^ (CurByte & 0x01); - Crc <<= 1; - CurByte >>= 1; - - if (Carry) { - Crc =(Crc ^ 0x04c11db6) | Carry; - } - } - } - - return Crc; + u32 Crc, Carry; + u32 i, j; + u8 CurByte; + + Crc = 0xffffffff; + + for (i = 0; i < Length; i++) { + CurByte = Buffer[i]; + for (j = 0; j < 8; j++) { + Carry = ((Crc & 0x80000000) ? 1 : 0) ^ (CurByte & 0x01); + Crc <<= 1; + CurByte >>= 1; + if (Carry) + Crc = (Crc ^ 0x04c11db6) | Carry; + } + } + return Crc; } -//================================================================== -// BitReverse -- -// Reverse the bits in the input argument, dwData, which is -// regarded as a string of bits with the length, DataLength. -// -// Arguments: -// dwData : -// DataLength : -// -// Return: -// The converted value. -//================================================================== -u32 BitReverse( u32 dwData, u32 DataLength) +/* + * ================================================================== + * BitReverse -- + * Reverse the bits in the input argument, dwData, which is + * regarded as a string of bits with the length, DataLength. + * + * Arguments: + * dwData : + * DataLength : + * + * Return: + * The converted value. + * ================================================================== + */ +u32 BitReverse(u32 dwData, u32 DataLength) { - u32 HalfLength, i, j; - u32 BitA, BitB; + u32 HalfLength, i, j; + u32 BitA, BitB; - if ( DataLength <= 0) return 0; // No conversion is done. + if (DataLength <= 0) + return 0; /* No conversion is done. */ dwData = dwData & (0xffffffff >> (32 - DataLength)); HalfLength = DataLength / 2; - for ( i = 0, j = DataLength-1 ; i < HalfLength; i++, j--) - { - BitA = GetBit( dwData, i); - BitB = GetBit( dwData, j); + for (i = 0, j = DataLength - 1; i < HalfLength; i++, j--) { + BitA = GetBit(dwData, i); + BitB = GetBit(dwData, j); if (BitA && !BitB) { - dwData = ClearBit( dwData, i); - dwData = SetBit( dwData, j); + dwData = ClearBit(dwData, i); + dwData = SetBit(dwData, j); } else if (!BitA && BitB) { - dwData = SetBit( dwData, i); - dwData = ClearBit( dwData, j); - } else - { - // Do nothing since these two bits are of the save values. + dwData = SetBit(dwData, i); + dwData = ClearBit(dwData, j); + } else { + /* Do nothing since these two bits are of the save values. */ } } - return dwData; } -void Wb35Reg_phy_calibration( struct hw_data * pHwData ) +void Wb35Reg_phy_calibration(struct hw_data *pHwData) { - u32 BB3c, BB54; + u32 BB3c, BB54; if ((pHwData->phy_type == RF_WB_242) || (pHwData->phy_type == RF_WB_242_1)) { - phy_calibration_winbond ( pHwData, 2412 ); // Sync operation - Wb35Reg_ReadSync( pHwData, 0x103c, &BB3c ); - Wb35Reg_ReadSync( pHwData, 0x1054, &BB54 ); + phy_calibration_winbond(pHwData, 2412); /* Sync operation */ + Wb35Reg_ReadSync(pHwData, 0x103c, &BB3c); + Wb35Reg_ReadSync(pHwData, 0x1054, &BB54); pHwData->BB3c_cal = BB3c; pHwData->BB54_cal = BB54; RFSynthesizer_initial(pHwData); - BBProcessor_initial(pHwData); // Async operation + BBProcessor_initial(pHwData); /* Async operation */ - Wb35Reg_WriteSync( pHwData, 0x103c, BB3c ); - Wb35Reg_WriteSync( pHwData, 0x1054, BB54 ); + Wb35Reg_WriteSync(pHwData, 0x103c, BB3c); + Wb35Reg_WriteSync(pHwData, 0x1054, BB54); } } diff --git a/drivers/staging/winbond/wb35reg_f.h b/drivers/staging/winbond/wb35reg_f.h index d352bce5c171..bf23c1084199 100644 --- a/drivers/staging/winbond/wb35reg_f.h +++ b/drivers/staging/winbond/wb35reg_f.h @@ -3,59 +3,63 @@ #include "wbhal_s.h" -//==================================== -// Interface function declare -//==================================== -unsigned char Wb35Reg_initial( struct hw_data * pHwData ); -void Uxx_power_on_procedure( struct hw_data * pHwData ); -void Uxx_power_off_procedure( struct hw_data * pHwData ); -void Uxx_ReadEthernetAddress( struct hw_data * pHwData ); -void Dxx_initial( struct hw_data * pHwData ); -void Mxx_initial( struct hw_data * pHwData ); -void RFSynthesizer_initial( struct hw_data * pHwData ); -//void RFSynthesizer_SwitchingChannel( struct hw_data * pHwData, s8 Channel ); -void RFSynthesizer_SwitchingChannel( struct hw_data * pHwData, struct chan_info Channel ); -void BBProcessor_initial( struct hw_data * pHwData ); -void BBProcessor_RateChanging( struct hw_data * pHwData, u8 rate ); // 20060613.1 -//void RF_RateChanging( struct hw_data * pHwData, u8 rate ); // 20060626.5.c Add -u8 RFSynthesizer_SetPowerIndex( struct hw_data * pHwData, u8 PowerIndex ); -u8 RFSynthesizer_SetMaxim2828_24Power( struct hw_data *, u8 index ); -u8 RFSynthesizer_SetMaxim2828_50Power( struct hw_data *, u8 index ); -u8 RFSynthesizer_SetMaxim2827_24Power( struct hw_data *, u8 index ); -u8 RFSynthesizer_SetMaxim2827_50Power( struct hw_data *, u8 index ); -u8 RFSynthesizer_SetMaxim2825Power( struct hw_data *, u8 index ); -u8 RFSynthesizer_SetAiroha2230Power( struct hw_data *, u8 index ); -u8 RFSynthesizer_SetAiroha7230Power( struct hw_data *, u8 index ); -u8 RFSynthesizer_SetWinbond242Power( struct hw_data *, u8 index ); -void GetTxVgaFromEEPROM( struct hw_data * pHwData ); -void EEPROMTxVgaAdjust( struct hw_data * pHwData ); // 20060619.5 Add - -#define RFWriteControlData( _A, _V ) Wb35Reg_Write( _A, 0x0864, _V ) - -void Wb35Reg_destroy( struct hw_data * pHwData ); - -unsigned char Wb35Reg_Read( struct hw_data * pHwData, u16 RegisterNo, u32 * pRegisterValue ); -unsigned char Wb35Reg_ReadSync( struct hw_data * pHwData, u16 RegisterNo, u32 * pRegisterValue ); -unsigned char Wb35Reg_Write( struct hw_data * pHwData, u16 RegisterNo, u32 RegisterValue ); -unsigned char Wb35Reg_WriteSync( struct hw_data * pHwData, u16 RegisterNo, u32 RegisterValue ); -unsigned char Wb35Reg_WriteWithCallbackValue( struct hw_data * pHwData, - u16 RegisterNo, - u32 RegisterValue, - s8 *pValue, - s8 Len); -unsigned char Wb35Reg_BurstWrite( struct hw_data * pHwData, u16 RegisterNo, u32 * pRegisterData, u8 NumberOfData, u8 Flag ); - -void Wb35Reg_EP0VM( struct hw_data * pHwData ); -void Wb35Reg_EP0VM_start( struct hw_data * pHwData ); +/* + * ==================================== + * Interface function declare + * ==================================== + */ +unsigned char Wb35Reg_initial(struct hw_data *hw_data); +void Uxx_power_on_procedure(struct hw_data *hw_data); +void Uxx_power_off_procedure(struct hw_data *hw_data); +void Uxx_ReadEthernetAddress(struct hw_data *hw_data); +void Dxx_initial(struct hw_data *hw_data); +void Mxx_initial(struct hw_data *hw_data); +void RFSynthesizer_initial(struct hw_data *hw_data); +void RFSynthesizer_SwitchingChannel(struct hw_data *hw_data, struct chan_info channel); +void BBProcessor_initial(struct hw_data *hw_data); +void BBProcessor_RateChanging(struct hw_data *hw_data, u8 rate); +u8 RFSynthesizer_SetPowerIndex(struct hw_data *hw_data, u8 power_index); +u8 RFSynthesizer_SetMaxim2828_24Power(struct hw_data *, u8 index); +u8 RFSynthesizer_SetMaxim2828_50Power(struct hw_data *, u8 index); +u8 RFSynthesizer_SetMaxim2827_24Power(struct hw_data *, u8 index); +u8 RFSynthesizer_SetMaxim2827_50Power(struct hw_data *, u8 index); +u8 RFSynthesizer_SetMaxim2825Power(struct hw_data *, u8 index); +u8 RFSynthesizer_SetAiroha2230Power(struct hw_data *, u8 index); +u8 RFSynthesizer_SetAiroha7230Power(struct hw_data *, u8 index); +u8 RFSynthesizer_SetWinbond242Power(struct hw_data *, u8 index); +void GetTxVgaFromEEPROM(struct hw_data *hw_data); +void EEPROMTxVgaAdjust(struct hw_data *hw_data); + +#define RFWriteControlData(_A, _V) Wb35Reg_Write(_A, 0x0864, _V) + +void Wb35Reg_destroy(struct hw_data *hw_data); + +unsigned char Wb35Reg_Read(struct hw_data *hw_data, u16 register_no, u32 *register_value); +unsigned char Wb35Reg_ReadSync(struct hw_data *hw_data, u16 register_no, u32 *register_value); +unsigned char Wb35Reg_Write(struct hw_data *hw_data, u16 register_no, u32 register_value); +unsigned char Wb35Reg_WriteSync(struct hw_data *hw_data, u16 register_no, u32 register_value); +unsigned char Wb35Reg_WriteWithCallbackValue(struct hw_data *hw_data, + u16 register_no, + u32 register_value, + s8 *value, + s8 len); +unsigned char Wb35Reg_BurstWrite(struct hw_data *hw_data, + u16 register_no, + u32 *register_data, + u8 number_of_data, + u8 flag); + +void Wb35Reg_EP0VM(struct hw_data *hw_data); +void Wb35Reg_EP0VM_start(struct hw_data *hw_data); void Wb35Reg_EP0VM_complete(struct urb *urb); -u32 BitReverse( u32 dwData, u32 DataLength); +u32 BitReverse(u32 data, u32 data_length); -void CardGetMulticastBit( u8 Address[MAC_ADDR_LENGTH], u8 *Byte, u8 *Value ); -u32 CardComputeCrc( u8 * Buffer, u32 Length ); +void CardGetMulticastBit(u8 address[MAC_ADDR_LENGTH], u8 *byte, u8 *value); +u32 CardComputeCrc(u8 *buffer, u32 length); -void Wb35Reg_phy_calibration( struct hw_data * pHwData ); -void Wb35Reg_Update( struct hw_data * pHwData, u16 RegisterNo, u32 RegisterValue ); -unsigned char adjust_TXVGA_for_iq_mag( struct hw_data * pHwData ); +void Wb35Reg_phy_calibration(struct hw_data *hw_data); +void Wb35Reg_Update(struct hw_data *hw_data, u16 register_no, u32 register_value); +unsigned char adjust_TXVGA_for_iq_mag(struct hw_data *hw_data); #endif diff --git a/drivers/staging/winbond/wb35reg_s.h b/drivers/staging/winbond/wb35reg_s.h index 32ef4b8a2d2a..4eff009444b8 100644 --- a/drivers/staging/winbond/wb35reg_s.h +++ b/drivers/staging/winbond/wb35reg_s.h @@ -5,98 +5,100 @@ #include <linux/types.h> #include <asm/atomic.h> -//======================================================================================= -/* - HAL setting function - - ======================================== - |Uxx| |Dxx| |Mxx| |BB| |RF| - ======================================== - | | - Wb35Reg_Read Wb35Reg_Write - - ---------------------------------------- - WbUsb_CallUSBDASync supplied By WbUsb module -*/ -//======================================================================================= - -#define GetBit( dwData, i) ( dwData & (0x00000001 << i)) -#define SetBit( dwData, i) ( dwData | (0x00000001 << i)) -#define ClearBit( dwData, i) ( dwData & ~(0x00000001 << i)) - -#define IGNORE_INCREMENT 0 -#define AUTO_INCREMENT 0 -#define NO_INCREMENT 1 -#define REG_DIRECTION(_x,_y) ((_y)->DIRECT ==0 ? usb_rcvctrlpipe(_x,0) : usb_sndctrlpipe(_x,0)) -#define REG_BUF_SIZE(_x) ((_x)->bRequest== 0x04 ? cpu_to_le16((_x)->wLength) : 4) - -// 20060613.2 Add the follow definition +/* ========================================================================= + * + * HAL setting function + * + * ======================================== + * |Uxx| |Dxx| |Mxx| |BB| |RF| + * ======================================== + * | | + * Wb35Reg_Read Wb35Reg_Write + * + * ---------------------------------------- + * WbUsb_CallUSBDASync supplied By WbUsb module + * ========================================================================== + */ +#define GetBit(dwData, i) (dwData & (0x00000001 << i)) +#define SetBit(dwData, i) (dwData | (0x00000001 << i)) +#define ClearBit(dwData, i) (dwData & ~(0x00000001 << i)) + +#define IGNORE_INCREMENT 0 +#define AUTO_INCREMENT 0 +#define NO_INCREMENT 1 +#define REG_DIRECTION(_x, _y) ((_y)->DIRECT == 0 ? usb_rcvctrlpipe(_x, 0) : usb_sndctrlpipe(_x, 0)) +#define REG_BUF_SIZE(_x) ((_x)->bRequest == 0x04 ? cpu_to_le16((_x)->wLength) : 4) + #define BB48_DEFAULT_AL2230_11B 0x0033447c #define BB4C_DEFAULT_AL2230_11B 0x0A00FEFF #define BB48_DEFAULT_AL2230_11G 0x00332C1B #define BB4C_DEFAULT_AL2230_11G 0x0A00FEFF -#define BB48_DEFAULT_WB242_11B 0x00292315 //backoff 2dB -#define BB4C_DEFAULT_WB242_11B 0x0800FEFF //backoff 2dB -//#define BB48_DEFAULT_WB242_11B 0x00201B11 //backoff 4dB -//#define BB4C_DEFAULT_WB242_11B 0x0600FF00 //backoff 4dB +#define BB48_DEFAULT_WB242_11B 0x00292315 /* backoff 2dB */ +#define BB4C_DEFAULT_WB242_11B 0x0800FEFF /* backoff 2dB */ #define BB48_DEFAULT_WB242_11G 0x00453B24 #define BB4C_DEFAULT_WB242_11G 0x0E00FEFF -//==================================== -// Default setting for Mxx -//==================================== -#define DEFAULT_CWMIN 31 //(M2C) CWmin. Its value is in the range 0-31. -#define DEFAULT_CWMAX 1023 //(M2C) CWmax. Its value is in the range 0-1023. -#define DEFAULT_AID 1 //(M34) AID. Its value is in the range 1-2007. +/* + * ==================================== + * Default setting for Mxx + * ==================================== + */ +#define DEFAULT_CWMIN 31 /* (M2C) CWmin. Its value is in the range 0-31. */ +#define DEFAULT_CWMAX 1023 /* (M2C) CWmax. Its value is in the range 0-1023. */ +#define DEFAULT_AID 1 /* (M34) AID. Its value is in the range 1-2007. */ #ifdef _USE_FALLBACK_RATE_ -#define DEFAULT_RATE_RETRY_LIMIT 2 //(M38) as named +#define DEFAULT_RATE_RETRY_LIMIT 2 /* (M38) as named */ #else -#define DEFAULT_RATE_RETRY_LIMIT 7 //(M38) as named +#define DEFAULT_RATE_RETRY_LIMIT 7 /* (M38) as named */ #endif -#define DEFAULT_LONG_RETRY_LIMIT 7 //(M38) LongRetryLimit. Its value is in the range 0-15. -#define DEFAULT_SHORT_RETRY_LIMIT 7 //(M38) ShortRetryLimit. Its value is in the range 0-15. -#define DEFAULT_PIFST 25 //(M3C) PIFS Time. Its value is in the range 0-65535. -#define DEFAULT_EIFST 354 //(M3C) EIFS Time. Its value is in the range 0-1048575. -#define DEFAULT_DIFST 45 //(M3C) DIFS Time. Its value is in the range 0-65535. -#define DEFAULT_SIFST 5 //(M3C) SIFS Time. Its value is in the range 0-65535. -#define DEFAULT_OSIFST 10 //(M3C) Original SIFS Time. Its value is in the range 0-15. -#define DEFAULT_ATIMWD 0 //(M40) ATIM Window. Its value is in the range 0-65535. -#define DEFAULT_SLOT_TIME 20 //(M40) ($) SlotTime. Its value is in the range 0-255. -#define DEFAULT_MAX_TX_MSDU_LIFE_TIME 512 //(M44) MaxTxMSDULifeTime. Its value is in the range 0-4294967295. -#define DEFAULT_BEACON_INTERVAL 500 //(M48) Beacon Interval. Its value is in the range 0-65535. -#define DEFAULT_PROBE_DELAY_TIME 200 //(M48) Probe Delay Time. Its value is in the range 0-65535. -#define DEFAULT_PROTOCOL_VERSION 0 //(M4C) -#define DEFAULT_MAC_POWER_STATE 2 //(M4C) 2: MAC at power active -#define DEFAULT_DTIM_ALERT_TIME 0 +#define DEFAULT_LONG_RETRY_LIMIT 7 /* (M38) LongRetryLimit. Its value is in the range 0-15. */ +#define DEFAULT_SHORT_RETRY_LIMIT 7 /* (M38) ShortRetryLimit. Its value is in the range 0-15. */ +#define DEFAULT_PIFST 25 /* (M3C) PIFS Time. Its value is in the range 0-65535. */ +#define DEFAULT_EIFST 354 /* (M3C) EIFS Time. Its value is in the range 0-1048575. */ +#define DEFAULT_DIFST 45 /* (M3C) DIFS Time. Its value is in the range 0-65535. */ +#define DEFAULT_SIFST 5 /* (M3C) SIFS Time. Its value is in the range 0-65535. */ +#define DEFAULT_OSIFST 10 /* (M3C) Original SIFS Time. Its value is in the range 0-15. */ +#define DEFAULT_ATIMWD 0 /* (M40) ATIM Window. Its value is in the range 0-65535. */ +#define DEFAULT_SLOT_TIME 20 /* (M40) ($) SlotTime. Its value is in the range 0-255. */ +#define DEFAULT_MAX_TX_MSDU_LIFE_TIME 512 /* (M44) MaxTxMSDULifeTime. Its value is in the range 0-4294967295. */ +#define DEFAULT_BEACON_INTERVAL 500 /* (M48) Beacon Interval. Its value is in the range 0-65535. */ +#define DEFAULT_PROBE_DELAY_TIME 200 /* (M48) Probe Delay Time. Its value is in the range 0-65535. */ +#define DEFAULT_PROTOCOL_VERSION 0 /* (M4C) */ +#define DEFAULT_MAC_POWER_STATE 2 /* (M4C) 2: MAC at power active */ +#define DEFAULT_DTIM_ALERT_TIME 0 struct wb35_reg_queue { - struct urb *urb; + struct urb *urb; void *pUsbReq; void *Next; union { u32 VALUE; u32 *pBuffer; }; - u8 RESERVED[4]; // space reserved for communication - u16 INDEX; // For storing the register index - u8 RESERVED_VALID; // Indicate whether the RESERVED space is valid at this command. - u8 DIRECT; // 0:In 1:Out + u8 RESERVED[4]; /* space reserved for communication */ + u16 INDEX; /* For storing the register index */ + u8 RESERVED_VALID; /* Indicate whether the RESERVED space is valid at this command. */ + u8 DIRECT; /* 0:In 1:Out */ }; -//==================================== -// Internal variable for module -//==================================== +/* + * ==================================== + * Internal variable for module + * ==================================== + */ #define MAX_SQ3_FILTER_SIZE 5 struct wb35_reg { - //============================ - // Register Bank backup - //============================ - u32 U1B0; //bit16 record the h/w radio on/off status + /* + * ============================ + * Register Bank backup + * ============================ + */ + u32 U1B0; /* bit16 record the h/w radio on/off status */ u32 U1BC_LEDConfigure; u32 D00_DmaControl; u32 M00_MacControl; @@ -105,68 +107,65 @@ struct wb35_reg { u32 M04_MulticastAddress1; u32 M08_MulticastAddress2; }; - u8 Multicast[8]; // contents of card multicast registers + u8 Multicast[8]; /* contents of card multicast registers */ }; u32 M24_MacControl; u32 M28_MacControl; u32 M2C_MacControl; u32 M38_MacControl; - u32 M3C_MacControl; // 20060214 backup only + u32 M3C_MacControl; u32 M40_MacControl; - u32 M44_MacControl; // 20060214 backup only - u32 M48_MacControl; // 20060214 backup only + u32 M44_MacControl; + u32 M48_MacControl; u32 M4C_MacStatus; - u32 M60_MacControl; // 20060214 backup only - u32 M68_MacControl; // 20060214 backup only - u32 M70_MacControl; // 20060214 backup only - u32 M74_MacControl; // 20060214 backup only - u32 M78_ERPInformation;//930206.2.b - u32 M7C_MacControl; // 20060214 backup only - u32 M80_MacControl; // 20060214 backup only - u32 M84_MacControl; // 20060214 backup only - u32 M88_MacControl; // 20060214 backup only - u32 M98_MacControl; // 20060214 backup only - - //[20040722 WK] - //Baseband register - u32 BB0C; // Used for LNA calculation - u32 BB2C; // - u32 BB30; //11b acquisition control register + u32 M60_MacControl; + u32 M68_MacControl; + u32 M70_MacControl; + u32 M74_MacControl; + u32 M78_ERPInformation; + u32 M7C_MacControl; + u32 M80_MacControl; + u32 M84_MacControl; + u32 M88_MacControl; + u32 M98_MacControl; + + /* Baseband register */ + u32 BB0C; /* Used for LNA calculation */ + u32 BB2C; + u32 BB30; /* 11b acquisition control register */ u32 BB3C; - u32 BB48; // 20051221.1.a 20060613.1 Fix OBW issue of 11b/11g rate - u32 BB4C; // 20060613.1 Fix OBW issue of 11b/11g rate - u32 BB50; //mode control register + u32 BB48; + u32 BB4C; + u32 BB50; /* mode control register */ u32 BB54; - u32 BB58; //IQ_ALPHA - u32 BB5C; // For test - u32 BB60; // for WTO read value - - //------------------- - // VM - //------------------- - spinlock_t EP0VM_spin_lock; // 4B - u32 EP0VM_status;//$$ + u32 BB58; /* IQ_ALPHA */ + u32 BB5C; /* For test */ + u32 BB60; /* for WTO read value */ + + /* VM */ + spinlock_t EP0VM_spin_lock; /* 4B */ + u32 EP0VM_status; /* $$ */ struct wb35_reg_queue *reg_first; struct wb35_reg_queue *reg_last; - atomic_t RegFireCount; + atomic_t RegFireCount; - // Hardware status + /* Hardware status */ u8 EP0vm_state; u8 mac_power_save; - u8 EEPROMPhyType; // 0 ~ 15 for Maxim (0 Ä„V MAX2825, 1 Ä„V MAX2827, 2 Ä„V MAX2828, 3 Ä„V MAX2829), - // 16 ~ 31 for Airoha (16 Ä„V AL2230, 11 - AL7230) - // 32 ~ Reserved - // 33 ~ 47 For WB242 ( 33 - WB242, 34 - WB242 with new Txvga 0.5 db step) - // 48 ~ 255 ARE RESERVED. - u8 EEPROMRegion; //Region setting in EEPROM - - u32 SyncIoPause; // If user use the Sync Io to access Hw, then pause the async access - - u8 LNAValue[4]; //Table for speed up running + u8 EEPROMPhyType; /* + * 0 ~ 15 for Maxim (0 Ä„V MAX2825, 1 Ä„V MAX2827, 2 Ä„V MAX2828, 3 Ä„V MAX2829), + * 16 ~ 31 for Airoha (16 Ä„V AL2230, 11 - AL7230) + * 32 ~ Reserved + * 33 ~ 47 For WB242 ( 33 - WB242, 34 - WB242 with new Txvga 0.5 db step) + * 48 ~ 255 ARE RESERVED. + */ + u8 EEPROMRegion; /* Region setting in EEPROM */ + + u32 SyncIoPause; /* If user use the Sync Io to access Hw, then pause the async access */ + + u8 LNAValue[4]; /* Table for speed up running */ u32 SQ3_filter[MAX_SQ3_FILTER_SIZE]; u32 SQ3_index; - }; - #endif diff --git a/drivers/staging/winbond/wb35rx.c b/drivers/staging/winbond/wb35rx.c index d7b57e62db08..efe82b141c10 100644 --- a/drivers/staging/winbond/wb35rx.c +++ b/drivers/staging/winbond/wb35rx.c @@ -1,13 +1,15 @@ -//============================================================================ -// Copyright (c) 1996-2002 Winbond Electronic Corporation -// -// Module Name: -// Wb35Rx.c -// -// Abstract: -// Processing the Rx message from down layer -// -//============================================================================ +/* + * ============================================================================ + * Copyright (c) 1996-2002 Winbond Electronic Corporation + * + * Module Name: + * Wb35Rx.c + * + * Abstract: + * Processing the Rx message from down layer + * + * ============================================================================ + */ #include <linux/usb.h> #include <linux/slab.h> @@ -30,16 +32,7 @@ static void packet_came(struct ieee80211_hw *hw, char *pRxBufferAddress, int Pac return; } - memcpy(skb_put(skb, PacketSize), - pRxBufferAddress, - PacketSize); - -/* - rx_status.rate = 10; - rx_status.channel = 1; - rx_status.freq = 12345; - rx_status.phymode = MODE_IEEE80211B; -*/ + memcpy(skb_put(skb, PacketSize), pRxBufferAddress, PacketSize); memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status)); ieee80211_rx_irqsafe(hw, skb); @@ -47,7 +40,7 @@ static void packet_came(struct ieee80211_hw *hw, char *pRxBufferAddress, int Pac static void Wb35Rx_adjust(struct wb35_descriptor *pRxDes) { - u32 * pRxBufferAddress; + u32 *pRxBufferAddress; u32 DecryptionMethod; u32 i; u16 BufferSize; @@ -56,81 +49,80 @@ static void Wb35Rx_adjust(struct wb35_descriptor *pRxDes) pRxBufferAddress = pRxDes->buffer_address[0]; BufferSize = pRxDes->buffer_size[0]; - // Adjust the last part of data. Only data left - BufferSize -= 4; // For CRC-32 + /* Adjust the last part of data. Only data left */ + BufferSize -= 4; /* For CRC-32 */ if (DecryptionMethod) BufferSize -= 4; - if (DecryptionMethod == 3) // For CCMP + if (DecryptionMethod == 3) /* For CCMP */ BufferSize -= 4; - // Adjust the IV field which after 802.11 header and ICV field. - if (DecryptionMethod == 1) // For WEP - { - for( i=6; i>0; i-- ) - pRxBufferAddress[i] = pRxBufferAddress[i-1]; + /* Adjust the IV field which after 802.11 header and ICV field. */ + if (DecryptionMethod == 1) { /* For WEP */ + for (i = 6; i > 0; i--) + pRxBufferAddress[i] = pRxBufferAddress[i - 1]; pRxDes->buffer_address[0] = pRxBufferAddress + 1; - BufferSize -= 4; // 4 byte for IV - } - else if( DecryptionMethod ) // For TKIP and CCMP - { - for (i=7; i>1; i--) - pRxBufferAddress[i] = pRxBufferAddress[i-2]; - pRxDes->buffer_address[0] = pRxBufferAddress + 2;//Update the descriptor, shift 8 byte - BufferSize -= 8; // 8 byte for IV + ICV + BufferSize -= 4; /* 4 byte for IV */ + } else if (DecryptionMethod) { /* For TKIP and CCMP */ + for (i = 7; i > 1; i--) + pRxBufferAddress[i] = pRxBufferAddress[i - 2]; + pRxDes->buffer_address[0] = pRxBufferAddress + 2; /* Update the descriptor, shift 8 byte */ + BufferSize -= 8; /* 8 byte for IV + ICV */ } pRxDes->buffer_size[0] = BufferSize; } static u16 Wb35Rx_indicate(struct ieee80211_hw *hw) { - struct wbsoft_priv *priv = hw->priv; - struct hw_data * pHwData = &priv->sHwData; + struct wbsoft_priv *priv = hw->priv; + struct hw_data *pHwData = &priv->sHwData; struct wb35_descriptor RxDes; - struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; - u8 * pRxBufferAddress; - u16 PacketSize; - u16 stmp, BufferSize, stmp2 = 0; - u32 RxBufferId; + struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; + u8 *pRxBufferAddress; + u16 PacketSize; + u16 stmp, BufferSize, stmp2 = 0; + u32 RxBufferId; - // Only one thread be allowed to run into the following + /* Only one thread be allowed to run into the following */ do { RxBufferId = pWb35Rx->RxProcessIndex; - if (pWb35Rx->RxOwner[ RxBufferId ]) //Owner by VM + if (pWb35Rx->RxOwner[RxBufferId]) /* Owner by VM */ break; pWb35Rx->RxProcessIndex++; pWb35Rx->RxProcessIndex %= MAX_USB_RX_BUFFER_NUMBER; pRxBufferAddress = pWb35Rx->pDRx; - BufferSize = pWb35Rx->RxBufferSize[ RxBufferId ]; + BufferSize = pWb35Rx->RxBufferSize[RxBufferId]; - // Parse the bulkin buffer + /* Parse the bulkin buffer */ while (BufferSize >= 4) { - if ((cpu_to_le32(*(u32 *)pRxBufferAddress) & 0x0fffffff) == RX_END_TAG) //Is ending? 921002.9.a + if ((cpu_to_le32(*(u32 *)pRxBufferAddress) & 0x0fffffff) == RX_END_TAG) /* Is ending? */ break; - // Get the R00 R01 first + /* Get the R00 R01 first */ RxDes.R00.value = le32_to_cpu(*(u32 *)pRxBufferAddress); PacketSize = (u16)RxDes.R00.R00_receive_byte_count; - RxDes.R01.value = le32_to_cpu(*((u32 *)(pRxBufferAddress+4))); - // For new DMA 4k + RxDes.R01.value = le32_to_cpu(*((u32 *)(pRxBufferAddress + 4))); + /* For new DMA 4k */ if ((PacketSize & 0x03) > 0) PacketSize -= 4; - // Basic check for Rx length. Is length valid? + /* Basic check for Rx length. Is length valid? */ if (PacketSize > MAX_PACKET_SIZE) { - #ifdef _PE_RX_DUMP_ +#ifdef _PE_RX_DUMP_ printk("Serious ERROR : Rx data size too long, size =%d\n", PacketSize); - #endif +#endif pWb35Rx->EP3vm_state = VM_STOP; pWb35Rx->Ep3ErrorCount2++; break; } - // Start to process Rx buffer -// RxDes.Descriptor_ID = RxBufferId; // Due to synchronous indicate, the field doesn't necessary to use. - BufferSize -= 8; //subtract 8 byte for 35's USB header length + /* + * Wb35Rx_indicate() is called synchronously so it isn't + * necessary to set "RxDes.Desctriptor_ID = RxBufferID;" + */ + BufferSize -= 8; /* subtract 8 byte for 35's USB header length */ pRxBufferAddress += 8; RxDes.buffer_address[0] = pRxBufferAddress; @@ -142,18 +134,17 @@ static u16 Wb35Rx_indicate(struct ieee80211_hw *hw) packet_came(hw, pRxBufferAddress, PacketSize); - // Move RxBuffer point to the next + /* Move RxBuffer point to the next */ stmp = PacketSize + 3; - stmp &= ~0x03; // 4n alignment + stmp &= ~0x03; /* 4n alignment */ pRxBufferAddress += stmp; BufferSize -= stmp; stmp2 += stmp; } - // Reclaim resource - pWb35Rx->RxOwner[ RxBufferId ] = 1; + /* Reclaim resource */ + pWb35Rx->RxOwner[RxBufferId] = 1; } while (true); - return stmp2; } @@ -161,112 +152,110 @@ static void Wb35Rx(struct ieee80211_hw *hw); static void Wb35Rx_Complete(struct urb *urb) { - struct ieee80211_hw *hw = urb->context; - struct wbsoft_priv *priv = hw->priv; - struct hw_data * pHwData = &priv->sHwData; - struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; - u8 * pRxBufferAddress; - u32 SizeCheck; - u16 BulkLength; - u32 RxBufferId; - R00_DESCRIPTOR R00; - - // Variable setting + struct ieee80211_hw *hw = urb->context; + struct wbsoft_priv *priv = hw->priv; + struct hw_data *pHwData = &priv->sHwData; + struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; + u8 *pRxBufferAddress; + u32 SizeCheck; + u16 BulkLength; + u32 RxBufferId; + R00_DESCRIPTOR R00; + + /* Variable setting */ pWb35Rx->EP3vm_state = VM_COMPLETED; - pWb35Rx->EP3VM_status = urb->status;//Store the last result of Irp + pWb35Rx->EP3VM_status = urb->status; /* Store the last result of Irp */ RxBufferId = pWb35Rx->CurrentRxBufferId; pRxBufferAddress = pWb35Rx->pDRx; BulkLength = (u16)urb->actual_length; - // The IRP is completed + /* The IRP is completed */ pWb35Rx->EP3vm_state = VM_COMPLETED; - if (pHwData->SurpriseRemove || pHwData->HwStop) // Must be here, or RxBufferId is invalid + if (pHwData->SurpriseRemove || pHwData->HwStop) /* Must be here, or RxBufferId is invalid */ goto error; if (pWb35Rx->rx_halt) goto error; - // Start to process the data only in successful condition - pWb35Rx->RxOwner[ RxBufferId ] = 0; // Set the owner to driver + /* Start to process the data only in successful condition */ + pWb35Rx->RxOwner[RxBufferId] = 0; /* Set the owner to driver */ R00.value = le32_to_cpu(*(u32 *)pRxBufferAddress); - // The URB is completed, check the result + /* The URB is completed, check the result */ if (pWb35Rx->EP3VM_status != 0) { - #ifdef _PE_USB_STATE_DUMP_ +#ifdef _PE_USB_STATE_DUMP_ printk("EP3 IoCompleteRoutine return error\n"); - #endif +#endif pWb35Rx->EP3vm_state = VM_STOP; goto error; } - // 20060220 For recovering. check if operating in single USB mode + /* For recovering. check if operating in single USB mode */ if (!HAL_USB_MODE_BURST(pHwData)) { - SizeCheck = R00.R00_receive_byte_count; //20060926 anson's endian + SizeCheck = R00.R00_receive_byte_count; if ((SizeCheck & 0x03) > 0) SizeCheck -= 4; SizeCheck = (SizeCheck + 3) & ~0x03; - SizeCheck += 12; // 8 + 4 badbeef + SizeCheck += 12; /* 8 + 4 badbeef */ if ((BulkLength > 1600) || (SizeCheck > 1600) || (BulkLength != SizeCheck) || - (BulkLength == 0)) { // Add for fail Urb + (BulkLength == 0)) { /* Add for fail Urb */ pWb35Rx->EP3vm_state = VM_STOP; pWb35Rx->Ep3ErrorCount2++; } } - // Indicating the receiving data + /* Indicating the receiving data */ pWb35Rx->ByteReceived += BulkLength; - pWb35Rx->RxBufferSize[ RxBufferId ] = BulkLength; + pWb35Rx->RxBufferSize[RxBufferId] = BulkLength; - if (!pWb35Rx->RxOwner[ RxBufferId ]) + if (!pWb35Rx->RxOwner[RxBufferId]) Wb35Rx_indicate(hw); kfree(pWb35Rx->pDRx); - // Do the next receive + /* Do the next receive */ Wb35Rx(hw); return; error: - pWb35Rx->RxOwner[ RxBufferId ] = 1; // Set the owner to hardware + pWb35Rx->RxOwner[RxBufferId] = 1; /* Set the owner to hardware */ atomic_dec(&pWb35Rx->RxFireCounter); pWb35Rx->EP3vm_state = VM_STOP; } -// This function cannot reentrain +/* This function cannot reentrain */ static void Wb35Rx(struct ieee80211_hw *hw) { - struct wbsoft_priv *priv = hw->priv; - struct hw_data * pHwData = &priv->sHwData; - struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; - u8 * pRxBufferAddress; - struct urb *urb = pWb35Rx->RxUrb; - int retv; - u32 RxBufferId; - - // - // Issuing URB - // + struct wbsoft_priv *priv = hw->priv; + struct hw_data *pHwData = &priv->sHwData; + struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; + u8 *pRxBufferAddress; + struct urb *urb = pWb35Rx->RxUrb; + int retv; + u32 RxBufferId; + + /* Issuing URB */ if (pHwData->SurpriseRemove || pHwData->HwStop) goto error; if (pWb35Rx->rx_halt) goto error; - // Get RxBuffer's ID + /* Get RxBuffer's ID */ RxBufferId = pWb35Rx->RxBufferId; if (!pWb35Rx->RxOwner[RxBufferId]) { - // It's impossible to run here. - #ifdef _PE_RX_DUMP_ + /* It's impossible to run here. */ +#ifdef _PE_RX_DUMP_ printk("Rx driver fifo unavailable\n"); - #endif +#endif goto error; } - // Update buffer point, then start to bulkin the data from USB + /* Update buffer point, then start to bulkin the data from USB */ pWb35Rx->RxBufferId++; pWb35Rx->RxBufferId %= MAX_USB_RX_BUFFER_NUMBER; @@ -295,18 +284,18 @@ static void Wb35Rx(struct ieee80211_hw *hw) return; error: - // VM stop + /* VM stop */ pWb35Rx->EP3vm_state = VM_STOP; atomic_dec(&pWb35Rx->RxFireCounter); } void Wb35Rx_start(struct ieee80211_hw *hw) { - struct wbsoft_priv *priv = hw->priv; - struct hw_data * pHwData = &priv->sHwData; - struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; + struct wbsoft_priv *priv = hw->priv; + struct hw_data *pHwData = &priv->sHwData; + struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; - // Allow only one thread to run into the Wb35Rx() function + /* Allow only one thread to run into the Wb35Rx() function */ if (atomic_inc_return(&pWb35Rx->RxFireCounter) == 1) { pWb35Rx->EP3vm_state = VM_RUNNING; Wb35Rx(hw); @@ -314,11 +303,10 @@ void Wb35Rx_start(struct ieee80211_hw *hw) atomic_dec(&pWb35Rx->RxFireCounter); } -//===================================================================================== -static void Wb35Rx_reset_descriptor( struct hw_data * pHwData ) +static void Wb35Rx_reset_descriptor(struct hw_data *pHwData) { - struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; - u32 i; + struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; + u32 i; pWb35Rx->ByteReceived = 0; pWb35Rx->RxProcessIndex = 0; @@ -326,49 +314,49 @@ static void Wb35Rx_reset_descriptor( struct hw_data * pHwData ) pWb35Rx->EP3vm_state = VM_STOP; pWb35Rx->rx_halt = 0; - // Initial the Queue. The last buffer is reserved for used if the Rx resource is unavailable. - for( i=0; i<MAX_USB_RX_BUFFER_NUMBER; i++ ) + /* Initial the Queue. The last buffer is reserved for used if the Rx resource is unavailable. */ + for (i = 0; i < MAX_USB_RX_BUFFER_NUMBER; i++) pWb35Rx->RxOwner[i] = 1; } -unsigned char Wb35Rx_initial(struct hw_data * pHwData) +unsigned char Wb35Rx_initial(struct hw_data *pHwData) { struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; - // Initial the Buffer Queue - Wb35Rx_reset_descriptor( pHwData ); + /* Initial the Buffer Queue */ + Wb35Rx_reset_descriptor(pHwData); pWb35Rx->RxUrb = usb_alloc_urb(0, GFP_ATOMIC); - return (!!pWb35Rx->RxUrb); + return !!pWb35Rx->RxUrb; } -void Wb35Rx_stop(struct hw_data * pHwData) +void Wb35Rx_stop(struct hw_data *pHwData) { struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; - // Canceling the Irp if already sends it out. + /* Canceling the Irp if already sends it out. */ if (pWb35Rx->EP3vm_state == VM_RUNNING) { - usb_unlink_urb( pWb35Rx->RxUrb ); // Only use unlink, let Wb35Rx_destroy to free them - #ifdef _PE_RX_DUMP_ + usb_unlink_urb(pWb35Rx->RxUrb); /* Only use unlink, let Wb35Rx_destroy to free them */ +#ifdef _PE_RX_DUMP_ printk("EP3 Rx stop\n"); - #endif +#endif } } -// Needs process context -void Wb35Rx_destroy(struct hw_data * pHwData) +/* Needs process context */ +void Wb35Rx_destroy(struct hw_data *pHwData) { struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; do { - msleep(10); // Delay for waiting function enter 940623.1.a + msleep(10); /* Delay for waiting function enter */ } while (pWb35Rx->EP3vm_state != VM_STOP); - msleep(10); // Delay for waiting function exit 940623.1.b + msleep(10); /* Delay for waiting function exit */ if (pWb35Rx->RxUrb) - usb_free_urb( pWb35Rx->RxUrb ); - #ifdef _PE_RX_DUMP_ + usb_free_urb(pWb35Rx->RxUrb); +#ifdef _PE_RX_DUMP_ printk("Wb35Rx_destroy OK\n"); - #endif +#endif } diff --git a/drivers/staging/winbond/wb35tx_f.h b/drivers/staging/winbond/wb35tx_f.h index a7af9cbe202a..1d3b515f83bc 100644 --- a/drivers/staging/winbond/wb35tx_f.h +++ b/drivers/staging/winbond/wb35tx_f.h @@ -4,18 +4,20 @@ #include "core.h" #include "wbhal_f.h" -//==================================== -// Interface function declare -//==================================== -unsigned char Wb35Tx_initial( struct hw_data * pHwData ); -void Wb35Tx_destroy( struct hw_data * pHwData ); -unsigned char Wb35Tx_get_tx_buffer( struct hw_data * pHwData, u8 **pBuffer ); +/* + * ==================================== + * Interface function declare + * ==================================== + */ +unsigned char Wb35Tx_initial(struct hw_data *hw_data); +void Wb35Tx_destroy(struct hw_data *hw_data); +unsigned char Wb35Tx_get_tx_buffer(struct hw_data *hw_data, u8 **buffer); void Wb35Tx_EP2VM_start(struct wbsoft_priv *adapter); void Wb35Tx_start(struct wbsoft_priv *adapter); -void Wb35Tx_stop( struct hw_data * pHwData ); +void Wb35Tx_stop(struct hw_data *hw_data); -void Wb35Tx_CurrentTime(struct wbsoft_priv *adapter, u32 TimeCount); +void Wb35Tx_CurrentTime(struct wbsoft_priv *adapter, u32 time_count); #endif diff --git a/drivers/staging/winbond/wbhal_f.h b/drivers/staging/winbond/wbhal_f.h index 64a008db30f4..401c024bead8 100644 --- a/drivers/staging/winbond/wbhal_f.h +++ b/drivers/staging/winbond/wbhal_f.h @@ -1,70 +1,91 @@ -//===================================================================== -// Device related include -//===================================================================== +/* + * ===================================================================== + * Device related include + * ===================================================================== +*/ #include "wb35reg_f.h" #include "wb35tx_f.h" #include "wb35rx_f.h" #include "core.h" -//==================================================================================== -// Function declaration -//==================================================================================== -void hal_remove_mapping_key( struct hw_data * pHwData, u8 *pmac_addr ); -void hal_remove_default_key( struct hw_data * pHwData, u32 index ); -unsigned char hal_set_mapping_key( struct hw_data * adapter, u8 *pmac_addr, u8 null_key, u8 wep_on, u8 *ptx_tsc, u8 *prx_tsc, u8 key_type, u8 key_len, u8 *pkey_data ); -unsigned char hal_set_default_key( struct hw_data * adapter, u8 index, u8 null_key, u8 wep_on, u8 *ptx_tsc, u8 *prx_tsc, u8 key_type, u8 key_len, u8 *pkey_data ); -void hal_clear_all_default_key( struct hw_data * pHwData ); -void hal_clear_all_group_key( struct hw_data * pHwData ); -void hal_clear_all_mapping_key( struct hw_data * pHwData ); -void hal_clear_all_key( struct hw_data * pHwData ); -void hal_set_power_save_mode( struct hw_data * pHwData, unsigned char power_save, unsigned char wakeup, unsigned char dtim ); -void hal_get_power_save_mode( struct hw_data * pHwData, u8 *pin_pwr_save ); -void hal_set_slot_time( struct hw_data * pHwData, u8 type ); -#define hal_set_atim_window( _A, _ATM ) -void hal_start_bss( struct hw_data * pHwData, u8 mac_op_mode ); -void hal_join_request( struct hw_data * pHwData, u8 bss_type ); // 0:BSS STA 1:IBSS STA// -void hal_stop_sync_bss( struct hw_data * pHwData ); -void hal_resume_sync_bss( struct hw_data * pHwData); -void hal_set_aid( struct hw_data * pHwData, u16 aid ); -void hal_set_bssid( struct hw_data * pHwData, u8 *pbssid ); -void hal_get_bssid( struct hw_data * pHwData, u8 *pbssid ); -void hal_set_listen_interval( struct hw_data * pHwData, u16 listen_interval ); -void hal_set_cap_info( struct hw_data * pHwData, u16 capability_info ); -void hal_set_ssid( struct hw_data * pHwData, u8 *pssid, u8 ssid_len ); -void hal_start_tx0( struct hw_data * pHwData ); -#define hal_get_cwmin( _A ) ( (_A)->cwmin ) -void hal_set_cwmax( struct hw_data * pHwData, u16 cwin_max ); -#define hal_get_cwmax( _A ) ( (_A)->cwmax ) -void hal_set_rsn_wpa( struct hw_data * pHwData, u32 * RSN_IE_Bitmap , u32 * RSN_OUI_type , unsigned char bDesiredAuthMode); -void hal_set_connect_info( struct hw_data * pHwData, unsigned char boConnect ); -u8 hal_get_est_sq3( struct hw_data * pHwData, u8 Count ); -void hal_descriptor_indicate( struct hw_data * pHwData, struct wb35_descriptor *pDes ); -u8 hal_get_antenna_number( struct hw_data * pHwData ); -u32 hal_get_bss_pk_cnt( struct hw_data * pHwData ); -#define hal_get_region_from_EEPROM( _A ) ( (_A)->reg.EEPROMRegion ) -#define hal_get_tx_buffer( _A, _B ) Wb35Tx_get_tx_buffer( _A, _B ) -#define hal_software_set( _A ) (_A->SoftwareSet) -#define hal_driver_init_OK( _A ) (_A->IsInitOK) -#define hal_rssi_boundary_high( _A ) (_A->RSSI_high) -#define hal_rssi_boundary_low( _A ) (_A->RSSI_low) -#define hal_scan_interval( _A ) (_A->Scan_Interval) - -#define PHY_DEBUG( msg, args... ) - -#define hal_get_time_count( _P ) (_P->time_count/10) // return 100ms count -#define hal_detect_error( _P ) (_P->WbUsb.DetectCount) - -//------------------------------------------------------------------------- -// The follow function is unused for IS89C35 -//------------------------------------------------------------------------- +/* ===================================================================== + * Function declaration + * ===================================================================== + */ +void hal_remove_mapping_key(struct hw_data *hw_data, u8 *mac_addr); +void hal_remove_default_key(struct hw_data *hw_data, u32 index); +unsigned char hal_set_mapping_key(struct hw_data *adapter, u8 *mac_addr, + u8 null_key, u8 wep_on, u8 *tx_tsc, + u8 *rx_tsc, u8 key_type, u8 key_len, + u8 *key_data); +unsigned char hal_set_default_key(struct hw_data *adapter, u8 index, + u8 null_key, u8 wep_on, u8 *tx_tsc, + u8 *rx_tsc, u8 key_type, u8 key_len, + u8 *key_data); +void hal_clear_all_default_key(struct hw_data *hw_data); +void hal_clear_all_group_key(struct hw_data *hw_data); +void hal_clear_all_mapping_key(struct hw_data *hw_data); +void hal_clear_all_key(struct hw_data *hw_data); +void hal_set_power_save_mode(struct hw_data *hw_data, unsigned char power_save, + unsigned char wakeup, unsigned char dtim); +void hal_get_power_save_mode(struct hw_data *hw_data, u8 *in_pwr_save); +void hal_set_slot_time(struct hw_data *hw_data, u8 type); + +#define hal_set_atim_window(_A, _ATM) + +void hal_start_bss(struct hw_data *hw_data, u8 mac_op_mode); + +/* 0:BSS STA 1:IBSS STA */ +void hal_join_request(struct hw_data *hw_data, u8 bss_type); + +void hal_stop_sync_bss(struct hw_data *hw_data); +void hal_resume_sync_bss(struct hw_data *hw_data); +void hal_set_aid(struct hw_data *hw_data, u16 aid); +void hal_set_bssid(struct hw_data *hw_data, u8 *bssid); +void hal_get_bssid(struct hw_data *hw_data, u8 *bssid); +void hal_set_listen_interval(struct hw_data *hw_data, u16 listen_interval); +void hal_set_cap_info(struct hw_data *hw_data, u16 capability_info); +void hal_set_ssid(struct hw_data *hw_data, u8 *ssid, u8 ssid_len); +void hal_start_tx0(struct hw_data *hw_data); + +#define hal_get_cwmin(_A) ((_A)->cwmin) + +void hal_set_cwmax(struct hw_data *hw_data, u16 cwin_max); + +#define hal_get_cwmax(_A) ((_A)->cwmax) + +void hal_set_rsn_wpa(struct hw_data *hw_data, u32 *rsn_ie_bitmap, + u32 *rsn_oui_type , unsigned char desired_auth_mode); +void hal_set_connect_info(struct hw_data *hw_data, unsigned char bo_connect); +u8 hal_get_est_sq3(struct hw_data *hw_data, u8 count); +void hal_descriptor_indicate(struct hw_data *hw_data, + struct wb35_descriptor *des); +u8 hal_get_antenna_number(struct hw_data *hw_data); +u32 hal_get_bss_pk_cnt(struct hw_data *hw_data); + +#define hal_get_region_from_EEPROM(_A) ((_A)->reg.EEPROMRegion) +#define hal_get_tx_buffer(_A, _B) Wb35Tx_get_tx_buffer(_A, _B) +#define hal_software_set(_A) (_A->SoftwareSet) +#define hal_driver_init_OK(_A) (_A->IsInitOK) +#define hal_rssi_boundary_high(_A) (_A->RSSI_high) +#define hal_rssi_boundary_low(_A) (_A->RSSI_low) +#define hal_scan_interval(_A) (_A->Scan_Interval) + +#define PHY_DEBUG(msg, args...) + +/* return 100ms count */ +#define hal_get_time_count(_P) (_P->time_count / 10) +#define hal_detect_error(_P) (_P->WbUsb.DetectCount) + +/* The follow function is unused for IS89C35 */ #define hal_disable_interrupt(_A) #define hal_enable_interrupt(_A) -#define hal_get_interrupt_type( _A) +#define hal_get_interrupt_type(_A) #define hal_get_clear_interrupt(_A) -#define hal_ibss_disconnect(_A) hal_stop_sync_bss(_A) +#define hal_ibss_disconnect(_A) (hal_stop_sync_bss(_A)) #define hal_join_request_stop(_A) -#define hw_get_cxx_reg( _A, _B, _C ) -#define hw_set_cxx_reg( _A, _B, _C ) +#define hw_get_cxx_reg(_A, _B, _C) +#define hw_set_cxx_reg(_A, _B, _C) diff --git a/drivers/staging/winbond/wbhal_s.h b/drivers/staging/winbond/wbhal_s.h index 372a05e3021a..33457c2e39be 100644 --- a/drivers/staging/winbond/wbhal_s.h +++ b/drivers/staging/winbond/wbhal_s.h @@ -4,179 +4,166 @@ #include <linux/types.h> #include <linux/if_ether.h> /* for ETH_ALEN */ -//[20040722 WK] -#define HAL_LED_SET_MASK 0x001c //20060901 Extend -#define HAL_LED_SET_SHIFT 2 +#define HAL_LED_SET_MASK 0x001c +#define HAL_LED_SET_SHIFT 2 -//supported RF type +/* supported RF type */ #define RF_MAXIM_2825 0 #define RF_MAXIM_2827 1 #define RF_MAXIM_2828 2 #define RF_MAXIM_2829 3 -#define RF_MAXIM_V1 15 +#define RF_MAXIM_V1 15 #define RF_AIROHA_2230 16 #define RF_AIROHA_7230 17 -#define RF_AIROHA_2230S 18 // 20060420 Add this -// #define RF_RFMD_2959 32 // 20060626 Remove all about RFMD -#define RF_WB_242 33 -#define RF_WB_242_1 34 // 20060619.5 Add +#define RF_AIROHA_2230S 18 +#define RF_WB_242 33 +#define RF_WB_242_1 34 #define RF_DECIDE_BY_INF 255 -//---------------------------------------------------------------- -// The follow define connect to upper layer -// User must modify for connection between HAL and upper layer -//---------------------------------------------------------------- - - - - -///////////////////////////////////////////////////////////////////////////////////////////////////// -//================================================================================================ -// Common define -//================================================================================================ -#define HAL_USB_MODE_BURST( _H ) (_H->SoftwareSet & 0x20 ) // Bit 5 20060901 Modify - -// Scan interval -#define SCAN_MAX_CHNL_TIME (50) - -// For TxL2 Frame typr recognise +/* + * ---------------------------------------------------------------- + * The follow define connect to upper layer + * User must modify for connection between HAL and upper layer + * ---------------------------------------------------------------- + */ + +/* + * ============================== + * Common define + * ============================== + */ +/* Bit 5 */ +#define HAL_USB_MODE_BURST(_H) (_H->SoftwareSet & 0x20) + +/* Scan interval */ +#define SCAN_MAX_CHNL_TIME (50) + +/* For TxL2 Frame typr recognise */ #define FRAME_TYPE_802_3_DATA 0 #define FRAME_TYPE_802_11_MANAGEMENT 1 -#define FRAME_TYPE_802_11_MANAGEMENT_CHALLENGE 2 +#define FRAME_TYPE_802_11_MANAGEMENT_CHALLENGE 2 #define FRAME_TYPE_802_11_CONTROL 3 #define FRAME_TYPE_802_11_DATA 4 #define FRAME_TYPE_PROMISCUOUS 5 -// The follow definition is used for convert the frame-------------------- -#define DOT_11_SEQUENCE_OFFSET 22 //Sequence control offset +/* The follow definition is used for convert the frame------------ */ +#define DOT_11_SEQUENCE_OFFSET 22 /* Sequence control offset */ #define DOT_3_TYPE_OFFSET 12 -#define DOT_11_MAC_HEADER_SIZE 24 +#define DOT_11_MAC_HEADER_SIZE 24 #define DOT_11_SNAP_SIZE 6 -#define DOT_11_TYPE_OFFSET 30 //The start offset of 802.11 Frame. Type encapsulatuin. +#define DOT_11_TYPE_OFFSET 30 /* The start offset of 802.11 Frame. Type encapsulation. */ #define DEFAULT_SIFSTIME 10 -#define DEFAULT_FRAGMENT_THRESHOLD 2346 // No fragment +#define DEFAULT_FRAGMENT_THRESHOLD 2346 /* No fragment */ #define DEFAULT_MSDU_LIFE_TIME 0xffff -#define LONG_PREAMBLE_PLUS_PLCPHEADER_TIME (144+48) -#define SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME (72+24) -#define PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION (16+4+6) -#define Tsym 4 +#define LONG_PREAMBLE_PLUS_PLCPHEADER_TIME (144 + 48) +#define SHORT_PREAMBLE_PLUS_PLCPHEADER_TIME (72 + 24) +#define PREAMBLE_PLUS_SIGNAL_PLUS_SIGNALEXTENSION (16 + 4 + 6) +#define Tsym 4 -// Frame Type of Bits (2, 3)--------------------------------------------- +/* Frame Type of Bits (2, 3)----------------------------------- */ #define MAC_TYPE_MANAGEMENT 0x00 #define MAC_TYPE_CONTROL 0x04 #define MAC_TYPE_DATA 0x08 -#define MASK_FRAGMENT_NUMBER 0x000F -#define SEQUENCE_NUMBER_SHIFT 4 +#define MASK_FRAGMENT_NUMBER 0x000F +#define SEQUENCE_NUMBER_SHIFT 4 #define HAL_WOL_TYPE_WAKEUP_FRAME 0x01 #define HAL_WOL_TYPE_MAGIC_PACKET 0x02 -// 20040106 ADDED -#define HAL_KEYTYPE_WEP40 0 -#define HAL_KEYTYPE_WEP104 1 -#define HAL_KEYTYPE_TKIP 2 // 128 bit key -#define HAL_KEYTYPE_AES_CCMP 3 // 128 bit key +#define HAL_KEYTYPE_WEP40 0 +#define HAL_KEYTYPE_WEP104 1 +#define HAL_KEYTYPE_TKIP 2 /* 128 bit key */ +#define HAL_KEYTYPE_AES_CCMP 3 /* 128 bit key */ -// For VM state +/* For VM state */ enum { VM_STOP = 0, VM_RUNNING, VM_COMPLETED }; -//----------------------------------------------------- -// Normal Key table format -//----------------------------------------------------- -// The order of KEY index is MAPPING_KEY_START_INDEX > GROUP_KEY_START_INDEX -#define MAX_KEY_TABLE 24 // 24 entry for storing key data +/* + * ================================ + * Normal Key table format + * ================================ + */ + +/* The order of KEY index is MAPPING_KEY_START_INDEX > GROUP_KEY_START_INDEX */ +#define MAX_KEY_TABLE 24 /* 24 entry for storing key data */ #define GROUP_KEY_START_INDEX 4 #define MAPPING_KEY_START_INDEX 8 -//-------------------------------------------------------- -// Descriptor -//-------------------------------------------------------- -#define MAX_DESCRIPTOR_BUFFER_INDEX 8 // Have to multiple of 2 -//#define FLAG_ERROR_TX_MASK cpu_to_le32(0x000000bf) //20061009 marked by anson's endian -#define FLAG_ERROR_TX_MASK 0x000000bf //20061009 anson's endian -//#define FLAG_ERROR_RX_MASK 0x00000c3f -//#define FLAG_ERROR_RX_MASK cpu_to_le32(0x0000083f) //20061009 marked by anson's endian - //Don't care replay error, - //it is handled by S/W -#define FLAG_ERROR_RX_MASK 0x0000083f //20060926 anson's endian - -#define FLAG_BAND_RX_MASK 0x10000000 //Bit 28 - -typedef struct _R00_DESCRIPTOR -{ - union - { +/* + * ========================================= + * Descriptor + * ========================================= + */ +#define MAX_DESCRIPTOR_BUFFER_INDEX 8 /* Have to multiple of 2 */ +#define FLAG_ERROR_TX_MASK 0x000000bf +#define FLAG_ERROR_RX_MASK 0x0000083f + +#define FLAG_BAND_RX_MASK 0x10000000 /* Bit 28 */ + +typedef struct _R00_DESCRIPTOR { + union { u32 value; - #ifdef _BIG_ENDIAN_ //20060926 anson's endian - struct - { +#ifdef _BIG_ENDIAN_ + struct { u32 R00_packet_or_buffer_status:1; u32 R00_packet_in_fifo:1; u32 R00_RESERVED:2; u32 R00_receive_byte_count:12; u32 R00_receive_time_index:16; }; - #else - struct - { +#else + struct { u32 R00_receive_time_index:16; u32 R00_receive_byte_count:12; u32 R00_RESERVED:2; u32 R00_packet_in_fifo:1; u32 R00_packet_or_buffer_status:1; }; - #endif +#endif }; } R00_DESCRIPTOR, *PR00_DESCRIPTOR; -typedef struct _T00_DESCRIPTOR -{ - union - { +typedef struct _T00_DESCRIPTOR { + union { u32 value; - #ifdef _BIG_ENDIAN_ //20061009 anson's endian - struct - { - u32 T00_first_mpdu:1; // for hardware use - u32 T00_last_mpdu:1; // for hardware use - u32 T00_IsLastMpdu:1;// 0: not 1:Yes for software used - u32 T00_IgnoreResult:1;// The same mechanism with T00 setting. 050111 Modify for TS - u32 T00_RESERVED_ID:2;//3 bit ID reserved - u32 T00_tx_packet_id:4;//930519.4.e 930810.3.c +#ifdef _BIG_ENDIAN_ + struct { + u32 T00_first_mpdu:1; /* for hardware use */ + u32 T00_last_mpdu:1; /* for hardware use */ + u32 T00_IsLastMpdu:1;/* 0:not 1:Yes for software used */ + u32 T00_IgnoreResult:1;/* The same mechanism with T00 setting. */ + u32 T00_RESERVED_ID:2;/* 3 bit ID reserved */ + u32 T00_tx_packet_id:4; u32 T00_RESERVED:4; u32 T00_header_length:6; u32 T00_frame_length:12; }; - #else - struct - { +#else + struct { u32 T00_frame_length:12; u32 T00_header_length:6; u32 T00_RESERVED:4; - u32 T00_tx_packet_id:4;//930519.4.e 930810.3.c - u32 T00_RESERVED_ID:2;//3 bit ID reserved - u32 T00_IgnoreResult:1;// The same mechanism with T00 setting. 050111 Modify for TS - u32 T00_IsLastMpdu:1;// 0: not 1:Yes for software used - u32 T00_last_mpdu:1; // for hardware use - u32 T00_first_mpdu:1; // for hardware use + u32 T00_tx_packet_id:4; + u32 T00_RESERVED_ID:2; /* 3 bit ID reserved */ + u32 T00_IgnoreResult:1; /* The same mechanism with T00 setting. */ + u32 T00_IsLastMpdu:1; /* 0:not 1:Yes for software used */ + u32 T00_last_mpdu:1; /* for hardware use */ + u32 T00_first_mpdu:1; /* for hardware use */ }; - #endif +#endif }; } T00_DESCRIPTOR, *PT00_DESCRIPTOR; -typedef struct _R01_DESCRIPTOR -{ - union - { +typedef struct _R01_DESCRIPTOR { + union { u32 value; - #ifdef _BIG_ENDIAN_ //20060926 add by anson's endian - struct - { +#ifdef _BIG_ENDIAN_ + struct { u32 R01_RESERVED:3; u32 R01_mod_type:1; u32 R01_pre_type:1; @@ -197,9 +184,8 @@ typedef struct _R01_DESCRIPTOR u32 R01_icv_error:1; u32 R01_crc_error:1; }; - #else - struct - { +#else + struct { u32 R01_crc_error:1; u32 R01_icv_error:1; u32 R01_null_key_to_authentication_frame:1; @@ -220,18 +206,15 @@ typedef struct _R01_DESCRIPTOR u32 R01_mod_type:1; u32 R01_RESERVED:3; }; - #endif +#endif }; } R01_DESCRIPTOR, *PR01_DESCRIPTOR; -typedef struct _T01_DESCRIPTOR -{ - union - { +typedef struct _T01_DESCRIPTOR { + union { u32 value; - #ifdef _BIG_ENDIAN_ //20061009 anson's endian - struct - { +#ifdef _BIG_ENDIAN_ + struct { u32 T01_rts_cts_duration:16; u32 T01_fall_back_rate:3; u32 T01_add_rts:1; @@ -245,9 +228,8 @@ typedef struct _T01_DESCRIPTOR u32 T01_loop_back_wep_mode:1; u32 T01_retry_abort_ebable:1; }; - #else - struct - { +#else + struct { u32 T01_retry_abort_ebable:1; u32 T01_loop_back_wep_mode:1; u32 T01_inhibit_crc:1; @@ -261,21 +243,18 @@ typedef struct _T01_DESCRIPTOR u32 T01_fall_back_rate:3; u32 T01_rts_cts_duration:16; }; - #endif +#endif }; } T01_DESCRIPTOR, *PT01_DESCRIPTOR; -typedef struct _T02_DESCRIPTOR -{ - union - { +typedef struct _T02_DESCRIPTOR { + union { u32 value; - #ifdef _BIG_ENDIAN_ //20061009 add by anson's endian - struct - { - u32 T02_IsLastMpdu:1;// The same mechanism with T00 setting - u32 T02_IgnoreResult:1;// The same mechanism with T00 setting. 050111 Modify for TS - u32 T02_RESERVED_ID:2;// The same mechanism with T00 setting +#ifdef _BIG_ENDIAN_ + struct { + u32 T02_IsLastMpdu:1; /* The same mechanism with T00 setting */ + u32 T02_IgnoreResult:1; /* The same mechanism with T00 setting. */ + u32 T02_RESERVED_ID:2; /* The same mechanism with T00 setting */ u32 T02_Tx_PktID:4; u32 T02_MPDU_Cnt:4; u32 T02_RTS_Cnt:4; @@ -290,9 +269,8 @@ typedef struct _T02_DESCRIPTOR u32 T02_transmit_abort:1; u32 T02_transmit_fail:1; }; - #else - struct - { +#else + struct { u32 T02_transmit_fail:1; u32 T02_transmit_abort:1; u32 T02_out_of_MaxTxMSDULiftTime:1; @@ -306,122 +284,120 @@ typedef struct _T02_DESCRIPTOR u32 T02_RTS_Cnt:4; u32 T02_MPDU_Cnt:4; u32 T02_Tx_PktID:4; - u32 T02_RESERVED_ID:2;// The same mechanism with T00 setting - u32 T02_IgnoreResult:1;// The same mechanism with T00 setting. 050111 Modify for TS - u32 T02_IsLastMpdu:1;// The same mechanism with T00 setting + u32 T02_RESERVED_ID:2; /* The same mechanism with T00 setting */ + u32 T02_IgnoreResult:1; /* The same mechanism with T00 setting. */ + u32 T02_IsLastMpdu:1; /* The same mechanism with T00 setting */ }; - #endif +#endif }; } T02_DESCRIPTOR, *PT02_DESCRIPTOR; -struct wb35_descriptor { // Skip length = 8 DWORD - // ID for descriptor ---, The field doesn't be cleard in the operation of Descriptor definition +struct wb35_descriptor { /* Skip length = 8 DWORD */ + /* ID for descriptor ---, The field doesn't be cleard in the operation of Descriptor definition */ u8 Descriptor_ID; - //----------------------The above region doesn't be cleared by DESCRIPTOR_RESET------ + /* ----------------------The above region doesn't be cleared by DESCRIPTOR_RESET------ */ u8 RESERVED[3]; u16 FragmentThreshold; - u8 InternalUsed;//Only can be used by operation of descriptor definition - u8 Type;// 0: 802.3 1:802.11 data frame 2:802.11 management frame + u8 InternalUsed; /* Only can be used by operation of descriptor definition */ + u8 Type; /* 0: 802.3 1:802.11 data frame 2:802.11 management frame */ - u8 PreambleMode;// 0: short 1:long + u8 PreambleMode;/* 0: short 1:long */ u8 TxRate; u8 FragmentCount; - u8 EapFix; // For speed up key install + u8 EapFix; /* For speed up key install */ - // For R00 and T00 ---------------------------------------------- - union - { + /* For R00 and T00 ------------------------------ */ + union { R00_DESCRIPTOR R00; T00_DESCRIPTOR T00; }; - // For R01 and T01 ---------------------------------------------- - union - { + /* For R01 and T01 ------------------------------ */ + union { R01_DESCRIPTOR R01; T01_DESCRIPTOR T01; }; - // For R02 and T02 ---------------------------------------------- - union - { - u32 R02; + /* For R02 and T02 ------------------------------ */ + union { + u32 R02; T02_DESCRIPTOR T02; }; - // For R03 and T03 ---------------------------------------------- - // For software used - union - { + /* For R03 and T03 ------------------------------ */ + /* For software used */ + union { u32 R03; u32 T03; - struct - { + struct { u8 buffer_number; u8 buffer_start_index; u16 buffer_total_size; }; }; - // For storing the buffer - u16 buffer_size[ MAX_DESCRIPTOR_BUFFER_INDEX ]; - void* buffer_address[ MAX_DESCRIPTOR_BUFFER_INDEX ];//931130.4.q - + /* For storing the buffer */ + u16 buffer_size[MAX_DESCRIPTOR_BUFFER_INDEX]; + void *buffer_address[MAX_DESCRIPTOR_BUFFER_INDEX]; }; -#define DEFAULT_NULL_PACKET_COUNT 180000 //20060828.1 Add. 180 seconds +#define DEFAULT_NULL_PACKET_COUNT 180000 /* 180 seconds */ -#define MAX_TXVGA_EEPROM 9 //How many word(u16) of EEPROM will be used for TxVGA -#define MAX_RF_PARAMETER 32 +#define MAX_TXVGA_EEPROM 9 /* How many word(u16) of EEPROM will be used for TxVGA */ +#define MAX_RF_PARAMETER 32 typedef struct _TXVGA_FOR_50 { - u8 ChanNo; - u8 TxVgaValue; + u8 ChanNo; + u8 TxVgaValue; } TXVGA_FOR_50; -//===================================================================== -// Device related include -//===================================================================== +/* + * ============================================== + * Device related include + * ============================================== + */ #include "wbusb_s.h" #include "wb35reg_s.h" #include "wb35tx_s.h" #include "wb35rx_s.h" -// For Hal using ================================================================== +/* For Hal using ============================================ */ struct hw_data { - // For compatible with 33 + /* For compatible with 33 */ u32 revision; - u32 BB3c_cal; // The value for Tx calibration comes from EEPROM - u32 BB54_cal; // The value for Rx calibration comes from EEPROM + u32 BB3c_cal; /* The value for Tx calibration comes from EEPROM */ + u32 BB54_cal; /* The value for Rx calibration comes from EEPROM */ - - // For surprise remove - u32 SurpriseRemove; // 0: Normal 1: Surprise remove + /* For surprise remove */ + u32 SurpriseRemove; /* 0: Normal 1: Surprise remove */ u8 IsKeyPreSet; - u8 CalOneTime; // 20060630.1 + u8 CalOneTime; u8 VCO_trim; - // For Fix 1'st DMA bug u32 FragCount; - u32 DMAFix; //V1_DMA_FIX The variable can be removed if driver want to save mem space for V2. - - //=============================================== - // Definition for MAC address - //=============================================== - u8 PermanentMacAddress[ETH_ALEN + 2]; // The Enthernet addr that are stored in EEPROM. + 2 to 8-byte alignment - u8 CurrentMacAddress[ETH_ALEN + 2]; // The Enthernet addr that are in used. + 2 to 8-byte alignment - - //===================================================================== - // Definition for 802.11 - //===================================================================== - u8 *bssid_pointer; // Used by hal_get_bssid for return value - u8 bssid[8];// Only 6 byte will be used. 8 byte is required for read buffer - u8 ssid[32];// maximum ssid length is 32 byte + u32 DMAFix; /* V1_DMA_FIX The variable can be removed if driver want to save mem space for V2. */ + + /* + * =============================================== + * Definition for MAC address + * =============================================== + */ + u8 PermanentMacAddress[ETH_ALEN + 2]; /* The Ethernet addr that are stored in EEPROM. + 2 to 8-byte alignment */ + u8 CurrentMacAddress[ETH_ALEN + 2]; /* The Enthernet addr that are in used. + 2 to 8-byte alignment */ + + /* + * ========================================= + * Definition for 802.11 + * ========================================= + */ + u8 *bssid_pointer; /* Used by hal_get_bssid for return value */ + u8 bssid[8]; /* Only 6 byte will be used. 8 byte is required for read buffer */ + u8 ssid[32]; /* maximum ssid length is 32 byte */ u16 AID; u8 ssid_length; @@ -433,112 +409,118 @@ struct hw_data { u16 BeaconPeriod; u16 ProbeDelay; - u8 bss_type;// 0: IBSS_NET or 1:ESS_NET - u8 preamble;// 0: short preamble, 1: long preamble - u8 slot_time_select;// 9 or 20 value - u8 phy_type;// Phy select + u8 bss_type;/* 0: IBSS_NET or 1:ESS_NET */ + u8 preamble;/* 0: short preamble, 1: long preamble */ + u8 slot_time_select; /* 9 or 20 value */ + u8 phy_type; /* Phy select */ u32 phy_para[MAX_RF_PARAMETER]; u32 phy_number; - u32 CurrentRadioSw; // 20060320.2 0:On 1:Off - u32 CurrentRadioHw; // 20060825 0:On 1:Off + u32 CurrentRadioSw; /* 0:On 1:Off */ + u32 CurrentRadioHw; /* 0:On 1:Off */ - u8 *power_save_point; // Used by hal_get_power_save_mode for return value + u8 *power_save_point; /* Used by hal_get_power_save_mode for return value */ u8 cwmin; u8 desired_power_save; - u8 dtim;// Is running dtim - u8 mapping_key_replace_index;//In Key table, the next index be replaced 931130.4.r + u8 dtim; /* Is running dtim */ + u8 mapping_key_replace_index; /* In Key table, the next index be replaced */ u16 MaxReceiveLifeTime; u16 FragmentThreshold; u16 FragmentThreshold_tmp; u16 cwmax; - u8 Key_slot[MAX_KEY_TABLE][8]; //Ownership record for key slot. For Alignment - u32 Key_content[MAX_KEY_TABLE][12]; // 10DW for each entry + 2 for burst command( Off and On valid bit) + u8 Key_slot[MAX_KEY_TABLE][8]; /* Ownership record for key slot. For Alignment */ + u32 Key_content[MAX_KEY_TABLE][12]; /* 10DW for each entry + 2 for burst command (Off and On valid bit) */ u8 CurrentDefaultKeyIndex; u32 CurrentDefaultKeyLength; - //======================================================================== - // Variable for each module - //======================================================================== - struct wb_usb WbUsb; // Need WbUsb.h - struct wb35_reg reg; // Need Wb35Reg.h - struct wb35_tx Wb35Tx; // Need Wb35Tx.h - struct wb35_rx Wb35Rx; // Need Wb35Rx.h + /* + * ================================================== + * Variable for each module + * ================================================== + */ + struct wb_usb WbUsb; /* Need WbUsb.h */ + struct wb35_reg reg; /* Need Wb35Reg.h */ + struct wb35_tx Wb35Tx; /* Need Wb35Tx.h */ + struct wb35_rx Wb35Rx; /* Need Wb35Rx.h */ - struct timer_list LEDTimer;// For LED + struct timer_list LEDTimer; /* For LED */ - u32 LEDpoint;// For LED + u32 LEDpoint; /* For LED */ - u32 dto_tx_retry_count; // LA20040210_DTO kevin - u32 dto_tx_frag_count; // LA20040210_DTO kevin - u32 rx_ok_count[13]; // index=0: total rx ok - //u32 rx_ok_bytes[13]; // index=0, total rx ok bytes - u32 rx_err_count[13]; // index=0: total rx err + u32 dto_tx_retry_count; + u32 dto_tx_frag_count; + u32 rx_ok_count[13]; /* index=0: total rx ok */ + u32 rx_err_count[13]; /* index=0: total rx err */ - //for Tx debug + /* for Tx debug */ u32 tx_TBTT_start_count; u32 tx_ETR_count; u32 tx_WepOn_false_count; u32 tx_Null_key_count; u32 tx_retry_count[8]; - u8 PowerIndexFromEEPROM; // For 2412MHz - u8 power_index; - u8 IsWaitJoinComplete; // TRUE: set join request - u8 band; + u8 PowerIndexFromEEPROM; /* For 2412MHz */ + u8 power_index; + u8 IsWaitJoinComplete; /* TRUE: set join request */ + u8 band; - u16 SoftwareSet; - u16 Reserved_s; + u16 SoftwareSet; + u16 Reserved_s; - u32 IsInitOK; // 0: Driver starting 1: Driver init OK + u32 IsInitOK; /* 0: Driver starting 1: Driver init OK */ - // For Phy calibration - s32 iq_rsdl_gain_tx_d2; - s32 iq_rsdl_phase_tx_d2; - u32 txvga_setting_for_cal; // 20060703.1 Add + /* For Phy calibration */ + s32 iq_rsdl_gain_tx_d2; + s32 iq_rsdl_phase_tx_d2; + u32 txvga_setting_for_cal; - u8 TxVgaSettingInEEPROM[ (((MAX_TXVGA_EEPROM*2)+3) & ~0x03) ]; // 20060621 For backup EEPROM value - u8 TxVgaFor24[16]; // Max is 14, 2 for alignment - TXVGA_FOR_50 TxVgaFor50[36]; // 35 channels in 5G. 35x2 = 70 byte. 2 for alignments + u8 TxVgaSettingInEEPROM[(((MAX_TXVGA_EEPROM * 2) + 3) & ~0x03)]; /* For EEPROM value */ + u8 TxVgaFor24[16]; /* Max is 14, 2 for alignment */ + TXVGA_FOR_50 TxVgaFor50[36]; /* 35 channels in 5G. 35x2 = 70 byte. 2 for alignments */ - u16 Scan_Interval; - u16 RESERVED6; + u16 Scan_Interval; + u16 RESERVED6; - // LED control + /* LED control */ u32 LED_control; - // LED_control 4 byte: Gray_Led_1[3] Gray_Led_0[2] Led[1] Led[0] - // Gray_Led - // For Led gray setting - // Led - // 0: normal control, LED behavior will decide by EEPROM setting - // 1: Turn off specific LED - // 2: Always on specific LED - // 3: slow blinking specific LED - // 4: fast blinking specific LED - // 5: WPS led control is set. Led0 is Red, Led1 id Green - // Led[1] is parameter for WPS LED mode - // // 1:InProgress 2: Error 3: Session overlap 4: Success 20061108 control - - u32 LED_LinkOn; //Turn LED on control - u32 LED_Scanning; // Let LED in scan process control - u32 LED_Blinking; // Temp variable for shining + /* + * LED_control 4 byte: Gray_Led_1[3] Gray_Led_0[2] Led[1] Led[0] + * Gray_Led + * For Led gray setting + * Led + * 0: normal control, + * LED behavior will decide by EEPROM setting + * 1: Turn off specific LED + * 2: Always on specific LED + * 3: slow blinking specific LED + * 4: fast blinking specific LED + * 5: WPS led control is set. Led0 is Red, Led1 id Green + * + * Led[1] is parameter for WPS LED mode + * 1:InProgress + * 2: Error + * 3: Session overlap + * 4: Success control + */ + u32 LED_LinkOn; /* Turn LED on control */ + u32 LED_Scanning; /* Let LED in scan process control */ + u32 LED_Blinking; /* Temp variable for shining */ u32 RxByteCountLast; u32 TxByteCountLast; atomic_t SurpriseRemoveCount; - // For global timer - u32 time_count;//TICK_TIME_100ms 1 = 100ms + /* For global timer */ + u32 time_count; /* TICK_TIME_100ms 1 = 100ms */ - // For error recover + /* For error recover */ u32 HwStop; - // 20060828.1 for avoid AP disconnect + /* For avoid AP disconnect */ u32 NullPacketCount; - }; #endif diff --git a/drivers/staging/winbond/wblinux_f.h b/drivers/staging/winbond/wblinux_f.h index 868e87727240..0a9d214f7187 100644 --- a/drivers/staging/winbond/wblinux_f.h +++ b/drivers/staging/winbond/wblinux_f.h @@ -4,13 +4,14 @@ #include "core.h" #include "mds_s.h" -//========================================================================= -// Copyright (c) 1996-2004 Winbond Electronic Corporation -// -// wblinux_f.h -// -int wb35_start_xmit(struct sk_buff *skb, struct net_device *netdev ); -void wb35_set_multicast( struct net_device *netdev ); -struct net_device_stats * wb35_netdev_stats( struct net_device *netdev ); - +/* + * ==================================================================== + * Copyright (c) 1996-2004 Winbond Electronic Corporation + * + * wblinux_f.h + * ==================================================================== + */ +int wb35_start_xmit(struct sk_buff *skb, struct net_device *netdev); +void wb35_set_multicast(struct net_device *netdev); +struct net_device_stats *wb35_netdev_stats(struct net_device *netdev); #endif diff --git a/drivers/staging/winbond/wbusb.c b/drivers/staging/winbond/wbusb.c index 5d9499bba9cc..681419d6856e 100644 --- a/drivers/staging/winbond/wbusb.c +++ b/drivers/staging/winbond/wbusb.c @@ -142,19 +142,17 @@ static void hal_set_radio_mode(struct hw_data *pHwData, unsigned char radio_off) if (pHwData->SurpriseRemove) return; - if (radio_off) //disable Baseband receive off - { - pHwData->CurrentRadioSw = 1; // off + if (radio_off) { /* disable Baseband receive off */ + pHwData->CurrentRadioSw = 1; /* off */ reg->M24_MacControl &= 0xffffffbf; } else { - pHwData->CurrentRadioSw = 0; // on + pHwData->CurrentRadioSw = 0; /* on */ reg->M24_MacControl |= 0x00000040; } Wb35Reg_Write(pHwData, 0x0824, reg->M24_MacControl); } -static void -hal_set_current_channel_ex(struct hw_data *pHwData, struct chan_info channel) +static void hal_set_current_channel_ex(struct hw_data *pHwData, struct chan_info channel) { struct wb35_reg *reg = &pHwData->reg; @@ -163,17 +161,18 @@ hal_set_current_channel_ex(struct hw_data *pHwData, struct chan_info channel) printk("Going to channel: %d/%d\n", channel.band, channel.ChanNo); - RFSynthesizer_SwitchingChannel(pHwData, channel); // Switch channel + RFSynthesizer_SwitchingChannel(pHwData, channel); /* Switch channel */ pHwData->Channel = channel.ChanNo; pHwData->band = channel.band; #ifdef _PE_STATE_DUMP_ printk("Set channel is %d, band =%d\n", pHwData->Channel, pHwData->band); #endif - reg->M28_MacControl &= ~0xff; // Clean channel information field + reg->M28_MacControl &= ~0xff; /* Clean channel information field */ reg->M28_MacControl |= channel.ChanNo; Wb35Reg_WriteWithCallbackValue(pHwData, 0x0828, reg->M28_MacControl, - (s8 *) & channel, sizeof(struct chan_info)); + (s8 *) &channel, + sizeof(struct chan_info)); } static void hal_set_current_channel(struct hw_data *pHwData, struct chan_info channel) @@ -188,21 +187,22 @@ static void hal_set_accept_broadcast(struct hw_data *pHwData, u8 enable) if (pHwData->SurpriseRemove) return; - reg->M00_MacControl &= ~0x02000000; //The HW value + reg->M00_MacControl &= ~0x02000000; /* The HW value */ if (enable) - reg->M00_MacControl |= 0x02000000; //The HW value + reg->M00_MacControl |= 0x02000000; /* The HW value */ Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); } -//for wep key error detection, we need to accept broadcast packets to be received temporary. +/* For wep key error detection, we need to accept broadcast packets to be received temporary. */ static void hal_set_accept_promiscuous(struct hw_data *pHwData, u8 enable) { struct wb35_reg *reg = &pHwData->reg; if (pHwData->SurpriseRemove) return; + if (enable) { reg->M00_MacControl |= 0x00400000; Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); @@ -219,9 +219,9 @@ static void hal_set_accept_multicast(struct hw_data *pHwData, u8 enable) if (pHwData->SurpriseRemove) return; - reg->M00_MacControl &= ~0x01000000; //The HW value + reg->M00_MacControl &= ~0x01000000; /* The HW value */ if (enable) - reg->M00_MacControl |= 0x01000000; //The HW value + reg->M00_MacControl |= 0x01000000; /* The HW value */ Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); } @@ -232,13 +232,12 @@ static void hal_set_accept_beacon(struct hw_data *pHwData, u8 enable) if (pHwData->SurpriseRemove) return; - // 20040108 debug - if (!enable) //Due to SME and MLME are not suitable for 35 + if (!enable) /* Due to SME and MLME are not suitable for 35 */ return; - reg->M00_MacControl &= ~0x04000000; //The HW value + reg->M00_MacControl &= ~0x04000000; /* The HW value */ if (enable) - reg->M00_MacControl |= 0x04000000; //The HW value + reg->M00_MacControl |= 0x04000000; /* The HW value */ Wb35Reg_Write(pHwData, 0x0800, reg->M00_MacControl); } @@ -283,8 +282,7 @@ static const struct ieee80211_ops wbsoft_ops = { .get_tsf = wbsoft_get_tsf, }; -static void -hal_set_ethernet_address(struct hw_data *pHwData, u8 * current_address) +static void hal_set_ethernet_address(struct hw_data *pHwData, u8 *current_address) { u32 ltmp[2]; @@ -294,14 +292,12 @@ hal_set_ethernet_address(struct hw_data *pHwData, u8 * current_address) memcpy(pHwData->CurrentMacAddress, current_address, ETH_ALEN); ltmp[0] = cpu_to_le32(*(u32 *) pHwData->CurrentMacAddress); - ltmp[1] = - cpu_to_le32(*(u32 *) (pHwData->CurrentMacAddress + 4)) & 0xffff; + ltmp[1] = cpu_to_le32(*(u32 *) (pHwData->CurrentMacAddress + 4)) & 0xffff; Wb35Reg_BurstWrite(pHwData, 0x03e8, ltmp, 2, AUTO_INCREMENT); } -static void -hal_get_permanent_address(struct hw_data *pHwData, u8 * pethernet_address) +static void hal_get_permanent_address(struct hw_data *pHwData, u8 *pethernet_address) { if (pHwData->SurpriseRemove) return; @@ -319,7 +315,7 @@ static void hal_stop(struct hw_data *pHwData) pHwData->Wb35Tx.tx_halt = 1; Wb35Tx_stop(pHwData); - reg->D00_DmaControl &= ~0xc0000000; //Tx Off, Rx Off + reg->D00_DmaControl &= ~0xc0000000; /* Tx Off, Rx Off */ Wb35Reg_Write(pHwData, 0x0400, reg->D00_DmaControl); } @@ -346,14 +342,14 @@ u8 hal_get_antenna_number(struct hw_data *pHwData) } /* 0 : radio on; 1: radio off */ -static u8 hal_get_hw_radio_off(struct hw_data * pHwData) +static u8 hal_get_hw_radio_off(struct hw_data *pHwData) { struct wb35_reg *reg = &pHwData->reg; if (pHwData->SurpriseRemove) return 1; - //read the bit16 of register U1B0 + /* read the bit16 of register U1B0 */ Wb35Reg_Read(pHwData, 0x3b0, ®->U1B0); if ((reg->U1B0 & 0x00010000)) { pHwData->CurrentRadioHw = 1; @@ -387,104 +383,98 @@ static void hal_led_control(unsigned long data) if (pHwData->LED_control) { ltmp2 = pHwData->LED_control & 0xff; - if (ltmp2 == 5) // 5 is WPS mode - { + if (ltmp2 == 5) { /* 5 is WPS mode */ TimeInterval = 100; ltmp2 = (pHwData->LED_control >> 8) & 0xff; switch (ltmp2) { - case 1: // [0.2 On][0.1 Off]... + case 1: /* [0.2 On][0.1 Off]... */ pHwData->LED_Blinking %= 3; - ltmp = 0x1010; // Led 1 & 0 Green and Red - if (pHwData->LED_Blinking == 2) // Turn off + ltmp = 0x1010; /* Led 1 & 0 Green and Red */ + if (pHwData->LED_Blinking == 2) /* Turn off */ ltmp = 0; break; - case 2: // [0.1 On][0.1 Off]... + case 2: /* [0.1 On][0.1 Off]... */ pHwData->LED_Blinking %= 2; - ltmp = 0x0010; // Led 0 red color - if (pHwData->LED_Blinking) // Turn off + ltmp = 0x0010; /* Led 0 red color */ + if (pHwData->LED_Blinking) /* Turn off */ ltmp = 0; break; - case 3: // [0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.5 Off]... + case 3: /* [0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.1 On][0.1 Off][0.5 Off]... */ pHwData->LED_Blinking %= 15; - ltmp = 0x0010; // Led 0 red color - if ((pHwData->LED_Blinking >= 9) || (pHwData->LED_Blinking % 2)) // Turn off 0.6 sec + ltmp = 0x0010; /* Led 0 red color */ + if ((pHwData->LED_Blinking >= 9) || (pHwData->LED_Blinking % 2)) /* Turn off 0.6 sec */ ltmp = 0; break; - case 4: // [300 On][ off ] - ltmp = 0x1000; // Led 1 Green color + case 4: /* [300 On][ off ] */ + ltmp = 0x1000; /* Led 1 Green color */ if (pHwData->LED_Blinking >= 3000) - ltmp = 0; // led maybe on after 300sec * 32bit counter overlap. + ltmp = 0; /* led maybe on after 300sec * 32bit counter overlap. */ break; } pHwData->LED_Blinking++; reg->U1BC_LEDConfigure = ltmp; - if (LEDSet != 7) // Only 111 mode has 2 LEDs on PCB. - { - reg->U1BC_LEDConfigure |= (ltmp & 0xff) << 8; // Copy LED result to each LED control register + if (LEDSet != 7) { /* Only 111 mode has 2 LEDs on PCB. */ + reg->U1BC_LEDConfigure |= (ltmp & 0xff) << 8; /* Copy LED result to each LED control register */ reg->U1BC_LEDConfigure |= (ltmp & 0xff00) >> 8; } Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); } - } else if (pHwData->CurrentRadioSw || pHwData->CurrentRadioHw) // If radio off - { + } else if (pHwData->CurrentRadioSw || pHwData->CurrentRadioHw) { /* If radio off */ if (reg->U1BC_LEDConfigure & 0x1010) { reg->U1BC_LEDConfigure &= ~0x1010; Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); } } else { switch (LEDSet) { - case 4: // [100] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing - if (!pHwData->LED_LinkOn) // Blink only if not Link On - { - // Blinking if scanning is on progress + case 4: /* [100] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing */ + if (!pHwData->LED_LinkOn) { /* Blink only if not Link On */ + /* Blinking if scanning is on progress */ if (pHwData->LED_Scanning) { if (pHwData->LED_Blinking == 0) { reg->U1BC_LEDConfigure |= 0x10; - Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 On + Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 On */ pHwData->LED_Blinking = 1; TimeInterval = 300; } else { reg->U1BC_LEDConfigure &= ~0x10; - Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off + Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 Off */ pHwData->LED_Blinking = 0; TimeInterval = 300; } } else { - //Turn Off LED_0 + /* Turn Off LED_0 */ if (reg->U1BC_LEDConfigure & 0x10) { reg->U1BC_LEDConfigure &= ~0x10; - Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off + Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 Off */ } } } else { - // Turn On LED_0 + /* Turn On LED_0 */ if ((reg->U1BC_LEDConfigure & 0x10) == 0) { reg->U1BC_LEDConfigure |= 0x10; - Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off + Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 Off */ } } break; - - case 6: // [110] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing - if (!pHwData->LED_LinkOn) // Blink only if not Link On - { - // Blinking if scanning is on progress + case 6: /* [110] Only 1 Led be placed on PCB and use pin 21 of IC. Use LED_0 for showing */ + if (!pHwData->LED_LinkOn) { /* Blink only if not Link On */ + /* Blinking if scanning is on progress */ if (pHwData->LED_Scanning) { if (pHwData->LED_Blinking == 0) { reg->U1BC_LEDConfigure &= ~0xf; reg->U1BC_LEDConfigure |= 0x10; - Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 On + Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 On */ pHwData->LED_Blinking = 1; TimeInterval = 300; } else { reg->U1BC_LEDConfigure &= ~0x1f; - Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off + Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 Off */ pHwData->LED_Blinking = 0; TimeInterval = 300; } } else { - // 20060901 Gray blinking if in disconnect state and not scanning + /* Gray blinking if in disconnect state and not scanning */ ltmp = reg->U1BC_LEDConfigure; reg->U1BC_LEDConfigure &= ~0x1f; if (LED_GRAY2[(pHwData->LED_Blinking % 30)]) { @@ -494,85 +484,78 @@ static void hal_led_control(unsigned long data) } pHwData->LED_Blinking++; if (reg->U1BC_LEDConfigure != ltmp) - Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off + Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 Off */ TimeInterval = 100; } } else { - // Turn On LED_0 + /* Turn On LED_0 */ if ((reg->U1BC_LEDConfigure & 0x10) == 0) { reg->U1BC_LEDConfigure |= 0x10; - Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_0 Off + Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_0 Off */ } } break; - - case 5: // [101] Only 1 Led be placed on PCB and use LED_1 for showing - if (!pHwData->LED_LinkOn) // Blink only if not Link On - { - // Blinking if scanning is on progress + case 5: /* [101] Only 1 Led be placed on PCB and use LED_1 for showing */ + if (!pHwData->LED_LinkOn) { /* Blink only if not Link On */ + /* Blinking if scanning is on progress */ if (pHwData->LED_Scanning) { if (pHwData->LED_Blinking == 0) { - reg->U1BC_LEDConfigure |= - 0x1000; - Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 On + reg->U1BC_LEDConfigure |= 0x1000; + Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_1 On */ pHwData->LED_Blinking = 1; TimeInterval = 300; } else { - reg->U1BC_LEDConfigure &= - ~0x1000; - Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 Off + reg->U1BC_LEDConfigure &= ~0x1000; + Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_1 Off */ pHwData->LED_Blinking = 0; TimeInterval = 300; } } else { - //Turn Off LED_1 + /* Turn Off LED_1 */ if (reg->U1BC_LEDConfigure & 0x1000) { - reg->U1BC_LEDConfigure &= - ~0x1000; - Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 Off + reg->U1BC_LEDConfigure &= ~0x1000; + Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_1 Off */ } } } else { - // Is transmitting/receiving ?? + /* Is transmitting/receiving ?? */ if ((adapter->RxByteCount != pHwData->RxByteCountLast) || (adapter->TxByteCount != pHwData->TxByteCountLast)) { if ((reg->U1BC_LEDConfigure & 0x3000) != 0x3000) { - reg->U1BC_LEDConfigure |= - 0x3000; - Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 On + reg->U1BC_LEDConfigure |= 0x3000; + Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_1 On */ } - // Update variable + /* Update variable */ pHwData->RxByteCountLast = adapter->RxByteCount; pHwData->TxByteCountLast = adapter->TxByteCount; TimeInterval = 200; } else { - // Turn On LED_1 and blinking if transmitting/receiving + /* Turn On LED_1 and blinking if transmitting/receiving */ if ((reg->U1BC_LEDConfigure & 0x3000) != 0x1000) { reg->U1BC_LEDConfigure &= ~0x3000; reg->U1BC_LEDConfigure |= 0x1000; - Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); // LED_1 On + Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); /* LED_1 On */ } } } break; - - default: // Default setting. 2 LED be placed on PCB. LED_0: Link On LED_1 Active + default: /* Default setting. 2 LED be placed on PCB. LED_0: Link On LED_1 Active */ if ((reg->U1BC_LEDConfigure & 0x3000) != 0x3000) { - reg->U1BC_LEDConfigure |= 0x3000; // LED_1 is always on and event enable + reg->U1BC_LEDConfigure |= 0x3000; /* LED_1 is always on and event enable */ Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); } if (pHwData->LED_Blinking) { - // Gray blinking + /* Gray blinking */ reg->U1BC_LEDConfigure &= ~0x0f; reg->U1BC_LEDConfigure |= 0x10; reg->U1BC_LEDConfigure |= @@ -584,7 +567,7 @@ static void hal_led_control(unsigned long data) if (pHwData->LED_Blinking < 40) TimeInterval = 100; else { - pHwData->LED_Blinking = 0; // Stop blinking + pHwData->LED_Blinking = 0; /* Stop blinking */ reg->U1BC_LEDConfigure &= ~0x0f; Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); @@ -593,16 +576,14 @@ static void hal_led_control(unsigned long data) } if (pHwData->LED_LinkOn) { - if (!(reg->U1BC_LEDConfigure & 0x10)) // Check the LED_0 - { - //Try to turn ON LED_0 after gray blinking + if (!(reg->U1BC_LEDConfigure & 0x10)) { /* Check the LED_0 */ + /* Try to turn ON LED_0 after gray blinking */ reg->U1BC_LEDConfigure |= 0x10; - pHwData->LED_Blinking = 1; //Start blinking + pHwData->LED_Blinking = 1; /* Start blinking */ TimeInterval = 50; } } else { - if (reg->U1BC_LEDConfigure & 0x10) // Check the LED_0 - { + if (reg->U1BC_LEDConfigure & 0x10) { /* Check the LED_0 */ reg->U1BC_LEDConfigure &= ~0x10; Wb35Reg_Write(pHwData, 0x03bc, reg->U1BC_LEDConfigure); @@ -611,7 +592,7 @@ static void hal_led_control(unsigned long data) break; } - //20060828.1 Active send null packet to avoid AP disconnect + /* Active send null packet to avoid AP disconnect */ if (pHwData->LED_LinkOn) { pHwData->NullPacketCount += TimeInterval; if (pHwData->NullPacketCount >= @@ -622,7 +603,7 @@ static void hal_led_control(unsigned long data) } pHwData->time_count += TimeInterval; - Wb35Tx_CurrentTime(adapter, pHwData->time_count); // 20060928 add + Wb35Tx_CurrentTime(adapter, pHwData->time_count); pHwData->LEDTimer.expires = jiffies + msecs_to_jiffies(TimeInterval); add_timer(&pHwData->LEDTimer); } @@ -654,7 +635,7 @@ static int hal_init_hardware(struct ieee80211_hw *hw) SoftwareSet = hal_software_set(pHwData); #ifdef Vendor2 - // Try to make sure the EEPROM contain + /* Try to make sure the EEPROM contain */ SoftwareSet >>= 8; if (SoftwareSet != 0x82) return false; diff --git a/drivers/staging/winbond/wbusb_s.h b/drivers/staging/winbond/wbusb_s.h index 0c7e6a383f2d..8961ae594c4e 100644 --- a/drivers/staging/winbond/wbusb_s.h +++ b/drivers/staging/winbond/wbusb_s.h @@ -1,16 +1,10 @@ -//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -// Copyright (c) 1996-2004 Winbond Electronic Corporation -// -// Module Name: -// wbusb_s.h -// -// Abstract: -// Linux driver. -// -// Author: -// -//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - +/* ========================================================= + * Copyright (c) 1996-2004 Winbond Electronic Corporation + * + * Module Name: + * wbusb_s.h + * ========================================================= + */ #ifndef __WINBOND_WBUSB_S_H #define __WINBOND_WBUSB_S_H @@ -18,8 +12,7 @@ struct wb_usb { u32 IsUsb20; - struct usb_device *udev; + struct usb_device *udev; u32 DetectCount; }; - #endif diff --git a/drivers/staging/wlags49_h2/ap_h2.c b/drivers/staging/wlags49_h2/ap_h2.c index f5123d2cb4c1..eb8244c4d6f0 100644 --- a/drivers/staging/wlags49_h2/ap_h2.c +++ b/drivers/staging/wlags49_h2/ap_h2.c @@ -25,10 +25,10 @@ */ -#include "hcfcfg.h" // to get hcf_16 etc defined as well as - // possible settings which inluence mdd.h or dhf.h -#include "mdd.h" //to get COMP_ID_STA etc defined -#include "dhf.h" //used to be "fhfmem.h", to get memblock,plugrecord, +#include "hcfcfg.h" /* to get hcf_16 etc defined as well as */ + /* possible settings which inluence mdd.h or dhf.h */ +#include "mdd.h" /* to get COMP_ID_STA etc defined */ +#include "dhf.h" /* used to be "fhfmem.h", to get memblock,plugrecord, */ static const hcf_8 fw_image_1_data[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -3238,59 +3238,59 @@ static const hcf_8 fw_image_4_data[] = { static const CFG_IDENTITY_STRCT fw_image_infoidentity[] = { { - sizeof( CFG_IDENTITY_STRCT ) / sizeof(hcf_16) - 1, + sizeof(CFG_IDENTITY_STRCT) / sizeof(hcf_16) - 1, CFG_FW_IDENTITY, COMP_ID_FW_AP, - 2, //Variant - 2, //Major - 36 //Minor + 2, /* Variant / + 2, /* Major */ + 36 /* Minor */ }, - { 0000, 0000, 0000, 0000, 0000, 0000 } //endsentinel + { 0000, 0000, 0000, 0000, 0000, 0000 } /* endsentinel */ }; static const CFG_PROG_STRCT fw_image_code[] = { { 8, CFG_PROG, - CFG_PROG_VOLATILE, // mode - 0x0146, // sizeof(fw_image_1_data), - 0x00000060, // Target address in NIC Memory - 0x0000, // CRC: yes/no TYPE: primary/station/tertiary - (hcf_8 FAR *) fw_image_1_data + CFG_PROG_VOLATILE, /* mode */ + 0x0146, /* sizeof(fw_image_1_data), */ + 0x00000060, /* Target address in NIC Memory */ + 0x0000, /* CRC: yes/no TYPE: primary/station/tertiary */ + (hcf_8 FAR *) fw_image_1_data }, { 8, CFG_PROG, - CFG_PROG_VOLATILE, // mode - 0x1918, // sizeof(fw_image_2_data), - 0x00000C16, // Target address in NIC Memory - 0x0000, // CRC: yes/no TYPE: primary/station/tertiary - (hcf_8 FAR *) fw_image_2_data + CFG_PROG_VOLATILE, /* mode */ + 0x1918, /* sizeof(fw_image_2_data), */ + 0x00000C16, /* Target address in NIC Memory */ + 0x0000, /* CRC: yes/no TYPE: primary/station/tertiary */ + (hcf_8 FAR *) fw_image_2_data }, { 8, CFG_PROG, - CFG_PROG_VOLATILE, // mode - 0x01bc, // sizeof(fw_image_3_data), - 0x001E252E, // Target address in NIC Memory - 0x0000, // CRC: yes/no TYPE: primary/station/tertiary - (hcf_8 FAR *) fw_image_3_data + CFG_PROG_VOLATILE, /* mode */ + 0x01bc, /* sizeof(fw_image_3_data), */ + 0x001E252E, /* Target address in NIC Memory */ + 0x0000, /* CRC: yes/no TYPE: primary/station/tertiary */ + (hcf_8 FAR *) fw_image_3_data }, { 8, CFG_PROG, - CFG_PROG_VOLATILE, // mode - 0xab28, // sizeof(fw_image_4_data), - 0x001F4000, // Target address in NIC Memory - 0x0000, // CRC: yes/no TYPE: primary/station/tertiary - (hcf_8 FAR *) fw_image_4_data + CFG_PROG_VOLATILE, /* mode */ + 0xab28, /* sizeof(fw_image_4_data), */ + 0x001F4000, /* Target address in NIC Memory */ + 0x0000, /* CRC: yes/no TYPE: primary/station/tertiary */ + (hcf_8 FAR *) fw_image_4_data }, { 5, CFG_PROG, - CFG_PROG_STOP, // mode + CFG_PROG_STOP, /* mode*/ 0000, - 0x000F1297, // Start execution address + 0x000F1297, /* Start execution address */ }, { 0000, 0000, 0000, 0000, 00000000, 0000, 00000000} }; @@ -3301,7 +3301,7 @@ static const CFG_RANGE20_STRCT fw_image_infocompat[] = { COMP_ROLE_SUPL, COMP_ID_APF, { - { 2, 2, 4 } //variant, bottom, top + { 2, 2, 4 } /* variant, bottom, top */ } }, { 3 + ((20 * sizeof(CFG_RANGE_SPEC_STRCT)) / sizeof(hcf_16)), @@ -3309,9 +3309,9 @@ static const CFG_RANGE20_STRCT fw_image_infocompat[] = { COMP_ROLE_ACT, COMP_ID_MFI, { - { 4, 6, 7 }, //variant, bottom, top - { 5, 6, 7 }, //variant, bottom, top - { 6, 6, 7 } //variant, bottom, top + { 4, 6, 7 }, /* variant, bottom, top */ + { 5, 6, 7 }, /* variant, bottom, top */ + { 6, 6, 7 } /* variant, bottom, top */ } }, { 3 + ((20 * sizeof(CFG_RANGE_SPEC_STRCT)) / sizeof(hcf_16)), @@ -3319,18 +3319,18 @@ static const CFG_RANGE20_STRCT fw_image_infocompat[] = { COMP_ROLE_ACT, COMP_ID_CFI, { - { 2, 1, 2 } //variant, bottom, top + { 2, 1, 2 } /* variant, bottom, top */ } }, - { 0000, 0000, 0000, 0000, { { 0000, 0000, 0000 } } } //endsentinel + { 0000, 0000, 0000, 0000, { { 0000, 0000, 0000 } } } /* endsentinel */ }; memimage fw_image = { - "FUPU7D37dhfwci\001C", //signature, <format number>, C/Bin type + "FUPU7D37dhfwci\001C", /* signature, <format number>, C/Bin type */ (CFG_PROG_STRCT *) fw_image_code, 0x000F1297, - 00000000, //(dummy) pdaplug - 00000000, //(dummy) priplug + 00000000, /* (dummy) pdaplug */ + 00000000, /* (dummy) priplug */ (CFG_RANGE20_STRCT *) fw_image_infocompat, (CFG_IDENTITY_STRCT *) fw_image_infoidentity, }; diff --git a/drivers/staging/wlags49_h2/debug.h b/drivers/staging/wlags49_h2/debug.h index 0b52e17b3011..2c3dd140a35f 100644 --- a/drivers/staging/wlags49_h2/debug.h +++ b/drivers/staging/wlags49_h2/debug.h @@ -22,7 +22,7 @@ * software indicates your acceptance of these terms and conditions. If you do * not agree with these terms and conditions, do not use the software. * - * Copyright © 2003 Agere Systems Inc. + * Copyright (c) 2003 Agere Systems Inc. * All rights reserved. * * Redistribution and use in source or binary forms, with or without @@ -70,7 +70,7 @@ #else #undef DBG #define DBG 1 -#endif //DBG +#endif /* DBG */ @@ -84,7 +84,7 @@ #ifndef DBG_LVL #define DBG_LVL 5 /* yields nothing via init_module, original value of 5 yields DBG_TRACE_ON and DBG_VERBOSE_ON */ -#endif // DBG_LVL +#endif /* DBG_LVL*/ #define DBG_ERROR_ON 0x00000001L @@ -100,80 +100,94 @@ #define DBG_DEFAULTS (DBG_ERROR_ON | DBG_WARNING_ON | DBG_BREAK_ON) -#define DBG_FLAGS(A) (A)->DebugFlag -#define DBG_NAME(A) (A)->dbgName -#define DBG_LEVEL(A) (A)->dbgLevel +#define DBG_FLAGS(A) ((A)->DebugFlag) +#define DBG_NAME(A) ((A)->dbgName) +#define DBG_LEVEL(A) ((A)->dbgLevel) #ifndef PRINTK # define PRINTK(S...) printk(S) -#endif // PRINTK +#endif /* PRINTK */ #ifndef DBG_PRINT # define DBG_PRINT(S...) PRINTK(KERN_DEBUG S) -#endif // DBG_PRINT +#endif /* DBG_PRINT */ #ifndef DBG_PRINTC # define DBG_PRINTC(S...) PRINTK(S) -#endif // DBG_PRINTC +#endif /* DBG_PRINTC */ #ifndef DBG_TRAP # define DBG_TRAP {} -#endif // DBG_TRAP +#endif /* DBG_TRAP */ #define _ENTER_STR ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" #define _LEAVE_STR "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" -#define _DBG_ENTER(A) DBG_PRINT("%s:%.*s:%s\n",DBG_NAME(A),++DBG_LEVEL(A),_ENTER_STR,__FUNC__) -#define _DBG_LEAVE(A) DBG_PRINT("%s:%.*s:%s\n",DBG_NAME(A),DBG_LEVEL(A)--,_LEAVE_STR,__FUNC__) +#define _DBG_ENTER(A) DBG_PRINT("%s:%.*s:%s\n", DBG_NAME(A), ++DBG_LEVEL(A), _ENTER_STR, __FUNC__) +#define _DBG_LEAVE(A) DBG_PRINT("%s:%.*s:%s\n", DBG_NAME(A), DBG_LEVEL(A)--, _LEAVE_STR, __FUNC__) #define DBG_FUNC(F) static const char *__FUNC__ = F; -#define DBG_ENTER(A) {if (DBG_FLAGS(A) & DBG_TRACE_ON) _DBG_ENTER(A);} +#define DBG_ENTER(A) {if (DBG_FLAGS(A) & DBG_TRACE_ON) \ + _DBG_ENTER(A); } -#define DBG_LEAVE(A) {if (DBG_FLAGS(A) & DBG_TRACE_ON) _DBG_LEAVE(A);} +#define DBG_LEAVE(A) {if (DBG_FLAGS(A) & DBG_TRACE_ON) \ + _DBG_LEAVE(A); } -#define DBG_PARAM(A,N,F,S...) {if (DBG_FLAGS(A) & DBG_PARAM_ON) \ - DBG_PRINT(" %s -- "F"\n",N,S);} +#define DBG_PARAM(A, N, F, S...) {if (DBG_FLAGS(A) & DBG_PARAM_ON) \ + DBG_PRINT(" %s -- "F"\n", N, S); } -#define DBG_ERROR(A,S...) {if (DBG_FLAGS(A) & DBG_ERROR_ON) \ - {DBG_PRINT("%s:ERROR:%s ",DBG_NAME(A),__FUNC__);DBG_PRINTC(S);DBG_TRAP;}} +#define DBG_ERROR(A, S...) {if (DBG_FLAGS(A) & DBG_ERROR_ON) {\ + DBG_PRINT("%s:ERROR:%s ", DBG_NAME(A), __FUNC__);\ + DBG_PRINTC(S); \ + DBG_TRAP; \ + } \ + } -#define DBG_WARNING(A,S...) {if (DBG_FLAGS(A) & DBG_WARNING_ON) \ - {DBG_PRINT("%s:WARNING:%s ",DBG_NAME(A),__FUNC__);DBG_PRINTC(S);}} +#define DBG_WARNING(A, S...) {if (DBG_FLAGS(A) & DBG_WARNING_ON) {\ + DBG_PRINT("%s:WARNING:%s ", DBG_NAME(A), __FUNC__);\ + DBG_PRINTC(S); } } -#define DBG_NOTICE(A,S...) {if (DBG_FLAGS(A) & DBG_NOTICE_ON) \ - {DBG_PRINT("%s:NOTICE:%s ",DBG_NAME(A),__FUNC__);DBG_PRINTC(S);}} +#define DBG_NOTICE(A, S...) {if (DBG_FLAGS(A) & DBG_NOTICE_ON) {\ + DBG_PRINT("%s:NOTICE:%s ", DBG_NAME(A), __FUNC__);\ + DBG_PRINTC(S); \ + } \ + } -#define DBG_TRACE(A,S...) do {if (DBG_FLAGS(A) & DBG_TRACE_ON) \ - {DBG_PRINT("%s:%s ",DBG_NAME(A),__FUNC__);DBG_PRINTC(S);}} while (0) +#define DBG_TRACE(A, S...) do {if (DBG_FLAGS(A) & DBG_TRACE_ON) {\ + DBG_PRINT("%s:%s ", DBG_NAME(A), __FUNC__);\ + DBG_PRINTC(S); } } while (0) -#define DBG_RX(A,S...) {if (DBG_FLAGS(A) & DBG_RX_ON) \ - {DBG_PRINT(S);}} +#define DBG_RX(A, S...) {if (DBG_FLAGS(A) & DBG_RX_ON) {\ + DBG_PRINT(S); } } -#define DBG_TX(A,S...) {if (DBG_FLAGS(A) & DBG_TX_ON) \ - {DBG_PRINT(S);}} +#define DBG_TX(A, S...) {if (DBG_FLAGS(A) & DBG_TX_ON) {\ + DBG_PRINT(S); } } -#define DBG_DS(A,S...) {if (DBG_FLAGS(A) & DBG_DS_ON) \ - {DBG_PRINT(S);}} +#define DBG_DS(A, S...) {if (DBG_FLAGS(A) & DBG_DS_ON) {\ + DBG_PRINT(S); } } -#define DBG_ASSERT(C) {if (!(C)) \ - {DBG_PRINT("ASSERT(%s) -- %s#%d (%s)\n", \ - #C,__FILE__,__LINE__,__FUNC__); \ - DBG_TRAP;}} +#define DBG_ASSERT(C) { \ + if (!(C)) {\ + DBG_PRINT("ASSERT(%s) -- %s#%d (%s)\n", \ + #C, __FILE__, __LINE__, __FUNC__); \ + DBG_TRAP; \ + } \ + } typedef struct { char *dbgName; @@ -183,7 +197,7 @@ typedef struct { /****************************************************************************/ -#else // DBG +#else /* DBG */ /****************************************************************************/ #define DBG_DEFN @@ -192,21 +206,21 @@ typedef struct { #define DBG_PRINT(S...) #define DBG_ENTER(A) #define DBG_LEAVE(A) -#define DBG_PARAM(A,N,F,S...) -#define DBG_ERROR(A,S...) -#define DBG_WARNING(A,S...) -#define DBG_NOTICE(A,S...) -#define DBG_TRACE(A,S...) -#define DBG_RX(A,S...) -#define DBG_TX(A,S...) -#define DBG_DS(A,S...) +#define DBG_PARAM(A, N, F, S...) +#define DBG_ERROR(A, S...) +#define DBG_WARNING(A, S...) +#define DBG_NOTICE(A, S...) +#define DBG_TRACE(A, S...) +#define DBG_RX(A, S...) +#define DBG_TX(A, S...) +#define DBG_DS(A, S...) #define DBG_ASSERT(C) -#endif // DBG +#endif /* DBG */ /****************************************************************************/ -#endif // _DEBUG_H +#endif /* _DEBUG_H */ diff --git a/drivers/staging/wlags49_h2/dhf.c b/drivers/staging/wlags49_h2/dhf.c index b6f5834b1aff..d5fb1a97e855 100644 --- a/drivers/staging/wlags49_h2/dhf.c +++ b/drivers/staging/wlags49_h2/dhf.c @@ -1,5 +1,5 @@ -// vim:tw=110:ts=4: +/* vim:tw=110:ts=4: */ /************************************************************************************************************** * * FILE : DHF.C @@ -54,8 +54,8 @@ * software indicates your acceptance of these terms and conditions. If you do * not agree with these terms and conditions, do not use the software. * -* COPYRIGHT © 1999 - 2000 by Lucent Technologies. All Rights Reserved -* COPYRIGHT © 2001 - 2004 by Agere Systems Inc. All Rights Reserved +* COPYRIGHT (C) 1999 - 2000 by Lucent Technologies. All Rights Reserved +* COPYRIGHT (C) 2001 - 2004 by Agere Systems Inc. All Rights Reserved * All rights reserved. * * Redistribution and use in source or binary forms, with or without @@ -97,7 +97,7 @@ #include "dhf.h" #include "mmd.h" -//to distinguish MMD from HCF asserts by means of line number +/* to distinguish MMD from HCF asserts by means of line number */ #undef FILE_NAME_OFFSET #define FILE_NAME_OFFSET MMD_FILE_NAME_OFFSET /*----------------------------------------------------------------------------- @@ -106,21 +106,21 @@ * *---------------------------------------------------------------------------*/ -// 12345678901234 +/* 12345678901234 */ char signature[14] = "FUPU7D37dhfwci"; -//The binary download function "relocates" the image using constructions like: -// fw->identity = (CFG_IDENTITY_STRCT FAR *)((char FAR *)fw->identity + (hcf_32)fw ); -//under some of the memory models under MSVC 1.52 these constructions degrade to 16-bits pointer arithmetic. -//fw->identity is limited, such that adding it to fw, does not need to carry over from offset to segment. -//However the segment is not set at all. -//As a workaround the PSEUDO_CHARP macro is introduced which is a char pointer except for MSVC 1.52, in -//which case we know that a 32-bit quantity is adequate as a pointer. -//Note that other platforms may experience comparable problems when using the binary download feature. -#if defined(_MSC_VER) && _MSC_VER == 800 // Visual C++ 1.5 +/* The binary download function "relocates" the image using constructions like: + fw->identity = (CFG_IDENTITY_STRCT FAR *)((char FAR *)fw->identity + (hcf_32)fw ); + under some of the memory models under MSVC 1.52 these constructions degrade to 16-bits pointer arithmetic. + fw->identity is limited, such that adding it to fw, does not need to carry over from offset to segment. + However the segment is not set at all. + As a workaround the PSEUDO_CHARP macro is introduced which is a char pointer except for MSVC 1.52, in + which case we know that a 32-bit quantity is adequate as a pointer. + Note that other platforms may experience comparable problems when using the binary download feature. */ +#if defined(_MSC_VER) && _MSC_VER == 800 /* Visual C++ 1.5 */ #define PSEUDO_CHARP hcf_32 #else -#define PSEUDO_CHARP hcf_8* +#define PSEUDO_CHARP (hcf_8 *) #endif /*----------------------------------------------------------------------------- @@ -132,12 +132,12 @@ char signature[14] = "FUPU7D37dhfwci"; * *---------------------------------------------------------------------------*/ -// for USB/H1 we needed a smaller value than the CFG_DL_BUF_STRCT reported 8192 -// for the time being it seems simpler to always use 2000 for USB/H1 as well as all other cases rather than -// using the "fixed anyway" CFG_DL_BUF_STRCT. +/* for USB/H1 we needed a smaller value than the CFG_DL_BUF_STRCT reported 8192 + for the time being it seems simpler to always use 2000 for USB/H1 as well as all other cases rather than + using the "fixed anyway" CFG_DL_BUF_STRCT. */ #define DL_SIZE 2000 -//CFG_IDENTITY_STRCT pri_identity = { LOF(CFG_IDENTITY_STRCT), CFG_PRI_IDENTITY }; +/* CFG_IDENTITY_STRCT pri_identity = { LOF(CFG_IDENTITY_STRCT), CFG_PRI_IDENTITY }; */ CFG_SUP_RANGE_STRCT mfi_sup = { LOF(CFG_SUP_RANGE_STRCT), CFG_NIC_MFI_SUP_RANGE }; CFG_SUP_RANGE_STRCT cfi_sup = { LOF(CFG_SUP_RANGE_STRCT), CFG_NIC_CFI_SUP_RANGE }; /* Note: could be used rather than the above explained and defined DL_SIZE if need arises @@ -164,7 +164,7 @@ LTV_INFO_STRUCT ltv_info[] = { /***********************************************************************************************************/ /*************************************** PROTOTYPES ******************************************************/ /***********************************************************************************************************/ -static int check_comp_fw( memimage *fw ); +static int check_comp_fw(memimage *fw); /************************************************************************************************************ @@ -185,18 +185,18 @@ static int check_comp_fw( memimage *fw ); *.ENDDOC END DOCUMENTATION *************************************************************************************************************/ int -check_comp_fw( memimage *fw ) +check_comp_fw(memimage *fw) { CFG_RANGE20_STRCT *p; int rc = HCF_SUCCESS; -CFG_RANGE_SPEC_STRCT* i; +CFG_RANGE_SPEC_STRCT *i; - switch( fw->identity->typ ) { - case CFG_FW_IDENTITY: //Station F/W - case COMP_ID_FW_AP_FAKE: //;?is this useful (used to be: CFG_AP_IDENTITY) + switch (fw->identity->typ) { + case CFG_FW_IDENTITY: /* Station F/W */ + case COMP_ID_FW_AP_FAKE: /* ;?is this useful (used to be: CFG_AP_IDENTITY) */ break; - default: - MMDASSERT( DO_ASSERT, fw->identity->typ ) //unknown/unsupported firmware_type: + default: + MMDASSERT(DO_ASSERT, fw->identity->typ) /* unknown/unsupported firmware_type: */ rc = DHF_ERR_INCOMP_FW; return rc; /* ;? how useful is this anyway, * till that is sorted out might as well violate my own single exit principle @@ -204,29 +204,29 @@ CFG_RANGE_SPEC_STRCT* i; } p = fw->compat; i = NULL; - while( p->len && i == NULL ) { // check the MFI ranges - if ( p->typ == CFG_MFI_ACT_RANGES_STA ) { - i = mmd_check_comp( (void*)p, &mfi_sup ); + while (p->len && i == NULL) { /* check the MFI ranges */ + if (p->typ == CFG_MFI_ACT_RANGES_STA) { + i = mmd_check_comp((void *)p, &mfi_sup); } p++; } - MMDASSERT( i, 0 ) //MFI: NIC Supplier not compatible with F/W image Actor - if ( i ) { + MMDASSERT(i, 0) /* MFI: NIC Supplier not compatible with F/W image Actor */ + if (i) { p = fw->compat; i = NULL; - while ( p->len && i == NULL ) { // check the CFI ranges - if ( p->typ == CFG_CFI_ACT_RANGES_STA ) { - i = mmd_check_comp( (void*)p, &cfi_sup ); + while (p->len && i == NULL) { /* check the CFI ranges */ + if (p->typ == CFG_CFI_ACT_RANGES_STA) { + i = mmd_check_comp((void *)p, &cfi_sup); } p++; } - MMDASSERT( i, 0 ) //CFI: NIC Supplier not compatible with F/W image Actor + MMDASSERT(i, 0) /* CFI: NIC Supplier not compatible with F/W image Actor */ } - if ( i == NULL ) { + if (i == NULL) { rc = DHF_ERR_INCOMP_FW; } return rc; -} // check_comp_fw +} /* check_comp_fw */ @@ -271,31 +271,34 @@ CFG_RANGE_SPEC_STRCT* i; *.ENDDOC END DOCUMENTATION *************************************************************************************************************/ int -dhf_download_binary( memimage *fw ) +dhf_download_binary(memimage *fw) { int rc = HCF_SUCCESS; CFG_PROG_STRCT *p; int i; - //validate the image - for ( i = 0; i < sizeof(signature) && fw->signature[i] == signature[i]; i++ ) /*NOP*/; - if ( i != sizeof(signature) || + /* validate the image */ + for (i = 0; i < sizeof(signature) && fw->signature[i] == signature[i]; i++) + ; /* NOP */ + if (i != sizeof(signature) || fw->signature[i] != 0x01 || - //test for Little/Big Endian Binary flag - fw->signature[i+1] != ( /*HCF_BIG_ENDIAN ? 'B' : */ 'L' ) ) rc = DHF_ERR_INCOMP_FW; - else { //Little Endian Binary format - fw->codep = (CFG_PROG_STRCT FAR *)((PSEUDO_CHARP)fw->codep + (hcf_32)fw ); - fw->identity = (CFG_IDENTITY_STRCT FAR *)((PSEUDO_CHARP)fw->identity + (hcf_32)fw ); - fw->compat = (CFG_RANGE20_STRCT FAR *)((PSEUDO_CHARP)fw->compat + (hcf_32)fw ); - for ( i = 0; fw->p[i]; i++ ) fw->p[i] = ((PSEUDO_CHARP)fw->p[i] + (hcf_32)fw ); + /* test for Little/Big Endian Binary flag */ + fw->signature[i+1] != (/* HCF_BIG_ENDIAN ? 'B' : */ 'L')) + rc = DHF_ERR_INCOMP_FW; + else { /* Little Endian Binary format */ + fw->codep = (CFG_PROG_STRCT FAR*)((PSEUDO_CHARP)fw->codep + (hcf_32)fw); + fw->identity = (CFG_IDENTITY_STRCT FAR*)((PSEUDO_CHARP)fw->identity + (hcf_32)fw); + fw->compat = (CFG_RANGE20_STRCT FAR*)((PSEUDO_CHARP)fw->compat + (hcf_32)fw); + for (i = 0; fw->p[i]; i++) + fw->p[i] = ((PSEUDO_CHARP)fw->p[i] + (hcf_32)fw); p = fw->codep; - while ( p->len ) { + while (p->len) { p->host_addr = (PSEUDO_CHARP)p->host_addr + (hcf_32)fw; p++; } } return rc; -} // dhf_download_binary +} /* dhf_download_binary */ /************************************************************************************************************* @@ -351,7 +354,7 @@ int i; *.ENDDOC END DOCUMENTATION *************************************************************************************************************/ int -dhf_download_fw( void *ifbp, memimage *fw ) +dhf_download_fw(void *ifbp, memimage *fw) { int rc = HCF_SUCCESS; LTV_INFO_STRUCT_PTR pp = ltv_info; @@ -359,32 +362,34 @@ CFG_PROG_STRCT *p = fw->codep; LTVP ltvp; int i; - MMDASSERT( fw != NULL, 0 ) - //validate the image - for ( i = 0; i < sizeof(signature) && fw->signature[i] == signature[i]; i++ ) /*NOP*/; - if ( i != sizeof(signature) || + MMDASSERT(fw != NULL, 0) + /* validate the image */ + for (i = 0; i < sizeof(signature) && fw->signature[i] == signature[i]; i++) + ; /* NOP */ + if (i != sizeof(signature) || fw->signature[i] != 0x01 || - //check for binary image - ( fw->signature[i+1] != 'C' && fw->signature[i+1] != ( /*HCF_BIG_ENDIAN ? 'B' : */ 'L' ) ) ) + /* check for binary image */ + (fw->signature[i+1] != 'C' && fw->signature[i+1] != (/*HCF_BIG_ENDIAN ? 'B' : */ 'L'))) rc = DHF_ERR_INCOMP_FW; -// Retrieve all information needed for download from the NIC - while ( ( rc == HCF_SUCCESS ) && ( ( ltvp = pp->ltvp) != NULL ) ) { - ltvp->len = pp++->len; // Set len to original len. This len is changed to real len by GET_INFO() - rc = GET_INFO( ltvp ); - MMDASSERT( rc == HCF_SUCCESS, rc ) - MMDASSERT( rc == HCF_SUCCESS, ltvp->typ ) - MMDASSERT( rc == HCF_SUCCESS, ltvp->len ) +/* Retrieve all information needed for download from the NIC */ + while ((rc == HCF_SUCCESS) && ((ltvp = pp->ltvp) != NULL)) { + ltvp->len = pp++->len; /* Set len to original len. This len is changed to real len by GET_INFO() */ + rc = GET_INFO(ltvp); + MMDASSERT(rc == HCF_SUCCESS, rc) + MMDASSERT(rc == HCF_SUCCESS, ltvp->typ) + MMDASSERT(rc == HCF_SUCCESS, ltvp->len) } - if ( rc == HCF_SUCCESS ) rc = check_comp_fw( fw ); - if ( rc == HCF_SUCCESS ) { - while ( rc == HCF_SUCCESS && p->len ) { - rc = PUT_INFO( p ); + if (rc == HCF_SUCCESS) + rc = check_comp_fw(fw); + if (rc == HCF_SUCCESS) { + while (rc == HCF_SUCCESS && p->len) { + rc = PUT_INFO(p); p++; } } - MMDASSERT( rc == HCF_SUCCESS, rc ) + MMDASSERT(rc == HCF_SUCCESS, rc) return rc; -} // dhf_download_fw +} /* dhf_download_fw */ diff --git a/drivers/staging/wlags49_h2/dhf.h b/drivers/staging/wlags49_h2/dhf.h index c071f342a655..dbe0611fd032 100644 --- a/drivers/staging/wlags49_h2/dhf.h +++ b/drivers/staging/wlags49_h2/dhf.h @@ -1,5 +1,5 @@ -// vim:tw=110:ts=4: +/* vim:tw=110:ts=4: */ #ifndef DHF_H #define DHF_H @@ -38,9 +38,9 @@ * software indicates your acceptance of these terms and conditions. If you do * not agree with these terms and conditions, do not use the software. * -* COPYRIGHT © 1994 - 1995 by AT&T. All Rights Reserved -* COPYRIGHT © 1999 - 2000 by Lucent Technologies. All Rights Reserved -* COPYRIGHT © 2001 - 2004 by Agere Systems Inc. All Rights Reserved +* COPYRIGHT (C) 1994 - 1995 by AT&T. All Rights Reserved +* COPYRIGHT (C) 1999 - 2000 by Lucent Technologies. All Rights Reserved +* COPYRIGHT (C) 2001 - 2004 by Agere Systems Inc. All Rights Reserved * All rights reserved. * * Redistribution and use in source or binary forms, with or without @@ -82,27 +82,27 @@ #include <windef.h> #endif -#include "hcf.h" // includes HCFCFG.H too +#include "hcf.h" /* includes HCFCFG.H too */ #ifdef DHF_UIL -#define GET_INFO( pp ) uil_get_info( (LTVP)pp ) -#define PUT_INFO( pp ) uil_put_info( (LTVP)pp ) +#define GET_INFO(pp) uil_get_info((LTVP)pp) +#define PUT_INFO(pp) uil_put_info((LTVP)pp) #else -#define GET_INFO( pp ) hcf_get_info( ifbp, (LTVP)pp ) -#define PUT_INFO( pp ) hcf_put_info( ifbp, (LTVP)pp ) +#define GET_INFO(pp) hcf_get_info(ifbp, (LTVP)pp) +#define PUT_INFO(pp) hcf_put_info(ifbp, (LTVP)pp) #endif /*---- Defines --------------------------------------------------------------*/ -#define CODEMASK 0x0000FFFFL // Codemask for plug records +#define CODEMASK 0x0000FFFFL /* Codemask for plug records */ /*---- Error numbers --------------------------------------------------------*/ -#define DHF_ERR_INCOMP_FW 0x40 //Image not compatible with NIC +#define DHF_ERR_INCOMP_FW 0x40 /* Image not compatible with NIC */ /*---- Type definitions -----------------------------------------------------*/ -//* needed by dhf_wrap.c -// +/* needed by dhf_wrap.c */ + typedef struct { LTVP ltvp; hcf_16 len; @@ -119,9 +119,9 @@ typedef struct { */ typedef struct { - hcf_32 code; // Code to plug - hcf_32 addr; // Address within the memory image to plug it in - hcf_32 len; // The # of bytes which are available to store it + hcf_32 code; /* Code to plug */ + hcf_32 addr; /* Address within the memory image to plug it in */ + hcf_32 len; /* The # of bytes which are available to store it */ } plugrecord; /* @@ -159,7 +159,7 @@ typedef struct { char str[MAX_DEBUGEXPORT_LEN]; } exportrecord; -// Offsets in memimage array p[] +/* Offsets in memimage array p[] */ #define FWSTRINGS_FUNCTION 0 #define FWEXPORTS_FUNCTION 1 @@ -188,13 +188,13 @@ typedef struct { * The end of the array is indicated by a plug record of which all fields are zero. */ typedef struct { - char signature[14+1+1]; // signature (see DHF.C) + C/LE-Bin/BE-Bin-flag + format version - CFG_PROG_STRCT FAR *codep; // - hcf_32 execution; // Execution address of the firmware - void FAR *place_holder_1; + char signature[14+1+1]; /* signature (see DHF.C) + C/LE-Bin/BE-Bin-flag + format version */ + CFG_PROG_STRCT FAR *codep; /* */ + hcf_32 execution; /* Execution address of the firmware */ + void FAR *place_holder_1; void FAR *place_holder_2; - CFG_RANGE20_STRCT FAR *compat; // Pointer to the compatibility info records - CFG_IDENTITY_STRCT FAR *identity; // Pointer to the identity info records + CFG_RANGE20_STRCT FAR *compat; /* Pointer to the compatibility info records */ + CFG_IDENTITY_STRCT FAR *identity; /* Pointer to the identity info records */ void FAR *p[2]; /* (Up to 9) pointers for (future) expansion * currently in use: * - F/W printf information @@ -209,8 +209,8 @@ typedef struct { * *---------------------------------------------------------------------------*/ -EXTERN_C int dhf_download_fw( void *ifbp, memimage *fw ); // ifbp, ignored when using the UIL -EXTERN_C int dhf_download_binary( memimage *fw ); +EXTERN_C int dhf_download_fw(void *ifbp, memimage *fw); /* ifbp, ignored when using the UIL */ +EXTERN_C int dhf_download_binary(memimage *fw); /*----------------------------------------------------------------------------- @@ -219,8 +219,8 @@ EXTERN_C int dhf_download_binary( memimage *fw ); * *---------------------------------------------------------------------------*/ -// defined in DHF.C; see there for comments -EXTERN_C hcf_16 *find_record_in_pda( hcf_16 *pdap, hcf_16 code ); +/* defined in DHF.C; see there for comments */ +EXTERN_C hcf_16 *find_record_in_pda(hcf_16 *pdap, hcf_16 code); -#endif // DHF_H +#endif /* DHF_H */ diff --git a/drivers/staging/wlags49_h2/dhfcfg.h b/drivers/staging/wlags49_h2/dhfcfg.h index a0c26c678c59..75c279f268ae 100644 --- a/drivers/staging/wlags49_h2/dhfcfg.h +++ b/drivers/staging/wlags49_h2/dhfcfg.h @@ -22,7 +22,7 @@ * software indicates your acceptance of these terms and conditions. If you do * not agree with these terms and conditions, do not use the software. * - * Copyright © 2003 Agere Systems Inc. + * Copyright (c) 2003 Agere Systems Inc. * All rights reserved. * * Redistribution and use in source or binary forms, with or without @@ -77,82 +77,82 @@ *---------------------------------------------------------------------------*/ -// Define DHF_WCI if you want to use the WCI to access the ORiNOCO card. -// Define DHF_UIL if you want to use the UIL to access the ORiNOCO card. -// You must define either DHF_WCI or DHF_UIL. If neither of the two is defined -// or both a compile error is generated. +/* Define DHF_WCI if you want to use the WCI to access the ORiNOCO card. + Define DHF_UIL if you want to use the UIL to access the ORiNOCO card. + You must define either DHF_WCI or DHF_UIL. If neither of the two is defined + or both a compile error is generated. */ #define DHF_WCI -//!!!#define DHF_UIL +/* !!!#define DHF_UIL */ -// Define DHF_BIG_ENDIAN if you are working on a big endian platform. -// Define DHF_LITTLE_ENDIAN if you are working on a little endian platform. -// You must define either DHF_BIG_ENDIAN or DHF_LITTLE_ENDIAN. If neither of -// the two is defined or both a compile error is generated. +/* Define DHF_BIG_ENDIAN if you are working on a big endian platform. + Define DHF_LITTLE_ENDIAN if you are working on a little endian platform. + You must define either DHF_BIG_ENDIAN or DHF_LITTLE_ENDIAN. If neither of + the two is defined or both a compile error is generated. */ #ifdef USE_BIG_ENDIAN #define DHF_BIG_ENDIAN #else #define DHF_LITTLE_ENDIAN #endif /* USE_BIG_ENDIAN */ -// Define DHF_WIN if you are working on Windows platform. -// Define DHF_DOS if you are working on DOS. -// You must define either DHF_WIN or DHF_DOS. If neither of -// the two is defined or both a compile error is generated. -//!!!#define DHF_WIN -//!!!#define DHF_DOS +/* Define DHF_WIN if you are working on Windows platform. + Define DHF_DOS if you are working on DOS. + You must define either DHF_WIN or DHF_DOS. If neither of + the two is defined or both a compile error is generated. + !!!#define DHF_WIN + !!!#define DHF_DOS */ -// Define if you want the DHF to users. Not defining DHF_GET_RES_MSG -// leads to a decrease in code size as message strings are not included. -//!!!#define DHF_GET_RES_MSG +/* Define if you want the DHF to users. Not defining DHF_GET_RES_MSG + leads to a decrease in code size as message strings are not included. + !!!#define DHF_GET_RES_MSG */ -// Linux driver specific -// Prevent inclusion of stdlib.h and string.h +/* Linux driver specific + Prevent inclusion of stdlib.h and string.h */ #define _INC_STDLIB #define _INC_STRING -//----------------------------------------------------------------------------- -// Define one or more of the following DSF #defines if you want to implement -// the related DSF-function. Function dsf_callback must allways be implemented. -// See file DHF.H for prototypes of the functions. - -// Define DSF_ALLOC if you want to manage memory allocation and de-allocation -// for the DHF. If DSF_ALLOC is defined you must implement dsf_alloc and dsf_free. -//!!!#define DSF_ALLOC - -// Define DSF_CONFIRM if you want the DHF to ask the user for confirmation in a -// number of situations. If DSF_CONFIRM is defined you must implement dsf_confirm. -// Not defining DSF_CONFIRM leads to a decrease in code size as confirmation -// strings are not included. -//!!!#define DSF_CONFIRM - -// Define DSF_DEBUG_MESSAGE if you want debug messages added to your output. -// If you define DSF_DEBUG_MESSAGE then you must implement function -// dsf_debug_message. -//#define DSF_DEBUG_MESSAGE - -// Define DSF_ASSERT if you want asserts to be activated. -// If you define DSF_ASSERT then you must implement function dsf_assert. -//#define DBG 1 -//#define DSF_ASSERT - -// Define DSF_DBWIN if you want asserts and debug messages to be send to a debug -// window like SOFTICE or DebugView from SysInternals. -//!!!#define DSF_DBWIN -//!!! Not implemented yet! - -// Define DSF_VOLATILE_ONLY if you only wants to use valatile functions -// This is a typical setting for a AP and a driver. +/*----------------------------------------------------------------------------- + Define one or more of the following DSF #defines if you want to implement + the related DSF-function. Function dsf_callback must allways be implemented. + See file DHF.H for prototypes of the functions. */ + +/* Define DSF_ALLOC if you want to manage memory allocation and de-allocation + for the DHF. If DSF_ALLOC is defined you must implement dsf_alloc and dsf_free. + !!!#define DSF_ALLOC */ + +/* Define DSF_CONFIRM if you want the DHF to ask the user for confirmation in a + number of situations. If DSF_CONFIRM is defined you must implement dsf_confirm. + Not defining DSF_CONFIRM leads to a decrease in code size as confirmation + strings are not included. + !!!#define DSF_CONFIRM */ + +/* Define DSF_DEBUG_MESSAGE if you want debug messages added to your output. + If you define DSF_DEBUG_MESSAGE then you must implement function + dsf_debug_message. + #define DSF_DEBUG_MESSAGE */ + +/* Define DSF_ASSERT if you want asserts to be activated. + If you define DSF_ASSERT then you must implement function dsf_assert. + #define DBG 1 + #define DSF_ASSERT */ + +/* Define DSF_DBWIN if you want asserts and debug messages to be send to a debug + window like SOFTICE or DebugView from SysInternals. + !!!#define DSF_DBWIN + !!! Not implemented yet! */ + +/* Define DSF_VOLATILE_ONLY if you only wants to use valatile functions + This is a typical setting for a AP and a driver. */ #define DSF_VOLATILE_ONLY -// Define DSF_HERMESII if you want to use the DHF for the Hermes-II +/* Define DSF_HERMESII if you want to use the DHF for the Hermes-II */ #ifdef HERMES2 #define DSF_HERMESII #else #undef DSF_HERMESII -#endif // HERMES2 +#endif /* HERMES2 */ -// Define DSF_BINARY_FILE if you want to use the DHF in combination with -// reading the Firmware from a separate binary file. -//!!!#define DSF_BINARY_FILE +/* Define DSF_BINARY_FILE if you want to use the DHF in combination with + reading the Firmware from a separate binary file. + !!!#define DSF_BINARY_FILE */ -#endif // DHFCFG_H +#endif /* DHFCFG_H */ diff --git a/drivers/staging/wlags49_h2/hcf.c b/drivers/staging/wlags49_h2/hcf.c index 6e39f5081e27..390628c6c1eb 100644 --- a/drivers/staging/wlags49_h2/hcf.c +++ b/drivers/staging/wlags49_h2/hcf.c @@ -990,7 +990,8 @@ int rc = HCF_ERR_INCOMP_FW; ifbp->IFB_CntlOpt |= DMA_ENABLED; HCFASSERT( NT_ASSERT, NEVER_TESTED ) // make the entire rx descriptor chain DMA-owned, so the DMA engine can (re-)use it. - if ( ( p = ifbp->IFB_FirstDesc[DMA_RX] ) != NULL ) { //;? Think this over again in the light of the new chaining strategy + p = ifbp->IFB_FirstDesc[DMA_RX]; + if (p != NULL) { //;? Think this over again in the light of the new chaining strategy if ( 1 ) { //begin alternative HCFASSERT( NT_ASSERT, NEVER_TESTED ) put_frame_lst( ifbp, ifbp->IFB_FirstDesc[DMA_RX], DMA_RX ); @@ -2087,7 +2088,8 @@ wci_bufp pt; //pointer with the "right" type, just to help ease writing macr OPW( HREG_AUX_OFFSET, (hcf_16)(PLUG_DATA_OFFSET & 0x7E) ); io_port = ifbp->IFB_IOBase + HREG_AUX_DATA; //to prevent side effects of the MSF-defined macro p = ltvp->val; //destination char pointer (in LTV record) - if ( ( i = len - 1 ) > 0 ) { + i = len - 1; + if (i > 0 ) { pt = (wci_bufp)p; //just to help ease writing macros with embedded assembly IN_PORT_STRING_8_16( io_port, pt, i ); //space used by T: -1 } @@ -2674,7 +2676,8 @@ hcf_16 fid = 0; #if (HCF_EXT) & HCF_EXT_TX_CONT // Continuous transmit test if ( tx_cntl == HFS_TX_CNTL_TX_CONT ) { - if ( ( fid = get_fid( ifbp ) ) != 0 ) { + fid = get_fid(ifbp); + if (fid != 0 ) { //setup BAP to begin of TxFS (void)setup_bap( ifbp, fid, 0, IO_OUT ); //copy all the fragments in a transparent fashion @@ -2700,7 +2703,8 @@ hcf_16 fid = 0; #if (HCF_TYPE) & HCF_TYPE_WPA tx_cntl |= ifbp->IFB_MICTxCntl; #endif // HCF_TYPE_WPA - if ( (fid = ifbp->IFB_TxFID) == 0 && ( fid = get_fid( ifbp ) ) != 0 ) /* 4 */ + fid = ifbp->IFB_TxFID; + if (fid == 0 && ( fid = get_fid( ifbp ) ) != 0 ) /* 4 */ /* skip the next compound statement if: - pre-put message or - no fid available (which should never occur if the MSF adheres to the WCI) @@ -4860,7 +4864,8 @@ PROT_CNT_INI int rc; HCFTRACE( ifbp, HCF_TRACE_STRIO ); - if ( ( rc = ifbp->IFB_DefunctStat ) == HCF_SUCCESS ) { /*2*/ + rc = ifbp->IFB_DefunctStat; + if (rc == HCF_SUCCESS) { /*2*/ OPW( HREG_SELECT_1, fid ); /*4*/ OPW( HREG_OFFSET_1, offset ); if ( type == IO_IN ) { diff --git a/drivers/staging/wlags49_h2/wl_main.c b/drivers/staging/wlags49_h2/wl_main.c index cf0c38468b20..88d0d472142f 100644 --- a/drivers/staging/wlags49_h2/wl_main.c +++ b/drivers/staging/wlags49_h2/wl_main.c @@ -3591,7 +3591,8 @@ int scull_read_procmem(char *buf, char **start, off_t offset, int len, int *eof, len=0; - if ( ( lp = ((struct net_device *)data)->priv ) == NULL ) { + lp = ((struct net_device *)data)->priv; + if (lp == NULL) { len += sprintf(buf+len,"No wl_private in scull_read_procmem\n" ); } else if ( lp->wlags49_type == 0 ){ ifbp = &lp->hcfCtx; diff --git a/drivers/staging/wlags49_h2/wl_netdev.c b/drivers/staging/wlags49_h2/wl_netdev.c index ca8c8b134c4e..b61677a2c740 100644 --- a/drivers/staging/wlags49_h2/wl_netdev.c +++ b/drivers/staging/wlags49_h2/wl_netdev.c @@ -930,8 +930,10 @@ int wl_rx(struct net_device *dev) port = ( hfs_stat >> 8 ) & 0x0007; DBG_RX( DbgInfo, "Rx frame for port %d\n", port ); - if(( pktlen = lp->hcfCtx.IFB_RxLen ) != 0 ) { - if(( skb = ALLOC_SKB( pktlen )) != NULL ) { + pktlen = lp->hcfCtx.IFB_RxLen; + if (pktlen != 0) { + skb = ALLOC_SKB(pktlen); + if (skb != NULL) { /* Set the netdev based on the port */ switch( port ) { #ifdef USE_WDS @@ -1995,8 +1997,10 @@ int wl_rx_dma( struct net_device *dev ) port = ( hfs_stat >> 8 ) & 0x0007; DBG_RX( DbgInfo, "Rx frame for port %d\n", port ); - if(( pktlen = GET_BUF_CNT( desc_next )) != 0 ) { - if(( skb = ALLOC_SKB( pktlen )) != NULL ) { + pktlen = GET_BUF_CNT(desc_next); + if (pktlen != 0) { + skb = ALLOC_SKB(pktlen); + if (skb != NULL) { switch( port ) { #ifdef USE_WDS case 1: diff --git a/drivers/staging/wlags49_h2/wl_priv.c b/drivers/staging/wlags49_h2/wl_priv.c index 727ea8a483af..a67ff529d359 100644 --- a/drivers/staging/wlags49_h2/wl_priv.c +++ b/drivers/staging/wlags49_h2/wl_priv.c @@ -503,7 +503,8 @@ int wvlan_uil_send_diag_msg( struct uilreq *urq, struct wl_private *lp ) return result; } - if ((data = kmalloc(urq->len, GFP_KERNEL)) != NULL) { + data = kmalloc(urq->len, GFP_KERNEL); + if (data != NULL) { memset( Descp, 0, sizeof( DESC_STRCT )); memcpy( data, urq->data, urq->len ); @@ -617,7 +618,8 @@ int wvlan_uil_put_info( struct uilreq *urq, struct wl_private *lp ) LTV record, try to allocate it from the kernel stack. Otherwise, we just use our local LTV record. */ if( urq->len > sizeof( lp->ltvRecord )) { - if(( pLtv = (ltv_t *)kmalloc( urq->len, GFP_KERNEL )) != NULL ) { + pLtv = (ltv_t *)kmalloc( urq->len, GFP_KERNEL ); + if (pLtv != NULL) { ltvAllocated = TRUE; } else { DBG_ERROR( DbgInfo, "Alloc FAILED\n" ); @@ -1296,7 +1298,8 @@ int wvlan_uil_get_info( struct uilreq *urq, struct wl_private *lp ) LTV record, try to allocate it from the kernel stack. Otherwise, we just use our local LTV record. */ if( urq->len > sizeof( lp->ltvRecord )) { - if(( pLtv = (ltv_t *)kmalloc( urq->len, GFP_KERNEL )) != NULL ) { + pLtv = (ltv_t *)kmalloc( urq->len, GFP_KERNEL ); + if (pLtv != NULL) { ltvAllocated = TRUE; /* Copy the command/length information into the new buffer. */ diff --git a/drivers/staging/wlags49_h2/wl_sysfs.c b/drivers/staging/wlags49_h2/wl_sysfs.c index 864e01a736c8..e4c8804ac37d 100644 --- a/drivers/staging/wlags49_h2/wl_sysfs.c +++ b/drivers/staging/wlags49_h2/wl_sysfs.c @@ -46,7 +46,8 @@ static ssize_t show_tallies(struct device *d, struct device_attribute *attr, if (dev_isalive(dev)) { wl_lock(lp, &flags); - if ((ret = wl_get_tallies(lp, &tallies)) == 0) { + ret = wl_get_tallies(lp, &tallies); + if (ret == 0) { wl_unlock(lp, &flags); ret = snprintf(buf, PAGE_SIZE, "TxUnicastFrames: %u\n" diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index 5df56f0238d6..a41db5dc8c7c 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -62,9 +62,9 @@ * * hfa384x_drvr_xxxconfig An example of the drvr level abstraction. These * functions are wrappers for the RID get/set -* sequence. They call copy_[to|from]_bap() and -* cmd_access(). These functions operate on the -* RIDs and buffers without validation. The caller +* sequence. They call copy_[to|from]_bap() and +* cmd_access(). These functions operate on the +* RIDs and buffers without validation. The caller * is responsible for that. * * API wrapper functions: @@ -144,7 +144,6 @@ enum cmd_mode { DOWAIT = 0, DOASYNC }; -typedef enum cmd_mode CMD_MODE; #define THROTTLE_JIFFIES (HZ/8) #define URB_ASYNC_UNLINK 0 @@ -206,12 +205,11 @@ static void unlocked_usbctlx_complete(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx); struct usbctlx_completor { int (*complete) (struct usbctlx_completor *); }; -typedef struct usbctlx_completor usbctlx_completor_t; static int hfa384x_usbctlx_complete_sync(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx, - usbctlx_completor_t *completor); + struct usbctlx_completor *completor); static int unlocked_usbctlx_cancel_async(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx); @@ -232,13 +230,13 @@ usbctlx_get_rridresult(const hfa384x_usb_rridresp_t *rridresp, /* Low level req/resp CTLX formatters and submitters */ static int hfa384x_docmd(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, hfa384x_metacmd_t *cmd, ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data); static int hfa384x_dorrid(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 rid, void *riddata, unsigned int riddatalen, @@ -246,7 +244,7 @@ hfa384x_dorrid(hfa384x_t *hw, static int hfa384x_dowrid(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 rid, void *riddata, unsigned int riddatalen, @@ -254,7 +252,7 @@ hfa384x_dowrid(hfa384x_t *hw, static int hfa384x_dormem(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 page, u16 offset, void *data, @@ -263,7 +261,7 @@ hfa384x_dormem(hfa384x_t *hw, static int hfa384x_dowmem(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 page, u16 offset, void *data, @@ -351,7 +349,8 @@ static int submit_rx_urb(hfa384x_t *hw, gfp_t memflags) hw->rx_urb_skb = skb; result = -ENOLINK; - if (!hw->wlandev->hwremoved && !test_bit(WORK_RX_HALT, &hw->usb_flags)) { + if (!hw->wlandev->hwremoved && + !test_bit(WORK_RX_HALT, &hw->usb_flags)) { result = SUBMIT_URB(&hw->rx_urb, memflags); /* Check whether we need to reset the RX pipe */ @@ -451,7 +450,7 @@ static void hfa384x_usb_defer(struct work_struct *data) if (test_bit(WORK_RX_HALT, &hw->usb_flags)) { int ret; - usb_kill_urb(&hw->rx_urb); /* Cannot be holding spinlock! */ + usb_kill_urb(&hw->rx_urb); /* Cannot be holding spinlock! */ ret = usb_clear_halt(hw->usb, hw->endp_in); if (ret != 0) { @@ -668,26 +667,26 @@ usbctlx_get_rridresult(const hfa384x_usb_rridresp_t *rridresp, * when processing a CTLX that returns a hfa384x_cmdresult_t structure. ----------------------------------------------------------------*/ struct usbctlx_cmd_completor { - usbctlx_completor_t head; + struct usbctlx_completor head; const hfa384x_usb_cmdresp_t *cmdresp; hfa384x_cmdresult_t *result; }; -typedef struct usbctlx_cmd_completor usbctlx_cmd_completor_t; -static int usbctlx_cmd_completor_fn(usbctlx_completor_t *head) +static inline int usbctlx_cmd_completor_fn(struct usbctlx_completor *head) { - usbctlx_cmd_completor_t *complete = (usbctlx_cmd_completor_t *) head; + struct usbctlx_cmd_completor *complete; + + complete = (struct usbctlx_cmd_completor *) head; return usbctlx_get_status(complete->cmdresp, complete->result); } -static inline usbctlx_completor_t *init_cmd_completor(usbctlx_cmd_completor_t * - completor, - const - hfa384x_usb_cmdresp_t * - cmdresp, - hfa384x_cmdresult_t * - result) +static inline struct usbctlx_completor *init_cmd_completor( + struct usbctlx_cmd_completor + *completor, + const hfa384x_usb_cmdresp_t + *cmdresp, + hfa384x_cmdresult_t *result) { completor->head.complete = usbctlx_cmd_completor_fn; completor->cmdresp = cmdresp; @@ -701,19 +700,19 @@ static inline usbctlx_completor_t *init_cmd_completor(usbctlx_cmd_completor_t * * when processing a CTLX that reads a RID. ----------------------------------------------------------------*/ struct usbctlx_rrid_completor { - usbctlx_completor_t head; + struct usbctlx_completor head; const hfa384x_usb_rridresp_t *rridresp; void *riddata; unsigned int riddatalen; }; -typedef struct usbctlx_rrid_completor usbctlx_rrid_completor_t; -static int usbctlx_rrid_completor_fn(usbctlx_completor_t *head) +static int usbctlx_rrid_completor_fn(struct usbctlx_completor *head) { - usbctlx_rrid_completor_t *complete = (usbctlx_rrid_completor_t *) head; + struct usbctlx_rrid_completor *complete; hfa384x_rridresult_t rridresult; + complete = (struct usbctlx_rrid_completor *) head; usbctlx_get_rridresult(complete->rridresp, &rridresult); /* Validate the length, note body len calculation in bytes */ @@ -729,12 +728,13 @@ static int usbctlx_rrid_completor_fn(usbctlx_completor_t *head) return 0; } -static inline usbctlx_completor_t *init_rrid_completor(usbctlx_rrid_completor_t - *completor, - const - hfa384x_usb_rridresp_t * - rridresp, void *riddata, - unsigned int riddatalen) +static inline struct usbctlx_completor *init_rrid_completor( + struct usbctlx_rrid_completor + *completor, + const hfa384x_usb_rridresp_t + *rridresp, + void *riddata, + unsigned int riddatalen) { completor->head.complete = usbctlx_rrid_completor_fn; completor->rridresp = rridresp; @@ -747,14 +747,14 @@ static inline usbctlx_completor_t *init_rrid_completor(usbctlx_rrid_completor_t * Completor object: * Interprets the results of a synchronous RID-write ----------------------------------------------------------------*/ -typedef usbctlx_cmd_completor_t usbctlx_wrid_completor_t; +typedef struct usbctlx_cmd_completor usbctlx_wrid_completor_t; #define init_wrid_completor init_cmd_completor /*---------------------------------------------------------------- * Completor object: * Interprets the results of a synchronous memory-write ----------------------------------------------------------------*/ -typedef usbctlx_cmd_completor_t usbctlx_wmem_completor_t; +typedef struct usbctlx_cmd_completor usbctlx_wmem_completor_t; #define init_wmem_completor init_cmd_completor /*---------------------------------------------------------------- @@ -762,7 +762,7 @@ typedef usbctlx_cmd_completor_t usbctlx_wmem_completor_t; * Interprets the results of a synchronous memory-read ----------------------------------------------------------------*/ struct usbctlx_rmem_completor { - usbctlx_completor_t head; + struct usbctlx_completor head; const hfa384x_usb_rmemresp_t *rmemresp; void *data; @@ -770,7 +770,7 @@ struct usbctlx_rmem_completor { }; typedef struct usbctlx_rmem_completor usbctlx_rmem_completor_t; -static int usbctlx_rmem_completor_fn(usbctlx_completor_t *head) +static int usbctlx_rmem_completor_fn(struct usbctlx_completor *head) { usbctlx_rmem_completor_t *complete = (usbctlx_rmem_completor_t *) head; @@ -779,11 +779,13 @@ static int usbctlx_rmem_completor_fn(usbctlx_completor_t *head) return 0; } -static inline usbctlx_completor_t *init_rmem_completor(usbctlx_rmem_completor_t - *completor, - hfa384x_usb_rmemresp_t - *rmemresp, void *data, - unsigned int len) +static inline struct usbctlx_completor *init_rmem_completor( + usbctlx_rmem_completor_t + *completor, + hfa384x_usb_rmemresp_t + *rmemresp, + void *data, + unsigned int len) { completor->head.complete = usbctlx_rmem_completor_fn; completor->rmemresp = rmemresp; @@ -1226,7 +1228,7 @@ int hfa384x_corereset(hfa384x_t *hw, int holdtime, int settletime, int genesis) * * Arguments: * hw device structure -* ctlx CTLX ptr +* ctlx CTLX ptr * completor functor object to decide what to * do with the CTLX's result. * @@ -1244,7 +1246,7 @@ int hfa384x_corereset(hfa384x_t *hw, int holdtime, int settletime, int genesis) ----------------------------------------------------------------*/ static int hfa384x_usbctlx_complete_sync(hfa384x_t *hw, hfa384x_usbctlx_t *ctlx, - usbctlx_completor_t *completor) + struct usbctlx_completor *completor) { unsigned long flags; int result; @@ -1359,7 +1361,7 @@ cleanup: ----------------------------------------------------------------*/ static int hfa384x_docmd(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, hfa384x_metacmd_t *cmd, ctlx_cmdcb_t cmdcb, ctlx_usercb_t usercb, void *usercb_data) { @@ -1394,7 +1396,7 @@ hfa384x_docmd(hfa384x_t *hw, if (result != 0) { kfree(ctlx); } else if (mode == DOWAIT) { - usbctlx_cmd_completor_t completor; + struct usbctlx_cmd_completor completor; result = hfa384x_usbctlx_complete_sync(hw, ctlx, @@ -1448,7 +1450,7 @@ done: ----------------------------------------------------------------*/ static int hfa384x_dorrid(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 rid, void *riddata, unsigned int riddatalen, @@ -1481,7 +1483,7 @@ hfa384x_dorrid(hfa384x_t *hw, if (result != 0) { kfree(ctlx); } else if (mode == DOWAIT) { - usbctlx_rrid_completor_t completor; + struct usbctlx_rrid_completor completor; result = hfa384x_usbctlx_complete_sync(hw, ctlx, @@ -1506,7 +1508,7 @@ done: * * Arguments: * hw device structure -* CMD_MODE DOWAIT or DOASYNC +* enum cmd_mode DOWAIT or DOASYNC * rid RID code * riddata Data portion of RID formatted for MAC * riddatalen Length of the data portion in bytes @@ -1529,7 +1531,7 @@ done: ----------------------------------------------------------------*/ static int hfa384x_dowrid(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 rid, void *riddata, unsigned int riddatalen, @@ -1616,7 +1618,7 @@ done: ----------------------------------------------------------------*/ static int hfa384x_dormem(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 page, u16 offset, void *data, @@ -1707,7 +1709,7 @@ done: ----------------------------------------------------------------*/ static int hfa384x_dowmem(hfa384x_t *hw, - CMD_MODE mode, + enum cmd_mode mode, u16 page, u16 offset, void *data, @@ -2075,12 +2077,9 @@ int hfa384x_drvr_flashdl_write(hfa384x_t *hw, u32 daddr, void *buf, u32 len) (j * HFA384x_USB_RWMEM_MAXLEN); writepage = HFA384x_ADDR_CMD_MKPAGE(dlbufaddr + - (j * - HFA384x_USB_RWMEM_MAXLEN)); - writeoffset = - HFA384x_ADDR_CMD_MKOFF(dlbufaddr + - (j * - HFA384x_USB_RWMEM_MAXLEN)); + (j * HFA384x_USB_RWMEM_MAXLEN)); + writeoffset = HFA384x_ADDR_CMD_MKOFF(dlbufaddr + + (j * HFA384x_USB_RWMEM_MAXLEN)); writelen = burnlen - (j * HFA384x_USB_RWMEM_MAXLEN); writelen = writelen > HFA384x_USB_RWMEM_MAXLEN ? @@ -2133,7 +2132,7 @@ exit_proc: * 0 success * >0 f/w reported error - f/w status code * <0 driver reported error -* -ENODATA length mismatch between argument and retrieved +* -ENODATA length mismatch between argument and retrieved * record. * * Side effects: @@ -2451,7 +2450,9 @@ int hfa384x_drvr_readpda(hfa384x_t *hw, void *buf, unsigned int len) currpage = HFA384x_ADDR_CMD_MKPAGE(pdaloc[i].cardaddr); curroffset = HFA384x_ADDR_CMD_MKOFF(pdaloc[i].cardaddr); - result = hfa384x_dormem_wait(hw, currpage, curroffset, buf, len); /* units of bytes */ + /* units of bytes */ + result = hfa384x_dormem_wait(hw, currpage, curroffset, buf, + len); if (result) { printk(KERN_WARNING @@ -2611,20 +2612,18 @@ int hfa384x_drvr_start(hfa384x_t *hw) if (result1 != 0) { if (result2 != 0) { printk(KERN_ERR - "cmd_initialize() failed on two attempts, results %d and %d\n", - result1, result2); + "cmd_initialize() failed on two attempts, results %d and %d\n", + result1, result2); usb_kill_urb(&hw->rx_urb); goto done; } else { pr_debug("First cmd_initialize() failed (result %d),\n", result1); - pr_debug - ("but second attempt succeeded. All should be ok\n"); + pr_debug("but second attempt succeeded. All should be ok\n"); } } else if (result2 != 0) { - printk(KERN_WARNING - "First cmd_initialize() succeeded, but second attempt failed (result=%d)\n", - result2); + printk(KERN_WARNING "First cmd_initialize() succeeded, but second attempt failed (result=%d)\n", + result2); printk(KERN_WARNING "Most likely the card will be functional\n"); goto done; @@ -3382,8 +3381,7 @@ retry: * our request has been acknowledged. Odd, * but our OUT URB is still alive... */ - pr_debug - ("Causality violation: please reboot Universe, or email linux-wlan-devel@lists.linux-wlan.com\n"); + pr_debug("Causality violation: please reboot Universe\n"); ctlx->state = CTLX_RESP_COMPLETE; break; @@ -3442,7 +3440,7 @@ static void hfa384x_usbin_txcompl(wlandevice_t *wlandev, { u16 status; - status = le16_to_cpu(usbin->type); /* yeah I know it says type... */ + status = le16_to_cpu(usbin->type); /* yeah I know it says type... */ /* Was there an error? */ if (HFA384x_TXSTATUS_ISERROR(status)) @@ -3583,7 +3581,7 @@ static void hfa384x_int_rxmonitor(wlandevice_t *wlandev, struct sk_buff *skb; hfa384x_t *hw = wlandev->priv; - /* Don't forget the status, time, and data_len fields are in host order */ + /* Remember the status, time, and data_len fields are in host order */ /* Figure out how big the frame is */ fc = le16_to_cpu(rxdesc->frame_control); hdrlen = p80211_headerlen(fc); @@ -3632,7 +3630,8 @@ static void hfa384x_int_rxmonitor(wlandevice_t *wlandev, caphdr->encoding = htonl(1); /* cck */ } - /* Copy the 802.11 header to the skb (ctl frames may be less than a full header) */ + /* Copy the 802.11 header to the skb + (ctl frames may be less than a full header) */ datap = skb_put(skb, hdrlen); memcpy(datap, &(rxdesc->frame_control), hdrlen); @@ -3644,7 +3643,8 @@ static void hfa384x_int_rxmonitor(wlandevice_t *wlandev, /* check for unencrypted stuff if WEP bit set. */ if (*(datap - hdrlen + 1) & 0x40) /* wep set */ if ((*(datap) == 0xaa) && (*(datap + 1) == 0xaa)) - *(datap - hdrlen + 1) &= 0xbf; /* clear wep; it's the 802.2 header! */ + /* clear wep; it's the 802.2 header! */ + *(datap - hdrlen + 1) &= 0xbf; } if (hw->sniff_fcs) { @@ -3846,9 +3846,9 @@ retry: default: /* This is NOT a valid CTLX "success" state! */ printk(KERN_ERR - "Illegal CTLX[%d] success state(%s, %d) in OUT URB\n", - le16_to_cpu(ctlx->outbuf.type), - ctlxstr(ctlx->state), urb->status); + "Illegal CTLX[%d] success state(%s, %d) in OUT URB\n", + le16_to_cpu(ctlx->outbuf.type), + ctlxstr(ctlx->state), urb->status); break; } /* switch */ } else { diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c index a1605fbc8092..71c3595fe830 100644 --- a/drivers/staging/wlan-ng/p80211conv.c +++ b/drivers/staging/wlan-ng/p80211conv.c @@ -208,7 +208,7 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv, p80211_wep->data = kmalloc(skb->len, GFP_ATOMIC); foo = wep_encrypt(wlandev, skb->data, p80211_wep->data, skb->len, - (wlandev->hostwep &HOSTWEP_DEFAULTKEY_MASK), + (wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK), p80211_wep->iv, p80211_wep->icv); if (foo) { printk(KERN_WARNING diff --git a/drivers/staging/wlan-ng/p80211req.c b/drivers/staging/wlan-ng/p80211req.c index e1e7bf1bf27c..207f080cfc9e 100644 --- a/drivers/staging/wlan-ng/p80211req.c +++ b/drivers/staging/wlan-ng/p80211req.c @@ -107,7 +107,8 @@ int p80211req_dorequest(wlandevice_t *wlandev, u8 *msgbuf) } /* Check Permissions */ - if (!capable(CAP_NET_ADMIN) && (msg->msgcode != DIDmsg_dot11req_mibget)) { + if (!capable(CAP_NET_ADMIN) && + (msg->msgcode != DIDmsg_dot11req_mibget)) { printk(KERN_ERR "%s: only dot11req_mibget allowed for non-root.\n", wlandev->name); @@ -128,7 +129,7 @@ int p80211req_dorequest(wlandevice_t *wlandev, u8 *msgbuf) wlandev->mlmerequest(wlandev, msg); clear_bit(1, &(wlandev->request_pending)); - return result; /* if result==0, msg->status still may contain an err */ + return result; /* if result==0, msg->status still may contain an err */ } /*---------------------------------------------------------------- diff --git a/drivers/staging/wlan-ng/p80211wext.c b/drivers/staging/wlan-ng/p80211wext.c index 83f1d6cd7991..387194d4a6eb 100644 --- a/drivers/staging/wlan-ng/p80211wext.c +++ b/drivers/staging/wlan-ng/p80211wext.c @@ -49,7 +49,6 @@ #include <linux/uaccess.h> #include <asm/byteorder.h> #include <linux/if_ether.h> -#include <linux/bitops.h> #include "p80211types.h" #include "p80211hdr.h" @@ -74,7 +73,7 @@ static u8 p80211_mhz_to_channel(u16 mhz) if (mhz >= 5000) return (mhz - 5000) / 5; - if (mhz == 2482) + if (mhz == 2484) return 14; if (mhz >= 2407) @@ -126,18 +125,38 @@ static int qual_as_percent(int snr) return 100; } -static int p80211wext_dorequest(wlandevice_t *wlandev, u32 did, u32 data) +static int p80211wext_setmib(wlandevice_t *wlandev, u32 did, u32 data) { p80211msg_dot11req_mibset_t msg; - p80211item_uint32_t mibitem; + 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; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); + 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; } @@ -263,32 +282,26 @@ static int p80211wext_giwfreq(netdevice_t *dev, struct iw_freq *freq, 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; - msg.msgcode = DIDmsg_dot11req_mibget; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); - + result = p80211wext_getmib(wlandev, + DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel, + &value); if (result) { err = -EFAULT; goto exit; } - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - if (mibitem.data > NUM_CHANNELS) { + if (value > NUM_CHANNELS) { err = -EFAULT; goto exit; } /* convert into frequency instead of a channel */ freq->e = 1; - freq->m = p80211_channel_to_mhz(mibitem.data, 0) * 100000; + freq->m = p80211_channel_to_mhz(value, 0) * 100000; exit: return err; @@ -299,28 +312,23 @@ static int p80211wext_siwfreq(netdevice_t *dev, struct iw_freq *freq, 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); + err = -EOPNOTSUPP; goto exit; } - msg.msgcode = DIDmsg_dot11req_mibset; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel; - mibitem.status = P80211ENUM_msgitem_status_data_ok; - if ((freq->e == 0) && (freq->m <= 1000)) - mibitem.data = freq->m; + value = freq->m; else - mibitem.data = p80211_mhz_to_channel(freq->m); + value = p80211_mhz_to_channel(freq->m); - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + result = p80211wext_setmib(wlandev, + DIDmib_dot11phy_dot11PhyDSSSTable_dot11CurrentChannel, + value); if (result) { err = -EFAULT; @@ -360,13 +368,11 @@ static int p80211wext_siwmode(netdevice_t *dev, __u32 *mode, char *extra) { wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; int result; int err = 0; if (!wlan_wext_write) { - err = (-EOPNOTSUPP); + err = -EOPNOTSUPP; goto exit; } @@ -397,16 +403,11 @@ static int p80211wext_siwmode(netdevice_t *dev, } /* Set Operation mode to the PORT TYPE RID */ - msg.msgcode = DIDmsg_dot11req_mibset; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = DIDmib_p2_p2Static_p2CnfPortType; - mibitem.data = (*mode == IW_MODE_ADHOC) ? 0 : 1; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); - + result = p80211wext_setmib(wlandev, + DIDmib_p2_p2Static_p2CnfPortType, + (*mode == IW_MODE_ADHOC) ? 0 : 1); if (result) err = -EFAULT; - exit: return err; } @@ -563,9 +564,9 @@ static int p80211wext_siwencode(netdevice_t *dev, /* Set current key number only if no keys are given */ if (erq->flags & IW_ENCODE_NOKEY) { result = - p80211wext_dorequest(wlandev, - DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, - i); + p80211wext_setmib(wlandev, + DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, + i); if (result) { err = -EFAULT; @@ -587,7 +588,6 @@ static int p80211wext_siwencode(netdevice_t *dev, -------------------------------------------------------------*/ 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); @@ -637,12 +637,12 @@ static int p80211wext_siwencode(netdevice_t *dev, /* Check the PrivacyInvoked flag */ if (erq->flags & IW_ENCODE_DISABLED) { result = - p80211wext_dorequest(wlandev, + p80211wext_setmib(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_false); } else { result = - p80211wext_dorequest(wlandev, + p80211wext_setmib(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_true); } @@ -661,12 +661,12 @@ static int p80211wext_siwencode(netdevice_t *dev, */ if (erq->flags & IW_ENCODE_RESTRICTED) { result = - p80211wext_dorequest(wlandev, + p80211wext_setmib(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_true); } else if (erq->flags & IW_ENCODE_OPEN) { result = - p80211wext_dorequest(wlandev, + p80211wext_setmib(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_false); } @@ -768,24 +768,16 @@ static int p80211wext_giwrate(netdevice_t *dev, 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; - msg.msgcode = DIDmsg_dot11req_mibget; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = DIDmib_p2_p2MAC_p2CurrentTxRate; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); - + result = p80211wext_getmib(wlandev, DIDmib_p2_p2MAC_p2CurrentTxRate, &value); if (result) { err = -EFAULT; goto exit; } - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - rrq->fixed = 0; /* can it change? */ rrq->disabled = 0; rrq->value = 0; @@ -795,7 +787,7 @@ static int p80211wext_giwrate(netdevice_t *dev, #define HFA384x_RATEBIT_5dot5 ((u16)4) #define HFA384x_RATEBIT_11 ((u16)8) - switch (mibitem.data) { + switch (value) { case HFA384x_RATEBIT_1: rrq->value = 1000000; break; @@ -820,25 +812,19 @@ static int p80211wext_giwrts(netdevice_t *dev, struct iw_param *rts, 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; - msg.msgcode = DIDmsg_dot11req_mibget; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); - + result = p80211wext_getmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold, + &value); if (result) { err = -EFAULT; goto exit; } - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - rts->value = mibitem.data; + rts->value = value; rts->disabled = (rts->value == 2347); rts->fixed = 1; @@ -851,27 +837,23 @@ static int p80211wext_siwrts(netdevice_t *dev, struct iw_param *rts, 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); + err = -EOPNOTSUPP; goto exit; } - msg.msgcode = DIDmsg_dot11req_mibget; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold; if (rts->disabled) - mibitem.data = 2347; + value = 2347; else - mibitem.data = rts->value; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + value = rts->value; + result = p80211wext_setmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11RTSThreshold, + value); if (result) { err = -EFAULT; goto exit; @@ -886,26 +868,19 @@ static int p80211wext_giwfrag(netdevice_t *dev, struct iw_param *frag, 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; - msg.msgcode = DIDmsg_dot11req_mibget; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = - DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); - + result = p80211wext_getmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold, + &value); if (result) { err = -EFAULT; goto exit; } - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - frag->value = mibitem.data; + frag->value = value; frag->disabled = (frag->value == 2346); frag->fixed = 1; @@ -918,28 +893,23 @@ static int p80211wext_siwfrag(netdevice_t *dev, struct iw_param *frag, char *extra) { wlandevice_t *wlandev = dev->ml_priv; - p80211item_uint32_t mibitem; - p80211msg_dot11req_mibset_t msg; int result; int err = 0; + int value; if (!wlan_wext_write) { err = (-EOPNOTSUPP); goto exit; } - msg.msgcode = DIDmsg_dot11req_mibset; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = - DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold; - if (frag->disabled) - mibitem.data = 2346; + value = 2346; else - mibitem.data = frag->value; + value = frag->value; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + result = p80211wext_setmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11FragmentationThreshold, + value); if (result) { err = -EFAULT; @@ -963,56 +933,40 @@ static int p80211wext_giwretry(netdevice_t *dev, 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; u16 shortretry, longretry, lifetime; + unsigned int value; - msg.msgcode = DIDmsg_dot11req_mibget; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); - + result = p80211wext_getmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit, + &value); if (result) { err = -EFAULT; goto exit; } - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - shortretry = mibitem.data; - - mibitem.did = DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + shortretry = value; + result = p80211wext_getmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit, + &value); if (result) { err = -EFAULT; goto exit; } - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - longretry = mibitem.data; - - mibitem.did = - DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + longretry = value; + result = p80211wext_getmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime, + &value); if (result) { err = -EFAULT; goto exit; } - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - - lifetime = mibitem.data; + lifetime = value; rrq->disabled = 0; @@ -1045,8 +999,7 @@ static int p80211wext_siwretry(netdevice_t *dev, p80211msg_dot11req_mibset_t msg; int result; int err = 0; - - memset(&mibitem, 0, sizeof(mibitem)); + unsigned int value; if (!wlan_wext_write) { err = (-EOPNOTSUPP); @@ -1061,26 +1014,20 @@ static int p80211wext_siwretry(netdevice_t *dev, msg.msgcode = DIDmsg_dot11req_mibset; if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { - mibitem.did = - DIDmib_dot11mac_dot11OperationTable_dot11MaxTransmitMSDULifetime; - mibitem.data = rrq->value /= 1024; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + 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) { - mibitem.did = - DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit; - mibitem.data = rrq->value; - - memcpy(&msg.mibattribute.data, &mibitem, - sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + result = p80211wext_setmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11LongRetryLimit, + rrq->value); if (result) { err = -EFAULT; @@ -1089,13 +1036,9 @@ static int p80211wext_siwretry(netdevice_t *dev, } if (rrq->flags & IW_RETRY_SHORT) { - mibitem.did = - DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit; - mibitem.data = rrq->value; - - memcpy(&msg.mibattribute.data, &mibitem, - sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + result = p80211wext_setmib(wlandev, + DIDmib_dot11mac_dot11OperationTable_dot11ShortRetryLimit, + rrq->value); if (result) { err = -EFAULT; @@ -1118,22 +1061,20 @@ static int p80211wext_siwtxpow(netdevice_t *dev, p80211msg_dot11req_mibset_t msg; int result; int err = 0; + unsigned int value; if (!wlan_wext_write) { err = (-EOPNOTSUPP); goto exit; } - msg.msgcode = DIDmsg_dot11req_mibset; - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = - DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel; if (rrq->fixed == 0) - mibitem.data = 30; + value = 30; else - mibitem.data = rrq->value; - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + value = rrq->value; + result = p80211wext_setmib(wlandev, + DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel, + value); if (result) { err = -EFAULT; @@ -1149,33 +1090,25 @@ static int p80211wext_giwtxpow(netdevice_t *dev, 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; - msg.msgcode = DIDmsg_dot11req_mibget; - - memset(&mibitem, 0, sizeof(mibitem)); - mibitem.did = - DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel; - - memcpy(&msg.mibattribute.data, &mibitem, sizeof(mibitem)); - result = p80211req_dorequest(wlandev, (u8 *) &msg); + result = p80211wext_getmib(wlandev, + DIDmib_dot11phy_dot11PhyTxPowerTable_dot11CurrentTxPowerLevel, + &value); if (result) { err = -EFAULT; goto exit; } - memcpy(&mibitem, &msg.mibattribute.data, sizeof(mibitem)); - /* XXX handle OFF by setting disabled = 1; */ rrq->flags = 0; /* IW_TXPOW_DBM; */ rrq->disabled = 0; rrq->fixed = 0; - rrq->value = mibitem.data; + rrq->value = value; exit: return err; @@ -1480,7 +1413,7 @@ static int p80211wext_set_encodeext(struct net_device *dev, } pr_debug("setting default key (%d)\n", idx); result = - p80211wext_dorequest(wlandev, + p80211wext_setmib(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, idx); if (result) @@ -1600,12 +1533,12 @@ static int p80211_wext_set_iwauth(struct net_device *dev, pr_debug("drop_unencrypted %d\n", param->value); if (param->value) result = - p80211wext_dorequest(wlandev, + p80211wext_setmib(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_true); else result = - p80211wext_dorequest(wlandev, + p80211wext_setmib(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_false); break; @@ -1614,12 +1547,12 @@ static int p80211_wext_set_iwauth(struct net_device *dev, pr_debug("privacy invoked %d\n", param->value); if (param->value) result = - p80211wext_dorequest(wlandev, + p80211wext_setmib(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_true); else result = - p80211wext_dorequest(wlandev, + p80211wext_setmib(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_false); @@ -1681,64 +1614,50 @@ static int p80211_wext_get_iwauth(struct net_device *dev, return result; } +#define IW_IOCTL(x) [(x)-SIOCSIWCOMMIT] + static iw_handler p80211wext_handlers[] = { - (iw_handler) p80211wext_siwcommit, /* SIOCSIWCOMMIT */ - (iw_handler) p80211wext_giwname, /* SIOCGIWNAME */ - (iw_handler) NULL, /* SIOCSIWNWID */ - (iw_handler) NULL, /* SIOCGIWNWID */ - (iw_handler) p80211wext_siwfreq, /* SIOCSIWFREQ */ - (iw_handler) p80211wext_giwfreq, /* SIOCGIWFREQ */ - (iw_handler) p80211wext_siwmode, /* SIOCSIWMODE */ - (iw_handler) p80211wext_giwmode, /* SIOCGIWMODE */ - (iw_handler) NULL, /* SIOCSIWSENS */ - (iw_handler) NULL, /* SIOCGIWSENS */ - (iw_handler) NULL, /* not used *//* SIOCSIWRANGE */ - (iw_handler) p80211wext_giwrange, /* SIOCGIWRANGE */ - (iw_handler) NULL, /* not used *//* SIOCSIWPRIV */ - (iw_handler) NULL, /* kernel code *//* SIOCGIWPRIV */ - (iw_handler) NULL, /* not used *//* SIOCSIWSTATS */ - (iw_handler) NULL, /* kernel code *//* SIOCGIWSTATS */ - (iw_handler) p80211wext_siwspy, /* SIOCSIWSPY */ - (iw_handler) p80211wext_giwspy, /* SIOCGIWSPY */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* SIOCSIWAP */ - (iw_handler) p80211wext_giwap, /* SIOCGIWAP */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* SIOCGIWAPLIST */ - (iw_handler) p80211wext_siwscan, /* SIOCSIWSCAN */ - (iw_handler) p80211wext_giwscan, /* SIOCGIWSCAN */ - (iw_handler) p80211wext_siwessid, /* SIOCSIWESSID */ - (iw_handler) p80211wext_giwessid, /* SIOCGIWESSID */ - (iw_handler) NULL, /* SIOCSIWNICKN */ - (iw_handler) p80211wext_giwessid, /* SIOCGIWNICKN */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* SIOCSIWRATE */ - (iw_handler) p80211wext_giwrate, /* SIOCGIWRATE */ - (iw_handler) p80211wext_siwrts, /* SIOCSIWRTS */ - (iw_handler) p80211wext_giwrts, /* SIOCGIWRTS */ - (iw_handler) p80211wext_siwfrag, /* SIOCSIWFRAG */ - (iw_handler) p80211wext_giwfrag, /* SIOCGIWFRAG */ - (iw_handler) p80211wext_siwtxpow, /* SIOCSIWTXPOW */ - (iw_handler) p80211wext_giwtxpow, /* SIOCGIWTXPOW */ - (iw_handler) p80211wext_siwretry, /* SIOCSIWRETRY */ - (iw_handler) p80211wext_giwretry, /* SIOCGIWRETRY */ - (iw_handler) p80211wext_siwencode, /* SIOCSIWENCODE */ - (iw_handler) p80211wext_giwencode, /* SIOCGIWENCODE */ - (iw_handler) NULL, /* SIOCSIWPOWER */ - (iw_handler) NULL, /* SIOCGIWPOWER */ + 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 */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* -- hole -- */ - (iw_handler) NULL, /* SIOCSIWGENIE set generic IE */ - (iw_handler) NULL, /* SIOCGIWGENIE get generic IE */ - (iw_handler) p80211_wext_set_iwauth, /* SIOCSIWAUTH set authentication mode params */ - (iw_handler) p80211_wext_get_iwauth, /* SIOCGIWAUTH get authentication mode params */ - - (iw_handler) p80211wext_set_encodeext, /* SIOCSIWENCODEEXT set encoding token & mode */ - (iw_handler) p80211wext_get_encodeext, /* SIOCGIWENCODEEXT get encoding token & mode */ - (iw_handler) NULL, /* SIOCSIWPMKSA PMKSA cache operation */ +/* 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 = { |